#include <ata.h>
#include <ide.h>
#include <io.h>
+#include <irq.h>
#include <string.h>
#include <system.h>
#include <types.h>
-
extern ide_pci_controller_t ide_pci_controller;
#define ATA_TIMEOUT 10 // 10次时钟中断
// 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));
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;