aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debugger/include/cli_platform.h46
-rw-r--r--debugger/src/cli/cli.c60
-rw-r--r--debugger/src/cli/cli_commands_checkpoint.c5
-rw-r--r--debugger/src/cli/cli_commands_core.c9
-rw-r--r--module/debugger_cli/src/mod_debugger_cli.c2
-rw-r--r--module/pl011/include/mod_pl011.h7
-rw-r--r--module/pl011/src/Makefile4
-rw-r--r--module/pl011/src/debug_uart.c93
-rw-r--r--module/pl011/src/mod_pl011.c2
9 files changed, 32 insertions, 196 deletions
diff --git a/debugger/include/cli_platform.h b/debugger/include/cli_platform.h
index f9ae03f7..2b983eba 100644
--- a/debugger/include/cli_platform.h
+++ b/debugger/include/cli_platform.h
@@ -65,15 +65,6 @@ void cli_platform_delay_ms(uint32_t ms);
/*****************************************************************************/
/*
- * cli_platform_uart_init
- * Description
- * Initializes the necessary hardware to send and receive characters.
- * Return
- * cli_ret_et: success if it works, something else if it fails.
- */
-uint32_t cli_platform_uart_init(void);
-
-/*
* cli_platform_uid_notify
* Description
* If system has a UID light, this function notifies it of activity on
@@ -83,41 +74,4 @@ uint32_t cli_platform_uart_init(void);
*/
uint32_t cli_platform_uid_notify(void);
-/*
- * cli_platform_uart_get
- * Description
- * Receives a single character from the UART. Must support blocking and
- * non-blocking receive operations.
- * Parameters
- * char *c
- * Pointer to a char in which to place the received character.
- * bool block
- * If true, this function must not return until a character is
- * received or the UART generates an error. If false, this function
- * returns immediately regardless of whether or not a character was
- * received.
- * Return
- * cli_ret_et: success if a character is read with no errors, error_empty
- * if block==true and no characters are available, or some other error
- * from the UART.
- */
-uint32_t cli_platform_uart_get(char *c, bool block);
-
-/*
- * cli_platform_uart_put
- * Description
- * Sends a single character on the UART. This function is blocking.
- * Parameters
- * char *c
- * Pointer to character to send.
- * bool block
- * If true, this function must not return until a character is
- * output or the UART generates an error. If false, this function
- * returns immediately regardless of whether or not a character was
- * output.
- * Return
- * cli_ret_et: success if it works, some other error if it doesn't.
- */
-uint32_t cli_platform_uart_put(const char *c, bool block);
-
#endif /* _CLI_PLATFORM_H_ */
diff --git a/debugger/src/cli/cli.c b/debugger/src/cli/cli.c
index aab034c6..3e5235d0 100644
--- a/debugger/src/cli/cli.c
+++ b/debugger/src/cli/cli.c
@@ -10,6 +10,7 @@
#include <cli_fifo.h>
#include <cli_platform.h>
+#include <fwk_io.h>
#include <fwk_list.h>
#include <fwk_mm.h>
@@ -354,11 +355,6 @@ uint32_t cli_init(void)
strncpy(cli_prompt, prompt, CLI_CONFIG_PROMPT_BUF_SIZE);
cli_prompt_size = strlen(prompt);
- /* Initializing platform UART. */
- status = cli_platform_uart_init();
- if (status != FWK_SUCCESS)
- return status;
-
/* Initialize print buffer FIFO. */
status = fifo_init(
&cli_print_fifo, cli_print_fifo_buffer, CLI_CONFIG_PRINT_BUFFER_SIZE);
@@ -528,7 +524,7 @@ uint32_t cli_print(const char *string)
int32_t status = FWK_SUCCESS;
for (index = 0; string[index] != 0; index++) {
- status = cli_platform_uart_put(&string[index], true);
+ status = fwk_io_putch(fwk_io_stdout, string[index]);
if (status != FWK_SUCCESS)
return status;
}
@@ -579,13 +575,14 @@ uint32_t cli_getline(
/*
* Loop will terminate when the user presses enter or when an error is
- * generated. If your cli_platform_uart_get is thread friendly (and it
- * should be if implemented correctly), this loop will have negligible
- * impact on system performance.
+ * generated. This loop will have negligible impact on system performance.
*/
while (1) {
/* Grab a character from the UART. */
- status = cli_platform_uart_get(&c, true);
+ do {
+ status = fwk_io_getch(fwk_io_stdin, &c);
+ } while (status == FWK_PENDING);
+
if (status != FWK_SUCCESS)
return status;
@@ -630,7 +627,10 @@ uint32_t cli_getline(
}
/* Echo received character to console. */
- status = cli_platform_uart_put(&c, true);
+ do {
+ status = fwk_io_putch(fwk_io_stdout, c);
+ } while (status == FWK_PENDING);
+
if (status != FWK_SUCCESS)
return status;
@@ -943,7 +943,10 @@ static uint32_t cli_get_command(
while (1) {
/* Get character from UART. */
- status = cli_platform_uart_get(&c, true);
+ do {
+ status = fwk_io_getch(fwk_io_stdin, &c);
+ } while (status == FWK_PENDING);
+
if (status != FWK_SUCCESS)
return status;
@@ -1006,8 +1009,8 @@ static uint32_t cli_get_command(
/* Printing history command to screen. */
while (buffer[index] != 0) {
- status = cli_platform_uart_put(&buffer[index],
- true);
+ status =
+ fwk_io_putch(fwk_io_stdout, buffer[index]);
if (status != FWK_SUCCESS)
return status;
index = index + 1;
@@ -1044,8 +1047,8 @@ static uint32_t cli_get_command(
/* Printing history command to screen. */
while (buffer[index] != 0) {
- status = cli_platform_uart_put(&buffer[index],
- true);
+ status =
+ fwk_io_putch(fwk_io_stdout, buffer[index]);
if (status != FWK_SUCCESS)
return status;
@@ -1096,7 +1099,7 @@ static uint32_t cli_get_command(
}
/* Printing received character to console. */
- status = cli_platform_uart_put(&c, true);
+ status = fwk_io_putch(fwk_io_stdout, c);
if (status != FWK_SUCCESS)
return status;
@@ -1299,7 +1302,7 @@ static uint32_t cli_debug_output(void)
"press Ctrl+C.\n");
while (1) {
/* Looking for Ctrl+C press. */
- if (cli_platform_uart_get((char *)&c, false) == FWK_SUCCESS) {
+ if (fwk_io_getch(fwk_io_stdin, &c) == FWK_SUCCESS) {
if (c == '\x03') {
cli_printf(
0,
@@ -1313,7 +1316,7 @@ static uint32_t cli_debug_output(void)
fifo_status = fifo_get(&cli_print_fifo, &c);
if (fifo_status == FWK_SUCCESS) {
overflow = false;
- cli_platform_uart_put((char *)&c, true);
+ fwk_io_putch(fwk_io_stdout, c);
} else
/* If no characters are available, let other stuff run. */
cli_platform_delay_ms(0);
@@ -1325,24 +1328,7 @@ static void cli_error_handler(uint32_t status)
if (status == FWK_SUCCESS)
return;
- cli_printf(NONE, "CONSOLE ERROR: ");
- switch (status) {
- case FWK_E_NOMEM:
- cli_print("Buffer size.\n");
- break;
- case FWK_E_PARAM:
- cli_print("Bad argument.\n");
- break;
- case FWK_E_SUPPORT:
- cli_print("Not found.\n");
- break;
- case FWK_E_DATA:
- cli_print("No data available.\n");
- break;
- default:
- cli_print("Unknown error.\n");
- return;
- }
+ cli_printf(NONE, "CONSOLE ERROR: %s\n", fwk_status_str(status));
}
static void cli_val2str(
diff --git a/debugger/src/cli/cli_commands_checkpoint.c b/debugger/src/cli/cli_commands_checkpoint.c
index 12b7eb23..29620230 100644
--- a/debugger/src/cli/cli_commands_checkpoint.c
+++ b/debugger/src/cli/cli_commands_checkpoint.c
@@ -9,6 +9,7 @@
#include <cli.h>
#include <cli_platform.h>
+#include <fwk_io.h>
#include <fwk_status.h>
#include <stdint.h>
@@ -109,12 +110,12 @@ void checkpoint_boot_state(uint32_t timeout_s)
char c = 0;
/* Make sure nothing is waiting in UART buffer. */
- while (cli_platform_uart_get(&c, false) == FWK_SUCCESS)
+ while (fwk_io_getch(fwk_io_stdin, &c) == FWK_SUCCESS)
;
cli_print("Press any key to enable checkpoints before boot... ");
while (timeout_s != 0) {
- if (cli_platform_uart_get(&c, false) == FWK_SUCCESS) {
+ if (fwk_io_getch(fwk_io_stdin, &c) == FWK_SUCCESS) {
cli_print("\nCheckpoints enabled.\n");
checkpoint_enable_all();
return;
diff --git a/debugger/src/cli/cli_commands_core.c b/debugger/src/cli/cli_commands_core.c
index 04d4f5ae..c7d6b088 100644
--- a/debugger/src/cli/cli_commands_core.c
+++ b/debugger/src/cli/cli_commands_core.c
@@ -41,9 +41,6 @@
/* cli_getline */
/* Retrieves a line of user input from the console, see cli_module.h for */
/* full description. */
-/* cli_platform_uart_get and cli_platform_uart_put */
-/* Direct access to the UART hardware, using these is not recommended */
-/* but shouldn't hurt anything. */
/* cli_snprintf */
/* Takes the place of snprintf and it's derivatives, a bit rudimentary */
/* but has no heap dependence, see cli_module.h for full descriptions. */
@@ -59,6 +56,8 @@
#include <cli_fifo.h>
#include <cli_platform.h>
+#include <fwk_io.h>
+
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -109,10 +108,10 @@ static int32_t dump_memory_f(int32_t argc, char **argv)
for (j = 0; j < NUM_BYTES_PER_LINE; j++) {
if ((bytes[j] >= 0x20) && (bytes[j] <= 0x7E))
/* Character is printing. */
- cli_platform_uart_put((const char *)&bytes[j], true);
+ fwk_io_putch(fwk_io_stdout, bytes[j]);
else
/* Character is non-printing so put a period. */
- cli_platform_uart_put(".", true);
+ fwk_io_putch(fwk_io_stdout, '.');
}
cli_print("\"\n");
}
diff --git a/module/debugger_cli/src/mod_debugger_cli.c b/module/debugger_cli/src/mod_debugger_cli.c
index 265563a2..78317c31 100644
--- a/module/debugger_cli/src/mod_debugger_cli.c
+++ b/module/debugger_cli/src/mod_debugger_cli.c
@@ -33,7 +33,7 @@ static void alarm_callback(uintptr_t module_idx)
struct fwk_event *event;
/* Get the pending character (if any) from the UART without blocking */
- status = cli_platform_uart_get(&ch, false);
+ status = fwk_io_getch(fwk_io_stdin, &ch);
if (status == FWK_SUCCESS) {
/* Ctrl-E has been pressed */
diff --git a/module/pl011/include/mod_pl011.h b/module/pl011/include/mod_pl011.h
index 424f8414..07d61459 100644
--- a/module/pl011/include/mod_pl011.h
+++ b/module/pl011/include/mod_pl011.h
@@ -69,13 +69,6 @@ struct mod_pl011_element_cfg {
};
/*!
- * \brief Set the baud rate of the PL011 device
- *
- * \param[in] cfg The desired device configuration.
- */
-void mod_pl011_set_baud_rate(const struct mod_pl011_element_cfg *cfg);
-
-/*!
* \}
*/
diff --git a/module/pl011/src/Makefile b/module/pl011/src/Makefile
index 61c66e8c..816a8d7e 100644
--- a/module/pl011/src/Makefile
+++ b/module/pl011/src/Makefile
@@ -8,8 +8,4 @@
BS_LIB_NAME := "PL011"
BS_LIB_SOURCES = mod_pl011.c
-ifeq ($(BUILD_HAS_DEBUGGER),yes)
- BS_LIB_SOURCES += debug_uart.c
-endif
-
include $(BS_DIR)/lib.mk
diff --git a/module/pl011/src/debug_uart.c b/module/pl011/src/debug_uart.c
deleted file mode 100644
index fcd5fca1..00000000
--- a/module/pl011/src/debug_uart.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Arm SCP/MCP Software
- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <dbg_system_map.h>
-#include <pl011.h>
-
-#include <mod_pl011.h>
-
-#include <fwk_assert.h>
-
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-
-static const struct mod_pl011_element_cfg config = {
- .reg_base = DEBUG_UART_BASE,
- .baud_rate_bps = 115200,
- .clock_rate_hz = 24 * FWK_MHZ,
-};
-
-uint32_t cli_platform_uart_init(void)
-{
- volatile struct pl011_reg *reg;
-
- reg = (volatile struct pl011_reg *)config.reg_base;
- if (reg == NULL)
- return FWK_E_DATA;
-
- mod_pl011_set_baud_rate(&config);
-
- /*
- * Initialize PL011 device
- */
- reg->ECR = PL011_ECR_CLR;
- reg->LCR_H = PL011_LCR_H_WLEN_8BITS |
- PL011_LCR_H_FEN;
- reg->CR = PL011_CR_UARTEN |
- PL011_CR_RXE |
- PL011_CR_TXE;
-
- return FWK_SUCCESS;
-}
-
-uint32_t cli_platform_uart_get(char *c, const bool block)
-{
- volatile struct pl011_reg *reg;
- uint32_t ch = 0;
-
- reg = (volatile struct pl011_reg *)config.reg_base;
-
- while (1) {
- /* Wait for a character to become available if block is set. */
- if ((reg->FR & PL011_FR_RXFE) == 0) {
- ch = reg->DR;
- *c = (char)ch;
- return FWK_SUCCESS;
- } else if (block == false) {
- return FWK_E_DATA;
- }
- }
-}
-
-uint32_t cli_platform_uart_put(const char *c, bool block)
-{
- int status;
- volatile struct pl011_reg *reg;
-
- reg = (volatile struct pl011_reg *)config.reg_base;
-
- uint32_t ch = (uint32_t)*c;
-
- /* If we get a \n, send a \r first. */
- if (*c == '\n') {
- status = cli_platform_uart_put("\r", true);
-
- if (status != FWK_SUCCESS)
- return status;
- }
-
- do {
- /* Wait for UART to be ready for a character if block is set. */
- if ((reg->FR & PL011_FR_TXFF) == 0) {
- reg->DR = ch;
- return FWK_SUCCESS;
- }
- } while (block);
-
- return FWK_E_DATA;
-}
diff --git a/module/pl011/src/mod_pl011.c b/module/pl011/src/mod_pl011.c
index 742a0925..2cbf7d40 100644
--- a/module/pl011/src/mod_pl011.c
+++ b/module/pl011/src/mod_pl011.c
@@ -94,7 +94,7 @@ static int mod_pl011_init_ctx(struct mod_pl011_ctx *ctx)
return FWK_SUCCESS;
}
-void mod_pl011_set_baud_rate(const struct mod_pl011_element_cfg *cfg)
+static void mod_pl011_set_baud_rate(const struct mod_pl011_element_cfg *cfg)
{
struct pl011_reg *reg = (void *)cfg->reg_base;