push %rbx
movl %ecx,%eax
movl %edx,%ecx
- push %rax
+ push %rax # save Index on stack
cpuid
mov 0x38(%rsp), %r10
test %r10, %r10
jrcxz L4
mov %edx, (%rcx)
L4:
- pop %rax
+ pop %rax # restore Index to rax as return value
pop %rbx
ret
# VOID
# EFIAPI
# InternalX86DisablePaging64 (
-# IN UINT16 Cs, %rdi
-# IN UINT64 EntryPoint, %rsi
-# IN UINT64 Context1, OPTIONAL %rdx
-# IN UINT32 Context2, OPTIONAL %rcx
-# IN UINT64 NewStack %r8
+# IN UINT16 Cs,
+# IN UINT64 EntryPoint,
+# IN UINT64 Context1, OPTIONAL
+# IN UINT32 Context2, OPTIONAL
+# IN UINT64 NewStack
# );
#------------------------------------------------------------------------------
.global ASM_PFX(InternalX86DisablePaging64)
ASM_PFX(InternalX86DisablePaging64):
cli
- shl $0x20,%rcx
+ shl $0x20,%rcx # rcx[32..47] <- Cs
lea L1, %eax
mov %r8d, %esi \r
- or %rax, %rcx\r
+ or %rax, %rcx # rcx[0..47] <- Cs:@F\r
mov %r9d, %edi \r
- mov 0x28(%rsp), %eax\r
+ mov 0x28(%rsp), %eax # eax <- New Stack\r
push %rcx\r
- ret\r
+ ret # switch to compatibility mode\r
L1:
- mov %eax,%esp
+ mov %eax,%esp # set up new stack
mov %cr0,%rax
btr $0x1f,%eax
- mov %rax,%cr0
+ mov %rax,%cr0 # disable paging
mov $0xc0000080,%ecx
rdmsr
- and $0xfe,%ah
+ and $0xfe,%ah # clear LME
wrmsr
mov %cr4,%rax
- and $0xdf,%al
+ and $0xdf,%al # clear PAE
mov %rax,%cr4
- push %rdi
- push %rsi
- callq *%rdx
- jmp .
+ push %rdi # push Context2
+ push %rsi # push Context1
+ callq *%rdx # transfer control to EntryPoint
+ jmp . # no one should get here
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006, Intel Corporation
+# Copyright (c) 2006 - 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# VOID
# EFIAPI
# InternalX86EnablePaging64 (
-# IN UINT16 Cs, %rdi
-# IN UINT64 EntryPoint, %rsi
-# IN UINT64 Context1, OPTIONAL %rdx
-# IN UINT64 Context2, OPTIONAL %rcx
-# IN UINT64 NewStack %r8
+# IN UINT16 Cs,
+# IN UINT64 EntryPoint,
+# IN UINT64 Context1, OPTIONAL
+# IN UINT64 Context2, OPTIONAL
+# IN UINT64 NewStack
# );
#------------------------------------------------------------------------------
.global ASM_PFX(InternalX86EnablePaging64)
ASM_PFX(InternalX86EnablePaging64):
cli
- pop %rax
+ pop %rax # skip the return address
callq Base
Base:
- addl $(L1-Base),(%rsp)
+ addl $(L1-Base),(%rsp) # offset for ret, seg is the 1st arg
mov %cr4,%rax
or $0x20,%al
- mov %rax,%cr4
+ mov %rax,%cr4 # enable PAE
mov $0xc0000080,%ecx
rdmsr
- or $0x1,%ah
+ or $0x1,%ah # set LME
wrmsr
mov %cr0,%rax
bts $0x1f,%eax
- mov %rax,%cr0
+ mov %rax,%cr0 # enable paging
lret
-L1:
+L1: # long mode starts here
addr32 mov (%esp),%rbx
addr32 mov 0x8(%esp),%rcx
addr32 mov 0x10(%esp),%rdx
addr32 mov 0x18(%esp),%rsp
add $-0x20,%rsp
callq *%rbx
- jmp .
+ jmp . # dead loop if EntryPoint() returned
;------------------------------------------------------------------------------\r
;\r
-; Copyright (c) 2006, Intel Corporation\r
+; Copyright (c) 2006 - 2008, Intel Corporation\r
; All rights reserved. This program and the accompanying materials\r
; are licensed and made available under the terms and conditions of the BSD License\r
; which accompanies this distribution. The full text of the license may be found at\r
call @Base\r
@Base:\r
add dword ptr [rsp], @F - @Base ; offset for far retf, seg is the 1st arg\r
- mov rax, cr4 ; mov eax, cr4\r
+ mov rax, cr4\r
or al, (1 SHL 5)\r
mov cr4, rax ; enable PAE\r
mov ecx, 0c0000080h\r
rdmsr\r
or ah, 1 ; set LME\r
wrmsr\r
- mov rax, cr0 ; mov eax, cr0\r
+ mov rax, cr0\r
bts eax, 31\r
mov cr0, rax ; enable paging\r
retf\r
#------------------------------------------------------------------------------\r
#\r
-# Copyright (c) 2006, Intel Corporation\r
+# Copyright (c) 2006 -2008, Intel Corporation\r
# All rights reserved. This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
mov 0x30(%rcx), %r13\r
mov 0x38(%rcx), %r14\r
mov 0x40(%rcx), %r15\r
- mov %rdx, %rax\r
+ mov %rdx, %rax # set return value\r
jmp *0x48(%rcx)\r
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006, Intel Corporation
+# Copyright (c) 2006 - 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
.global ASM_PFX(AsmReadMm0)
.align 16
ASM_PFX(AsmReadMm0):
- #DB 48h, 0fh, 7eh, 0c0h
movd %mm0, %rax
ret
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006, Intel Corporation
+# Copyright (c) 2006 - 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
.global ASM_PFX(AsmReadMm1)
.align 16
ASM_PFX(AsmReadMm1):
- #DB 48h, 0fh, 7eh, 0c8h
movd %mm1, %rax
ret
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006, Intel Corporation
+# Copyright (c) 2006 - 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
.global ASM_PFX(AsmReadMm2)
.align 16
ASM_PFX(AsmReadMm2):
- #DB 48h, 0fh, 7eh, 0d0h
movd %mm2, %rax
ret
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006, Intel Corporation
+# Copyright (c) 2006 - 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
.global ASM_PFX(AsmReadMm3)
.align 16
ASM_PFX(AsmReadMm3):
- #DB 48h, 0fh, 7eh, 0d8h
movd %mm3, %rax
ret
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006, Intel Corporation
+# Copyright (c) 2006 - 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
.global ASM_PFX(AsmReadMm4)
.align 16
ASM_PFX(AsmReadMm4):
- #DB 48h, 0fh, 7eh, 0e0h
movd %mm4, %rax
ret
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006, Intel Corporation
+# Copyright (c) 2006 - 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
.global ASM_PFX(AsmReadMm5)
.align 16
ASM_PFX(AsmReadMm5):
- #DB 48h, 0fh, 7eh, 0e8h
movd %mm5, %rax
ret
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006, Intel Corporation
+# Copyright (c) 2006 - 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
.global ASM_PFX(AsmReadMm6)
.align 16
ASM_PFX(AsmReadMm6):
- #DB 48h, 0fh, 7eh, 0f0h
movd %mm6, %rax
ret
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006, Intel Corporation
+# Copyright (c) 2006 - 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
.global ASM_PFX(AsmReadMm7)
.align 16
ASM_PFX(AsmReadMm7):
- #DB 48h, 0fh, 7eh, 0f8h
movd %mm7, %rax
ret
;------------------------------------------------------------------------------\r
;\r
-; Copyright (c) 2006, Intel Corporation\r
+; Copyright (c) 2006 - 2008, Intel Corporation\r
; All rights reserved. This program and the accompanying materials\r
; are licensed and made available under the terms and conditions of the BSD License\r
; which accompanies this distribution. The full text of the license may be found at\r
;------------------------------------------------------------------------------\r
; UINTN\r
; EFIAPI\r
-; AsmWriteDr6 (\r
+; AsmWriteDr5 (\r
; IN UINTN Value\r
; );\r
;------------------------------------------------------------------------------\r
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006, Intel Corporation
+# Copyright (c) 2006 - 2008, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# IN UINT32 Index,
# IN UINT64 Value
# );
-# TODO:
#------------------------------------------------------------------------------
.global ASM_PFX(AsmWriteMsr64)
.align 16
ASM_PFX(AsmWriteMsr64):
- mov %rdx, %rax
- shr $0x20, %rdx
+ mov %rdx, %rax # meanwhile, rax <- return value
+ shr $0x20, %rdx # edx:eax contains the value to write
wrmsr
ret