9
Some time ago I studied to create a draft operating system for Intel PC compatible computers, which actually didn’t need to do much, besides putting the computer in 32-bit mode, handle keyboard interruptions, and (at the time) serial ports.
My procedure at the time was this (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 Linux is open source, but the code is big, and I don’t 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.
Perhaps you could even make an operating system, other than a GNU license. It would be a good idea.
– Tony
The original idea was not even to create a true operating system, it was only for learning/didactic purposes. But who knows what the future holds ;)
– carlosrafaelgn