X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/b60166b327a9108b07e3069fa6568a451529ffd9..34f6af4f61e0eec9c96113e07f140b609b4113c8:/lunaix-os/hal/ahci/ahci.c diff --git a/lunaix-os/hal/ahci/ahci.c b/lunaix-os/hal/ahci/ahci.c index 0f1ebf3..f40ae24 100644 --- a/lunaix-os/hal/ahci/ahci.c +++ b/lunaix-os/hal/ahci/ahci.c @@ -14,16 +14,14 @@ #include #include -#include -#include +#include #include #include -#include +#include #include -#include #include -#include +#include #include #include @@ -128,16 +126,19 @@ ahci_driver_init(struct ahci_driver_param* param) __hba_reset_port(port_regs); #endif + struct leaflet* leaflet; if (!clbp) { // 每页最多4个命令队列 - clb_pa = pmm_alloc_page(PP_FGLOCKED); - clb_pg_addr = (ptr_t)ioremap(clb_pa, 0x1000); + leaflet = alloc_leaflet(0); + clb_pa = leaflet_addr(leaflet); + clb_pg_addr = vmap(leaflet, KERNEL_DATA); memset((void*)clb_pg_addr, 0, 0x1000); } if (!fisp) { // 每页最多16个FIS - fis_pa = pmm_alloc_page(PP_FGLOCKED); - fis_pg_addr = (ptr_t)ioremap(fis_pa, 0x1000); + leaflet = alloc_leaflet(0); + fis_pa = leaflet_addr(leaflet); + fis_pg_addr = vmap(leaflet, KERNEL_DATA); memset((void*)fis_pg_addr, 0, 0x1000); } @@ -254,6 +255,7 @@ hba_bind_vbuf(struct hba_cmdh* cmdh, struct hba_cmdt* cmdt, struct vecbuf* vbuf) do { assert_msg(i < HBA_MAX_PRDTE, "HBA: Too many PRDTEs"); assert_msg(pos->buf.size <= 0x400000U, "HBA: Buffer too big"); + assert_msg(pos->buf.size, "HBA: expect a non-zero buffer size"); cmdt->entries[i++] = (struct hba_prdte){ .data_base = vmm_v2p((ptr_t)pos->buf.buffer), @@ -409,6 +411,7 @@ int ahci_identify_device(struct hba_device* device) { // 用于重新识别设备(比如在热插拔的情况下) + // FIXME this is not right... vfree(device); return ahci_init_device(device->port); }