Virtual memory

This commit is contained in:
2026-02-09 15:13:29 +04:00
parent 8710577d42
commit 10c456438b
4 changed files with 61 additions and 5 deletions

View File

@@ -6,6 +6,7 @@
extern char __bss[], __bss_end[];
extern char __stack_top[];
extern char __free_ram[], __free_ram_end[];
extern char __kernel_base[];
// ===== SBI data ======
struct sbiret {
@@ -58,12 +59,21 @@ struct process {
int pid;
int state;
vaddr_t sp;
uint32_t *page_table;
uint8_t stack[8192];
};
struct process procs[PROCS_MAX];
struct process *current_proc;
struct process *idle_proc;
// ===== Memory allocation =====
#define SATP_SV32 (1u << 31)
#define PAGE_V (1 << 0)
#define PAGE_R (1 << 1)
#define PAGE_W (1 << 2)
#define PAGE_X (1 << 3)
#define PAGE_U (1 << 4)
// ===== Macros =====
#define READ_CSR(reg) \
({ \