Some time ago I studied to create a draft operating system for Intel compatible PC computers, which really did not have to do much, besides putting the computer in 32-bit mode, handling the keyboard interrupts, and (at the time) of the serial ports.
My procedure at the time was this one (it worked very well):
cli cld ;habilita o gate A20, liberando acesso a mais de 1MB _A20_1: in al, 064h test al, 2 jnz _A20_1 mov al, 0D1h out 064h, al _A20_2: in al, 064h test al, 2 jnz _A20_2 mov al, 0DFh out 060h, al ;calcula e preenche a IDT e a GDT ;... db 066h lgdt [GDT] db 066h lidt [IDT] ;liga o bit do modo protegido smsw ax or ax,1 lmsw ax ;jmp next ;next: db 0ebh db 000h ;entra em modo 32 bits ;PCODE_ADDR contém o endereço do label _32BIT ;jmp fword ptr PCODE_ADDR db 066h db 0ffh db 02eh dw PCODE_ADDR _32BIT: ;daqui em diante tudo está em 32 bits ;... PCODE_ADDR: dd _32BIT ;endereço linear usado para o JUMP dw 08h ;seletor usado para o JUMP
My question is: how do I do a similar procedure, but to put the computer in 64-bit mode, starting from 16-bit mode?
I know that Linux is open source, but the code is great, and I do not have much experience with it. If the answer involves the Linux source code, I would ask, please, to indicate the version, the file and the corresponding lines.