tables.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /*
  2. * This file is part of the libpayload project.
  3. *
  4. * Copyright (C) 2008 Advanced Micro Devices, Inc.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. The name of the author may not be used to endorse or promote products
  15. * derived from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. */
  29. #ifndef _COREBOOT_TABLES_H
  30. #define _COREBOOT_TABLES_H
  31. #include <compiler.h>
  32. struct cbuint64 {
  33. u32 lo;
  34. u32 hi;
  35. };
  36. struct cb_header {
  37. u8 signature[4];
  38. u32 header_bytes;
  39. u32 header_checksum;
  40. u32 table_bytes;
  41. u32 table_checksum;
  42. u32 table_entries;
  43. };
  44. struct cb_record {
  45. u32 tag;
  46. u32 size;
  47. };
  48. #define CB_TAG_UNUSED 0x0000
  49. #define CB_TAG_MEMORY 0x0001
  50. struct cb_memory_range {
  51. struct cbuint64 start;
  52. struct cbuint64 size;
  53. u32 type;
  54. };
  55. #define CB_MEM_RAM 1
  56. #define CB_MEM_RESERVED 2
  57. #define CB_MEM_ACPI 3
  58. #define CB_MEM_NVS 4
  59. #define CB_MEM_UNUSABLE 5
  60. #define CB_MEM_VENDOR_RSVD 6
  61. #define CB_MEM_TABLE 16
  62. struct cb_memory {
  63. u32 tag;
  64. u32 size;
  65. struct cb_memory_range map[0];
  66. };
  67. #define CB_TAG_HWRPB 0x0002
  68. struct cb_hwrpb {
  69. u32 tag;
  70. u32 size;
  71. u64 hwrpb;
  72. };
  73. #define CB_TAG_MAINBOARD 0x0003
  74. struct cb_mainboard {
  75. u32 tag;
  76. u32 size;
  77. u8 vendor_idx;
  78. u8 part_number_idx;
  79. u8 strings[0];
  80. };
  81. #define CB_TAG_VERSION 0x0004
  82. #define CB_TAG_EXTRA_VERSION 0x0005
  83. #define CB_TAG_BUILD 0x0006
  84. #define CB_TAG_COMPILE_TIME 0x0007
  85. #define CB_TAG_COMPILE_BY 0x0008
  86. #define CB_TAG_COMPILE_HOST 0x0009
  87. #define CB_TAG_COMPILE_DOMAIN 0x000a
  88. #define CB_TAG_COMPILER 0x000b
  89. #define CB_TAG_LINKER 0x000c
  90. #define CB_TAG_ASSEMBLER 0x000d
  91. struct cb_string {
  92. u32 tag;
  93. u32 size;
  94. u8 string[0];
  95. };
  96. #define CB_TAG_SERIAL 0x000f
  97. struct cb_serial {
  98. u32 tag;
  99. u32 size;
  100. #define CB_SERIAL_TYPE_IO_MAPPED 1
  101. #define CB_SERIAL_TYPE_MEMORY_MAPPED 2
  102. u32 type;
  103. u32 baseaddr;
  104. u32 baud;
  105. };
  106. #define CB_TAG_CONSOLE 0x00010
  107. struct cb_console {
  108. u32 tag;
  109. u32 size;
  110. u16 type;
  111. };
  112. #define CB_TAG_CONSOLE_SERIAL8250 0
  113. #define CB_TAG_CONSOLE_VGA 1 /* OBSOLETE */
  114. #define CB_TAG_CONSOLE_BTEXT 2 /* OBSOLETE */
  115. #define CB_TAG_CONSOLE_LOGBUF 3
  116. #define CB_TAG_CONSOLE_SROM 4 /* OBSOLETE */
  117. #define CB_TAG_CONSOLE_EHCI 5
  118. #define CB_TAG_FORWARD 0x00011
  119. struct cb_forward {
  120. u32 tag;
  121. u32 size;
  122. u64 forward;
  123. };
  124. #define CB_TAG_FRAMEBUFFER 0x0012
  125. struct cb_framebuffer {
  126. u32 tag;
  127. u32 size;
  128. u64 physical_address;
  129. u32 x_resolution;
  130. u32 y_resolution;
  131. u32 bytes_per_line;
  132. u8 bits_per_pixel;
  133. u8 red_mask_pos;
  134. u8 red_mask_size;
  135. u8 green_mask_pos;
  136. u8 green_mask_size;
  137. u8 blue_mask_pos;
  138. u8 blue_mask_size;
  139. u8 reserved_mask_pos;
  140. u8 reserved_mask_size;
  141. };
  142. #define CB_TAG_GPIO 0x0013
  143. #define GPIO_MAX_NAME_LENGTH 16
  144. struct cb_gpio {
  145. u32 port;
  146. u32 polarity;
  147. u32 value;
  148. u8 name[GPIO_MAX_NAME_LENGTH];
  149. };
  150. struct cb_gpios {
  151. u32 tag;
  152. u32 size;
  153. u32 count;
  154. struct cb_gpio gpios[0];
  155. };
  156. #define CB_TAG_FDT 0x0014
  157. struct cb_fdt {
  158. uint32_t tag;
  159. uint32_t size; /* size of the entire entry */
  160. /* the actual FDT gets placed here */
  161. };
  162. #define CB_TAG_VDAT 0x0015
  163. struct cb_vdat {
  164. uint32_t tag;
  165. uint32_t size; /* size of the entire entry */
  166. void *vdat_addr;
  167. uint32_t vdat_size;
  168. };
  169. #define CB_TAG_TIMESTAMPS 0x0016
  170. #define CB_TAG_CBMEM_CONSOLE 0x0017
  171. #define CB_TAG_MRC_CACHE 0x0018
  172. struct cb_cbmem_tab {
  173. uint32_t tag;
  174. uint32_t size;
  175. void *cbmem_tab;
  176. };
  177. #define CB_TAG_VBNV 0x0019
  178. struct cb_vbnv {
  179. uint32_t tag;
  180. uint32_t size;
  181. uint32_t vbnv_start;
  182. uint32_t vbnv_size;
  183. };
  184. #define CB_TAG_CMOS_OPTION_TABLE 0x00c8
  185. struct cb_cmos_option_table {
  186. u32 tag;
  187. u32 size;
  188. u32 header_length;
  189. };
  190. #define CB_TAG_OPTION 0x00c9
  191. #define CMOS_MAX_NAME_LENGTH 32
  192. struct cb_cmos_entries {
  193. u32 tag;
  194. u32 size;
  195. u32 bit;
  196. u32 length;
  197. u32 config;
  198. u32 config_id;
  199. u8 name[CMOS_MAX_NAME_LENGTH];
  200. };
  201. #define CB_TAG_OPTION_ENUM 0x00ca
  202. #define CMOS_MAX_TEXT_LENGTH 32
  203. struct cb_cmos_enums {
  204. u32 tag;
  205. u32 size;
  206. u32 config_id;
  207. u32 value;
  208. u8 text[CMOS_MAX_TEXT_LENGTH];
  209. };
  210. #define CB_TAG_OPTION_DEFAULTS 0x00cb
  211. #define CMOS_IMAGE_BUFFER_SIZE 128
  212. struct cb_cmos_defaults {
  213. u32 tag;
  214. u32 size;
  215. u32 name_length;
  216. u8 name[CMOS_MAX_NAME_LENGTH];
  217. u8 default_set[CMOS_IMAGE_BUFFER_SIZE];
  218. };
  219. #define CB_TAG_OPTION_CHECKSUM 0x00cc
  220. #define CHECKSUM_NONE 0
  221. #define CHECKSUM_PCBIOS 1
  222. struct cb_cmos_checksum {
  223. u32 tag;
  224. u32 size;
  225. u32 range_start;
  226. u32 range_end;
  227. u32 location;
  228. u32 type;
  229. };
  230. /* Helpful macros */
  231. #define MEM_RANGE_COUNT(_rec) \
  232. (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0]))
  233. #define MEM_RANGE_PTR(_rec, _idx) \
  234. (((u8 *) (_rec)) + sizeof(*(_rec)) \
  235. + (sizeof((_rec)->map[0]) * (_idx)))
  236. #define MB_VENDOR_STRING(_mb) \
  237. (((unsigned char *) ((_mb)->strings)) + (_mb)->vendor_idx)
  238. #define MB_PART_STRING(_mb) \
  239. (((unsigned char *) ((_mb)->strings)) + (_mb)->part_number_idx)
  240. #define UNPACK_CB64(_in) \
  241. ((((u64) _in.hi) << 32) | _in.lo)
  242. struct sysinfo_t;
  243. int get_coreboot_info(struct sysinfo_t *info);
  244. #define CBMEM_TOC_RESERVED 512
  245. #define MAX_CBMEM_ENTRIES 16
  246. #define CBMEM_MAGIC 0x434f5245
  247. struct cbmem_entry {
  248. u32 magic;
  249. u32 id;
  250. u64 base;
  251. u64 size;
  252. } __packed;
  253. #define CBMEM_ID_FREESPACE 0x46524545
  254. #define CBMEM_ID_GDT 0x4c474454
  255. #define CBMEM_ID_ACPI 0x41435049
  256. #define CBMEM_ID_CBTABLE 0x43425442
  257. #define CBMEM_ID_PIRQ 0x49525154
  258. #define CBMEM_ID_MPTABLE 0x534d5054
  259. #define CBMEM_ID_RESUME 0x5245534d
  260. #define CBMEM_ID_RESUME_SCRATCH 0x52455343
  261. #define CBMEM_ID_SMBIOS 0x534d4254
  262. #define CBMEM_ID_TIMESTAMP 0x54494d45
  263. #define CBMEM_ID_MRCDATA 0x4d524344
  264. #define CBMEM_ID_CONSOLE 0x434f4e53
  265. #define CBMEM_ID_NONE 0x00000000
  266. #endif