From: acevest Date: Tue, 24 Sep 2024 12:05:05 +0000 (+0800) Subject: 使用pio模式读硬盘 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=bdfb6eb3c2a0aa0a789da7fc49fbf09ef3f6e9d9;p=kernel.git 使用pio模式读硬盘 --- 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) {