Added basic paging.h & paging.c

This commit is contained in:
2025-03-28 11:30:43 +01:00
parent f73a6f9ccb
commit 5cee647ff0
6 changed files with 93 additions and 36 deletions
+4 -3
View File
@@ -16,12 +16,13 @@
#define BOOT_MMAP_NVS 4
#define BOOT_MMAP_BADRAM 5
#define BOOT_MAX_MMAP_ENTRIES 128
// A memory map entry
struct boot_memmap {
uint32_t skip; // Used for skipping (may be padded for alignment)
uint64_t base; // Memory region address
uint64_t size; // Memory region length
uint32_t type; // Memory region type
uint8_t type; // Memory region type
} __packed;
/*
@@ -39,7 +40,7 @@ struct boot_info {
uint8_t bootPart2;
uint8_t bootPart3;
char* cmdline;
uint32_t memmap;
struct boot_memmap* memmap;
size_t memmapLen;
char* bootname;
} __packed;
+25
View File
@@ -0,0 +1,25 @@
#ifndef _PAGING_H
#define _PAGING_H
#include <kernel.h>
#define PAGE_SIZE 4096
#define PHYS_ADDR(_a) ((_a) & ~0xfff)
#define PAGE_FLAG_PRESENT (1 << 0)
#define PAGE_FLAG_WRITE (1 << 1)
#define PAGE_FLAG_USER (1 << 2)
#define PAGE_FLAG_PWT (1 << 3)
#define PAGE_FLAG_NOCACHE (1 << 4)
#define PAGE_FLAG_ACCESSED (1 << 5)
#define PAGE_FLAG_DIRTY (1 << 6)
#define PAGE_FLAG_4MB (1 << 7)
#define PAGE_FLAG_GLOBAL (1 << 8)
// Defined in entry.s for initial paging
extern uint32_t init_pagedir[1024];
int pag_init(void);
#endif