fs lockup

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Styx
Posts: 2
Joined: Fri Mar 27, 2009 6:58 pm

fs lockup

Post by Styx »

the atapi code i have locks up after a 2nd read. the first read works fine. the code is as follows:

Code: Select all

volatile char irqhd = 0;

void irq_hdd(struct regs* r)
{
	irqhd = 1;
}

/* buffer = place to stuff data, lba = location on disk, count = num sectors */
void read(unsigned short *buffer, unsigned int lba, unsigned char count)
{
	register int i;
	
	irqhd = 0;
	
	// read
	outb(0x03f6, BIT(2));						// set srst (software reset)
	inb(0x03f6);  inb(0x03f6);					// wait
	inb(0x03f6);  inb(0x03f6);
	outb(0x01f6, 0xe0);							// first master
	outb(0x01f2, count);						// set the count
	outb(0x01f3, (unsigned char) lba);			// and the lba
	outb(0x01f4, (unsigned char) (lba >> 8));
	outb(0x01f5, (unsigned char) (lba >> 16));
	outb(0x01f7, 0x20);							// read with retry
	
	while(!irqhd);								// wait for irq to fire
	
	for(i = 0; i < count*256; i++)
		buffer[i] = inw(0x01f0);				// read in count sectors, word by word
}
can anyone see a problem with this?

EDIT: found problem

to anyone who may stumble upon this: you need to read the regular status register (0x1f7) in the interrupt
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: fs lockup

Post by pcmattman »

EDIT: found problem

to anyone who may stumble upon this: you need to read the regular status register (0x1f7) in the interrupt
There are more problems than that in this code, but if you're only aiming for it to work for now and be fixed later. As long as you do change it, because if you don't you're going to get smashed with bugs :)
Post Reply