From 47513bd32c256c4f35e3a8ced7d9fd7e15903530 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Tue, 16 Feb 2021 20:38:53 -0500 Subject: terminal application with ipc, shift+pause state dumper, hello world for terminal, meminfo popup program --- src/user/knob/ipc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/user/knob/ipc.c') diff --git a/src/user/knob/ipc.c b/src/user/knob/ipc.c index dbf1a22..5ca4bb4 100644 --- a/src/user/knob/ipc.c +++ b/src/user/knob/ipc.c @@ -2,10 +2,12 @@ //blocking, returns early if other process is dead. //return value is number of bytes written. -uint32_t try_send_ipc(_task_handle_t to, void *buffer, uint32_t size) { +uint32_t try_send_ipc(_task_handle_t to, const void *buffer, uint32_t size) { const uint32_t size_backup = size; while (size) { + //syslogf("_ipc_send(0x%2h, 0x%h, %u)", to, buffer, size); uint32_t res = _ipc_send(to, size, buffer); + //syslogf("=> %u", res); if (!res) { _wait_ipc_read(to); _yield_task(); @@ -17,16 +19,19 @@ uint32_t try_send_ipc(_task_handle_t to, void *buffer, uint32_t size) { buffer += res; } } + return size_backup; } //blocking, returns early if other process is dead. //return value is number of bytes read. -uint32_t read_ipc(_task_handle_t from, void *buffer, uint32_t size) { +uint32_t try_read_ipc(_task_handle_t from, void *buffer, uint32_t size) { const uint32_t size_backup = size; while (size) { + //syslogf("_ipc_read(0x%2h, 0x%h, %u)", from, buffer, size); uint32_t res = _ipc_read(from, size, buffer); + //syslogf("=> %u", res); if (!res) { - _wait_ipc_send(from); + _wait_ipc_sent(from); _yield_task(); } else if (res == -1) @@ -36,6 +41,7 @@ uint32_t read_ipc(_task_handle_t from, void *buffer, uint32_t size) { buffer += res; } } + return size_backup; } void flush_ipc(_task_handle_t from) { -- cgit v1.2.3