Last active
August 2, 2020 19:59
-
-
Save cinemast/bab73717155b07d23cd10885b6a319a3 to your computer and use it in GitHub Desktop.
bootboot.zig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ExportOptions = @import("std").builtin.ExportOptions; | |
const FrameBufferType = enum(u8) { | |
ARGB = 0, | |
RGBA = 1, | |
ABGR = 2, | |
BGRA = 3 | |
}; | |
const ProtocolLevel = enum(u2) { | |
MINIAMAL = 0, | |
STATIC = 1, | |
DYNAMIC = 2 | |
}; | |
const Endianess = enum(u1) { | |
BIG_ENDIAN = 1, | |
LITTL_ENDIAN = 0 | |
}; | |
const LoaderType = enum(u5) { | |
BIOS = (0<<2), | |
UEFI = (1<<2), | |
RASPBERRY_PI = (2<<2) | |
}; | |
const ProtocolInfo = extern struct { | |
protocolLevel: ProtocolLevel, | |
loaderType: LoaderType, | |
endianness: Endianess, | |
}; | |
const PlatformX8664 = extern struct { | |
acpi: u64, | |
smbi: u64, | |
efi: u64, | |
mp: u64, | |
unused: [4]u64 | |
}; | |
const PlatformAarch64 = extern struct { | |
acpi: u64, | |
mmio: u64, | |
efi: u64, | |
unused: [5]u64 | |
}; | |
const ArchSpecific = extern union { | |
x8664: PlatformX8664, | |
aarch64: PlatformAarch64 | |
}; | |
const Mmap = extern struct { | |
ptr: u64, | |
size: u64 | |
}; | |
const Bootboot = extern struct { | |
magic: [4]u8, | |
size: u32, | |
protocol: u8, | |
fbType: u8, | |
numcores: u16, | |
bspId: u16, | |
timezone: i16, | |
datetime: [8]u8, | |
initrdAddress: u64, | |
initrdSize: u64, | |
frameBufferAddress: *u8, | |
frameBufferSize: u32, | |
frameBufferWidth: u32, | |
frameBufferHeight: u32, | |
frameBufferScanLine: u32, | |
specific: ArchSpecific, | |
mmap: Mmap | |
}; | |
pub var boot : *Bootboot; | |
comptime { | |
@export(boot, .{ .name = "boot", .section = "boot", .linkage = .Strong }); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */ | |
fb = 0xfffffffffc000000; | |
PHDRS | |
{ | |
boot PT_LOAD; /* one single loadable segment */ | |
} | |
SECTIONS | |
{ | |
. = 0xffffffffffe00000; | |
bootboot = .; . += 4096; | |
environment = .; . += 4096; | |
.text : { | |
KEEP(*(.text.boot)) *(.text .text.*) /* code */ | |
*(.rodata .rodata.*) /* data */ | |
*(.data .data.*) | |
} :boot | |
.bss (NOLOAD) : { /* bss */ | |
. = ALIGN(16); | |
*(.bss .bss.*) | |
*(COMMON) | |
} :boot | |
/DISCARD/ : { *(.eh_frame) *(.comment) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment