mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
loader: detect CPU features
This commit is contained in:
@@ -739,3 +739,7 @@ pub const IdtEntry = extern struct {
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
pub const BootInfo = struct {
|
||||
cpu_features: CpuFeatures,
|
||||
};
|
||||
|
||||
@@ -107,7 +107,7 @@ var initial_offsets: [1]usize = .{0};
|
||||
extern var __percpu_start: u8;
|
||||
|
||||
pub fn early_init() linksection(r.init) void {
|
||||
amd64.detect_cpu_features();
|
||||
amd64.cpu_features = r.boot_info.arch_info.cpu_features;
|
||||
early_cpu_init();
|
||||
|
||||
impl.cpu_offsets = &initial_offsets;
|
||||
|
||||
@@ -10,6 +10,8 @@ var thread0: ke.Thread = undefined;
|
||||
var stack: [r.kib(16)]u8 align(16) = undefined;
|
||||
|
||||
pub fn init(boot_info: *r.BootInfo) linksection(r.init) void {
|
||||
r.boot_info = boot_info;
|
||||
|
||||
ke.ncpus = 1;
|
||||
ki.impl.early_init();
|
||||
ki.tunable.init(boot_info);
|
||||
|
||||
@@ -113,4 +113,5 @@ pub fn debug_write(c: u8) void {
|
||||
|
||||
pub fn init() void {
|
||||
amd64.detect_cpu_features();
|
||||
r.loader_info.arch_info.cpu_features = amd64.cpu_features;
|
||||
}
|
||||
|
||||
+3
-4
@@ -1,3 +1,5 @@
|
||||
const arch = @import("arch");
|
||||
|
||||
/// Represents the system memory map.
|
||||
pub const MemMap = struct {
|
||||
/// A memory map entry.
|
||||
@@ -32,8 +34,6 @@ pub const Framebuffer = struct {
|
||||
// Kept in sync with the kernel
|
||||
pub const page_struct_size = 16;
|
||||
|
||||
pub const KernelAddress = struct { physical_base: usize, virtual_base: usize };
|
||||
|
||||
/// RSDP on ACPI machines
|
||||
rsdp: ?usize,
|
||||
|
||||
@@ -46,5 +46,4 @@ memory_map: MemMap,
|
||||
/// Framebuffer info, if available
|
||||
framebuffer: ?Framebuffer,
|
||||
|
||||
/// Kernel address
|
||||
kernel_address: KernelAddress,
|
||||
arch_info: arch.BootInfo,
|
||||
|
||||
@@ -24,6 +24,8 @@ pub const Nanoseconds = u64;
|
||||
pub var kernel_heap_base: usize = 0;
|
||||
pub var kernel_pfndb_base: usize = 0;
|
||||
|
||||
pub var boot_info: *BootInfo = undefined;
|
||||
|
||||
/// Return N kibibytes in bytes.
|
||||
pub fn kib(comptime N: u32) usize {
|
||||
return N * 1024;
|
||||
|
||||
Reference in New Issue
Block a user