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.
The function call 'io_delay()' here is to let the CPU wait for some time (by 'outb' a byte to the diagnostics IO Port 0x80), and my question is:
Why does it need to wait for some delay after doing I/O?
Most devices require a delay after writing to their command registers to give the device time to respond to the command. Alternatively, there may be a status register that can be polled to indicate when a command has been processed.
Ignoring ths is the sort of thing that can cause an OS to run on an emulator but not a real CPU.
iansjack wrote:Most devices require a delay after writing to their command registers to give the device time to respond to the command. Alternatively, there may be a status register that can be polled to indicate when a command has been processed.
Ignoring ths is the sort of thing that can cause an OS to run on an emulator but not a real CPU.
I should have mentioned another possibility. Some devices can be configured to issue an interrupt to notify the cpu that an operation has completed. Typically this is used with network controllers or drive controllers, where the time to complete some operations may be relatively long. That way the whole system doesn't have to stop waiting for an i/o operation. And, of course, a keyboard controller is normally configured this way.