multiboot2.h 8.5 KB

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