summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2022-11-01 11:40:30 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-04 15:44:26 +0000
commitd05099c826aed67f4b132c44d8e18a2fc1e6c489 (patch)
tree2298e9c5d718b8d6d17f372036415fa93532f247
parent62b71b15e13f41e5403c6d9abe216bf8c88af444 (diff)
downloadchrome-ec-d05099c826aed67f4b132c44d8e18a2fc1e6c489.tar.gz
libc/syscalls: Implement _write
All output goes to the UART. _write is used by printf(), so this allows printf() to work correctly. BRANCH=none BUG=b:234181908, b:254530679 TEST=./test/run_device_tests.py --board dartmonkey -t libc_printf Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I60a5f283975c21dabac395f00b4738a6db083d29 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3997615 Reviewed-by: Bobby Casey <bobbycasey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Andrea Grandi <agrandi@google.com>
-rw-r--r--libc/syscalls.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/libc/syscalls.c b/libc/syscalls.c
index 9c683a2732..43955a0ddd 100644
--- a/libc/syscalls.c
+++ b/libc/syscalls.c
@@ -14,6 +14,7 @@
#include "panic.h"
#include "software_panic.h"
#include "task.h"
+#include "uart.h"
/**
* Reboot the system.
@@ -27,3 +28,18 @@ void _exit(int rc)
panic_printf("%s called with rc: %d\n", __func__, rc);
software_panic(PANIC_SW_EXIT, task_get_current());
}
+
+/**
+ * Write to the UART.
+ *
+ * This function is called from libc functions such as printf().
+ *
+ * @param fd ignored
+ * @param buf buffer to write
+ * @param len number of bytes in @buf to write
+ * @return number of bytes successfully written
+ */
+int _write(int fd, char *buf, int len)
+{
+ return uart_put(buf, len);
+}