The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
boot_info.h
Go to the documentation of this file.
1#pragma once
2
3#include "common/stdint.h"
4#include "memory_map.h"
5
6/**
7 * information the bootloader hands to the kernel.
8 *
9 * the layout up to and including memory_map is shared byte-for-byte with the
10 * stage2 assembly that fills it in (see src/bootloader/stage2/main.asm), so
11 * those fields must not be reordered. anything a boot protocol cannot supply
12 * is left zero: framebuffer_addr == 0 means "no framebuffer", cmdline_addr
13 * == 0 means "no command line".
14 *
15 * stage2 fills in the fields up to and including the framebuffer pixel
16 * format. the kernel copies only that part into its own boot_info_t
17 * (kernel.c), so the fields after it are zero on a stage2 boot. a multiboot 2
18 * boot fills in all fields (arch/x86/boot/multiboot2.c).
19 */
20typedef struct
21{
22 // shared with stage2 assembly (do not reorder)
23 uint8_t boot_drive; // x86/BIOS drive number the system booted from (e.g. 0x80).
24 uint8_t _reserved[3]; // alignment padding, zeroed.
25 memory_map_t memory_map; // physical memory regions reported by the boot protocol.
26
27 // arch-neutral, filled when the boot protocol provides them
28 uint32_t framebuffer_addr; // physical address of a linear framebuffer, or 0 if none.
29 uint32_t framebuffer_width; // framebuffer width in pixels (valid when addr != 0).
30 uint32_t framebuffer_height; // framebuffer height in pixels (valid when addr != 0).
31 uint32_t cmdline_addr; // physical address of a NUL-terminated boot command
32 // line, or 0 if none (a fixed-width field: stage2
33 // is 32-bit, the kernel may not be)
34
35 // framebuffer pixel format (valid when framebuffer_type != 0). the channel
36 // size/shift pairs describe how r/g/b sit inside a pixel, so the driver can
37 // compose pixels for whatever layout VBE reports instead of assuming
38 // 0x00RRGGBB. all zero when there is no framebuffer.
39 uint32_t framebuffer_pitch; // bytes per scanline (may exceed width * bpp/8).
40 uint8_t framebuffer_bpp; // bits per pixel (e.g. 32).
41 uint8_t framebuffer_type; // 0 = none/text, 1 = RGB linear framebuffer.
42 uint8_t framebuffer_red_size; // red channel bit width.
43 uint8_t framebuffer_red_shift; // red channel low bit position.
44 uint8_t framebuffer_green_size; // green channel bit width.
45 uint8_t framebuffer_green_shift; // green channel low bit position.
46 uint8_t framebuffer_blue_size; // blue channel bit width.
47 uint8_t framebuffer_blue_shift; // blue channel low bit position.
48 uint8_t _fb_pad[2]; // pad to a 4-byte boundary, zeroed.
49
50 // the fields below are not shared with stage2
51
52 uint32_t boot_protocol; // BOOT_PROTOCOL_STAGE2, _MULTIBOOT2 or _LIMINE.
53
54 // a root filesystem image that the bootloader loaded into RAM (a boot
55 // module), or 0 and 0. the physical range [initrd_start, initrd_end)
56 // stays reserved.
59
60 // a copy of the ACPI RSDP from the bootloader (rsdp_size 0: none). a
61 // multiboot 2 bootloader gives a copy, not an address.
64
65 // bits 32 to 63 of the framebuffer address: on UEFI machines it is
66 // often above 4 GiB (only a 64-bit kernel can use that)
69
70#define BOOT_PROTOCOL_STAGE2 0 // the custom BIOS bootloader (src/bootloader)
71#define BOOT_PROTOCOL_MULTIBOOT2 1 // a multiboot 2 bootloader, for example limine
72#define BOOT_PROTOCOL_LIMINE 2 // the limine boot protocol (x86_64)
73
74/* the part of boot_info_t that stage2 fills in */
75#define BOOT_INFO_STAGE2_SIZE __builtin_offsetof(boot_info_t, _fb_pad)
unsigned int uint32_t
Definition fb.h:17
unsigned char uint8_t
Definition fb.h:18
information the bootloader hands to the kernel.
Definition boot_info.h:21
uint32_t rsdp_size
Definition boot_info.h:62
uint32_t framebuffer_addr
Definition boot_info.h:28
uint8_t framebuffer_red_shift
Definition boot_info.h:43
uint8_t framebuffer_green_size
Definition boot_info.h:44
uint8_t framebuffer_type
Definition boot_info.h:41
memory_map_t memory_map
Definition boot_info.h:25
uint8_t _reserved[3]
Definition boot_info.h:24
uint32_t boot_protocol
Definition boot_info.h:52
uint8_t framebuffer_blue_size
Definition boot_info.h:46
uint32_t initrd_end
Definition boot_info.h:58
uint8_t rsdp[36]
Definition boot_info.h:63
uint8_t boot_drive
Definition boot_info.h:23
uint8_t framebuffer_bpp
Definition boot_info.h:40
uint32_t framebuffer_pitch
Definition boot_info.h:39
uint32_t framebuffer_width
Definition boot_info.h:29
uint8_t _fb_pad[2]
Definition boot_info.h:48
uint8_t framebuffer_blue_shift
Definition boot_info.h:47
uint32_t framebuffer_addr_high
Definition boot_info.h:67
uint8_t framebuffer_green_shift
Definition boot_info.h:45
uint32_t cmdline_addr
Definition boot_info.h:31
uint32_t initrd_start
Definition boot_info.h:57
uint32_t framebuffer_height
Definition boot_info.h:30
uint8_t framebuffer_red_size
Definition boot_info.h:42
structure representing the system's memory map, containing multiple memory regions.
Definition memory_map.h:20