summaryrefslogtreecommitdiff
path: root/kernel.cc
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2025-12-09 00:57:38 +0800
committerRichard Qin <richard.qin.x@gmail.com>2025-12-09 00:57:38 +0800
commitc36e1b5e5e069ce1735dcc2a94aa45ba72ea2441 (patch)
tree34be19b553615cfe36a556452e3b7ebad5276216 /kernel.cc
parent8cf8be522133548ee25fdcb0258ddf3950a68bcf (diff)
downloadlume-c36e1b5e5e069ce1735dcc2a94aa45ba72ea2441.tar.gz
lume-c36e1b5e5e069ce1735dcc2a94aa45ba72ea2441.tar.xz
feat: Initial PMM implementation
Introduce the foundational Physical Memory Manager (PMM) and restructure the project for modularity. Implemented basic PMM and related memory management headers (mm/pmm.h, mm/vm.h). Updated Makefile and build process to support new modular structure.
Diffstat (limited to 'kernel.cc')
-rw-r--r--kernel.cc69
1 files changed, 0 insertions, 69 deletions
diff --git a/kernel.cc b/kernel.cc
deleted file mode 100644
index f9cacba..0000000
--- a/kernel.cc
+++ /dev/null
@@ -1,69 +0,0 @@
-extern "C" void kernel_main();
-
-#define UART_ADDR 0x10000000UL
-
-#define THR_OFFSET 0x0
-#define LSR_OFFSET 0x5
-#define FCR_OFFSET 0x2
-#define LCR_OFFSET 0x3
-#define DLL_OFFSET 0x0
-#define DLH_OFFSET 0x1
-
-static void
-write_byte(unsigned long addr, char byte)
-{
- *((volatile char *)addr) = byte;
-}
-
-static int
-is_tx_empty()
-{
- return *((volatile char *)(UART_ADDR + LSR_OFFSET)) & (1 << 5);
-}
-
-void uart_init()
-{
- write_byte(UART_ADDR + LCR_OFFSET, 0x80);
-
- write_byte(UART_ADDR + DLL_OFFSET, 0x01);
- write_byte(UART_ADDR + DLH_OFFSET, 0x00);
-
- write_byte(UART_ADDR + LCR_OFFSET, 0x03);
-
- write_byte(UART_ADDR + FCR_OFFSET, 0x07);
-}
-
-void put_char(char c)
-{
- if (c == '\n')
- {
- put_char('\r');
- }
-
- while (!is_tx_empty())
- {
- }
- write_byte(UART_ADDR + THR_OFFSET, c);
-}
-
-void print_str(const char *s)
-{
- while (*s != '\0')
- {
- put_char(*s++);
- }
-}
-
-void kernel_main()
-{
- uart_init();
-
- print_str("Modern DOS 1.0\n");
- print_str("Hello OS! Running on RISC-V 64.\n");
- print_str("Hello Ziyi Yang! Love from RUC");
-
- while (1)
- {
-
- }
-} \ No newline at end of file