diff options
author | bxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-11-15 09:31:03 +0000 |
---|---|---|
committer | bxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-11-15 09:31:03 +0000 |
commit | 38b5365e3931f6ff0a130338a367bba5ee473628 (patch) | |
tree | ec19f4d2a231f8ecbe443c87ab4ada53ce4a09cf /MdePkg/Library/BaseLib/X64 | |
parent | adf6ff605fbcf882a45d3e2e14d7ddf9ea71d946 (diff) | |
download | edk2-38b5365e3931f6ff0a130338a367bba5ee473628.zip edk2-38b5365e3931f6ff0a130338a367bba5ee473628.tar.gz edk2-38b5365e3931f6ff0a130338a367bba5ee473628.tar.bz2 |
Enabled 4G+ memory in thunk.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1957 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/BaseLib/X64')
-rw-r--r-- | MdePkg/Library/BaseLib/X64/Thunk16.asm | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/MdePkg/Library/BaseLib/X64/Thunk16.asm b/MdePkg/Library/BaseLib/X64/Thunk16.asm index 631b0fd..b77ba68 100644 --- a/MdePkg/Library/BaseLib/X64/Thunk16.asm +++ b/MdePkg/Library/BaseLib/X64/Thunk16.asm @@ -100,6 +100,11 @@ _ThunkAttr DD ? mov ebx, (IA32_REGS ptr [rsi - sizeof (IA32_REGS)])._EIP
shl ax, 4 ; shl eax, 4
add bp, ax ; add ebp, eax
+ mov ax, cs
+ shl ax, 4
+ lea ax, [eax + ebx + (@64BitCode - @Base)]
+ DB 2eh ; cs:
+ mov [rdi + (@64Eip - @Base)], ax
DB 66h, 0b8h ; mov eax, imm32
SavedCr4 DD ?
mov cr4, rax
@@ -113,13 +118,13 @@ SavedCr4 DD ? DB 66h, 0b8h ; mov eax, imm32
SavedCr0 DD ?
mov cr0, rax
- DB 0b8h ; mov ax, imm16
-SavedSs DW ?
- mov ss, eax
- DB 66h, 0bch ; mov esp, imm32
-SavedEsp DD ?
- DB 66h
- retf ; return to protected mode
+ DB 66h, 0eah ; jmp far cs:@64Bit
+@64Eip DD ?
+SavedCs DW ?
+@64BitCode:
+ DB 48h, 0b8h ; mov rax, imm64
+SavedRip DQ ?
+ jmp rax ; return to caller
_BackFromUserCode ENDP
_EntryPoint DD _ToUserCode - m16Start
@@ -147,7 +152,7 @@ _ToUserCode PROC wrmsr
mov cr4, rbp
mov ss, esi ; set up 16-bit stack segment
- xchg sp, bx ; set up 16-bit stack pointer
+ mov sp, bx ; set up 16-bit stack pointer
DB 66h
call @Base ; push eip
@Base:
@@ -157,11 +162,6 @@ _ToUserCode PROC push rax
retf
@RealMode:
- DB 6ah, DATA32
- DB 2eh ; cs:
- pop [rsi + (SavedSs - @Base)]
- DB 2eh ; cs:
- mov [rsi + (SavedEsp - @Base)], bx
DB 66h, 2eh ; CS and operand size override
lidt fword ptr [rsi + (_16Idtr - @Base)]
DB 66h, 61h ; popad
@@ -232,8 +232,7 @@ InternalAsmThunk16 PROC USES rbp rbx rsi rdi mov eax, edx ; eax <- transition code address
and edx, 0fh
shl eax, 12
- lea edx, [rdx + (_BackFromUserCode - m16Start)]
- mov ax, dx
+ lea ax, [rdx + (_BackFromUserCode - m16Start)]
stosd ; [edi] <- return address of user code
sgdt fword ptr [rcx + (SavedGdt - SavedCr4)]
sidt fword ptr [rsp + 38h] ; save IDT stack in argument space
@@ -250,7 +249,14 @@ InternalAsmThunk16 PROC USES rbp rbx rsi rdi mov ss, edx
pushfq
lea edx, [rdx + DATA16 - DATA32]
- call fword ptr [rcx + (_EntryPoint - SavedCr4)]
+ lea r8, @RetFromRealMode
+ mov [rcx + (SavedRip - SavedCr4)], r8
+ mov r8d, cs
+ mov [rcx + (SavedCs - SavedCr4)], r8w
+ mov r8, rsp
+ jmp fword ptr [rcx + (_EntryPoint - SavedCr4)]
+@RetFromRealMode:
+ mov rsp, r8
popfq
lidt fword ptr [rsp + 38h] ; restore protected mode IDTR
lea eax, [rbp - sizeof (IA32_REGS)]
|