:: limine / common / protos / multiboot2.h 9.6 KB raw

1
/*   multiboot2.h - Multiboot 2 header file. Copied from the multiboot2 specs /
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 PROTOS__MULTIBOOT2_H__
23
#define PROTOS__MULTIBOOT2_H__
24
25
#include <stdint.h>
26
#include <stdnoreturn.h>
27
28
noreturn void multiboot2_load(char *config, char *cmdline);
29
30
/*  How many bytes from the start of the file we search for the header. */
31
#define MULTIBOOT_SEARCH                        32768
32
#define MULTIBOOT_HEADER_ALIGN                  8
33
34
/*  The magic field should contain this. */
35
#define MULTIBOOT2_HEADER_MAGIC                 0xe85250d6
36
37
/*  This should be in %eax. */
38
#define MULTIBOOT2_BOOTLOADER_MAGIC             0x36d76289
39
40
/*  Alignment of multiboot modules. */
41
#define MULTIBOOT_MOD_ALIGN                     0x00001000
42
43
/*  Alignment of the multiboot info structure. */
44
#define MULTIBOOT_INFO_ALIGN                    0x00000008
45
46
/*  Flags set in the ’flags’ member of the multiboot header. */
47
48
#define MULTIBOOT_TAG_ALIGN                  8
49
#define MULTIBOOT_TAG_TYPE_END               0
50
#define MULTIBOOT_TAG_TYPE_CMDLINE           1
51
#define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME  2
52
#define MULTIBOOT_TAG_TYPE_MODULE            3
53
#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO     4
54
#define MULTIBOOT_TAG_TYPE_BOOTDEV           5
55
#define MULTIBOOT_TAG_TYPE_MMAP              6
56
#define MULTIBOOT_TAG_TYPE_VBE               7
57
#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER       8
58
#define MULTIBOOT_TAG_TYPE_ELF_SECTIONS      9
59
#define MULTIBOOT_TAG_TYPE_APM               10
60
#define MULTIBOOT_TAG_TYPE_EFI32             11
61
#define MULTIBOOT_TAG_TYPE_EFI64             12
62
#define MULTIBOOT_TAG_TYPE_SMBIOS            13
63
#define MULTIBOOT_TAG_TYPE_ACPI_OLD          14
64
#define MULTIBOOT_TAG_TYPE_ACPI_NEW          15
65
#define MULTIBOOT_TAG_TYPE_NETWORK           16
66
#define MULTIBOOT_TAG_TYPE_EFI_MMAP          17
67
#define MULTIBOOT_TAG_TYPE_EFI_BS            18
68
#define MULTIBOOT_TAG_TYPE_EFI32_IH          19
69
#define MULTIBOOT_TAG_TYPE_EFI64_IH          20
70
#define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR    21
71
72
#define MULTIBOOT_HEADER_TAG_END  0
73
#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST  1
74
#define MULTIBOOT_HEADER_TAG_ADDRESS  2
75
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS  3
76
#define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS  4
77
#define MULTIBOOT_HEADER_TAG_FRAMEBUFFER  5
78
#define MULTIBOOT_HEADER_TAG_MODULE_ALIGN  6
79
#define MULTIBOOT_HEADER_TAG_EFI_BS        7
80
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32  8
81
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64  9
82
#define MULTIBOOT_HEADER_TAG_RELOCATABLE  10
83
84
#define MULTIBOOT_ARCHITECTURE_I386  0
85
#define MULTIBOOT_ARCHITECTURE_MIPS32  4
86
#define MULTIBOOT_HEADER_TAG_OPTIONAL 1
87
88
#define MULTIBOOT_LOAD_PREFERENCE_NONE 0
89
#define MULTIBOOT_LOAD_PREFERENCE_LOW 1
90
#define MULTIBOOT_LOAD_PREFERENCE_HIGH 2
91
92
#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
93
#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
94
95
struct multiboot_header
96
{
97
    /*  Must be MULTIBOOT_MAGIC - see above. */
98
    uint32_t magic;
99
100
    /*  ISA */
101
    uint32_t architecture;
102
103
    /*  Total header length. */
104
    uint32_t header_length;
105
106
    /*  The above fields plus this one must equal 0 mod 2^32. */
107
    uint32_t checksum;
108
};
109
110
struct multiboot_header_tag
111
{
112
    uint16_t type;
113
    uint16_t flags;
114
    uint32_t size;
115
};
116
117
struct multiboot_header_tag_information_request
118
{
119
    uint16_t type;
120
    uint16_t flags;
121
    uint32_t size;
122
    uint32_t requests[0];
123
};
124
125
struct multiboot2_start_tag {
126
    uint32_t size;
127
    uint32_t reserved;
128
};
129
130
struct multiboot_header_tag_address
131
{
132
    uint16_t type;
133
    uint16_t flags;
134
    uint32_t size;
135
    uint32_t header_addr;
136
    uint32_t load_addr;
137
    uint32_t load_end_addr;
138
    uint32_t bss_end_addr;
139
};
140
141
struct multiboot_header_tag_entry_address
142
{
143
    uint16_t type;
144
    uint16_t flags;
145
    uint32_t size;
146
    uint32_t entry_addr;
147
};
148
149
struct multiboot_header_tag_console_flags
150
{
151
    uint16_t type;
152
    uint16_t flags;
153
    uint32_t size;
154
    uint32_t console_flags;
155
};
156
157
struct multiboot_header_tag_framebuffer
158
{
159
    uint16_t type;
160
    uint16_t flags;
161
    uint32_t size;
162
    uint32_t width;
163
    uint32_t height;
164
    uint32_t depth;
165
};
166
167
struct multiboot_header_tag_module_align
168
{
169
    uint16_t type;
170
    uint16_t flags;
171
    uint32_t size;
172
};
173
174
struct multiboot_header_tag_relocatable
175
{
176
    uint16_t type;
177
    uint16_t flags;
178
    uint32_t size;
179
    uint32_t min_addr;
180
    uint32_t max_addr;
181
    uint32_t align;
182
    uint32_t preference;
183
};
184
185
struct multiboot_color
186
{
187
    uint8_t red;
188
    uint8_t green;
189
    uint8_t blue;
190
};
191
192
struct multiboot_mmap_entry
193
{
194
    uint64_t addr;
195
    uint64_t len;
196
#define MULTIBOOT_MEMORY_AVAILABLE              1
197
#define MULTIBOOT_MEMORY_RESERVED               2
198
#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE       3
199
#define MULTIBOOT_MEMORY_NVS                    4
200
#define MULTIBOOT_MEMORY_BADRAM                 5
201
    uint32_t type;
202
    uint32_t zero;
203
};
204
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
205
206
struct multiboot_tag
207
{
208
    uint32_t type;
209
    uint32_t size;
210
};
211
212
struct multiboot_tag_string
213
{
214
    uint32_t type;
215
    uint32_t size;
216
    char string[0];
217
};
218
219
struct multiboot_tag_module
220
{
221
    uint32_t type;
222
    uint32_t size;
223
    uint32_t mod_start;
224
    uint32_t mod_end;
225
    char cmdline[0];
226
};
227
228
struct multiboot_tag_basic_meminfo
229
{
230
    uint32_t type;
231
    uint32_t size;
232
    uint32_t mem_lower;
233
    uint32_t mem_upper;
234
};
235
236
struct multiboot_tag_bootdev
237
{
238
    uint32_t type;
239
    uint32_t size;
240
    uint32_t biosdev;
241
    uint32_t slice;
242
    uint32_t part;
243
};
244
245
struct multiboot_tag_mmap
246
{
247
    uint32_t type;
248
    uint32_t size;
249
    uint32_t entry_size;
250
    uint32_t entry_version;
251
    struct multiboot_mmap_entry entries[0];
252
};
253
254
struct multiboot_vbe_info_block
255
{
256
    uint8_t external_specification[512];
257
};
258
259
struct multiboot_vbe_mode_info_block
260
{
261
    uint8_t external_specification[256];
262
};
263
264
struct multiboot_tag_vbe
265
{
266
    uint32_t type;
267
    uint32_t size;
268
269
    uint16_t vbe_mode;
270
    uint16_t vbe_interface_seg;
271
    uint16_t vbe_interface_off;
272
    uint16_t vbe_interface_len;
273
274
    struct multiboot_vbe_info_block vbe_control_info;
275
    struct multiboot_vbe_mode_info_block vbe_mode_info;
276
};
277
278
struct multiboot_tag_framebuffer_common
279
{
280
    uint32_t type;
281
    uint32_t size;
282
283
    uint64_t framebuffer_addr;
284
    uint32_t framebuffer_pitch;
285
    uint32_t framebuffer_width;
286
    uint32_t framebuffer_height;
287
    uint8_t framebuffer_bpp;
288
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
289
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB     1
290
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT     2
291
    uint8_t framebuffer_type;
292
    uint16_t reserved;
293
};
294
295
struct multiboot_tag_framebuffer
296
{
297
    struct multiboot_tag_framebuffer_common common;
298
299
    union
300
    {
301
        struct
302
        {
303
            uint16_t framebuffer_palette_num_colors;
304
            struct multiboot_color framebuffer_palette[0];
305
        };
306
        struct
307
        {
308
            uint8_t framebuffer_red_field_position;
309
            uint8_t framebuffer_red_mask_size;
310
            uint8_t framebuffer_green_field_position;
311
            uint8_t framebuffer_green_mask_size;
312
            uint8_t framebuffer_blue_field_position;
313
            uint8_t framebuffer_blue_mask_size;
314
        };
315
    };
316
};
317
318
struct multiboot_tag_elf_sections
319
{
320
    uint32_t type;
321
    uint32_t size;
322
    uint32_t num;
323
    uint32_t entsize;
324
    uint32_t shndx;
325
    char sections[0];
326
};
327
328
struct multiboot_tag_apm
329
{
330
    uint32_t type;
331
    uint32_t size;
332
    uint16_t version;
333
    uint16_t cseg;
334
    uint32_t offset;
335
    uint16_t cseg_16;
336
    uint16_t dseg;
337
    uint16_t flags;
338
    uint16_t cseg_len;
339
    uint16_t cseg_16_len;
340
    uint16_t dseg_len;
341
};
342
343
struct multiboot_tag_efi32
344
{
345
    uint32_t type;
346
    uint32_t size;
347
    uint32_t pointer;
348
};
349
350
struct multiboot_tag_efi64
351
{
352
    uint32_t type;
353
    uint32_t size;
354
    uint64_t pointer;
355
};
356
357
struct multiboot_tag_smbios
358
{
359
    uint32_t type;
360
    uint32_t size;
361
    uint8_t major;
362
    uint8_t minor;
363
    uint8_t reserved[6];
364
    uint8_t tables[0];
365
};
366
367
struct multiboot_tag_old_acpi
368
{
369
    uint32_t type;
370
    uint32_t size;
371
    uint8_t rsdp[0];
372
};
373
374
struct multiboot_tag_new_acpi
375
{
376
    uint32_t type;
377
    uint32_t size;
378
    uint8_t rsdp[0];
379
};
380
381
struct multiboot_tag_network
382
{
383
    uint32_t type;
384
    uint32_t size;
385
    uint8_t dhcpack[0];
386
};
387
388
struct multiboot_tag_efi_mmap
389
{
390
    uint32_t type;
391
    uint32_t size;
392
    uint32_t descr_size;
393
    uint32_t descr_vers;
394
    uint8_t efi_mmap[0];
395
};
396
397
struct multiboot_tag_efi32_ih
398
{
399
    uint32_t type;
400
    uint32_t size;
401
    uint32_t pointer;
402
};
403
404
struct multiboot_tag_efi64_ih
405
{
406
    uint32_t type;
407
    uint32_t size;
408
    uint64_t pointer;
409
};
410
411
struct multiboot_tag_load_base_addr
412
{
413
    uint32_t type;
414
    uint32_t size;
415
    uint32_t load_base_addr;
416
};
417
418
#endif
tab: 248 wrap: offon