]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmulatorPkg: Fix Visual Studio build for IA32 & X64
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 15 Aug 2012 00:03:25 +0000 (00:03 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 15 Aug 2012 00:03:25 +0000 (00:03 +0000)
This code is untested since there is currently no 'host' component
for Win32/Win64.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13633 6f19259b-4bc3-4df7-8a09-765794883524

EmulatorPkg/CpuRuntimeDxe/Cpu.c
EmulatorPkg/CpuRuntimeDxe/CpuIo.c
EmulatorPkg/CpuRuntimeDxe/MpService.c
EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.c
EmulatorPkg/Library/SmbiosLib/SmbiosLib.c
EmulatorPkg/Sec/Ia32/SwitchRam.asm [new file with mode: 0644]
EmulatorPkg/Sec/Sec.inf
EmulatorPkg/Sec/X64/SwitchRam.asm [new file with mode: 0644]
EmulatorPkg/TimerDxe/Timer.c

index fc8d325ffc26a7488fca033d4cac6f2af1aeebd0..b25ed45da4f1ca4af0a993ccba92ce515bbf11e1 100644 (file)
@@ -1,7 +1,7 @@
 /*++ @file\r
   Emu driver to produce CPU Architectural Protocol.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2011 - 2012, Apple Inc. All rights reserved.\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -241,9 +241,9 @@ CpuUpdateSmbios (
   IN UINTN  MaxCpus\r
   )\r
 {\r
-  mCpuSmbiosType4.CoreCount        = MaxCpus;\r
-  mCpuSmbiosType4.EnabledCoreCount = MaxCpus;\r
-  mCpuSmbiosType4.ThreadCount      = MaxCpus;\r
+  mCpuSmbiosType4.CoreCount        = (UINT8) MaxCpus;\r
+  mCpuSmbiosType4.EnabledCoreCount = (UINT8) MaxCpus;\r
+  mCpuSmbiosType4.ThreadCount      = (UINT8) MaxCpus;\r
 \r
   LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mCpuSmbiosType4, mCpuSmbiosType4Strings);\r
 }\r
index 3d4309d4221cab6ab9de63dc277811e64e285165..37905f892afd5c66fd5a9c5681c180a60c45a355 100644 (file)
@@ -6,7 +6,7 @@
   Bridge I/O Protocol.\r
 \r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -315,7 +315,7 @@ CpuIoCheckAddressRange (
   }\r
 \r
   Width = Width & 0x03;\r
-  if (Address - 1 + (1 << Width) * Count > Limit) {\r
+  if ((Address - 1 + LShiftU64 (Count, Width)) > Limit) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
index 6eecbbc9bd3ba939b6050818e5d899eed648f9bd..bffc82b0479fed4fbe2233111e194997645711f1 100644 (file)
@@ -28,7 +28,7 @@
   APs to help test system memory in parallel with other device initialization.\r
   Diagnostics applications may also use this protocol for multi-processor.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 Portitions Copyright (c) 2011, Apple Inc. All rights reserved.\r
 This program and the accompanying materials are licensed and made available under\r
 the terms and conditions of the BSD License that accompanies this distribution.\r
@@ -1158,7 +1158,7 @@ FillInProcessorInformation (
     gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_AS_BSP_BIT;\r
   }\r
 \r
-  gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Package = ProcessorNumber;\r
+  gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Package = (UINT32) ProcessorNumber;\r
   gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Core    = 0;\r
   gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Thread  = 0;\r
   gMPSystem.ProcessorData[ProcessorNumber].State = BSP ? CPU_STATE_BUSY : CPU_STATE_IDLE;\r
@@ -1332,7 +1332,7 @@ CpuMpServicesInit (
     return EFI_SUCCESS;\r
   }\r
 \r
-  gPollInterval = PcdGet64 (PcdEmuMpServicesPollingInterval);\r
+  gPollInterval = (UINTN) PcdGet64 (PcdEmuMpServicesPollingInterval);\r
 \r
   Status  = InitializeMpSystemData (*MaxCpus);\r
   if (EFI_ERROR (Status)) {\r
index 2c47a4f006021d47bbc6c003fa1f6375e367122d..46560f8117a964913c2241fac32af984b1bd337d 100644 (file)
@@ -1,6 +1,6 @@
 /*++ @file\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -292,6 +292,6 @@ PeCoffGetSizeOfHeaders (
     SizeOfHeaders = 0;\r
   }\r
 \r
-  return SizeOfHeaders;\r
+  return (UINT32) SizeOfHeaders;\r
 }\r
 \r
index 604aa39d0c61917673282c2e97117a344e3431a6..3382d7d2a6632e4b522f44677b9f16905fce645d 100644 (file)
@@ -4,7 +4,7 @@
 
 
 Copyright (c) 2012, Apple Inc. All rights reserved.
-Portitions Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Portitions Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials are licensed and made available under 
 the terms and conditions of the BSD License that accompanies this distribution.  
 The full text of the license may be found at
@@ -50,10 +50,12 @@ SmbiosLibInitializeFromTemplate (
     return EFI_INVALID_PARAMETER;
   }
 
+  Status = EFI_SUCCESS;
+
   for (Index = 0; Template[Index].Entry != NULL; Index++) {
     Status = SmbiosLibCreateEntry (Template[Index].Entry, Template[Index].StringArray);
   }
-  
+
   return Status;
 }
 
diff --git a/EmulatorPkg/Sec/Ia32/SwitchRam.asm b/EmulatorPkg/Sec/Ia32/SwitchRam.asm
new file mode 100644 (file)
index 0000000..a2e1f3e
--- /dev/null
@@ -0,0 +1,94 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+; 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
+; http://opensource.org/licenses/bsd-license.php\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+;   Stack.asm\r
+;\r
+; Abstract:\r
+;\r
+;   Switch the stack from temporary memory to permenent memory.\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    .586p\r
+    .model  flat,C\r
+    .code\r
+    \r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; SecSwitchStack (\r
+;   UINT32   TemporaryMemoryBase,\r
+;   UINT32   PermenentMemoryBase\r
+;   );\r
+;------------------------------------------------------------------------------    \r
+SecSwitchStack   PROC\r
+    ;\r
+    ; Save three register: eax, ebx, ecx\r
+    ;\r
+    push  eax\r
+    push  ebx\r
+    push  ecx\r
+    push  edx\r
+    \r
+    ;\r
+    ; !!CAUTION!! this function address's is pushed into stack after\r
+    ; migration of whole temporary memory, so need save it to permenent\r
+    ; memory at first!\r
+    ;\r
+    \r
+    mov   ebx, [esp + 20]          ; Save the first parameter\r
+    mov   ecx, [esp + 24]          ; Save the second parameter\r
+    \r
+    ;\r
+    ; Save this function's return address into permenent memory at first.\r
+    ; Then, Fixup the esp point to permenent memory\r
+    ;\r
+    mov   eax, esp\r
+    sub   eax, ebx\r
+    add   eax, ecx\r
+    mov   edx, dword ptr [esp]         ; copy pushed register's value to permenent memory\r
+    mov   dword ptr [eax], edx    \r
+    mov   edx, dword ptr [esp + 4]\r
+    mov   dword ptr [eax + 4], edx    \r
+    mov   edx, dword ptr [esp + 8]\r
+    mov   dword ptr [eax + 8], edx    \r
+    mov   edx, dword ptr [esp + 12]\r
+    mov   dword ptr [eax + 12], edx    \r
+    mov   edx, dword ptr [esp + 16]    ; Update this function's return address into permenent memory\r
+    mov   dword ptr [eax + 16], edx    \r
+    mov   esp, eax                     ; From now, esp is pointed to permenent memory\r
+        \r
+    ;\r
+    ; Fixup the ebp point to permenent memory\r
+    ;\r
+    mov   eax, ebp\r
+    sub   eax, ebx\r
+    add   eax, ecx\r
+    mov   ebp, eax                ; From now, ebp is pointed to permenent memory\r
+    \r
+    ;\r
+    ; Fixup callee's ebp point for PeiDispatch\r
+    ;\r
+    mov   eax, dword ptr [ebp]\r
+    sub   eax, ebx\r
+    add   eax, ecx\r
+    mov   dword ptr [ebp], eax    ; From now, Temporary's PPI caller's stack is in permenent memory\r
+    \r
+    pop   edx\r
+    pop   ecx\r
+    pop   ebx\r
+    pop   eax\r
+    ret\r
+SecSwitchStack   ENDP\r
+\r
+    END\r
index 484e7a0a93f92a399db557092c81b4b0d970309f..d253fd724e8ff1c208b6721930f02479fdeff20f 100644 (file)
@@ -3,6 +3,7 @@
 #\r
 # Main executable file of Unix Emulator that loads PEI core after initialization finished.\r
 # Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>\r
+# Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
   Sec.c\r
 \r
 [Sources.X64]\r
+  X64/SwitchRam.asm\r
   X64/SwitchRam.S\r
 \r
 [Sources.IA32]\r
   Ia32/TempRam.c\r
+  Ia32/SwitchRam.asm\r
   Ia32/SwitchRam.S\r
 \r
 [Packages]\r
diff --git a/EmulatorPkg/Sec/X64/SwitchRam.asm b/EmulatorPkg/Sec/X64/SwitchRam.asm
new file mode 100644 (file)
index 0000000..d1a7b94
--- /dev/null
@@ -0,0 +1,76 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+; Portitions copyright (c) 2011, Apple Inc. All rights reserved.\r
+; 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
+; http://opensource.org/licenses/bsd-license.php.\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+EXTERN CopyMem:PROC\r
+EXTERN ZeroMem:PROC\r
+\r
+    .code\r
+\r
+;------------------------------------------------------------------------------\r
+;  EFI_STATUS\r
+;  EFIAPI\r
+;  SecTemporaryRamSupport (\r
+;    IN CONST EFI_PEI_SERVICES   **PeiServices,         // %rcx\r
+;    IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,   // %rdx\r
+;    IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,   // %r8\r
+;    IN UINTN                    CopySize               // %r9\r
+;    )\r
+;------------------------------------------------------------------------------\r
+SecTemporaryRamSupport PROC\r
+  ; Adjust callers %rbp to account for stack move\r
+  sub     rbp, rdx      ; Calc offset of %rbp in Temp Memory\r
+  add     rbp, r8       ; add in permanent base to offset\r
+\r
+  push    rbp           ; stack frame is for the debugger\r
+  mov     rbp, rsp\r
+\r
+  push    rdx           ; Save TemporaryMemoryBase\r
+  push    r8            ; Save PermanentMemoryBase\r
+  push    r9            ; Save CopySize\r
+\r
+  ;\r
+  ; Copy all of temp RAM to permanent memory, including stack\r
+  ;\r
+  ; CopyMem (PermanentMemoryBase, TemporaryMemoryBase, CopySize);\r
+  ;          %rcx,                %rdx,                %r8\r
+  mov     rcx, r8       ; Shift arguments\r
+  mov     r8, r9\r
+  sub     rsp, 028h     ; Allocate register spill area & 16-byte align stack\r
+  call    CopyMem\r
+  ; Temp mem stack now copied to permanent location. %esp still in temp memory\r
+  add     rsp, 028h\r
+\r
+  pop     r9            ; CopySize (old stack)\r
+  pop     r8            ; PermanentMemoryBase (old stack)\r
+  pop     rdx           ; TemporaryMemoryBase (old stack)\r
+\r
+  mov     rcx, rsp      ; Move to new stack\r
+  sub     rcx, rdx      ; Calc offset of stack in Temp Memory\r
+  add     rcx, r8       ; Calc PermanentMemoryBase address\r
+  mov     rsp, rcx      ; Update stack\r
+  ; Stack now points to permanent memory\r
+\r
+  ; ZeroMem (TemporaryMemoryBase /* rcx */, CopySize /* rdx */);\r
+  mov     rcx, rdx\r
+  mov     rdx, r9\r
+  sub     rsp, 028h     ; Allocate register spill area & 16-byte align stack\r
+  call    ZeroMem\r
+  add     rsp, 028h\r
+\r
+  ; This data comes off the NEW stack\r
+  pop     rbp\r
+  ret\r
+SecTemporaryRamSupport ENDP\r
+\r
+  END\r
index d19ced7dd9ac6a3e6e5cdfa30541c8f05cadbfe8..5230a9625e97a6843a5cc13b2903d140bc705666 100644 (file)
@@ -5,7 +5,7 @@
   timer service.  In the future, the Thread creation should possibly be\r
   abstracted by the CPU architectural protocol\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -74,7 +74,7 @@ TimerCallback (UINT64 DeltaMs)
     // registered. Assume all other handlers are legal.\r
     //\r
     if (CallbackFunction != NULL) {\r
-      CallbackFunction ((UINT64) (DeltaMs * 10000));\r
+      CallbackFunction (MultU64x32 (DeltaMs, 10000));\r
     }\r
   }\r
 \r
@@ -246,7 +246,7 @@ Returns:
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  *TimerPeriod = mTimerPeriodMs * 10000;\r
+  *TimerPeriod = MultU64x32 (mTimerPeriodMs, 10000);\r
 \r
   return EFI_SUCCESS;\r
 }\r