multiboot.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /* multiboot.h - Multiboot header file. */
  2. /* Copyright (C) 1999,2003,2007,2008,2009 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 8192
  25. #define MULTIBOOT_HEADER_ALIGN 4
  26. /* The magic field should contain this. */
  27. #define MULTIBOOT_HEADER_MAGIC 0x1BADB002
  28. /* This should be in %eax. */
  29. #define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
  30. /* Alignment of multiboot modules. */
  31. #define MULTIBOOT_MOD_ALIGN 0x00001000
  32. /* Alignment of the multiboot info structure. */
  33. #define MULTIBOOT_INFO_ALIGN 0x00000004
  34. /* Flags set in the 'flags' member of the multiboot header. */
  35. /* Align all boot modules on i386 page (4KB) boundaries. */
  36. #define MULTIBOOT_PAGE_ALIGN 0x00000001
  37. /* Must pass memory information to OS. */
  38. #define MULTIBOOT_MEMORY_INFO 0x00000002
  39. /* Must pass video information to OS. */
  40. #define MULTIBOOT_VIDEO_MODE 0x00000004
  41. /* This flag indicates the use of the address fields in the header. */
  42. #define MULTIBOOT_AOUT_KLUDGE 0x00010000
  43. /* Flags to be set in the 'flags' member of the multiboot info structure. */
  44. /* is there basic lower/upper memory information? */
  45. #define MULTIBOOT_INFO_MEMORY 0x00000001
  46. /* is there a boot device set? */
  47. #define MULTIBOOT_INFO_BOOTDEV 0x00000002
  48. /* is the command-line defined? */
  49. #define MULTIBOOT_INFO_CMDLINE 0x00000004
  50. /* are there modules to do something with? */
  51. #define MULTIBOOT_INFO_MODS 0x00000008
  52. /* These next two are mutually exclusive */
  53. /* is there a symbol table loaded? */
  54. #define MULTIBOOT_INFO_AOUT_SYMS 0x00000010
  55. /* is there an ELF section header table? */
  56. #define MULTIBOOT_INFO_ELF_SHDR 0X00000020
  57. /* is there a full memory map? */
  58. #define MULTIBOOT_INFO_MEM_MAP 0x00000040
  59. /* Is there drive info? */
  60. #define MULTIBOOT_INFO_DRIVE_INFO 0x00000080
  61. /* Is there a config table? */
  62. #define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100
  63. /* Is there a boot loader name? */
  64. #define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200
  65. /* Is there a APM table? */
  66. #define MULTIBOOT_INFO_APM_TABLE 0x00000400
  67. /* Is there video information? */
  68. #define MULTIBOOT_INFO_VBE_INFO 0x00000800
  69. #define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000
  70. #ifndef ASM_FILE
  71. typedef unsigned char multiboot_uint8_t;
  72. typedef unsigned short multiboot_uint16_t;
  73. typedef unsigned int multiboot_uint32_t;
  74. typedef unsigned long long multiboot_uint64_t;
  75. struct multiboot_header
  76. {
  77. /* Must be MULTIBOOT_MAGIC - see above. */
  78. multiboot_uint32_t magic;
  79. /* Feature flags. */
  80. multiboot_uint32_t flags;
  81. /* The above fields plus this one must equal 0 mod 2^32. */
  82. multiboot_uint32_t checksum;
  83. /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
  84. multiboot_uint32_t header_addr;
  85. multiboot_uint32_t load_addr;
  86. multiboot_uint32_t load_end_addr;
  87. multiboot_uint32_t bss_end_addr;
  88. multiboot_uint32_t entry_addr;
  89. /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */
  90. multiboot_uint32_t mode_type;
  91. multiboot_uint32_t width;
  92. multiboot_uint32_t height;
  93. multiboot_uint32_t depth;
  94. };
  95. /* The symbol table for a.out. */
  96. struct multiboot_aout_symbol_table
  97. {
  98. multiboot_uint32_t tabsize;
  99. multiboot_uint32_t strsize;
  100. multiboot_uint32_t addr;
  101. multiboot_uint32_t reserved;
  102. };
  103. typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
  104. /* The section header table for ELF. */
  105. struct multiboot_elf_section_header_table
  106. {
  107. multiboot_uint32_t num;
  108. multiboot_uint32_t size;
  109. multiboot_uint32_t addr;
  110. multiboot_uint32_t shndx;
  111. };
  112. typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
  113. struct multiboot_info
  114. {
  115. /* Multiboot info version number */
  116. multiboot_uint32_t flags;
  117. /* Available memory from BIOS */
  118. multiboot_uint32_t mem_lower;
  119. multiboot_uint32_t mem_upper;
  120. /* "root" partition */
  121. multiboot_uint32_t boot_device;
  122. /* Kernel command line */
  123. multiboot_uint32_t cmdline;
  124. /* Boot-Module list */
  125. multiboot_uint32_t mods_count;
  126. multiboot_uint32_t mods_addr;
  127. union
  128. {
  129. multiboot_aout_symbol_table_t aout_sym;
  130. multiboot_elf_section_header_table_t elf_sec;
  131. } u;
  132. /* Memory Mapping buffer */
  133. multiboot_uint32_t mmap_length;
  134. multiboot_uint32_t mmap_addr;
  135. /* Drive Info buffer */
  136. multiboot_uint32_t drives_length;
  137. multiboot_uint32_t drives_addr;
  138. /* ROM configuration table */
  139. multiboot_uint32_t config_table;
  140. /* Boot Loader Name */
  141. multiboot_uint32_t boot_loader_name;
  142. /* APM table */
  143. multiboot_uint32_t apm_table;
  144. /* Video */
  145. multiboot_uint32_t vbe_control_info;
  146. multiboot_uint32_t vbe_mode_info;
  147. multiboot_uint16_t vbe_mode;
  148. multiboot_uint16_t vbe_interface_seg;
  149. multiboot_uint16_t vbe_interface_off;
  150. multiboot_uint16_t vbe_interface_len;
  151. multiboot_uint64_t framebuffer_addr;
  152. multiboot_uint32_t framebuffer_pitch;
  153. multiboot_uint32_t framebuffer_width;
  154. multiboot_uint32_t framebuffer_height;
  155. multiboot_uint8_t framebuffer_bpp;
  156. #define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
  157. #define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
  158. #define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
  159. multiboot_uint8_t framebuffer_type;
  160. union
  161. {
  162. struct
  163. {
  164. multiboot_uint32_t framebuffer_palette_addr;
  165. multiboot_uint16_t framebuffer_palette_num_colors;
  166. };
  167. struct
  168. {
  169. multiboot_uint8_t framebuffer_red_field_position;
  170. multiboot_uint8_t framebuffer_red_mask_size;
  171. multiboot_uint8_t framebuffer_green_field_position;
  172. multiboot_uint8_t framebuffer_green_mask_size;
  173. multiboot_uint8_t framebuffer_blue_field_position;
  174. multiboot_uint8_t framebuffer_blue_mask_size;
  175. };
  176. };
  177. };
  178. typedef struct multiboot_info multiboot_info_t;
  179. struct multiboot_color
  180. {
  181. multiboot_uint8_t red;
  182. multiboot_uint8_t green;
  183. multiboot_uint8_t blue;
  184. };
  185. struct multiboot_mmap_entry
  186. {
  187. multiboot_uint32_t size;
  188. multiboot_uint64_t addr;
  189. multiboot_uint64_t len;
  190. #define MULTIBOOT_MEMORY_AVAILABLE 1
  191. #define MULTIBOOT_MEMORY_RESERVED 2
  192. #define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
  193. #define MULTIBOOT_MEMORY_NVS 4
  194. multiboot_uint32_t type;
  195. } __attribute__((packed));
  196. typedef struct multiboot_mmap_entry multiboot_memory_map_t;
  197. struct multiboot_mod_list
  198. {
  199. /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
  200. multiboot_uint32_t mod_start;
  201. multiboot_uint32_t mod_end;
  202. /* Module command line */
  203. multiboot_uint32_t cmdline;
  204. /* padding to take it to 16 bytes (must be zero) */
  205. multiboot_uint32_t pad;
  206. };
  207. typedef struct multiboot_mod_list multiboot_module_t;
  208. #endif /* ! ASM_FILE */
  209. #endif /* ! MULTIBOOT_HEADER */