mercredi 17 septembre 2014

how to switch to real mode from protected mode?


Vote count:

-1




I found a source code to switch back to real mode from protected mode on http://ift.tt/1iZ5qSd. But linker gives following errors:



kernel_entry.o: In function `halt':
kernel_entry.asm:(.text+0x3fd): relocation truncated to fit: R_386_16 against `.text'
kernel_entry.asm:(.text+0x409): relocation truncated to fit: R_386_16 against `.text'
kernel_entry.o: In function `GoRMode':
kernel_entry.asm:(.text+0x422): relocation truncated to fit: R_386_16 against `.text'


And the code is as follows:



[bits 16]
[global halt]

idt_real:
dw 0x3ff ; 256 entries, 4b each = 1K
dd 0
savcr0:
dd 0

halt:
; We are already in 16-bit mode here!

cli ; Disable interrupts.

; Need 16-bit Protected Mode GDT entries!
mov eax, 0x20 ; 16-bit Protected Mode data selector.
mov ds, eax
mov es, eax
mov fs, eax
mov gs, eax
mov ss, eax

; Disable paging (we need everything to be 1:1 mapped).
mov eax, cr0
mov [savcr0], eax ; save pmode CR0
and eax, 0x7FFFFFFe ; Disable paging bit & enable 16-bit pmode.
mov cr0, eax
jmp 0x00:GoRMode ; Perform Far jump to set CS.

GoRMode:
mov bp, 0x8000
mov sp, bp ; pick a stack pointer.
mov ax, 0 ; Reset segment registers to 0.
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
lidt [idt_real]
sti


What is wrong with this code? I almost completely copy the code from the site.



asked 3 mins ago







how to switch to real mode from protected mode?

Aucun commentaire:

Enregistrer un commentaire