[sw] Remove remaining references to uart.h
Signed-off-by: Miguel Young de la Sota <mcyoung@google.com>
diff --git a/sw/device/benchmarks/coremark/top_earlgrey/core_portme.h b/sw/device/benchmarks/coremark/top_earlgrey/core_portme.h
index b7eaf9f..643c2e0 100644
--- a/sw/device/benchmarks/coremark/top_earlgrey/core_portme.h
+++ b/sw/device/benchmarks/coremark/top_earlgrey/core_portme.h
@@ -15,7 +15,6 @@
#include <stddef.h>
#include "sw/device/lib/common.h"
-#include "sw/device/lib/uart.h"
extern unsigned int _stack_start;
diff --git a/sw/device/examples/demos.c b/sw/device/examples/demos.c
index bfd5570..a8b6393 100644
--- a/sw/device/examples/demos.c
+++ b/sw/device/examples/demos.c
@@ -9,10 +9,10 @@
#include "sw/device/lib/arch/device.h"
#include "sw/device/lib/dif/dif_gpio.h"
#include "sw/device/lib/dif/dif_spi_device.h"
+#include "sw/device/lib/dif/dif_uart.h"
#include "sw/device/lib/runtime/check.h"
#include "sw/device/lib/runtime/hart.h"
#include "sw/device/lib/runtime/log.h"
-#include "sw/device/lib/uart.h"
void demo_gpio_startup(dif_gpio_t *gpio) {
LOG_INFO("Watch the LEDs!");
@@ -75,10 +75,17 @@
}
}
-void demo_uart_to_uart_and_gpio_echo(dif_gpio_t *gpio) {
- char rcv_char;
- while (uart_rcv_char(&rcv_char) != -1) {
- uart_send_char(rcv_char);
+void demo_uart_to_uart_and_gpio_echo(dif_uart_t *uart, dif_gpio_t *gpio) {
+ while (true) {
+ size_t chars_available;
+ if (dif_uart_rx_bytes_available(uart, &chars_available) != kDifUartOk ||
+ chars_available == 0) {
+ break;
+ }
+
+ uint8_t rcv_char;
+ CHECK(dif_uart_bytes_receive(uart, 1, &rcv_char, NULL) == kDifUartOk);
+ CHECK(dif_uart_byte_send_polled(uart, rcv_char) == kDifUartOk);
CHECK(dif_gpio_write_all(gpio, rcv_char << 8) == kDifGpioOk);
}
}
diff --git a/sw/device/examples/demos.h b/sw/device/examples/demos.h
index b537873..2ebcc14 100644
--- a/sw/device/examples/demos.h
+++ b/sw/device/examples/demos.h
@@ -9,6 +9,7 @@
#include "sw/device/lib/dif/dif_gpio.h"
#include "sw/device/lib/dif/dif_spi_device.h"
+#include "sw/device/lib/dif/dif_uart.h"
/**
* This header provides a small library of reuseable demos for use with
@@ -46,8 +47,9 @@
* Attempts to read characters from UART and immediately echo them back,
* as well as to write its bits to GPIO pins 8-15.
*
+ * @param uart the UART device to actuate.
* @param gpio the GPIO device to actuate.
*/
-void demo_uart_to_uart_and_gpio_echo(dif_gpio_t *gpio);
+void demo_uart_to_uart_and_gpio_echo(dif_uart_t *uart, dif_gpio_t *gpio);
#endif // OPENTITAN_SW_DEVICE_EXAMPLES_DEMOS_H_
diff --git a/sw/device/examples/hello_world/hello_world.c b/sw/device/examples/hello_world/hello_world.c
index 052ce8e..33f5c4a 100644
--- a/sw/device/examples/hello_world/hello_world.c
+++ b/sw/device/examples/hello_world/hello_world.c
@@ -80,6 +80,6 @@
usleep(10 * 1000); // 10 ms
gpio_state = demo_gpio_to_log_echo(&gpio, gpio_state);
demo_spi_to_log_echo(&spi);
- demo_uart_to_uart_and_gpio_echo(&gpio);
+ demo_uart_to_uart_and_gpio_echo(&uart, &gpio);
}
}
diff --git a/sw/device/examples/meson.build b/sw/device/examples/meson.build
index f2e2f36..d81282b 100644
--- a/sw/device/examples/meson.build
+++ b/sw/device/examples/meson.build
@@ -10,8 +10,8 @@
sw_lib_runtime_hart,
sw_lib_dif_gpio,
sw_lib_dif_spi_device,
- sw_lib_uart,
sw_lib_runtime_log,
+ sw_lib_dif_uart,
],
)
)
diff --git a/sw/device/exts/common/meson.build b/sw/device/exts/common/meson.build
index 51657fc..154b755 100644
--- a/sw/device/exts/common/meson.build
+++ b/sw/device/exts/common/meson.build
@@ -43,6 +43,7 @@
freestanding_headers,
sw_lib_mem,
sw_lib_irq,
+ top_earlgrey,
],
# This argument exists solely so that Meson realizes that riscv_linker_script
# is part of the dependency graph. This seems to be the only way to convince
diff --git a/sw/device/lib/handler.c b/sw/device/lib/handler.c
index 27c867c..f9617e9 100644
--- a/sw/device/lib/handler.c
+++ b/sw/device/lib/handler.c
@@ -6,7 +6,7 @@
#include "sw/device/lib/base/stdasm.h"
#include "sw/device/lib/common.h"
-#include "sw/device/lib/uart.h"
+#include "sw/device/lib/runtime/log.h"
/**
* Return value of mtval
@@ -23,11 +23,8 @@
* TODO - this will be soon by a real print formatting
*/
static void print_exc_msg(const char *msg) {
- const uint32_t mtval = get_mtval();
- uart_send_str((char *)msg);
- uart_send_str("MTVAL value is ");
- uart_send_uint(mtval, 32);
- uart_send_str("\n");
+ LOG_INFO("%s", msg);
+ LOG_INFO("MTVAL value is 0x%x", get_mtval());
while (1) {
};
}
@@ -69,48 +66,48 @@
}
__attribute__((weak)) void handler_irq_software(void) {
- uart_send_str("Software IRQ triggered!\n");
+ LOG_INFO("Software IRQ triggered!");
while (1) {
}
}
__attribute__((weak)) void handler_irq_timer(void) {
- uart_send_str("Timer IRQ triggered!\n");
+ LOG_INFO("Timer IRQ triggered!");
while (1) {
}
}
__attribute__((weak)) void handler_irq_external(void) {
- uart_send_str("External IRQ triggered!\n");
+ LOG_INFO("External IRQ triggered!");
while (1) {
}
}
__attribute__((weak)) void handler_instr_acc_fault(void) {
const char fault_msg[] =
- "Instruction access fault, mtval shows fault address\n";
+ "Instruction access fault, mtval shows fault address";
print_exc_msg(fault_msg);
}
__attribute__((weak)) void handler_instr_ill_fault(void) {
const char fault_msg[] =
- "Illegal Instruction fault, mtval shows instruction content\n";
+ "Illegal Instruction fault, mtval shows instruction content";
print_exc_msg(fault_msg);
}
__attribute__((weak)) void handler_bkpt(void) {
const char exc_msg[] =
- "Breakpoint triggerd, mtval shows the breakpoint address\n";
+ "Breakpoint triggerd, mtval shows the breakpoint address";
print_exc_msg(exc_msg);
}
__attribute__((weak)) void handler_lsu_fault(void) {
- const char exc_msg[] = "Load/Store fault, mtval shows the fault address\n";
+ const char exc_msg[] = "Load/Store fault, mtval shows the fault address";
print_exc_msg(exc_msg);
}
__attribute__((weak)) void handler_ecall(void) {
- uart_send_str("Environment call encountered\n");
+ LOG_INFO("Environment call encountered");
while (1) {
}
}
diff --git a/sw/device/lib/meson.build b/sw/device/lib/meson.build
index aacf57e..d467cb6 100644
--- a/sw/device/lib/meson.build
+++ b/sw/device/lib/meson.build
@@ -110,7 +110,7 @@
'handler.c',
],
dependencies: [
- sw_lib_uart,
+ sw_lib_runtime_log,
],
)
)
@@ -126,7 +126,6 @@
'usbdev.c',
],
dependencies: [
- sw_lib_uart,
top_earlgrey,
]
)
diff --git a/sw/device/riscv_compliance_support/meson.build b/sw/device/riscv_compliance_support/meson.build
index 380c086..68a896c 100644
--- a/sw/device/riscv_compliance_support/meson.build
+++ b/sw/device/riscv_compliance_support/meson.build
@@ -12,10 +12,11 @@
'ot_riscv_compliance_support_inner_' + device_name,
sources: ['support.c'],
dependencies: [
- sw_lib_uart,
sw_lib_runtime_print,
+ sw_lib_runtime_log,
sw_lib_irq_handlers,
sw_lib_mem,
+ sw_lib_testing_test_status,
device_lib,
],
)
diff --git a/sw/device/riscv_compliance_support/support.c b/sw/device/riscv_compliance_support/support.c
index e31337a..55bf72c 100644
--- a/sw/device/riscv_compliance_support/support.c
+++ b/sw/device/riscv_compliance_support/support.c
@@ -5,6 +5,7 @@
#include <stddef.h>
#include "sw/device/lib/arch/device.h"
+#include "sw/device/lib/dif/dif_uart.h"
#include "sw/device/lib/runtime/check.h"
#include "sw/device/lib/runtime/print.h"
diff --git a/sw/device/sca/aes_serial/aes_serial.c b/sw/device/sca/aes_serial/aes_serial.c
index 3706480..465e2ea 100644
--- a/sw/device/sca/aes_serial/aes_serial.c
+++ b/sw/device/sca/aes_serial/aes_serial.c
@@ -132,7 +132,7 @@
size_t data_len) {
base_printf("%c", cmd_tag);
for (int i = 0; i < data_len; ++i) {
- base_printf("%x", (uint32_t)data[i]);
+ base_printf("%2x", (uint32_t)data[i]);
}
base_printf("\n");
}
diff --git a/sw/device/tests/coverage_test.c b/sw/device/tests/coverage_test.c
index 0689d9e..17fb3c8 100644
--- a/sw/device/tests/coverage_test.c
+++ b/sw/device/tests/coverage_test.c
@@ -2,18 +2,19 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-#include "sw/device/lib/arch/device.h"
-#include "sw/device/lib/runtime/hart.h"
-#include "sw/device/lib/testing/test_coverage.h"
-#include "sw/device/lib/testing/test_main.h"
-#include "sw/device/lib/uart.h"
#include <stdbool.h>
#include <stdint.h>
+#include "sw/device/lib/arch/device.h"
+#include "sw/device/lib/runtime/hart.h"
+#include "sw/device/lib/runtime/log.h"
+#include "sw/device/lib/runtime/print.h"
+#include "sw/device/lib/testing/test_coverage.h"
+#include "sw/device/lib/testing/test_main.h"
+
static void spin_45(uint8_t state) {
static const char kSpinnerChars[] = "|/-\\";
- uart_send_char(kSpinnerChars[state]);
- uart_send_char('\r');
+ base_printf("%c\r", kSpinnerChars[state]);
}
static void spin_180(void) {
@@ -32,7 +33,7 @@
*/
bool test_main(void) {
// Print an assuring message.
- uart_send_str("Collecting coverage data.\r\n");
+ LOG_INFO("Collecting coverage data.");
// Display a spinning bar.
for (uint8_t i = 0; i < 4; ++i) {
spin_180();
diff --git a/sw/device/tests/dif/dif_hmac_sanitytest.c b/sw/device/tests/dif/dif_hmac_sanitytest.c
index 8c7722c..9401d7e 100644
--- a/sw/device/tests/dif/dif_hmac_sanitytest.c
+++ b/sw/device/tests/dif/dif_hmac_sanitytest.c
@@ -10,7 +10,6 @@
#include "sw/device/lib/runtime/check.h"
#include "sw/device/lib/runtime/log.h"
#include "sw/device/lib/testing/test_main.h"
-#include "sw/device/lib/uart.h"
#include "hw/top_earlgrey/sw/autogen/top_earlgrey.h"
diff --git a/sw/device/tests/meson.build b/sw/device/tests/meson.build
index df6a89c..228caa3 100644
--- a/sw/device/tests/meson.build
+++ b/sw/device/tests/meson.build
@@ -66,7 +66,6 @@
'coverage_test_lib',
sources: ['coverage_test.c'],
dependencies: [
- sw_lib_uart,
collect_coverage,
],
),
diff --git a/sw/device/tests/sim_dv/meson.build b/sw/device/tests/sim_dv/meson.build
index 1a37203..31b35a5 100644
--- a/sw/device/tests/sim_dv/meson.build
+++ b/sw/device/tests/sim_dv/meson.build
@@ -11,7 +11,6 @@
sw_lib_dif_plic,
sw_lib_irq,
sw_lib_mmio,
- sw_lib_uart,
sw_lib_runtime_log,
sw_lib_runtime_hart,
sw_lib_testing_test_status,
diff --git a/sw/device/tests/sim_dv/uart_tx_rx_test.c b/sw/device/tests/sim_dv/uart_tx_rx_test.c
index 8c5aad9..e26c879 100644
--- a/sw/device/tests/sim_dv/uart_tx_rx_test.c
+++ b/sw/device/tests/sim_dv/uart_tx_rx_test.c
@@ -2,7 +2,6 @@
// 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/base/mmio.h"
#include "sw/device/lib/dif/dif_plic.h"
diff --git a/sw/device/tests/usbdev_test.c b/sw/device/tests/usbdev_test.c
index 60c0773..409bb3e 100644
--- a/sw/device/tests/usbdev_test.c
+++ b/sw/device/tests/usbdev_test.c
@@ -21,8 +21,8 @@
#include "sw/device/lib/runtime/check.h"
#include "sw/device/lib/runtime/log.h"
+#include "sw/device/lib/runtime/print.h"
#include "sw/device/lib/testing/test_main.h"
-#include "sw/device/lib/uart.h"
#include "sw/device/lib/usb_controlep.h"
#include "sw/device/lib/usb_simpleserial.h"
@@ -70,7 +70,7 @@
*/
static void usb_receipt_callback(uint8_t c) {
c = make_printable(c, '?');
- uart_send_char(c);
+ base_printf("%c", c);
if (usb_chars_recved_total < kExpectedUsbCharsRecved) {
buffer[usb_chars_recved_total] = c;
++usb_chars_recved_total;
@@ -98,7 +98,7 @@
usbdev_poll(&usbdev);
}
- uart_send_str("\r\n");
+ base_printf("\r\n");
for (int i = 0; i < kExpectedUsbCharsRecved; i++) {
CHECK(buffer[i] == kExpectedUsbRecved[i],
"Recieved char #%d mismatched: exp = %x, actual = %x", i,