[Rx86os-ii] Making IPL

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/misskissc/article/details/44803115


Platform

Processor: Inte Lceleron (R) Dual-core CPU

Operating system: Windows7 Professional Edition x86

Read "30-day homemade operating system"-Chuan he Xiu [2015.03.15–03.16],[03.27] notes.

"30 days Homemade operating system" referred to as "book". For the tools in the book, you can take notes exclusively on them.

Tools:.. /toolset/


1 Learn about IPL 1.1 ScanDisk

The first sector of a floppy disk has so many rigid rules because the first sector of the floppy disk has a special effect: the computer first reads the floppy disk from the first sector of the head 0, and then checks the last 2 bytes of the sector. If this last 2 bytes is not 55AAH, the computer will assume that the disk does not have the required startup program, will be reported a failure to start, if the computer confirms that the last 2 bytes of the first sector is exactly 55AAH, it is considered that the beginning of the sector is the start of the program, and began to execute the program . Therefore, the first sector of the floppy disk is called ScanDisk (Boot sector).


The computer (BIOS) only reads the contents of the first sector of the floppy disk into memory, and the contents of the other sectors of the floppy disk are loaded by executing the program in the first sector .


1.2 IPL

IPL (Initial program loader, launcher loader) is a program in the floppy disk boot area, the function of which is to load the contents of each sector of the floppy disk into memory. In the "[Os-i] computer boot from floppy disk display string Hello World", the function of the binary program in the first sector is to display the string "Hello world" and does not load floppy disk sector contents into memory. The first sector of a floppy disk such as this may not be called the "boot area", the program is also not called "IPL", respectively, called their "Hello World Sector" and "Hello World program" more appropriate.


2 Making IPL

There are 2 points to follow when making IPL:

[1] BIOS 13h to the ScanDisk format requirements (not the program to run the necessary things);

[2] The code within the ScanDisk to have the ability to load other sector contents into memory.


2.1 Cylinder of floppy disk

Two tracks with the same track number as the face of the head 0 and the head 1 are referred to as a cylindrical surface. The (black) media that is used to store binary information in a floppy disk is called a diskette.


2.2 Reading a floppy 10-cylinder IPL

The contents of the ScanDisk are loaded into the 0x7c00~ 0X7DFF of the memory, so that the contents of the floppy disk follow-up area are connected with the boot area content, and the subsequent contents are copied to 0x8000~ 0X34DFF.[Plain]  View plain copy print; ipl  ; tab=4   cyls    equ & nbsp;   10              ; Read Disk 10 cylinders               ORG      0x7c00          ; Subsequent programs start loading      from 0X7C00  ; FAT12 format floppy disk boot area content (not required)            JMP      entry           DB       0x90           DB       " Haribote "      ; ScanDisk name, can be any 8 byte string             DW      512              ; the size of each sector (sector) (must be 512 bytes)            db       1                ; cluster (cluster) size (must be 1 sectors)            DW       1                ; Start position of fat (typically starting with the first sector)            DB       2               ; Number of fat (must be 2)            DW       224             ; root directory size (generally set to 224)            DW      2880             ; the size of the read disk (media for floppy disk memory data) (must be 2880 sectors)             DB      0xf0                 ; type of disk (must be 0xf0)             DW      9                ; Fat Length (must be 9 sectors)            DW       18              ;1 tracks (track) There are several sectors (must be)            DW       Number of 2               ; heads (must be 2)             DD      0               ; do not use partitions, must be 0            DD      2880             ; rewrite disk size             DB      0,0,0x29            DD      0xffffffff              DB       "hariboteos "     ; The name of the disk (11 bytes)            DB       Format name for "fat12   "       ; disk (8 bytes)             RESB    18               ; empty 18 bytes         ; program Body: Read disk contents to memory    entry:            MOV     AX,0         ; Initialize registers based on the address of the program being loaded            ; mov        ss,ax            ; mov        sp,0x7c00            MOV     DS,AX      Read disk contents to memory program             MOV     AX,0x0820            MOV     ES,AX            MOV     CH,0        ; cylinder of the disk, Bios 0x13h Interrupt PathOrder Parameters            MOV     DH,0         ; Head 0,bios 0x13h Interrupt program parameters             MOV     CL,2        ; Sector 2, BIOS 0X13H Interrupt Program Parameters    readloop:           mov      SI,0            ; Number of read sector failures    retry:           MOV      AH,0X02     ; AH=0X02: Read disk; bios 0x13h Interrupt program Parameters             MOV     AL,1         ; a sector; bios 0x13h Interrupt program Parameters            mov     &nbsp bx,0        ; read the disk contents to es:bx              mov     dl,0x00     ; a Drive            INT     0x13             ; Call bios 0x13h Interrupt program             JNC     next                 ; jump to next without error             ADD     SI,1             ; record the number of failed disk operations            CMP      SI,5                jae     error                ; if si >= 5 jumps to error   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.