diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2020-10-30 00:23:04 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2020-10-30 14:04:12 -0400 |
commit | a5604320418a13472940f4bdf11e56a9c197ff12 (patch) | |
tree | e79b17772a7454315052dfd1682b40f8e5968f4b /src | |
parent | 473828ca6aef18c574b8665ae484513e5592af03 (diff) | |
download | kutter-a5604320418a13472940f4bdf11e56a9c197ff12.tar.gz kutter-a5604320418a13472940f4bdf11e56a9c197ff12.tar.xz kutter-a5604320418a13472940f4bdf11e56a9c197ff12.zip |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/command.c | 4 | ||||
-rw-r--r-- | src/generic/misc.h | 1 | ||||
-rw-r--r-- | src/linux/console.c | 6 | ||||
-rw-r--r-- | src/simulator/serial.c | 6 |
4 files changed, 17 insertions, 0 deletions
diff --git a/src/command.c b/src/command.c index e3167baf..015cdb8e 100644 --- a/src/command.c +++ b/src/command.c @@ -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; } diff --git a/src/generic/misc.h b/src/generic/misc.h index 5e50633e..a24e8b0a 100644 --- a/src/generic/misc.h +++ b/src/generic/misc.h @@ -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); diff --git a/src/linux/console.c b/src/linux/console.c index 1c02b7a1..55688322 100644 --- a/src/linux/console.c +++ b/src/linux/console.c @@ -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) diff --git a/src/simulator/serial.c b/src/simulator/serial.c index d2d183f4..c8111acf 100644 --- a/src/simulator/serial.c +++ b/src/simulator/serial.c @@ -19,6 +19,12 @@ serial_init(void) } DECL_INIT(serial_init); +void * +console_receive_buffer(void) +{ + return NULL; +} + static void do_uart(void) { |