1 /*
2  *  Copyright (C) 1999,2003,2007,2008,2009,2010  Free Software Foundation, Inc.
3  *
4  *  multiboot2.h - Multiboot 2 header file.
5  *
6  *  Based on grub-2.00/include/multiboot2.h file.
7  *
8  *  Permission is hereby granted, free of charge, to any person obtaining a copy
9  *  of this software and associated documentation files (the "Software"), to
10  *  deal in the Software without restriction, including without limitation the
11  *  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12  *  sell copies of the Software, and to permit persons to whom the Software is
13  *  furnished to do so, subject to the following conditions:
14  *
15  *  The above copyright notice and this permission notice shall be included in
16  *  all copies or substantial portions of the Software.
17  *
18  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL ANY
21  *  DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22  *  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
23  *  IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
26 #ifndef __MULTIBOOT2_H__
27 #define __MULTIBOOT2_H__
28 
29 /* The magic field should contain this.  */
30 #define MULTIBOOT2_HEADER_MAGIC                         0xe85250d6
31 
32 /* This should be in %eax on x86 architecture.  */
33 #define MULTIBOOT2_BOOTLOADER_MAGIC                     0x36d76289
34 
35 /* How many bytes from the start of the file we search for the header.  */
36 #define MULTIBOOT2_SEARCH                               32768
37 
38 /* Multiboot 2 header alignment. */
39 #define MULTIBOOT2_HEADER_ALIGN                         8
40 
41 /* Alignment of multiboot 2 modules.  */
42 #define MULTIBOOT2_MOD_ALIGN                            0x00001000
43 
44 /* Alignment of the multiboot 2 info structure.  */
45 #define MULTIBOOT2_INFO_ALIGN                           0x00000008
46 
47 /* Multiboot 2 architectures. */
48 #define MULTIBOOT2_ARCHITECTURE_I386                    0
49 #define MULTIBOOT2_ARCHITECTURE_MIPS32                  4
50 
51 /* Header tag types. */
52 #define MULTIBOOT2_HEADER_TAG_END                       0
53 #define MULTIBOOT2_HEADER_TAG_INFORMATION_REQUEST       1
54 #define MULTIBOOT2_HEADER_TAG_ADDRESS                   2
55 #define MULTIBOOT2_HEADER_TAG_ENTRY_ADDRESS             3
56 #define MULTIBOOT2_HEADER_TAG_CONSOLE_FLAGS             4
57 #define MULTIBOOT2_HEADER_TAG_FRAMEBUFFER               5
58 #define MULTIBOOT2_HEADER_TAG_MODULE_ALIGN              6
59 #define MULTIBOOT2_HEADER_TAG_EFI_BS                    7
60 #define MULTIBOOT2_HEADER_TAG_ENTRY_ADDRESS_EFI32       8
61 #define MULTIBOOT2_HEADER_TAG_ENTRY_ADDRESS_EFI64       9
62 #define MULTIBOOT2_HEADER_TAG_RELOCATABLE               10
63 
64 /* Header tag flags. */
65 #define MULTIBOOT2_HEADER_TAG_REQUIRED                  0
66 #define MULTIBOOT2_HEADER_TAG_OPTIONAL                  1
67 
68 /* Where image should be loaded (suggestion not requirement). */
69 #define MULTIBOOT2_LOAD_PREFERENCE_NONE                 0
70 #define MULTIBOOT2_LOAD_PREFERENCE_LOW                  1
71 #define MULTIBOOT2_LOAD_PREFERENCE_HIGH                 2
72 
73 /* Header console tag console_flags. */
74 #define MULTIBOOT2_CONSOLE_FLAGS_CONSOLE_REQUIRED       1
75 #define MULTIBOOT2_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED     2
76 
77 /* Flags set in the 'flags' member of the multiboot header.  */
78 #define MULTIBOOT2_TAG_TYPE_END                         0
79 #define MULTIBOOT2_TAG_TYPE_CMDLINE                     1
80 #define MULTIBOOT2_TAG_TYPE_BOOT_LOADER_NAME            2
81 #define MULTIBOOT2_TAG_TYPE_MODULE                      3
82 #define MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO               4
83 #define MULTIBOOT2_TAG_TYPE_BOOTDEV                     5
84 #define MULTIBOOT2_TAG_TYPE_MMAP                        6
85 #define MULTIBOOT2_TAG_TYPE_VBE                         7
86 #define MULTIBOOT2_TAG_TYPE_FRAMEBUFFER                 8
87 #define MULTIBOOT2_TAG_TYPE_ELF_SECTIONS                9
88 #define MULTIBOOT2_TAG_TYPE_APM                         10
89 #define MULTIBOOT2_TAG_TYPE_EFI32                       11
90 #define MULTIBOOT2_TAG_TYPE_EFI64                       12
91 #define MULTIBOOT2_TAG_TYPE_SMBIOS                      13
92 #define MULTIBOOT2_TAG_TYPE_ACPI_OLD                    14
93 #define MULTIBOOT2_TAG_TYPE_ACPI_NEW                    15
94 #define MULTIBOOT2_TAG_TYPE_NETWORK                     16
95 #define MULTIBOOT2_TAG_TYPE_EFI_MMAP                    17
96 #define MULTIBOOT2_TAG_TYPE_EFI_BS                      18
97 #define MULTIBOOT2_TAG_TYPE_EFI32_IH                    19
98 #define MULTIBOOT2_TAG_TYPE_EFI64_IH                    20
99 #define MULTIBOOT2_TAG_TYPE_LOAD_BASE_ADDR              21
100 
101 /* Multiboot 2 tag alignment. */
102 #define MULTIBOOT2_TAG_ALIGN                            8
103 
104 /* Memory types. */
105 #define MULTIBOOT2_MEMORY_AVAILABLE                     1
106 #define MULTIBOOT2_MEMORY_RESERVED                      2
107 #define MULTIBOOT2_MEMORY_ACPI_RECLAIMABLE              3
108 #define MULTIBOOT2_MEMORY_NVS                           4
109 #define MULTIBOOT2_MEMORY_BADRAM                        5
110 
111 /* Framebuffer types. */
112 #define MULTIBOOT2_FRAMEBUFFER_TYPE_INDEXED             0
113 #define MULTIBOOT2_FRAMEBUFFER_TYPE_RGB                 1
114 #define MULTIBOOT2_FRAMEBUFFER_TYPE_EGA_TEXT            2
115 
116 #ifndef __ASSEMBLY__
117 typedef struct {
118     u32 total_size;
119     u32 reserved;
120 } multiboot2_fixed_t;
121 
122 typedef struct {
123     u32 type;
124     u32 size;
125 } multiboot2_tag_t;
126 
127 typedef struct {
128     u32 type;
129     u32 size;
130     u32 load_base_addr;
131 } multiboot2_tag_load_base_addr_t;
132 
133 typedef struct {
134     u32 type;
135     u32 size;
136     char string[];
137 } multiboot2_tag_string_t;
138 
139 typedef struct {
140     u32 type;
141     u32 size;
142     u32 mem_lower;
143     u32 mem_upper;
144 } multiboot2_tag_basic_meminfo_t;
145 
146 typedef struct {
147     u64 addr;
148     u64 len;
149     u32 type;
150     u32 zero;
151 } multiboot2_memory_map_t;
152 
153 typedef struct {
154     u32 type;
155     u32 size;
156     u32 entry_size;
157     u32 entry_version;
158     multiboot2_memory_map_t entries[];
159 } multiboot2_tag_mmap_t;
160 
161 typedef struct {
162     u32 type;
163     u32 size;
164     u64 pointer;
165 } multiboot2_tag_efi64_t;
166 
167 typedef struct {
168     u32 type;
169     u32 size;
170     u64 pointer;
171 } multiboot2_tag_efi64_ih_t;
172 
173 typedef struct {
174     u32 type;
175     u32 size;
176     u32 mod_start;
177     u32 mod_end;
178     char cmdline[];
179 } multiboot2_tag_module_t;
180 #endif /* __ASSEMBLY__ */
181 
182 #endif /* __MULTIBOOT2_H__ */
183