mirror of
https://github.com/StepanovPlaton/OSin1000Lines.git
synced 2026-04-03 20:30:46 +04:00
Virtual memory
This commit is contained in:
10
src/kernel.h
10
src/kernel.h
@@ -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) \
|
||||
({ \
|
||||
|
||||
Reference in New Issue
Block a user