In the PC world, BIOS cannot detect if a hard disk drive is SCSI or IDE, generally speaking. Thus, it is not trivial to know which BIOS drive corresponds to an OS device. So the Multiboot Specification describes some techniques on how to guess mappings (see section `BIOS device mapping techniques' in The Multiboot Specification).
However, the techniques described are unreliable or difficult to be implemented, so we use a different technique from them in GRUB. Our technique is INT 13H tracking technique. More precisely, it runs the INT 13 call (see section INT 13H disk I/O interrupts) in single-step mode just like a debugger and parses the instructions.
To execute the call one instruction at a time, set the TF (trap flag) flag in the register FLAGS. By this, your CPU generates Break Point Trap after each instruction is executed and call INT 1. In the stack in the interrupt handler, callee's FLAGS and the far pointer which points to the next instruction to be executed are pushed, so we can know what instruction will be executed in the next time and the current contents of all the registers. If the next instruction is an I/O operation, the interrupt handler adds the I/O port into the I/O map.
If the INT 13 handler returns, the TF flag is cleared automatically by
the instruction iret
, and then output the I/O map on the screen.
See the source code for the command ioprobe
(see section The list of command-line and menu entry commands), for more information.
Go to the first, previous, next, last section, table of contents.