multiboot2.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /* multiboot2.h - Multiboot 2 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. #ifndef MULTIBOOT_HEADER
  22. #define MULTIBOOT_HEADER 1
  23. /* How many bytes from the start of the file we search for the header. */
  24. #define MULTIBOOT_SEARCH 32768
  25. #define MULTIBOOT_HEADER_ALIGN 8
  26. /* The magic field should contain this. */
  27. #define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
  28. /* This should be in %eax. */
  29. #define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289
  30. /* Alignment of multiboot modules. */
  31. #define MULTIBOOT_MOD_ALIGN 0x00001000
  32. /* Alignment of the multiboot info structure. */
  33. #define MULTIBOOT_INFO_ALIGN 0x00000008
  34. /* Flags set in the 'flags' member of the multiboot header. */
  35. #define MULTIBOOT_TAG_ALIGN 8
  36. #define MULTIBOOT_TAG_TYPE_END 0
  37. #define MULTIBOOT_TAG_TYPE_CMDLINE 1
  38. #define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2
  39. #define MULTIBOOT_TAG_TYPE_MODULE 3
  40. #define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4
  41. #define MULTIBOOT_TAG_TYPE_BOOTDEV 5
  42. #define MULTIBOOT_TAG_TYPE_MMAP 6
  43. #define MULTIBOOT_TAG_TYPE_VBE 7
  44. #define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8
  45. #define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9
  46. #define MULTIBOOT_TAG_TYPE_APM 10
  47. #define MULTIBOOT_HEADER_TAG_END 0
  48. #define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1
  49. #define MULTIBOOT_HEADER_TAG_ADDRESS 2
  50. #define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3
  51. #define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4
  52. #define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5
  53. #define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6
  54. #define MULTIBOOT_ARCHITECTURE_I386 0
  55. #define MULTIBOOT_ARCHITECTURE_MIPS32 4
  56. #define MULTIBOOT_HEADER_TAG_OPTIONAL 1
  57. #define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
  58. #define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
  59. #ifndef ASM_FILE
  60. typedef unsigned char multiboot_uint8_t;
  61. typedef unsigned short multiboot_uint16_t;
  62. typedef unsigned int multiboot_uint32_t;
  63. typedef unsigned long long multiboot_uint64_t;
  64. struct multiboot_header
  65. {
  66. /* Must be MULTIBOOT_MAGIC - see above. */
  67. multiboot_uint32_t magic;
  68. /* ISA */
  69. multiboot_uint32_t architecture;
  70. /* Total header length. */
  71. multiboot_uint32_t header_length;
  72. /* The above fields plus this one must equal 0 mod 2^32. */
  73. multiboot_uint32_t checksum;
  74. };
  75. struct multiboot_header_tag
  76. {
  77. multiboot_uint16_t type;
  78. multiboot_uint16_t flags;
  79. multiboot_uint32_t size;
  80. };
  81. struct multiboot_header_tag_information_request
  82. {
  83. multiboot_uint16_t type;
  84. multiboot_uint16_t flags;
  85. multiboot_uint32_t size;
  86. multiboot_uint32_t requests[0];
  87. };
  88. struct multiboot_header_tag_address
  89. {
  90. multiboot_uint16_t type;
  91. multiboot_uint16_t flags;
  92. multiboot_uint32_t size;
  93. multiboot_uint32_t header_addr;
  94. multiboot_uint32_t load_addr;
  95. multiboot_uint32_t load_end_addr;
  96. multiboot_uint32_t bss_end_addr;
  97. };
  98. struct multiboot_header_tag_entry_address
  99. {
  100. multiboot_uint16_t type;
  101. multiboot_uint16_t flags;
  102. multiboot_uint32_t size;
  103. multiboot_uint32_t entry_addr;
  104. };
  105. struct multiboot_header_tag_console_flags
  106. {
  107. multiboot_uint16_t type;
  108. multiboot_uint16_t flags;
  109. multiboot_uint32_t size;
  110. multiboot_uint32_t console_flags;
  111. };
  112. struct multiboot_header_tag_framebuffer
  113. {
  114. multiboot_uint16_t type;
  115. multiboot_uint16_t flags;
  116. multiboot_uint32_t size;
  117. multiboot_uint32_t width;
  118. multiboot_uint32_t height;
  119. multiboot_uint32_t depth;
  120. };
  121. struct multiboot_header_tag_module_align
  122. {
  123. multiboot_uint16_t type;
  124. multiboot_uint16_t flags;
  125. multiboot_uint32_t size;
  126. multiboot_uint32_t width;
  127. multiboot_uint32_t height;
  128. multiboot_uint32_t depth;
  129. };
  130. struct multiboot_color
  131. {
  132. multiboot_uint8_t red;
  133. multiboot_uint8_t green;
  134. multiboot_uint8_t blue;
  135. };
  136. struct multiboot_mmap_entry
  137. {
  138. multiboot_uint64_t addr;
  139. multiboot_uint64_t len;
  140. #define MULTIBOOT_MEMORY_AVAILABLE 1
  141. #define MULTIBOOT_MEMORY_RESERVED 2
  142. #define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
  143. #define MULTIBOOT_MEMORY_NVS 4
  144. multiboot_uint32_t type;
  145. multiboot_uint32_t zero;
  146. } __attribute__((packed));
  147. typedef struct multiboot_mmap_entry multiboot_memory_map_t;
  148. struct multiboot_tag
  149. {
  150. multiboot_uint32_t type;
  151. multiboot_uint32_t size;
  152. };
  153. struct multiboot_tag_string
  154. {
  155. multiboot_uint32_t type;
  156. multiboot_uint32_t size;
  157. char string[0];
  158. };
  159. struct multiboot_tag_module
  160. {
  161. multiboot_uint32_t type;
  162. multiboot_uint32_t size;
  163. multiboot_uint32_t mod_start;
  164. multiboot_uint32_t mod_end;
  165. char cmdline[0];
  166. };
  167. struct multiboot_tag_basic_meminfo
  168. {
  169. multiboot_uint32_t type;
  170. multiboot_uint32_t size;
  171. multiboot_uint32_t mem_lower;
  172. multiboot_uint32_t mem_upper;
  173. };
  174. struct multiboot_tag_bootdev
  175. {
  176. multiboot_uint32_t type;
  177. multiboot_uint32_t size;
  178. multiboot_uint32_t biosdev;
  179. multiboot_uint32_t slice;
  180. multiboot_uint32_t part;
  181. };
  182. struct multiboot_tag_mmap
  183. {
  184. multiboot_uint32_t type;
  185. multiboot_uint32_t size;
  186. multiboot_uint32_t entry_size;
  187. multiboot_uint32_t entry_version;
  188. struct multiboot_mmap_entry entries[0];
  189. };
  190. struct multiboot_vbe_info_block
  191. {
  192. multiboot_uint8_t external_specification[512];
  193. };
  194. struct multiboot_vbe_mode_info_block
  195. {
  196. multiboot_uint8_t external_specification[256];
  197. };
  198. struct multiboot_tag_vbe
  199. {
  200. multiboot_uint32_t type;
  201. multiboot_uint32_t size;
  202. multiboot_uint16_t vbe_mode;
  203. multiboot_uint16_t vbe_interface_seg;
  204. multiboot_uint16_t vbe_interface_off;
  205. multiboot_uint16_t vbe_interface_len;
  206. struct multiboot_vbe_info_block vbe_control_info;
  207. struct multiboot_vbe_mode_info_block vbe_mode_info;
  208. };
  209. struct multiboot_tag_framebuffer_common
  210. {
  211. multiboot_uint32_t type;
  212. multiboot_uint32_t size;
  213. multiboot_uint64_t framebuffer_addr;
  214. multiboot_uint32_t framebuffer_pitch;
  215. multiboot_uint32_t framebuffer_width;
  216. multiboot_uint32_t framebuffer_height;
  217. multiboot_uint8_t framebuffer_bpp;
  218. #define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
  219. #define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
  220. #define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
  221. multiboot_uint8_t framebuffer_type;
  222. multiboot_uint16_t reserved;
  223. };
  224. struct multiboot_tag_framebuffer
  225. {
  226. struct multiboot_tag_framebuffer_common common;
  227. union
  228. {
  229. struct
  230. {
  231. multiboot_uint16_t framebuffer_palette_num_colors;
  232. struct multiboot_color framebuffer_palette[0];
  233. };
  234. struct
  235. {
  236. multiboot_uint8_t framebuffer_red_field_position;
  237. multiboot_uint8_t framebuffer_red_mask_size;
  238. multiboot_uint8_t framebuffer_green_field_position;
  239. multiboot_uint8_t framebuffer_green_mask_size;
  240. multiboot_uint8_t framebuffer_blue_field_position;
  241. multiboot_uint8_t framebuffer_blue_mask_size;
  242. };
  243. };
  244. };
  245. struct multiboot_tag_elf_sections
  246. {
  247. multiboot_uint32_t type;
  248. multiboot_uint32_t size;
  249. multiboot_uint32_t num;
  250. multiboot_uint32_t entsize;
  251. multiboot_uint32_t shndx;
  252. char sections[0];
  253. };
  254. struct multiboot_tag_apm
  255. {
  256. multiboot_uint32_t type;
  257. multiboot_uint32_t size;
  258. multiboot_uint16_t version;
  259. multiboot_uint16_t cseg;
  260. multiboot_uint32_t offset;
  261. multiboot_uint16_t cseg_16;
  262. multiboot_uint16_t dseg;
  263. multiboot_uint16_t flags;
  264. multiboot_uint16_t cseg_len;
  265. multiboot_uint16_t cseg_16_len;
  266. multiboot_uint16_t dseg_len;
  267. };
  268. #endif /* ! ASM_FILE */
  269. #endif /* ! MULTIBOOT_HEADER */