tables.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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_CMOS_OPTION_TABLE 0x00c8
  143. struct cb_cmos_option_table {
  144. u32 tag;
  145. u32 size;
  146. u32 header_length;
  147. };
  148. #define CB_TAG_OPTION 0x00c9
  149. #define CMOS_MAX_NAME_LENGTH 32
  150. struct cb_cmos_entries {
  151. u32 tag;
  152. u32 size;
  153. u32 bit;
  154. u32 length;
  155. u32 config;
  156. u32 config_id;
  157. u8 name[CMOS_MAX_NAME_LENGTH];
  158. };
  159. #define CB_TAG_OPTION_ENUM 0x00ca
  160. #define CMOS_MAX_TEXT_LENGTH 32
  161. struct cb_cmos_enums {
  162. u32 tag;
  163. u32 size;
  164. u32 config_id;
  165. u32 value;
  166. u8 text[CMOS_MAX_TEXT_LENGTH];
  167. };
  168. #define CB_TAG_OPTION_DEFAULTS 0x00cb
  169. #define CMOS_IMAGE_BUFFER_SIZE 128
  170. struct cb_cmos_defaults {
  171. u32 tag;
  172. u32 size;
  173. u32 name_length;
  174. u8 name[CMOS_MAX_NAME_LENGTH];
  175. u8 default_set[CMOS_IMAGE_BUFFER_SIZE];
  176. };
  177. #define CB_TAG_OPTION_CHECKSUM 0x00cc
  178. #define CHECKSUM_NONE 0
  179. #define CHECKSUM_PCBIOS 1
  180. struct cb_cmos_checksum {
  181. u32 tag;
  182. u32 size;
  183. u32 range_start;
  184. u32 range_end;
  185. u32 location;
  186. u32 type;
  187. };
  188. /* Helpful macros */
  189. #define MEM_RANGE_COUNT(_rec) \
  190. (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0]))
  191. #define MEM_RANGE_PTR(_rec, _idx) \
  192. (((u8 *) (_rec)) + sizeof(*(_rec)) \
  193. + (sizeof((_rec)->map[0]) * (_idx)))
  194. #define MB_VENDOR_STRING(_mb) \
  195. (((unsigned char *) ((_mb)->strings)) + (_mb)->vendor_idx)
  196. #define MB_PART_STRING(_mb) \
  197. (((unsigned char *) ((_mb)->strings)) + (_mb)->part_number_idx)
  198. #define UNPACK_CB64(_in) \
  199. ((((u64) _in.hi) << 32) | _in.lo)
  200. struct sysinfo_t;
  201. int get_coreboot_info(struct sysinfo_t *info);
  202. #endif