:: commit c936305f3765d961aea5877ec62414d52cefa4cb

Kacper Słomiński <kacper.slominski72@gmail.com> — 2024-06-28 02:29

parents: 32a94cd9b8

protos/limine: Find device tree using helper function

diff --git a/common/protos/limine.c b/common/protos/limine.c
index b63f7ab0..473ab5ab 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -691,27 +691,14 @@ FEAT_START
     }
 
 #if defined (UEFI)
-    // TODO: Looking for the DTB should be moved out of here and into lib/, because:
-    // 1. We will need it for core bring-up for the SMP request.
-    // 2. We will need to patch it for the Linux boot protocol to set the initramfs
-    //    and boot arguments.
-    // 3. If Limine is ported to platforms that use a DTB but do not use UEFI, it will
-    //    need to be found in a different way.
-    const EFI_GUID dtb_guid = EFI_DTB_TABLE_GUID;
-
-    // Look for the DTB in the configuration tables
-    for (size_t i = 0; i < gST->NumberOfTableEntries; i++) {
-        EFI_CONFIGURATION_TABLE *cur_table = &gST->ConfigurationTable[i];
-
-        if (memcmp(&cur_table->VendorGuid, &dtb_guid, sizeof(EFI_GUID)) == 0) {
-            struct limine_dtb_response *dtb_response =
-                ext_mem_alloc(sizeof(struct limine_dtb_response));
-            dtb_response->dtb_ptr = reported_addr((void *)cur_table->VendorTable);
-            dtb_request->response = reported_addr(dtb_response);
-            break;
-        }
-    }
+    void *dtb = get_device_tree_blob(0);
 
+    if (dtb) {
+        struct limine_dtb_response *dtb_response =
+            ext_mem_alloc(sizeof(struct limine_dtb_response));
+        dtb_response->dtb_ptr = reported_addr(dtb);
+        dtb_request->response = reported_addr(dtb_response);
+    }
 #endif
 
 FEAT_END
tab: 248 wrap: offon