anyone know?
EDIT: Look at that, we posted the exact same time. :)
Code: Select all
void outb(unsigned short _port, unsigned char _data) //output a byte to a port
{
// "a" (_data) means: load EAX with _data
// "d" (_port) means: load EDX with _port
__asm__ __volatile__("outb %%al, %%dx" : :"a" (_data), "d" (_port));
}
There is my outb.
EDIT: In regards to IRQs. My Raid Controller is using IRQ 11, so can I treat it like everything else and install a handler for it, something like:
Code: Select all
void pci_handler(void)
{
//do stuff
//send acknowledgment?
}
void init_pci(void)
{
irq_install_handler(11,pci_handler)
}
EDIT: When a driver issues a PIO read or write command, it needs to wait until the drive is ready before transferring data. There are two ways to know when the drive is ready for the data. The drive will send an IRQ when it is good and ready. Or, a driver can poll one of the Status ports (either the Regular or Alternate Status).
There are two advantages to polling, and one gigantic disadvantage. Advantages: Polling responds more quickly than an IRQ. The logic of polling is much simpler than waiting on an IRQ.
The disadvantage: In a multitasking environment, polling will eat up all your CPU time. However, in singletasking mode this is not an issue (the CPU has nothing better to do) -- so polling is a good thing, then.
How to poll (waiting for the drive to be ready to transfer data): Read the Regular Status port until bit 7 (BSY, value = 0x80) clears, and bit 3 (DRQ, value = 8) sets -- or until bit 0 (ERR, value = 1) or bit 5 (DF, value = 0x20) sets. If neither error bit is set, the device is ready right then.
I use a single-tasking OS, so do I really need the IRQ or can I just query the status port after all? thanks
Free energy is indeed evil for it absorbs the light.