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