2014-04-09 14 views

risposta

7

Per abilitare le capacità a 64 bit, è necessario portare la CPU in modalità estesa.

per attivare la modalità a lungo su un processore x86 a 64-bit (x86-64):

If paging is enabled, disable paging. 
If CR4.PAE is not already set, set it. 
Set IA32_EFER.LME = 1. 
Load CR3 with a valid PML4 table. 
Enable paging. 
At this point you will be in compatibility mode. A far jump may be executed to switch to long mode. However, the offset must not exceed 32-bit. 
+0

Documentazione ufficiale: [Intel® 64 e IA-32 Architectures Software Manuale dello sviluppatore, Volume 3A: Guida alla programmazione del sistema:] (https://www.intel.com/content/www/us/en/architecture-and- technology/64-ia-32-architectures-software-developer-vol-3a-part-1-manual.html) "Sezione 9.8.5 Inizializzazione della modalità IA-32e" –

2

OSDev è una buona risorsa per informazioni di basso livello su x86 (e un po 'su altre architetture). Ad esempio, this article è un buon interessante resoconto sulla modalità Long e come accedervi, sia dalla modalità protetta e direttamente dalla modalità reale:

Accesso alla modalità a lungo

Accesso alla modalità a lungo può essere sia fatto da modalità reale e modalità protetta, tuttavia solo la modalità protetta è trattata nei manuali Intel e AMD64. La documentazione di AMD precedente spiega che questo processo funziona dalla modalità reale come .

2

Se vuoi andare direttamente alla modalità a 64 bit, si può fare qualcosa di simile:

%xdefine PML4_BASE 0x70000  ; Address of PML4-table. 
%xdefine CR0_PE  1 << 0 
%xdefine CR0_PG  1 << 31 
%xdefine CR4_PAE 1 << 5 
%xdefine CR4_PGE 1 << 7 
%xdefine EFER_LME 1 << 8 

mov eax, CR4_PAE | CR4_PGE  ; Set PAE- (Physical Address Extensions) and 
mov cr4, eax     ; PGE- (Page Global Enable). 
mov eax, PML4_BASE    ; Address of PML4. 
mov cr3, eax     ; Point CR3 to PML4. 
mov ecx, 0xC0000080   ; EFER MSR selector. 
rdmsr       ; Read from model specific register. 
or eax, EFER_LME    ; Set LME (Long Mode Enable). 
wrmsr       ; Write to model specific register. 
mov ebx, cr0     ; Get CR0. 
or ebx, CR0_PG | CR0_PE  ; Set PG (Paging) and PE (Protection Enabled). 
mov cr0, ebx     ; Set flags to CR0. 
lgdt [GDT.ptr]     ; Load global descriptor table. 
jmp GDT.code_0:long_mode_entry ; Jump to long mode. 

Sopra il codice richiede di avere già le tabelle delle pagine di configurazione e Global Descriptor Table.

Problemi correlati