Add a physical memory manager

This commit is contained in:
Sam Tebbs 2019-09-09 23:38:06 +01:00 committed by Sam Tebbs
parent 6a46d263cf
commit 7043ccd6b9
10 changed files with 567 additions and 7 deletions

View file

@ -11,6 +11,7 @@ const paging = @import("paging.zig");
const syscalls = @import("syscalls.zig");
const mem = @import("../../mem.zig");
const multiboot = @import("../../multiboot.zig");
const pmm = @import("pmm.zig");
const MemProfile = mem.MemProfile;
/// The interrupt context that is given to a interrupt handler. It contains most of the registers
@ -46,6 +47,9 @@ pub const InterruptContext = struct {
ss: u32,
};
/// The size of each allocatable block of memory, normally set to the page size.
pub const MEMORY_BLOCK_SIZE = paging.PAGE_SIZE_4KB;
///
/// Assembly to write to a given port with a byte of data.
///

View file

@ -83,12 +83,6 @@ const ENTRIES_PER_DIRECTORY: u32 = 1024;
/// Each table has 1024 entries
const ENTRIES_PER_TABLE: u32 = 1024;
/// The number of bytes in 4MB
const PAGE_SIZE_4MB: u32 = 0x400000;
/// The number of bytes in 4KB
const PAGE_SIZE_4KB: u32 = PAGE_SIZE_4MB / 1024;
/// There are 1024 entries per directory with each one covering 4KB
const PAGES_PER_DIR_ENTRY: u32 = 1024;
@ -121,6 +115,12 @@ const TENTRY_GLOBAL: u32 = 0x100;
const TENTRY_AVAILABLE: u32 = 0xE00;
const TENTRY_PAGE_ADDR: u32 = 0xFFFFF000;
/// The number of bytes in 4MB
pub const PAGE_SIZE_4MB: u32 = 0x400000;
/// The number of bytes in 4KB
pub const PAGE_SIZE_4KB: u32 = PAGE_SIZE_4MB / 1024;
///
/// Convert a virtual address to an index within an array of directory entries.
///