easyboot.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * easyboot.h - Multiboot2 compatible Boot header file.
  3. * https://codeberg.org/bzt/easyboot
  4. *
  5. * Copyright (C) 2023 bzt, MIT license
  6. * Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc.
  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. * @brief Simpleboot / Easyboot header file for kernels
  26. */
  27. #if !defined(SIMPLEBOOT_H) && !defined(EASYBOOT_H)
  28. #define EASYBOOT_H 1
  29. #include <stdint.h>
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. #define SIMPLEBOOT_MAGIC "Simpleboot" /* minimalistic boot loader */
  34. #define EASYBOOT_MAGIC "Easyboot" /* fully featured boot manager */
  35. /*** Multiboot2 ***/
  36. /* This should be in the first kernel parameter as well as in %eax. */
  37. #define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289
  38. /* Alignment of multiboot modules. */
  39. #define MULTIBOOT_MOD_ALIGN 0x00001000
  40. /* Alignment of the multiboot info structure. */
  41. #define MULTIBOOT_INFO_ALIGN 0x00000008
  42. /* Flags set in the ’flags’ member of the multiboot header. */
  43. #define MULTIBOOT_TAG_ALIGN 8
  44. #define MULTIBOOT_TAG_TYPE_END 0
  45. #define MULTIBOOT_TAG_TYPE_CMDLINE 1
  46. #define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2
  47. #define MULTIBOOT_TAG_TYPE_MODULE 3
  48. #define MULTIBOOT_TAG_TYPE_MMAP 6
  49. #define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8
  50. #define MULTIBOOT_TAG_TYPE_EFI64 12
  51. #define MULTIBOOT_TAG_TYPE_SMBIOS 13
  52. #define MULTIBOOT_TAG_TYPE_ACPI_OLD 14
  53. #define MULTIBOOT_TAG_TYPE_ACPI_NEW 15
  54. #define MULTIBOOT_TAG_TYPE_EFI64_IH 20
  55. /* Additional, not in the original Multiboot2 spec. */
  56. #define MULTIBOOT_TAG_TYPE_EDID 256
  57. #define MULTIBOOT_TAG_TYPE_SMP 257
  58. #define MULTIBOOT_TAG_TYPE_PARTUUID 258
  59. /* Multiboot2 information header */
  60. typedef struct {
  61. uint32_t total_size;
  62. uint32_t reserved;
  63. } multiboot_info_t;
  64. /* common tag header */
  65. typedef struct {
  66. uint32_t type;
  67. uint32_t size;
  68. } multiboot_tag_t;
  69. /* Boot command line (type 1) */
  70. typedef struct {
  71. uint32_t type;
  72. uint32_t size;
  73. char string[0];
  74. } multiboot_tag_cmdline_t;
  75. /* Boot loader name (type 2) */
  76. typedef struct {
  77. uint32_t type;
  78. uint32_t size;
  79. char string[0];
  80. } multiboot_tag_loader_t;
  81. /* Modules (type 3) */
  82. typedef struct {
  83. uint32_t type;
  84. uint32_t size;
  85. uint32_t mod_start;
  86. uint32_t mod_end;
  87. char string[0];
  88. } multiboot_tag_module_t;
  89. /* Memory Map (type 6) */
  90. #define MULTIBOOT_MEMORY_AVAILABLE 1
  91. #define MULTIBOOT_MEMORY_RESERVED 2
  92. /* original EFI type stored in "reserved" field */
  93. #define MULTIBOOT_MEMORY_UEFI MULTIBOOT_MEMORY_RESERVED
  94. #define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
  95. #define MULTIBOOT_MEMORY_NVS 4
  96. #define MULTIBOOT_MEMORY_BADRAM 5
  97. typedef struct {
  98. uint64_t base_addr;
  99. uint64_t length;
  100. uint32_t type;
  101. uint32_t reserved; /* original EFI Memory Type */
  102. } multiboot_mmap_entry_t;
  103. typedef struct {
  104. uint32_t type;
  105. uint32_t size;
  106. uint32_t entry_size;
  107. uint32_t entry_version;
  108. multiboot_mmap_entry_t entries[0];
  109. } multiboot_tag_mmap_t;
  110. /* Framebuffer info (type 8) */
  111. typedef struct {
  112. uint32_t type;
  113. uint32_t size;
  114. uint64_t framebuffer_addr;
  115. uint32_t framebuffer_pitch;
  116. uint32_t framebuffer_width;
  117. uint32_t framebuffer_height;
  118. uint8_t framebuffer_bpp;
  119. uint8_t framebuffer_type; /* must be 1 */
  120. uint16_t reserved;
  121. uint8_t framebuffer_red_field_position;
  122. uint8_t framebuffer_red_mask_size;
  123. uint8_t framebuffer_green_field_position;
  124. uint8_t framebuffer_green_mask_size;
  125. uint8_t framebuffer_blue_field_position;
  126. uint8_t framebuffer_blue_mask_size;
  127. } multiboot_tag_framebuffer_t;
  128. /* EFI 64-bit image handle pointer (type 12) */
  129. typedef struct {
  130. uint32_t type;
  131. uint32_t size;
  132. uint64_t pointer;
  133. } multiboot_tag_efi64_t;
  134. /* SMBIOS tables (type 13) */
  135. typedef struct {
  136. uint32_t type;
  137. uint32_t size;
  138. uint8_t major;
  139. uint8_t minor;
  140. uint8_t reserved[6];
  141. uint8_t tables[0];
  142. } multiboot_tag_smbios_t;
  143. /* ACPI old RSDP (type 14) */
  144. typedef struct {
  145. uint32_t type;
  146. uint32_t size;
  147. uint8_t rsdp[0];
  148. } multiboot_tag_old_acpi_t;
  149. /* ACPI new RSDP (type 15) */
  150. typedef struct {
  151. uint32_t type;
  152. uint32_t size;
  153. uint8_t rsdp[0];
  154. } multiboot_tag_new_acpi_t;
  155. /* EFI 64-bit image handle pointer (type 20) */
  156. typedef struct {
  157. uint32_t type;
  158. uint32_t size;
  159. uint64_t pointer;
  160. } multiboot_tag_efi64_ih_t;
  161. /* EDID supported monitor resolutions (type 256) */
  162. typedef struct {
  163. uint32_t type;
  164. uint32_t size;
  165. uint8_t edid[0];
  166. } multiboot_tag_edid_t;
  167. /* SMP supported (type 257) */
  168. typedef struct {
  169. uint32_t type;
  170. uint32_t size;
  171. uint32_t numcores;
  172. uint32_t running;
  173. uint32_t bspid;
  174. } multiboot_tag_smp_t;
  175. /* Partition UUIDs (type 258) */
  176. typedef struct {
  177. uint32_t type;
  178. uint32_t size;
  179. uint8_t bootuuid[16];
  180. uint8_t rootuuid[16];
  181. } multiboot_tag_partuuid_t;
  182. #ifdef __cplusplus
  183. }
  184. #endif
  185. #endif /* EASYBOOT_H */