initial commit
This commit is contained in:
10
lib/limine/limine.conf
Executable file
10
lib/limine/limine.conf
Executable file
@@ -0,0 +1,10 @@
|
||||
# Timeout in seconds that Limine will use before automatically booting.
|
||||
timeout: 0
|
||||
|
||||
# The entry name that will be displayed in the boot menu.
|
||||
/Tangerine
|
||||
# We use the Limine boot protocol.
|
||||
protocol: limine
|
||||
|
||||
# Path to the kernel to boot. boot():/ represents the partition on which limine.conf is located.
|
||||
kernel_path: boot():/boot/kernel
|
||||
281
lib/limine/limine.zig
Executable file
281
lib/limine/limine.zig
Executable file
@@ -0,0 +1,281 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub fn magic(a: u64, b: u64) [4]u64 {
|
||||
return .{ 0xc7b1dd30df4c8b88, 0x0a82e883a194f07b, a, b };
|
||||
}
|
||||
|
||||
pub const BaseRevision = extern struct {
|
||||
id: [2]u64 = .{ 0xf9562b2d5c95a6c8, 0x6a7b384944536bdc },
|
||||
revision: u64,
|
||||
|
||||
pub fn is_supported(self: *const volatile @This()) bool {
|
||||
return self.revision == 0;
|
||||
}
|
||||
};
|
||||
|
||||
pub const BootloaderInfo = struct {
|
||||
pub const Request = extern struct {
|
||||
id: [4]u64 = magic(0xf55038d8e2a1202f, 0x279426fcf5f59740),
|
||||
revision: u64 = 0,
|
||||
response: ?*Response = null,
|
||||
};
|
||||
|
||||
pub const Response = extern struct {
|
||||
revision: u64,
|
||||
name: [*:0]u8,
|
||||
version: [*:0]u8,
|
||||
};
|
||||
};
|
||||
|
||||
pub const BootTime = struct {
|
||||
pub const Request = extern struct {
|
||||
id: [4]u64 = magic(0x502746e184c088aa, 0xfbc5ec83e6327893),
|
||||
revision: u64 = 0,
|
||||
response: ?*Response = null,
|
||||
};
|
||||
|
||||
pub const Response = extern struct {
|
||||
revision: u64,
|
||||
boot_time: i64,
|
||||
};
|
||||
};
|
||||
|
||||
pub const File = extern struct {
|
||||
revision: u64,
|
||||
address: [*]u8,
|
||||
size: u64,
|
||||
path: [*:0]u8,
|
||||
cmdline: [*:0]u8,
|
||||
media_type: MediaType,
|
||||
unused: u32,
|
||||
tftp_ip: u32,
|
||||
tftp_port: u32,
|
||||
partition_index: u32,
|
||||
mbr_disk_id: u32,
|
||||
gpt_disk_uuid: Uuid,
|
||||
gpt_part_uuid: Uuid,
|
||||
part_uuid: Uuid,
|
||||
|
||||
pub const Uuid = extern struct {
|
||||
a: u32,
|
||||
b: u16,
|
||||
c: u16,
|
||||
d: [8]u8,
|
||||
};
|
||||
|
||||
pub const MediaType = enum(u32) {
|
||||
generic = 0,
|
||||
optical = 1,
|
||||
tftp = 2,
|
||||
};
|
||||
};
|
||||
|
||||
pub const Framebuffer = extern struct {
|
||||
address: [*]u8,
|
||||
width: u64,
|
||||
height: u64,
|
||||
pitch: u64,
|
||||
bpp: u16,
|
||||
memory_model: MemoryModel,
|
||||
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: ?[*]u8,
|
||||
|
||||
// Response revision 1
|
||||
mode_count: u64,
|
||||
modes: [*]*VideoMode,
|
||||
|
||||
pub const MemoryModel = enum(u8) {
|
||||
rgb = 1,
|
||||
};
|
||||
|
||||
pub const VideoMode = extern struct {
|
||||
pitch: u64,
|
||||
width: u64,
|
||||
height: u64,
|
||||
bpp: u16,
|
||||
memory_model: MemoryModel,
|
||||
red_mask_size: u8,
|
||||
red_mask_shift: u8,
|
||||
green_mask_size: u8,
|
||||
green_mask_shift: u8,
|
||||
blue_mask_size: u8,
|
||||
blue_mask_shift: u8,
|
||||
};
|
||||
|
||||
pub const Request = extern struct {
|
||||
id: [4]u64 = magic(0x9d5827dcd881dd75, 0xa3148604f6fab11b),
|
||||
revision: u64 = 1,
|
||||
response: ?*Response = null
|
||||
};
|
||||
|
||||
pub const Response = extern struct {
|
||||
revision: u64,
|
||||
framebuffer_count: u64,
|
||||
framebuffers: [*]*Framebuffer,
|
||||
|
||||
pub inline fn getFramebuffers(self: *@This()) []*Framebuffer {
|
||||
return self.framebuffers[0..self.framebuffer_count];
|
||||
}
|
||||
};
|
||||
|
||||
pub inline fn getEdid(self: *@This()) ?[]u8 {
|
||||
if (self.edid) |edid| {
|
||||
return edid[0..self.edid_size];
|
||||
}
|
||||
}
|
||||
|
||||
pub inline fn getModes(self: *@This()) []*VideoMode {
|
||||
return self.modes[0..self.mode_count];
|
||||
}
|
||||
};
|
||||
|
||||
pub const Hhdm = struct {
|
||||
pub const Request = extern struct {
|
||||
id: [4]u64 = magic(0x48dcf1cb8ad2b852, 0x63984e959a98244b),
|
||||
revision: u64 = 0,
|
||||
response: ?*Response = null,
|
||||
};
|
||||
|
||||
pub const Response = extern struct {
|
||||
revision: u64,
|
||||
offset: u64,
|
||||
};
|
||||
};
|
||||
|
||||
pub const Rsdp = struct {
|
||||
pub const Request = extern struct {
|
||||
id: [4]u64 = magic(0xc5e77b6b397e7b43, 0x27637845accdcf3c),
|
||||
revision: u64 = 0,
|
||||
response: ?*Response = null,
|
||||
};
|
||||
|
||||
pub const Response = extern struct {
|
||||
revision: u64,
|
||||
address: u64,
|
||||
};
|
||||
};
|
||||
|
||||
pub const MemoryMap = struct {
|
||||
pub const Request = extern struct {
|
||||
id: [4]u64 = magic(0x67cf3d9d378a806f, 0xe304acdfc50c3c62),
|
||||
revision: u64 = 0,
|
||||
response: ?*Response = null,
|
||||
};
|
||||
|
||||
pub const Response = extern struct {
|
||||
revision: u64,
|
||||
entry_count: u64,
|
||||
entries: [*]*Entry,
|
||||
|
||||
pub inline fn getEntries(self: *@This()) []*Entry {
|
||||
return self.entries[0..self.entry_count];
|
||||
}
|
||||
};
|
||||
|
||||
pub const Entry = extern struct {
|
||||
base: u64,
|
||||
length: u64,
|
||||
type: EntryType,
|
||||
};
|
||||
|
||||
pub const EntryType = enum(u64) {
|
||||
usable = 0,
|
||||
reserved = 1,
|
||||
acpi_reclaimable = 2,
|
||||
acpi_nvs = 3,
|
||||
bad_memory = 4,
|
||||
bootloader_reclaimable = 5,
|
||||
kernel_and_modules = 6,
|
||||
framebuffer = 7,
|
||||
};
|
||||
};
|
||||
|
||||
pub const Paging = struct {
|
||||
pub const Mode = switch (builtin.cpu.arch) {
|
||||
.aarch64, .x86_64 => enum(u64) {
|
||||
four_level,
|
||||
five_level,
|
||||
|
||||
pub inline fn default() Mode {
|
||||
return Mode.four_level;
|
||||
}
|
||||
|
||||
pub inline fn max() Mode {
|
||||
return Mode.five_level;
|
||||
}
|
||||
|
||||
pub inline fn min() Mode {
|
||||
return Mode.four_level;
|
||||
}
|
||||
},
|
||||
.loongarch64 => enum(u64) {
|
||||
four_level,
|
||||
|
||||
pub inline fn default() Mode {
|
||||
return Mode.four_level;
|
||||
}
|
||||
|
||||
pub inline fn max() Mode {
|
||||
return Mode.four_level;
|
||||
}
|
||||
|
||||
pub inline fn min() Mode {
|
||||
return Mode.four_level;
|
||||
}
|
||||
},
|
||||
.riscv64 => enum(u64) {
|
||||
sv39,
|
||||
sv48,
|
||||
sv57,
|
||||
|
||||
pub inline fn default() Mode {
|
||||
return Mode.sv48;
|
||||
}
|
||||
|
||||
pub inline fn max() Mode {
|
||||
return Mode.sv57;
|
||||
}
|
||||
|
||||
pub inline fn min() Mode {
|
||||
return Mode.sv39;
|
||||
}
|
||||
},
|
||||
else => |x| @compileError("Unsupported architecture: " ++ @tagName(x)),
|
||||
};
|
||||
|
||||
pub const Request = extern struct {
|
||||
id: [4]u64 = magic(0x95c1a0edab0944cb, 0xa4e5cb3842f7488a),
|
||||
revision: u64 = 0,
|
||||
response: ?*Response = null,
|
||||
mode: Mode = .default(),
|
||||
|
||||
// Revision 1+
|
||||
max_mode: Mode = .max(),
|
||||
min_mode: Mode = .min(),
|
||||
};
|
||||
|
||||
pub const Response = extern struct {
|
||||
revision: u64,
|
||||
mode: Mode
|
||||
};
|
||||
};
|
||||
|
||||
pub const DeviceTreeBlob = struct {
|
||||
pub const Request = extern struct {
|
||||
id: [4]u64 = magic(0xb40ddb48fb54bac7, 0x545081493f81ffb7),
|
||||
revision: u64 = 0,
|
||||
response: ?*Response = null,
|
||||
};
|
||||
|
||||
pub const Response = extern struct {
|
||||
revision: u64,
|
||||
pointer: ?*anyopaque,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user