Estoy intentando cambiar al modo protegido en intel x86."llamar" después de cambiar al modo protegido
He cargado mi GDT con lgdt, establezca el indicador P de cr0 a 1 y todos los selectores de segmentos, pero cuando regreso de la llamada a la función, no puedo llamar a cualquier otra función o me sale este error
qemu: fatal: Trying to execute code outside RAM or ROM at 0xfeeb7c5b
Aquí es mi función switch_to_pmode:
gdtr:
.short 23 // limit
gdtr_base:
.long 0 // base
switch_to_pmode:
movl $null_segment, %eax // Address of the first byte of the GDT
movl %eax, gdtr_base
cli // disable interrupts
lgdt (gdtr)
movl %cr0, %eax
or $0x1, %eax
movl %eax, %cr0 // Set the PE flag
push $0x8
push $reload_segments
lret
reload_segments:
movl $0x10, %eax
movl %eax, %ds
movl %eax, %ss
movl %eax, %es
movl %eax, %fs
movl %eax, %gs
ret
foo:
ret
Y mis llamadas
_start:
call switch_to_pmode
call foo // <----- Ouch!
Gracias
¡Gracias! ¡El .code32 funciona! – marmottus