summaryrefslogtreecommitdiff
path: root/include/uart.h
diff options
context:
space:
mode:
authorWei-Han Chen <stimim@google.com>2018-08-16 11:47:58 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-08-20 21:43:06 -0700
commit3f19d870f81f062410e30d166848d47a2a20e5d9 (patch)
treeb8af51b5b8f312bbf25caa53e45c3385094589a0 /include/uart.h
parentb059ccdead89713485fc031faa622115d0839d57 (diff)
downloadchrome-ec-3f19d870f81f062410e30d166848d47a2a20e5d9.tar.gz
uart_buffering: expose interface to support non-host command
UART buffer could only be accessed by host command. For detachable devices, we don't want to enable all host commands. Refactor and expose an API to support accessing UART buffer directly, host command is not necessary. BRANCH=none BUG=b:70482333 TEST=tested on whiskers TEST=tested on nocturne Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: I8a9bbad23fbd3c02df54cd7b5d59b0e8376756ac Reviewed-on: https://chromium-review.googlesource.com/1177094 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'include/uart.h')
-rw-r--r--include/uart.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/uart.h b/include/uart.h
index d17b161ae5..e40b0e866f 100644
--- a/include/uart.h
+++ b/include/uart.h
@@ -300,4 +300,36 @@ int uart_alt_pad_write_read(uint8_t *tx, int tx_len, uint8_t *rx, int rx_len,
*/
void uart_default_pad_rx_interrupt(enum gpio_signal signal);
+/**
+ * Prepare for following `uart_console_read_buffer()` call. It will create a
+ * snapshot of current uart buffer.
+ *
+ * @return result status (EC_RES_*)
+ */
+int uart_console_read_buffer_init(void);
+
+/**
+ * Read from uart buffer.
+ *
+ * `uart_console_read_buffer_init()` must be called first.
+ *
+ * If `type` is CONSOLE_READ_NEXT, this will return data starting from the
+ * beginning of the last snapshot created by `uart_console_read_buffer_init()`.
+ *
+ * If `type` is CONSOLE_READ_RECENT, this will start from the end of the
+ * previous snapshot (so if current snapshot and previous snapshot has overlaps,
+ * only new content will be returned).
+ *
+ * @param type an ec_console_read_subcmd value.
+ * @param dest output buffer, it will be a null-terminated string.
+ * @param dest_size size of output buffer.
+ * @param write_count number of bytes written (including '\0').
+ *
+ * @return result status (EC_RES_*)
+ */
+int uart_console_read_buffer(uint8_t type,
+ char *dest,
+ uint16_t dest_size,
+ uint16_t *write_count);
+
#endif /* __CROS_EC_UART_H */