From bdfb6eb3c2a0aa0a789da7fc49fbf09ef3f6e9d9 Mon Sep 17 00:00:00 2001 From: acevest Date: Tue, 24 Sep 2024 20:05:05 +0800 Subject: [PATCH] =?utf8?q?=E4=BD=BF=E7=94=A8pio=E6=A8=A1=E5=BC=8F=E8=AF=BB?= =?utf8?q?=E7=A1=AC=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- drivers/ata.c | 3 +-- kernel/task_disk.c | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/ata.c b/drivers/ata.c index c060f99..cf250fb 100644 --- a/drivers/ata.c +++ b/drivers/ata.c @@ -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; diff --git a/kernel/task_disk.c b/kernel/task_disk.c index 4b6dd21..b5525ae 100644 --- a/kernel/task_disk.c +++ b/kernel/task_disk.c @@ -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) { -- 2.44.0