Passage en protected mode
Bonjour tout le monde, j'ai découvert un bon tuto sur le net : The booting process by Gergor Brunmar
Il est vraiment bien, j'ai compris le principe de la GDT, donc la je suis au 2eme chapitre qui est basé sur le passage du protected mode (ici), mais je bloque dans une partie du code, le voici en entier :
Code:
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| [BITS 16] ; We need 16-bit intructions for Real mode
[ORG 0x7C00] ; The BIOS loads the boot sector into memory location 0x7C00
cli ; Disable interrupts, we want to be alone
xor ax, ax
mov ds, ax ; Set DS-register to 0 - used by lgdt
lgdt [gdt_desc] ; Load the GDT descriptor
mov eax, cr0 ; Copy the contents of CR0 into EAX
or eax, 1 ; Set bit 0
mov cr0, eax ; Copy the contents of EAX into CR0
jmp 08h:clear_pipe ; Jump to code segment, offset clear_pipe
[BITS 32] ; We now need 32-bit instructions
clear_pipe:
mov ax, 10h ; Save data segment identifyer
mov ds, ax ; Move a valid data segment into the data segment register
mov ss, ax ; Move a valid data segment into the stack segment register
mov esp, 090000h ; Move the stack pointer to 090000h
mov byte [ds:0B8000h], 'P' ; Move the ASCII-code of 'P' into first video memory
mov byte [ds:0B8001h], 1Bh ; Assign a color code
hang:
jmp hang ; Loop, self-jump
gdt: ; Address for the GDT
gdt_null: ; Null Segment
dd 0
dd 0
gdt_code: ; Code segment, read/execute, nonconforming
dw 0FFFFh
dw 0
db 0
db 10011010b
db 11001111b
db 0
gdt_data: ; Data segment, read/write, expand down
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
gdt_end: ; Used to calculate the size of the GDT
gdt_desc: ; The GDT descriptor
dw gdt_end - gdt - 1 ; Limit (size)
dd gdt ; Address of the GDT
times 510-($-$$) db 0 ; Fill up the file with zeros
dw 0AA55h ; Boot sector identifyer |
Ce que je ne comprend pas c'est entre
Code:
jmp 08h:clear_pipe ; Jump to code segment, offset clear_pipe
et
Code:
mov esp, 090000h ; Move the stack pointer to 090000h
A part la commande [BITS 32].
Si quelqu'un pouvait m'expliquer clairement cette partie du code :) (surtout le jmp : pourquoi 08h ? et pourquoi mettre ds et ss a 10h ?)
EDIT: je croit que j'ai compris pour 08h : on saute la gdt null (puisque une gdt fait 2 DWORD) et pour la stack : on choisi juste un emplacement libre on aurait pu mettre :
Code:
mov esp, 095600h ; Move the stack pointer to 095600h
par example c'est ca ? Sinon pour le 10h je suis toujours perdu..
Merci :)