ReactOS Source Code Analysis--Kernel loader (i)

Source: Internet
Author: User

The computer BIOS reads the data from the first sector of the hard disk to the memory 0x7c00 location, gives control to the active partition table of the master boot Record (MBR), the MBR re-search system, and loads the first sector of the active partition table to a fixed address. The MBR then gives control to PBR,PBR to parse the FAT or NTFS format file system, locate the boot kernel file ntldr, and load the file into 0x20000. Finally, control is given to NTLDR for kernel boot.

The original source code is a compilation process, the path of the assembler is probably in the "\boot\freeldr\bootsect\dosmbr.asm".

I refer to the source code is not the original ReactOS, the reference source is derived from the "Windows kernel design thought" author Chen Shubao rewrite the lite version of the BMR boot source. I looked at the original DOSMBR code and its code was closer to the startup logic of Windows XP. The Chen Shubao version is much easier to understand. The following is a code snippet for Chen Shubao:

Start:
    CLI,             off interrupt, zero interrupt flag in flag Register, disable interrupt,
    xor  ax, ax,     heterogeneous or operation, two operands identical, i.e. clear 0 operation;
    mov  SS, ax     ; Set stack segment register, segment register clear 0;
    mov  sp, 7c00h  ; set stack top, stack top is 0x7c00; STI; interrupt, the interrupt             flag position in the Flag Register 1, open interrupt;

    push 07c0h
    pop ds
    mov  ax, 07c0h  ; Set data segment Register
    mov  ds, ax

    ; load NTLDR
    push  DWORD 80000h/512-8  ;  Total number of COUNT-NTLDR sectors, 80000h/512-8 = 0x3f8
    push  DWORD 8             ; src-start reading of the sector area code
    push  DWORD 20000h        ; DES-the destination address for storing data call  loadsector          ; loading sector

    ; Ntfsboot jmp 0x2000:0000,fatboot jmp 0x2000:0003
    Push  word 2000h
    push  word 0000h 
o16 retf

Not to be continued ...

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.