Switching from 16 to 64 bits during the boot of an Intel compatible PC

9

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.

    
asked by anonymous 28.04.2014 / 22:45

1 answer

4

Entering Long Mode is not so simple, I suggest starting with these pages:

Introduction: link

Traditional mode: link

Direct Mode: link

    
15.05.2014 / 01:13