1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
lgdt [cs:GDT]
call set_a20
mov eax,cr0 ; The lsb of cr0 is the protected mode bit
or al,01h ; Set protected mode bit
mov cr0,eax ; Mov modified word to the control register
jmp 08h:protected_mode ; Jump to Start32 (below)
protected_mode:
; Initialize all segment registers to 10h (entry #2 in the GDT)
mov ax,10h ; entry #1 in GDT
mov ds,ax ; ds = 10h
mov es,ax ; es = 10h
mov fs,ax ; fs = 10h
mov gs,ax ; gs = 10h
mov ss,ax ; ss = 10h
mov eax,1234h ;this push is for test only
push eax
mov ebx,entry_c_code ; 03000h
call ebx
pop ebx; this pop is for push balance
mov ebx,cr0 ; The lsb of cr0 is the protected mode bit
and bl,0FEh ; Clear protected mode bit
mov cr0,ebx ; Mov modified word to the control register
jmp 0:real_mode ; jump to next int real mode with CS=0h
real_mode:
; Initialize all segment registers to CS segment register
mov bx,cs
mov ds,bx
mov es,bx
mov fs,bx
mov gs,bx
mov ss,bx
;etc........
align 4
align 2 ; pour aligner la gdt et gdtr sur les bonnes addresses
GDT:
dw GDT_SIZE2 - 1
dd Gdt2
Gdt2:
dd 0,0
; GDT[1]: Executable, read-only code, base address of 0, limit of FFFFFh,
dw 0FFFFh,0,0,9ah,0CFh,0
; GDT[2]: Writable data segment, covering the save address space than GDT[1].
dw 0FFFFh,0,0,92h,0CFh,0
GDT_SIZE2 = $ - Gdt2
; à propos des commentaires, desfois, ils ne sont pas du tout indispensables,
;les etiquettes et les instructions parlent d'elles même |
Partager