From: acevest Date: Tue, 24 Sep 2024 16:04:31 +0000 (+0800) Subject: 在task_disk任务中显示硬盘请求统计信息 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=d0f16abaa39deb3b7dd5fb5c70aec78bef78a30e;p=kernel.git 在task_disk任务中显示硬盘请求统计信息 --- diff --git a/drivers/ide.c b/drivers/ide.c index 1aaad36..f96715b 100644 --- a/drivers/ide.c +++ b/drivers/ide.c @@ -107,6 +107,14 @@ ide_pci_controller_t ide_pci_controller[NR_IDE_CONTROLLER]; void ata_dma_stop(int channel); +void ide_stat_print(ide_pci_controller_t *ide_ctrl) { + int r = atomic_read(&(ide_ctrl->request_cnt)); + int i = atomic_read(&(ide_ctrl->irq_cnt)); + int c = atomic_read(&(ide_ctrl->consumed_cnt)); + int channel = ide_ctrl->channel; + printlxy(MPL_IDE0 + channel, MPO_IDE, "IDE%d req %u irq %u consumed %u", channel, r, i, c); +} + void ide_irq_bh_handler(void *arg) { int channel = (int)arg; @@ -124,10 +132,7 @@ void ide_irq_bh_handler(void *arg) { atomic_inc(&ide_ctrl->irq_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)); - printlxy(MPL_IDE0 + channel, MPO_IDE, "IDE%d req %u irq %u consumed %u", channel, r, i, c); + ide_stat_print(ide_ctrl); // 之前这里是用up()来唤醒磁盘任务 // 但在中断的底半处理,不应该切换任务,因为会引起irq里的reenter问题,导致不能再进底半处理,也无法切换任务 @@ -209,6 +214,8 @@ void ide_pci_init(pci_device_t *pci) { ide_pci_controller[i].pci = pci; + ide_pci_controller[i].channel = i; + unsigned int irq_line = pci_read_config_byte(pci_cmd(pci, PCI_INTRLINE)); assert(irq_line <= 15); if (irq_line == 0) { diff --git a/drivers/ide.h b/drivers/ide.h index c230c34..2b8c4c6 100644 --- a/drivers/ide.h +++ b/drivers/ide.h @@ -197,6 +197,8 @@ typedef struct _ide_pci_controller { atomic_t irq_cnt; atomic_t consumed_cnt; + int channel; + int irq_line; } ide_pci_controller_t; @@ -226,3 +228,4 @@ typedef struct _ide_drive { extern ide_drive_t ide_drives[MAX_IDE_DRIVE_CNT]; ide_drive_t *ide_get_drive(dev_t dev); +void ide_stat_print(ide_pci_controller_t *ide_ctrl); diff --git a/kernel/task_disk.c b/kernel/task_disk.c index 32259af..bc3b5df 100644 --- a/kernel/task_disk.c +++ b/kernel/task_disk.c @@ -154,6 +154,8 @@ void disk_task_entry(void *arg) { printk("IDE status %02X error for drv %u pos %lu count %u\n", ide_ctrl->status, drvid, pos, r->count); ret = -1; } + + ide_stat_print(ide_ctrl); } // 读数据 diff --git a/kernel/task_init.c b/kernel/task_init.c index dace90f..4cab514 100644 --- a/kernel/task_init.c +++ b/kernel/task_init.c @@ -51,15 +51,15 @@ void verify_hd_data(uint64_t sect_nr, uint16_t *buf, const char *name) { } } -// 保存它们不跨64KB +// 保证它们不跨64KB u16 disk_buf1[256] __attribute__((__aligned__(512))); u16 disk_buf2[256] __attribute__((__aligned__(512))); void taskA_entry() { - current->priority = 7; + current->priority = 3; while (1) { - sysc_wait(7); + sysc_wait(197); uint64_t sect_nr = get_next_deubug_sect_nr(); memset(disk_buf1, 0, 512);