mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-30 23:08:21 +00:00
refactor: slightly refactor amd64
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
const b = @import("base");
|
||||
const ki = b.ke.private;
|
||||
|
||||
pub const name = "AMD64";
|
||||
|
||||
pub fn first_init() void {}
|
||||
pub const name = "amd64";
|
||||
|
||||
pub fn early_init() void {
|
||||
const impl_cpu = &ki.bootstrap_cpu.impl;
|
||||
|
||||
@@ -3,23 +3,16 @@ const ksyms = @import("ksyms");
|
||||
|
||||
const pl = b.pl;
|
||||
const ke = b.ke;
|
||||
const ki = ke.private;
|
||||
|
||||
pub const std_options = b.std_options;
|
||||
pub const panic = b.panic;
|
||||
|
||||
pub const rtl = @import("rtl");
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
var boot_info: pl.BootInfo = undefined;
|
||||
|
||||
export fn kmain() callconv(.c) void {
|
||||
std.log.info("hello from kernel!", .{});
|
||||
|
||||
for (ksyms.ksyms) |sym| {
|
||||
std.log.info(" 0x{x:0>16} {s}", .{ sym.addr, sym.name });
|
||||
}
|
||||
|
||||
boot_info.memory_map.entry_count = 0;
|
||||
|
||||
var cpus: [1]*ke.Cpu = .{&ke.private.bootstrap_cpu};
|
||||
@@ -27,5 +20,5 @@ export fn kmain() callconv(.c) void {
|
||||
ke.ncpus = 1;
|
||||
ke.cpus = &cpus;
|
||||
|
||||
ke.private.init(&boot_info);
|
||||
ki.init(&boot_info);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
pub const common_magic: [2]u64 = .{
|
||||
0xc7b1dd30df4c8b88,
|
||||
0x0a82e883a194f07b,
|
||||
};
|
||||
|
||||
pub const requests_start_marker: [4]u64 = .{
|
||||
0xf6b8f4b39de7d1ae,
|
||||
0xfab91a6940fcb9cf,
|
||||
0x785c6ed015d3e316,
|
||||
0x181e920a7852b9d9,
|
||||
};
|
||||
|
||||
pub const requests_end_marker: [2]u64 = .{
|
||||
0xadc0e0531bb10d03,
|
||||
0x9572709f31764c62,
|
||||
};
|
||||
|
||||
pub fn baseRevision(rev: u64) [3]u64 {
|
||||
return .{
|
||||
0xf9562b2d5c95a6c8,
|
||||
0x6a7b384944536bdc,
|
||||
rev,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn baseRevisionSupported(base_rev: *const [3]u64) bool {
|
||||
// Limine will overwrite base_rev[2] with 0 if it supports the requested revision.
|
||||
return base_rev[2] == 0;
|
||||
}
|
||||
|
||||
pub const framebuffer_request_id: [4]u64 = .{
|
||||
common_magic[0],
|
||||
common_magic[1],
|
||||
0x9d5827dcd881dd75,
|
||||
0xa3148604f6fab11b,
|
||||
};
|
||||
|
||||
pub const FramebufferRequest = extern struct {
|
||||
id: [4]u64,
|
||||
revision: u64,
|
||||
response: ?*FramebufferResponse,
|
||||
};
|
||||
|
||||
pub const FramebufferResponse = extern struct {
|
||||
revision: u64,
|
||||
framebuffer_count: u64,
|
||||
framebuffers: ?[*]*Framebuffer,
|
||||
};
|
||||
|
||||
pub const Framebuffer = extern struct {
|
||||
address: ?*anyopaque,
|
||||
width: u64,
|
||||
height: u64,
|
||||
pitch: u64,
|
||||
bpp: u16,
|
||||
memory_model: u8,
|
||||
red_mask_size: u8,
|
||||
red_mask_shift: u8,
|
||||
green_mask_size: u8,
|
||||
green_mask_shift: u8,
|
||||
blue_mask_size: u8,
|
||||
blue_mask_shift: u8,
|
||||
unused: [7]u8,
|
||||
edid_size: u64,
|
||||
edid: ?*anyopaque,
|
||||
// Response revision 1 fields (ignored by this template).
|
||||
mode_count: u64,
|
||||
modes: ?[*]*anyopaque,
|
||||
};
|
||||
|
||||
@@ -10,10 +10,6 @@ else if (@hasDecl(config, "CONFIG_ARCH_UM"))
|
||||
else
|
||||
@compileError("unsupported architecture");
|
||||
|
||||
pub inline fn first_init() void {
|
||||
return impl.first_init();
|
||||
}
|
||||
|
||||
/// Early platform-specific initialization, called before anything else.
|
||||
pub inline fn early_init() void {
|
||||
return impl.early_init();
|
||||
|
||||
@@ -3,8 +3,6 @@ const b = @import("base");
|
||||
pub const std_options = b.std_options;
|
||||
pub const panic = b.panic;
|
||||
|
||||
pub const rtl = @import("rtl");
|
||||
|
||||
const c = @cImport({
|
||||
@cInclude("SDL.h");
|
||||
@cInclude("signal.h");
|
||||
|
||||
@@ -37,8 +37,6 @@ pub const GlobalState = struct {
|
||||
pub var global_state: GlobalState = undefined;
|
||||
pub threadlocal var my_cpu: *ke.Cpu = undefined;
|
||||
|
||||
pub fn devices_init() void {}
|
||||
|
||||
pub fn debug_write(char: u8) void {
|
||||
_ = linux.write(linux.STDERR_FILENO, @ptrCast(&char), 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user