From the GCC manual. > GCC permits a C structure to have no members: struct empty { }; > The structure has size zero. In C++, empty structures are part of the > language. G++ treats empty structures as if they had a single member of type > char. I was not aware of the different behavior in C++. This fixes every maple example--most were broken for multiple reasons, including this one. This also enables SH4 caching. This includes linking code/data into the P1 area (previously this was not the case). The maple examples (which indeed involve much use of DMA) require much work to successfully work with the operand and copyback caches. The vibration example currently is the most complete, though I should consider more on how I want to structure maple response operand cache invalidation more generally.
60 lines
1.8 KiB
C++
60 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include "align.hpp"
|
|
|
|
namespace maple {
|
|
|
|
template <typename T>
|
|
struct host_command {
|
|
uint32_t host_instruction;
|
|
uint32_t receive_data_storage_address;
|
|
struct bus_data {
|
|
uint8_t command_code;
|
|
uint8_t destination_ap;
|
|
uint8_t source_ap;
|
|
uint8_t data_size;
|
|
T data_fields;
|
|
} bus_data;
|
|
};
|
|
static_assert((sizeof (host_command<uint8_t[0]>)) == 12);
|
|
static_assert((sizeof (host_command<uint8_t[0]>[4])) == 48);
|
|
|
|
template <typename T>
|
|
struct command_response {
|
|
struct bus_data {
|
|
uint8_t command_code;
|
|
uint8_t destination_ap;
|
|
uint8_t source_ap;
|
|
uint8_t data_size;
|
|
T data_fields;
|
|
} bus_data;
|
|
uint8_t _pad[align_32byte((sizeof (bus_data))) - (sizeof (bus_data))];
|
|
};
|
|
static_assert((sizeof (command_response<uint8_t[0]>)) == align_32byte((sizeof (command_response<uint8_t[0]>))));
|
|
|
|
void init_host_command(uint32_t * buf, uint32_t * receive_buf,
|
|
uint32_t destination_port,
|
|
uint8_t destination_ap, uint8_t command_code, uint8_t data_size,
|
|
bool end_flag);
|
|
|
|
uint32_t init_device_request(uint32_t * buf, uint32_t * receive_buf,
|
|
uint32_t destination_port,
|
|
uint8_t destination_ap);
|
|
|
|
uint32_t init_get_condition(uint32_t * buf, uint32_t * receive_buf,
|
|
uint32_t destination_port,
|
|
uint8_t destination_ap,
|
|
uint32_t function_type);
|
|
|
|
uint32_t init_block_write(uint32_t * buf, uint32_t * receive_buf,
|
|
uint32_t destination_port,
|
|
uint8_t destination_ap,
|
|
uint32_t * data,
|
|
uint32_t data_size);
|
|
|
|
void dma_start(const uint32_t * command_buf, const uint32_t size);
|
|
|
|
}
|