command: Fix handling of buffer passing in args[] on 64bit mcu

If the buffer pointer can't fit in a uint32_t then pass a relative
buffer offset instead.  This fixes buffer handling on 64bit linux
mcus.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2020-10-30 00:23:04 -04:00
parent 473828ca6a
commit a560432041
4 changed files with 17 additions and 0 deletions

View File

@ -18,12 +18,16 @@ static uint8_t next_sequence = MESSAGE_DEST;
static uint32_t
command_encode_ptr(void *p)
{
if (sizeof(size_t) > sizeof(uint32_t))
return p - console_receive_buffer();
return (size_t)p;
}
void *
command_decode_ptr(uint32_t v)
{
if (sizeof(size_t) > sizeof(uint32_t))
return console_receive_buffer() + v;
return (void*)(size_t)v;
}

View File

@ -6,6 +6,7 @@
struct command_encoder;
void console_sendf(const struct command_encoder *ce, va_list args);
void *console_receive_buffer(void);
uint32_t timer_from_us(uint32_t us);
uint8_t timer_is_before(uint32_t time1, uint32_t time2);

View File

@ -131,6 +131,12 @@ static struct task_wake console_wake;
static uint8_t receive_buf[4096];
static int receive_pos;
void *
console_receive_buffer(void)
{
return receive_buf;
}
// Process any incoming commands
void
console_task(void)

View File

@ -19,6 +19,12 @@ serial_init(void)
}
DECL_INIT(serial_init);
void *
console_receive_buffer(void)
{
return NULL;
}
static void
do_uart(void)
{