After the BIOS bootsect this bootloader into memory, the next step is to load the second and third batches of programs by Bootsect.
The first thing Bootsect do is to plan for memory .
In real mode, the maximum addressing range is 1MB (0xFFFFF). About the Setup program, In Bootsect.s, you specify the number of sectors of the Setup program and the location to which it is loaded (0x90200), and also specify the location where the boot sector (that is, BOOTSECT.S) is loaded by the BIOS (0X07C00) and the new location to be moved (0x90000), where the kernel is loaded (0x10 000) and the end of the kernel, the root file system device number (root_dev=0x306, the first partition of the second hard disk).
This is memory planning to ensure that there is no overlap.
The first step in Bootsect is to copy itself from the 0X07C00 location to the 0x90000 location.
The second step is to load the Setup program into memory.
Loading bootsect,bios requires an int 0x19 this interrupt vector. To load Setup, use the Interrupt service program-the disk service program-that the BIOS provides for the int 0x13 interrupt vector. The difference is that the boot loader that the int 0x19 points to is performed by the BIOS, and the disk service program that the int 0x13 points to is the boot code of the Linux itself Bootsect executes. The former is only responsible for loading the code of the first sector into the 0X07C00 location, while the latter's interrupt service program loads the code of the specified sector into the specified location of memory according to the designer's intent. Therefore, for the int 0x13, the specified sector, the loaded memory location, etc. are passed to the interrupt service program beforehand.
The starting position of the copied bootsect is 0x90000, which takes up 512B, so 0x90200 is next to Bootsect's tail, so bootsect and setup are connected together. The Setup program occupies four sectors, and with bootsect, a total of five sectors are loaded. After the Bootsect code executes, Setup starts.
0.11 Way (ii): Load Setup