easyboot.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. /* Multiboot2 information header */
  59. typedef struct {
  60. uint32_t total_size;
  61. uint32_t reserved;
  62. } multiboot_info_t;
  63. /* common tag header */
  64. typedef struct {
  65. uint32_t type;
  66. uint32_t size;
  67. } multiboot_tag_t;
  68. /* Boot command line (type 1) */
  69. typedef struct {
  70. uint32_t type;
  71. uint32_t size;
  72. char string[0];
  73. } multiboot_tag_cmdline_t;
  74. /* Boot loader name (type 2) */
  75. typedef struct {
  76. uint32_t type;
  77. uint32_t size;
  78. char string[0];
  79. } multiboot_tag_loader_t;
  80. /* Modules (type 3) */
  81. typedef struct {
  82. uint32_t type;
  83. uint32_t size;
  84. uint32_t mod_start;
  85. uint32_t mod_end;
  86. char string[0];
  87. } multiboot_tag_module_t;
  88. /* Memory Map (type 6) */
  89. #define MULTIBOOT_MEMORY_AVAILABLE 1
  90. #define MULTIBOOT_MEMORY_RESERVED 2
  91. /* original EFI type stored in "reserved" field */
  92. #define MULTIBOOT_MEMORY_UEFI MULTIBOOT_MEMORY_RESERVED
  93. #define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
  94. #define MULTIBOOT_MEMORY_NVS 4
  95. #define MULTIBOOT_MEMORY_BADRAM 5
  96. typedef struct {
  97. uint64_t base_addr;
  98. uint64_t length;
  99. uint32_t type;
  100. uint32_t reserved; /* original EFI Memory Type */
  101. } multiboot_mmap_entry_t;
  102. typedef struct {
  103. uint32_t type;
  104. uint32_t size;
  105. uint32_t entry_size;
  106. uint32_t entry_version;
  107. multiboot_mmap_entry_t entries[0];
  108. } multiboot_tag_mmap_t;
  109. /* Framebuffer info (type 8) */
  110. typedef struct {
  111. uint32_t type;
  112. uint32_t size;
  113. uint64_t framebuffer_addr;
  114. uint32_t framebuffer_pitch;
  115. uint32_t framebuffer_width;
  116. uint32_t framebuffer_height;
  117. uint8_t framebuffer_bpp;
  118. uint8_t framebuffer_type; /* must be 1 */
  119. uint16_t reserved;
  120. uint8_t framebuffer_red_field_position;
  121. uint8_t framebuffer_red_mask_size;
  122. uint8_t framebuffer_green_field_position;
  123. uint8_t framebuffer_green_mask_size;
  124. uint8_t framebuffer_blue_field_position;
  125. uint8_t framebuffer_blue_mask_size;
  126. } multiboot_tag_framebuffer_t;
  127. /* EFI 64-bit image handle pointer (type 12) */
  128. typedef struct {
  129. uint32_t type;
  130. uint32_t size;
  131. uint64_t pointer;
  132. } multiboot_tag_efi64_t;
  133. /* SMBIOS tables (type 13) */
  134. typedef struct {
  135. uint32_t type;
  136. uint32_t size;
  137. uint8_t major;
  138. uint8_t minor;
  139. uint8_t reserved[6];
  140. uint8_t tables[0];
  141. } multiboot_tag_smbios_t;
  142. /* ACPI old RSDP (type 14) */
  143. typedef struct {
  144. uint32_t type;
  145. uint32_t size;
  146. uint8_t rsdp[0];
  147. } multiboot_tag_old_acpi_t;
  148. /* ACPI new RSDP (type 15) */
  149. typedef struct {
  150. uint32_t type;
  151. uint32_t size;
  152. uint8_t rsdp[0];
  153. } multiboot_tag_new_acpi_t;
  154. /* EFI 64-bit image handle pointer (type 20) */
  155. typedef struct {
  156. uint32_t type;
  157. uint32_t size;
  158. uint64_t pointer;
  159. } multiboot_tag_efi64_ih_t;
  160. /* EDID supported monitor resolutions (type 256) */
  161. typedef struct {
  162. uint32_t type;
  163. uint32_t size;
  164. uint8_t edid[0];
  165. } multiboot_tag_edid_t;
  166. /* SMP supported (type 257) */
  167. typedef struct {
  168. uint32_t type;
  169. uint32_t size;
  170. uint32_t numcores;
  171. uint32_t running;
  172. uint32_t bspid;
  173. } multiboot_tag_smp_t;
  174. #ifdef __cplusplus
  175. }
  176. #endif
  177. #endif /* EASYBOOT_H */