Compare commits
No commits in common. "ad6b4bf0db5f47df8c5a30f03f25adc968a090a1" and "f8182bd38671e87bf2f3611fb78b447629df1a86" have entirely different histories.
ad6b4bf0db
...
f8182bd386
@ -5,4 +5,3 @@ default 1 1000
|
|||||||
menuentry Astryon default
|
menuentry Astryon default
|
||||||
kernel core
|
kernel core
|
||||||
module init
|
module init
|
||||||
module memory
|
|
||||||
|
BIN
boot/memory
BIN
boot/memory
Binary file not shown.
@ -1,4 +1,3 @@
|
|||||||
const std = @import("std");
|
|
||||||
const gdt = @import("gdt.zig");
|
const gdt = @import("gdt.zig");
|
||||||
const idt = @import("idt.zig");
|
const idt = @import("idt.zig");
|
||||||
const pic = @import("pic.zig");
|
const pic = @import("pic.zig");
|
||||||
@ -19,21 +18,6 @@ fn enableNX() void {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var stack: [PAGE_SIZE * 8]u8 = std.mem.zeroes([PAGE_SIZE * 8]u8);
|
|
||||||
const top: usize = (PAGE_SIZE * 8) - 16;
|
|
||||||
|
|
||||||
pub inline fn _start() noreturn {
|
|
||||||
asm volatile (
|
|
||||||
\\ mov %[stack], %rsp
|
|
||||||
\\ addq %[top], %rsp
|
|
||||||
\\ call main
|
|
||||||
:
|
|
||||||
: [stack] "i" (&stack),
|
|
||||||
[top] "i" (top),
|
|
||||||
);
|
|
||||||
unreachable;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize platform-specific components.
|
// Initialize platform-specific components.
|
||||||
pub fn platformInit() void {
|
pub fn platformInit() void {
|
||||||
gdt.setupGDT();
|
gdt.setupGDT();
|
||||||
|
@ -3,7 +3,6 @@ const easyboot = @cImport(@cInclude("easyboot.h"));
|
|||||||
const mmap = @import("../../mmap.zig");
|
const mmap = @import("../../mmap.zig");
|
||||||
const pmm = @import("../../pmm.zig");
|
const pmm = @import("../../pmm.zig");
|
||||||
const platform = @import("platform.zig");
|
const platform = @import("platform.zig");
|
||||||
const debug = @import("../debug.zig");
|
|
||||||
|
|
||||||
const USER_ADDRESS_RANGE_END = 0x0000_7fff_ffff_ffff;
|
const USER_ADDRESS_RANGE_END = 0x0000_7fff_ffff_ffff;
|
||||||
pub const PHYSICAL_MAPPING_BASE = 0xffff_8000_0000_0000;
|
pub const PHYSICAL_MAPPING_BASE = 0xffff_8000_0000_0000;
|
||||||
@ -152,11 +151,6 @@ pub fn getEntry(space: AddressSpace, base: usize, virt_address: u64) ?*PageTable
|
|||||||
return pt_entry;
|
return pt_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getAddress(space: AddressSpace, base: usize, virt_address: u64) ?usize {
|
|
||||||
const entry = getEntry(space, base, virt_address) orelse return null;
|
|
||||||
return entry.getAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn copyToUser(space: AddressSpace, base: usize, user: usize, kernel: [*]const u8, size: usize) !void {
|
pub fn copyToUser(space: AddressSpace, base: usize, user: usize, kernel: [*]const u8, size: usize) !void {
|
||||||
const remainder: usize = @rem(user, platform.PAGE_SIZE);
|
const remainder: usize = @rem(user, platform.PAGE_SIZE);
|
||||||
const user_page = user - remainder;
|
const user_page = user - remainder;
|
||||||
@ -283,20 +277,22 @@ fn setUpKernelPageDirectory(allocator: *pmm.FrameAllocator, tag: *easyboot.multi
|
|||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setUpInitialUserPageDirectory(allocator: *pmm.FrameAllocator, tag: *easyboot.multiboot_tag_mmap_t, space: AddressSpace) !usize {
|
pub fn setUpInitialUserPageDirectory(allocator: *pmm.FrameAllocator, tag: *easyboot.multiboot_tag_mmap_t, user_table: *PageTable) !usize {
|
||||||
const kernel_space = AddressSpace.create(readPageTable(), PHYSICAL_MAPPING_BASE);
|
const kernel_space = AddressSpace.create(readPageTable(), PHYSICAL_MAPPING_BASE);
|
||||||
const kernel_table = kernel_space.table;
|
const kernel_table = kernel_space.table;
|
||||||
|
|
||||||
const physical_address_space_size = mmap.getAddressSpaceSize(tag) orelse return error.InvalidMemoryMap;
|
const physical_address_space_size = mmap.getAddressSpaceSize(tag) orelse return error.InvalidMemoryMap;
|
||||||
|
|
||||||
space.table.* = std.mem.zeroes(PageTable);
|
user_table.* = std.mem.zeroes(PageTable);
|
||||||
|
|
||||||
const directory_upper_half: *[256]PageTableEntry = kernel_table.entries[256..];
|
const directory_upper_half: *[256]PageTableEntry = kernel_table.entries[256..];
|
||||||
const user_directory_upper_half: *[256]PageTableEntry = space.table.entries[256..];
|
const user_directory_upper_half: *[256]PageTableEntry = user_table.entries[256..];
|
||||||
@memcpy(user_directory_upper_half, directory_upper_half);
|
@memcpy(user_directory_upper_half, directory_upper_half);
|
||||||
|
|
||||||
const user_physical_address_base = (USER_ADDRESS_RANGE_END + 1) - physical_address_space_size;
|
const user_physical_address_base = (USER_ADDRESS_RANGE_END + 1) - physical_address_space_size;
|
||||||
|
|
||||||
|
const space = AddressSpace.create(.{ .address = @intFromPtr(user_table) }, 0);
|
||||||
|
|
||||||
try mapPhysicalMemory(allocator, tag, space, PHYSICAL_MAPPING_BASE, user_physical_address_base, @intFromEnum(Flags.ReadWrite) | @intFromEnum(Flags.NoExecute) | @intFromEnum(Flags.User));
|
try mapPhysicalMemory(allocator, tag, space, PHYSICAL_MAPPING_BASE, user_physical_address_base, @intFromEnum(Flags.ReadWrite) | @intFromEnum(Flags.NoExecute) | @intFromEnum(Flags.User));
|
||||||
|
|
||||||
return user_physical_address_base;
|
return user_physical_address_base;
|
||||||
|
@ -13,11 +13,51 @@ const elf = @import("elf.zig");
|
|||||||
|
|
||||||
const MultibootInfo = [*c]u8;
|
const MultibootInfo = [*c]u8;
|
||||||
|
|
||||||
export fn _start(_: u32, _: MultibootInfo) callconv(.C) noreturn {
|
fn adjustAddressToPageBoundary(address: *usize, size: *usize) void {
|
||||||
platform._start();
|
const diff = address.* % platform.PAGE_SIZE;
|
||||||
|
|
||||||
|
address.* -= diff;
|
||||||
|
size.* += diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
export fn main(magic: u32, info: MultibootInfo) callconv(.C) noreturn {
|
fn reserveMultibootMemory(allocator: *pmm.FrameAllocator, info: MultibootInfo) !void {
|
||||||
|
const info_tag: *easyboot.multiboot_info_t = @alignCast(@ptrCast(info));
|
||||||
|
|
||||||
|
var address: usize = @intFromPtr(info);
|
||||||
|
var size: usize = info_tag.total_size;
|
||||||
|
adjustAddressToPageBoundary(&address, &size);
|
||||||
|
|
||||||
|
debug.print("Locking multiboot memory at {x}, {d} bytes\n", .{ address, size });
|
||||||
|
|
||||||
|
try pmm.lockFrames(allocator, address, try std.math.divCeil(usize, size, platform.PAGE_SIZE));
|
||||||
|
|
||||||
|
const Context = struct {
|
||||||
|
allocator: *pmm.FrameAllocator,
|
||||||
|
};
|
||||||
|
|
||||||
|
var ctx = Context{ .allocator = allocator };
|
||||||
|
|
||||||
|
multiboot.findMultibootTags(easyboot.multiboot_tag_module_t, @ptrCast(info), struct {
|
||||||
|
fn reserveMemory(mod: *easyboot.multiboot_tag_module_t, context: *const Context) !void {
|
||||||
|
var mod_address: usize = mod.mod_start;
|
||||||
|
var mod_size: usize = mod.mod_end - mod.mod_start;
|
||||||
|
adjustAddressToPageBoundary(&mod_address, &mod_size);
|
||||||
|
|
||||||
|
debug.print("Locking memory for module {s} at address {x}, {d} bytes\n", .{ mod.string(), mod_address, mod_size });
|
||||||
|
|
||||||
|
try pmm.lockFrames(context.allocator, mod_address, try std.math.divCeil(usize, mod_size, platform.PAGE_SIZE));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handler(mod: *easyboot.multiboot_tag_module_t, context: *const anyopaque) void {
|
||||||
|
reserveMemory(mod, @alignCast(@ptrCast(context))) catch |err| {
|
||||||
|
debug.print("Error while reserving multiboot memory {s}: {}\n", .{ mod.string(), err });
|
||||||
|
while (true) {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}.handler, &ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
export fn _start(magic: u32, info: MultibootInfo) callconv(.C) noreturn {
|
||||||
interrupts.disableInterrupts();
|
interrupts.disableInterrupts();
|
||||||
|
|
||||||
if (magic != easyboot.MULTIBOOT2_BOOTLOADER_MAGIC) {
|
if (magic != easyboot.MULTIBOOT2_BOOTLOADER_MAGIC) {
|
||||||
@ -40,7 +80,7 @@ export fn main(magic: u32, info: MultibootInfo) callconv(.C) noreturn {
|
|||||||
while (true) {}
|
while (true) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
pmm.reserveMultibootMemory(&allocator, info) catch |err| {
|
reserveMultibootMemory(&allocator, info) catch |err| {
|
||||||
debug.print("Error while reserving multiboot memory: {}\n", .{err});
|
debug.print("Error while reserving multiboot memory: {}\n", .{err});
|
||||||
while (true) {}
|
while (true) {}
|
||||||
};
|
};
|
||||||
@ -68,7 +108,7 @@ export fn main(magic: u32, info: MultibootInfo) callconv(.C) noreturn {
|
|||||||
const frame = try pmm.allocFrame(context.allocator);
|
const frame = try pmm.allocFrame(context.allocator);
|
||||||
const space = vmm.AddressSpace.create(frame, vmm.PHYSICAL_MAPPING_BASE);
|
const space = vmm.AddressSpace.create(frame, vmm.PHYSICAL_MAPPING_BASE);
|
||||||
|
|
||||||
const base = try vmm.setUpInitialUserPageDirectory(context.allocator, context.mmap, space);
|
const base = try vmm.setUpInitialUserPageDirectory(context.allocator, context.mmap, space.table);
|
||||||
|
|
||||||
const module = try thread.createThreadControlBlock(context.allocator);
|
const module = try thread.createThreadControlBlock(context.allocator);
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ const vmm = @import("arch/vmm.zig");
|
|||||||
const mmap = @import("mmap.zig");
|
const mmap = @import("mmap.zig");
|
||||||
const bmap = @import("lib/bitmap.zig");
|
const bmap = @import("lib/bitmap.zig");
|
||||||
const locking = @import("lib/spinlock.zig");
|
const locking = @import("lib/spinlock.zig");
|
||||||
const debug = @import("arch/debug.zig");
|
|
||||||
const multiboot = @import("multiboot.zig");
|
|
||||||
|
|
||||||
const FrameAllocatorError = error{
|
const FrameAllocatorError = error{
|
||||||
InvalidMemoryMap,
|
InvalidMemoryMap,
|
||||||
@ -106,74 +104,9 @@ pub fn initializeFrameAllocator(tag: *easyboot.multiboot_tag_mmap_t) !FrameAlloc
|
|||||||
// Avoid causing trouble.
|
// Avoid causing trouble.
|
||||||
try lockFrame(&allocator, 0);
|
try lockFrame(&allocator, 0);
|
||||||
|
|
||||||
try reserveKernelMemory(&allocator);
|
|
||||||
|
|
||||||
return allocator;
|
return allocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn adjustAddressToPageBoundary(address: *usize, size: *usize) void {
|
|
||||||
const diff = address.* % platform.PAGE_SIZE;
|
|
||||||
|
|
||||||
address.* -= diff;
|
|
||||||
size.* += diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern const kernel_start: [*]u8;
|
|
||||||
extern const kernel_end: [*]u8;
|
|
||||||
|
|
||||||
fn reserveKernelMemory(allocator: *FrameAllocator) !void {
|
|
||||||
debug.print("Kernel begins at {*} and ends at {*}\n", .{ &kernel_start, &kernel_end });
|
|
||||||
|
|
||||||
const start: usize = @intFromPtr(&kernel_start);
|
|
||||||
const end: usize = @intFromPtr(&kernel_end);
|
|
||||||
const pages = try std.math.divCeil(usize, end - start, platform.PAGE_SIZE);
|
|
||||||
|
|
||||||
const page_table = vmm.readPageTable();
|
|
||||||
const space = vmm.AddressSpace.create(page_table, 0);
|
|
||||||
|
|
||||||
var i: usize = 0;
|
|
||||||
while (i < pages) : (i += 1) {
|
|
||||||
try lockFrame(allocator, vmm.getAddress(space, 0, start + (i * platform.PAGE_SIZE)).?);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn reserveMultibootMemory(allocator: *FrameAllocator, info: [*c]u8) !void {
|
|
||||||
const info_tag: *easyboot.multiboot_info_t = @alignCast(@ptrCast(info));
|
|
||||||
|
|
||||||
var address: usize = @intFromPtr(info);
|
|
||||||
var size: usize = info_tag.total_size;
|
|
||||||
adjustAddressToPageBoundary(&address, &size);
|
|
||||||
|
|
||||||
debug.print("Locking multiboot memory at {x}, {d} bytes\n", .{ address, size });
|
|
||||||
|
|
||||||
try lockFrames(allocator, address, try std.math.divCeil(usize, size, platform.PAGE_SIZE));
|
|
||||||
|
|
||||||
const Context = struct {
|
|
||||||
allocator: *FrameAllocator,
|
|
||||||
};
|
|
||||||
|
|
||||||
var ctx = Context{ .allocator = allocator };
|
|
||||||
|
|
||||||
multiboot.findMultibootTags(easyboot.multiboot_tag_module_t, @ptrCast(info), struct {
|
|
||||||
fn reserveMemory(mod: *easyboot.multiboot_tag_module_t, context: *const Context) !void {
|
|
||||||
var mod_address: usize = mod.mod_start;
|
|
||||||
var mod_size: usize = mod.mod_end - mod.mod_start;
|
|
||||||
adjustAddressToPageBoundary(&mod_address, &mod_size);
|
|
||||||
|
|
||||||
debug.print("Locking memory for module {s} at address {x}, {d} bytes\n", .{ mod.string(), mod_address, mod_size });
|
|
||||||
|
|
||||||
try lockFrames(context.allocator, mod_address, try std.math.divCeil(usize, mod_size, platform.PAGE_SIZE));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handler(mod: *easyboot.multiboot_tag_module_t, context: *const anyopaque) void {
|
|
||||||
reserveMemory(mod, @alignCast(@ptrCast(context))) catch |err| {
|
|
||||||
debug.print("Error while reserving multiboot memory {s}: {}\n", .{ mod.string(), err });
|
|
||||||
while (true) {}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}.handler, &ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
var lock: locking.SpinLock = .{};
|
var lock: locking.SpinLock = .{};
|
||||||
var global_allocator: *FrameAllocator = undefined;
|
var global_allocator: *FrameAllocator = undefined;
|
||||||
|
|
||||||
|
@ -24,15 +24,15 @@ pub fn yield(regs: *platform.Registers, _: *sys.Arguments, _: *isize) anyerror!v
|
|||||||
|
|
||||||
pub fn setPriority(_: *platform.Registers, args: *sys.Arguments, _: *isize) anyerror!void {
|
pub fn setPriority(_: *platform.Registers, args: *sys.Arguments, _: *isize) anyerror!void {
|
||||||
const core = cpu.thisCore();
|
const core = cpu.thisCore();
|
||||||
if (!sys.checkToken(core, system.kernel.Token.ThreadPriority)) return error.NotAuthorized;
|
|
||||||
const target = thread.lookupThreadById(args.arg0) orelse return error.NoSuchThread;
|
|
||||||
|
|
||||||
target.user_priority = @truncate(args.arg1);
|
if (!sys.checkToken(core, system.kernel.Token.ThreadPriority)) return error.NotAuthorized;
|
||||||
|
|
||||||
|
core.current_thread.user_priority = @truncate(args.arg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getPriority(_: *platform.Registers, args: *sys.Arguments, retval: *isize) anyerror!void {
|
pub fn getPriority(_: *platform.Registers, _: *sys.Arguments, retval: *isize) anyerror!void {
|
||||||
const target = thread.lookupThreadById(args.arg0) orelse return error.NoSuchThread;
|
const core = cpu.thisCore();
|
||||||
retval.* = target.user_priority;
|
retval.* = core.current_thread.user_priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sleep(regs: *platform.Registers, args: *sys.Arguments, _: *isize) anyerror!void {
|
pub fn sleep(regs: *platform.Registers, args: *sys.Arguments, _: *isize) anyerror!void {
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const init = @import("init/build.zig");
|
const init = @import("init/build.zig");
|
||||||
const memory = @import("memory/build.zig");
|
|
||||||
|
|
||||||
pub fn buildAsSubmodule(b: *std.Build, build_step: *std.Build.Step, optimize: std.builtin.OptimizeMode, system_module: *std.Build.Module) void {
|
pub fn buildAsSubmodule(b: *std.Build, build_step: *std.Build.Step, optimize: std.builtin.OptimizeMode, system_module: *std.Build.Module) void {
|
||||||
const system_step = b.step("system", "Build core system services");
|
const system_step = b.step("system", "Build core system services");
|
||||||
init.buildAsSubmodule(b, system_step, optimize, system_module);
|
init.buildAsSubmodule(b, system_step, optimize, system_module);
|
||||||
memory.buildAsSubmodule(b, system_step, optimize, system_module);
|
|
||||||
|
|
||||||
build_step.dependOn(system_step);
|
build_step.dependOn(system_step);
|
||||||
}
|
}
|
||||||
|
@ -25,22 +25,22 @@ fn setTokens() void {
|
|||||||
syscalls.setTokens(syscalls.getThreadId(), tokens) catch {};
|
syscalls.setTokens(syscalls.getThreadId(), tokens) catch {};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn discoverThreadLimit() u64 {
|
|
||||||
var pid: u64 = 1;
|
|
||||||
while (true) {
|
|
||||||
_ = syscalls.getPriority(pid) catch return (pid - 1);
|
|
||||||
pid += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export fn _start(base: u64, address: u64) callconv(.C) noreturn {
|
export fn _start(base: u64, address: u64) callconv(.C) noreturn {
|
||||||
setTokens();
|
setTokens();
|
||||||
|
|
||||||
const mapper = vm.MemoryMapper.create(.{ .address = address }, base);
|
const mapper = vm.MemoryMapper.create(.{ .address = address }, base);
|
||||||
_ = mapper;
|
|
||||||
|
|
||||||
const threads = discoverThreadLimit();
|
syscalls.print(base);
|
||||||
syscalls.print(threads);
|
syscalls.print(address);
|
||||||
|
syscalls.print(@intFromPtr(mapper.directory));
|
||||||
|
|
||||||
|
const phys = syscalls.allocFrame() catch {
|
||||||
|
while (true) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.map(&mapper, 0x6000000, .{ .address = phys }, @intFromEnum(vm.Flags.ReadWrite) | @intFromEnum(vm.Flags.User)) catch {
|
||||||
|
while (true) {}
|
||||||
|
};
|
||||||
|
|
||||||
const event_queue = setupKernelRingBuffer(base) catch {
|
const event_queue = setupKernelRingBuffer(base) catch {
|
||||||
while (true) {}
|
while (true) {}
|
||||||
|
@ -36,15 +36,12 @@ pub fn yield() void {
|
|||||||
_ = syscall(.Yield, 0, 0, 0);
|
_ = syscall(.Yield, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setPriority(pid: u64, priority: u8) !void {
|
pub fn setPriority(priority: u8) void {
|
||||||
const retval = syscall(.SetPriority, pid, priority, 0);
|
_ = syscall(.SetPriority, priority, 0, 0);
|
||||||
if (retval < 0) return error.NoSuchThread;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getPriority(pid: u64) !u8 {
|
pub fn getPriority() u8 {
|
||||||
const retval = syscall(.GetPriority, pid, 0, 0);
|
return @truncate(@as(u64, @bitCast(syscall(.GetPriority, 0, 0, 0))));
|
||||||
if (retval < 0) return error.NoSuchThread;
|
|
||||||
return @truncate(@as(u64, @bitCast(retval)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sleep(ms: u64) void {
|
pub fn sleep(ms: u64) void {
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
const std = @import("std");
|
|
||||||
|
|
||||||
const here = "system/memory";
|
|
||||||
|
|
||||||
pub fn buildAsSubmodule(b: *std.Build, build_step: *std.Build.Step, optimize: std.builtin.OptimizeMode, system_module: *std.Build.Module) void {
|
|
||||||
var disabled_features = std.Target.Cpu.Feature.Set.empty;
|
|
||||||
var enabled_features = std.Target.Cpu.Feature.Set.empty;
|
|
||||||
|
|
||||||
disabled_features.addFeature(@intFromEnum(std.Target.x86.Feature.mmx));
|
|
||||||
disabled_features.addFeature(@intFromEnum(std.Target.x86.Feature.sse));
|
|
||||||
disabled_features.addFeature(@intFromEnum(std.Target.x86.Feature.sse2));
|
|
||||||
disabled_features.addFeature(@intFromEnum(std.Target.x86.Feature.avx));
|
|
||||||
disabled_features.addFeature(@intFromEnum(std.Target.x86.Feature.avx2));
|
|
||||||
enabled_features.addFeature(@intFromEnum(std.Target.x86.Feature.soft_float));
|
|
||||||
|
|
||||||
const target_query = std.Target.Query{
|
|
||||||
.cpu_arch = std.Target.Cpu.Arch.x86_64,
|
|
||||||
.os_tag = std.Target.Os.Tag.freestanding,
|
|
||||||
.abi = std.Target.Abi.none,
|
|
||||||
.cpu_features_sub = disabled_features,
|
|
||||||
.cpu_features_add = enabled_features,
|
|
||||||
};
|
|
||||||
|
|
||||||
const memory = b.addExecutable(.{
|
|
||||||
.name = "memory",
|
|
||||||
.root_source_file = b.path(here ++ "/main.zig"),
|
|
||||||
.target = b.resolveTargetQuery(target_query),
|
|
||||||
.optimize = optimize,
|
|
||||||
.code_model = .default,
|
|
||||||
});
|
|
||||||
|
|
||||||
memory.root_module.addImport("system", system_module);
|
|
||||||
|
|
||||||
const install = b.addInstallArtifact(memory, .{
|
|
||||||
.dest_dir = .{
|
|
||||||
.override = .{ .custom = "boot/" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
var memory_step = b.step("memory", "Build the memory manager");
|
|
||||||
memory_step.dependOn(&memory.step);
|
|
||||||
memory_step.dependOn(&install.step);
|
|
||||||
|
|
||||||
build_step.dependOn(memory_step);
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
const system = @import("system");
|
|
||||||
|
|
||||||
const vm = system.vm;
|
|
||||||
const syscalls = system.syscalls;
|
|
||||||
|
|
||||||
fn setTokens() void {
|
|
||||||
var tokens: u64 = 0;
|
|
||||||
tokens |= @intFromEnum(system.kernel.Token.PhysicalMemory);
|
|
||||||
syscalls.setTokens(syscalls.getThreadId(), tokens) catch {};
|
|
||||||
}
|
|
||||||
|
|
||||||
export fn _start(_: u64, _: u64) callconv(.C) noreturn {
|
|
||||||
setTokens();
|
|
||||||
|
|
||||||
while (true) {}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user