]> Zhao Yanbai Git Server - kernel.git/commitdiff
使用pio模式读硬盘
authoracevest <zhaoyanbai@126.com>
Tue, 24 Sep 2024 12:05:05 +0000 (20:05 +0800)
committeracevest <zhaoyanbai@126.com>
Tue, 24 Sep 2024 12:05:05 +0000 (20:05 +0800)
drivers/ata.c
kernel/task_disk.c

index c060f993450562c82535eb3d5a7a6d3b468894dd..cf250fb5da3140018a081e99873012d9b8b6b067 100644 (file)
@@ -625,9 +625,8 @@ int ata_pio_read_ext(int drvid, uint64_t pos, uint16_t count, int timeout, void
             break;
         }
 
-        asm("sti;hlt;");
+        asm("hlt;");
     }
-    asm("cli");
 
     if (timeout == 0) {
         return -1;
index 4b6dd21b9d3ffdf8a3bbd8204468217706574d0b..b5525ae821b0e6e0fcca9609d56cd56d1b7729e6 100644 (file)
@@ -106,7 +106,8 @@ void disk_task_entry(void *arg) {
             panic("INVARG");
         }
 
-        // init_completion(&ide_ctrl->intr_complete);
+        const bool pio_mode = true;
+        init_completion(&ide_ctrl->intr_complete);
 
         switch (r->command) {
         case DISK_REQ_IDENTIFY:
@@ -118,10 +119,19 @@ void disk_task_entry(void *arg) {
             assert(r->count > 0);
             assert(r->buf != NULL || r->bb->data != NULL);
             // printk("DISK READ drv_no %u pos %u count %u bb %x\n", drv_no, (uint32_t)pos, r->count, r->bb);
-            if (r->bb != 0) {
-                ata_dma_read_ext(drv_no, pos, r->count, r->bb->data);
+            if (pio_mode) {
+                int ata_pio_read_ext(int drvid, uint64_t pos, uint16_t count, int timeout, void *dest);
+                if (r->bb != 0) {
+                    ata_pio_read_ext(drv_no, pos, r->count, 100, r->bb->data);
+                } else {
+                    ata_pio_read_ext(drv_no, pos, r->count, 100, r->buf);
+                }
             } else {
-                ata_dma_read_ext(drv_no, pos, r->count, r->buf);
+                if (r->bb != 0) {
+                    ata_dma_read_ext(drv_no, pos, r->count, r->bb->data);
+                } else {
+                    ata_dma_read_ext(drv_no, pos, r->count, r->buf);
+                }
             }
             break;
         default:
@@ -129,8 +139,10 @@ void disk_task_entry(void *arg) {
             break;
         }
 
-        // 等待硬盘中断
-        wait_completion(&ide_ctrl->intr_complete);
+        if (!pio_mode) {
+            // 等待硬盘中断
+            wait_completion(&ide_ctrl->intr_complete);
+        }
 
         // 读数据
         if (DISK_REQ_IDENTIFY == r->command) {