cbfs_core.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * This file is part of the coreboot project.
  3. *
  4. * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
  5. * Copyright (C) 2012 Google, Inc.
  6. * Copyright (C) 2013 The Chromium OS Authors. All rights reserved.
  7. *
  8. * This file is dual-licensed. You can choose between:
  9. * - The GNU GPL, version 2, as published by the Free Software Foundation
  10. * - The revised BSD license (without advertising clause)
  11. *
  12. * ---------------------------------------------------------------------------
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; version 2 of the License.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
  25. * ---------------------------------------------------------------------------
  26. * Redistribution and use in source and binary forms, with or without
  27. * modification, are permitted provided that the following conditions
  28. * are met:
  29. * 1. Redistributions of source code must retain the above copyright
  30. * notice, this list of conditions and the following disclaimer.
  31. * 2. Redistributions in binary form must reproduce the above copyright
  32. * notice, this list of conditions and the following disclaimer in the
  33. * documentation and/or other materials provided with the distribution.
  34. * 3. The name of the author may not be used to endorse or promote products
  35. * derived from this software without specific prior written permission.
  36. *
  37. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  38. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  39. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  41. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  42. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  43. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  44. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  45. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  46. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  47. * SUCH DAMAGE.
  48. * ---------------------------------------------------------------------------
  49. */
  50. #ifndef _CBFS_CORE_H_
  51. #define _CBFS_CORE_H_
  52. #include <grub/types.h>
  53. /** These are standard values for the known compression
  54. alogrithms that coreboot knows about for stages and
  55. payloads. Of course, other CBFS users can use whatever
  56. values they want, as long as they understand them. */
  57. #define CBFS_COMPRESS_NONE 0
  58. #define CBFS_COMPRESS_LZMA 1
  59. /** These are standard component types for well known
  60. components (i.e - those that coreboot needs to consume.
  61. Users are welcome to use any other value for their
  62. components */
  63. #define CBFS_TYPE_STAGE 0x10
  64. #define CBFS_TYPE_PAYLOAD 0x20
  65. #define CBFS_TYPE_OPTIONROM 0x30
  66. #define CBFS_TYPE_BOOTSPLASH 0x40
  67. #define CBFS_TYPE_RAW 0x50
  68. #define CBFS_TYPE_VSA 0x51
  69. #define CBFS_TYPE_MBI 0x52
  70. #define CBFS_TYPE_MICROCODE 0x53
  71. #define CBFS_COMPONENT_CMOS_DEFAULT 0xaa
  72. #define CBFS_COMPONENT_CMOS_LAYOUT 0x01aa
  73. #define CBFS_HEADER_MAGIC 0x4F524243
  74. #define CBFS_HEADER_VERSION1 0x31313131
  75. #define CBFS_HEADER_VERSION2 0x31313132
  76. #define CBFS_HEADER_VERSION CBFS_HEADER_VERSION2
  77. #define CBFS_HEADER_INVALID_ADDRESS ((void*)(0xffffffff))
  78. /** this is the master cbfs header - it need to be located somewhere available
  79. to bootblock (to load romstage). Where it actually lives is up to coreboot.
  80. On x86, a pointer to this header will live at 0xFFFFFFFC.
  81. For other platforms, you need to define CONFIG_CBFS_HEADER_ROM_OFFSET */
  82. struct cbfs_header {
  83. grub_uint32_t magic;
  84. grub_uint32_t version;
  85. grub_uint32_t romsize;
  86. grub_uint32_t bootblocksize;
  87. grub_uint32_t align;
  88. grub_uint32_t offset;
  89. grub_uint32_t architecture;
  90. grub_uint32_t pad[1];
  91. } GRUB_PACKED;
  92. /* "Unknown" refers to CBFS headers version 1,
  93. * before the architecture was defined (i.e., x86 only).
  94. */
  95. #define CBFS_ARCHITECTURE_UNKNOWN 0xFFFFFFFF
  96. #define CBFS_ARCHITECTURE_X86 0x00000001
  97. #define CBFS_ARCHITECTURE_ARMV7 0x00000010
  98. /** This is a component header - every entry in the CBFS
  99. will have this header.
  100. This is how the component is arranged in the ROM:
  101. -------------- <- 0
  102. component header
  103. -------------- <- sizeof(struct component)
  104. component name
  105. -------------- <- offset
  106. data
  107. ...
  108. -------------- <- offset + len
  109. */
  110. #define CBFS_FILE_MAGIC "LARCHIVE"
  111. struct cbfs_file {
  112. char magic[8];
  113. grub_uint32_t len;
  114. grub_uint32_t type;
  115. grub_uint32_t checksum;
  116. grub_uint32_t offset;
  117. } GRUB_PACKED;
  118. /*** Component sub-headers ***/
  119. /* Following are component sub-headers for the "standard"
  120. component types */
  121. /** This is the sub-header for stage components. Stages are
  122. loaded by coreboot during the normal boot process */
  123. struct cbfs_stage {
  124. grub_uint32_t compression; /** Compression type */
  125. grub_uint64_t entry; /** entry point */
  126. grub_uint64_t load; /** Where to load in memory */
  127. grub_uint32_t len; /** length of data to load */
  128. grub_uint32_t memlen; /** total length of object in memory */
  129. } GRUB_PACKED;
  130. /** this is the sub-header for payload components. Payloads
  131. are loaded by coreboot at the end of the boot process */
  132. struct cbfs_payload_segment {
  133. grub_uint32_t type;
  134. grub_uint32_t compression;
  135. grub_uint32_t offset;
  136. grub_uint64_t load_addr;
  137. grub_uint32_t len;
  138. grub_uint32_t mem_len;
  139. } GRUB_PACKED;
  140. struct cbfs_payload {
  141. struct cbfs_payload_segment segments;
  142. };
  143. #define PAYLOAD_SEGMENT_CODE 0x45444F43
  144. #define PAYLOAD_SEGMENT_DATA 0x41544144
  145. #define PAYLOAD_SEGMENT_BSS 0x20535342
  146. #define PAYLOAD_SEGMENT_PARAMS 0x41524150
  147. #define PAYLOAD_SEGMENT_ENTRY 0x52544E45
  148. struct cbfs_optionrom {
  149. grub_uint32_t compression;
  150. grub_uint32_t len;
  151. } GRUB_PACKED;
  152. #endif