maple: remove cruft from maple_wink
This also adds a new overload for align_32byte for integers.
This commit is contained in:
parent
5d1e2f7225
commit
9bd79c6664
@ -3,7 +3,12 @@
|
||||
#include <cstdint>
|
||||
|
||||
template <typename T>
|
||||
inline T * align_32byte(T * mem)
|
||||
constexpr inline T * align_32byte(T * mem)
|
||||
{
|
||||
return reinterpret_cast<T *>((((reinterpret_cast<uint32_t>(mem) + 31) & ~31)));
|
||||
}
|
||||
|
||||
constexpr inline uint32_t align_32byte(uint32_t mem)
|
||||
{
|
||||
return (mem + 31) & ~31;
|
||||
}
|
||||
|
@ -7,8 +7,8 @@
|
||||
constexpr uint32_t command_data_size = (sizeof (device_request::data_fields));
|
||||
constexpr uint32_t response_data_size = (sizeof (device_status::data_fields));
|
||||
|
||||
constexpr uint32_t host_command_size = ((sizeof (struct maple::host_command<device_request::data_fields>)));
|
||||
constexpr uint32_t command_response_size = ((sizeof (struct maple::command_response<device_status::data_fields>)) + 31) & ~31;
|
||||
constexpr uint32_t host_command_size = (sizeof (struct maple::host_command<device_request::data_fields>));
|
||||
constexpr uint32_t command_response_size = align_32byte((sizeof (struct maple::command_response<device_status::data_fields>)));
|
||||
|
||||
uint32_t _command_buf[host_command_size * 4 + 32] = {0};
|
||||
uint32_t _receive_buf[command_response_size * 4 + 32] = {0};
|
||||
|
@ -25,28 +25,26 @@ void make_wink(uint32_t * buf)
|
||||
}
|
||||
}
|
||||
|
||||
constexpr uint32_t width = 48;
|
||||
constexpr uint32_t height = 32;
|
||||
constexpr uint32_t pixels_per_byte = 8;
|
||||
constexpr uint32_t wink_size = width * height / pixels_per_byte;
|
||||
|
||||
void main()
|
||||
{
|
||||
constexpr int width = 48;
|
||||
constexpr int height = 32;
|
||||
constexpr int pixels_per_byte = 8;
|
||||
|
||||
uint32_t __attribute__((aligned(4))) wink_buf[(width * height / pixels_per_byte + 32) / 4];
|
||||
uint32_t wink_buf[wink_size / 4];
|
||||
make_wink(wink_buf);
|
||||
if ((((uint32_t)wink_buf) & 3) != 0) serial::string("misaligned\n");
|
||||
|
||||
uint32_t _command_buf[(1024 + 32) / 4];
|
||||
uint32_t _receive_buf[(1024 + 32) / 4];
|
||||
uint32_t * command_buf = align_32byte(_command_buf);
|
||||
uint32_t * receive_buf = align_32byte(_receive_buf);
|
||||
if ((((uint32_t)command_buf) & 31) != 0) serial::string("misaligned\n");
|
||||
if ((((uint32_t)receive_buf) & 31) != 0) serial::string("misaligned\n");
|
||||
|
||||
maple::init_block_write(command_buf, receive_buf,
|
||||
host_instruction::port_select::a,
|
||||
ap::de::expansion_device | ap::port_select::a | ap::lm_bus::_0,
|
||||
wink_buf,
|
||||
192);
|
||||
wink_size);
|
||||
maple::dma_start(command_buf);
|
||||
|
||||
for (int i = 0; i < 1; i++) {
|
||||
|
@ -1,10 +1,12 @@
|
||||
#include <cstdint>
|
||||
#include <bit>
|
||||
|
||||
#include "../sh7091.hpp"
|
||||
#include "../sh7091_bits.hpp"
|
||||
#include "../systembus.hpp"
|
||||
#include "../systembus_bits.hpp"
|
||||
#include "align.hpp"
|
||||
|
||||
#include "sh7091.hpp"
|
||||
#include "sh7091_bits.hpp"
|
||||
#include "systembus.hpp"
|
||||
#include "systembus_bits.hpp"
|
||||
|
||||
#include "maple_bits.hpp"
|
||||
#include "maple_bus_bits.hpp"
|
||||
@ -38,8 +40,8 @@ void init_host_command(uint32_t * command_buf, uint32_t * receive_buf,
|
||||
void init_host_command_all_ports(uint32_t * buf, uint32_t * receive_buf,
|
||||
uint8_t command_code, uint32_t command_data_size, uint32_t response_data_size)
|
||||
{
|
||||
const uint32_t command_size = (((sizeof (struct host_command<uint8_t[0]>)) + command_data_size));
|
||||
const uint32_t response_size = (((sizeof (struct command_response<uint8_t[0]>)) + response_data_size) + 31) & ~31;
|
||||
const uint32_t command_size = ((sizeof (struct host_command<uint8_t[0]>)) + command_data_size);
|
||||
const uint32_t response_size = align_32byte(((sizeof (struct command_response<uint8_t[0]>)) + response_data_size));
|
||||
|
||||
init_host_command(&buf[(command_size / 4) * 0], &receive_buf[(response_size / 4) * 0],
|
||||
host_instruction::port_select::a, // destination_port
|
||||
|
@ -128,8 +128,6 @@ namespace block_write {
|
||||
};
|
||||
|
||||
static_assert((sizeof (struct data_fields<char[0]>)) == 8);
|
||||
static_assert((offsetof (struct data_fields<char[0]>, written_data)) == 8);
|
||||
static_assert((offsetof (struct data_fields<char[192 / 4]>, written_data)) == 8);
|
||||
}
|
||||
|
||||
namespace get_last_error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user