From c36e1b5e5e069ce1735dcc2a94aa45ba72ea2441 Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Tue, 9 Dec 2025 00:57:38 +0800 Subject: 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. --- kernel.cc | 69 --------------------------------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 kernel.cc (limited to 'kernel.cc') 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 -- cgit v1.2.3