From: acevest Date: Tue, 16 Nov 2021 04:09:37 +0000 (+0800) Subject: ata用中断读IENTIFY时不再用sleep_on X-Git-Url: http://zhaoyanbai.com/repos/dig.html?a=commitdiff_plain;h=ee2fbdae0ea5e69abedf81c92fdb69f2932d7ef7;p=kernel.git ata用中断读IENTIFY时不再用sleep_on --- diff --git a/drivers/ata.c b/drivers/ata.c index e6e2bb6..d2dc346 100644 --- a/drivers/ata.c +++ b/drivers/ata.c @@ -9,10 +9,10 @@ #include #include #include +#include #include #include #include - extern ide_pci_controller_t ide_pci_controller; #define ATA_TIMEOUT 10 // 10次时钟中断 @@ -41,14 +41,26 @@ void ata_test(uint64_t nr) { // 2. 等到status的BSY位清除 // 3. 等到status的DRQ位或ERR位设置 u16 identify[256]; -void ata_send_read_identify_cmd(int dev) { +void ata_send_read_identify_cmd(int dev) {} +void ata_read_identify(int dev) { // 这里所用的dev是逻辑编号 ATA0、ATA1下的Master、Salve的dev分别为0,1,2,3 outb(0x00, REG_CTL(dev)); outb(0x00 | ((dev & 0x01) << 4), REG_DEVICE(dev)); // 根据文档P113,这里不用指定bit5, bit7,直接指示DRIVE就行 + + unsigned long flags; + irq_save(flags); + + void add_to_ide_wait_queue(); + add_to_ide_wait_queue(); + outb(ATA_CMD_IDENTIFY, REG_CMD(dev)); -} -void ata_read_identify(int dev) { // 这里所用的dev是逻辑编号 ATA0、ATA1下的Master、Salve的dev分别为0,1,2,3 - sleep_on_ide(); + irq_restore(flags); + + schedule(); + + printk("asfdasdfasd----\n"); + + // sleep_on_ide(); insw(REG_DATA(dev), identify, SECT_SIZE / sizeof(u16)); diff --git a/drivers/ide.c b/drivers/ide.c index 2c51213..b399fc2 100644 --- a/drivers/ide.c +++ b/drivers/ide.c @@ -538,6 +538,15 @@ DECLARE_WAIT_QUEUE_HEAD(ide_wait_queue_head); void sleep_on_ide() { sleep_on(&ide_wait_queue_head); } +wait_queue_t iwait; +// DECLARE_WAIT_QUEUE(wait, current); +void add_to_ide_wait_queue() { + iwait.task = current; + iwait.task_list.prev = &iwait.task_list; + iwait.task_list.next = &iwait.task_list; + list_add_tail(&iwait.task_list, &ide_wait_queue_head.task_list); +} + extern void *mbr_buf; uint8_t ata_pci_bus_status(); extern ide_pci_controller_t ide_pci_controller;