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

@ -5,6 +5,7 @@ const MemProfile = mem.MemProfile;
const gdt = @import("gdt_mock.zig");
const idt = @import("idt_mock.zig");
const multiboot = @import("../../../src/kernel/multiboot.zig");
const paging = @import("paging_mock.zig");
const mock_framework = @import("mock_framework.zig");
pub const initTest = mock_framework.initTest;
@ -35,6 +36,8 @@ pub const InterruptContext = struct {
ss: u32,
};
pub const MEMORY_BLOCK_SIZE = paging.PAGE_SIZE_4KB;
pub fn outb(port: u16, data: u8) void {
return mock_framework.performAction("outb", void, .{ port, data });
}

View file

@ -7,6 +7,7 @@ pub const MemProfile = struct {
physaddr_start: [*]u8,
mem_kb: u32,
fixed_alloc_size: u32,
mem_map: []multiboot.multiboot_memory_map_t,
};
// The virtual/physical start/end of the kernel code
@ -28,5 +29,6 @@ pub fn init(mb_info: *multiboot.multiboot_info_t) MemProfile {
// Total memory available including the initial 1MiB that grub doesn't include
.mem_kb = mb_info.mem_upper + mb_info.mem_lower + 1024,
.fixed_alloc_size = FIXED_ALLOC_SIZE,
.mem_map = undefined,
};
}

View file

@ -0,0 +1 @@
pub const PAGE_SIZE_4KB = 4096;

View file

@ -36,6 +36,8 @@ def get_pre_archinit_cases():
TestCase("Log warning tests", [r"Test WARNING level", r"Test WARNING level with args a, 1", r"Test WARNING function", r"Test WARNING function with args a, 1"], "\[WARNING\] "),
TestCase("Log error tests", [r"Test ERROR level", r"Test ERROR level with args a, 1", r"Test ERROR function", r"Test ERROR function with args a, 1"], "\[ERROR\] "),
TestCase("Mem init", [r"Init mem", r"Done"]),
TestCase("PMM init", [r"Init pmm", r"Done"]),
TestCase("PMM tests", [r"PMM: Tested allocation"]),
TestCase("Arch init starts", [r"Init arch \w+"])
]