[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH v2 01/24] cdi/pci: Ausrichtung von BARs an Pageframes



! BARs müssen nicht immer an 4k (oder was auch immer die Pageframegröße
  ist) ausgerichtet sein. Wenn sie das nicht sind, sollte die
  CDI-Bibliothek entsprechend handeln.

Signed-off-by: Max Reitz <max@xxxxxxxxxx>
---
 src/modules/cdi/lib/pci.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/modules/cdi/lib/pci.c b/src/modules/cdi/lib/pci.c
index 1df92dd..0dd07f8 100644
--- a/src/modules/cdi/lib/pci.c
+++ b/src/modules/cdi/lib/pci.c
@@ -16,6 +16,7 @@
 #include <services.h>
 
 #include <init.h>
+#include <page.h>
 #include <rpc.h>
 #include <pci.h>
 #include <dir.h>
@@ -191,7 +192,10 @@ void cdi_pci_alloc_memory(struct cdi_pci_device* device)
 
     for (i = 0; (res = cdi_list_get(device->resources, i)); i++) {
         if (res->type == CDI_PCI_MEMORY) {
-            res->address = mem_allocate_physical(res->length, res->start, 0);
+            uintptr_t offset = res->start % PAGE_SIZE;
+            void* mapping = mem_allocate_physical(res->length + offset,
+                                                  res->start - offset, 0);
+            res->address = (void*) ((uintptr_t)mapping + offset);
         }
     }
 }
-- 
2.6.3