blob: 0ba7692970b184ea438d0debae2115601cec2920 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
// Distributed under the Apache Software License, Version 2.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.apache.org/licenses/LICENSE-2.0)
// Official repository: https://github.com/ne-foss-org/neboot
#include <include/boot.h>
#include <include/string.h>
/// BUGS: 0
#define NB_NS16550_COM1 (NB_UART_BASE + 0x4500)
#define NB_NS16550_COM2 (NB_UART_BASE + 0x4600)
volatile ascii_char_t* const UART0DR = (ascii_char_t*) NB_NS16550_COM1;
/* this file handles the UART */
/// @brief Get character from UART.
/// @param
/// @return
utf_char_t nb_get_char(void) {
while (!(*(((volatile uint8_t*) UART0DR) + 0x05) & 0x01));
return (utf_char_t) *UART0DR;
}
/// @brief Put character into UART.
/// @param ch
void nb_put_char(utf_char_t ch) {
*UART0DR = (ascii_char_t) (ch);
}
/// @brief Put string in UART.
/// @param text the input text.
size_t nb_put_string(const char* text) {
while (*text != '\0') { /* Loop until end of string */
nb_put_char(*text); /* Transmit char */
text++; /* Next char */
}
return 0;
}
|