ACPI/PCI: Improved output
authorLukas Humbel <lukas.humbel@inf.ethz.ch>
Tue, 17 May 2016 11:55:34 +0000 (13:55 +0200)
committerLukas Humbel <lukas.humbel@inf.ethz.ch>
Tue, 17 May 2016 14:51:48 +0000 (16:51 +0200)
Signed-off-by: Lukas Humbel <lukas.humbel@inf.ethz.ch>

errors/errno.fugu
usr/acpi/acpi.c
usr/acpi/acpi_service.c
usr/acpi/acpi_shared.h
usr/pci/pci.c

index 99bd7ea..c11a35a 100755 (executable)
@@ -798,6 +798,8 @@ errors pci PCI_ERR_ {
 errors acpi ACPI_ERR_ {
     failure NO_MCFG_TABLE       "No MCFG Table found.",
     failure INVALID_PATH_NAME   "Invalid ACPI path name.",
+    failure INVALID_HANDLE      "Invalid ACPI handle.",
+    failure NO_CHILD_BRIDGE     "No matching child bridge found.",
     failure GET_RESOURCES       "Failed to execute _CRT method.",
     failure SET_IRQ             "Failed to set IRQ for device.",
     failure NO_MADT_TABLE       "No APIC found in ACPI.",
index e1acbbe..ed68a27 100644 (file)
@@ -432,7 +432,7 @@ static void get_irq_routing(ACPI_HANDLE handle, uint8_t bus)
     }
 }
 
-void acpi_get_irqtable_device(ACPI_HANDLE parent,
+errval_t acpi_get_irqtable_device(ACPI_HANDLE parent,
         acpi_pci_address_t device, ACPI_HANDLE *child, uint8_t bus)
 {
 /*     char b[128]; */
@@ -442,23 +442,25 @@ void acpi_get_irqtable_device(ACPI_HANDLE parent,
     *child = NULL;
 
     if(parent == NULL) {
-        return;
+        return ACPI_ERR_INVALID_PATH_NAME;
     }
 
 /*     s = AcpiGetName(parent, ACPI_FULL_PATHNAME, &buf); */
 /*     assert(ACPI_SUCCESS(s)); */
 /*     printf("Parent: %s\n", b); */
 
+    // For each children of parent
     for(;;) {
         ACPI_STATUS as =
             AcpiGetNextObject(ACPI_TYPE_DEVICE, parent, *child, child);
 
         if(as == AE_NOT_FOUND || *child == NULL) {
-            return;
+            ACPI_DEBUG("No matching child bridge found.\n");
+            return ACPI_ERR_NO_CHILD_BRIDGE;
         }
 
         if(ACPI_FAILURE(as)) {
-            ACPI_DEBUG("Error looking up ACPI children\n");
+            ACPI_DEBUG("Error looking up ACPI children.\n");
             abort();
         }
 
@@ -473,6 +475,7 @@ void acpi_get_irqtable_device(ACPI_HANDLE parent,
         ACPI_INTEGER addr;
         as = acpi_eval_integer(*child, "_ADR", &addr);
         if (ACPI_FAILURE(as)) {
+            ACPI_DEBUG("No _ADR method found !?!.\n");
             continue;
         }
 
@@ -483,10 +486,12 @@ void acpi_get_irqtable_device(ACPI_HANDLE parent,
 
         if(device.device == bridgeaddr.device
            && device.function == bridgeaddr.function) {
-/*             printf("Found corresponding ACPI bridge device!\n"); */
             get_irq_routing(*child, bus);
+            return SYS_ERR_OK;
         }
     }
+    ACPI_DEBUG("No matching child bridge found.\n");
+    return ACPI_ERR_NO_CHILD_BRIDGE;
 }
 
 static ACPI_STATUS add_pci_lnk_device(ACPI_HANDLE handle, UINT32 level,
index 70b3287..ee87d91 100644 (file)
@@ -135,7 +135,8 @@ static void get_path_name(ACPI_HANDLE handle, char* name, size_t len)
 static void read_irq_table(struct acpi_binding* b, char* pathname,
         acpi_pci_address_t addr, uint8_t bus)
 {
-    ACPI_DEBUG("read_irq_table: %s\n", pathname);
+    ACPI_DEBUG("read_irq_table: (parent)%s, (%"PRIu8",%"PRIu8",%"PRIu8"), %"PRIu8"\n",
+            pathname, addr.bus, addr.device, addr.function, bus);
 
     errval_t err;
     ACPI_STATUS as;
@@ -144,14 +145,20 @@ static void read_irq_table(struct acpi_binding* b, char* pathname,
     as = AcpiGetHandle(NULL, pathname, &handle);
     if (ACPI_SUCCESS(as)) {
         ACPI_HANDLE child;
-        acpi_get_irqtable_device(handle, addr, &child, bus);
-
-        char name[128];
-        get_path_name(child, name, 128);
-        ACPI_DEBUG("Sending back path name: %s\n", name);
-
-        err = b->tx_vtbl.read_irq_table_response(b, NOP_CONT, SYS_ERR_OK, name);
-        assert(err_is_ok(err));
+        err = acpi_get_irqtable_device(handle, addr, &child, bus);
+
+        if(err_is_fail(err)){
+            ACPI_DEBUG("get_irq_table failed.\n");
+            err = b->tx_vtbl.read_irq_table_response(b, NOP_CONT, err, NULL);
+            assert(err_is_ok(err));
+        } else {
+            char name[128];
+            get_path_name(child, name, 128);
+            ACPI_DEBUG("Sending back path name: %s\n", name);
+
+            err = b->tx_vtbl.read_irq_table_response(b, NOP_CONT, SYS_ERR_OK, name);
+            assert(err_is_ok(err));
+        }
     }
     else {
         ACPI_DEBUG("Unknown ACPI Handle for path: %s\n", pathname);
index 463b0dc..d10ea90 100644 (file)
@@ -28,7 +28,7 @@ errval_t find_all_apics(void);
 
 int init_acpi(void);
 ACPI_STATUS acpi_eval_integer(ACPI_HANDLE handle, char *name, ACPI_INTEGER *ret);
-void acpi_get_irqtable_device(ACPI_HANDLE parent, acpi_pci_address_t device,
+errval_t acpi_get_irqtable_device(ACPI_HANDLE parent, acpi_pci_address_t device,
         ACPI_HANDLE *child, uint8_t bus);
 void video_init(void);
 void buttons_init(void);
index 3c685dd..e9f60cb 100644 (file)
@@ -1072,6 +1072,9 @@ static void assign_bus_numbers(struct pci_address parentaddr,
                 }
             }
 
+            if(hdr_type.fmt == pci_hdr0_cardbus) {
+                printf("PCI: WARNING: Found cardbus bridge.\n");
+            }
             // is this a multi-function device?
             if (addr.function == 0 && !hdr_type.multi) {
                 break;