blob: 686a6b4c6e48cb6c8d61b8307e1af46924673383 [file] [log] [blame]
Martin Roth8cc1aeb2016-02-24 13:03:52 -08001/* multiboot.h - Multiboot header file. */
2/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY
17 * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
19 * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 */
21
22#ifndef MULTIBOOT_HEADER
23#define MULTIBOOT_HEADER 1
24
25/* How many bytes from the start of the file we search for the header. */
26#define MULTIBOOT_SEARCH 8192
27
28/* The magic field should contain this. */
29#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
30
31/* This should be in %eax. */
32#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
33
34/* Alignment of multiboot modules. */
35#define MULTIBOOT_MOD_ALIGN 0x00001000
36
37/* Alignment of the multiboot info structure. */
38#define MULTIBOOT_INFO_ALIGN 0x00000004
39
40/* Flags set in the 'flags' member of the multiboot header. */
41
42/* Align all boot modules on i386 page (4KB) boundaries. */
43#define MULTIBOOT_PAGE_ALIGN 0x00000001
44
45/* Must pass memory information to OS. */
46#define MULTIBOOT_MEMORY_INFO 0x00000002
47
48/* Must pass video information to OS. */
49#define MULTIBOOT_VIDEO_MODE 0x00000004
50
51/* This flag indicates the use of the address fields in the header. */
52#define MULTIBOOT_AOUT_KLUDGE 0x00010000
53
54/* Flags to be set in the 'flags' member of the multiboot info structure. */
55
56/* is there basic lower/upper memory information? */
57#define MULTIBOOT_INFO_MEMORY 0x00000001
58/* is there a boot device set? */
59#define MULTIBOOT_INFO_BOOTDEV 0x00000002
60/* is the command-line defined? */
61#define MULTIBOOT_INFO_CMDLINE 0x00000004
62/* are there modules to do something with? */
63#define MULTIBOOT_INFO_MODS 0x00000008
64
65/* These next two are mutually exclusive */
66
67/* is there a symbol table loaded? */
68#define MULTIBOOT_INFO_AOUT_SYMS 0x00000010
69/* is there an ELF section header table? */
70#define MULTIBOOT_INFO_ELF_SHDR 0X00000020
71
72/* is there a full memory map? */
73#define MULTIBOOT_INFO_MEM_MAP 0x00000040
74
75/* Is there drive info? */
76#define MULTIBOOT_INFO_DRIVE_INFO 0x00000080
77
78/* Is there a config table? */
79#define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100
80
81/* Is there a boot loader name? */
82#define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200
83
84/* Is there a APM table? */
85#define MULTIBOOT_INFO_APM_TABLE 0x00000400
86
87/* Is there video information? */
88#define MULTIBOOT_INFO_VBE_INFO 0x00000800
89#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000
90
91#ifndef ASM_FILE
92
93typedef unsigned char multiboot_uint8_t;
94typedef unsigned short multiboot_uint16_t;
95typedef unsigned int multiboot_uint32_t;
96typedef unsigned long long multiboot_uint64_t;
97
98struct multiboot_header
99{
100 /* Must be MULTIBOOT_MAGIC - see above. */
101 multiboot_uint32_t magic;
102
103 /* Feature flags. */
104 multiboot_uint32_t flags;
105
106 /* The above fields plus this one must equal 0 mod 2^32. */
107 multiboot_uint32_t checksum;
108
109 /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
110 multiboot_uint32_t header_addr;
111 multiboot_uint32_t load_addr;
112 multiboot_uint32_t load_end_addr;
113 multiboot_uint32_t bss_end_addr;
114 multiboot_uint32_t entry_addr;
115
116 /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */
117 multiboot_uint32_t mode_type;
118 multiboot_uint32_t width;
119 multiboot_uint32_t height;
120 multiboot_uint32_t depth;
121};
122
123/* The symbol table for a.out. */
124struct multiboot_aout_symbol_table
125{
126 multiboot_uint32_t tabsize;
127 multiboot_uint32_t strsize;
128 multiboot_uint32_t addr;
129 multiboot_uint32_t reserved;
130};
131typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
132
133/* The section header table for ELF. */
134struct multiboot_elf_section_header_table
135{
136 multiboot_uint32_t num;
137 multiboot_uint32_t size;
138 multiboot_uint32_t addr;
139 multiboot_uint32_t shndx;
140};
141typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
142
143struct multiboot_color
144{
145 multiboot_uint8_t red;
146 multiboot_uint8_t green;
147 multiboot_uint8_t blue;
148};
149
150struct multiboot_info
151{
152 /* Multiboot info version number */
153 multiboot_uint32_t flags;
154
155 /* Available memory from BIOS */
156 multiboot_uint32_t mem_lower;
157 multiboot_uint32_t mem_upper;
158
159 /* "root" partition */
160 multiboot_uint32_t boot_device;
161
162 /* Kernel command line */
163 multiboot_uint32_t cmdline;
164
165 /* Boot-Module list */
166 multiboot_uint32_t mods_count;
167 multiboot_uint32_t mods_addr;
168
169 union
170 {
171 multiboot_aout_symbol_table_t aout_sym;
172 multiboot_elf_section_header_table_t elf_sec;
173 } u;
174
175 /* Memory Mapping buffer */
176 multiboot_uint32_t mmap_length;
177 multiboot_uint32_t mmap_addr;
178
179 /* Drive Info buffer */
180 multiboot_uint32_t drives_length;
181 multiboot_uint32_t drives_addr;
182
183 /* ROM configuration table */
184 multiboot_uint32_t config_table;
185
186 /* Boot Loader Name */
187 multiboot_uint32_t boot_loader_name;
188
189 /* APM table */
190 multiboot_uint32_t apm_table;
191
192 /* Video */
193 multiboot_uint32_t vbe_control_info;
194 multiboot_uint32_t vbe_mode_info;
195 multiboot_uint16_t vbe_mode;
196 multiboot_uint16_t vbe_interface_seg;
197 multiboot_uint16_t vbe_interface_off;
198 multiboot_uint16_t vbe_interface_len;
199
200 multiboot_uint64_t framebuffer_addr;
201 multiboot_uint32_t framebuffer_pitch;
202 multiboot_uint32_t framebuffer_width;
203 multiboot_uint32_t framebuffer_height;
204 multiboot_uint8_t framebuffer_bpp;
205#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
206#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
207#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
208 multiboot_uint8_t framebuffer_type;
209 union
210 {
211 /* Indexed color. */
212 struct
213 {
214 struct multiboot_color *framebuffer_palette_addr;
215 multiboot_uint16_t framebuffer_palette_num_colors;
216 };
217
218 /* Direct RGB color. */
219 struct
220 {
221 multiboot_uint8_t framebuffer_red_field_position;
222 multiboot_uint8_t framebuffer_red_mask_size;
223 multiboot_uint8_t framebuffer_green_field_position;
224 multiboot_uint8_t framebuffer_green_mask_size;
225 multiboot_uint8_t framebuffer_blue_field_position;
226 multiboot_uint8_t framebuffer_blue_mask_size;
227 };
228 };
229};
230typedef struct multiboot_info multiboot_info_t;
231
232struct multiboot_mmap_entry
233{
234 multiboot_uint32_t size;
235 multiboot_uint64_t addr;
236 multiboot_uint64_t len;
237#define MULTIBOOT_MEMORY_AVAILABLE 1
238#define MULTIBOOT_MEMORY_RESERVED 2
239 multiboot_uint32_t type;
240} __attribute__((packed));
241typedef struct multiboot_mmap_entry multiboot_memory_map_t;
242
243struct multiboot_mod_list
244{
245 /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
246 multiboot_uint32_t mod_start;
247 multiboot_uint32_t mod_end;
248
249 /* Module command line */
250 multiboot_uint32_t cmdline;
251
252 /* padding to take it to 16 bytes (must be zero) */
253 multiboot_uint32_t pad;
254};
255typedef struct multiboot_mod_list multiboot_module_t;
256
257#endif /* ! ASM_FILE */
258
259#endif /* ! MULTIBOOT_HEADER */