From f928dd9c71b3bd300831c2e9ec03208ceab0a4dd Mon Sep 17 00:00:00 2001 From: acevest Date: Tue, 24 Sep 2024 22:40:17 +0800 Subject: [PATCH] =?utf8?q?=E5=9C=A8=E7=A1=AC=E7=9B=98=E4=B8=AD=E6=96=AD?= =?utf8?q?=E5=A4=84=E7=90=86=E4=B8=AD=E6=B7=BB=E5=8A=A0=E5=81=9C=E6=AD=A2D?= =?utf8?q?MA=E7=9A=84=E9=80=BB=E8=BE=91;=E6=B7=BB=E5=8A=A0=E7=A1=AC?= =?utf8?q?=E7=9B=98=E4=B8=AD=E6=96=AD=E7=9A=84=E5=90=8E=E5=8D=8A=E9=83=A8?= =?utf8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=E5=8F=AA=E6=89=93=E5=8D=B0?= =?utf8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- drivers/ide.c | 33 ++++++++++----------------------- kernel/task_disk.c | 2 ++ 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/drivers/ide.c b/drivers/ide.c index c9d9193..902a971 100644 --- a/drivers/ide.c +++ b/drivers/ide.c @@ -110,47 +110,31 @@ void ata_dma_stop(int channel); void ide_irq_bh_handler(void *arg) { int channel = (int)arg; - // printk("channel %08x\n", channel); assert(channel <= 1); assert(channel >= 0); ide_pci_controller_t *ide_ctrl = ide_pci_controller + channel; - // printlxy(MPL_IDE, MPO_IDE, "disk irq %u req %u consumed %u ", disk_inter_cnt, disk_request_cnt, - // disk_handled_cnt); - printlxy(MPL_IDE0 + channel, MPO_IDE, "IDE%d req %u irq %u consumed %u", channel, - atomic_read(&(ide_ctrl->request_cnt)), ide_ctrl->irq_cnt, ide_ctrl->consumed_cnt); + int r = atomic_read(&(ide_ctrl->request_cnt)); + int i = atomic_read(&(ide_ctrl->irq_cnt)); + int c = atomic_read(&(ide_ctrl->consumed_cnt)); - // 之前这里是用up()来唤醒磁盘任务 - // 但在中断的底半处理,不应该切换任务,因为会引起irq里的reenter问题,导致不能再进底半处理,也无法切换任务 - // 所以就移除了up()里的 schedule() - // 后来就改用完成量来通知磁盘任务,就不存在这个问题了 - - // complete会唤醒进程,但不会立即重新调度进程 - complete(&ide_ctrl->intr_complete); + printlxy(MPL_IDE0 + channel, MPO_IDE, "IDE%d req %u irq %u consumed %u", channel, r, i, c); } void ide_irq_handler(unsigned int irq, pt_regs_t *regs, void *devid) { // printk("ide irq %d handler pci status: 0x%02x\n", irq, ata_pci_bus_status()); int channel = irq == ide_pci_controller[0].irq_line ? 0 : 1; -#if 0 - // printk("ide[%d] irq %d handler\n", channel, irq); - + const int drvid = (channel << 1); // 虚拟一个 ide_pci_controller_t *ide_ctrl = ide_pci_controller + channel; + ide_ctrl->status = inb(REG_STATUS(drvid)); + ide_ctrl->pci_status = inb(ide_ctrl->bus_status); atomic_inc(&ide_ctrl->irq_cnt); ata_dma_stop(channel); - add_irq_bh_handler(ide_irq_bh_handler, (void *)channel); -#endif - - const int drvid = (channel << 1); // 虚拟一个 - ide_pci_controller_t *ide_ctrl = ide_pci_controller + channel; - ide_ctrl->status = inb(REG_STATUS(drvid)); - ide_ctrl->pci_status = inb(ide_ctrl->bus_status); - // 之前这里是用up()来唤醒磁盘任务 // 但在中断的底半处理,不应该切换任务,因为会引起irq里的reenter问题,导致不能再进底半处理,也无法切换任务 // 所以就移除了up()里的 schedule() @@ -158,6 +142,9 @@ void ide_irq_handler(unsigned int irq, pt_regs_t *regs, void *devid) { // complete会唤醒进程,但不会立即重新调度进程 complete(&ide_ctrl->intr_complete); + + // 纯debug打印 + add_irq_bh_handler(ide_irq_bh_handler, (void *)channel); } unsigned int IDE_CHL0_CMD_BASE = 0x1F0; diff --git a/kernel/task_disk.c b/kernel/task_disk.c index 60d1ca3..e1f15d1 100644 --- a/kernel/task_disk.c +++ b/kernel/task_disk.c @@ -69,11 +69,13 @@ void disk_task_entry(void *arg) { int channel = (int)arg; ide_pci_controller_t *ide_ctrl = ide_pci_controller + channel; +#if 0 // 为了在DEBUG时看到RUN int cnt = 2; for (int i = 0; i < cnt; i++) { asm("hlt;"); } +#endif // printk("wait request for hard disk channel %d\n", channel); down(&ide_ctrl->request_queue.sem); -- 2.44.0