blob: 623a7036933cfb886278a5ec14ad2f4e483142a4 [file] [log] [blame]
Bin Meng721e9922015-10-12 05:23:41 -07001/*
2 * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
3 *
4 * Adapted from coreboot src/include/smbios.h
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
9#ifndef _SMBIOS_H_
10#define _SMBIOS_H_
11
12/* SMBIOS spec version implemented */
13#define SMBIOS_MAJOR_VER 3
14#define SMBIOS_MINOR_VER 0
15
16/* SMBIOS structure types */
17enum {
18 SMBIOS_BIOS_INFORMATION = 0,
19 SMBIOS_SYSTEM_INFORMATION = 1,
20 SMBIOS_BOARD_INFORMATION = 2,
21 SMBIOS_SYSTEM_ENCLOSURE = 3,
22 SMBIOS_PROCESSOR_INFORMATION = 4,
23 SMBIOS_CACHE_INFORMATION = 7,
24 SMBIOS_SYSTEM_SLOTS = 9,
25 SMBIOS_PHYS_MEMORY_ARRAY = 16,
26 SMBIOS_MEMORY_DEVICE = 17,
27 SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS = 19,
28 SMBIOS_SYSTEM_BOOT_INFORMATION = 32,
29 SMBIOS_END_OF_TABLE = 127
30};
31
32#define SMBIOS_INTERMEDIATE_OFFSET 16
33#define SMBIOS_STRUCT_EOS_BYTES 2
34
35struct __packed smbios_entry {
36 u8 anchor[4];
37 u8 checksum;
38 u8 length;
39 u8 major_ver;
40 u8 minor_ver;
41 u16 max_struct_size;
42 u8 entry_point_rev;
43 u8 formatted_area[5];
44 u8 intermediate_anchor[5];
45 u8 intermediate_checksum;
46 u16 struct_table_length;
47 u32 struct_table_address;
48 u16 struct_count;
49 u8 bcd_rev;
50};
51
52/* BIOS characteristics */
53#define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
54#define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
55#define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16)
56
57#define BIOS_CHARACTERISTICS_EXT1_ACPI (1 << 0)
58#define BIOS_CHARACTERISTICS_EXT2_TARGET (1 << 2)
59
60struct __packed smbios_type0 {
61 u8 type;
62 u8 length;
63 u16 handle;
64 u8 vendor;
65 u8 bios_ver;
66 u16 bios_start_segment;
67 u8 bios_release_date;
68 u8 bios_rom_size;
69 u64 bios_characteristics;
70 u8 bios_characteristics_ext1;
71 u8 bios_characteristics_ext2;
72 u8 bios_major_release;
73 u8 bios_minor_release;
74 u8 ec_major_release;
75 u8 ec_minor_release;
76 char eos[SMBIOS_STRUCT_EOS_BYTES];
77};
78
79struct __packed smbios_type1 {
80 u8 type;
81 u8 length;
82 u16 handle;
83 u8 manufacturer;
84 u8 product_name;
85 u8 version;
86 u8 serial_number;
87 u8 uuid[16];
88 u8 wakeup_type;
89 u8 sku_number;
90 u8 family;
91 char eos[SMBIOS_STRUCT_EOS_BYTES];
92};
93
94#define SMBIOS_BOARD_FEATURE_HOSTING (1 << 0)
95#define SMBIOS_BOARD_MOTHERBOARD 10
96
97struct __packed smbios_type2 {
98 u8 type;
99 u8 length;
100 u16 handle;
101 u8 manufacturer;
102 u8 product_name;
103 u8 version;
104 u8 serial_number;
105 u8 asset_tag_number;
106 u8 feature_flags;
107 u8 chassis_location;
108 u16 chassis_handle;
109 u8 board_type;
110 char eos[SMBIOS_STRUCT_EOS_BYTES];
111};
112
113#define SMBIOS_ENCLOSURE_DESKTOP 3
114#define SMBIOS_STATE_SAFE 3
115#define SMBIOS_SECURITY_NONE 3
116
117struct __packed smbios_type3 {
118 u8 type;
119 u8 length;
120 u16 handle;
121 u8 manufacturer;
122 u8 chassis_type;
123 u8 version;
124 u8 serial_number;
125 u8 asset_tag_number;
126 u8 bootup_state;
127 u8 power_supply_state;
128 u8 thermal_state;
129 u8 security_status;
130 u32 oem_defined;
131 u8 height;
132 u8 number_of_power_cords;
133 u8 element_count;
134 u8 element_record_length;
135 char eos[SMBIOS_STRUCT_EOS_BYTES];
136};
137
138#define SMBIOS_PROCESSOR_TYPE_CENTRAL 3
139#define SMBIOS_PROCESSOR_STATUS_ENABLED 1
140#define SMBIOS_PROCESSOR_UPGRADE_NONE 6
141
142struct __packed smbios_type4 {
143 u8 type;
144 u8 length;
145 u16 handle;
146 u8 socket_designation;
147 u8 processor_type;
148 u8 processor_family;
149 u8 processor_manufacturer;
150 u32 processor_id[2];
151 u8 processor_version;
152 u8 voltage;
153 u16 external_clock;
154 u16 max_speed;
155 u16 current_speed;
156 u8 status;
157 u8 processor_upgrade;
158 u16 l1_cache_handle;
159 u16 l2_cache_handle;
160 u16 l3_cache_handle;
161 u8 serial_number;
162 u8 asset_tag;
163 u8 part_number;
164 u8 core_count;
165 u8 core_enabled;
166 u8 thread_count;
167 u16 processor_characteristics;
168 u16 processor_family2;
169 u16 core_count2;
170 u16 core_enabled2;
171 u16 thread_count2;
172 char eos[SMBIOS_STRUCT_EOS_BYTES];
173};
174
175struct __packed smbios_type32 {
176 u8 type;
177 u8 length;
178 u16 handle;
179 u8 reserved[6];
180 u8 boot_status;
181 u8 eos[SMBIOS_STRUCT_EOS_BYTES];
182};
183
184struct __packed smbios_type127 {
185 u8 type;
186 u8 length;
187 u16 handle;
188 u8 eos[SMBIOS_STRUCT_EOS_BYTES];
189};
190
191struct __packed smbios_header {
192 u8 type;
193 u8 length;
194 u16 handle;
195};
196
197/**
198 * fill_smbios_header() - Fill the header of an SMBIOS table
199 *
200 * This fills the header of an SMBIOS table structure.
201 *
202 * @table: start address of the structure
203 * @type: the type of structure
204 * @length: the length of the formatted area of the structure
205 * @handle: the structure's handle, a unique 16-bit number
206 */
207static inline void fill_smbios_header(void *table, int type,
208 int length, int handle)
209{
210 struct smbios_header *header = table;
211
212 header->type = type;
213 header->length = length - SMBIOS_STRUCT_EOS_BYTES;
214 header->handle = handle;
215}
216
217/**
218 * Function prototype to write a specific type of SMBIOS structure
219 *
220 * @addr: start address to write the structure
221 * @handle: the structure's handle, a unique 16-bit number
222 * @return: size of the structure
223 */
224typedef int (*smbios_write_type)(u32 *addr, int handle);
225
226/**
227 * write_smbios_table() - Write SMBIOS table
228 *
229 * This writes SMBIOS table at a given address.
230 *
231 * @addr: start address to write SMBIOS table
232 * @return: end address of SMBIOS table
233 */
234u32 write_smbios_table(u32 addr);
235
236#endif /* _SMBIOS_H_ */