From ee2fbdae0ea5e69abedf81c92fdb69f2932d7ef7 Mon Sep 17 00:00:00 2001 From: acevest Date: Tue, 16 Nov 2021 12:09:37 +0800 Subject: [PATCH] =?utf8?q?ata=E7=94=A8=E4=B8=AD=E6=96=AD=E8=AF=BBIENTIFY?= =?utf8?q?=E6=97=B6=E4=B8=8D=E5=86=8D=E7=94=A8sleep=5Fon?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- drivers/ata.c | 22 +++++++++++++++++----- drivers/ide.c | 9 +++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) 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; -- 2.44.0