Repos / kernel.git / commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e1efc59)
raw | patch | inline | side by side (parent: e1efc59)
| author | zhaoyanbai <zhaoyanbai@126.com> | |
| Tue, 24 Sep 2024 16:04:31 +0000 (00:04 +0800) | ||
| committer | zhaoyanbai <zhaoyanbai@126.com> | |
| Tue, 24 Sep 2024 16:04:31 +0000 (00:04 +0800) |
| drivers/ide.c | patch | blob | history | |
| drivers/ide.h | patch | blob | history | |
| kernel/task_disk.c | patch | blob | history | |
| kernel/task_init.c | patch | blob | history |
diff --git a/drivers/ide.c b/drivers/ide.c
--- a/drivers/ide.c
+++ b/drivers/ide.c
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;
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问题,导致不能再进底半处理,也无法切换任务
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
--- a/drivers/ide.h
+++ b/drivers/ide.h
atomic_t irq_cnt;
atomic_t consumed_cnt;
+ int channel;
+
int irq_line;
} ide_pci_controller_t;
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
--- a/kernel/task_disk.c
+++ b/kernel/task_disk.c
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
--- a/kernel/task_init.c
+++ b/kernel/task_init.c
}
}
-// 保存它们不跨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);