mirror of
https://github.com/rdmsr/zag.git
synced 2026-11-01 15:48:21 +00:00
everywhere: nuke UM
This commit is contained in:
+1
-3
@@ -103,9 +103,7 @@ fn map_kernel(boot_info: *pl.BootInfo) void {
|
||||
|
||||
pub fn init(boot_info: *pl.BootInfo) linksection(r.init) void {
|
||||
mi.phys.init(boot_info);
|
||||
if (config.arch != .um) {
|
||||
map_kernel(boot_info);
|
||||
}
|
||||
map_kernel(boot_info);
|
||||
mi.kernel_space.pmap.activate();
|
||||
mi.phys.init_pfndb();
|
||||
mi.zone.early_init();
|
||||
|
||||
@@ -29,7 +29,6 @@ pub const PMapLevel = struct {
|
||||
|
||||
pub const impl = switch (config.arch) {
|
||||
.amd64 => @import("amd64/impl.zig"),
|
||||
.um => @import("um/impl.zig"),
|
||||
else => @compileError("unsupported architecture"),
|
||||
};
|
||||
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
const r = @import("root");
|
||||
const std = @import("std");
|
||||
const linux = std.os.linux;
|
||||
|
||||
pub var kernel_heap_base: usize = 0;
|
||||
pub var pfndb_base: usize = 0;
|
||||
pub const hhdm_minimum_max_address: usize = 0;
|
||||
|
||||
var page_table: std.AutoHashMap(usize, usize) = .init(std.heap.page_allocator);
|
||||
|
||||
pub fn init_kernel() void {
|
||||
kernel_heap_base = linux.mmap(
|
||||
null,
|
||||
r.gib(8),
|
||||
.{ .READ = true, .WRITE = true },
|
||||
.{ .ANONYMOUS = true, .TYPE = .PRIVATE },
|
||||
-1,
|
||||
0,
|
||||
);
|
||||
|
||||
r.pl.impl.check_function("mmap", kernel_heap_base);
|
||||
|
||||
pfndb_base = linux.mmap(
|
||||
null,
|
||||
r.gib(1),
|
||||
.{ .READ = true, .WRITE = true },
|
||||
.{ .ANONYMOUS = true, .TYPE = .PRIVATE },
|
||||
-1,
|
||||
0,
|
||||
);
|
||||
|
||||
r.pl.impl.check_function("mmap", pfndb_base);
|
||||
}
|
||||
|
||||
pub fn phys_to_virt(pa: usize) usize {
|
||||
return r.pl.impl.global_state.phys_base + pa;
|
||||
}
|
||||
|
||||
pub fn virt_to_phys(va: usize) usize {
|
||||
return va - r.pl.impl.global_state.phys_base;
|
||||
}
|
||||
|
||||
pub const PMap = struct {
|
||||
const Self = @This();
|
||||
|
||||
pub fn map_from(_: *Self, va: r.VAddr, size: usize, source: anytype) void {
|
||||
var remain = size;
|
||||
|
||||
while (remain > 0) {
|
||||
const item = source.next(va);
|
||||
|
||||
var posix_flags: std.c.PROT = .{};
|
||||
|
||||
posix_flags.READ = item.flags.read;
|
||||
posix_flags.WRITE = item.flags.write;
|
||||
posix_flags.EXEC = item.flags.execute;
|
||||
|
||||
_ = std.c.mmap(
|
||||
@ptrFromInt(va),
|
||||
size,
|
||||
posix_flags,
|
||||
.{ .FIXED = true, .TYPE = .PRIVATE },
|
||||
r.pl.impl.global_state.phys_memory_memfd,
|
||||
@bitCast(item.pa),
|
||||
);
|
||||
|
||||
page_table.put(va & ~@as(usize, 0xFFF), item.pa) catch unreachable;
|
||||
|
||||
remain -|= item.len;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn query(_: *Self, va: r.VAddr) ?r.PAddr {
|
||||
const page = va & ~@as(usize, 0xFFF);
|
||||
const pa = page_table.get(page) orelse return null;
|
||||
return pa;
|
||||
}
|
||||
|
||||
pub fn activate(_: *Self) void {}
|
||||
};
|
||||
Reference in New Issue
Block a user