diff options
| author | Amlal <amlal@nekernel.org> | 2025-04-25 13:28:08 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-04-25 13:28:08 +0200 |
| commit | 1c8414d3348c55fcf132839a04fdedec5efaacbe (patch) | |
| tree | 5c7386fae0504a798801e0b34b588f4177ba67c1 /src/rv64 | |
| parent | d7e35959ebb6b1dd892a99f23c2a7f23c0f99041 (diff) | |
dev: refactor codebase.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'src/rv64')
| -rw-r--r-- | src/rv64/rv64-err.c | 18 | ||||
| -rw-r--r-- | src/rv64/rv64-uart.c | 52 |
2 files changed, 30 insertions, 40 deletions
diff --git a/src/rv64/rv64-err.c b/src/rv64/rv64-err.c index 19d0f3c..a616d83 100644 --- a/src/rv64/rv64-err.c +++ b/src/rv64/rv64-err.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -10,14 +10,12 @@ /// @brief Goes into a panic state. /// @param reason why? -void cb_panic(const char* reason) -{ - cb_put_string("Error: "); - cb_put_string(reason); - cb_put_char('\n'); +void cb_panic(const char* reason) { + cb_put_string("Error: "); + cb_put_string(reason); + cb_put_char('\n'); - while (yes) - { - asm volatile("wfi"); - } + while (yes) { + asm volatile("wfi"); + } } diff --git a/src/rv64/rv64-uart.c b/src/rv64/rv64-uart.c index 0bc6517..a859add 100644 --- a/src/rv64/rv64-uart.c +++ b/src/rv64/rv64-uart.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -11,51 +11,43 @@ /* this file handles the UART */ -static uint8_t* cb_uart_ptr = (uint8_t*)CB_UART_BASE; +static uint8_t* cb_uart_ptr = (uint8_t*) CB_UART_BASE; -utf_char_t cb_get_char(void) -{ - uintptr_t ptr = CB_UART_BASE; +utf_char_t cb_get_char(void) { + uintptr_t ptr = CB_UART_BASE; - while (!(*(((volatile uint8_t*)ptr) + 0x05) & 0x01)) - ; + while (!(*(((volatile uint8_t*) ptr) + 0x05) & 0x01)); - return (utf_char_t)*cb_uart_ptr; + return (utf_char_t) *cb_uart_ptr; } // we need that one, to avoid sending mutliple chars to UART. static boolean cb_locked_put_char = no; -void cb_put_char(utf_char_t ch) -{ - int32_t timeout = 0; +void cb_put_char(utf_char_t ch) { + int32_t timeout = 0; - while (cb_locked_put_char) - { - ++timeout; + while (cb_locked_put_char) { + ++timeout; - if (timeout > 1000000) - break; - } + if (timeout > 1000000) break; + } - cb_locked_put_char = yes; - *cb_uart_ptr = ch; - cb_locked_put_char = no; + cb_locked_put_char = yes; + *cb_uart_ptr = ch; + cb_locked_put_char = no; } /// @brief UART put string /// @param text the input text. -size_t cb_put_string(const char* text) -{ - if (text == nil) - return 0; +size_t cb_put_string(const char* text) { + if (text == nil) return 0; - size_t i = 0; + size_t i = 0; - for (; i < strlen(text); i++) - { - cb_put_char(text[i]); - } + for (; i < strlen(text); i++) { + cb_put_char(text[i]); + } - return i; + return i; } |
