MentOS  0.8.0
The Mentoring Operating System
multiboot.h
Go to the documentation of this file.
1 
6 // Do not inc here in boot.s.
7 
8 #pragma once
9 
10 #include "stdint.h"
11 
12 #define MULTIBOOT_HEADER_MAGIC 0x1BADB002U
13 #define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002U
14 
15 #define MULTIBOOT_FLAG_MEM 0x00000001U
16 #define MULTIBOOT_FLAG_DEVICE 0x00000002U
17 #define MULTIBOOT_FLAG_CMDLINE 0x00000004U
18 #define MULTIBOOT_FLAG_MODS 0x00000008U
19 #define MULTIBOOT_FLAG_AOUT 0x00000010U
20 #define MULTIBOOT_FLAG_ELF 0x00000020U
21 #define MULTIBOOT_FLAG_MMAP 0x00000040U
22 #define MULTIBOOT_FLAG_DRIVE_INFO 0x00000080U
23 #define MULTIBOOT_FLAG_CONFIG_TABLE 0x00000100U
24 #define MULTIBOOT_FLAG_BOOT_LOADER_NAME 0x00000200U
25 #define MULTIBOOT_FLAG_APM_TABLE 0x00000400U
26 #define MULTIBOOT_FLAG_VBE_INFO 0x00000800U
27 #define MULTIBOOT_FLAG_FRAMEBUFFER_INFO 0x00001000U
28 
29 #define MULTIBOOT_MEMORY_AVAILABLE 1
30 #define MULTIBOOT_MEMORY_RESERVED 2
31 
32 // +-------------------+
33 // 0 | flags | (required)
34 // +-------------------+
35 // 4 | mem_lower | (present if flags[0] is set)
36 // 8 | mem_upper | (present if flags[0] is set)
37 // +-------------------+
38 // 12 | boot_device | (present if flags[1] is set)
39 // +-------------------+
40 // 16 | cmdline | (present if flags[2] is set)
41 // +-------------------+
42 // 20 | mods_count | (present if flags[3] is set)
43 // 24 | mods_addr | (present if flags[3] is set)
44 // +-------------------+
45 // 28 - 40 | syms | (present if flags[4] or
46 // | | flags[5] is set)
47 // +-------------------+
48 // 44 | mmap_length | (present if flags[6] is set)
49 // 48 | mmap_addr | (present if flags[6] is set)
50 // +-------------------+
51 // 52 | drives_length | (present if flags[7] is set)
52 // 56 | drives_addr | (present if flags[7] is set)
53 // +-------------------+
54 // 60 | config_table | (present if flags[8] is set)
55 // +-------------------+
56 // 64 | boot_loader_name | (present if flags[9] is set)
57 // +-------------------+
58 // 68 | apm_table | (present if flags[10] is set)
59 // +-------------------+
60 // 72 | vbe_control_info | (present if flags[11] is set)
61 // 76 | vbe_mode_info |
62 // 80 | vbe_mode |
63 // 82 | vbe_interface_seg |
64 // 84 | vbe_interface_off |
65 // 86 | vbe_interface_len |
66 // +-------------------+
67 // 88 | framebuffer_addr | (present if flags[12] is set)
68 // 96 | framebuffer_pitch |
69 // 100 | framebuffer_width |
70 // 104 | framebuffer_height|
71 // 108 | framebuffer_bpp |
72 // 109 | framebuffer_type |
73 // 110-115 | color_info |
74 // +-------------------+
75 
87 
99 
101 typedef struct multiboot_module_t {
102  // The memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive.
112 
114 typedef struct multiboot_memory_map_t {
128 
130 typedef struct multiboot_info_t {
146  union {
151  } u;
191  union {
193  struct {
200  struct {
216 
221 
227 
233 
240 
245 
250 
256 
259 void dump_multiboot(multiboot_info_t *mboot_ptr);
struct multiboot_elf_section_header_table_t multiboot_elf_section_header_table_t
The section header table for ELF.
multiboot_memory_map_t * mmap_first_entry_of_type(multiboot_info_t *info, uint32_t type)
The first entry of the given type.
Definition: multiboot.c:27
void dump_multiboot(multiboot_info_t *mboot_ptr)
Prints as debugging output the info regarding the multiboot.
Definition: multiboot.c:90
struct multiboot_memory_map_t multiboot_memory_map_t
Stores information about memory mapping.
multiboot_module_t * next_module(multiboot_info_t *info, multiboot_module_t *mod)
Finds the next module after the one we provide.
Definition: multiboot.c:79
struct multiboot_info_t multiboot_info_t
Multiboot information structure.
multiboot_memory_map_t * mmap_next_entry_of_type(multiboot_info_t *info, multiboot_memory_map_t *entry, uint32_t type)
Returns the next mmap entry of the given type.
Definition: multiboot.c:47
char * mmap_type_name(multiboot_memory_map_t *entry)
Returns the type of the entry as string.
Definition: multiboot.c:57
multiboot_module_t * first_module(multiboot_info_t *info)
Finds the first module.
Definition: multiboot.c:68
struct multiboot_aout_symbol_table_t multiboot_aout_symbol_table_t
The symbol table for a.out.
multiboot_memory_map_t * mmap_next_entry(multiboot_info_t *info, multiboot_memory_map_t *entry)
Returns the next mmap entry.
Definition: multiboot.c:37
struct multiboot_module_t multiboot_module_t
Stores information about a module.
multiboot_memory_map_t * mmap_first_entry(multiboot_info_t *info)
Returns the first mmap entry.
Definition: multiboot.c:19
Standard integer data-types.
unsigned short uint16_t
Define the unsigned 16-bit integer.
Definition: stdint.h:24
unsigned int uint32_t
Define the unsigned 32-bit integer.
Definition: stdint.h:18
unsigned char uint8_t
Define the unsigned 8-bit integer.
Definition: stdint.h:30
The symbol table for a.out.
Definition: multiboot.h:77
uint32_t reserved
TODO: Comment.
Definition: multiboot.h:85
uint32_t strsize
TODO: Comment.
Definition: multiboot.h:81
uint32_t tabsize
TODO: Comment.
Definition: multiboot.h:79
uint32_t addr
TODO: Comment.
Definition: multiboot.h:83
The section header table for ELF.
Definition: multiboot.h:89
uint32_t num
TODO: Comment.
Definition: multiboot.h:91
uint32_t shndx
TODO: Comment.
Definition: multiboot.h:97
uint32_t size
TODO: Comment.
Definition: multiboot.h:93
uint32_t addr
TODO: Comment.
Definition: multiboot.h:95
Multiboot information structure.
Definition: multiboot.h:130
uint32_t vbe_mode
Current VBE mode.
Definition: multiboot.h:171
uint32_t framebuffer_addr
TODO: Comment.
Definition: multiboot.h:179
uint32_t mem_upper
Upper memory available from the BIOS.
Definition: multiboot.h:136
uint32_t mods_count
Amount of modules loaded.
Definition: multiboot.h:142
uint32_t cmdline
Pointer to the boot command line.
Definition: multiboot.h:140
uint8_t framebuffer_blue_field_position
TODO: Comment.
Definition: multiboot.h:210
multiboot_aout_symbol_table_t aout_sym
Symbol table for aout file.
Definition: multiboot.h:148
uint32_t vbe_control_info
Pointer to the VBE control info structure.
Definition: multiboot.h:167
uint32_t mods_addr
Address to the first module structure.
Definition: multiboot.h:144
multiboot_elf_section_header_table_t elf_sec
Elf section header table for elf file.
Definition: multiboot.h:150
uint8_t framebuffer_red_mask_size
TODO: Comment.
Definition: multiboot.h:204
uint32_t boot_loader_name
Boot Loader Name.
Definition: multiboot.h:163
uint32_t apm_table
APM table.
Definition: multiboot.h:165
uint8_t framebuffer_green_field_position
TODO: Comment.
Definition: multiboot.h:206
uint32_t framebuffer_type
TODO: Comment.
Definition: multiboot.h:189
uint32_t mmap_length
Memory map length.
Definition: multiboot.h:153
uint8_t framebuffer_green_mask_size
TODO: Comment.
Definition: multiboot.h:208
uint32_t vbe_mode_info
Pointer to the VBE mode info structure.
Definition: multiboot.h:169
uint32_t vbe_interface_off
VBE3.0 interface segment offset.
Definition: multiboot.h:175
uint32_t flags
Multiboot info version number.
Definition: multiboot.h:132
uint32_t framebuffer_palette_addr
TODO: Comment.
Definition: multiboot.h:195
uint32_t framebuffer_bpp
TODO: Comment.
Definition: multiboot.h:187
uint32_t drives_addr
Drive map address.
Definition: multiboot.h:159
uint32_t boot_device
Boot device ID.
Definition: multiboot.h:138
uint8_t framebuffer_blue_mask_size
TODO: Comment.
Definition: multiboot.h:212
uint32_t mem_lower
Lower memory available from the BIOS.
Definition: multiboot.h:134
uint16_t framebuffer_palette_num_colors
TODO: Comment.
Definition: multiboot.h:197
uint32_t framebuffer_pitch
TODO: Comment.
Definition: multiboot.h:181
uint32_t framebuffer_width
TODO: Comment.
Definition: multiboot.h:183
uint32_t drives_length
Drive map length.
Definition: multiboot.h:157
uint32_t framebuffer_height
TODO: Comment.
Definition: multiboot.h:185
struct multiboot_info_t::@8::@10 rgb_field
TODO: Comment.
union multiboot_info_t::@8 framebuffer_info
TODO: Comment.
union multiboot_info_t::@7 u
Contains data either of an aout or elf file.
uint8_t framebuffer_red_field_position
TODO: Comment.
Definition: multiboot.h:202
struct multiboot_info_t::@8::@9 palette_field
TODO: Comment.
uint32_t config_table
ROM configuration table.
Definition: multiboot.h:161
uint32_t mmap_addr
Memory map address.
Definition: multiboot.h:155
uint32_t vbe_interface_seg
VBE3.0 interface segment.
Definition: multiboot.h:173
uint32_t vbe_interface_len
VBE3.0 interface segment length.
Definition: multiboot.h:177
Stores information about memory mapping.
Definition: multiboot.h:114
uint32_t base_addr_high
Higher bytes of the base address.
Definition: multiboot.h:120
uint32_t length_high
Higher bytes of the length.
Definition: multiboot.h:124
uint32_t type
Memory type.
Definition: multiboot.h:126
uint32_t size
Size of this entry.
Definition: multiboot.h:116
uint32_t base_addr_low
Lower bytes of the base address.
Definition: multiboot.h:118
uint32_t length_low
Lower bytes of the length.
Definition: multiboot.h:122
Stores information about a module.
Definition: multiboot.h:101
uint32_t cmdline
Module command line.
Definition: multiboot.h:108
uint32_t pad
Padding to take it to 16 bytes (must be zero).
Definition: multiboot.h:110
uint32_t mod_end
The ending address of the modules.
Definition: multiboot.h:106
uint32_t mod_start
The starting address of the modules.
Definition: multiboot.h:104