Coreboot.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /** @file
  2. Coreboot PEI module include file.
  3. Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. /*
  7. * This file is part of the libpayload project.
  8. *
  9. * Copyright (C) 2008 Advanced Micro Devices, Inc.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. * 3. The name of the author may not be used to endorse or promote products
  20. * derived from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  23. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. */
  34. #ifndef _COREBOOT_PEI_H_INCLUDED_
  35. #define _COREBOOT_PEI_H_INCLUDED_
  36. #if defined(_MSC_VER)
  37. #pragma warning( disable : 4200 )
  38. #endif
  39. #define DYN_CBMEM_ALIGN_SIZE (4096)
  40. #define IMD_ENTRY_MAGIC (~0xC0389481)
  41. #define CBMEM_ENTRY_MAGIC (~0xC0389479)
  42. struct cbmem_entry {
  43. UINT32 magic;
  44. UINT32 start;
  45. UINT32 size;
  46. UINT32 id;
  47. };
  48. struct cbmem_root {
  49. UINT32 max_entries;
  50. UINT32 num_entries;
  51. UINT32 locked;
  52. UINT32 size;
  53. struct cbmem_entry entries[0];
  54. };
  55. struct imd_entry {
  56. UINT32 magic;
  57. UINT32 start_offset;
  58. UINT32 size;
  59. UINT32 id;
  60. };
  61. struct imd_root {
  62. UINT32 max_entries;
  63. UINT32 num_entries;
  64. UINT32 flags;
  65. UINT32 entry_align;
  66. UINT32 max_offset;
  67. struct imd_entry entries[0];
  68. };
  69. struct cbuint64 {
  70. UINT32 lo;
  71. UINT32 hi;
  72. };
  73. #define CB_HEADER_SIGNATURE 0x4F49424C
  74. struct cb_header {
  75. UINT32 signature;
  76. UINT32 header_bytes;
  77. UINT32 header_checksum;
  78. UINT32 table_bytes;
  79. UINT32 table_checksum;
  80. UINT32 table_entries;
  81. };
  82. struct cb_record {
  83. UINT32 tag;
  84. UINT32 size;
  85. };
  86. #define CB_TAG_UNUSED 0x0000
  87. #define CB_TAG_MEMORY 0x0001
  88. struct cb_memory_range {
  89. struct cbuint64 start;
  90. struct cbuint64 size;
  91. UINT32 type;
  92. };
  93. #define CB_MEM_RAM 1
  94. #define CB_MEM_RESERVED 2
  95. #define CB_MEM_ACPI 3
  96. #define CB_MEM_NVS 4
  97. #define CB_MEM_UNUSABLE 5
  98. #define CB_MEM_VENDOR_RSVD 6
  99. #define CB_MEM_TABLE 16
  100. struct cb_memory {
  101. UINT32 tag;
  102. UINT32 size;
  103. struct cb_memory_range map[0];
  104. };
  105. #define CB_TAG_MAINBOARD 0x0003
  106. struct cb_mainboard {
  107. UINT32 tag;
  108. UINT32 size;
  109. UINT8 vendor_idx;
  110. UINT8 part_number_idx;
  111. UINT8 strings[0];
  112. };
  113. #define CB_TAG_VERSION 0x0004
  114. #define CB_TAG_EXTRA_VERSION 0x0005
  115. #define CB_TAG_BUILD 0x0006
  116. #define CB_TAG_COMPILE_TIME 0x0007
  117. #define CB_TAG_COMPILE_BY 0x0008
  118. #define CB_TAG_COMPILE_HOST 0x0009
  119. #define CB_TAG_COMPILE_DOMAIN 0x000a
  120. #define CB_TAG_COMPILER 0x000b
  121. #define CB_TAG_LINKER 0x000c
  122. #define CB_TAG_ASSEMBLER 0x000d
  123. struct cb_string {
  124. UINT32 tag;
  125. UINT32 size;
  126. UINT8 string[0];
  127. };
  128. #define CB_TAG_SERIAL 0x000f
  129. struct cb_serial {
  130. UINT32 tag;
  131. UINT32 size;
  132. #define CB_SERIAL_TYPE_IO_MAPPED 1
  133. #define CB_SERIAL_TYPE_MEMORY_MAPPED 2
  134. UINT32 type;
  135. UINT32 baseaddr;
  136. UINT32 baud;
  137. UINT32 regwidth;
  138. // Crystal or input frequency to the chip containing the UART.
  139. // Provide the board specific details to allow the payload to
  140. // initialize the chip containing the UART and make independent
  141. // decisions as to which dividers to select and their values
  142. // to eventually arrive at the desired console baud-rate.
  143. UINT32 input_hertz;
  144. // UART PCI address: bus, device, function
  145. // 1 << 31 - Valid bit, PCI UART in use
  146. // Bus << 20
  147. // Device << 15
  148. // Function << 12
  149. UINT32 uart_pci_addr;
  150. };
  151. #define CB_TAG_CONSOLE 0x00010
  152. struct cb_console {
  153. UINT32 tag;
  154. UINT32 size;
  155. UINT16 type;
  156. };
  157. #define CB_TAG_CONSOLE_SERIAL8250 0
  158. #define CB_TAG_CONSOLE_VGA 1 // OBSOLETE
  159. #define CB_TAG_CONSOLE_BTEXT 2 // OBSOLETE
  160. #define CB_TAG_CONSOLE_LOGBUF 3
  161. #define CB_TAG_CONSOLE_SROM 4 // OBSOLETE
  162. #define CB_TAG_CONSOLE_EHCI 5
  163. #define CB_TAG_FORWARD 0x00011
  164. struct cb_forward {
  165. UINT32 tag;
  166. UINT32 size;
  167. UINT64 forward;
  168. };
  169. #define CB_TAG_FRAMEBUFFER 0x0012
  170. struct cb_framebuffer {
  171. UINT32 tag;
  172. UINT32 size;
  173. UINT64 physical_address;
  174. UINT32 x_resolution;
  175. UINT32 y_resolution;
  176. UINT32 bytes_per_line;
  177. UINT8 bits_per_pixel;
  178. UINT8 red_mask_pos;
  179. UINT8 red_mask_size;
  180. UINT8 green_mask_pos;
  181. UINT8 green_mask_size;
  182. UINT8 blue_mask_pos;
  183. UINT8 blue_mask_size;
  184. UINT8 reserved_mask_pos;
  185. UINT8 reserved_mask_size;
  186. };
  187. #define CB_TAG_VDAT 0x0015
  188. struct cb_vdat {
  189. UINT32 tag;
  190. UINT32 size; /* size of the entire entry */
  191. UINT64 vdat_addr;
  192. UINT32 vdat_size;
  193. };
  194. #define CB_TAG_TIMESTAMPS 0x0016
  195. #define CB_TAG_CBMEM_CONSOLE 0x0017
  196. #define CB_TAG_MRC_CACHE 0x0018
  197. struct cb_cbmem_tab {
  198. UINT32 tag;
  199. UINT32 size;
  200. UINT64 cbmem_tab;
  201. };
  202. /* Helpful macros */
  203. #define MEM_RANGE_COUNT(_rec) \
  204. (((_rec)->size - sizeof(*(_rec))) / sizeof((_rec)->map[0]))
  205. #define MEM_RANGE_PTR(_rec, _idx) \
  206. (void *)(((UINT8 *) (_rec)) + sizeof(*(_rec)) \
  207. + (sizeof((_rec)->map[0]) * (_idx)))
  208. #endif // _COREBOOT_PEI_H_INCLUDED_