]> Zhao Yanbai Git Server - kernel.git/commitdiff
在task_disk任务中显示硬盘请求统计信息
authoracevest <zhaoyanbai@126.com>
Tue, 24 Sep 2024 16:04:31 +0000 (00:04 +0800)
committeracevest <zhaoyanbai@126.com>
Tue, 24 Sep 2024 16:04:31 +0000 (00:04 +0800)
drivers/ide.c
drivers/ide.h
kernel/task_disk.c
kernel/task_init.c

index 1aaad3690b4e516a1e1578a52009cea11c8ef367..f96715bd16befda7ef89505304065fdd49bdc7b9 100644 (file)
@@ -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) {
index c230c34e2d28f780a0b0a253b0f84bc33a1a2fa6..2b8c4c611b3aa3bf0c127a2bfdd5022f7eea57b9 100644 (file)
@@ -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);
index 32259af84c51124fd08bdfd847166b3e470f9731..bc3b5df76e5ee44a919c44779a6f6e3ccc0e9b1e 100644 (file)
@@ -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);
         }
 
         // 读数据
index dace90f9d1a263ab243c6fc98aa3d301a9b2403c..4cab5145ef810354ed1d4f96ac8b6475341d1eb0 100644 (file)
@@ -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);