-
-
Save betawaffle/f44a2033815dad64ac91e39c7fe64c6f to your computer and use it in GitHub Desktop.
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
// Flags to be set in the ’flags’ member of the multiboot info structure. | |
const InfoFlags = packed struct { | |
// Is there basic lower/upper memory information? | |
memory: bool, // 0x00000001 | |
// Is there a boot device set? | |
bootdev: bool, // 0x00000002 | |
// Is the command-line defined? | |
cmdline: bool, // 0x00000004 | |
// Are there modules to do something with? | |
mods: bool, // 0x00000008 | |
// Is there a symbol table loaded? Mutually exclusive with elf_shdr. | |
aout_syms: bool, // 0x00000010 | |
// Is there an ELF section header table? Mutually exclusive with aout_syms. | |
elf_shdr: bool, // 0x00000020 | |
// Is there a full memory map? | |
mem_map: bool, // 0x00000040 | |
// Is there drive info? | |
drive_info: bool, // 0x00000080 | |
// Is there a config table? | |
config_table: bool, // 0x00000100 | |
// Is there a boot loader name? | |
boot_loader_name: bool, // 0x00000200 | |
// Is there an APM table? | |
apm_table: bool, // 0x00000400 | |
// Is there video information? | |
vbe_info: bool, // 0x00000800 | |
framebuffer_info: bool, // 0x00001000 | |
unused: u19, | |
}; | |
comptime { | |
assert(@bitSizeOf(InfoFlags) == 32); | |
} | |
pub const Info = packed struct { | |
flags: InfoFlags align(4), | |
mem_lower: u32, | |
mem_upper: u32, | |
boot_device: packed struct { | |
part3: u8, | |
part2: u8, | |
part1: u8, | |
drive: u8, | |
}, | |
cmdline: [*:0]const u8, | |
mods_count: u32, | |
mods_addr: [*]const u8, | |
syms: packed union { | |
aout_sym: packed struct { | |
tabsize: u32, | |
strsize: u32, | |
addr: u32, | |
reserved: u32, | |
}, | |
elf_sec: packed struct { | |
num: u32, | |
size: u32, | |
addr: u32, | |
shndx: u32, | |
}, | |
}, | |
mmap_length: u32, | |
mmap_addr: [*]const u8, | |
drives_length: u32, | |
drives_addr: [*]const u8, | |
config_table: u32, | |
boot_loader_name: u32, | |
apm_table: u32, | |
vbe_control_info: u32, | |
vbe_mode_info: u32, | |
vbe_mode: u16, | |
vbe_interface_seg: u16, | |
vbe_interface_off: u16, | |
vbe_interface_len: u16, | |
framebuffer_addr: u64, | |
framebuffer_pitch: u32, | |
framebuffer_width: u32, | |
framebuffer_height: u32, | |
framebuffer_bpp: u8, | |
framebuffer_type: u8, | |
color_info: packed union { | |
indexed: packed struct { | |
framebuffer_palette_addr: u32, | |
framebuffer_palette_num_colors: u16, | |
}, | |
rgb: packed struct { | |
framebuffer_red_field_position: u8, | |
framebuffer_red_mask_size: u8, | |
framebuffer_green_field_position: u8, | |
framebuffer_green_mask_size: u8, | |
framebuffer_blue_field_position: u8, | |
framebuffer_blue_mask_size: u8, | |
}, | |
ega_text: void, | |
}, | |
}; | |
comptime { | |
assert(@byteOffsetOf(Info, "flags") == 0); | |
assert(@byteOffsetOf(Info, "mem_lower") == 4); | |
assert(@byteOffsetOf(Info, "mem_upper") == 8); | |
assert(@byteOffsetOf(Info, "boot_device") == 12); | |
assert(@byteOffsetOf(Info, "cmdline") == 16); | |
assert(@byteOffsetOf(Info, "mods_count") == 20); | |
assert(@byteOffsetOf(Info, "mods_addr") == 24); | |
assert(@byteOffsetOf(Info, "syms") == 28); | |
assert(@byteOffsetOf(Info, "mmap_length") == 44); | |
assert(@byteOffsetOf(Info, "mmap_addr") == 48); | |
assert(@byteOffsetOf(Info, "drives_length") == 52); | |
assert(@byteOffsetOf(Info, "drives_addr") == 56); | |
assert(@byteOffsetOf(Info, "config_table") == 60); | |
assert(@byteOffsetOf(Info, "boot_loader_name") == 64); | |
assert(@byteOffsetOf(Info, "apm_table") == 68); | |
assert(@byteOffsetOf(Info, "vbe_control_info") == 72); | |
assert(@byteOffsetOf(Info, "vbe_mode_info") == 76); | |
assert(@byteOffsetOf(Info, "vbe_mode") == 80); | |
assert(@byteOffsetOf(Info, "vbe_interface_seg") == 82); | |
assert(@byteOffsetOf(Info, "vbe_interface_off") == 84); | |
assert(@byteOffsetOf(Info, "vbe_interface_len") == 86); | |
assert(@byteOffsetOf(Info, "framebuffer_addr") == 88); | |
assert(@byteOffsetOf(Info, "framebuffer_pitch") == 96); | |
assert(@byteOffsetOf(Info, "framebuffer_width") == 100); | |
assert(@byteOffsetOf(Info, "framebuffer_height") == 104); | |
assert(@byteOffsetOf(Info, "framebuffer_bpp") == 108); | |
assert(@byteOffsetOf(Info, "framebuffer_type") == 109); | |
assert(@byteOffsetOf(Info, "color_info") == 110); | |
// Extra 4 bytes of padding? | |
assert(@sizeOf(Info) == 116 + 4); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment