blob: e1f63a81d0c51a884d0a36786b1bdf5ee551de3e [file] [log] [blame]
Uwe Hermannf78cff12009-06-12 14:05:25 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2002 Linux Networx
5 * (Written by Eric Biederman <ebiederman@lnxi.com> for Linux Networx)
6 * Copyright (C) 2005-2007 coresystems GmbH
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Uwe Hermannf78cff12009-06-12 14:05:25 +000016 */
17
Stefan Reinauere3f3e2e2008-01-18 15:33:10 +000018#ifndef COREBOOT_TABLES_H
19#define COREBOOT_TABLES_H
Uwe Hermannce1041c2007-02-06 19:53:51 +000020
21#include <stdint.h>
22
Stefan Reinauere3f3e2e2008-01-18 15:33:10 +000023/* The coreboot table information is for conveying information
Uwe Hermannce1041c2007-02-06 19:53:51 +000024 * from the firmware to the loaded OS image. Primarily this
25 * is expected to be information that cannot be discovered by
Uwe Hermann4e3d0b32010-03-25 23:18:41 +000026 * other means, such as querying the hardware directly.
Uwe Hermannce1041c2007-02-06 19:53:51 +000027 *
Elyes HAOUAS124ef382018-03-27 12:15:09 +020028 * All of the information should be Position Independent Data.
Uwe Hermannce1041c2007-02-06 19:53:51 +000029 * That is it should be safe to relocated any of the information
Uwe Hermann4e3d0b32010-03-25 23:18:41 +000030 * without it's meaning/correctness changing. For table that
Uwe Hermannce1041c2007-02-06 19:53:51 +000031 * can reasonably be used on multiple architectures the data
32 * size should be fixed. This should ease the transition between
33 * 32 bit and 64 bit architectures etc.
34 *
35 * The completeness test for the information in this table is:
36 * - Can all of the hardware be detected?
37 * - Are the per motherboard constants available?
38 * - Is there enough to allow a kernel to run that was written before
39 * a particular motherboard is constructed? (Assuming the kernel
40 * has drivers for all of the hardware but it does not have
41 * assumptions on how the hardware is connected together).
42 *
43 * With this test it should be straight forward to determine if a
44 * table entry is required or not. This should remove much of the
45 * long term compatibility burden as table entries which are
46 * irrelevant or have been replaced by better alternatives may be
Uwe Hermann4e3d0b32010-03-25 23:18:41 +000047 * dropped. Of course it is polite and expedite to include extra
Uwe Hermannce1041c2007-02-06 19:53:51 +000048 * table entries and be backwards compatible, but it is not required.
49 */
50
Elyes HAOUAS124ef382018-03-27 12:15:09 +020051/* Since coreboot is usually compiled 32bit, gcc will align 64bit
52 * types to 32bit boundaries. If the coreboot table is dumped on a
53 * 64bit system, a uint64_t would be aligned to 64bit boundaries,
Uwe Hermannce1041c2007-02-06 19:53:51 +000054 * breaking the table format.
55 *
Stefan Reinauere3f3e2e2008-01-18 15:33:10 +000056 * lb_uint64 will keep 64bit coreboot table values aligned to 32bit
Uwe Hermannce1041c2007-02-06 19:53:51 +000057 * to ensure compatibility. They can be accessed with the two functions
58 * below: unpack_lb64() and pack_lb64()
59 *
60 * See also: util/lbtdump/lbtdump.c
61 */
62
63struct lb_uint64 {
64 uint32_t lo;
65 uint32_t hi;
66};
67
Uwe Hermanna7e05482007-05-09 10:17:44 +000068struct lb_header {
69 uint8_t signature[4]; /* LBIO */
Uwe Hermannce1041c2007-02-06 19:53:51 +000070 uint32_t header_bytes;
71 uint32_t header_checksum;
72 uint32_t table_bytes;
73 uint32_t table_checksum;
74 uint32_t table_entries;
75};
76
Uwe Hermann4e3d0b32010-03-25 23:18:41 +000077/* Every entry in the boot environment list will correspond to a boot
Uwe Hermannce1041c2007-02-06 19:53:51 +000078 * info record. Encoding both type and size. The type is obviously
79 * so you can tell what it is. The size allows you to skip that
Uwe Hermann4e3d0b32010-03-25 23:18:41 +000080 * boot environment record if you don't know what it easy. This allows
Uwe Hermannce1041c2007-02-06 19:53:51 +000081 * forward compatibility with records not yet defined.
82 */
83struct lb_record {
84 uint32_t tag; /* tag ID */
85 uint32_t size; /* size of record (in bytes) */
86};
87
88#define LB_TAG_UNUSED 0x0000
89
90#define LB_TAG_MEMORY 0x0001
91
92struct lb_memory_range {
93 struct lb_uint64 start;
94 struct lb_uint64 size;
95 uint32_t type;
96#define LB_MEM_RAM 1 /* Memory anyone can use */
97#define LB_MEM_RESERVED 2 /* Don't use this memory region */
98#define LB_MEM_TABLE 16 /* Ram configuration tables are kept in */
99};
100
101struct lb_memory {
102 uint32_t tag;
103 uint32_t size;
104 struct lb_memory_range map[0];
105};
106
107#define LB_TAG_HWRPB 0x0002
108struct lb_hwrpb {
109 uint32_t tag;
110 uint32_t size;
111 uint64_t hwrpb;
112};
113
114#define LB_TAG_MAINBOARD 0x0003
115struct lb_mainboard {
116 uint32_t tag;
117 uint32_t size;
Uwe Hermanna7e05482007-05-09 10:17:44 +0000118 uint8_t vendor_idx;
119 uint8_t part_number_idx;
120 uint8_t strings[0];
Uwe Hermannce1041c2007-02-06 19:53:51 +0000121};
122
123#define LB_TAG_VERSION 0x0004
124#define LB_TAG_EXTRA_VERSION 0x0005
125#define LB_TAG_BUILD 0x0006
126#define LB_TAG_COMPILE_TIME 0x0007
127#define LB_TAG_COMPILE_BY 0x0008
128#define LB_TAG_COMPILE_HOST 0x0009
129#define LB_TAG_COMPILE_DOMAIN 0x000a
130#define LB_TAG_COMPILER 0x000b
131#define LB_TAG_LINKER 0x000c
132#define LB_TAG_ASSEMBLER 0x000d
133struct lb_string {
134 uint32_t tag;
135 uint32_t size;
Uwe Hermanna7e05482007-05-09 10:17:44 +0000136 uint8_t string[0];
Uwe Hermannce1041c2007-02-06 19:53:51 +0000137};
138
Stefan Reinauer2d853bb2009-03-17 14:39:25 +0000139#define LB_TAG_FORWARD 0x0011
140struct lb_forward {
141 uint32_t tag;
142 uint32_t size;
143 uint64_t forward;
144};
145
Stefan Reinauere3f3e2e2008-01-18 15:33:10 +0000146#endif /* COREBOOT_TABLES_H */