tables.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /*
  2. * This file is part of the libpayload project.
  3. *
  4. * Copyright (C) 2008 Advanced Micro Devices, Inc.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef _COREBOOT_TABLES_H
  9. #define _COREBOOT_TABLES_H
  10. #include <compiler.h>
  11. struct cbuint64 {
  12. u32 lo;
  13. u32 hi;
  14. };
  15. struct cb_header {
  16. u8 signature[4];
  17. u32 header_bytes;
  18. u32 header_checksum;
  19. u32 table_bytes;
  20. u32 table_checksum;
  21. u32 table_entries;
  22. };
  23. struct cb_record {
  24. u32 tag;
  25. u32 size;
  26. };
  27. #define CB_TAG_UNUSED 0x0000
  28. #define CB_TAG_MEMORY 0x0001
  29. struct cb_memory_range {
  30. struct cbuint64 start;
  31. struct cbuint64 size;
  32. u32 type;
  33. };
  34. #define CB_MEM_RAM 1
  35. #define CB_MEM_RESERVED 2
  36. #define CB_MEM_ACPI 3
  37. #define CB_MEM_NVS 4
  38. #define CB_MEM_UNUSABLE 5
  39. #define CB_MEM_VENDOR_RSVD 6
  40. #define CB_MEM_TABLE 16
  41. struct cb_memory {
  42. u32 tag;
  43. u32 size;
  44. struct cb_memory_range map[0];
  45. };
  46. #define CB_TAG_HWRPB 0x0002
  47. struct cb_hwrpb {
  48. u32 tag;
  49. u32 size;
  50. u64 hwrpb;
  51. };
  52. #define CB_TAG_MAINBOARD 0x0003
  53. struct cb_mainboard {
  54. u32 tag;
  55. u32 size;
  56. u8 vendor_idx;
  57. u8 part_number_idx;
  58. u8 strings[0];
  59. };
  60. #define CB_TAG_VERSION 0x0004
  61. #define CB_TAG_EXTRA_VERSION 0x0005
  62. #define CB_TAG_BUILD 0x0006
  63. #define CB_TAG_COMPILE_TIME 0x0007
  64. #define CB_TAG_COMPILE_BY 0x0008
  65. #define CB_TAG_COMPILE_HOST 0x0009
  66. #define CB_TAG_COMPILE_DOMAIN 0x000a
  67. #define CB_TAG_COMPILER 0x000b
  68. #define CB_TAG_LINKER 0x000c
  69. #define CB_TAG_ASSEMBLER 0x000d
  70. struct cb_string {
  71. u32 tag;
  72. u32 size;
  73. u8 string[0];
  74. };
  75. #define CB_TAG_SERIAL 0x000f
  76. struct cb_serial {
  77. u32 tag;
  78. u32 size;
  79. #define CB_SERIAL_TYPE_IO_MAPPED 1
  80. #define CB_SERIAL_TYPE_MEMORY_MAPPED 2
  81. u32 type;
  82. u32 baseaddr;
  83. u32 baud;
  84. };
  85. #define CB_TAG_CONSOLE 0x00010
  86. struct cb_console {
  87. u32 tag;
  88. u32 size;
  89. u16 type;
  90. };
  91. #define CB_TAG_CONSOLE_SERIAL8250 0
  92. #define CB_TAG_CONSOLE_VGA 1 /* OBSOLETE */
  93. #define CB_TAG_CONSOLE_BTEXT 2 /* OBSOLETE */
  94. #define CB_TAG_CONSOLE_LOGBUF 3
  95. #define CB_TAG_CONSOLE_SROM 4 /* OBSOLETE */
  96. #define CB_TAG_CONSOLE_EHCI 5
  97. #define CB_TAG_FORWARD 0x00011
  98. struct cb_forward {
  99. u32 tag;
  100. u32 size;
  101. u64 forward;
  102. };
  103. #define CB_TAG_FRAMEBUFFER 0x0012
  104. struct cb_framebuffer {
  105. u32 tag;
  106. u32 size;
  107. u64 physical_address;
  108. u32 x_resolution;
  109. u32 y_resolution;
  110. u32 bytes_per_line;
  111. u8 bits_per_pixel;
  112. u8 red_mask_pos;
  113. u8 red_mask_size;
  114. u8 green_mask_pos;
  115. u8 green_mask_size;
  116. u8 blue_mask_pos;
  117. u8 blue_mask_size;
  118. u8 reserved_mask_pos;
  119. u8 reserved_mask_size;
  120. };
  121. #define CB_TAG_GPIO 0x0013
  122. #define GPIO_MAX_NAME_LENGTH 16
  123. struct cb_gpio {
  124. u32 port;
  125. u32 polarity;
  126. u32 value;
  127. u8 name[GPIO_MAX_NAME_LENGTH];
  128. };
  129. struct cb_gpios {
  130. u32 tag;
  131. u32 size;
  132. u32 count;
  133. struct cb_gpio gpios[0];
  134. };
  135. #define CB_TAG_FDT 0x0014
  136. struct cb_fdt {
  137. uint32_t tag;
  138. uint32_t size; /* size of the entire entry */
  139. /* the actual FDT gets placed here */
  140. };
  141. #define CB_TAG_VDAT 0x0015
  142. struct cb_vdat {
  143. uint32_t tag;
  144. uint32_t size; /* size of the entire entry */
  145. void *vdat_addr;
  146. uint32_t vdat_size;
  147. };
  148. #define CB_TAG_TIMESTAMPS 0x0016
  149. #define CB_TAG_CBMEM_CONSOLE 0x0017
  150. #define CB_TAG_MRC_CACHE 0x0018
  151. struct cb_cbmem_tab {
  152. uint32_t tag;
  153. uint32_t size;
  154. void *cbmem_tab;
  155. };
  156. #define CB_TAG_VBNV 0x0019
  157. struct cb_vbnv {
  158. uint32_t tag;
  159. uint32_t size;
  160. uint32_t vbnv_start;
  161. uint32_t vbnv_size;
  162. };
  163. #define CB_TAG_CMOS_OPTION_TABLE 0x00c8
  164. struct cb_cmos_option_table {
  165. u32 tag;
  166. u32 size;
  167. u32 header_length;
  168. };
  169. #define CB_TAG_OPTION 0x00c9
  170. #define CMOS_MAX_NAME_LENGTH 32
  171. struct cb_cmos_entries {
  172. u32 tag;
  173. u32 size;
  174. u32 bit;
  175. u32 length;
  176. u32 config;
  177. u32 config_id;
  178. u8 name[CMOS_MAX_NAME_LENGTH];
  179. };
  180. #define CB_TAG_OPTION_ENUM 0x00ca
  181. #define CMOS_MAX_TEXT_LENGTH 32
  182. struct cb_cmos_enums {
  183. u32 tag;
  184. u32 size;
  185. u32 config_id;
  186. u32 value;
  187. u8 text[CMOS_MAX_TEXT_LENGTH];
  188. };
  189. #define CB_TAG_OPTION_DEFAULTS 0x00cb
  190. #define CMOS_IMAGE_BUFFER_SIZE 128
  191. struct cb_cmos_defaults {
  192. u32 tag;
  193. u32 size;
  194. u32 name_length;
  195. u8 name[CMOS_MAX_NAME_LENGTH];
  196. u8 default_set[CMOS_IMAGE_BUFFER_SIZE];
  197. };
  198. #define CB_TAG_OPTION_CHECKSUM 0x00cc
  199. #define CHECKSUM_NONE 0
  200. #define CHECKSUM_PCBIOS 1
  201. struct cb_cmos_checksum {
  202. u32 tag;
  203. u32 size;
  204. u32 range_start;
  205. u32 range_end;
  206. u32 location;
  207. u32 type;
  208. };
  209. /* Helpful macros */
  210. #define MEM_RANGE_COUNT(_rec) \
  211. (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0]))
  212. #define MEM_RANGE_PTR(_rec, _idx) \
  213. (((u8 *) (_rec)) + sizeof(*(_rec)) \
  214. + (sizeof((_rec)->map[0]) * (_idx)))
  215. #define MB_VENDOR_STRING(_mb) \
  216. (((unsigned char *) ((_mb)->strings)) + (_mb)->vendor_idx)
  217. #define MB_PART_STRING(_mb) \
  218. (((unsigned char *) ((_mb)->strings)) + (_mb)->part_number_idx)
  219. #define UNPACK_CB64(_in) \
  220. ((((u64) _in.hi) << 32) | _in.lo)
  221. struct sysinfo_t;
  222. int get_coreboot_info(struct sysinfo_t *info);
  223. #define CBMEM_TOC_RESERVED 512
  224. #define MAX_CBMEM_ENTRIES 16
  225. #define CBMEM_MAGIC 0x434f5245
  226. struct cbmem_entry {
  227. u32 magic;
  228. u32 id;
  229. u64 base;
  230. u64 size;
  231. } __packed;
  232. #define CBMEM_ID_FREESPACE 0x46524545
  233. #define CBMEM_ID_GDT 0x4c474454
  234. #define CBMEM_ID_ACPI 0x41435049
  235. #define CBMEM_ID_CBTABLE 0x43425442
  236. #define CBMEM_ID_PIRQ 0x49525154
  237. #define CBMEM_ID_MPTABLE 0x534d5054
  238. #define CBMEM_ID_RESUME 0x5245534d
  239. #define CBMEM_ID_RESUME_SCRATCH 0x52455343
  240. #define CBMEM_ID_SMBIOS 0x534d4254
  241. #define CBMEM_ID_TIMESTAMP 0x54494d45
  242. #define CBMEM_ID_MRCDATA 0x4d524344
  243. #define CBMEM_ID_CONSOLE 0x434f4e53
  244. #define CBMEM_ID_NONE 0x00000000
  245. #endif