diff options
author | rtm <rtm> | 2006-08-30 18:55:06 +0000 |
---|---|---|
committer | rtm <rtm> | 2006-08-30 18:55:06 +0000 |
commit | 2aa4c3bc29b67dcc4810aca96fd0ae8aa7c32b5e (patch) | |
tree | 63446e3d197769ba44a9e32a30a284327ec93af8 /ide.c | |
parent | 18432ed5edaeb2a6ffd91f557880c277d96784c1 (diff) | |
download | xv6-labs-2aa4c3bc29b67dcc4810aca96fd0ae8aa7c32b5e.tar.gz xv6-labs-2aa4c3bc29b67dcc4810aca96fd0ae8aa7c32b5e.tar.bz2 xv6-labs-2aa4c3bc29b67dcc4810aca96fd0ae8aa7c32b5e.zip |
complain if no disk 1
lots of cleanup
Diffstat (limited to 'ide.c')
-rw-r--r-- | ide.c | 28 |
1 files changed, 8 insertions, 20 deletions
@@ -1,7 +1,5 @@ /* - * Minimal PIO-based (non-interrupt-driven) IDE driver code. - * For information about what all this IDE/ATA magic means, - * see the materials available on the class references page. + * Simple PIO-based (non-DMA) IDE driver code. */ #include "types.h" @@ -27,9 +25,11 @@ struct ide_request { struct ide_request request[NREQUEST]; int head, tail; struct spinlock ide_lock; - +int disk_1_present; int disk_channel; +int ide_probe_disk1(void); + static int ide_wait_ready(int check_error) { @@ -47,11 +47,9 @@ void ide_init(void) { initlock(&ide_lock, "ide"); - if (ncpu < 2) { - panic ("ide_init: disk interrupt is going to the second cpu\n"); - } - ioapic_enable (IRQ_IDE, 1); + ioapic_enable (IRQ_IDE, ncpu - 1); ide_wait_ready(0); + disk_1_present = ide_probe_disk1(); } void @@ -80,7 +78,6 @@ ide_probe_disk1(void) // switch back to Device 0 outb(0x1F6, 0xE0 | (0<<4)); - cprintf("Device 1 presence: %d\n", (x < 1000)); return (x < 1000); } @@ -111,11 +108,8 @@ ide_start_rw(int diskno, uint secno, void *addr, uint nsecs, int read) { struct ide_request *r; - if(!holding(&ide_lock)) - panic("ide_start_read: not holding ide_lock"); - - if(nsecs > 1) - panic("ide_start_read: nsecs too large"); + if(diskno && !disk_1_present) + panic("ide disk 1 not present"); while ((head + 1) % NREQUEST == tail) sleep (&disk_channel, &ide_lock); @@ -140,12 +134,6 @@ ide_finish(void *c) int r; struct ide_request *req = (struct ide_request *) c; - if(c != &request[tail]) - panic("ide_finish_read"); - - if(!holding(&ide_lock)) - panic("ide_start_read: not holding ide_lock"); - if (req->read) { if ((r = ide_wait_ready(1)) >= 0) insl(0x1F0, req->addr, 512/4); |