coreboot_tables.h 5.5 KB

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