SMBIOS/SCONFIG: Allow devtree-defined Type 41 entries

Introduce the `smbios_dev_info` devicetree keyword to specify the
instance ID and RefDes (Reference Designation) of onboard devices.

Example syntax:

 device pci 1c.0 on	# PCIe Port #1
 	device pci 00.0 on
 		smbios_dev_info 6
 	end
 end
 device pci 1c.1 on	# PCIe Port #2
 	device pci 00.0 on
 		smbios_dev_info 42 "PCIe-PCI Time Machine"
 	end
 end

The `SMBIOS_TYPE41_PROVIDED_BY_DEVTREE` Kconfig option enables using
this syntax to control the generated Type 41 entries. When this option
is enabled, Type 41 entries are only autogenerated for devices with a
defined instance ID. This avoids having to keep track of which instance
IDs have been used for every device class.

Using `smbios_dev_info` when `SMBIOS_TYPE41_PROVIDED_BY_DEVTREE` is not
enabled will result in a build-time error, as the syntax is meaningless
in this case. This is done with preprocessor guards around the Type 41
members in `struct device` and the code which uses the guarded members.
Although the preprocessor usage isn't particularly elegant, adjusting
the devicetree syntax and/or grammar depending on a Kconfig option is
probably even worse.

Change-Id: Iecca9ada6ee1000674cb5dd7afd5c309d8e1a64b
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57370
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Angel Pons
2021-09-03 16:51:40 +02:00
committed by Patrick Georgi
parent bb03e763de
commit 437da71d0a
10 changed files with 492 additions and 386 deletions

View File

