text_editor/keyboard: use new maple interface
This commit is contained in:
parent
9801557535
commit
643ad0e9fb
@ -27,6 +27,8 @@ void do_get_condition()
|
|||||||
auto [host_command, host_response]
|
auto [host_command, host_response]
|
||||||
= writer.append_command_all_ports<command_type, response_type>();
|
= writer.append_command_all_ports<command_type, response_type>();
|
||||||
|
|
||||||
|
host_command->bus_data.data_fields.function_type = std::byteswap(function_type::controller);
|
||||||
|
|
||||||
maple::dma_start(send_buf, writer.send_offset,
|
maple::dma_start(send_buf, writer.send_offset,
|
||||||
recv_buf, writer.recv_offset);
|
recv_buf, writer.recv_offset);
|
||||||
|
|
||||||
|
@ -145,28 +145,28 @@ static inline void _dma_start(const uint32_t * command_buf)
|
|||||||
maple_if.MDST = mdst::start_status::start;
|
maple_if.MDST = mdst::start_status::start;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dma_start(const uint32_t * command_buf,
|
void dma_start(const uint32_t * send_buf,
|
||||||
const uint32_t command_size,
|
const uint32_t send_size,
|
||||||
const uint32_t * receive_buf,
|
const uint32_t * recv_buf,
|
||||||
const uint32_t receive_size
|
const uint32_t recv_size
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// write back operand cache blocks for command buffer prior to starting DMA
|
// write back operand cache blocks for command buffer prior to starting DMA
|
||||||
for (uint32_t i = 0; i < align_32byte(command_size) / 32; i++) {
|
for (uint32_t i = 0; i < align_32byte(send_size) / 32; i++) {
|
||||||
asm volatile ("ocbwb @%0"
|
asm volatile ("ocbwb @%0"
|
||||||
: // output
|
: // output
|
||||||
: "r" (reinterpret_cast<uint32_t>(&command_buf[(32 * i) / 4])) // input
|
: "r" (reinterpret_cast<uint32_t>(&send_buf[(32 * i) / 4])) // input
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// start maple DMA
|
// start maple DMA
|
||||||
_dma_start(command_buf);
|
_dma_start(send_buf);
|
||||||
|
|
||||||
// purge operand cache block for receive buffer, prior to returning to the caller
|
// purge operand cache block for recv buffer, prior to returning to the caller
|
||||||
for (uint32_t i = 0; i < align_32byte(receive_size) / 32; i++) {
|
for (uint32_t i = 0; i < align_32byte(recv_size) / 32; i++) {
|
||||||
asm volatile ("ocbp @%0"
|
asm volatile ("ocbp @%0"
|
||||||
: // output
|
: // output
|
||||||
: "r" (reinterpret_cast<uint32_t>(&receive_buf[(32 * i) / 4])) // input
|
: "r" (reinterpret_cast<uint32_t>(&recv_buf[(32 * i) / 4])) // input
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,29 +34,9 @@ struct host_response {
|
|||||||
};
|
};
|
||||||
static_assert((sizeof (host_response<uint8_t[0]>)) == align_32byte((sizeof (host_response<uint8_t[0]>))));
|
static_assert((sizeof (host_response<uint8_t[0]>)) == align_32byte((sizeof (host_response<uint8_t[0]>))));
|
||||||
|
|
||||||
void init_host_command(uint32_t * buf, uint32_t * receive_buf,
|
void dma_start(uint32_t const * const command_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 command_size,
|
const uint32_t command_size,
|
||||||
const uint32_t * receive_buf,
|
uint32_t const * const receive_buf,
|
||||||
const uint32_t receive_size
|
const uint32_t receive_size
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -3,36 +3,35 @@
|
|||||||
#include "maple/maple_bus_ft6_key_scan_codes.hpp"
|
#include "maple/maple_bus_ft6_key_scan_codes.hpp"
|
||||||
#include "maple/maple_bus_commands.hpp"
|
#include "maple/maple_bus_commands.hpp"
|
||||||
#include "maple/maple_bus_bits.hpp"
|
#include "maple/maple_bus_bits.hpp"
|
||||||
#include "maple/maple_impl.hpp"
|
#include "maple/maple_host_command_writer.hpp"
|
||||||
|
|
||||||
#include "sh7091/serial.hpp"
|
#include "sh7091/serial.hpp"
|
||||||
|
|
||||||
#include "keyboard.hpp"
|
#include "keyboard.hpp"
|
||||||
|
|
||||||
void keyboard_do_get_condition(uint32_t * command_buf,
|
void keyboard_do_get_condition(ft6::data_transfer::data_format& data)
|
||||||
uint32_t * receive_buf,
|
|
||||||
ft6::data_transfer::data_format& data)
|
|
||||||
{
|
{
|
||||||
|
uint32_t send_buf[1024] __attribute__((aligned(32)));
|
||||||
|
uint32_t recv_buf[1024] __attribute__((aligned(32)));
|
||||||
|
|
||||||
|
auto writer = maple::host_command_writer(send_buf, recv_buf);
|
||||||
|
|
||||||
using command_type = get_condition;
|
using command_type = get_condition;
|
||||||
using response_type = data_transfer<ft6::data_transfer::data_format>;
|
using response_type = data_transfer<ft6::data_transfer::data_format>;
|
||||||
|
|
||||||
get_condition::data_fields data_fields = {
|
auto [host_command, host_response]
|
||||||
.function_type = std::byteswap(function_type::keyboard)
|
= writer.append_command_all_ports<command_type, response_type>();
|
||||||
};
|
host_command->bus_data.data_fields.function_type = std::byteswap(function_type::keyboard);
|
||||||
|
|
||||||
const uint32_t command_size = maple::init_host_command_all_ports<command_type, response_type>(command_buf, receive_buf, data_fields);
|
maple::dma_start(send_buf, writer.send_offset,
|
||||||
using host_response_type = struct maple::host_response<response_type::data_fields>;
|
recv_buf, writer.recv_offset);
|
||||||
auto host_response = reinterpret_cast<host_response_type *>(receive_buf);
|
|
||||||
|
|
||||||
maple::dma_start(command_buf, command_size,
|
|
||||||
receive_buf, maple::sizeof_command(host_response));
|
|
||||||
|
|
||||||
for (uint8_t port = 0; port < 4; port++) {
|
for (uint8_t port = 0; port < 4; port++) {
|
||||||
auto& bus_data = host_response[port].bus_data;
|
auto& bus_data = host_response[port].bus_data;
|
||||||
|
auto& data_fields = bus_data.data_fields;
|
||||||
if (bus_data.command_code != response_type::command_code) {
|
if (bus_data.command_code != response_type::command_code) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto& data_fields = bus_data.data_fields;
|
|
||||||
if ((data_fields.function_type & std::byteswap(function_type::keyboard)) == 0) {
|
if ((data_fields.function_type & std::byteswap(function_type::keyboard)) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
#include "maple/maple_bus_ft6.hpp"
|
#include "maple/maple_bus_ft6.hpp"
|
||||||
#include "gap_buffer.hpp"
|
#include "gap_buffer.hpp"
|
||||||
|
|
||||||
void keyboard_do_get_condition(uint32_t * command_buf,
|
void keyboard_do_get_condition(ft6::data_transfer::data_format& data);
|
||||||
uint32_t * receive_buf,
|
|
||||||
ft6::data_transfer::data_format& data);
|
|
||||||
|
|
||||||
void keyboard_debug(ft6::data_transfer::data_format * keyboards, uint32_t frame_ix);
|
void keyboard_debug(ft6::data_transfer::data_format * keyboards, uint32_t frame_ix);
|
||||||
|
|
||||||
|
@ -44,8 +44,6 @@ void inflate_font(const uint32_t * src,
|
|||||||
curve_end_ix);
|
curve_end_ix);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t _command_buf[(1024 + 32) / 4];
|
|
||||||
uint32_t _receive_buf[(1024 + 32) / 4];
|
|
||||||
uint32_t _ta_parameter_buf[((32 * 10 * 17) + 32) / 4];
|
uint32_t _ta_parameter_buf[((32 * 10 * 17) + 32) / 4];
|
||||||
|
|
||||||
struct editor_state {
|
struct editor_state {
|
||||||
@ -100,9 +98,6 @@ void main()
|
|||||||
|
|
||||||
uint32_t frame_ix = 0;
|
uint32_t frame_ix = 0;
|
||||||
|
|
||||||
uint32_t * command_buf = align_32byte(_command_buf);
|
|
||||||
uint32_t * receive_buf = align_32byte(_receive_buf);
|
|
||||||
|
|
||||||
struct editor_state state = { 0 };
|
struct editor_state state = { 0 };
|
||||||
gap_init_from_buf(state.gb, buf, buf_size, 0);
|
gap_init_from_buf(state.gb, buf, buf_size, 0);
|
||||||
line_init_from_buf(state.gb, offsets, offsets_size);
|
line_init_from_buf(state.gb, offsets, offsets_size);
|
||||||
@ -111,7 +106,7 @@ void main()
|
|||||||
ft6::data_transfer::data_format keyboards[2] = { 0 };
|
ft6::data_transfer::data_format keyboards[2] = { 0 };
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
keyboard_do_get_condition(command_buf, receive_buf, keyboards[frame_ix & 1]);
|
keyboard_do_get_condition(keyboards[frame_ix & 1]);
|
||||||
keyboard_debug(keyboards, frame_ix);
|
keyboard_debug(keyboards, frame_ix);
|
||||||
keyboard_update(keyboards, frame_ix, state.gb);
|
keyboard_update(keyboards, frame_ix, state.gb);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user