misc: Simplifications after 945c43de0 and e721cecc2
diff --git a/common/lib/misc.c b/common/lib/misc.c
index a692e85d..5013b5bf 100644
--- a/common/lib/misc.c
+++ b/common/lib/misc.c
@@ -111,8 +111,6 @@ uint32_t hex2bin(uint8_t *str, uint32_t size) {
return value;
}
-#if defined (UEFI)
-
void *get_device_tree_blob(const char *config, size_t extra_size) {
int ret;
@@ -133,6 +131,7 @@ void *get_device_tree_blob(const char *config, size_t extra_size) {
}
}
+#if defined (UEFI)
if (!dtb) {
EFI_GUID dtb_guid = EFI_DTB_TABLE_GUID;
for (size_t i = 0; i < gST->NumberOfTableEntries; i++) {
@@ -144,6 +143,7 @@ void *get_device_tree_blob(const char *config, size_t extra_size) {
break;
}
}
+#endif
if (extra_size == 0) {
return dtb;
@@ -188,6 +188,8 @@ void *get_device_tree_blob(const char *config, size_t extra_size) {
return dtb;
}
+#if defined (UEFI)
+
#if defined (__riscv)
RISCV_EFI_BOOT_PROTOCOL *get_riscv_boot_protocol(void) {
diff --git a/common/lib/misc.h b/common/lib/misc.h
index 8e27023c..f1790c53 100644
--- a/common/lib/misc.h
+++ b/common/lib/misc.h
@@ -26,9 +26,9 @@ extern UINT32 efi_desc_ver;
extern bool efi_boot_services_exited;
bool efi_exit_boot_services(void);
+#endif
void *get_device_tree_blob(const char *config, size_t extra_size);
-#endif
extern struct volume *boot_volume;
diff --git a/common/menu.c b/common/menu.c
index 18405626..fd623691 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -1174,6 +1174,10 @@ timeout_aborted:
}
noreturn void boot(char *config) {
+#if defined (__riscv)
+ init_riscv(config);
+#endif
+
char *cmdline = config_get_value(config, 0, "KERNEL_CMDLINE");
if (!cmdline) {
cmdline = config_get_value(config, 0, "CMDLINE");
diff --git a/common/protos/limine.c b/common/protos/limine.c
index 67d9476e..0b713df7 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -405,10 +405,6 @@ static void *_get_request(uint64_t id[4]) {
#define FEAT_END } while (0);
noreturn void limine_load(char *config, char *cmdline) {
-#if defined (__riscv)
- init_riscv(config);
-#endif
-
#if defined (__x86_64__) || defined (__i386__)
uint32_t eax, ebx, ecx, edx;
#endif
@@ -1007,23 +1003,7 @@ FEAT_START
break; // next feature
}
- void *dtb = NULL;
- char *dtb_path = config_get_value(config, 0, "DTB_PATH");
-
- if (dtb_path) {
- struct file_handle *dtb_file;
- if ((dtb_file = uri_open(dtb_path)) == NULL)
- panic(true, "limine: Failed to open device tree blob with path `%#`. Is the path correct?", dtb_path);
-
- dtb = freadall(dtb_file, MEMMAP_BOOTLOADER_RECLAIMABLE);
- fclose(dtb_file);
- } else {
-#if defined (UEFI)
- dtb = get_device_tree_blob(config, 0);
-#else
- break;
-#endif
- }
+ void *dtb = get_device_tree_blob(config, 0);
if (dtb) {
// Delete all /memory@... nodes.
@@ -1050,7 +1030,6 @@ FEAT_START
dtb_response->dtb_ptr = reported_addr(dtb);
dtb_request->response = reported_addr(dtb_response);
}
-
FEAT_END
// Stack size
