ahci: relocate ahci_vbase to unmapped region

This commit is contained in:
Michael Shaw 2023-11-15 20:16:21 -05:00
commit ec4d266abd
3 changed files with 9 additions and 3 deletions

View file

@ -22,6 +22,7 @@ static uint8_t sata_device_count = 0;
static struct sata_device sata_devices[32] = { 0 }; static struct sata_device sata_devices[32] = { 0 };
static paddr_t ahci_pbase = 0; static paddr_t ahci_pbase = 0;
static uintptr_t ahci_vbase = 0;
static void ahci_irq_handler() static void ahci_irq_handler()
{ {
@ -286,12 +287,14 @@ void ahci_init()
ahci_pbase = (paddr_t)buddy_alloc(ahci_zone_size) & (~hhdm_start); /* 1 MiB */ ahci_pbase = (paddr_t)buddy_alloc(ahci_zone_size) & (~hhdm_start); /* 1 MiB */
ahci_probe_ports(dev, abar); ahci_probe_ports(dev, abar);
ahci_vbase = mmap_find_unmapped(kmap_tree, &kmap_lock, hhdm_start, ahci_zone_size);
/* map ahci zone with cache disabled (pcd=1) */ /* map ahci zone with cache disabled (pcd=1) */
struct page attrs; struct page attrs;
attrs.val = 1; attrs.val = 1;
attrs.rw = 1; attrs.rw = 1;
attrs.pcd = 1; attrs.pcd = 1;
kmap(ahci_pbase, ahci_pbase | hhdm_start, ahci_zone_size, attrs.val); kmap(ahci_pbase, ahci_vbase, ahci_zone_size, attrs.val);
if (sata_device_count == 0) { if (sata_device_count == 0) {
kprintf(LOG_WARN "No SATA devices found\n"); kprintf(LOG_WARN "No SATA devices found\n");

View file

@ -93,6 +93,9 @@ extern struct mem_region *regions;
extern size_t num_regions; extern size_t num_regions;
extern size_t max_regions; extern size_t max_regions;
extern struct rbtree *kmap_tree;
extern spinlock_t kmap_lock;
extern struct page *pml4; extern struct page *pml4;
extern paddr_t kcr3; extern paddr_t kcr3;
extern struct page kdefault_attrs; extern struct page kdefault_attrs;

View file

@ -6,11 +6,11 @@
#include <kernel/proc.h> #include <kernel/proc.h>
static slab_t *page_slab; static slab_t *page_slab;
static spinlock_t kmap_lock = 0;
extern void *(*alloc_page)(); extern void *(*alloc_page)();
static struct rbtree *kmap_tree = NULL; struct rbtree *kmap_tree = NULL;
spinlock_t kmap_lock = 0;
static void *kmap_alloc_page() static void *kmap_alloc_page()
{ {