Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
[RFC] sconfig: Allow to give static device nodes a name
The idea is to give device nodes in the `devicetree.cb` a name that can later be used in C code to identify the device (without having to look it up by fragile means). For this, we add an optional `as <identifier>` to the device declaration, for instance:
device i2c 0x50 as serial_eeprom on end
This leads to a `struct device __static_serial_eeprom;` that can then be used throughout coreboot.
Change-Id: I058a319f9b968924fbef9485a96c9e3f900a3ee8 Signed-off-by: Nico Huber nico.huber@secunet.com --- M Makefile.inc M util/sconfig/lex.yy.c_shipped M util/sconfig/main.c M util/sconfig/sconfig.h M util/sconfig/sconfig.l M util/sconfig/sconfig.tab.c_shipped M util/sconfig/sconfig.tab.h_shipped M util/sconfig/sconfig.y 8 files changed, 589 insertions(+), 505 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/56/35456/1
diff --git a/Makefile.inc b/Makefile.inc index 3c3088d..ed4874a 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -386,7 +386,7 @@ COREBOOT_EXPORTS += COREBOOT_EXTRA_VERSION endif
-CPPFLAGS_common := -Isrc -Isrc/include -Isrc/commonlib/include -I$(obj) +CPPFLAGS_common := -Isrc -Isrc/include -Isrc/commonlib/include -I$(obj) -I$(obj)/mainboard/$(MAINBOARDDIR) VBOOT_SOURCE ?= 3rdparty/vboot CPPFLAGS_common += -I$(VBOOT_SOURCE)/firmware/include CPPFLAGS_common += -include $(src)/include/kconfig.h diff --git a/util/sconfig/lex.yy.c_shipped b/util/sconfig/lex.yy.c_shipped index 14ffeff..c8202a1 100644 --- a/util/sconfig/lex.yy.c_shipped +++ b/util/sconfig/lex.yy.c_shipped @@ -6,7 +6,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 1 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -81,10 +81,16 @@ #define UINT32_MAX (4294967295U) #endif
+#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */ + /* TODO: this is always defined, so inline it */ #define yyconst const
@@ -97,32 +103,26 @@ /* Returned upon end-of-file. */ #define YY_NULL 0
-/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
/* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ) - +#define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */ @@ -159,7 +159,7 @@ #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - + #define YY_LESS_LINENO(n) #define YY_LINENO_REWIND_TO(ptr)
@@ -168,7 +168,7 @@ do \ { \ /* Undo effects of setting up yytext. */ \ - yy_size_t yyless_macro_arg = (n); \ + int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ @@ -176,7 +176,6 @@ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_STRUCT_YY_BUFFER_STATE @@ -258,7 +257,6 @@ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ @@ -279,62 +277,56 @@ */ static int yy_did_buffer_switch_on_eof;
-void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void );
-static void yyensure_buffer_stack (void ); -static void yy_load_buffer_state (void ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER )
-#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
-YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); - -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * );
#define yy_new_buffer yy_create_buffer - #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
/* Begin user sect3 */ - -typedef unsigned char YY_CHAR; +typedef flex_uint8_t YY_CHAR;
FILE *yyin = NULL, *yyout = NULL;
typedef int yy_state_type;
extern int yylineno; - int yylineno = 1;
extern char *yytext; @@ -343,10 +335,10 @@ #endif #define yytext_ptr yytext
-static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yynoreturn yy_fatal_error (yyconst char* msg ); +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg );
/* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -357,9 +349,8 @@ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 38 -#define YY_END_OF_BUFFER 39 +#define YY_NUM_RULES 39 +#define YY_END_OF_BUFFER 40 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -367,28 +358,29 @@ flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[160] = +static const flex_int16_t yy_accept[162] = { 0, - 0, 0, 39, 37, 1, 3, 37, 37, 37, 32, - 32, 30, 33, 37, 33, 33, 33, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 1, 3, - 37, 0, 37, 37, 0, 2, 32, 33, 37, 37, - 37, 37, 33, 37, 37, 37, 37, 37, 37, 37, - 24, 37, 37, 37, 37, 7, 37, 37, 37, 37, - 37, 37, 37, 36, 36, 37, 0, 31, 37, 37, - 16, 37, 37, 23, 28, 37, 37, 13, 37, 37, - 22, 37, 37, 8, 10, 12, 37, 37, 20, 37, - 21, 37, 0, 34, 4, 37, 37, 37, 37, 37, + 0, 0, 40, 38, 1, 3, 38, 38, 38, 33, + 33, 31, 34, 38, 34, 34, 34, 34, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 1, + 3, 38, 0, 38, 38, 0, 2, 33, 34, 38, + 38, 7, 38, 38, 34, 38, 38, 38, 38, 38, + 38, 38, 25, 38, 38, 38, 38, 8, 38, 38, + 38, 38, 38, 38, 38, 37, 37, 38, 0, 32, + 38, 38, 17, 38, 38, 24, 29, 38, 38, 14, + 38, 38, 23, 38, 38, 9, 11, 13, 38, 38, + 21, 38, 22, 38, 0, 35, 4, 38, 38, 38,
- 37, 37, 37, 19, 37, 37, 37, 35, 35, 37, - 37, 37, 37, 37, 37, 37, 14, 37, 37, 37, - 37, 5, 17, 37, 9, 37, 11, 37, 37, 37, - 37, 18, 26, 37, 37, 37, 37, 37, 37, 6, - 37, 37, 37, 37, 37, 37, 37, 25, 37, 37, - 15, 37, 27, 37, 37, 37, 37, 29, 0 + 38, 38, 38, 38, 38, 20, 38, 38, 38, 36, + 36, 38, 38, 38, 38, 38, 38, 38, 15, 38, + 38, 38, 38, 5, 18, 38, 10, 38, 12, 38, + 38, 38, 38, 19, 27, 38, 38, 38, 38, 38, + 38, 6, 38, 38, 38, 38, 38, 38, 38, 26, + 38, 38, 16, 38, 28, 38, 38, 38, 38, 30, + 0 } ;
-static yyconst YY_CHAR yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, @@ -420,7 +412,7 @@ 1, 1, 1, 1, 1 } ;
-static yyconst YY_CHAR yy_meta[39] = +static const YY_CHAR yy_meta[39] = { 0, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -428,114 +420,114 @@ 1, 1, 1, 1, 1, 1, 1, 1 } ;
-static yyconst flex_uint16_t yy_base[167] = +static const flex_int16_t yy_base[169] = { 0, - 0, 0, 227, 0, 224, 228, 222, 37, 41, 38, - 187, 0, 44, 209, 54, 78, 60, 201, 196, 45, - 203, 192, 42, 47, 197, 62, 184, 0, 214, 228, - 77, 210, 88, 69, 211, 228, 0, 87, 104, 198, - 187, 176, 93, 183, 178, 188, 179, 186, 186, 180, - 186, 171, 171, 175, 177, 0, 173, 167, 173, 177, - 169, 175, 174, 0, 228, 101, 186, 0, 179, 159, - 172, 162, 169, 0, 0, 164, 164, 0, 162, 152, - 0, 156, 151, 0, 0, 0, 154, 153, 0, 144, - 0, 171, 170, 0, 0, 155, 154, 147, 139, 149, + 0, 0, 231, 0, 228, 232, 226, 37, 41, 38, + 191, 0, 44, 213, 54, 58, 82, 64, 205, 200, + 65, 207, 196, 26, 49, 201, 48, 188, 0, 218, + 232, 93, 214, 97, 67, 215, 232, 0, 72, 108, + 202, 0, 191, 180, 77, 187, 182, 192, 183, 190, + 190, 184, 190, 175, 175, 179, 181, 0, 177, 171, + 177, 181, 173, 179, 178, 0, 232, 102, 190, 0, + 183, 163, 176, 166, 173, 0, 0, 168, 168, 0, + 166, 156, 0, 160, 155, 0, 0, 0, 158, 157, + 0, 148, 0, 175, 174, 0, 0, 159, 158, 151,
- 137, 143, 148, 0, 133, 136, 126, 0, 228, 137, - 141, 133, 135, 131, 133, 138, 0, 122, 122, 121, - 118, 0, 0, 133, 0, 117, 134, 128, 132, 113, - 113, 0, 0, 120, 112, 110, 121, 94, 95, 0, - 94, 92, 97, 86, 85, 84, 76, 0, 71, 78, - 0, 67, 0, 61, 55, 32, 29, 0, 228, 40, - 129, 131, 133, 135, 137, 139 + 143, 153, 141, 147, 152, 0, 137, 140, 130, 0, + 232, 141, 145, 137, 139, 135, 137, 142, 0, 126, + 126, 125, 122, 0, 0, 137, 0, 121, 138, 132, + 136, 117, 117, 0, 0, 124, 116, 114, 125, 111, + 112, 0, 117, 97, 102, 91, 92, 93, 80, 0, + 76, 89, 0, 92, 0, 86, 80, 43, 45, 0, + 232, 40, 130, 132, 134, 136, 138, 140 } ;
-static yyconst flex_int16_t yy_def[167] = +static const flex_int16_t yy_def[169] = { 0, - 159, 1, 159, 160, 159, 159, 160, 161, 162, 160, - 10, 160, 10, 160, 10, 10, 10, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 159, 159, - 161, 163, 164, 162, 165, 159, 10, 10, 10, 160, - 160, 160, 10, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 159, 164, 166, 39, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 159, 160, 160, 160, 160, 160, 160, 160, + 161, 1, 161, 162, 161, 161, 162, 163, 164, 162, + 10, 162, 10, 162, 10, 10, 10, 10, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 161, + 161, 163, 165, 166, 164, 167, 161, 10, 10, 10, + 162, 162, 162, 162, 10, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 161, 166, 168, 40, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 161, 162, 162, 162, 162, 162,
- 160, 160, 160, 160, 160, 160, 160, 160, 159, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 0, 159, - 159, 159, 159, 159, 159, 159 + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 161, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 0, 161, 161, 161, 161, 161, 161, 161 } ;
-static yyconst flex_uint16_t yy_nxt[267] = +static const flex_int16_t yy_nxt[271] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 10, 12, - 13, 13, 14, 4, 4, 4, 13, 13, 15, 16, - 17, 13, 18, 19, 20, 21, 22, 4, 23, 24, - 4, 25, 26, 4, 27, 4, 4, 4, 32, 32, - 28, 33, 35, 36, 37, 37, 37, 158, 38, 38, - 38, 38, 38, 49, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 55, 157, 57, 38, 38, 38, 56, - 35, 36, 50, 51, 58, 156, 52, 41, 32, 32, - 155, 64, 154, 42, 38, 38, 38, 46, 60, 67, - 67, 61, 28, 38, 38, 38, 62, 153, 43, 38, + 13, 13, 14, 4, 4, 4, 15, 13, 16, 17, + 18, 13, 19, 20, 21, 22, 23, 4, 24, 25, + 4, 26, 27, 4, 28, 4, 4, 4, 33, 33, + 29, 34, 36, 37, 38, 38, 38, 57, 39, 39, + 39, 39, 39, 58, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 160, 39, 39, 39, 59, 36, 37, + 39, 39, 39, 51, 62, 159, 60, 63, 39, 39, + 39, 43, 64, 39, 39, 39, 42, 44, 39, 39, + 39, 48, 52, 53, 33, 33, 54, 66, 69, 69,
- 38, 38, 67, 67, 152, 92, 44, 151, 150, 45, - 68, 68, 68, 149, 68, 68, 148, 147, 146, 145, - 68, 68, 68, 68, 68, 68, 144, 143, 72, 31, - 31, 34, 34, 32, 32, 66, 66, 35, 35, 67, - 67, 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, 112, 111, 110, 109, 108, 107, 106, 105, 104, - 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, - 93, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 158, 29, 45, 69, 69, 157, 94, 156, 155, 154, + 46, 153, 74, 47, 70, 70, 70, 152, 70, 70, + 151, 150, 149, 148, 70, 70, 70, 70, 70, 70, + 32, 32, 35, 35, 33, 33, 68, 68, 36, 36, + 69, 69, 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, 112, 111, 110, + 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, + 99, 98, 97, 96, 95, 93, 92, 91, 90, 89,
- 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, - 71, 70, 69, 36, 65, 29, 63, 59, 54, 53, - 48, 47, 40, 39, 30, 29, 159, 3, 159, 159, - 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, - 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, - 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, - 159, 159, 159, 159, 159, 159 + 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, + 78, 77, 76, 75, 73, 72, 71, 37, 67, 30, + 65, 61, 56, 55, 50, 49, 41, 40, 31, 30, + 161, 3, 161, 161, 161, 161, 161, 161, 161, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161 } ;
-static yyconst flex_int16_t yy_chk[267] = +static const flex_int16_t yy_chk[271] = { 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, 8, 8, - 160, 8, 9, 9, 10, 10, 10, 157, 10, 10, - 13, 13, 13, 20, 10, 10, 10, 10, 10, 10, - 15, 15, 15, 23, 156, 24, 17, 17, 17, 23, - 34, 34, 20, 20, 24, 155, 20, 15, 31, 31, - 154, 31, 152, 15, 16, 16, 16, 17, 26, 33, - 33, 26, 33, 38, 38, 38, 26, 150, 16, 43, + 162, 8, 9, 9, 10, 10, 10, 24, 10, 10, + 13, 13, 13, 24, 10, 10, 10, 10, 10, 10, + 15, 15, 15, 159, 16, 16, 16, 25, 35, 35, + 18, 18, 18, 21, 27, 158, 25, 27, 39, 39, + 39, 16, 27, 45, 45, 45, 15, 16, 17, 17, + 17, 18, 21, 21, 32, 32, 21, 32, 34, 34,
- 43, 43, 66, 66, 149, 66, 16, 147, 146, 16, - 39, 39, 39, 145, 39, 39, 144, 143, 142, 141, - 39, 39, 39, 39, 39, 39, 139, 138, 43, 161, - 161, 162, 162, 163, 163, 164, 164, 165, 165, 166, - 166, 137, 136, 135, 134, 131, 130, 129, 128, 127, - 126, 124, 121, 120, 119, 118, 116, 115, 114, 113, - 112, 111, 110, 107, 106, 105, 103, 102, 101, 100, - 99, 98, 97, 96, 93, 92, 90, 88, 87, 83, - 82, 80, 79, 77, 76, 73, 72, 71, 70, 69, - 67, 63, 62, 61, 60, 59, 58, 57, 55, 54, + 157, 34, 17, 68, 68, 156, 68, 154, 152, 151, + 17, 149, 45, 17, 40, 40, 40, 148, 40, 40, + 147, 146, 145, 144, 40, 40, 40, 40, 40, 40, + 163, 163, 164, 164, 165, 165, 166, 166, 167, 167, + 168, 168, 143, 141, 140, 139, 138, 137, 136, 133, + 132, 131, 130, 129, 128, 126, 123, 122, 121, 120, + 118, 117, 116, 115, 114, 113, 112, 109, 108, 107, + 105, 104, 103, 102, 101, 100, 99, 98, 95, 94, + 92, 90, 89, 85, 84, 82, 81, 79, 78, 75, + 74, 73, 72, 71, 69, 65, 64, 63, 62, 61,
- 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, - 42, 41, 40, 35, 32, 29, 27, 25, 22, 21, - 19, 18, 14, 11, 7, 5, 3, 159, 159, 159, - 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, - 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, - 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, - 159, 159, 159, 159, 159, 159 + 60, 59, 57, 56, 55, 54, 53, 52, 51, 50, + 49, 48, 47, 46, 44, 43, 41, 36, 33, 30, + 28, 26, 23, 22, 20, 19, 14, 11, 7, 5, + 3, 161, 161, 161, 161, 161, 161, 161, 161, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161 } ;
static yy_state_type yy_last_accepting_state; @@ -586,36 +578,36 @@ #define YY_EXTRA_TYPE void * #endif
-static int yy_init_globals (void ); +static int yy_init_globals ( void );
/* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */
-int yylex_destroy (void ); +int yylex_destroy ( void );
-int yyget_debug (void ); +int yyget_debug ( void );
-void yyset_debug (int debug_flag ); +void yyset_debug ( int debug_flag );
-YY_EXTRA_TYPE yyget_extra (void ); +YY_EXTRA_TYPE yyget_extra ( void );
-void yyset_extra (YY_EXTRA_TYPE user_defined ); +void yyset_extra ( YY_EXTRA_TYPE user_defined );
-FILE *yyget_in (void ); +FILE *yyget_in ( void );
-void yyset_in (FILE * _in_str ); +void yyset_in ( FILE * _in_str );
-FILE *yyget_out (void ); +FILE *yyget_out ( void );
-void yyset_out (FILE * _out_str ); +void yyset_out ( FILE * _out_str );
- int yyget_leng (void ); + int yyget_leng ( void );
-char *yyget_text (void ); +char *yyget_text ( void );
-int yyget_lineno (void ); +int yyget_lineno ( void );
-void yyset_lineno (int _line_number ); +void yyset_lineno ( int _line_number );
/* Macros after this point can all be overridden by user definitions in * section 1. @@ -623,32 +615,31 @@
#ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap (void ); +extern "C" int yywrap ( void ); #else -extern int yywrap (void ); +extern int yywrap ( void ); #endif #endif
#ifndef YY_NO_UNPUT
- static void yyunput (int c,char *buf_ptr ); + static void yyunput ( int c, char *buf_ptr );
#endif
#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy ( char *, const char *, int ); #endif
#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen ( const char * ); #endif
#ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (void ); +static int yyinput ( void ); #else -static int input (void ); +static int input ( void ); #endif
#endif @@ -781,10 +772,10 @@ if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); }
- yy_load_buffer_state( ); + yy_load_buffer_state( ); }
{ @@ -814,13 +805,13 @@ 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 >= 160 ) - yy_c = yy_meta[(unsigned int) yy_c]; + if ( yy_current_state >= 162 ) + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 228 ); + while ( yy_base[yy_current_state] != 232 );
yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -872,103 +863,103 @@ YY_BREAK case 7: YY_RULE_SETUP -{yylval.number=1; return(BOOL);} +{return(MNEMONIC);} YY_BREAK case 8: YY_RULE_SETUP -{yylval.number=0; return(BOOL);} +{yylval.number=1; return(BOOL);} YY_BREAK case 9: YY_RULE_SETUP -{yylval.number=3; return(HIDDEN);} +{yylval.number=0; return(BOOL);} YY_BREAK case 10: YY_RULE_SETUP -{yylval.number=PCI; return(BUS);} +{yylval.number=3; return(HIDDEN);} YY_BREAK case 11: YY_RULE_SETUP -{yylval.number=IOAPIC; return(BUS);} +{yylval.number=PCI; return(BUS);} YY_BREAK case 12: YY_RULE_SETUP -{yylval.number=PNP; return(BUS);} +{yylval.number=IOAPIC; return(BUS);} YY_BREAK case 13: YY_RULE_SETUP -{yylval.number=I2C; return(BUS);} +{yylval.number=PNP; return(BUS);} YY_BREAK case 14: YY_RULE_SETUP -{yylval.number=APIC; return(BUS);} +{yylval.number=I2C; return(BUS);} YY_BREAK case 15: YY_RULE_SETUP -{yylval.number=CPU_CLUSTER; return(BUS);} +{yylval.number=APIC; return(BUS);} YY_BREAK case 16: YY_RULE_SETUP -{yylval.number=CPU; return(BUS);} +{yylval.number=CPU_CLUSTER; return(BUS);} YY_BREAK case 17: YY_RULE_SETUP -{yylval.number=DOMAIN; return(BUS);} +{yylval.number=CPU; return(BUS);} YY_BREAK case 18: YY_RULE_SETUP -{yylval.number=GENERIC; return(BUS);} +{yylval.number=DOMAIN; return(BUS);} YY_BREAK case 19: YY_RULE_SETUP -{yylval.number=MMIO; return(BUS);} +{yylval.number=GENERIC; return(BUS);} YY_BREAK case 20: YY_RULE_SETUP -{yylval.number=SPI; return(BUS);} +{yylval.number=MMIO; return(BUS);} YY_BREAK case 21: YY_RULE_SETUP -{yylval.number=USB; return(BUS);} +{yylval.number=SPI; return(BUS);} YY_BREAK case 22: YY_RULE_SETUP -{yylval.number=IRQ; return(RESOURCE);} +{yylval.number=USB; return(BUS);} YY_BREAK case 23: YY_RULE_SETUP -{yylval.number=DRQ; return(RESOURCE);} +{yylval.number=IRQ; return(RESOURCE);} YY_BREAK case 24: YY_RULE_SETUP -{yylval.number=IO; return(RESOURCE);} +{yylval.number=DRQ; return(RESOURCE);} YY_BREAK case 25: YY_RULE_SETUP -{return(IOAPIC_IRQ);} +{yylval.number=IO; return(RESOURCE);} YY_BREAK case 26: YY_RULE_SETUP -{return(INHERIT);} +{return(IOAPIC_IRQ);} YY_BREAK case 27: YY_RULE_SETUP -{return(SUBSYSTEMID);} +{return(INHERIT);} YY_BREAK case 28: YY_RULE_SETUP -{return(END);} +{return(SUBSYSTEMID);} YY_BREAK case 29: YY_RULE_SETUP -{return(SLOT_DESC);} +{return(END);} YY_BREAK case 30: YY_RULE_SETUP -{return(EQUALS);} +{return(SLOT_DESC);} YY_BREAK case 31: YY_RULE_SETUP -{yylval.string = malloc(yyleng+1); strncpy(yylval.string, yytext, yyleng); yylval.string[yyleng]='\0'; return(NUMBER);} +{return(EQUALS);} YY_BREAK case 32: YY_RULE_SETUP @@ -980,12 +971,11 @@ YY_BREAK case 34: 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 35: -/* rule 35 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 36: /* rule 36 can match eol */ @@ -993,10 +983,15 @@ {yylval.string = malloc(yyleng-1); strncpy(yylval.string, yytext+1, yyleng-2); yylval.string[yyleng-2]='\0'; return(STRING);} YY_BREAK case 37: +/* rule 37 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 38: YY_RULE_SETUP {yylval.string = malloc(yyleng+1); strncpy(yylval.string, yytext, yyleng); yylval.string[yyleng]='\0'; return(STRING);} YY_BREAK -case 38: +case 39: YY_RULE_SETUP ECHO; YY_BREAK @@ -1077,7 +1072,7 @@ { (yy_did_buffer_switch_on_eof) = 0;
- if ( yywrap( ) ) + if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -1144,7 +1139,7 @@ { char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *source = (yytext_ptr); - yy_size_t number_to_move, i; + int number_to_move, i; int ret_val;
if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) @@ -1173,7 +1168,7 @@ /* Try to read more data. */
/* First move last chars to start of buffer. */ - number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1; + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1209,7 +1204,8 @@
b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,(yy_size_t) (b->yy_buf_size + 2) ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); } else /* Can't grow it, we don't own it. */ @@ -1241,7 +1237,7 @@ if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ); + yyrestart( yyin ); }
else @@ -1255,12 +1251,15 @@ else ret_val = EOB_ACT_CONTINUE_SCAN;
- if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,(yy_size_t) new_size ); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); }
(yy_n_chars) += number_to_move; @@ -1292,10 +1291,10 @@ 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 >= 160 ) - yy_c = yy_meta[(unsigned int) yy_c]; + if ( yy_current_state >= 162 ) + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; }
return yy_current_state; @@ -1320,11 +1319,11 @@ 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 >= 160 ) - yy_c = yy_meta[(unsigned int) yy_c]; + if ( yy_current_state >= 162 ) + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; - yy_is_jam = (yy_current_state == 159); + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 161);
return yy_is_jam ? 0 : yy_current_state; } @@ -1394,7 +1393,7 @@
else { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); ++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) ) @@ -1411,13 +1410,13 @@ */
/* Reset buffer status. */ - yyrestart(yyin ); + yyrestart( yyin );
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE: { - if ( yywrap( ) ) + if ( yywrap( ) ) return 0;
if ( ! (yy_did_buffer_switch_on_eof) ) @@ -1455,11 +1454,11 @@ if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); }
- yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - yy_load_buffer_state( ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); }
/** Switch to a different input buffer. @@ -1487,7 +1486,7 @@ }
YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); + yy_load_buffer_state( );
/* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag @@ -1515,7 +1514,7 @@ { YY_BUFFER_STATE b;
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
@@ -1524,13 +1523,13 @@ /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) yyalloc((yy_size_t) (b->yy_buf_size + 2) ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
- yy_init_buffer(b,file ); + yy_init_buffer( b, file );
return b; } @@ -1549,9 +1548,9 @@ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ); + yyfree( (void *) b->yy_ch_buf );
- yyfree((void *) b ); + yyfree( (void *) b ); }
/* Initializes or reinitializes a buffer. @@ -1563,7 +1562,7 @@ { int oerrno = errno;
- yy_flush_buffer(b ); + yy_flush_buffer( b );
b->yy_input_file = file; b->yy_fill_buffer = 1; @@ -1606,7 +1605,7 @@ b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); + yy_load_buffer_state( ); }
/** Pushes the new state onto the stack. The new state becomes @@ -1637,7 +1636,7 @@ YY_CURRENT_BUFFER_LVALUE = new_buffer;
/* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; }
@@ -1656,7 +1655,7 @@ --(yy_buffer_stack_top);
if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } @@ -1666,7 +1665,7 @@ */ static void yyensure_buffer_stack (void) { - int num_to_alloc; + yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
@@ -1723,7 +1722,7 @@ /* They forgot to leave room for the EOB's. */ return NULL;
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
@@ -1737,7 +1736,7 @@ b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW;
- yy_switch_to_buffer(b ); + yy_switch_to_buffer( b );
return b; } @@ -1750,10 +1749,10 @@ * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) +YY_BUFFER_STATE yy_scan_string (const char * yystr ) {
- return yy_scan_bytes(yystr,(int) strlen(yystr) ); + return yy_scan_bytes( yystr, (int) strlen(yystr) ); }
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will @@ -1763,7 +1762,7 @@ * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) { YY_BUFFER_STATE b; char *buf; @@ -1772,7 +1771,7 @@
/* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc(n ); + buf = (char *) yyalloc( n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
@@ -1781,7 +1780,7 @@
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
- b = yy_scan_buffer(buf,n ); + b = yy_scan_buffer( buf, n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
@@ -1797,9 +1796,9 @@ #define YY_EXIT_FAILURE 2 #endif
-static void yynoreturn yy_fatal_error (yyconst char* msg ) +static void yynoreturn yy_fatal_error (const char* msg ) { - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); }
@@ -1810,7 +1809,7 @@ do \ { \ /* Undo effects of setting up yytext. */ \ - yy_size_t yyless_macro_arg = (n); \ + int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = (yy_hold_char); \ (yy_c_buf_p) = yytext + yyless_macro_arg; \ @@ -1934,7 +1933,7 @@
/* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer( YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; yypop_buffer_state(); } @@ -1955,7 +1954,7 @@ */
#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +static void yy_flex_strncpy (char* s1, const char * s2, int n ) { int i; @@ -1965,7 +1964,7 @@ #endif
#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (const char * s ) { int n; for ( n = 0; s[n]; ++n ) diff --git a/util/sconfig/main.c b/util/sconfig/main.c index 6b421ec..4d15c8f 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -483,9 +483,9 @@ struct device *new_device(struct bus *parent, struct chip_instance *chip_instance, const int bustype, const char *devnum, - int status) + const char *const mnemonic, int status) { - char *tmp; + char *tmp, *name; int path_a; int path_b = 0; struct device *new_d; @@ -510,8 +510,14 @@ new_d->path_a = path_a; new_d->path_b = path_b;
- char *name = S_ALLOC(10); - sprintf(name, "_dev%d", new_d->id); + if (mnemonic) { + name = S_ALLOC(strlen("__static_") + strlen(mnemonic) + 1); + sprintf(name, "__static_%s", mnemonic); + new_d->has_mnemonic = 1; + } else { + name = S_ALLOC(10); + sprintf(name, "_dev%d", new_d->id); + } new_d->name = name;
new_d->enabled = status & 0x01; @@ -696,7 +702,7 @@ return 0; }
-static void pass0(FILE *fil, struct device *ptr, struct device *next) +static void pass0(FILE *fil, FILE *head, struct device *ptr, struct device *next) { if (ptr == &base_root_dev) { fprintf(fil, "STORAGE struct bus %s_links[];\n", @@ -704,7 +710,8 @@ return; }
- fprintf(fil, "STORAGE struct device %s;\n", ptr->name); + if (!ptr->has_mnemonic) + fprintf(fil, "STORAGE struct device %s;\n", ptr->name); if (ptr->res) fprintf(fil, "STORAGE struct resource %s_res[];\n", ptr->name); @@ -781,13 +788,13 @@ fprintf(fil, "\t};\n"); }
-static void pass1(FILE *fil, struct device *ptr, struct device *next) +static void pass1(FILE *fil, FILE *head, struct device *ptr, struct device *next) { int pin; struct chip_instance *chip_ins = ptr->chip_instance; int has_children = dev_has_children(ptr);
- if (ptr == &base_root_dev) + if (ptr == &base_root_dev || ptr->has_mnemonic) fprintf(fil, "DEVTREE_CONST struct device %s = {\n", ptr->name); else fprintf(fil, "STORAGE struct device %s = {\n", ptr->name); @@ -883,16 +890,25 @@ emit_dev_links(fil, ptr); }
-static void expose_device_names(FILE *fil, struct device *ptr, struct device *next) +static void expose_device_names(FILE *fil, FILE *head, struct device *ptr, struct device *next) { /* Only devices on root bus here. */ - if (ptr->bustype == PCI && ptr->parent->dev->bustype == DOMAIN) + if (ptr->bustype == PCI && ptr->parent->dev->bustype == DOMAIN) { + fprintf(head, "extern DEVTREE_CONST struct device *DEVTREE_CONST __pci_0_%02x_%d;\n", + ptr->path_a, ptr->path_b); fprintf(fil, "DEVTREE_CONST struct device *DEVTREE_CONST __pci_0_%02x_%d = &%s;\n", ptr->path_a, ptr->path_b, ptr->name); + }
- if (ptr->bustype == PNP) + if (ptr->bustype == PNP) { + fprintf(head, "extern DEVTREE_CONST struct device *DEVTREE_CONST __pnp_%04x_%02x;\n", + ptr->path_a, ptr->path_b); fprintf(fil, "DEVTREE_CONST struct device *DEVTREE_CONST __pnp_%04x_%02x = &%s;\n", ptr->path_a, ptr->path_b, ptr->name); + } + + if (ptr->has_mnemonic) + fprintf(head, "extern DEVTREE_CONST struct device %s;\n", ptr->name); }
static void add_siblings_to_queue(struct queue_entry **bfs_q_head, @@ -916,8 +932,8 @@ } }
-static void walk_device_tree(FILE *fil, struct device *ptr, - void (*func)(FILE *, struct device *, +static void walk_device_tree(FILE *fil, FILE *head, struct device *ptr, + void (*func)(FILE *, FILE *, struct device *, struct device *)) { struct queue_entry *bfs_q_head = NULL; @@ -926,7 +942,7 @@
while ((ptr = dequeue_head(&bfs_q_head))) { add_children_to_queue(&bfs_q_head, ptr); - func(fil, ptr, peek_queue_head(bfs_q_head)); + func(fil, head, ptr, peek_queue_head(bfs_q_head)); } }
@@ -995,7 +1011,7 @@ } }
-static void inherit_subsystem_ids(FILE *file, struct device *dev, +static void inherit_subsystem_ids(FILE *file, FILE *head, struct device *dev, struct device *next) { struct device *p; @@ -1360,11 +1376,13 @@
int main(int argc, char **argv) { + unsigned int i; + if ((argc < MANDATORY_ARG_COUNT) || (argc > TOTAL_ARG_COUNT)) usage();
const char *base_devtree = argv[DEVICEFILE_ARG]; - const char *outputc = argv[OUTPUTFILE_ARG]; + char *outputf = argv[OUTPUTFILE_ARG]; const char *override_devtree;
parse_devicetree(base_devtree, &base_root_bus); @@ -1381,26 +1399,49 @@ override_devicetree(&base_root_bus, &override_root_bus); }
- FILE *autogen = fopen(outputc, "w"); + FILE *autogen = fopen(outputf, "w"); if (!autogen) { fprintf(stderr, "Could not open file '%s' for writing: ", - outputc); + outputf); perror(NULL); exit(1); }
+ outputf[strlen(outputf) - 1] = 'h'; + FILE *autohead = fopen(outputf, "w"); + if (!autohead) { + fprintf(stderr, "Could not open file '%s' for writing: ", outputf); + perror(NULL); + fclose(autogen); + exit(1); + } + fprintf(autohead, "#ifndef __STATIC_DEVICE_TREE_H\n"); + fprintf(autohead, "#define __STATIC_DEVICE_TREE_H\n\n"); + fprintf(autohead, "#include <device/device.h>\n\n"); + + char *header_name = outputf; + for (i = strlen(outputf) - 1; i > 0; --i) { + if (outputf[i] == '/') { + header_name = outputf + i + 1; + break; + } + } + fprintf(autogen, "#include "%s"\n", header_name); + emit_chips(autogen);
- walk_device_tree(autogen, &base_root_dev, inherit_subsystem_ids); + walk_device_tree(autogen, autohead, &base_root_dev, inherit_subsystem_ids); fprintf(autogen, "\n/* pass 0 */\n"); - walk_device_tree(autogen, &base_root_dev, pass0); + walk_device_tree(autogen, autohead, &base_root_dev, pass0); fprintf(autogen, "\n/* pass 1 */\n"); - walk_device_tree(autogen, &base_root_dev, pass1); + walk_device_tree(autogen, autohead, &base_root_dev, pass1);
/* Expose static devicenames to global namespace. */ fprintf(autogen, "\n/* expose_device_names */\n"); - walk_device_tree(autogen, &base_root_dev, expose_device_names); + walk_device_tree(autogen, autohead, &base_root_dev, expose_device_names);
+ fprintf(autohead, "\n#endif /* __STATIC_DEVICE_TREE_H */\n"); + fclose(autohead); fclose(autogen);
return 0; diff --git a/util/sconfig/sconfig.h b/util/sconfig/sconfig.h index eea2a14..ca834e8 100644 --- a/util/sconfig/sconfig.h +++ b/util/sconfig/sconfig.h @@ -112,6 +112,7 @@
/* Name of this device. */ char *name; + int has_mnemonic;
/* Path of this device. */ char *path; @@ -159,7 +160,7 @@ struct device *new_device(struct bus *parent, struct chip_instance *chip_instance, const int bustype, const char *devnum, - int status); + const char *mnemonic, int status);
void add_resource(struct bus *bus, int type, int index, int base);
diff --git a/util/sconfig/sconfig.l b/util/sconfig/sconfig.l index 87de6e2..4752cca 100755 --- a/util/sconfig/sconfig.l +++ b/util/sconfig/sconfig.l @@ -27,6 +27,7 @@ chip {return(CHIP);} device {return(DEVICE);} register {return(REGISTER);} +as {return(MNEMONIC);} on {yylval.number=1; return(BOOL);} off {yylval.number=0; return(BOOL);} hidden {yylval.number=3; return(HIDDEN);} diff --git a/util/sconfig/sconfig.tab.c_shipped b/util/sconfig/sconfig.tab.c_shipped index 8e1e57d..9fd57e0 100644 --- a/util/sconfig/sconfig.tab.c_shipped +++ b/util/sconfig/sconfig.tab.c_shipped @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.5. */ +/* A Bison parser, made by GNU Bison 3.3.2. */
/* Bison implementation for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, + Inc.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,11 +41,14 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */
+/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + /* Identify Bison output. */ #define YYBISON 1
/* Bison version. */ -#define YYBISON_VERSION "3.0.5" +#define YYBISON_VERSION "3.3.2"
/* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -61,7 +65,7 @@
-/* Copy the first part of user declarations. */ +/* First part of user prologue. */
/* @@ -90,12 +94,15 @@
- # ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif # else -# define YY_NULLPTR 0 +# define YY_NULLPTR ((void*)0) # endif # endif
@@ -109,8 +116,8 @@
/* In a future release of Bison, this section will be replaced by #include "sconfig.tab.h_shipped". */ -#ifndef YY_YY_UTIL_SCONFIG_SCONFIG_TAB_H_SHIPPED_INCLUDED -# define YY_YY_UTIL_SCONFIG_SCONFIG_TAB_H_SHIPPED_INCLUDED +#ifndef YY_YY_HOME_ICON_COREBOOT_UTIL_SCONFIG_SCONFIG_TAB_H_SHIPPED_INCLUDED +# define YY_YY_HOME_ICON_COREBOOT_UTIL_SCONFIG_SCONFIG_TAB_H_SHIPPED_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -127,35 +134,36 @@ CHIP = 258, DEVICE = 259, REGISTER = 260, - BOOL = 261, - HIDDEN = 262, - BUS = 263, - RESOURCE = 264, - END = 265, - EQUALS = 266, - HEX = 267, - STRING = 268, - PCI = 269, - PNP = 270, - I2C = 271, - APIC = 272, - CPU_CLUSTER = 273, - CPU = 274, - DOMAIN = 275, - IRQ = 276, - DRQ = 277, - SLOT_DESC = 278, - IO = 279, - NUMBER = 280, - SUBSYSTEMID = 281, - INHERIT = 282, - IOAPIC_IRQ = 283, - IOAPIC = 284, - PCIINT = 285, - GENERIC = 286, - SPI = 287, - USB = 288, - MMIO = 289 + MNEMONIC = 261, + BOOL = 262, + HIDDEN = 263, + BUS = 264, + RESOURCE = 265, + END = 266, + EQUALS = 267, + HEX = 268, + STRING = 269, + PCI = 270, + PNP = 271, + I2C = 272, + APIC = 273, + CPU_CLUSTER = 274, + CPU = 275, + DOMAIN = 276, + IRQ = 277, + DRQ = 278, + SLOT_DESC = 279, + IO = 280, + NUMBER = 281, + SUBSYSTEMID = 282, + INHERIT = 283, + IOAPIC_IRQ = 284, + IOAPIC = 285, + PCIINT = 286, + GENERIC = 287, + SPI = 288, + USB = 289, + MMIO = 290 }; #endif
@@ -184,9 +192,7 @@
int yyparse (void);
-#endif /* !YY_YY_UTIL_SCONFIG_SCONFIG_TAB_H_SHIPPED_INCLUDED */ - -/* Copy the second part of user declarations. */ +#endif /* !YY_YY_HOME_ICON_COREBOOT_UTIL_SCONFIG_SCONFIG_TAB_H_SHIPPED_INCLUDED */
@@ -209,13 +215,13 @@ #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else -typedef unsigned short int yytype_uint16; +typedef unsigned short yytype_uint16; #endif
#ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else -typedef short int yytype_int16; +typedef short yytype_int16; #endif
#ifndef YYSIZE_T @@ -227,7 +233,7 @@ # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif
@@ -263,15 +269,6 @@ # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif
-#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) -# endif -#endif - /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -279,7 +276,7 @@ # define YYUSE(E) /* empty */ #endif
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ @@ -430,27 +427,27 @@ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 43 +#define YYLAST 47
/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 35 +#define YYNTOKENS 36 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 15 +#define YYNNTS 16 /* YYNRULES -- Number of rules. */ -#define YYNRULES 28 +#define YYNRULES 30 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 49 +#define YYNSTATES 52
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 289 +#define YYMAXUTOK 290
+/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ + as returned by yylex. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -481,7 +478,8 @@ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34 + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35 };
#if YYDEBUG @@ -490,7 +488,8 @@ { 0, 36, 36, 36, 38, 38, 38, 38, 40, 40, 40, 40, 40, 40, 40, 42, 42, 51, 51, 59, - 59, 61, 64, 67, 70, 73, 76, 79, 82 + 61, 65, 65, 67, 70, 73, 76, 79, 82, 85, + 88 }; #endif
@@ -499,14 +498,14 @@ First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "CHIP", "DEVICE", "REGISTER", "BOOL", - "HIDDEN", "BUS", "RESOURCE", "END", "EQUALS", "HEX", "STRING", "PCI", - "PNP", "I2C", "APIC", "CPU_CLUSTER", "CPU", "DOMAIN", "IRQ", "DRQ", - "SLOT_DESC", "IO", "NUMBER", "SUBSYSTEMID", "INHERIT", "IOAPIC_IRQ", - "IOAPIC", "PCIINT", "GENERIC", "SPI", "USB", "MMIO", "$accept", - "devtree", "$@1", "chipchildren", "devicechildren", "chip", "@2", - "device", "@3", "status", "resource", "registers", "subsystemid", - "ioapic_irq", "smbios_slot_desc", YY_NULLPTR + "$end", "error", "$undefined", "CHIP", "DEVICE", "REGISTER", "MNEMONIC", + "BOOL", "HIDDEN", "BUS", "RESOURCE", "END", "EQUALS", "HEX", "STRING", + "PCI", "PNP", "I2C", "APIC", "CPU_CLUSTER", "CPU", "DOMAIN", "IRQ", + "DRQ", "SLOT_DESC", "IO", "NUMBER", "SUBSYSTEMID", "INHERIT", + "IOAPIC_IRQ", "IOAPIC", "PCIINT", "GENERIC", "SPI", "USB", "MMIO", + "$accept", "devtree", "$@1", "chipchildren", "devicechildren", "chip", + "@2", "device", "@3", "mnemonic", "status", "resource", "registers", + "subsystemid", "ioapic_irq", "smbios_slot_desc", YY_NULLPTR }; #endif
@@ -518,7 +517,7 @@ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289 + 285, 286, 287, 288, 289, 290 }; # endif
@@ -536,11 +535,12 @@ STATE-NUM. */ static const yytype_int8 yypact[] = { - -12, 11, 9, -12, 1, -12, -12, -12, 0, 5, - 3, -12, -12, -12, -12, -10, 6, 2, 8, -12, - -12, -12, -12, -12, -3, -1, -12, 13, 4, 7, - -12, -12, -12, -12, -12, -12, 16, 15, 10, -11, - 12, 17, -5, 14, -12, 18, -12, -12, -12 + -12, 11, -1, -12, 0, -12, -12, -12, 1, 4, + 3, -12, -12, -12, -12, -11, 6, 10, 5, 9, + 2, -12, -12, -12, -12, -12, -12, -3, -6, -12, + 13, 7, 8, -12, -12, -12, -12, -12, -12, 16, + 15, 12, 14, 17, 18, 19, 20, -12, 21, -12, + -12, -12 };
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -549,24 +549,25 @@ static const yytype_uint8 yydefact[] = { 2, 0, 0, 1, 0, 3, 15, 7, 0, 0, - 0, 16, 5, 4, 6, 0, 0, 0, 0, 19, - 20, 17, 22, 14, 0, 0, 18, 0, 0, 0, - 9, 8, 10, 11, 12, 13, 0, 0, 0, 0, - 0, 28, 23, 0, 21, 27, 24, 25, 26 + 0, 16, 5, 4, 6, 0, 0, 19, 0, 0, + 0, 24, 20, 21, 22, 17, 14, 0, 0, 18, + 0, 0, 0, 9, 8, 10, 11, 12, 13, 0, + 0, 0, 0, 0, 30, 25, 0, 23, 29, 26, + 27, 28 };
/* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -12, -12, -12, -12, -12, -6, -12, 19, -12, -12, - -12, -12, -12, -12, -12 + -12, -12, -12, -12, -12, -5, -12, -2, -12, -12, + -12, -12, -12, -12, -12, -12 };
/* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 1, 2, 8, 24, 5, 7, 13, 23, 21, - 32, 14, 33, 34, 35 + -1, 1, 2, 8, 27, 5, 7, 13, 26, 20, + 25, 35, 14, 36, 37, 38 };
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -574,47 +575,50 @@ number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_uint8 yytable[] = { - 4, 9, 12, 4, 9, 10, 25, 26, 19, 20, - 11, 3, 4, 15, 6, 17, 16, 18, 30, 43, - 27, 22, 46, 28, 36, 29, 37, 40, 41, 38, - 45, 48, 39, 0, 0, 42, 0, 44, 0, 47, - 0, 0, 0, 31 + 4, 9, 4, 12, 4, 9, 10, 28, 29, 23, + 24, 3, 11, 15, 6, 17, 19, 16, 18, 21, + 39, 30, 33, 22, 31, 34, 32, 40, 43, 44, + 0, 0, 48, 41, 42, 51, 0, 0, 45, 0, + 0, 0, 0, 47, 0, 46, 50, 49 };
static const yytype_int8 yycheck[] = { - 3, 4, 8, 3, 4, 5, 9, 10, 6, 7, - 10, 0, 3, 8, 13, 25, 13, 11, 24, 30, - 23, 13, 27, 26, 25, 28, 13, 11, 13, 25, - 13, 13, 25, -1, -1, 25, -1, 25, -1, 25, - -1, -1, -1, 24 + 3, 4, 3, 8, 3, 4, 5, 10, 11, 7, + 8, 0, 11, 9, 14, 26, 6, 14, 12, 14, + 26, 24, 27, 14, 27, 27, 29, 14, 12, 14, + -1, -1, 14, 26, 26, 14, -1, -1, 26, -1, + -1, -1, -1, 26, -1, 31, 26, 28 };
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 36, 37, 0, 3, 40, 13, 41, 38, 4, - 5, 10, 40, 42, 46, 8, 13, 25, 11, 6, - 7, 44, 13, 43, 39, 9, 10, 23, 26, 28, - 40, 42, 45, 47, 48, 49, 25, 13, 25, 25, - 11, 13, 25, 30, 25, 13, 27, 25, 13 + 0, 37, 38, 0, 3, 41, 14, 42, 39, 4, + 5, 11, 41, 43, 48, 9, 14, 26, 12, 6, + 45, 14, 14, 7, 8, 46, 44, 40, 10, 11, + 24, 27, 29, 41, 43, 47, 49, 50, 51, 26, + 14, 26, 26, 12, 14, 26, 31, 26, 14, 28, + 26, 14 };
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 35, 37, 36, 38, 38, 38, 38, 39, 39, - 39, 39, 39, 39, 39, 41, 40, 43, 42, 44, - 44, 45, 46, 47, 47, 48, 49, 49, 49 + 0, 36, 38, 37, 39, 39, 39, 39, 40, 40, + 40, 40, 40, 40, 40, 42, 41, 44, 43, 45, + 45, 46, 46, 47, 48, 49, 49, 50, 51, 51, + 51 };
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 0, 2, 2, 2, 2, 0, 2, 2, - 2, 2, 2, 2, 0, 0, 5, 0, 7, 1, - 1, 4, 4, 3, 4, 4, 5, 4, 3 + 2, 2, 2, 2, 0, 0, 5, 0, 8, 0, + 2, 1, 1, 4, 4, 3, 4, 4, 5, 4, + 3 };
@@ -630,22 +634,22 @@
#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0)
/* Error token number */ #define YYTERROR 1 @@ -685,37 +689,37 @@ } while (0)
-/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/
static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YYUSE (yyoutput); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); + YYPRINT (yyo, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); }
-/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/
static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { - YYFPRINTF (yyoutput, "%s %s (", + YYFPRINTF (yyo, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
- yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yytype, yyvaluep); + YYFPRINTF (yyo, ")"); }
/*------------------------------------------------------------------. @@ -749,7 +753,7 @@ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) { - unsigned long int yylno = yyrline[yyrule]; + unsigned long yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", @@ -760,7 +764,7 @@ YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) + &yyvsp[(yyi + 1) - (yynrhs)] ); YYFPRINTF (stderr, "\n"); } @@ -864,7 +868,10 @@ case '\': if (*++yyp != '\') goto do_not_strip_quotes; - /* Fall through. */ + else + goto append; + + append: default: if (yyres) yyres[yyn] = *yyp; @@ -882,7 +889,7 @@ if (! yyres) return yystrlen (yystr);
- return yystpcpy (yyres, yystr) - yyres; + return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); } # endif
@@ -960,10 +967,10 @@ yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } } } @@ -987,9 +994,10 @@
{ YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; }
if (*yymsg_alloc < yysize) @@ -1115,23 +1123,31 @@ yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate;
+ /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++;
- yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yynewstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + *yyssp = (yytype_int16) yystate;
if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
-#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into @@ -1147,14 +1163,10 @@ &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1170,22 +1182,22 @@ goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */
yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long) yystacksize));
if (yyss + yystacksize - 1 <= yyssp) YYABORT; } +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
@@ -1194,11 +1206,11 @@
goto yybackup;
+ /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */
@@ -1271,7 +1283,7 @@
/*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1318,7 +1330,7 @@ case 17:
{ - (yyval.dev) = new_device(cur_parent, cur_chip_instance, (yyvsp[-2].number), (yyvsp[-1].string), (yyvsp[0].number)); + (yyval.dev) = new_device(cur_parent, cur_chip_instance, (yyvsp[-3].number), (yyvsp[-2].string), (yyvsp[-1].string), (yyvsp[0].number)); cur_parent = (yyval.dev)->last_bus; }
@@ -1332,50 +1344,66 @@
break;
- case 21: + case 19:
- { add_resource(cur_parent, (yyvsp[-3].number), strtol((yyvsp[-2].string), NULL, 0), strtol((yyvsp[0].string), NULL, 0)); } + { + (yyval.string) = NULL; +}
break;
- case 22: + case 20:
- { add_register(cur_chip_instance, (yyvsp[-2].string), (yyvsp[0].string)); } + { + (yyval.string) = (yyvsp[0].string); +}
break;
case 23:
- { add_pci_subsystem_ids(cur_parent, strtol((yyvsp[-1].string), NULL, 16), strtol((yyvsp[0].string), NULL, 16), 0); } + { add_resource(cur_parent, (yyvsp[-3].number), strtol((yyvsp[-2].string), NULL, 0), strtol((yyvsp[0].string), NULL, 0)); }
break;
case 24:
- { add_pci_subsystem_ids(cur_parent, strtol((yyvsp[-2].string), NULL, 16), strtol((yyvsp[-1].string), NULL, 16), 1); } + { add_register(cur_chip_instance, (yyvsp[-2].string), (yyvsp[0].string)); }
break;
case 25:
- { add_ioapic_info(cur_parent, strtol((yyvsp[-2].string), NULL, 16), (yyvsp[-1].string), strtol((yyvsp[0].string), NULL, 16)); } + { add_pci_subsystem_ids(cur_parent, strtol((yyvsp[-1].string), NULL, 16), strtol((yyvsp[0].string), NULL, 16), 0); }
break;
case 26:
- { add_slot_desc(cur_parent, (yyvsp[-3].string), (yyvsp[-2].string), (yyvsp[-1].string), (yyvsp[0].string)); } + { add_pci_subsystem_ids(cur_parent, strtol((yyvsp[-2].string), NULL, 16), strtol((yyvsp[-1].string), NULL, 16), 1); }
break;
case 27:
- { add_slot_desc(cur_parent, (yyvsp[-2].string), (yyvsp[-1].string), (yyvsp[0].string), NULL); } + { add_ioapic_info(cur_parent, strtol((yyvsp[-2].string), NULL, 16), (yyvsp[-1].string), strtol((yyvsp[0].string), NULL, 16)); }
break;
case 28:
+ { add_slot_desc(cur_parent, (yyvsp[-3].string), (yyvsp[-2].string), (yyvsp[-1].string), (yyvsp[0].string)); } + + break; + + case 29: + + { add_slot_desc(cur_parent, (yyvsp[-2].string), (yyvsp[-1].string), (yyvsp[0].string), NULL); } + + break; + + case 30: + { add_slot_desc(cur_parent, (yyvsp[-1].string), (yyvsp[0].string), NULL, NULL); }
break; @@ -1406,14 +1434,13 @@ /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + }
goto yynewstate;
@@ -1496,12 +1523,10 @@ | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR;
/* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -1563,6 +1588,7 @@ yyresult = 0; goto yyreturn;
+ /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -1570,6 +1596,7 @@ yyresult = 1; goto yyreturn;
+ #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -1580,6 +1607,10 @@ /* Fall through. */ #endif
+ +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { diff --git a/util/sconfig/sconfig.tab.h_shipped b/util/sconfig/sconfig.tab.h_shipped index bcbd644..8af828e 100644 --- a/util/sconfig/sconfig.tab.h_shipped +++ b/util/sconfig/sconfig.tab.h_shipped @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.5. */ +/* A Bison parser, made by GNU Bison 3.3.2. */
/* Bison interface for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, + Inc.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,8 +31,11 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */
-#ifndef YY_YY_UTIL_SCONFIG_SCONFIG_TAB_H_SHIPPED_INCLUDED -# define YY_YY_UTIL_SCONFIG_SCONFIG_TAB_H_SHIPPED_INCLUDED +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + +#ifndef YY_YY_HOME_ICON_COREBOOT_UTIL_SCONFIG_SCONFIG_TAB_H_SHIPPED_INCLUDED +# define YY_YY_HOME_ICON_COREBOOT_UTIL_SCONFIG_SCONFIG_TAB_H_SHIPPED_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -48,35 +52,36 @@ CHIP = 258, DEVICE = 259, REGISTER = 260, - BOOL = 261, - HIDDEN = 262, - BUS = 263, - RESOURCE = 264, - END = 265, - EQUALS = 266, - HEX = 267, - STRING = 268, - PCI = 269, - PNP = 270, - I2C = 271, - APIC = 272, - CPU_CLUSTER = 273, - CPU = 274, - DOMAIN = 275, - IRQ = 276, - DRQ = 277, - SLOT_DESC = 278, - IO = 279, - NUMBER = 280, - SUBSYSTEMID = 281, - INHERIT = 282, - IOAPIC_IRQ = 283, - IOAPIC = 284, - PCIINT = 285, - GENERIC = 286, - SPI = 287, - USB = 288, - MMIO = 289 + MNEMONIC = 261, + BOOL = 262, + HIDDEN = 263, + BUS = 264, + RESOURCE = 265, + END = 266, + EQUALS = 267, + HEX = 268, + STRING = 269, + PCI = 270, + PNP = 271, + I2C = 272, + APIC = 273, + CPU_CLUSTER = 274, + CPU = 275, + DOMAIN = 276, + IRQ = 277, + DRQ = 278, + SLOT_DESC = 279, + IO = 280, + NUMBER = 281, + SUBSYSTEMID = 282, + INHERIT = 283, + IOAPIC_IRQ = 284, + IOAPIC = 285, + PCIINT = 286, + GENERIC = 287, + SPI = 288, + USB = 289, + MMIO = 290 }; #endif
@@ -105,4 +110,4 @@
int yyparse (void);
-#endif /* !YY_YY_UTIL_SCONFIG_SCONFIG_TAB_H_SHIPPED_INCLUDED */ +#endif /* !YY_YY_HOME_ICON_COREBOOT_UTIL_SCONFIG_SCONFIG_TAB_H_SHIPPED_INCLUDED */ diff --git a/util/sconfig/sconfig.y b/util/sconfig/sconfig.y index 0d894a9..1f225c1 100755 --- a/util/sconfig/sconfig.y +++ b/util/sconfig/sconfig.y @@ -31,7 +31,7 @@ int number; }
-%token CHIP DEVICE REGISTER BOOL HIDDEN BUS RESOURCE END EQUALS HEX STRING PCI PNP I2C APIC CPU_CLUSTER CPU DOMAIN IRQ DRQ SLOT_DESC IO NUMBER SUBSYSTEMID INHERIT IOAPIC_IRQ IOAPIC PCIINT GENERIC SPI USB MMIO +%token CHIP DEVICE REGISTER MNEMONIC BOOL HIDDEN BUS RESOURCE END EQUALS HEX STRING PCI PNP I2C APIC CPU_CLUSTER CPU DOMAIN IRQ DRQ SLOT_DESC IO NUMBER SUBSYSTEMID INHERIT IOAPIC_IRQ IOAPIC PCIINT GENERIC SPI USB MMIO %% devtree: { cur_parent = root_parent; } chip;
@@ -48,12 +48,18 @@ cur_chip_instance = chip_dequeue_tail(); };
-device: DEVICE BUS NUMBER /* == devnum */ status { - $<dev>$ = new_device(cur_parent, cur_chip_instance, $<number>2, $<string>3, $<number>4); +device: DEVICE BUS NUMBER /* == devnum */ mnemonic status { + $<dev>$ = new_device(cur_parent, cur_chip_instance, $<number>2, $<string>3, $<string>4, $<number>5); cur_parent = $<dev>$->last_bus; } devicechildren END { - cur_parent = $<dev>5->parent; + cur_parent = $<dev>6->parent; +}; + +mnemonic: /* empty */ { + $<string>$ = NULL; +} | MNEMONIC STRING { + $<string>$ = $<string>2; };
status: BOOL | HIDDEN;
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
Patch Set 1:
(3 comments)
https://review.coreboot.org/c/coreboot/+/35456/1/util/sconfig/lex.yy.c_shipp... File util/sconfig/lex.yy.c_shipped:
https://review.coreboot.org/c/coreboot/+/35456/1/util/sconfig/lex.yy.c_shipp... PS1, Line 162: trailing whitespace
https://review.coreboot.org/c/coreboot/+/35456/1/util/sconfig/main.c File util/sconfig/main.c:
https://review.coreboot.org/c/coreboot/+/35456/1/util/sconfig/main.c@897 PS1, Line 897: fprintf(head, "extern DEVTREE_CONST struct device *DEVTREE_CONST __pci_0_%02x_%d;\n", line over 96 characters
https://review.coreboot.org/c/coreboot/+/35456/1/util/sconfig/main.c@904 PS1, Line 904: fprintf(head, "extern DEVTREE_CONST struct device *DEVTREE_CONST __pnp_%04x_%02x;\n", line over 96 characters
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
Patch Set 1:
So, this is my approach to get rid of the fragile dev_find_slot_on_smbus() (see next commit for an example).
I found out about the new expose_device_names() in `sconfig/main.c` late during writing this, hence some inconsistency (renaming objects vs. aliased pointers). Just wanted to get some feedback early if this is the right thing :)
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
Patch Set 1:
(1 comment)
Patch Set 1:
So, this is my approach to get rid of the fragile dev_find_slot_on_smbus() (see next commit for an example).
I found out about the new expose_device_names() in `sconfig/main.c` late during writing this, hence some inconsistency (renaming objects vs. aliased pointers). Just wanted to get some feedback early if this is the right thing :)
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG@14 PS1, Line 14: as Maybe learning Ada helps, but I feel like this keyword is a bit hard to understand.
Maybe "named" or something like that would help?
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG@14 PS1, Line 14: as
Maybe learning Ada helps, but I feel like this keyword is a bit hard to understand. […]
`named` sounds good, too. however, I believe that `as` reflects better that the code expects that name. `named` suggests to me that it's the devicetree author's choice.
I see now that the commit message has it backwards too :)
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
Patch Set 1:
(2 comments)
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG@16 PS1, Line 16: _static_serial_eeprom What are your thoughts in promoting the name defined in devicetree as a global symbol w/o the hierarchy information? My concern is around having multiples of certain things and then we have something1 and something2 and those symbols baked into the code.
When should someone use the 1 variant vs the 2 variant? Should we allow common code (soc/) changes to refer to names in mainboard devicetrees?
Do you envision this approach proliferating?
https://review.coreboot.org/c/coreboot/+/35456/1/util/sconfig/main.c File util/sconfig/main.c:
https://review.coreboot.org/c/coreboot/+/35456/1/util/sconfig/main.c@1410 PS1, Line 1410: outputf[strlen(outputf) - 1] = 'h'; Looks like this patch is also making a new file. Could you please mention that in the description as well?
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
Patch Set 1:
(2 comments)
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG@16 PS1, Line 16: _static_serial_eeprom
What are your thoughts in promoting the name defined in devicetree as a global symbol w/o the hierarchy information? My concern is around having multiples of certain things and then we have something1 and something2 and those symbols baked into the code.
The problem with hierarchy information is how to communicate it. The cases where dev_find_slot_on_smbus() is used (with fragile bus numbers), show that there is a need to tell the driver of one device (or framework code, e.g. SMBIOS) about another device that can be anywhere.
I was first thinking about something like what is currently done in the nvidia/nic drivers (southbridge/nvidia/ck804/chip.h:26): Let the device- tree tell the driver about the path to the other device. However, any generic solution that I came up with wasn't very user friendly (for the dt author).
Hence my current approach: let the consuming code define the name and a devicetree using that code should follow (sorry for the brief commit message, I was too much in a hurry).
When should someone use the 1 variant vs the 2 variant?
I'm not sure where you are going...
Should we allow common code (soc/) changes to refer to names in mainboard devicetrees?
I would they yes, but only where necessary. Integrated devices are known to soc/ code anyway, so naming them in the dt explicitly would be a useless exercise.
Do you envision this approach proliferating?
Nope. It seems very rarely necessary to cross reference devices, dev_find_slot_on_smbus() has been there for a long time and has only 2 use cases.
https://review.coreboot.org/c/coreboot/+/35456/1/util/sconfig/main.c File util/sconfig/main.c:
https://review.coreboot.org/c/coreboot/+/35456/1/util/sconfig/main.c@1410 PS1, Line 1410: outputf[strlen(outputf) - 1] = 'h';
Looks like this patch is also making a new file. […]
Ack, will mention it (and most likely make it more obvious with another command-line parameter).
Hello Kyösti Mälkki, Aaron Durbin, Patrick Rudolph, Felix Held, Julius Werner, Arthur Heymans, build bot (Jenkins), Furquan Shaikh, Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/35456
to look at the new patch set (#2).
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
[RFC] sconfig: Allow to give static device nodes a name
Rarely, the driver of one device needs to know about another device that can be anywhere in the device hierarchy. Current applications boil down to EEPROMs that store information that is consumed by some code (e.g. MAC address, SMBIOS data).
The idea is to give device nodes in the `devicetree.cb` a name that can later be used in C code to identify the device (without having to look it up by fragile means). For this, we add an optional `as <identifier>` to the device declaration, for instance:
device i2c 0x50 as serial_eeprom on end
This leads to a `struct device __static_serial_eeprom;` that can then be used throughout coreboot. The name should actually be defined by the code that is using the device.
Change-Id: I058a319f9b968924fbef9485a96c9e3f900a3ee8 Signed-off-by: Nico Huber nico.huber@secunet.com --- M Makefile.inc M util/sconfig/lex.yy.c_shipped M util/sconfig/main.c M util/sconfig/sconfig.h M util/sconfig/sconfig.l M util/sconfig/sconfig.tab.c_shipped M util/sconfig/sconfig.tab.h_shipped M util/sconfig/sconfig.y 8 files changed, 589 insertions(+), 505 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/56/35456/2
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
Patch Set 2:
Thinking further about this, we already include `chip.h` files. Those might be a better place to provide the external declaration; wouldn't need a header file along `static.c` and would shift error messages towards the dt (a typo in the dt would result in an error when compiling `static.c` instead of the code that is using the device, what I did here ._.)
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG@16 PS1, Line 16: _static_serial_eeprom
What are your thoughts in promoting the name defined in devicetree as a global symbol w/o the hierarchy information? My concern is around having multiples of certain things and then we have something1 and something2 and those symbols baked into the code.
The problem with hierarchy information is how to communicate it. The cases where dev_find_slot_on_smbus() is used (with fragile bus numbers), show that there is a need to tell the driver of one device (or framework code, e.g. SMBIOS) about another device that can be anywhere.
I was first thinking about something like what is currently done in the nvidia/nic drivers (southbridge/nvidia/ck804/chip.h:26): Let the device- tree tell the driver about the path to the other device. However, any generic solution that I came up with wasn't very user friendly (for the dt author).
Hence my current approach: let the consuming code define the name and a devicetree using that code should follow (sorry for the brief commit message, I was too much in a hurry).
When should someone use the 1 variant vs the 2 variant?
I'm not sure where you are going...
I was speculating about how/when to use right name. Basically. code in drivers/ would have a hard time using this feature, and I suspect we should push back against the usage there.
Should we allow common code (soc/) changes to refer to names in mainboard devicetrees?
I would they yes, but only where necessary. Integrated devices are known to soc/ code anyway, so naming them in the dt explicitly would be a useless exercise.
Seems like one would use this solely within mainboard or soc and just declare consistency in naming in usage. I'm ok with that. I did want to understand your thinking of direction here as it sets context of future intent.
Do you envision this approach proliferating?
Nope. It seems very rarely necessary to cross reference devices, dev_find_slot_on_smbus() has been there for a long time and has only 2 use cases.
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
Patch Set 2:
I only had a brief look for now. Auto-generated static.h was something I commented as missing in CB:31933 patchset #5, this seems to add it, thanks.
For PCI devices, I was hoping we could have a template file under soc/ that defines such "static device node names" for all integrated devices (PCI bus 0, essentially). I think such approach would help us remove the defines in soc/pci_devs.h that eg. map XHCI0 to PCI 0:10.0.
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
Patch Set 2:
I only had a brief look for now. Auto-generated static.h was something I commented as missing in CB:31933 patchset #5, this seems to add it, thanks.
Right. If that is generally useful, I'll split it out of this change.
For PCI devices, I was hoping we could have a template file under soc/ that defines such "static device node names" for all integrated devices (PCI bus 0, essentially). I think such approach would help us remove the defines in soc/pci_devs.h that eg. map XHCI0 to PCI 0:10.0.
Do I understand this right, an additional template file that is passed to sconfig? And sconfig would then emit e.g. `xhci0_dev` instead of or additionally to `__pci_0_14_0`?
I had a rather simple `pci_devs.h` in mind, that would just #define the names, e.g.
#include <static.h> #define pch_dev_xhci __pci_0_14_0
Not that I put much thought into it, just how I imagined it.
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
Patch Set 2:
To solve my original problem, I have a more elaborate scheme in mind now:
The piece of code that consumes the device reference would have to be a driver that is hooked up as a `chip` in the dt. In the `chip.h` we'd declare the device reference as part of the config struct, e.g.:
struct some_chip_driver_config { DEVTREE_CONST struct device *needed_eeprom; };
Now in the dt, we'd name the referenced device, but only for sconfig's internal use:
device i2c 0x50 alias my_eeprom on end
The author of the dt would be free to choose this name. Later, when configuring the driver in the dt we would associate this given name with the one in the `chip.h`:
chip some/chip/driver use my_eeprom as needed_eeprom end
No global names anymore! I hope you like that, Aaron :)
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [RFC] sconfig: Allow to give static device nodes a name ......................................................................
Patch Set 2:
Patch Set 2:
To solve my original problem, I have a more elaborate scheme in mind now:
The piece of code that consumes the device reference would have to be a driver that is hooked up as a `chip` in the dt. In the `chip.h` we'd declare the device reference as part of the config struct, e.g.:
struct some_chip_driver_config { DEVTREE_CONST struct device *needed_eeprom; };
Now in the dt, we'd name the referenced device, but only for sconfig's internal use:
device i2c 0x50 alias my_eeprom on end
The author of the dt would be free to choose this name. Later, when configuring the driver in the dt we would associate this given name with the one in the `chip.h`:
chip some/chip/driver use my_eeprom as needed_eeprom end
No global names anymore! I hope you like that, Aaron :)
Meh, https://review.coreboot.org/16080 If we have code at the mainboard level that needs a device reference (e.g. smbios_mainboard_serial_number()) how could that be handled? any ideas? revert to mb/chip.h?
Hello Kyösti Mälkki, Aaron Durbin, Patrick Rudolph, Felix Held, Julius Werner, Arthur Heymans, build bot (Jenkins), Furquan Shaikh, Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/35456
to look at the new patch set (#3).
Change subject: [WIP] sconfig: Allow to link devices to other device' drivers ......................................................................
[WIP] sconfig: Allow to link devices to other device' drivers
Rarely, the driver of one device needs to know about another device that can be anywhere in the device hierarchy. Current applications boil down to EEPROMs that store information that is consumed by some code (e.g. MAC address).
The idea is to give device nodes in the `devicetree.cb` an alias that can later be used to link it to a device driver's `config` structure. The driver has to declare a field of type `struct device *`, e.g.
struct some_chip_driver_config { DEVTREE_CONST struct device *needed_eeprom; };
In the devicetree, the referenced device gets an alias, e.g.
device i2c 0x50 alias my_eeprom on end
The author of the devicetree is free to choose any alias name that is unique in the devicetree. Later, when configuring the driver the alias can be used to link the device with the field of a driver's config:
chip some/chip/driver use my_eeprom as needed_eeprom end
The current implementation should work, however lacks some features: * No checking of alias conflicts. * Order matters, as the alias is resolved when the `use` statement is parsed. * Override trees can only use their own alias for a device if none was given in the base tree.
Change-Id: I058a319f9b968924fbef9485a96c9e3f900a3ee8 Signed-off-by: Nico Huber nico.huber@secunet.com --- M util/sconfig/lex.yy.c_shipped M util/sconfig/main.c M util/sconfig/sconfig.h M util/sconfig/sconfig.l M util/sconfig/sconfig.tab.c_shipped M util/sconfig/sconfig.tab.h_shipped M util/sconfig/sconfig.y 7 files changed, 640 insertions(+), 513 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/56/35456/3
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [WIP] sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 3:
Patch Set 2:
I only had a brief look for now. Auto-generated static.h was something I commented as missing in CB:31933 patchset #5, this seems to add it, thanks.
Right. If that is generally useful, I'll split it out of this change.
For PCI devices, I was hoping we could have a template file under soc/ that defines such "static device node names" for all integrated devices (PCI bus 0, essentially). I think such approach would help us remove the defines in soc/pci_devs.h that eg. map XHCI0 to PCI 0:10.0.
Do I understand this right, an additional template file that is passed to sconfig? And sconfig would then emit e.g. `xhci0_dev` instead of or additionally to `__pci_0_14_0`?
I think that's what Kyosti meant.
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [WIP] sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 3:
Patch Set 2:
Patch Set 2:
To solve my original problem, I have a more elaborate scheme in mind now:
The piece of code that consumes the device reference would have to be a driver that is hooked up as a `chip` in the dt. In the `chip.h` we'd declare the device reference as part of the config struct, e.g.:
struct some_chip_driver_config { DEVTREE_CONST struct device *needed_eeprom; };
How does one reference this? Driver and chip binding alone?
What about all the SoC devices? We wouldn't have one reference in that case and the code would need to know what device is correct one. I think this handles your drivers/ case well, but I'm missing the SoC part. And you mention the mainboard one below.
Now in the dt, we'd name the referenced device, but only for sconfig's internal use:
device i2c 0x50 alias my_eeprom on end
The author of the dt would be free to choose this name. Later, when configuring the driver in the dt we would associate this given name with the one in the `chip.h`:
chip some/chip/driver use my_eeprom as needed_eeprom end
No global names anymore! I hope you like that, Aaron :)
It is nice that there aren't globals, but my guess is that this may be harder to do.
Meh, https://review.coreboot.org/16080 If we have code at the mainboard level that needs a device reference (e.g. smbios_mainboard_serial_number()) how could that be handled? any ideas? revert to mb/chip.h?
I was thinking in my original questioning that the names used in the mainboards and soc would just become the norm. More so in SoC -- need the consistency. Within a mainboard the namespaces shouldn't collide so they could just use whatever they want (unless one is sharing code then the names need to be consistent). The harder one is the drivers/ situation. But, is there ever a case where the drivers/ need to know a specific alias name? I think my concern is about 'common' or 'library' code utilizing/requiring consistent naming. I'm thinking that would never work and it's the responsibility of the mainboard code to obtain and send the correct reference to the common code itself.
Duncan Laurie has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 4:
I resurrected this change and added the missing features that were called out (order doesn't matter now, handle overrides, check for conflicts) because this solves a device reference problem for USB4 in a clean way and it has potential to be useful in many other situations.
With USB4 ports we need to provide a set of references to the OS (connection manager) that indicate the underlying devices where the various data streams that go to the port actually come from.
In this case the mainboard devicetree will have a number of aliases defined throughout the tree and a typec driver that collates them:
chip ec/google/chromeec/typec use typec_mlb_usb2 as usb2_port use typec_mlb_usb3 as usb3_port use typec_mlb_usb4 as usb4_port use typec_mlb_pcie as pcie_port use typec_mlb_mux as orientation_switch use typec_mlb_mux as usb_role_switch use typec_mlb_mux as mode_switch use typec_mlb_retimer as retimer0 device generic 1 on end end
And generates ACPI properties with the links:
Package () { "port-number", 1 }, Package () { "usb2-port", _SB.PCI0.XHCI.RHUB.HS10 }, Package () { "usb3-port", _SB.PCI0.TXHC.RHUB.SS02 }, Package () { "usb4-port", _SB.PCI0.TDM0.RHUB.PRTB }, Package () { "pcie-port", _SB.PCI0.TRP1 }, Package () { "orientation-switch", _SB.PCI0.PMC.MUX.CON1 }, Package () { "usb-role-switch", _SB.PCI0.PMC.MUX.CON1 }, Package () { "mode-switch", _SB.PCI0.PMC.MUX.CON1 } Package () { "retimers", Package () { _SB.PCI0.SBUS.RTM0 } },
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 4:
(5 comments)
Thanks for reviving this!
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG@36 PS4, Line 36: defined in the base tree. Changing the alias feels wrong. But we can start with this behavior and amend it if it ever fails us (e.g. make it a list of aliases?).
Alternatively, we could resolve the references right before an override tree is applied or the tree is printed out in the end. This way, aliases would have some kind of file scope.
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG@38 PS4, Line 38: conflits confli*c*ts
https://review.coreboot.org/c/coreboot/+/35456/4/util/sconfig/main.c File util/sconfig/main.c:
https://review.coreboot.org/c/coreboot/+/35456/4/util/sconfig/main.c@862 PS4, Line 862: free(alias); This looks a bit odd now that we have a copy of the pointer in the `->ref` list. I would prefer to just drop the free() or clean the whole list up (which we know isn't necessary as sconfig is nearly done).
https://review.coreboot.org/c/coreboot/+/35456/4/util/sconfig/main.c@874 PS4, Line 874: if (!dev->chip_instance->ref) Nit, technicallly this repeats the loop condition.
https://review.coreboot.org/c/coreboot/+/35456/4/util/sconfig/main.c@1716 PS4, Line 1716: walk_device_tree(autogen, autohead, &base_root_dev, update_references); Could we just do it as part of pass0()? If not, is there a reason to interleave it with the printing, or could we do it above after applying the override tree?
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 4: Code-Review+1
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG@32 PS4, Line 32: use my_eeprom as needed_eeprom What about just keeping `register` for this? It would still require a different token but it still keeps the syntax regular, implying that it's still just a field like the other registers (a const struct device * though).
`register "my_eeprom" aliases needed_eeprom` could be the above instead then.
WDYT?
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG@32 PS4, Line 32: use my_eeprom as needed_eeprom
What about just keeping `register` for this? It would still require a different token but it still k […]
It would have to be the other way around `register "needed_eeprom" ...`. I don't care much, but would prefer a syntax that is more related to the solution. If I had to decide today, I would probably use
dev needed_eeprom is my_eeprom
(having the config field on the left aligns better with the regular assignments)
TBH, I hate the `register` keyword. I can only guess it's a relict from a time when board ports were allowed to override actual register contents. Today, I believe, it discourages to implement more abstract, high-level configuration options.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG@32 PS4, Line 32: use my_eeprom as needed_eeprom
It would have to be the other way around `register "needed_eeprom" ...`. […]
I don't like `register` either. We use it for pretty much everything except for actual registers (see superio configuration using wacky irq syntax)
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG@32 PS4, Line 32: use my_eeprom as needed_eeprom
I don't like `register` either. […]
whoops, I got the names backwards, but you see my point.
I totally agree with the naming convention; `register` doesn't make any sense in general the way we use it, but I just don't see why this case should be different than any other. At the end of the day, we're just setting fields in struct blah_config.
On a related note, I would consider +2'ing a patch that changed `register` to something different 😉
Duncan Laurie has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 4:
(5 comments)
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG@32 PS4, Line 32: use my_eeprom as needed_eeprom
whoops, I got the names backwards, but you see my point. […]
'dev' seems a bit overloaded in the grammar since it already uses 'device' quite a bit.
I have a patch series that builds on this and adds a chipset provided devicetree:
``` chipset.cb: device pci 15.0 alias i2c0 off end ```
And I added 'ref' as a synonym for 'use' because it seemed odd otherwise.
This is a completely made up example to show ways to use the alias, obviously wouldn't need both for the same device.
``` devicetree.cb: device ref i2c0 on use i2c0 as my_i2c_port end ```
We could build on that and replace 'use' with 'ref' completely and invert the syntax as suggested:
``` devicetree.cb: device ref i2c0 on ref my_i2c_port is i2c0 end ```
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG@36 PS4, Line 36: defined in the base tree.
Changing the alias feels wrong. But we can start with this behavior […]
I ended up changing this, overrides can now add an alias if it does not exist but cannot change an existing one.
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG@38 PS4, Line 38: conflits
confli*c*ts
Done
https://review.coreboot.org/c/coreboot/+/35456/4/util/sconfig/main.c File util/sconfig/main.c:
https://review.coreboot.org/c/coreboot/+/35456/4/util/sconfig/main.c@862 PS4, Line 862: free(alias);
This looks a bit odd now that we have a copy of the pointer in the `->ref` […]
Done
https://review.coreboot.org/c/coreboot/+/35456/4/util/sconfig/main.c@1716 PS4, Line 1716: walk_device_tree(autogen, autohead, &base_root_dev, update_references);
Could we just do it as part of pass0()? If not, is there a reason to […]
The device names don't get created until pass0 now (this was a more recent change) so it needs to happen after pass0 as a separate step once all the devices have names to link to.
Duncan Laurie has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG@32 PS4, Line 32: use my_eeprom as needed_eeprom
'dev' seems a bit overloaded in the grammar since it already uses 'device' quite a bit. […]
Although I guess that does make the syntax inconsistent, in the first example it is 'ref i2c0' but in the second 'i2c0' is not immediately after 'ref'.
Duncan Laurie has uploaded a new patch set (#5) to the change originally created by Nico Huber. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
sconfig: Allow to link devices to other device' drivers
Rarely, the driver of one device needs to know about another device that can be anywhere in the device hierarchy. Current applications boil down to EEPROMs that store information that is consumed by some code (e.g. MAC address).
The idea is to give device nodes in the `devicetree.cb` an alias that can later be used to link it to a device driver's `config` structure. The driver has to declare a field of type `struct device *`, e.g.
struct some_chip_driver_config { DEVTREE_CONST struct device *needed_eeprom; };
In the devicetree, the referenced device gets an alias, e.g.
device i2c 0x50 alias my_eeprom on end
The author of the devicetree is free to choose any alias name that is unique in the devicetree. Later, when configuring the driver the alias can be used to link the device with the field of a driver's config:
chip some/chip/driver use my_eeprom as needed_eeprom end
Override devices can add an alias if it does not exist, but cannot change the alias for a device that already exists.
Alias names are checked for conflicts both in the base tree and in the override tree.
References are resolved after the tree is parsed so aliases and references do not need to be in a specific order in the tree.
Change-Id: I058a319f9b968924fbef9485a96c9e3f900a3ee8 Signed-off-by: Nico Huber nico.huber@secunet.com Signed-off-by: Duncan Laurie dlaurie@google.com --- M util/sconfig/lex.yy.c_shipped M util/sconfig/main.c M util/sconfig/sconfig.h M util/sconfig/sconfig.l M util/sconfig/sconfig.tab.c_shipped M util/sconfig/sconfig.tab.h_shipped M util/sconfig/sconfig.y 7 files changed, 538 insertions(+), 385 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/56/35456/5
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 5: Code-Review+1
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 6: Code-Review+2
I won't fight you anymore on the exact syntax, I think this is too useful to leave behind.
Stefan Reinauer has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 6: Code-Review+2
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 7:
(2 comments)
Two open comments left on
- representing devicetree names as global (also making them unique) - syntax
Any way to move this forward?
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG@14 PS1, Line 14: as
`named` sounds good, too. however, I believe that `as` reflects […]
Done
https://review.coreboot.org/c/coreboot/+/35456/1/util/sconfig/main.c File util/sconfig/main.c:
https://review.coreboot.org/c/coreboot/+/35456/1/util/sconfig/main.c@1410 PS1, Line 1410: outputf[strlen(outputf) - 1] = 'h';
Ack, will mention it (and most likely make it more obvious with another […]
Done
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 7:
(1 comment)
https://review.coreboot.org/c/coreboot/+/35456/7//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/7//COMMIT_MSG@7 PS7, Line 7: device' drivers device’s drivers?
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 7:
(1 comment)
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/4//COMMIT_MSG@32 PS4, Line 32: use my_eeprom as needed_eeprom
Although I guess that does make the syntax inconsistent, in the first example it is 'ref i2c0' but i […]
I drop my reservations about the syntax, I'm more interested in having this functionality.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 7: Code-Review+2
Tim Wawrzynczak has uploaded a new patch set (#8) to the change originally created by Nico Huber. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device's drivers ......................................................................
sconfig: Allow to link devices to other device's drivers
Rarely, the driver of one device needs to know about another device that can be anywhere in the device hierarchy. Current applications boil down to EEPROMs that store information that is consumed by some code (e.g. MAC address).
The idea is to give device nodes in the `devicetree.cb` an alias that can later be used to link it to a device driver's `config` structure. The driver has to declare a field of type `struct device *`, e.g.
struct some_chip_driver_config { DEVTREE_CONST struct device *needed_eeprom; };
In the devicetree, the referenced device gets an alias, e.g.
device i2c 0x50 alias my_eeprom on end
The author of the devicetree is free to choose any alias name that is unique in the devicetree. Later, when configuring the driver the alias can be used to link the device with the field of a driver's config:
chip some/chip/driver use my_eeprom as needed_eeprom end
Override devices can add an alias if it does not exist, but cannot change the alias for a device that already exists.
Alias names are checked for conflicts both in the base tree and in the override tree.
References are resolved after the tree is parsed so aliases and references do not need to be in a specific order in the tree.
Change-Id: I058a319f9b968924fbef9485a96c9e3f900a3ee8 Signed-off-by: Nico Huber nico.huber@secunet.com Signed-off-by: Duncan Laurie dlaurie@google.com --- M util/sconfig/lex.yy.c_shipped M util/sconfig/main.c M util/sconfig/sconfig.h M util/sconfig/sconfig.l M util/sconfig/sconfig.tab.c_shipped M util/sconfig/sconfig.tab.h_shipped M util/sconfig/sconfig.y 7 files changed, 538 insertions(+), 385 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/56/35456/8
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device's drivers ......................................................................
Patch Set 8:
(1 comment)
https://review.coreboot.org/c/coreboot/+/35456/7//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/7//COMMIT_MSG@7 PS7, Line 7: device' drivers
device’s drivers?
Done
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device's drivers ......................................................................
Patch Set 8:
(1 comment)
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/35456/1//COMMIT_MSG@16 PS1, Line 16: _static_serial_eeprom
What are your thoughts in promoting the name defined in devicetree as a global symbol w/o the hi […]
Chatted with Aaron, considering potentially adding a `__dont_directly_use` or similar prefix to these names to help prevent misuse by making it easier to see in code review (in a follow-up)
Tim Wawrzynczak has submitted this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: sconfig: Allow to link devices to other device's drivers ......................................................................
sconfig: Allow to link devices to other device's drivers
Rarely, the driver of one device needs to know about another device that can be anywhere in the device hierarchy. Current applications boil down to EEPROMs that store information that is consumed by some code (e.g. MAC address).
The idea is to give device nodes in the `devicetree.cb` an alias that can later be used to link it to a device driver's `config` structure. The driver has to declare a field of type `struct device *`, e.g.
struct some_chip_driver_config { DEVTREE_CONST struct device *needed_eeprom; };
In the devicetree, the referenced device gets an alias, e.g.
device i2c 0x50 alias my_eeprom on end
The author of the devicetree is free to choose any alias name that is unique in the devicetree. Later, when configuring the driver the alias can be used to link the device with the field of a driver's config:
chip some/chip/driver use my_eeprom as needed_eeprom end
Override devices can add an alias if it does not exist, but cannot change the alias for a device that already exists.
Alias names are checked for conflicts both in the base tree and in the override tree.
References are resolved after the tree is parsed so aliases and references do not need to be in a specific order in the tree.
Change-Id: I058a319f9b968924fbef9485a96c9e3f900a3ee8 Signed-off-by: Nico Huber nico.huber@secunet.com Signed-off-by: Duncan Laurie dlaurie@google.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/35456 Reviewed-by: Angel Pons th3fanbus@gmail.com Reviewed-by: Tim Wawrzynczak twawrzynczak@chromium.org Reviewed-by: Stefan Reinauer stefan.reinauer@coreboot.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M util/sconfig/lex.yy.c_shipped M util/sconfig/main.c M util/sconfig/sconfig.h M util/sconfig/sconfig.l M util/sconfig/sconfig.tab.c_shipped M util/sconfig/sconfig.tab.h_shipped M util/sconfig/sconfig.y 7 files changed, 538 insertions(+), 385 deletions(-)
Approvals: build bot (Jenkins): Verified Stefan Reinauer: Looks good to me, approved Angel Pons: Looks good to me, approved Tim Wawrzynczak: Looks good to me, approved
diff --git a/util/sconfig/lex.yy.c_shipped b/util/sconfig/lex.yy.c_shipped index 998505e..fcf5c3e 100644 --- a/util/sconfig/lex.yy.c_shipped +++ b/util/sconfig/lex.yy.c_shipped @@ -349,8 +349,8 @@ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 45 -#define YY_END_OF_BUFFER 46 +#define YY_NUM_RULES 48 +#define YY_END_OF_BUFFER 49 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -358,30 +358,31 @@ flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[195] = +static const flex_int16_t yy_accept[202] = { 0, - 0, 0, 46, 44, 1, 3, 44, 44, 44, 39, - 39, 37, 40, 44, 40, 40, 40, 40, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44, 44, 1, - 3, 44, 0, 44, 44, 0, 2, 39, 40, 44, - 44, 44, 44, 40, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 31, 44, 44, 44, 44, 44, - 44, 11, 44, 44, 44, 44, 44, 44, 44, 44, - 44, 43, 43, 44, 0, 38, 44, 44, 21, 44, - 44, 30, 35, 44, 44, 44, 44, 44, 18, 44, - 44, 29, 44, 27, 44, 44, 12, 44, 15, 17, + 0, 0, 49, 47, 1, 3, 47, 47, 47, 42, + 42, 40, 43, 47, 43, 43, 43, 43, 43, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 1, 3, 47, 0, 47, 47, 0, 2, 42, 43, + 47, 47, 47, 8, 47, 47, 43, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 34, 47, 47, + 47, 47, 47, 47, 14, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 46, 46, 47, 0, 41, 47, + 47, 47, 24, 47, 47, 33, 38, 47, 47, 47, + 47, 47, 21, 47, 47, 32, 47, 30, 47, 47,
- 44, 44, 44, 25, 44, 26, 44, 0, 41, 4, - 44, 44, 44, 28, 44, 44, 44, 44, 44, 44, - 44, 44, 24, 44, 44, 44, 44, 44, 42, 42, - 44, 44, 44, 8, 44, 44, 44, 44, 44, 19, - 44, 44, 10, 44, 44, 44, 44, 5, 22, 44, - 44, 13, 44, 16, 44, 9, 44, 44, 44, 44, - 44, 23, 33, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 6, 44, 44, 44, 7, 44, 14, 44, - 44, 44, 32, 44, 44, 20, 44, 34, 44, 44, - 44, 44, 36, 0 + 15, 47, 18, 20, 47, 47, 47, 28, 47, 29, + 7, 47, 0, 44, 47, 4, 47, 47, 47, 31, + 47, 47, 47, 47, 47, 47, 47, 47, 27, 47, + 47, 47, 47, 47, 45, 45, 6, 47, 47, 47, + 11, 47, 47, 47, 47, 47, 22, 47, 47, 13, + 47, 47, 47, 47, 5, 25, 47, 47, 16, 47, + 19, 47, 12, 47, 47, 47, 47, 47, 26, 36, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 9, + 47, 47, 47, 10, 47, 17, 47, 47, 47, 35, + 47, 47, 23, 47, 37, 47, 47, 47, 47, 39,
+ 0 } ;
static const YY_CHAR yy_ec[256] = @@ -424,134 +425,136 @@ 1, 1, 1, 1, 1, 1, 1, 1, 1 } ;
-static const flex_int16_t yy_base[202] = +static const flex_int16_t yy_base[209] = { 0, - 0, 0, 265, 0, 262, 266, 260, 38, 42, 39, - 224, 0, 45, 247, 55, 79, 61, 58, 239, 234, - 46, 54, 55, 68, 73, 237, 46, 224, 0, 254, - 266, 101, 250, 107, 111, 251, 266, 0, 108, 111, - 238, 227, 216, 117, 223, 218, 228, 217, 225, 229, - 216, 223, 223, 217, 223, 208, 208, 218, 208, 210, - 212, 0, 199, 207, 201, 201, 206, 210, 202, 208, - 207, 0, 266, 132, 219, 0, 212, 192, 205, 195, - 202, 0, 0, 193, 191, 197, 194, 194, 0, 192, - 182, 0, 186, 0, 190, 180, 0, 183, 0, 0, + 0, 0, 274, 0, 271, 275, 269, 38, 42, 39, + 233, 0, 45, 256, 55, 59, 83, 65, 62, 248, + 243, 68, 25, 48, 54, 75, 246, 75, 233, 0, + 263, 275, 106, 259, 111, 76, 260, 275, 0, 110, + 113, 247, 236, 0, 235, 224, 119, 231, 226, 236, + 225, 233, 237, 224, 231, 231, 225, 231, 216, 216, + 226, 216, 218, 220, 0, 207, 215, 209, 209, 214, + 218, 210, 216, 118, 0, 275, 135, 228, 0, 221, + 214, 200, 213, 203, 210, 0, 0, 201, 199, 205, + 202, 202, 0, 200, 190, 0, 194, 0, 198, 188,
- 189, 181, 180, 0, 171, 0, 198, 197, 0, 0, - 182, 181, 174, 0, 178, 168, 164, 174, 162, 168, - 173, 174, 0, 161, 168, 155, 158, 147, 0, 266, - 159, 163, 155, 0, 154, 156, 152, 154, 159, 0, - 143, 148, 0, 141, 141, 140, 137, 0, 0, 149, - 151, 0, 135, 152, 138, 0, 145, 136, 117, 117, - 124, 0, 0, 123, 115, 114, 112, 123, 109, 119, - 109, 101, 0, 113, 111, 115, 0, 96, 0, 92, - 82, 70, 0, 65, 77, 0, 77, 0, 71, 59, - 44, 30, 0, 266, 41, 153, 155, 157, 159, 161, + 0, 191, 0, 0, 197, 189, 188, 0, 179, 0, + 0, 206, 205, 0, 176, 0, 189, 188, 181, 0, + 185, 175, 171, 181, 169, 175, 180, 181, 0, 168, + 175, 162, 165, 154, 0, 275, 0, 166, 170, 162, + 0, 161, 163, 159, 161, 166, 0, 150, 155, 0, + 148, 148, 147, 144, 0, 0, 156, 158, 0, 142, + 159, 145, 0, 152, 156, 137, 137, 144, 0, 0, + 143, 122, 121, 119, 130, 116, 126, 116, 108, 0, + 120, 118, 123, 0, 112, 0, 113, 116, 97, 0, + 89, 86, 0, 85, 0, 75, 65, 52, 61, 0,
- 163 + 275, 48, 155, 157, 159, 161, 163, 165 } ;
-static const flex_int16_t yy_def[202] = +static const flex_int16_t yy_def[209] = { 0, - 194, 1, 194, 195, 194, 194, 195, 196, 197, 195, - 10, 195, 10, 195, 10, 10, 10, 10, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 194, - 194, 196, 198, 199, 197, 200, 194, 10, 10, 10, - 195, 195, 195, 10, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 194, 199, 201, 40, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, + 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, + 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, 202, 201, 206, 208, 41, 202, + 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, + 202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
- 195, 195, 195, 195, 195, 195, 195, 194, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 194, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 0, 194, 194, 194, 194, 194, 194, + 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,
- 194 + 0, 201, 201, 201, 201, 201, 201, 201 } ;
-static const flex_int16_t yy_nxt[306] = +static const flex_int16_t yy_nxt[315] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 10, 12, - 13, 13, 14, 4, 4, 4, 13, 13, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 4, 24, 25, - 4, 26, 27, 4, 28, 4, 4, 4, 4, 33, - 33, 29, 34, 36, 37, 38, 38, 38, 193, 39, - 39, 39, 39, 39, 53, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 57, 59, 68, 54, 55, 69, 192, 56, 42, 191, - 70, 60, 49, 58, 43, 39, 39, 39, 47, 61, - 190, 64, 189, 48, 50, 62, 188, 63, 187, 44, + 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, 34, + 34, 60, 35, 37, 38, 39, 39, 39, 30, 40, + 40, 40, 40, 40, 61, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 62, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 63, 64, 56, 37, 38, 200, + 43, 65, 45, 66, 199, 198, 52, 44, 46, 40, + 40, 40, 50, 67, 197, 57, 58, 51, 53, 59,
- 65, 186, 33, 33, 66, 72, 185, 45, 75, 75, - 46, 29, 36, 37, 39, 39, 39, 76, 76, 76, - 184, 76, 76, 39, 39, 39, 183, 76, 76, 76, - 76, 76, 76, 75, 75, 182, 107, 181, 180, 179, - 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, - 168, 167, 80, 32, 32, 35, 35, 33, 33, 74, - 74, 36, 36, 75, 75, 166, 165, 164, 163, 162, - 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, - 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, - 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, + 196, 71, 68, 47, 72, 195, 69, 34, 34, 73, + 75, 48, 78, 78, 49, 30, 40, 40, 40, 79, + 79, 79, 194, 79, 79, 40, 40, 40, 193, 79, + 79, 79, 79, 79, 79, 110, 78, 78, 111, 112, + 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, + 182, 181, 180, 179, 84, 33, 33, 36, 36, 34, + 34, 77, 77, 37, 37, 78, 78, 178, 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, 147, 146,
- 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, - 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, - 111, 110, 109, 108, 106, 105, 104, 103, 102, 101, - 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, - 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, - 79, 78, 77, 37, 73, 30, 71, 67, 52, 51, - 41, 40, 31, 30, 194, 3, 194, 194, 194, 194, - 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, - 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, - 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, + 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, 106, 105, 104, 103, + 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 83, 82, + 81, 80, 38, 76, 31, 74, 70, 55, 54, 42, + 41, 32, 31, 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,
- 194, 194, 194, 194, 194 + 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, + 201, 201, 201, 201 } ;
-static const flex_int16_t yy_chk[306] = +static const flex_int16_t yy_chk[315] = { 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, 8, - 8, 195, 8, 9, 9, 10, 10, 10, 192, 10, - 10, 13, 13, 13, 21, 10, 10, 10, 10, 10, - 10, 15, 15, 15, 18, 18, 18, 17, 17, 17, - 22, 23, 27, 21, 21, 27, 191, 21, 15, 190, - 27, 23, 18, 22, 15, 16, 16, 16, 17, 24, - 189, 25, 187, 17, 18, 24, 185, 24, 184, 16, + 8, 23, 8, 9, 9, 10, 10, 10, 202, 10, + 10, 13, 13, 13, 23, 10, 10, 10, 10, 10, + 10, 15, 15, 15, 24, 16, 16, 16, 19, 19, + 19, 18, 18, 18, 24, 25, 22, 36, 36, 199, + 15, 25, 16, 25, 198, 197, 19, 15, 16, 17, + 17, 17, 18, 26, 196, 22, 22, 18, 19, 22,
- 25, 182, 32, 32, 25, 32, 181, 16, 34, 34, - 16, 34, 35, 35, 39, 39, 39, 40, 40, 40, - 180, 40, 40, 44, 44, 44, 178, 40, 40, 40, - 40, 40, 40, 74, 74, 176, 74, 175, 174, 172, - 171, 170, 169, 168, 167, 166, 165, 164, 161, 160, - 159, 158, 44, 196, 196, 197, 197, 198, 198, 199, - 199, 200, 200, 201, 201, 157, 155, 154, 153, 151, - 150, 147, 146, 145, 144, 142, 141, 139, 138, 137, - 136, 135, 133, 132, 131, 128, 127, 126, 125, 124, - 122, 121, 120, 119, 118, 117, 116, 115, 113, 112, + 194, 28, 26, 17, 28, 192, 26, 33, 33, 28, + 33, 17, 35, 35, 17, 35, 40, 40, 40, 41, + 41, 41, 191, 41, 41, 47, 47, 47, 189, 41, + 41, 41, 41, 41, 41, 74, 77, 77, 74, 77, + 188, 187, 185, 183, 182, 181, 179, 178, 177, 176, + 175, 174, 173, 172, 47, 203, 203, 204, 204, 205, + 205, 206, 206, 207, 207, 208, 208, 171, 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, 127, 126,
- 111, 108, 107, 105, 103, 102, 101, 98, 96, 95, - 93, 91, 90, 88, 87, 86, 85, 84, 81, 80, - 79, 78, 77, 75, 71, 70, 69, 68, 67, 66, - 65, 64, 63, 61, 60, 59, 58, 57, 56, 55, - 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, - 43, 42, 41, 36, 33, 30, 28, 26, 20, 19, - 14, 11, 7, 5, 3, 194, 194, 194, 194, 194, - 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, - 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, - 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, + 125, 124, 123, 122, 121, 119, 118, 117, 115, 113, + 112, 109, 107, 106, 105, 102, 100, 99, 97, 95, + 94, 92, 91, 90, 89, 88, 85, 84, 83, 82, + 81, 80, 78, 73, 72, 71, 70, 69, 68, 67, + 66, 64, 63, 62, 61, 60, 59, 58, 57, 56, + 55, 54, 53, 52, 51, 50, 49, 48, 46, 45, + 43, 42, 37, 34, 31, 29, 27, 21, 20, 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,
- 194, 194, 194, 194, 194 + 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, + 201, 201, 201, 201 } ;
static yy_state_type yy_last_accepting_state; @@ -816,13 +819,13 @@ 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 >= 195 ) + if ( yy_current_state >= 202 ) 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] != 266 ); + while ( yy_base[yy_current_state] != 275 );
yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -870,163 +873,175 @@ YY_BREAK case 6: YY_RULE_SETUP -{return(REGISTER);} +{return(ALIAS);} YY_BREAK case 7: YY_RULE_SETUP -{return(FW_CONFIG_TABLE);} +{return(REFERENCE);} YY_BREAK case 8: YY_RULE_SETUP -{return(FW_CONFIG_FIELD);} +{return(ASSOCIATION);} YY_BREAK case 9: YY_RULE_SETUP -{return(FW_CONFIG_OPTION);} +{return(REGISTER);} YY_BREAK case 10: YY_RULE_SETUP -{return(FW_CONFIG_PROBE);} +{return(FW_CONFIG_TABLE);} YY_BREAK case 11: YY_RULE_SETUP -{yylval.number=1; return(BOOL);} +{return(FW_CONFIG_FIELD);} YY_BREAK case 12: YY_RULE_SETUP -{yylval.number=0; return(BOOL);} +{return(FW_CONFIG_OPTION);} YY_BREAK case 13: YY_RULE_SETUP -{yylval.number=3; return(STATUS);} +{return(FW_CONFIG_PROBE);} YY_BREAK case 14: YY_RULE_SETUP -{yylval.number=5; return(STATUS);} +{yylval.number=1; return(BOOL);} YY_BREAK case 15: YY_RULE_SETUP -{yylval.number=PCI; return(BUS);} +{yylval.number=0; return(BOOL);} YY_BREAK case 16: YY_RULE_SETUP -{yylval.number=IOAPIC; return(BUS);} +{yylval.number=3; return(STATUS);} YY_BREAK case 17: YY_RULE_SETUP -{yylval.number=PNP; return(BUS);} +{yylval.number=5; return(STATUS);} YY_BREAK case 18: YY_RULE_SETUP -{yylval.number=I2C; return(BUS);} +{yylval.number=PCI; return(BUS);} YY_BREAK case 19: YY_RULE_SETUP -{yylval.number=APIC; return(BUS);} +{yylval.number=IOAPIC; return(BUS);} YY_BREAK case 20: YY_RULE_SETUP -{yylval.number=CPU_CLUSTER; return(BUS);} +{yylval.number=PNP; return(BUS);} YY_BREAK case 21: YY_RULE_SETUP -{yylval.number=CPU; return(BUS);} +{yylval.number=I2C; return(BUS);} YY_BREAK case 22: YY_RULE_SETUP -{yylval.number=DOMAIN; return(BUS);} +{yylval.number=APIC; return(BUS);} YY_BREAK case 23: YY_RULE_SETUP -{yylval.number=GENERIC; return(BUS);} +{yylval.number=CPU_CLUSTER; return(BUS);} YY_BREAK case 24: YY_RULE_SETUP -{yylval.number=MMIO; return(BUS);} +{yylval.number=CPU; return(BUS);} YY_BREAK case 25: YY_RULE_SETUP -{yylval.number=SPI; return(BUS);} +{yylval.number=DOMAIN; return(BUS);} YY_BREAK case 26: YY_RULE_SETUP -{yylval.number=USB; return(BUS);} +{yylval.number=GENERIC; return(BUS);} YY_BREAK case 27: YY_RULE_SETUP -{yylval.number=LPC; return(BUS);} +{yylval.number=MMIO; return(BUS);} YY_BREAK case 28: YY_RULE_SETUP -{yylval.number=ESPI; return(BUS);} +{yylval.number=SPI; return(BUS);} YY_BREAK case 29: YY_RULE_SETUP -{yylval.number=IRQ; return(RESOURCE);} +{yylval.number=USB; return(BUS);} YY_BREAK case 30: YY_RULE_SETUP -{yylval.number=DRQ; return(RESOURCE);} +{yylval.number=LPC; return(BUS);} YY_BREAK case 31: YY_RULE_SETUP -{yylval.number=IO; return(RESOURCE);} +{yylval.number=ESPI; return(BUS);} YY_BREAK case 32: YY_RULE_SETUP -{return(IOAPIC_IRQ);} +{yylval.number=IRQ; return(RESOURCE);} YY_BREAK case 33: YY_RULE_SETUP -{return(INHERIT);} +{yylval.number=DRQ; return(RESOURCE);} YY_BREAK case 34: YY_RULE_SETUP -{return(SUBSYSTEMID);} +{yylval.number=IO; return(RESOURCE);} YY_BREAK case 35: YY_RULE_SETUP -{return(END);} +{return(IOAPIC_IRQ);} YY_BREAK case 36: YY_RULE_SETUP -{return(SLOT_DESC);} +{return(INHERIT);} YY_BREAK case 37: YY_RULE_SETUP -{return(EQUALS);} +{return(SUBSYSTEMID);} YY_BREAK case 38: YY_RULE_SETUP -{yylval.string = malloc(yyleng+1); strncpy(yylval.string, yytext, yyleng); yylval.string[yyleng]='\0'; return(NUMBER);} +{return(END);} YY_BREAK case 39: YY_RULE_SETUP -{yylval.string = malloc(yyleng+1); strncpy(yylval.string, yytext, yyleng); yylval.string[yyleng]='\0'; return(NUMBER);} +{return(SLOT_DESC);} YY_BREAK case 40: YY_RULE_SETUP -{yylval.string = malloc(yyleng+1); strncpy(yylval.string, yytext, yyleng); yylval.string[yyleng]='\0'; return(NUMBER);} +{return(EQUALS);} YY_BREAK case 41: 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 42: -/* rule 42 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(NUMBER);} YY_BREAK case 43: -/* rule 43 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(NUMBER);} YY_BREAK case 44: YY_RULE_SETUP -{yylval.string = malloc(yyleng+1); strncpy(yylval.string, yytext, yyleng); yylval.string[yyleng]='\0'; return(STRING);} +{yylval.string = malloc(yyleng+1); strncpy(yylval.string, yytext, yyleng); yylval.string[yyleng]='\0'; return(PCIINT);} YY_BREAK case 45: +/* rule 45 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 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);} + YY_BREAK +case 47: +YY_RULE_SETUP +{yylval.string = malloc(yyleng+1); strncpy(yylval.string, yytext, yyleng); yylval.string[yyleng]='\0'; return(STRING);} + YY_BREAK +case 48: YY_RULE_SETUP ECHO; YY_BREAK @@ -1326,7 +1341,7 @@ 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 >= 195 ) + if ( yy_current_state >= 202 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1354,11 +1369,11 @@ 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 >= 195 ) + if ( yy_current_state >= 202 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 194); + yy_is_jam = (yy_current_state == 201);
return yy_is_jam ? 0 : yy_current_state; } diff --git a/util/sconfig/main.c b/util/sconfig/main.c index b0c32f6..170acad 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -669,16 +669,41 @@ child->parent = parent; }
+static const struct device *find_alias(const struct device *const parent, + const char *const alias) +{ + if (parent->alias && !strcmp(parent->alias, alias)) + return parent; + + const struct bus *bus; + for (bus = parent->bus; bus; bus = bus->next_bus) { + const struct device *child; + for (child = bus->children; child; child = child->sibling) { + const struct device *const ret = find_alias(child, alias); + if (ret) + return ret; + } + } + + return NULL; +} + struct device *new_device(struct bus *parent, struct chip_instance *chip_instance, const int bustype, const char *devnum, - int status) + char *alias, int status) { char *tmp; int path_a; int path_b = 0; struct device *new_d;
+ /* Check for alias name conflicts. */ + if (alias && find_alias(&base_root_dev, alias)) { + printf("ERROR: Alias already exists: %s\n", alias); + exit(1); + } + path_a = strtol(devnum, &tmp, 16); if (*tmp == '.') { tmp++; @@ -698,6 +723,7 @@
new_d->path_a = path_a; new_d->path_b = path_b; + new_d->alias = alias;
new_d->enabled = status & 0x01; new_d->hidden = (status >> 1) & 0x01; @@ -819,6 +845,35 @@ add_reg(&chip_instance->reg, name, val); }
+void add_reference(struct chip_instance *const chip_instance, + char *const name, char *const alias) +{ + add_reg(&chip_instance->ref, name, alias); +} + +static void set_reference(struct chip_instance *const chip_instance, + char *const name, char *const alias) +{ + const struct device *const dev = find_alias(&base_root_dev, alias); + if (!dev) { + printf("ERROR: Cannot find device alias '%s'.\n", alias); + exit(1); + } + + char *const ref_name = S_ALLOC(strlen(dev->name) + 2); + sprintf(ref_name, "&%s", dev->name); + add_register(chip_instance, name, ref_name); +} + +static void update_references(FILE *file, FILE *head, struct device *dev, + struct device *next) +{ + struct reg *ref; + + for (ref = dev->chip_instance->ref; ref; ref = ref->next) + set_reference(dev->chip_instance, ref->key, ref->value); +} + void add_slot_desc(struct bus *bus, char *type, char *length, char *designation, char *data_width) { @@ -1203,16 +1258,12 @@ fprintf(fil, "};\n\n"); }
-static void emit_chips(FILE *fil) +static void emit_chip_configs(FILE *fil) { struct chip *chip = chip_header.next; struct chip_instance *instance; int chip_id;
- emit_chip_headers(fil, chip); - - fprintf(fil, "\n#define STORAGE static __unused DEVTREE_CONST\n\n"); - for (; chip; chip = chip->next) { if (!chip->chiph_exists) continue; @@ -1337,9 +1388,9 @@ * Add register to chip instance. If register is already present, then update * its value. If not, then add a new register to the chip instance. */ -static void update_register(struct chip_instance *c, struct reg *reg) +static void update_register(struct reg **const head, struct reg *reg) { - struct reg *base_reg = c->reg; + struct reg *base_reg = *head;
while (base_reg) { if (!strcmp(base_reg->key, reg->key)) { @@ -1349,7 +1400,7 @@ base_reg = base_reg->next; }
- add_register(c, reg->key, reg->value); + add_reg(head, reg->key, reg->value); }
static void override_devicetree(struct bus *base_parent, @@ -1422,6 +1473,19 @@ * | | | * +-----------------------------------------------------------------+ * | | | + * | ref | Each reference that is present in override | + * | | device is copied over to base device with | + * | | the same rules as registers. | + * | | | + * +-----------------------------------------------------------------+ + * | | | + * | alias | Base device alias is copied to override. | + * | | Override devices cannot change/remove an | + * | | existing alias, but they can add an alias | + * | | if one does not exist. | + * | | | + * +-----------------------------------------------------------------+ + * | | | * | chip_instance | Each register of chip_instance is copied | * | | over from override device to base device: | * | | 1. If register with same key is present in | @@ -1492,10 +1556,34 @@ */ struct reg *reg = override_dev->chip_instance->reg; while (reg) { - update_register(base_dev->chip_instance, reg); + update_register(&base_dev->chip_instance->reg, reg); reg = reg->next; }
+ /* Copy references just as with registers. */ + reg = override_dev->chip_instance->ref; + while (reg) { + update_register(&base_dev->chip_instance->ref, reg); + reg = reg->next; + } + + /* Check for alias name conflicts. */ + if (override_dev->alias && find_alias(&base_root_dev, override_dev->alias)) { + printf("ERROR: alias already exists: %s\n", override_dev->alias); + exit(1); + } + + /* + * Copy alias from base device. + * + * Override devices cannot change/remove an existing alias, + * but they can add an alias to a device if one does not exist yet. + */ + if (base_dev->alias) + override_dev->alias = base_dev->alias; + else + base_dev->alias = override_dev->alias; + /* * Use probe list from override device in place of base device, in order * to allow an override to remove a probe from the base device. @@ -1631,12 +1719,15 @@ fprintf(autogen, "#include <device/device.h>\n"); fprintf(autogen, "#include <device/pci.h>\n\n"); fprintf(autogen, "#include <static.h>\n"); - - emit_chips(autogen); + emit_chip_headers(autogen, chip_header.next); + fprintf(autogen, "\n#define STORAGE static __unused DEVTREE_CONST\n\n");
walk_device_tree(autogen, autohead, &base_root_dev, inherit_subsystem_ids); fprintf(autogen, "\n/* pass 0 */\n"); walk_device_tree(autogen, autohead, &base_root_dev, pass0); + walk_device_tree(autogen, autohead, &base_root_dev, update_references); + fprintf(autogen, "\n/* chip configs */\n"); + emit_chip_configs(autogen); fprintf(autogen, "\n/* pass 1 */\n"); walk_device_tree(autogen, autohead, &base_root_dev, pass1);
diff --git a/util/sconfig/sconfig.h b/util/sconfig/sconfig.h index 1bbff46..719519e 100644 --- a/util/sconfig/sconfig.h +++ b/util/sconfig/sconfig.h @@ -57,6 +57,9 @@ /* Pointer to registers for this chip. */ struct reg *reg;
+ /* Pointer to references for this chip. */ + struct reg *ref; + /* Pointer to chip of which this is instance. */ struct chip *chip;
@@ -123,6 +126,9 @@ /* Name of this device. */ char *name;
+ /* Alias of this device (for internal references) */ + char *alias; + /* Path of this device. */ char *path; int path_a; @@ -172,7 +178,7 @@ struct device *new_device(struct bus *parent, struct chip_instance *chip_instance, const int bustype, const char *devnum, - int status); + char *alias, int status);
void add_resource(struct bus *bus, int type, int index, int base);
@@ -195,6 +201,7 @@
struct chip_instance *new_chip_instance(char *path); void add_register(struct chip_instance *chip, char *name, char *val); +void add_reference(struct chip_instance *chip, char *name, char *alias);
struct fw_config_field *get_fw_config_field(const char *name);
diff --git a/util/sconfig/sconfig.l b/util/sconfig/sconfig.l index 10a86a2..0505150 100755 --- a/util/sconfig/sconfig.l +++ b/util/sconfig/sconfig.l @@ -13,6 +13,9 @@ \r?\n {linenum++;} chip {return(CHIP);} device {return(DEVICE);} +alias {return(ALIAS);} +use {return(REFERENCE);} +as {return(ASSOCIATION);} register {return(REGISTER);} fw_config {return(FW_CONFIG_TABLE);} field {return(FW_CONFIG_FIELD);} diff --git a/util/sconfig/sconfig.tab.c_shipped b/util/sconfig/sconfig.tab.c_shipped index c78f1ac..52bb79c 100644 --- a/util/sconfig/sconfig.tab.c_shipped +++ b/util/sconfig/sconfig.tab.c_shipped @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 3.5.1. */ +/* A Bison parser, made by GNU Bison 3.5.3. */
/* Bison implementation for Yacc-like parsers in C
@@ -48,7 +48,7 @@ #define YYBISON 1
/* Bison version. */ -#define YYBISON_VERSION "3.5.1" +#define YYBISON_VERSION "3.5.3"
/* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -130,42 +130,45 @@ CHIP = 258, DEVICE = 259, REGISTER = 260, - BOOL = 261, - STATUS = 262, - MANDATORY = 263, - BUS = 264, - RESOURCE = 265, - END = 266, - EQUALS = 267, - HEX = 268, - STRING = 269, - PCI = 270, - PNP = 271, - I2C = 272, - APIC = 273, - CPU_CLUSTER = 274, - CPU = 275, - DOMAIN = 276, - IRQ = 277, - DRQ = 278, - SLOT_DESC = 279, - IO = 280, - NUMBER = 281, - SUBSYSTEMID = 282, - INHERIT = 283, - IOAPIC_IRQ = 284, - IOAPIC = 285, - PCIINT = 286, - GENERIC = 287, - SPI = 288, - USB = 289, - MMIO = 290, - LPC = 291, - ESPI = 292, - FW_CONFIG_TABLE = 293, - FW_CONFIG_FIELD = 294, - FW_CONFIG_OPTION = 295, - FW_CONFIG_PROBE = 296 + ALIAS = 261, + REFERENCE = 262, + ASSOCIATION = 263, + BOOL = 264, + STATUS = 265, + MANDATORY = 266, + BUS = 267, + RESOURCE = 268, + END = 269, + EQUALS = 270, + HEX = 271, + STRING = 272, + PCI = 273, + PNP = 274, + I2C = 275, + APIC = 276, + CPU_CLUSTER = 277, + CPU = 278, + DOMAIN = 279, + IRQ = 280, + DRQ = 281, + SLOT_DESC = 282, + IO = 283, + NUMBER = 284, + SUBSYSTEMID = 285, + INHERIT = 286, + IOAPIC_IRQ = 287, + IOAPIC = 288, + PCIINT = 289, + GENERIC = 290, + SPI = 291, + USB = 292, + MMIO = 293, + LPC = 294, + ESPI = 295, + FW_CONFIG_TABLE = 296, + FW_CONFIG_FIELD = 297, + FW_CONFIG_OPTION = 298, + FW_CONFIG_PROBE = 299 }; #endif
@@ -497,19 +500,19 @@ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 58 +#define YYLAST 64
/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 42 +#define YYNTOKENS 45 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 23 +#define YYNNTS 25 /* YYNRULES -- Number of rules. */ -#define YYNRULES 44 +#define YYNRULES 48 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 75 +#define YYNSTATES 83
#define YYUNDEFTOK 2 -#define YYMAXUTOK 296 +#define YYMAXUTOK 299
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM @@ -550,18 +553,18 @@ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41 + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44 };
#if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_int8 yyrline[] = { - 0, 24, 24, 24, 24, 26, 26, 26, 26, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 30, 30, - 39, 39, 47, 47, 49, 52, 55, 58, 61, 64, - 67, 70, 74, 77, 77, 80, 80, 83, 83, 89, - 89, 95, 95, 101, 105 + 0, 24, 24, 24, 24, 26, 26, 26, 26, 26, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 30, + 30, 39, 39, 47, 49, 53, 53, 55, 58, 61, + 64, 67, 70, 73, 76, 79, 83, 86, 86, 89, + 89, 92, 92, 98, 98, 104, 104, 110, 114 }; #endif
@@ -570,18 +573,19 @@ First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "CHIP", "DEVICE", "REGISTER", "BOOL", - "STATUS", "MANDATORY", "BUS", "RESOURCE", "END", "EQUALS", "HEX", - "STRING", "PCI", "PNP", "I2C", "APIC", "CPU_CLUSTER", "CPU", "DOMAIN", - "IRQ", "DRQ", "SLOT_DESC", "IO", "NUMBER", "SUBSYSTEMID", "INHERIT", - "IOAPIC_IRQ", "IOAPIC", "PCIINT", "GENERIC", "SPI", "USB", "MMIO", "LPC", - "ESPI", "FW_CONFIG_TABLE", "FW_CONFIG_FIELD", "FW_CONFIG_OPTION", - "FW_CONFIG_PROBE", "$accept", "devtree", "chipchildren", - "devicechildren", "chip", "@1", "device", "@2", "status", "resource", - "registers", "subsystemid", "ioapic_irq", "smbios_slot_desc", - "fw_config_table", "fw_config_table_children", - "fw_config_field_children", "fw_config_field", "$@3", "$@4", "$@5", - "fw_config_option", "fw_config_probe", YY_NULLPTR + "$end", "error", "$undefined", "CHIP", "DEVICE", "REGISTER", "ALIAS", + "REFERENCE", "ASSOCIATION", "BOOL", "STATUS", "MANDATORY", "BUS", + "RESOURCE", "END", "EQUALS", "HEX", "STRING", "PCI", "PNP", "I2C", + "APIC", "CPU_CLUSTER", "CPU", "DOMAIN", "IRQ", "DRQ", "SLOT_DESC", "IO", + "NUMBER", "SUBSYSTEMID", "INHERIT", "IOAPIC_IRQ", "IOAPIC", "PCIINT", + "GENERIC", "SPI", "USB", "MMIO", "LPC", "ESPI", "FW_CONFIG_TABLE", + "FW_CONFIG_FIELD", "FW_CONFIG_OPTION", "FW_CONFIG_PROBE", "$accept", + "devtree", "chipchildren", "devicechildren", "chip", "@1", "device", + "@2", "alias", "status", "resource", "reference", "registers", + "subsystemid", "ioapic_irq", "smbios_slot_desc", "fw_config_table", + "fw_config_table_children", "fw_config_field_children", + "fw_config_field", "$@3", "$@4", "$@5", "fw_config_option", + "fw_config_probe", YY_NULLPTR }; #endif
@@ -594,11 +598,11 @@ 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296 + 295, 296, 297, 298, 299 }; # endif
-#define YYPACT_NINF (-12) +#define YYPACT_NINF (-21)
#define yypact_value_is_default(Yyn) \ ((Yyn) == YYPACT_NINF) @@ -612,14 +616,15 @@ STATE-NUM. */ static const yytype_int8 yypact[] = { - -12, 3, -12, 4, -12, -12, -12, -12, -2, -12, - -12, 8, -12, 9, 1, 14, 11, -12, -12, -12, - -12, 2, -12, 5, 17, -12, -12, -6, 10, 16, - -12, -1, -12, 18, -12, -12, -12, -12, -12, 0, - -12, 7, -12, -12, -12, -3, 19, -12, 21, 20, - 22, 28, -12, -12, -12, -12, -12, -12, -12, -12, - 31, 30, 23, 24, 33, 25, 36, 26, 27, -12, - -12, 38, -12, -12, -12 + -21, 3, -21, -4, -21, -21, -21, -21, -2, -21, + -21, 4, -21, 11, -20, 14, 6, 13, -21, -21, + -21, -21, -21, -1, -21, 2, 17, 26, -21, -21, + -10, 29, 21, 22, -21, -7, -21, 25, -21, 30, + 10, -21, -21, -6, -21, 19, -21, -21, -21, -21, + -21, -21, -21, -3, 20, -21, 33, 23, 24, 34, + -21, -21, -21, -21, -21, -21, -21, -21, 28, 37, + 27, 12, 38, 31, 40, 32, 35, -21, -21, 41, + -21, -21, -21 };
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -627,30 +632,31 @@ means the default is an error. */ static const yytype_int8 yydefact[] = { - 2, 0, 1, 0, 34, 3, 4, 18, 0, 8, - 32, 0, 33, 0, 41, 0, 0, 19, 6, 5, - 7, 39, 36, 0, 0, 37, 36, 0, 0, 0, - 36, 0, 42, 0, 35, 22, 23, 20, 25, 0, - 40, 0, 17, 38, 43, 0, 0, 21, 0, 0, - 0, 0, 10, 9, 11, 15, 12, 13, 14, 16, - 0, 0, 0, 0, 0, 0, 31, 26, 0, 44, - 24, 30, 27, 28, 29 + 2, 0, 1, 0, 38, 3, 4, 19, 0, 9, + 36, 0, 37, 0, 45, 0, 0, 0, 20, 6, + 5, 8, 7, 43, 40, 0, 0, 0, 41, 40, + 0, 23, 0, 0, 40, 0, 46, 0, 39, 0, + 0, 29, 28, 0, 44, 0, 24, 25, 26, 21, + 42, 47, 18, 0, 0, 22, 0, 0, 0, 0, + 11, 10, 12, 16, 13, 14, 15, 17, 0, 0, + 0, 0, 0, 0, 35, 30, 0, 48, 27, 34, + 31, 32, 33 };
/* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -12, -12, -12, -12, -9, -12, 12, -12, -12, -12, - 13, -12, -12, -12, -12, -12, -11, -12, -12, -12, - -12, -12, -12 + -21, -21, -21, -21, -8, -21, 8, -21, -21, -21, + -21, -21, 9, -21, -21, -21, -21, -21, -12, -21, + -21, -21, -21, -21, -21 };
/* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 1, 13, 45, 5, 9, 19, 42, 37, 54, - 20, 56, 57, 58, 6, 8, 27, 12, 30, 26, - 22, 34, 59 + -1, 1, 13, 53, 5, 9, 20, 52, 40, 49, + 62, 21, 22, 64, 65, 66, 6, 8, 30, 12, + 34, 29, 24, 38, 67 };
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -658,56 +664,59 @@ number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int8 yytable[] = { - 3, 15, 16, 2, 18, 32, 3, 46, 47, 10, - 40, 43, 3, 15, 16, 31, 35, 36, 7, 39, - 17, 48, 14, 23, 49, 24, 50, 21, 25, 29, - 38, 28, 41, 44, 33, 61, 52, 11, 51, 33, - 33, 4, 64, 65, 66, 60, 62, 69, 63, 67, - 71, 70, 74, 73, 72, 68, 0, 53, 55 + 3, 15, 16, 2, 36, 19, 3, 44, 50, 23, + 54, 55, 10, 7, 3, 15, 16, 35, 17, 47, + 48, 14, 43, 26, 56, 18, 25, 57, 28, 58, + 27, 31, 32, 37, 33, 39, 37, 37, 41, 42, + 11, 59, 45, 73, 4, 60, 76, 46, 51, 68, + 69, 72, 70, 71, 74, 77, 75, 79, 82, 0, + 78, 61, 63, 80, 81 };
static const yytype_int8 yycheck[] = { - 3, 4, 5, 0, 13, 11, 3, 10, 11, 11, - 11, 11, 3, 4, 5, 26, 6, 7, 14, 30, - 11, 24, 14, 9, 27, 14, 29, 26, 26, 12, - 14, 26, 14, 26, 40, 14, 45, 39, 41, 40, - 40, 38, 14, 12, 14, 26, 26, 14, 26, 26, - 14, 26, 14, 26, 28, 31, -1, 45, 45 + 3, 4, 5, 0, 14, 13, 3, 14, 14, 29, + 13, 14, 14, 17, 3, 4, 5, 29, 7, 9, + 10, 17, 34, 17, 27, 14, 12, 30, 29, 32, + 17, 29, 15, 43, 8, 6, 43, 43, 17, 17, + 42, 44, 17, 15, 41, 53, 34, 17, 29, 29, + 17, 17, 29, 29, 17, 17, 29, 17, 17, -1, + 29, 53, 53, 31, 29 };
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_int8 yystos[] = { - 0, 43, 0, 3, 38, 46, 56, 14, 57, 47, - 11, 39, 59, 44, 14, 4, 5, 11, 46, 48, - 52, 26, 62, 9, 14, 26, 61, 58, 26, 12, - 60, 58, 11, 40, 63, 6, 7, 50, 14, 58, - 11, 14, 49, 11, 26, 45, 10, 11, 24, 27, - 29, 41, 46, 48, 51, 52, 53, 54, 55, 64, - 26, 14, 26, 26, 14, 12, 14, 26, 31, 14, - 26, 14, 28, 26, 14 + 0, 46, 0, 3, 41, 49, 61, 17, 62, 50, + 14, 42, 64, 47, 17, 4, 5, 7, 14, 49, + 51, 56, 57, 29, 67, 12, 17, 17, 29, 66, + 63, 29, 15, 8, 65, 63, 14, 43, 68, 6, + 53, 17, 17, 63, 14, 17, 17, 9, 10, 54, + 14, 29, 52, 48, 13, 14, 27, 30, 32, 44, + 49, 51, 55, 57, 58, 59, 60, 69, 29, 17, + 29, 29, 17, 15, 17, 29, 34, 17, 29, 17, + 31, 29, 17 };
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_int8 yyr1[] = { - 0, 42, 43, 43, 43, 44, 44, 44, 44, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 47, 46, - 49, 48, 50, 50, 51, 52, 53, 53, 54, 55, - 55, 55, 56, 57, 57, 58, 58, 60, 59, 61, - 59, 62, 59, 63, 64 + 0, 45, 46, 46, 46, 47, 47, 47, 47, 47, + 48, 48, 48, 48, 48, 48, 48, 48, 48, 50, + 49, 52, 51, 53, 53, 54, 54, 55, 56, 57, + 58, 58, 59, 60, 60, 60, 61, 62, 62, 63, + 63, 65, 64, 66, 64, 67, 64, 68, 69 };
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_int8 yyr2[] = { - 0, 2, 0, 2, 2, 2, 2, 2, 0, 2, - 2, 2, 2, 2, 2, 2, 2, 0, 0, 5, - 0, 7, 1, 1, 4, 4, 3, 4, 4, 5, - 4, 3, 3, 2, 0, 2, 0, 0, 7, 0, - 6, 0, 5, 3, 3 + 0, 2, 0, 2, 2, 2, 2, 2, 2, 0, + 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, + 5, 0, 8, 0, 2, 1, 1, 4, 4, 4, + 3, 4, 4, 5, 4, 3, 3, 2, 0, 2, + 0, 0, 7, 0, 6, 0, 5, 3, 3 };
@@ -1406,7 +1415,7 @@ { cur_parent = root_parent; } break;
- case 18: + case 19: { (yyval.chip_instance) = new_chip_instance((yyvsp[0].string)); chip_enqueue_tail(cur_chip_instance); @@ -1414,96 +1423,112 @@ } break;
- case 19: + case 20: { cur_chip_instance = chip_dequeue_tail(); } break;
- case 20: - { - (yyval.dev) = new_device(cur_parent, cur_chip_instance, (yyvsp[-2].number), (yyvsp[-1].string), (yyvsp[0].number)); + case 21: + { + (yyval.dev) = new_device(cur_parent, cur_chip_instance, (yyvsp[-3].number), (yyvsp[-2].string), (yyvsp[-1].string), (yyvsp[0].number)); cur_parent = (yyval.dev)->last_bus; } break;
- case 21: + case 22: { cur_parent = (yyvsp[-2].dev)->parent; } break;
+ case 23: + { + (yyval.string) = NULL; +} + break; + case 24: - { add_resource(cur_parent, (yyvsp[-3].number), strtol((yyvsp[-2].string), NULL, 0), strtol((yyvsp[0].string), NULL, 0)); } - break; - - case 25: - { add_register(cur_chip_instance, (yyvsp[-2].string), (yyvsp[0].string)); } - break; - - case 26: - { add_pci_subsystem_ids(cur_parent, strtol((yyvsp[-1].string), NULL, 16), strtol((yyvsp[0].string), NULL, 16), 0); } + { + (yyval.string) = (yyvsp[0].string); +} break;
case 27: - { add_pci_subsystem_ids(cur_parent, strtol((yyvsp[-2].string), NULL, 16), strtol((yyvsp[-1].string), NULL, 16), 1); } + { add_resource(cur_parent, (yyvsp[-3].number), strtol((yyvsp[-2].string), NULL, 0), strtol((yyvsp[0].string), NULL, 0)); } break;
case 28: - { add_ioapic_info(cur_parent, strtol((yyvsp[-2].string), NULL, 16), (yyvsp[-1].string), strtol((yyvsp[0].string), NULL, 16)); } + { add_reference(cur_chip_instance, (yyvsp[0].string), (yyvsp[-2].string)); } break;
case 29: - { add_slot_desc(cur_parent, (yyvsp[-3].string), (yyvsp[-2].string), (yyvsp[-1].string), (yyvsp[0].string)); } + { add_register(cur_chip_instance, (yyvsp[-2].string), (yyvsp[0].string)); } break;
case 30: - { add_slot_desc(cur_parent, (yyvsp[-2].string), (yyvsp[-1].string), (yyvsp[0].string), NULL); } + { add_pci_subsystem_ids(cur_parent, strtol((yyvsp[-1].string), NULL, 16), strtol((yyvsp[0].string), NULL, 16), 0); } break;
case 31: - { add_slot_desc(cur_parent, (yyvsp[-1].string), (yyvsp[0].string), NULL, NULL); } + { add_pci_subsystem_ids(cur_parent, strtol((yyvsp[-2].string), NULL, 16), strtol((yyvsp[-1].string), NULL, 16), 1); } break;
case 32: + { add_ioapic_info(cur_parent, strtol((yyvsp[-2].string), NULL, 16), (yyvsp[-1].string), strtol((yyvsp[0].string), NULL, 16)); } + break; + + case 33: + { add_slot_desc(cur_parent, (yyvsp[-3].string), (yyvsp[-2].string), (yyvsp[-1].string), (yyvsp[0].string)); } + break; + + case 34: + { add_slot_desc(cur_parent, (yyvsp[-2].string), (yyvsp[-1].string), (yyvsp[0].string), NULL); } + break; + + case 35: + { add_slot_desc(cur_parent, (yyvsp[-1].string), (yyvsp[0].string), NULL, NULL); } + break; + + case 36: { } break;
- case 37: + case 41: { cur_field = new_fw_config_field((yyvsp[-2].string), strtoul((yyvsp[-1].string), NULL, 0), strtoul((yyvsp[0].string), NULL, 0)); } break;
- case 38: - { } - break; - - case 39: - { - cur_field = new_fw_config_field((yyvsp[-1].string), strtoul((yyvsp[0].string), NULL, 0), strtoul((yyvsp[0].string), NULL, 0)); -} - break; - - case 40: - { } - break; - - case 41: - { - cur_field = get_fw_config_field((yyvsp[0].string)); -} - break; - case 42: { } break;
case 43: - { add_fw_config_option(cur_field, (yyvsp[-1].string), strtoul((yyvsp[0].string), NULL, 0)); } + { + cur_field = new_fw_config_field((yyvsp[-1].string), strtoul((yyvsp[0].string), NULL, 0), strtoul((yyvsp[0].string), NULL, 0)); +} break;
case 44: + { } + break; + + case 45: + { + cur_field = get_fw_config_field((yyvsp[0].string)); +} + break; + + case 46: + { } + break; + + case 47: + { add_fw_config_option(cur_field, (yyvsp[-1].string), strtoul((yyvsp[0].string), NULL, 0)); } + break; + + case 48: { add_fw_config_probe(cur_parent, (yyvsp[-1].string), (yyvsp[0].string)); } break;
diff --git a/util/sconfig/sconfig.tab.h_shipped b/util/sconfig/sconfig.tab.h_shipped index cadd847..b556bba 100644 --- a/util/sconfig/sconfig.tab.h_shipped +++ b/util/sconfig/sconfig.tab.h_shipped @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 3.5.1. */ +/* A Bison parser, made by GNU Bison 3.5.3. */
/* Bison interface for Yacc-like parsers in C
@@ -52,42 +52,45 @@ CHIP = 258, DEVICE = 259, REGISTER = 260, - BOOL = 261, - STATUS = 262, - MANDATORY = 263, - BUS = 264, - RESOURCE = 265, - END = 266, - EQUALS = 267, - HEX = 268, - STRING = 269, - PCI = 270, - PNP = 271, - I2C = 272, - APIC = 273, - CPU_CLUSTER = 274, - CPU = 275, - DOMAIN = 276, - IRQ = 277, - DRQ = 278, - SLOT_DESC = 279, - IO = 280, - NUMBER = 281, - SUBSYSTEMID = 282, - INHERIT = 283, - IOAPIC_IRQ = 284, - IOAPIC = 285, - PCIINT = 286, - GENERIC = 287, - SPI = 288, - USB = 289, - MMIO = 290, - LPC = 291, - ESPI = 292, - FW_CONFIG_TABLE = 293, - FW_CONFIG_FIELD = 294, - FW_CONFIG_OPTION = 295, - FW_CONFIG_PROBE = 296 + ALIAS = 261, + REFERENCE = 262, + ASSOCIATION = 263, + BOOL = 264, + STATUS = 265, + MANDATORY = 266, + BUS = 267, + RESOURCE = 268, + END = 269, + EQUALS = 270, + HEX = 271, + STRING = 272, + PCI = 273, + PNP = 274, + I2C = 275, + APIC = 276, + CPU_CLUSTER = 277, + CPU = 278, + DOMAIN = 279, + IRQ = 280, + DRQ = 281, + SLOT_DESC = 282, + IO = 283, + NUMBER = 284, + SUBSYSTEMID = 285, + INHERIT = 286, + IOAPIC_IRQ = 287, + IOAPIC = 288, + PCIINT = 289, + GENERIC = 290, + SPI = 291, + USB = 292, + MMIO = 293, + LPC = 294, + ESPI = 295, + FW_CONFIG_TABLE = 296, + FW_CONFIG_FIELD = 297, + FW_CONFIG_OPTION = 298, + FW_CONFIG_PROBE = 299 }; #endif
diff --git a/util/sconfig/sconfig.y b/util/sconfig/sconfig.y index 57e939d..d441ff8 100755 --- a/util/sconfig/sconfig.y +++ b/util/sconfig/sconfig.y @@ -19,11 +19,11 @@ int number; }
-%token CHIP DEVICE REGISTER BOOL STATUS MANDATORY BUS RESOURCE END EQUALS HEX STRING PCI PNP I2C APIC CPU_CLUSTER CPU DOMAIN IRQ DRQ SLOT_DESC IO NUMBER SUBSYSTEMID INHERIT IOAPIC_IRQ IOAPIC PCIINT GENERIC SPI USB MMIO LPC ESPI FW_CONFIG_TABLE FW_CONFIG_FIELD FW_CONFIG_OPTION FW_CONFIG_PROBE +%token CHIP DEVICE REGISTER ALIAS REFERENCE ASSOCIATION BOOL STATUS MANDATORY BUS RESOURCE END EQUALS HEX STRING PCI PNP I2C APIC CPU_CLUSTER CPU DOMAIN IRQ DRQ SLOT_DESC IO NUMBER SUBSYSTEMID INHERIT IOAPIC_IRQ IOAPIC PCIINT GENERIC SPI USB MMIO LPC ESPI FW_CONFIG_TABLE FW_CONFIG_FIELD FW_CONFIG_OPTION FW_CONFIG_PROBE %% devtree: { cur_parent = root_parent; } | devtree chip | devtree fw_config_table;
-chipchildren: chipchildren device | chipchildren chip | chipchildren registers | /* empty */ ; +chipchildren: chipchildren device | chipchildren chip | chipchildren registers | chipchildren reference | /* empty */ ;
devicechildren: devicechildren device | devicechildren chip | devicechildren resource | devicechildren subsystemid | devicechildren ioapic_irq | devicechildren smbios_slot_desc | devicechildren registers | devicechildren fw_config_probe | /* empty */ ;
@@ -36,12 +36,18 @@ cur_chip_instance = chip_dequeue_tail(); };
-device: DEVICE BUS NUMBER /* == devnum */ status { - $<dev>$ = new_device(cur_parent, cur_chip_instance, $<number>2, $<string>3, $<number>4); +device: DEVICE BUS NUMBER /* == devnum */ alias status { + $<dev>$ = new_device(cur_parent, cur_chip_instance, $<number>2, $<string>3, $<string>4, $<number>5); cur_parent = $<dev>$->last_bus; } devicechildren END { - cur_parent = $<dev>5->parent; + cur_parent = $<dev>6->parent; +}; + +alias: /* empty */ { + $<string>$ = NULL; +} | ALIAS STRING { + $<string>$ = $<string>2; };
status: BOOL | STATUS ; @@ -49,6 +55,9 @@ resource: RESOURCE NUMBER /* == resnum */ EQUALS NUMBER /* == resval */ { add_resource(cur_parent, $<number>1, strtol($<string>2, NULL, 0), strtol($<string>4, NULL, 0)); } ;
+reference: REFERENCE STRING /* == alias */ ASSOCIATION STRING /* == field in chip config */ + { add_reference(cur_chip_instance, $<string>4, $<string>2); } ; + registers: REGISTER STRING /* == regname */ EQUALS STRING /* == regval */ { add_register(cur_chip_instance, $<string>2, $<string>4); } ;