[sw] Delete uart.h
Signed-off-by: Miguel Young de la Sota <mcyoung@google.com>
diff --git a/sw/device/lib/meson.build b/sw/device/lib/meson.build
index d467cb6..8d3486d 100644
--- a/sw/device/lib/meson.build
+++ b/sw/device/lib/meson.build
@@ -6,23 +6,6 @@
subdir('arch')
subdir('dif')
subdir('runtime')
-
-# UART library (sw_lib_uart)
-sw_lib_uart = declare_dependency(
- link_with: static_library(
- 'uart_ot',
- sources: ['uart.c'],
- dependencies: [
- sw_lib_runtime_print,
- sw_lib_runtime_ibex,
- sw_lib_dif_uart,
- top_earlgrey,
- ],
- )
-)
-
-# NOTE: this needs to come *after* the UART library for now, until `test_main.c`
-# no longer depends on `uart.c`.
subdir('testing')
# Flash controller library (sw_lib_flash_ctrl)
diff --git a/sw/device/lib/uart.c b/sw/device/lib/uart.c
deleted file mode 100644
index 40f09ea..0000000
--- a/sw/device/lib/uart.c
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright lowRISC contributors.
-// Licensed under the Apache License, Version 2.0, see LICENSE for details.
-// SPDX-License-Identifier: Apache-2.0
-
-#include "sw/device/lib/uart.h"
-
-#include "sw/device/lib/arch/device.h"
-#include "sw/device/lib/common.h"
-#include "sw/device/lib/dif/dif_uart.h"
-#include "sw/device/lib/runtime/ibex.h"
-
-#include "hw/top_earlgrey/sw/autogen/top_earlgrey.h"
-
-static dif_uart_t uart0;
-
-void uart_init(unsigned int baud) {
- // Note that, due to a GCC bug, we cannot use the standard `(void) expr`
- // syntax to drop this value on the ground.
- // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509
- mmio_region_t base_addr = mmio_region_from_addr(TOP_EARLGREY_UART_BASE_ADDR);
- if (dif_uart_init((dif_uart_params_t){.base_addr = base_addr}, &uart0)) {
- }
- if (dif_uart_configure(&uart0, (dif_uart_config_t){
- .baudrate = baud,
- .clk_freq_hz = kClockFreqPeripheralHz,
- .parity_enable = kDifUartToggleDisabled,
- .parity = kDifUartParityEven,
- })) {
- }
-}
-
-void uart_send_char(char c) {
- // Note that, due to a GCC bug, we cannot use the standard `(void) expr`
- // syntax to drop this value on the ground.
- // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509
- if (dif_uart_byte_send_polled(&uart0, (uint8_t)c)) {
- }
-}
-
-void uart_send_str(char *str) {
- while (*str != '\0') {
- uart_send_char(*str++);
- }
-}
-
-size_t uart_send_buf(void *data, const char *buf, size_t len) {
- for (size_t i = 0; i < len; ++i) {
- uart_send_char(buf[i]);
- }
- return len;
-}
-
-const buffer_sink_t uart_stdout = {
- .data = NULL, .sink = &uart_send_buf,
-};
-
-#define hexchar(i) (((i & 0xf) > 9) ? (i & 0xf) - 10 + 'A' : (i & 0xf) + '0')
-
-void uart_send_uint(uint32_t n, int bits) {
- for (int i = bits - 4; i >= 0; i -= 4) {
- uart_send_char(hexchar(n >> i));
- }
-}
-
-int uart_rcv_char(char *c) {
- size_t num_bytes = 0;
- if (dif_uart_rx_bytes_available(&uart0, &num_bytes) != kDifUartOk) {
- return -1;
- }
- if (num_bytes == 0) {
- return -1;
- }
- // The pointer cast from char* to uint8_t* is dangerous. This needs to be
- // revisited.
- if (dif_uart_bytes_receive(&uart0, 1, (uint8_t *)c, NULL) != kDifUartOk) {
- return -1;
- }
-
- return 0;
-}
diff --git a/sw/device/lib/uart.h b/sw/device/lib/uart.h
deleted file mode 100644
index 2abc86d..0000000
--- a/sw/device/lib/uart.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright lowRISC contributors.
-// Licensed under the Apache License, Version 2.0, see LICENSE for details.
-// SPDX-License-Identifier: Apache-2.0
-
-#ifndef OPENTITAN_SW_DEVICE_LIB_UART_H_
-#define OPENTITAN_SW_DEVICE_LIB_UART_H_
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "sw/device/lib/runtime/print.h"
-
-void uart_send_char(char c);
-
-/**
- * Send unsigned int over UART
- */
-void uart_send_uint(uint32_t n, int size);
-void uart_init(unsigned int baud);
-
-/**
- * Send a NULL-terminated string over UART
- */
-void uart_send_str(char *str);
-
-extern const buffer_sink_t uart_stdout;
-
-/**
- * Receive a single character from UART
- *
- * @param c received character, caller-allocated
- * @return 0 on success, -1 if no data is available
- */
-int uart_rcv_char(char *c);
-
-#endif // OPENTITAN_SW_DEVICE_LIB_UART_H_