1;------------------------------------------------------------------------------ 2; 3; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> 4; This program and the accompanying materials 5; are licensed and made available under the terms and conditions of the BSD License 6; which accompanies this distribution. The full text of the license may be found at 7; http://opensource.org/licenses/bsd-license.php. 8; 9; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11; 12; Module Name: 13; 14; EnablePaging64.Asm 15; 16; Abstract: 17; 18; AsmEnablePaging64 function 19; 20; Notes: 21; 22;------------------------------------------------------------------------------ 23 24 .686p 25 .model flat,C 26 .code 27 28;------------------------------------------------------------------------------ 29; VOID 30; EFIAPI 31; InternalX86EnablePaging64 ( 32; IN UINT16 Cs, 33; IN UINT64 EntryPoint, 34; IN UINT64 Context1, OPTIONAL 35; IN UINT64 Context2, OPTIONAL 36; IN UINT64 NewStack 37; ); 38;------------------------------------------------------------------------------ 39InternalX86EnablePaging64 PROC 40 cli 41 mov [esp], @F ; offset for far retf, seg is the 1st arg 42 mov eax, cr4 43 or al, (1 SHL 5) 44 mov cr4, eax ; enable PAE 45 mov ecx, 0c0000080h 46 rdmsr 47 or ah, 1 ; set LME 48 wrmsr 49 mov eax, cr0 50 bts eax, 31 ; set PG 51 mov cr0, eax ; enable paging 52 retf ; topmost 2 dwords hold the address 53@@: ; long mode starts here 54 DB 67h, 48h ; 32-bit address size, 64-bit operand size 55 mov ebx, [esp] ; mov rbx, [esp] 56 DB 67h, 48h 57 mov ecx, [esp + 8] ; mov rcx, [esp + 8] 58 DB 67h, 48h 59 mov edx, [esp + 10h] ; mov rdx, [esp + 10h] 60 DB 67h, 48h 61 mov esp, [esp + 18h] ; mov rsp, [esp + 18h] 62 DB 48h 63 add esp, -20h ; add rsp, -20h 64 call ebx ; call rbx 65 hlt ; no one should get here 66InternalX86EnablePaging64 ENDP 67 68 END 69