[fdt] Allow paths and aliases to be terminated with separator characters

Non-permitted name characters such as a colon are sometimes used to
separate alias names or paths from additional metadata, such as the
baud rate for a UART in the "/chosen/stdout-path" property.

Support the use of such alias names and paths by allowing any
character not permitted in a property name to terminate a property or
node name match.  (This is a very relaxed matching rule that will
produce false positive matches on invalid input, but this is unlikely
to cause problems in practice.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-06-11 16:08:42 +01:00
parent 1de3aef78c
commit 7e96e5f2ef
2 changed files with 37 additions and 9 deletions

View File

@@ -213,6 +213,10 @@ static void fdt_test_exec ( void ) {
ok ( strcmp ( string, "sifive,uart0" ) == 0 );
ok ( fdt_path ( &fdt, "/nonexistent", &offset ) != 0 );
ok ( fdt_path ( &fdt, "/cpus/nonexistent", &offset ) != 0 );
ok ( fdt_path ( &fdt, "/soc/serial@10010000:115200n8",
&offset ) == 0 );
ok ( ( string = fdt_string ( &fdt, offset, "compatible" ) ) != NULL );
ok ( strcmp ( string, "sifive,uart0" ) == 0 );
/* Verify 64-bit integer properties */
ok ( fdt_u64 ( &fdt, 0, "#address-cells", &u64 ) == 0 );
@@ -249,6 +253,9 @@ static void fdt_test_exec ( void ) {
ok ( ( string = fdt_string ( &fdt, offset, "compatible" ) ) != NULL );
ok ( strcmp ( string, "sifive,uart0" ) == 0 );
ok ( fdt_alias ( &fdt, "nonexistent0", &offset ) != 0 );
ok ( fdt_alias ( &fdt, "ethernet0:params", &offset ) == 0 );
ok ( ( string = fdt_string ( &fdt, offset, "phy-mode" ) ) != NULL );
ok ( strcmp ( string, "gmii" ) == 0 );
/* Verify node description */
ok ( fdt_path ( &fdt, "/memory@80000000", &offset ) == 0 );