efi_selftest: check for RISC-V boot-hartid in FDT
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 17 Sep 2020 05:33:29 +0000 (07:33 +0200)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Fri, 18 Sep 2020 20:23:58 +0000 (22:23 +0200)
On RISC-V check that the /chosen node has a boot-hartid property.

To run the test configure with CONFIG_CMD_BOOTEFI_SELFTEST=y and issue

    setenv efi_selftest device tree
    setenv serial# myserial
    bootefi selftest

If the test succeeds, it reports the boot-hartid, e.g.

    boot-hartid: 1

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/efi_selftest/efi_selftest_fdt.c

index 52a9630..eae9820 100644 (file)
@@ -219,6 +219,21 @@ static int execute(void)
                        return EFI_ST_FAILURE;
                }
        }
+       str = get_property(L"boot-hartid", L"chosen");
+       if (IS_ENABLED(CONFIG_RISCV)) {
+               if (str) {
+                       efi_st_printf("boot-hartid: %u\n",
+                                     f2h(*(fdt32_t *)str));
+                       ret = boottime->free_pool(str);
+                       if (ret != EFI_SUCCESS) {
+                               efi_st_error("FreePool failed\n");
+                               return EFI_ST_FAILURE;
+                       }
+               } else {
+                       efi_st_error("boot-hartid not found\n");
+                       return EFI_ST_FAILURE;
+               }
+       }
 
        return EFI_ST_SUCCESS;
 }