pru: Use a pointer when working with send_data array items
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
da3569c490
commit
c8dca0a56c
|
@ -22,15 +22,16 @@
|
|||
#define ALT_PRU_PTR(ptr) ((typeof(ptr))((uint32_t)(ptr) ^ 0x2000))
|
||||
|
||||
// Layout of shared memory
|
||||
struct shared_response_buffer {
|
||||
uint32_t count;
|
||||
char data[64];
|
||||
};
|
||||
struct shared_mem {
|
||||
uint32_t signal;
|
||||
const struct command_parser *next_command;
|
||||
uint32_t next_command_args[16];
|
||||
uint32_t send_push_pos, send_pop_pos;
|
||||
struct {
|
||||
uint32_t count;
|
||||
char data[64];
|
||||
} send_data[4];
|
||||
struct shared_response_buffer send_data[4];
|
||||
const struct command_parser *command_index;
|
||||
uint32_t command_index_size;
|
||||
const struct command_parser *shutdown_handler;
|
||||
|
|
|
@ -125,19 +125,16 @@ console_sendf(const struct command_encoder *ce, va_list args)
|
|||
{
|
||||
// Verify space for message
|
||||
uint32_t max_size = ce->max_size;
|
||||
if (max_size > sizeof(SHARED_MEM->send_data[0].data))
|
||||
return;
|
||||
uint32_t send_push_pos = SHARED_MEM->send_push_pos;
|
||||
if (readl(&SHARED_MEM->send_data[send_push_pos].count))
|
||||
// Queue full
|
||||
struct shared_response_buffer *s = &SHARED_MEM->send_data[send_push_pos];
|
||||
if (max_size > sizeof(s->data) || readl(&s->count))
|
||||
return;
|
||||
|
||||
// Generate message
|
||||
char *buf = SHARED_MEM->send_data[send_push_pos].data;
|
||||
uint32_t msglen = command_encodef(buf, max_size, ce, args);
|
||||
uint32_t msglen = command_encodef(s->data, max_size, ce, args);
|
||||
|
||||
// Signal PRU0 to transmit message
|
||||
writel(&SHARED_MEM->send_data[send_push_pos].count, msglen);
|
||||
writel(&s->count, msglen);
|
||||
write_r31(R31_WRITE_IRQ_SELECT | (KICK_PRU0_EVENT - R31_WRITE_IRQ_OFFSET));
|
||||
SHARED_MEM->send_push_pos = (
|
||||
(send_push_pos + 1) % ARRAY_SIZE(SHARED_MEM->send_data));
|
||||
|
|
|
@ -38,15 +38,14 @@ check_can_send(void)
|
|||
{
|
||||
for (;;) {
|
||||
uint32_t send_pop_pos = SHARED_MEM->send_pop_pos;
|
||||
uint32_t count = readl(&SHARED_MEM->send_data[send_pop_pos].count);
|
||||
struct shared_response_buffer *s = &SHARED_MEM->send_data[send_pop_pos];
|
||||
uint32_t count = readl(&s->count);
|
||||
if (!count)
|
||||
// Queue empty
|
||||
break;
|
||||
command_add_frame(SHARED_MEM->send_data[send_pop_pos].data, count);
|
||||
pru_rpmsg_send(
|
||||
&transport, CHAN_PORT, transport_dst
|
||||
, &SHARED_MEM->send_data[send_pop_pos].data, count);
|
||||
writel(&SHARED_MEM->send_data[send_pop_pos].count, 0);
|
||||
command_add_frame(s->data, count);
|
||||
pru_rpmsg_send(&transport, CHAN_PORT, transport_dst, &s->data, count);
|
||||
writel(&s->count, 0);
|
||||
SHARED_MEM->send_pop_pos = (
|
||||
(send_pop_pos + 1) % ARRAY_SIZE(SHARED_MEM->send_data));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue