This commit is contained in:
ccckmit
2020-11-14 11:31:33 +08:00
commit 5eec97bef9
69 changed files with 2775 additions and 0 deletions

22
01-HelloOs/os.c Normal file
View File

@@ -0,0 +1,22 @@
#include <stdint.h>
// ref: https://www.activexperts.com/serial-port-component/tutorials/uart/
#define UART 0x10000000
#define UART_THR (uint8_t*)(UART+0x00) // THR:transmitter holding register
#define UART_LSR (uint8_t*)(UART+0x05) // LSR:line status register
#define UART_LSR_EMPTY_MASK 0x40 // LSR Bit 6: Transmitter empty; both the THR and LSR are empty
int lib_putc(char ch) {
while ((*UART_LSR & UART_LSR_EMPTY_MASK) == 0);
return *UART_THR = ch;
}
void lib_puts(char *s) {
while (*s) lib_putc(*s++);
}
int os_main(void)
{
lib_puts("Hello OS!\n");
return 0;
}