[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH 2/5] CDI/pci: Ressourcenindex
From: Max Reitz <max@xxxxxxxxxx>
! Der Index einer Ressource entspricht dem Index ihres BARs, IRQs sind
deshalb nicht in die Ermittlung dieses Indexes einzubeziehen.
Signed-off-by: Max Reitz <max@xxxxxxxxxx>
---
src/modules/cdi/lib/pci.c | 3 +--
src/modules/include/pci.h | 2 ++
src/modules/pci/pciscan.c | 4 ++++
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/modules/cdi/lib/pci.c b/src/modules/cdi/lib/pci.c
index 9b37da8..542fa79 100644
--- a/src/modules/cdi/lib/pci.c
+++ b/src/modules/cdi/lib/pci.c
@@ -60,7 +60,6 @@ static struct cdi_pci_device* read_pci_device(uint8_t* data, size_t size)
// Ressourcen hinzufuegen
struct pci_resource res;
struct cdi_pci_resource* cdi_res;
- int index = 0;
size -= sizeof(*device);
data += sizeof(*device);
@@ -73,7 +72,7 @@ static struct cdi_pci_device* read_pci_device(uint8_t* data, size_t size)
cdi_res = malloc(sizeof(*cdi_res));
cdi_res->start = res.start;
cdi_res->length = res.length;
- cdi_res->index = index++;
+ cdi_res->index = res.index;
cdi_res->address = 0;
switch (res.type) {
diff --git a/src/modules/include/pci.h b/src/modules/include/pci.h
index fdab461..043ce07 100644
--- a/src/modules/include/pci.h
+++ b/src/modules/include/pci.h
@@ -60,6 +60,8 @@ struct pci_resource {
uint32_t type;
uint32_t start;
uint32_t length;
+
+ int index;
} __attribute__ ((packed));
diff --git a/src/modules/pci/pciscan.c b/src/modules/pci/pciscan.c
index 08ec88a..fc76226 100644
--- a/src/modules/pci/pciscan.c
+++ b/src/modules/pci/pciscan.c
@@ -87,6 +87,8 @@ static void add_device(uint32_t bus, uint32_t device, uint32_t func)
struct pci_resource* resource =
malloc(sizeof(struct pci_resource));
+ resource->index = bar_number;
+
switch(bar->type) {
case bar_mem:
resource->type = PCI_RESOURCE_MEM;
@@ -121,6 +123,8 @@ static void add_device(uint32_t bus, uint32_t device, uint32_t func)
resource->start = pci_device.irq;
resource->length = 0;
+ resource->index = -1;
+
if (element->resources == NULL) {
element->resources = list_create();
}
--
1.7.1