diff options
| author | Amlal <amlal.elmahrouss@icloud.com> | 2025-01-21 20:32:19 +0100 |
|---|---|---|
| committer | Amlal <amlal.elmahrouss@icloud.com> | 2025-01-21 20:32:19 +0100 |
| commit | 046d884b50c32cacd3523071541e7e38241083f3 (patch) | |
| tree | 92ce6fd53e0c031c569270b04aefa8fc0aa1e074 /src/ppc64/ppc64-uart.c | |
ADD: CoreBoot, also comes with my reimplementation of libfdt, which is just a dumb rewrite.
Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'src/ppc64/ppc64-uart.c')
| -rw-r--r-- | src/ppc64/ppc64-uart.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/ppc64/ppc64-uart.c b/src/ppc64/ppc64-uart.c new file mode 100644 index 0000000..23aeebd --- /dev/null +++ b/src/ppc64/ppc64-uart.c @@ -0,0 +1,48 @@ +/* -------------------------------------------
+
+ Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#include <lib/string.h>
+#include <lib/boot.h>
+
+/// BUGS: 0
+
+#define SYS_NS16550_COM1 (SYS_UART_BASE + 0x4500)
+#define SYS_NS16550_COM2 (SYS_UART_BASE + 0x4600)
+
+volatile ascii_char_t* const UART0DR = (ascii_char_t*)SYS_NS16550_COM1;
+
+/* this file handles the UART */
+
+/// @brief Get character from UART.
+/// @param
+/// @return
+utf_char_t mp_get_char(void)
+{
+ while (!(*(((volatile uint8_t*)UART0DR) + 0x05) & 0x01))
+ ;
+ return (utf_char_t)*UART0DR;
+}
+
+/// @brief Put character into UART.
+/// @param ch
+void mp_put_char(utf_char_t ch)
+{
+ *UART0DR = (ascii_char_t)(ch);
+}
+
+/// @brief Put string in UART.
+/// @param text the input text.
+size_t mp_put_string(const char* text)
+{
+ while (*text != '\0')
+ { /* Loop until end of string */
+
+ mp_put_char(*text); /* Transmit char */
+
+ text++; /* Next char */
+ }
+ return 0;
+}
|
