| 1 |
/* |
| 2 |
* This file is part of the coreboot project. |
| 3 |
* |
| 4 |
* Copyright (C) 2002 Linux Networx |
| 5 |
* (Written by Eric Biederman <[email protected]> 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. |
| 16 |
*/ |
| 17 |
|
| 18 |
#ifndef COREBOOT_TABLES_H |
| 19 |
#define COREBOOT_TABLES_H |
| 20 |
|
| 21 |
#include <stdint.h> |
| 22 |
|
| 23 |
/* The coreboot table information is for conveying information |
| 24 |
* from the firmware to the loaded OS image. Primarily this |
| 25 |
* is expected to be information that cannot be discovered by |
| 26 |
* other means, such as querying the hardware directly. |
| 27 |
* |
| 28 |
* All of the information should be Position Independent Data. |
| 29 |
* That is it should be safe to relocated any of the information |
| 30 |
* without it's meaning/correctness changing. For table that |
| 31 |
* 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 |
| 47 |
* dropped. Of course it is polite and expedite to include extra |
| 48 |
* table entries and be backwards compatible, but it is not required. |
| 49 |
*/ |
| 50 |
|
| 51 |
/* 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, |
| 54 |
* breaking the table format. |
| 55 |
* |
| 56 |
* lb_uint64 will keep 64bit coreboot table values aligned to 32bit |
| 57 |
* 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 |
|
| 63 |
struct lb_uint64 { |
| 64 |
uint32_t lo; |
| 65 |
uint32_t hi; |
| 66 |
}; |
| 67 |
|
| 68 |
struct lb_header { |
| 69 |
uint8_t signature[4]; /* LBIO */ |
| 70 |
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 |
|
| 77 |
/* Every entry in the boot environment list will correspond to a boot |
| 78 |
* 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 |
| 80 |
* boot environment record if you don't know what it easy. This allows |
| 81 |
* forward compatibility with records not yet defined. |
| 82 |
*/ |
| 83 |
struct 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 |
|
| 92 |
struct 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 |
|
| 101 |
struct 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 |
| 108 |
struct lb_hwrpb { |
| 109 |
uint32_t tag; |
| 110 |
uint32_t size; |
| 111 |
uint64_t hwrpb; |
| 112 |
}; |
| 113 |
|
| 114 |
#define LB_TAG_MAINBOARD 0x0003 |
| 115 |
struct lb_mainboard { |
| 116 |
uint32_t tag; |
| 117 |
uint32_t size; |
| 118 |
uint8_t vendor_idx; |
| 119 |
uint8_t part_number_idx; |
| 120 |
uint8_t strings[0]; |
| 121 |
}; |
| 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 |
| 133 |
struct lb_string { |
| 134 |
uint32_t tag; |
| 135 |
uint32_t size; |
| 136 |
uint8_t string[0]; |
| 137 |
}; |
| 138 |
|
| 139 |
#define LB_TAG_FORWARD 0x0011 |
| 140 |
struct lb_forward { |
| 141 |
uint32_t tag; |
| 142 |
uint32_t size; |
| 143 |
uint64_t forward; |
| 144 |
}; |
| 145 |
|
| 146 |
#endif /* COREBOOT_TABLES_H */ |