Menuconfig Implementation and auto-qemu refactoring (#44)
[lunaix-os.git] / lunaix-os / hal / ahci / io_event.c
index c1bd6a5ad2f2cc9465aac2ab52beec962314c99c..d37f8e6f7663f2c6255c4ae9ea9548395cb0770b 100644 (file)
@@ -1,21 +1,21 @@
 #include <hal/ahci/ahci.h>
 #include <hal/ahci/sata.h>
 #include <hal/ahci/ahci.h>
 #include <hal/ahci/sata.h>
-#include <lunaix/isrm.h>
+#include <lunaix/generic/isrm.h>
 #include <lunaix/mm/valloc.h>
 #include <lunaix/syslog.h>
 
 LOG_MODULE("io_evt")
 
 #include <lunaix/mm/valloc.h>
 #include <lunaix/syslog.h>
 
 LOG_MODULE("io_evt")
 
-extern struct llist_header ahcis;
-
 void
 void
-__ahci_hba_isr(const isr_param* param)
+ahci_hba_isr(const struct hart_state* hstate)
 {
     struct ahci_hba* hba;
     struct ahci_driver *pos, *n;
 {
     struct ahci_hba* hba;
     struct ahci_driver *pos, *n;
-    llist_for_each(pos, n, &ahcis, ahci_drvs)
+    struct llist_header* ahcis = (struct llist_header*)isrm_get_payload(hstate);
+
+    llist_for_each(pos, n, ahcis, ahci_drvs)
     {
     {
-        if (pos->id == param->execp->vector) {
+        if (pos->id == hart_vector_stamp(hstate)) {
             hba = &pos->hba;
             goto proceed;
         }
             hba = &pos->hba;
             goto proceed;
         }
@@ -28,7 +28,7 @@ proceed:
     if (!hba->base[HBA_RIS])
         return;
 
     if (!hba->base[HBA_RIS])
         return;
 
-    u32_t port_num = 31 - __builtin_clz(hba->base[HBA_RIS]);
+    u32_t port_num = msbiti - clz(hba->base[HBA_RIS]);
     struct hba_port* port = hba->ports[port_num];
     struct hba_cmd_context* cmdctx = &port->cmdctx;
     u32_t processed = port->regs[HBA_RPxCI] ^ cmdctx->tracked_ci;
     struct hba_port* port = hba->ports[port_num];
     struct hba_cmd_context* cmdctx = &port->cmdctx;
     u32_t processed = port->regs[HBA_RPxCI] ^ cmdctx->tracked_ci;
@@ -48,7 +48,7 @@ proceed:
         goto done;
     }
 
         goto done;
     }
 
-    u32_t slot = 31 - __builtin_clz(processed);
+    u32_t slot = msbiti - clz(processed);
     struct hba_cmd_state* cmdstate = cmdctx->issued[slot];
 
     if (!cmdstate) {
     struct hba_cmd_state* cmdstate = cmdctx->issued[slot];
 
     if (!cmdstate) {
@@ -65,7 +65,7 @@ proceed:
 
     blkio_schedule(ioreq->io_ctx);
     blkio_complete(ioreq);
 
     blkio_schedule(ioreq->io_ctx);
     blkio_complete(ioreq);
-    vfree(cmdstate->cmd_table);
+    vfree_dma(cmdstate->cmd_table);
 
 done:
     hba_clear_reg(port->regs[HBA_RPxIS]);
 
 done:
     hba_clear_reg(port->regs[HBA_RPxIS]);