@@ -349,8 +349,8 @@ static void yynoreturn yy_fatal_error ( const char* msg );
(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;
#define YY_NUM_RULES 49
#define YY_END_OF_BUFFER 50
#define YY_NUM_RULES 50
#define YY_END_OF_BUFFER 51
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -358,31 +358,31 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const flex_int16_t yy_accept[202] =
static const flex_int16_t yy_accept[210] =
{ 0,
0, 0, 50, 48, 1, 3, 48, 48, 48, 43,
43, 40, 44, 48, 44, 44, 44, 44, 44, 48,
48, 48, 48, 48, 48, 48, 48, 48, 48, 41,
48, 1, 3, 48, 0, 48, 48, 0, 2, 43,
44, 48, 48, 48, 9, 48, 48, 44, 48, 48,
48, 48, 48, 48, 48, 48, 48, 48, 34, 48,
48, 48, 48, 48, 15, 48, 48, 48, 48, 48,
48, 48, 48, 48, 47, 47, 48, 0, 42, 48,
48, 48, 25, 48, 48, 33, 38, 48, 48, 48,
48, 48, 22, 48, 48, 32, 48, 48, 48, 16,
0, 0, 51, 49, 1, 3, 49, 49, 49, 44,
44, 41, 45, 49, 45, 45, 45, 45, 45, 49,
49, 49, 49, 49, 49, 49, 49, 49, 49, 42,
49, 1, 3, 49, 0, 49, 49, 0, 2, 44,
45, 49, 49, 49, 9, 49, 49, 45, 49, 49,
49, 49, 49, 49, 49, 49, 49, 49, 34, 49,
49, 49, 49, 49, 15, 49, 49, 49, 49, 49,
49, 49, 49, 49, 48, 48, 49, 0, 43, 49,
49, 49, 25, 49, 49, 33, 38, 49, 49, 49,
49, 49, 22, 49, 49, 32, 49, 49, 49, 16,
48, 19, 21, 48, 8, 48, 48, 29, 48, 30,
7, 48, 0, 45, 48, 4, 48, 48, 48, 48,
48, 48, 31, 48, 48, 48, 48, 48, 28, 48,
48, 48, 48, 48, 46, 46, 6, 48, 48, 48,
12, 48, 48, 48, 48, 48, 23, 48, 48, 14,
48, 48, 48, 48, 5, 26, 48, 48, 17, 48,
20, 48, 13, 48, 48, 48, 48, 48, 27, 36,
48, 48, 48, 48, 48, 48, 48, 48, 48, 10,
48, 48, 48, 11, 48, 18, 48, 48, 48, 35,
48, 48, 24, 48, 37, 48, 48, 48, 48, 39,
49, 19, 21, 49, 8, 49, 49, 29, 49, 30,
7, 49, 0, 46, 49, 4, 49, 49, 49, 49,
49, 49, 31, 49, 49, 49, 49, 49, 28, 49,
49, 49, 49, 49, 47, 47, 6, 49, 49, 49,
12, 49, 49, 49, 49, 49, 23, 49, 49, 14,
49, 49, 49, 49, 5, 26, 49, 49, 17, 49,
20, 49, 13, 49, 49, 49, 49, 49, 27, 36,
49, 49, 49, 49, 49, 49, 49, 49, 49, 10,
49, 49, 49, 49, 11, 49, 18, 49, 49, 49,
49, 35, 49, 49, 49, 24, 49, 49, 37, 49,
0
49, 49, 49, 49, 49, 40, 49, 39, 0
} ;
static const YY_CHAR yy_ec[256] =
@@ -425,136 +425,140 @@ static const YY_CHAR yy_meta[41] =
1, 1, 1, 1, 1, 1, 1, 1, 1, 1
} ;
static const flex_int16_t yy_base[209] =
static const flex_int16_t yy_base[217] =
{ 0,
0, 0, 274, 0, 271, 275, 269, 39, 43, 40,
233, 0, 46, 256, 56, 60, 64, 67, 72, 56,
244, 74, 251, 39, 70, 59, 246, 77, 233, 0,
0, 263, 275, 108, 259, 112, 116, 260, 275, 0,
113, 116, 247, 236, 0, 235, 224, 122, 231, 226,
236, 234, 238, 225, 227, 231, 231, 225, 231, 216,
216, 217, 219, 221, 0, 208, 216, 210, 210, 117,
220, 212, 218, 87, 0, 275, 139, 230, 0, 223,
216, 202, 215, 205, 212, 0, 0, 202, 208, 205,
196, 204, 0, 202, 192, 0, 196, 200, 190, 0,
0, 0, 282, 0, 279, 283, 277, 39, 43, 40,
241, 0, 46, 264, 56, 60, 64, 67, 72, 56,
252, 74, 259, 39, 70, 59, 254, 77, 241, 0,
0, 271, 283, 108, 267, 112, 116, 268, 283, 0,
113, 116, 255, 244, 0, 243, 232, 122, 239, 234,
244, 242, 246, 233, 235, 239, 239, 233, 239, 224,
224, 225, 227, 229, 0, 216, 224, 218, 218, 117,
228, 220, 226, 87, 0, 283, 139, 238, 0, 231,
224, 210, 223, 213, 220, 0, 0, 210, 216, 213,
204, 212, 0, 210, 200, 0, 204, 208, 198, 0,
193, 0, 0, 199, 0, 191, 190, 0, 181, 0,
0, 208, 207, 0, 178, 0, 191, 190, 183, 187,
177, 173, 0, 183, 171, 177, 182, 183, 0, 170,
177, 164, 167, 156, 0, 275, 0, 168, 172, 164,
0, 163, 165, 161, 163, 168, 0, 152, 157, 0,
150, 150, 149, 146, 0, 0, 158, 160, 0, 144,
161, 147, 0, 154, 158, 139, 139, 146, 0, 0,
132, 124, 123, 121, 132, 118, 128, 118, 110, 0,
122, 120, 125, 0, 114, 0, 114, 107, 94, 0,
82, 81, 0, 83, 0, 74, 67, 37, 31, 0,
201, 0, 0, 207, 0, 199, 198, 0, 189, 0,
0, 216, 215, 0, 186, 0, 199, 198, 191, 195,
185, 181, 0, 191, 179, 185, 190, 191, 0, 178,
185, 172, 175, 164, 0, 283, 0, 176, 180, 172,
0, 171, 173, 169, 171, 176, 0, 160, 165, 0,
158, 158, 157, 154, 0, 0, 166, 168, 0, 152,
169, 155, 0, 162, 166, 147, 147, 154, 0, 0,
153, 145, 144, 68, 154, 140, 150, 140, 132, 0,
136, 130, 128, 133, 0, 122, 0, 116, 122, 125,
117, 0, 132, 113, 126, 0, 120, 127, 0, 104,
275, 42, 158, 160, 162, 164, 166, 168
106, 94, 78, 65, 37, 0, 31, 0, 283, 42,
158, 160, 162, 164, 166, 168
} ;
static const flex_int16_t yy_def[209] =
static const flex_int16_t yy_def[217] =
{ 0,
201, 1, 201, 202, 201, 201, 202, 203, 204, 202,
10, 202, 10, 202, 10, 10, 10, 10, 10, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 201, 201, 203, 205, 206, 204, 207, 201, 10,
10, 10, 202, 202, 202, 202, 202, 10, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 201, 206, 208, 42, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
209, 1, 209, 210, 209, 209, 210, 211, 212, 210,
10, 210, 10, 210, 10, 10, 10, 10, 10, 210,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
210, 209, 209, 211, 213, 214, 212, 215, 209, 10,
10, 10, 210, 210, 210, 210, 210, 10, 210, 210,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
210, 210, 210, 210, 210, 209, 214, 216, 42, 210,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 201, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 201, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
210, 210, 209, 210, 210, 210, 210, 210, 210, 210,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
210, 210, 210, 210, 210, 209, 210, 210, 210, 210,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
0, 201, 201, 201, 201, 201, 201, 201
210, 210, 210, 210, 210, 210, 210, 210, 0, 209,
209, 209, 209, 209, 209, 209
} ;
static const flex_int16_t yy_nxt[316] =
static const flex_int16_t yy_nxt[324] =
{ 0,
4, 5, 6, 7, 8, 9, 10, 11, 10, 12,
13, 13, 14, 4, 4, 4, 15, 13, 16, 17,
18, 19, 20, 21, 22, 23, 24, 4, 25, 26,
4, 27, 28, 4, 29, 4, 4, 4, 4, 30,
35, 35, 31, 36, 38, 39, 40, 40, 40, 200,
35, 35, 31, 36, 38, 39, 40, 40, 40, 208,
41, 41, 41, 41, 41, 62, 41, 41, 41, 41,
41, 41, 41, 41, 41, 63, 41, 41, 41, 199,
41, 41, 41, 41, 41, 63, 41, 41, 41, 207,
41, 41, 41, 41, 41, 41, 54, 67, 41, 41,
41, 44, 57, 46, 48, 55, 68, 198, 45, 47,
69, 64, 49, 197, 51, 50, 52, 65, 196, 66,
41, 44, 57, 46, 48, 55, 68, 181, 45, 47,
69, 64, 49, 206, 51, 50, 52, 65, 205, 66,
195, 58, 59, 71, 110, 60, 72, 111, 53, 35,
35, 73, 75, 78, 78, 194, 31, 38, 39, 41,
41, 41, 79, 79, 79, 193, 79, 79, 41, 41,
41, 192, 79, 79, 79, 79, 79, 79, 105, 106,
78, 78, 191, 112, 190, 189, 188, 187, 186, 185,
184, 183, 182, 181, 180, 179, 178, 84, 34, 34,
182, 58, 59, 71, 110, 60, 72, 111, 53, 35,
35, 73, 75, 78, 78, 204, 31, 38, 39, 41,
41, 41, 79, 79, 79, 203, 79, 79, 41, 41,
41, 202, 79, 79, 79, 79, 79, 79, 105, 106,
78, 78, 201, 112, 200, 199, 198, 197, 196, 195,
194, 193, 192, 191, 190, 189, 188, 84, 34, 34,
37, 37, 35, 35, 77, 77, 38, 38, 78, 78,
177, 176, 175, 174, 173, 172, 171, 170, 169, 168,
167, 166, 165, 164, 163, 162, 161, 160, 159, 158,
157, 156, 155, 154, 153, 152, 151, 150, 149, 148,
187, 186, 185, 184, 183, 180, 179, 178, 177, 176,
175, 174, 173, 172, 171, 170, 169, 168, 167, 166,
165, 164, 163, 162, 161, 160, 159, 158, 157, 156,
147, 146, 145, 144, 143, 142, 141, 140, 139, 138,
137, 136, 135, 134, 133, 132, 131, 130, 129, 128,
127, 126, 125, 124, 123, 122, 121, 120, 119, 118,
117, 116, 115, 114, 113, 109, 108, 107, 104, 103,
102, 101, 100, 99, 98, 97, 96, 95, 94, 93,
92, 91, 90, 89, 88, 87, 86, 85, 83, 82,
81, 80, 39, 76, 32, 74, 70, 61, 56, 43,
42, 33, 32, 201, 3, 201, 201, 201, 201, 201,
201, 201, 201, 201, 201, 201, 201, 201, 201, 201,
201, 201, 201, 201, 201, 201, 201, 201, 201, 201,
155, 154, 153, 152, 151, 150, 149, 148, 147, 146,
145, 144, 143, 142, 141, 140, 139, 138, 137, 136,
135, 134, 133, 132, 131, 130, 129, 128, 127, 126,
125, 124, 123, 122, 121, 120, 119, 118, 117, 116,
115, 114, 113, 109, 108, 107, 104, 103, 102, 101,
100, 99, 98, 97, 96, 95, 94, 93, 92, 91,
90, 89, 88, 87, 86, 85, 83, 82, 81, 80,
39, 76, 32, 74, 70, 61, 56, 43, 42, 33,
32, 209, 3, 209, 209, 209, 209, 209, 209, 209,
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
201, 201, 201, 201, 201, 201, 201, 201, 201, 201,
201, 201, 201, 201, 201
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
209, 209, 209
} ;
static const flex_int16_t yy_chk[316] =
static const flex_int16_t yy_chk[324] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
8, 8, 202, 8, 9, 9, 10, 10, 10, 199,
8, 8, 210, 8, 9, 9, 10, 10, 10, 207,
10, 10, 13, 13, 13, 24, 10, 10, 10, 10,
10, 10, 15, 15, 15, 24, 16, 16, 16, 198,
10, 10, 15, 15, 15, 24, 16, 16, 16, 205,
17, 17, 17, 18, 18, 18, 20, 26, 19, 19,
19, 15, 22, 16, 17, 20, 26, 197, 15, 16,
26, 25, 17, 196, 18, 17, 19, 25, 194, 25,
19, 15, 22, 16, 17, 20, 26, 174, 15, 16,
26, 25, 17, 204, 18, 17, 19, 25, 203, 25,
192, 22, 22, 28, 74, 22, 28, 74, 19, 34,
34, 28, 34, 36, 36, 191, 36, 37, 37, 41,
41, 41, 42, 42, 42, 189, 42, 42, 48, 48,
48, 188, 42, 42, 42, 42, 42, 42, 70, 70,
77, 77, 187, 77, 185, 183, 182, 181, 179, 178,
177, 176, 175, 174, 173, 172, 171, 48, 203, 203,
204, 204, 205, 205, 206, 206, 207, 207, 208, 208,
168, 167, 166, 165, 164, 162, 161, 160, 158, 157,
154, 153, 152, 151, 149, 148, 146, 145, 144, 143,
142, 140, 139, 138, 134, 133, 132, 131, 130, 128,
174, 22, 22, 28, 74, 22, 28, 74, 19, 34,
34, 28, 34, 36, 36, 202, 36, 37, 37, 41,
41, 41, 42, 42, 42, 201, 42, 42, 48, 48,
48, 200, 42, 42, 42, 42, 42, 42, 70, 70,
77, 77, 198, 77, 197, 195, 194, 193, 191, 190,
189, 188, 186, 184, 183, 182, 181, 48, 211, 211,
212, 212, 213, 213, 214, 214, 215, 215, 216, 216,
179, 178, 177, 176, 175, 173, 172, 171, 168, 167,
166, 165, 164, 162, 161, 160, 158, 157, 154, 153,
152, 151, 149, 148, 146, 145, 144, 143, 142, 140,
127, 126, 125, 124, 122, 121, 120, 119, 118, 117,
115, 113, 112, 109, 107, 106, 104, 101, 99, 98,
97, 95, 94, 92, 91, 90, 89, 88, 85, 84,
83, 82, 81, 80, 78, 73, 72, 71, 69, 68,
67, 66, 64, 63, 62, 61, 60, 59, 58, 57,
56, 55, 54, 53, 52, 51, 50, 49, 47, 46,
44, 43, 38, 35, 32, 29, 27, 23, 21, 14,
11, 7, 5, 3, 201, 201, 201, 201, 201, 201,
201, 201, 201, 201, 201, 201, 201, 201, 201, 201,
201, 201, 201, 201, 201, 201, 201, 201, 201, 201,
139, 138, 134, 133, 132, 131, 130, 128, 127, 126,
125, 124, 122, 121, 120, 119, 118, 117, 115, 113,
112, 109, 107, 106, 104, 101, 99, 98, 97, 95,
94, 92, 91, 90, 89, 88, 85, 84, 83, 82,
81, 80, 78, 73, 72, 71, 69, 68, 67, 66,
64, 63, 62, 61, 60, 59, 58, 57, 56, 55,
54, 53, 52, 51, 50, 49, 47, 46, 44, 43,
38, 35, 32, 29, 27, 23, 21, 14, 11, 7,
5, 3, 209, 209, 209, 209, 209, 209, 209, 209,
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
201, 201, 201, 201, 201, 201, 201, 201, 201, 201,
201, 201, 201, 201, 201
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
209, 209, 209
} ;
static yy_state_type yy_last_accepting_state;
@@ -819,13 +823,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 202 )
if ( yy_current_state >= 210 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
while ( yy_base[yy_current_state] != 275 );
while ( yy_base[yy_current_state] != 283 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -1009,15 +1013,15 @@ YY_RULE_SETUP
YY_BREAK
case 40:
YY_RULE_SETUP
{return(EQUALS);}
{return(SMBIOS_DEV_INFO);}
YY_BREAK
case 41:
YY_RULE_SETUP
{return(PIPE);}
{return(EQUALS);}
YY_BREAK
case 42:
YY_RULE_SETUP
{yylval.string = malloc(yyleng+1); strncpy(yylval.string, yytext, yyleng); yylval.string[yyleng]='\0'; return(NUMBER);}
{return(PIPE);}
YY_BREAK
case 43:
YY_RULE_SETUP
@@ -1029,12 +1033,11 @@ YY_RULE_SETUP
YY_BREAK
case 45:
YY_RULE_SETUP
{yylval.string = malloc(yyleng+1); strncpy(yylval.string, yytext, yyleng); yylval.string[yyleng]='\0'; return(PCIINT);}
{yylval.string = malloc(yyleng+1); strncpy(yylval.string, yytext, yyleng); yylval.string[yyleng]='\0'; return(NUMBER);}
YY_BREAK
case 46:
/* rule 46 can match eol */
YY_RULE_SETUP
{yylval.string = malloc(yyleng-1); strncpy(yylval.string, yytext+1, yyleng-2); yylval.string[yyleng-2]='\0'; return(STRING);}
{yylval.string = malloc(yyleng+1); strncpy(yylval.string, yytext, yyleng); yylval.string[yyleng]='\0'; return(PCIINT);}
YY_BREAK
case 47:
/* rule 47 can match eol */
@@ -1042,10 +1045,15 @@ YY_RULE_SETUP
{yylval.string = malloc(yyleng-1); strncpy(yylval.string, yytext+1, yyleng-2); yylval.string[yyleng-2]='\0'; return(STRING);}
YY_BREAK
case 48:
/* rule 48 can match eol */
YY_RULE_SETUP
{yylval.string = malloc(yyleng-1); strncpy(yylval.string, yytext+1, yyleng-2); yylval.string[yyleng-2]='\0'; return(STRING);}
YY_BREAK
case 49:
YY_RULE_SETUP
{yylval.string = malloc(yyleng+1); strncpy(yylval.string, yytext, yyleng); yylval.string[yyleng]='\0'; return(STRING);}
YY_BREAK
case 49:
case 50:
YY_RULE_SETUP
ECHO;
YY_BREAK
@@ -1345,7 +1353,7 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 202 )
if ( yy_current_state >= 210 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -1373,11 +1381,11 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 202 )
if ( yy_current_state >= 210 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 201);
yy_is_jam = (yy_current_state == 209);
return yy_is_jam ? 0 : yy_current_state;
}