From 69feeaf9d0438f3a52bcfe09d44999aea3dcdefa Mon Sep 17 00:00:00 2001 From: Sparchatus Date: Thu, 31 Mar 2022 12:53:38 +0000 Subject: [PATCH] Revert "Fix kernel bug in INIT_LX_SIZE" This reverts commit 16f26e8aa00f883b86854f34cc49b645e619bebb. --- lib/aos/aos_rpc.c | 62 +++++++---------------------------------------- 1 file changed, 9 insertions(+), 53 deletions(-) diff --git a/lib/aos/aos_rpc.c b/lib/aos/aos_rpc.c index d0072d0..652ec1e 100644 --- a/lib/aos/aos_rpc.c +++ b/lib/aos/aos_rpc.c @@ -126,78 +126,34 @@ aos_rpc_serial_putchar(struct aos_rpc *rpc, char c) { ); } -// putchar for terminal printing is too slow so we write buffers instead -// the corresponding interface does not know about errors, just partial writes -size_t +// putchar for terminal printing is too slow so we send buffers instead +errval_t aos_rpc_serial_write(struct aos_rpc *rpc, const char *buf, size_t buf_len) { errval_t err; // split the buffer into chunks for sending - size_t total_bytes = 0; while(buf_len > 0) { - size_t chunk_len = MIN(buf_len, RPC_SHARED_SIZE); + size_t chunk_len = buf_len; + if (chunk_len > RPC_SHARED_SIZE) { + chunk_len = RPC_SHARED_SIZE; + } memcpy(rpc->shared_mem, buf, chunk_len); - size_t written_bytes; err = do_aos_rpc( rpc, RPC_MTYPE_SERIAL_WRITE, NULL_CAP, chunk_len, 0, 0, - NULL, NULL, &written_bytes, NULL + NULL, NULL, NULL, NULL ); if (err_is_fail(err)) { - return total_bytes; - } - - total_bytes += written_bytes; - - // if the receiver was not able to write all we have given, return for now - if (written_bytes < chunk_len) { - return total_bytes; + return err; } buf += chunk_len; buf_len -= chunk_len; } - return total_bytes; -} - -// getchar for terminal reading is too slow so we read buffers instead -// the corresponding interface does not know about errors, just partial reads -size_t -aos_rpc_serial_read(struct aos_rpc *rpc, const char *buf, size_t buf_len) { - errval_t err; - - // split the buffer into chunks for reading - size_t total_bytes = 0; - while(buf_len > 0) { - size_t chunk_len = MIN(buf_len, RPC_SHARED_SIZE); - - memcpy(rpc->shared_mem, buf, chunk_len); - - size_t written_bytes; - err = do_aos_rpc( - rpc, RPC_MTYPE_SERIAL_WRITE, - NULL_CAP, chunk_len, 0, 0, - NULL, NULL, &written_bytes, NULL - ); - if (err_is_fail(err)) { - return total_bytes; - } - - total_bytes += written_bytes; - - // if the receiver was not able to write all we have given, return for now - if (written_bytes < chunk_len) { - return total_bytes; - } - - buf += chunk_len; - buf_len -= chunk_len; - } - - return total_bytes; + return SYS_ERR_OK; } errval_t