stivale2.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. #ifndef __STIVALE__STIVALE2_H__
  2. #define __STIVALE__STIVALE2_H__
  3. #include <stdint.h>
  4. struct stivale2_tag {
  5. uint64_t identifier;
  6. uint64_t next;
  7. } __attribute__((__packed__));
  8. /* --- Header --------------------------------------------------------------- */
  9. /* Information passed from the kernel to the bootloader */
  10. struct stivale2_header {
  11. uint64_t entry_point;
  12. uint64_t stack;
  13. uint64_t flags;
  14. uint64_t tags;
  15. } __attribute__((__packed__));
  16. #define STIVALE2_HEADER_TAG_FRAMEBUFFER_ID 0x3ecc1bc43d0f7971
  17. struct stivale2_header_tag_framebuffer {
  18. struct stivale2_tag tag;
  19. uint16_t framebuffer_width;
  20. uint16_t framebuffer_height;
  21. uint16_t framebuffer_bpp;
  22. } __attribute__((__packed__));
  23. #define STIVALE2_HEADER_TAG_FB_MTRR_ID 0x4c7bb07731282e00
  24. #define STIVALE2_HEADER_TAG_TERMINAL_ID 0xa85d499b1823be72
  25. struct stivale2_header_tag_terminal {
  26. struct stivale2_tag tag;
  27. uint64_t flags;
  28. } __attribute__((__packed__));
  29. #define STIVALE2_HEADER_TAG_SMP_ID 0x1ab015085f3273df
  30. struct stivale2_header_tag_smp {
  31. struct stivale2_tag tag;
  32. uint64_t flags;
  33. } __attribute__((__packed__));
  34. #define STIVALE2_HEADER_TAG_5LV_PAGING_ID 0x932f477032007e8f
  35. #define STIVALE2_HEADER_TAG_UNMAP_NULL_ID 0x92919432b16fe7e7
  36. /* --- Struct --------------------------------------------------------------- */
  37. /* Information passed from the bootloader to the kernel */
  38. struct stivale2_struct {
  39. #define STIVALE2_BOOTLOADER_BRAND_SIZE 64
  40. char bootloader_brand[STIVALE2_BOOTLOADER_BRAND_SIZE];
  41. #define STIVALE2_BOOTLOADER_VERSION_SIZE 64
  42. char bootloader_version[STIVALE2_BOOTLOADER_VERSION_SIZE];
  43. uint64_t tags;
  44. } __attribute__((__packed__));
  45. #define STIVALE2_STRUCT_TAG_CMDLINE_ID 0xe5e76a1b4597a781
  46. struct stivale2_struct_tag_cmdline {
  47. struct stivale2_tag tag;
  48. uint64_t cmdline;
  49. } __attribute__((__packed__));
  50. #define STIVALE2_STRUCT_TAG_MEMMAP_ID 0x2187f79e8612de07
  51. #define STIVALE2_MMAP_USABLE 1
  52. #define STIVALE2_MMAP_RESERVED 2
  53. #define STIVALE2_MMAP_ACPI_RECLAIMABLE 3
  54. #define STIVALE2_MMAP_ACPI_NVS 4
  55. #define STIVALE2_MMAP_BAD_MEMORY 5
  56. #define STIVALE2_MMAP_BOOTLOADER_RECLAIMABLE 0x1000
  57. #define STIVALE2_MMAP_KERNEL_AND_MODULES 0x1001
  58. #define STIVALE2_MMAP_FRAMEBUFFER 0x1002
  59. struct stivale2_mmap_entry {
  60. uint64_t base;
  61. uint64_t length;
  62. uint32_t type;
  63. uint32_t unused;
  64. } __attribute__((__packed__));
  65. struct stivale2_struct_tag_memmap {
  66. struct stivale2_tag tag;
  67. uint64_t entries;
  68. struct stivale2_mmap_entry memmap[];
  69. } __attribute__((__packed__));
  70. #define STIVALE2_STRUCT_TAG_FRAMEBUFFER_ID 0x506461d2950408fa
  71. #define STIVALE2_FBUF_MMODEL_RGB 1
  72. struct stivale2_struct_tag_framebuffer {
  73. struct stivale2_tag tag;
  74. uint64_t framebuffer_addr;
  75. uint16_t framebuffer_width;
  76. uint16_t framebuffer_height;
  77. uint16_t framebuffer_pitch;
  78. uint16_t framebuffer_bpp;
  79. uint8_t memory_model;
  80. uint8_t red_mask_size;
  81. uint8_t red_mask_shift;
  82. uint8_t green_mask_size;
  83. uint8_t green_mask_shift;
  84. uint8_t blue_mask_size;
  85. uint8_t blue_mask_shift;
  86. } __attribute__((__packed__));
  87. #define STIVALE2_STRUCT_TAG_EDID_ID 0x968609d7af96b845
  88. struct stivale2_struct_tag_edid {
  89. struct stivale2_tag tag;
  90. uint64_t edid_size;
  91. uint8_t edid_information[];
  92. } __attribute__((__packed__));
  93. #define STIVALE2_STRUCT_TAG_FB_MTRR_ID 0x6bc1a78ebe871172
  94. #define STIVALE2_STRUCT_TAG_TERMINAL_ID 0xc2b3f4c3233b0974
  95. struct stivale2_struct_tag_terminal {
  96. struct stivale2_tag tag;
  97. uint32_t flags;
  98. uint16_t cols;
  99. uint16_t rows;
  100. uint64_t term_write;
  101. } __attribute__((__packed__));
  102. #define STIVALE2_STRUCT_TAG_MODULES_ID 0x4b6fe466aade04ce
  103. struct stivale2_module {
  104. uint64_t begin;
  105. uint64_t end;
  106. #define STIVALE2_MODULE_STRING_SIZE 128
  107. char string[STIVALE2_MODULE_STRING_SIZE];
  108. } __attribute__((__packed__));
  109. struct stivale2_struct_tag_modules {
  110. struct stivale2_tag tag;
  111. uint64_t module_count;
  112. struct stivale2_module modules[];
  113. } __attribute__((__packed__));
  114. #define STIVALE2_STRUCT_TAG_RSDP_ID 0x9e1786930a375e78
  115. struct stivale2_struct_tag_rsdp {
  116. struct stivale2_tag tag;
  117. uint64_t rsdp;
  118. } __attribute__((__packed__));
  119. #define STIVALE2_STRUCT_TAG_EPOCH_ID 0x566a7bed888e1407
  120. struct stivale2_struct_tag_epoch {
  121. struct stivale2_tag tag;
  122. uint64_t epoch;
  123. } __attribute__((__packed__));
  124. #define STIVALE2_STRUCT_TAG_FIRMWARE_ID 0x359d837855e3858c
  125. #define STIVALE2_FIRMWARE_BIOS (1 << 0)
  126. struct stivale2_struct_tag_firmware {
  127. struct stivale2_tag tag;
  128. uint64_t flags;
  129. } __attribute__((__packed__));
  130. #define STIVALE2_STRUCT_TAG_EFI_SYSTEM_TABLE_ID 0x4bc5ec15845b558e
  131. struct stivale2_struct_tag_efi_system_table {
  132. struct stivale2_tag tag;
  133. uint64_t system_table;
  134. } __attribute__((__packed__));
  135. #define STIVALE2_STRUCT_TAG_KERNEL_FILE_ID 0xe599d90c2975584a
  136. struct stivale2_struct_tag_kernel_file {
  137. struct stivale2_tag tag;
  138. uint64_t kernel_file;
  139. } __attribute__((__packed__));
  140. #define STIVALE2_STRUCT_TAG_KERNEL_SLIDE_ID 0xee80847d01506c57
  141. struct stivale2_struct_tag_kernel_slide {
  142. struct stivale2_tag tag;
  143. uint64_t kernel_slide;
  144. } __attribute__((packed));
  145. #define STIVALE2_STRUCT_TAG_SMBIOS_ID 0x274bd246c62bf7d1
  146. struct stivale2_struct_tag_smbios {
  147. struct stivale2_tag tag;
  148. uint64_t flags;
  149. uint64_t smbios_entry_32;
  150. uint64_t smbios_entry_64;
  151. } __attribute__((packed));
  152. #define STIVALE2_STRUCT_TAG_SMP_ID 0x34d1d96339647025
  153. struct stivale2_smp_info {
  154. uint32_t processor_id;
  155. uint32_t lapic_id;
  156. uint64_t target_stack;
  157. uint64_t goto_address;
  158. uint64_t extra_argument;
  159. } __attribute__((__packed__));
  160. struct stivale2_struct_tag_smp {
  161. struct stivale2_tag tag;
  162. uint64_t flags;
  163. uint32_t bsp_lapic_id;
  164. uint32_t unused;
  165. uint64_t cpu_count;
  166. struct stivale2_smp_info smp_info[];
  167. } __attribute__((__packed__));
  168. #define STIVALE2_STRUCT_TAG_PXE_SERVER_INFO 0x29d1e96239247032
  169. struct stivale2_struct_tag_pxe_server_info {
  170. struct stivale2_tag tag;
  171. uint32_t server_ip;
  172. } __attribute__((__packed__));
  173. #define STIVALE2_STRUCT_TAG_MMIO32_UART 0xb813f9b8dbc78797
  174. struct stivale2_struct_tag_mmio32_uart {
  175. struct stivale2_tag tag;
  176. uint64_t addr;
  177. } __attribute__((__packed__));
  178. #define STIVALE2_STRUCT_TAG_DTB 0xabb29bd49a2833fa
  179. struct stivale2_struct_tag_dtb {
  180. struct stivale2_tag tag;
  181. uint64_t addr;
  182. uint64_t size;
  183. } __attribute__((__packed__));
  184. #define STIVALE2_STRUCT_TAG_VMAP 0xb0ed257db18cb58f
  185. struct stivale2_struct_vmap {
  186. struct stivale2_tag tag;
  187. uint64_t addr;
  188. } __attribute__((__packed__));
  189. #endif