]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OVMF ResetVector: Modify interface with SEC module
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 16 Dec 2009 23:29:15 +0000 (23:29 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 16 Dec 2009 23:29:15 +0000 (23:29 +0000)
Previously it was:
  ESI/RSI - SEC Core entry point
  EDI/RDI - PEI Core entry point
  EBP/RBP - Start of BFV

Now it is:
  RAX/EAX  Initial value of the EAX register
           (BIST: Built-in Self Test)
  DI       'BP': boot-strap processor, or
           'AP': application processor
  RBP/EBP  Address of Boot Firmware Volume (BFV)

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9571 6f19259b-4bc3-4df7-8a09-765794883524

23 files changed:
OvmfPkg/ResetVector/Bin/ResetVector.ia32.port80.raw [new file with mode: 0644]
OvmfPkg/ResetVector/Bin/ResetVector.ia32.raw
OvmfPkg/ResetVector/Bin/ResetVector.ia32.serial.raw [new file with mode: 0644]
OvmfPkg/ResetVector/Bin/ResetVector.x64.port80.raw [new file with mode: 0644]
OvmfPkg/ResetVector/Bin/ResetVector.x64.raw
OvmfPkg/ResetVector/Bin/ResetVector.x64.serial.raw [new file with mode: 0644]
OvmfPkg/ResetVector/Build.py [new file with mode: 0644]
OvmfPkg/ResetVector/CommonMacros.inc
OvmfPkg/ResetVector/DebugDisabled.asm [new file with mode: 0644]
OvmfPkg/ResetVector/Ia16/16RealTo32Flat.asm
OvmfPkg/ResetVector/Ia16/Init16.asm [new file with mode: 0644]
OvmfPkg/ResetVector/Ia16/ResetVectorOldTools.asm [deleted file]
OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm
OvmfPkg/ResetVector/Ia32/32FlatTo64Flat.asm
OvmfPkg/ResetVector/Ia32/SearchForBfvBase.asm
OvmfPkg/ResetVector/Ia32/SearchForSecAndPeiEntries.asm [deleted file]
OvmfPkg/ResetVector/Ia32/SearchForSecEntry.asm [new file with mode: 0644]
OvmfPkg/ResetVector/JumpToSec.asm [deleted file]
OvmfPkg/ResetVector/Main.asm [new file with mode: 0644]
OvmfPkg/ResetVector/Port80Debug.asm [new file with mode: 0644]
OvmfPkg/ResetVector/PostCodes.inc [new file with mode: 0644]
OvmfPkg/ResetVector/ResetVectorCode.asm
OvmfPkg/ResetVector/SerialDebug.asm

diff --git a/OvmfPkg/ResetVector/Bin/ResetVector.ia32.port80.raw b/OvmfPkg/ResetVector/Bin/ResetVector.ia32.port80.raw
new file mode 100644 (file)
index 0000000..b136e69
Binary files /dev/null and b/OvmfPkg/ResetVector/Bin/ResetVector.ia32.port80.raw differ
index 76286b9fa3c49e96543042703f424cc2004062d4..f772255004a366fef2b693f0e54a4c2d2c93ccb8 100644 (file)
Binary files a/OvmfPkg/ResetVector/Bin/ResetVector.ia32.raw and b/OvmfPkg/ResetVector/Bin/ResetVector.ia32.raw differ
diff --git a/OvmfPkg/ResetVector/Bin/ResetVector.ia32.serial.raw b/OvmfPkg/ResetVector/Bin/ResetVector.ia32.serial.raw
new file mode 100644 (file)
index 0000000..7b17db9
Binary files /dev/null and b/OvmfPkg/ResetVector/Bin/ResetVector.ia32.serial.raw differ
diff --git a/OvmfPkg/ResetVector/Bin/ResetVector.x64.port80.raw b/OvmfPkg/ResetVector/Bin/ResetVector.x64.port80.raw
new file mode 100644 (file)
index 0000000..307fc66
Binary files /dev/null and b/OvmfPkg/ResetVector/Bin/ResetVector.x64.port80.raw differ
index adf44b10286bc4ec4ab35ffbd2d325889a19096c..aff1447b99c73418742563240532a6161f0bfbd4 100644 (file)
Binary files a/OvmfPkg/ResetVector/Bin/ResetVector.x64.raw and b/OvmfPkg/ResetVector/Bin/ResetVector.x64.raw differ
diff --git a/OvmfPkg/ResetVector/Bin/ResetVector.x64.serial.raw b/OvmfPkg/ResetVector/Bin/ResetVector.x64.serial.raw
new file mode 100644 (file)
index 0000000..3224e3f
Binary files /dev/null and b/OvmfPkg/ResetVector/Bin/ResetVector.x64.serial.raw differ
diff --git a/OvmfPkg/ResetVector/Build.py b/OvmfPkg/ResetVector/Build.py
new file mode 100644 (file)
index 0000000..ff723c8
--- /dev/null
@@ -0,0 +1,53 @@
+## @file
+#  Automate the process of building the various reset vector types
+#
+#  Copyright (c) 2009, 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
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+import glob
+import os
+import subprocess
+import sys
+
+def RunCommand(commandLine):
+    #print ' '.join(commandLine)
+    return subprocess.call(commandLine)
+
+for filename in glob.glob(os.path.join('Bin', '*.raw')):
+    os.remove(filename)
+
+for arch in ('ia32', 'x64'):
+    for debugType in (None, 'port80', 'serial'):
+        output = os.path.join('Bin', 'ResetVector')
+        output += '.' + arch
+        if debugType is not None:
+            output += '.' + debugType
+        output += '.raw'
+        commandLine = (
+            'nasm',
+            '-D', 'ARCH_%s' % arch.upper(),
+            '-D', 'DEBUG_%s' % str(debugType).upper(),
+            '-o', output,
+            'ResetVectorCode.asm',
+            )
+        ret = RunCommand(commandLine)
+        print '\tASM\t' + output
+        if ret != 0: sys.exit(ret)
+
+        commandLine = (
+            'python',
+            'Tools/FixupForRawSection.py',
+            output,
+            )
+        print '\tFIXUP\t' + output
+        ret = RunCommand(commandLine)
+        if ret != 0: sys.exit(ret)
+
index 19c6d07a3f3cdeb152388338235972b2f9e3c879..c25c8663ed46f3c3d7474497aaa1310f826cda57 100644 (file)
@@ -1,4 +1,6 @@
 ;------------------------------------------------------------------------------\r
+; @file\r
+; Common macros used in the ResetVector VTF module.\r
 ;\r
 ; Copyright (c) 2008, Intel Corporation\r
 ; All rights reserved. This program and the accompanying materials\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
-;   CommonMacros.inc\r
-;\r
-; Abstract:\r
-;\r
-;   Common macros used in the ResetVector VTF module.\r
-;\r
 ;------------------------------------------------------------------------------\r
 \r
 %define ADDR16_OF(x) (0x10000 - fourGigabytes + x)\r
 %define ADDR_OF(x) (0x100000000 - fourGigabytes + x)\r
 \r
-%macro  callEdx 1\r
-    mov     edx, ADDR_OF(%%returnLabel)\r
-    jmp     %1\r
-%%returnLabel:\r
-%endmacro\r
-\r
 %macro  OneTimeCall 1\r
     jmp     %1\r
 %1 %+ OneTimerCallReturn:\r
diff --git a/OvmfPkg/ResetVector/DebugDisabled.asm b/OvmfPkg/ResetVector/DebugDisabled.asm
new file mode 100644 (file)
index 0000000..78389f4
--- /dev/null
@@ -0,0 +1,26 @@
+;------------------------------------------------------------------------------\r
+; @file\r
+; Debug disabled\r
+;\r
+; Copyright (c) 2009, 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
+; 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
+BITS    16\r
+\r
+%macro  debugInitialize 0\r
+    ;\r
+    ; No initialization is required\r
+    ;\r
+%endmacro\r
+\r
+%macro  debugShowPostCode 1\r
+%endmacro\r
+\r
index d030c0b52b5aab26287ff0f095f778db1e6cb3d2..47e3c6d9297abbb363982df90e559b3f16b90cb8 100644 (file)
@@ -1,6 +1,8 @@
 ;------------------------------------------------------------------------------\r
+; @file\r
+; Transition from 16 bit real mode into 32 bit flat protected mode\r
 ;\r
-; Copyright (c) 2008, Intel Corporation\r
+; Copyright (c) 2008 - 2009, 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
@@ -9,14 +11,6 @@
 ; 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
-;   16RealTo32Flat.asm\r
-;\r
-; Abstract:\r
-;\r
-;   Transition from 16 bit real mode into 32 bit flat protected mode\r
-;\r
 ;------------------------------------------------------------------------------\r
 \r
 %define SEC_DEFAULT_CR0  0x40000023\r
 \r
 BITS    16\r
 \r
-to32BitFlat:\r
+;\r
+; Modified:  EAX, EBX\r
+;\r
+TransitionFromReal16To32BitFlat:\r
 \r
-    writeToSerialPort '1'\r
-    writeToSerialPort '6'\r
-    writeToSerialPort ' '\r
+    debugShowPostCode POSTCODE_16BIT_MODE\r
 \r
     cli\r
 \r
@@ -42,10 +37,6 @@ o32 lgdt    [bx]
     mov     eax, SEC_DEFAULT_CR0\r
     mov     cr0, eax\r
 \r
-;    mov     eax, cr0\r
-;    or      al, 1\r
-;    mov     cr0, eax\r
-\r
     jmp     LINEAR_CODE_SEL:dword ADDR_OF(jumpTo32BitAndLandHere)\r
 BITS    32\r
 jumpTo32BitAndLandHere:\r
@@ -53,18 +44,16 @@ jumpTo32BitAndLandHere:
     mov     eax, SEC_DEFAULT_CR4\r
     mov     cr4, eax\r
 \r
-    writeToSerialPort '3'\r
-    writeToSerialPort '2'\r
-    writeToSerialPort ' '\r
+    debugShowPostCode POSTCODE_32BIT_MODE\r
 \r
-    mov ax, LINEAR_SEL\r
-    mov ds, ax\r
-    mov es, ax\r
-    mov fs, ax\r
-    mov gs, ax\r
-    mov ss, ax\r
+    mov     ax, LINEAR_SEL\r
+    mov     ds, ax\r
+    mov     es, ax\r
+    mov     fs, ax\r
+    mov     gs, ax\r
+    mov     ss, ax\r
 \r
-    jmp     TransitionFrom16RealTo32FlatComplete\r
+    OneTimeCallRet TransitionFromReal16To32BitFlat\r
 \r
 ALIGN   2\r
 \r
@@ -77,75 +66,75 @@ ALIGN   16
 GDT_BASE:\r
 ; null descriptor\r
 NULL_SEL            equ $-GDT_BASE\r
-        dw 0            ; limit 15:0\r
-        dw 0            ; base 15:0\r
-        db 0            ; base 23:16\r
-        db 0            ; type\r
-        db 0            ; limit 19:16, flags\r
-        db 0            ; base 31:24\r
+    dw      0            ; limit 15:0\r
+    dw      0            ; base 15:0\r
+    db      0            ; base 23:16\r
+    db      0            ; type\r
+    db      0            ; limit 19:16, flags\r
+    db      0            ; base 31:24\r
 \r
 ; linear data segment descriptor\r
 LINEAR_SEL      equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
+    dw      0FFFFh       ; limit 0xFFFFF\r
+    dw      0            ; base 0\r
+    db      0\r
+    db      092h         ; present, ring 0, data, expand-up, writable\r
+    db      0CFh         ; page-granular, 32-bit\r
+    db      0\r
 \r
 ; linear code segment descriptor\r
 LINEAR_CODE_SEL equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
+    dw      0FFFFh       ; limit 0xFFFFF\r
+    dw      0            ; base 0\r
+    db      0\r
+    db      09Ah         ; present, ring 0, data, expand-up, writable\r
+    db      0CFh         ; page-granular, 32-bit\r
+    db      0\r
 \r
 ; system data segment descriptor\r
 SYS_DATA_SEL    equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 092h         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
+    dw      0FFFFh       ; limit 0xFFFFF\r
+    dw      0            ; base 0\r
+    db      0\r
+    db      092h         ; present, ring 0, data, expand-up, writable\r
+    db      0CFh         ; page-granular, 32-bit\r
+    db      0\r
 \r
 ; system code segment descriptor\r
 SYS_CODE_SEL    equ $-GDT_BASE\r
-        dw 0FFFFh       ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 09Ah         ; present, ring 0, data, expand-up, writable\r
-        db 0CFh                 ; page-granular, 32-bit\r
-        db 0\r
+    dw      0FFFFh       ; limit 0xFFFFF\r
+    dw      0            ; base 0\r
+    db      0\r
+    db      09Ah         ; present, ring 0, data, expand-up, writable\r
+    db      0CFh         ; page-granular, 32-bit\r
+    db      0\r
 \r
 ; spare segment descriptor\r
 LINEAR_CODE64_SEL  equ $-GDT_BASE\r
-    DW      -1                  ; LimitLow\r
-    DW      0                   ; BaseLow\r
-    DB      0                   ; BaseMid\r
+    DW      -1           ; LimitLow\r
+    DW      0            ; BaseLow\r
+    DB      0            ; BaseMid\r
     DB      9bh\r
-    DB      0afh                ; LimitHigh   (CS.L=1, CS.D=0)\r
-    DB      0                   ; BaseHigh\r
+    DB      0afh         ; LimitHigh   (CS.L=1, CS.D=0)\r
+    DB      0            ; BaseHigh\r
 \r
 ; spare segment descriptor\r
 SPARE4_SEL  equ $-GDT_BASE\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
+    dw      0            ; limit 0xFFFFF\r
+    dw      0            ; base 0\r
+    db      0\r
+    db      0            ; present, ring 0, data, expand-up, writable\r
+    db      0            ; page-granular, 32-bit\r
+    db      0\r
 \r
 ; spare segment descriptor\r
 SPARE5_SEL  equ $-GDT_BASE\r
-        dw 0            ; limit 0xFFFFF\r
-        dw 0            ; base 0\r
-        db 0\r
-        db 0            ; present, ring 0, data, expand-up, writable\r
-        db 0            ; page-granular, 32-bit\r
-        db 0\r
+    dw      0            ; limit 0xFFFFF\r
+    dw      0            ; base 0\r
+    db      0\r
+    db      0            ; present, ring 0, data, expand-up, writable\r
+    db      0            ; page-granular, 32-bit\r
+    db      0\r
 \r
 GDT_END:\r
 \r
diff --git a/OvmfPkg/ResetVector/Ia16/Init16.asm b/OvmfPkg/ResetVector/Ia16/Init16.asm
new file mode 100644 (file)
index 0000000..3d3d8b0
--- /dev/null
@@ -0,0 +1,48 @@
+;------------------------------------------------------------------------------\r
+; @file\r
+; 16-bit initialization code\r
+;\r
+; Copyright (c) 2008 - 2009, 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
+; 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
+\r
+BITS    16\r
+\r
+;\r
+; @param[out] DI    'BP' to indicate boot-strap processor\r
+;\r
+EarlyBspInitReal16:\r
+    mov     di, 'BP'\r
+    jmp     short Main16\r
+\r
+;\r
+; @param[out] DI    'AP' to indicate application processor\r
+;\r
+EarlyApInitReal16:\r
+    mov     di, 'AP'\r
+    jmp     short Main16\r
+\r
+;\r
+; Modified:  EAX\r
+;\r
+; @param[in]  EAX   Initial value of the EAX register (BIST: Built-in Self Test)\r
+; @param[out] ESP   Initial value of the EAX register (BIST: Built-in Self Test)\r
+;\r
+EarlyInit16:\r
+    ;\r
+    ; ESP -  Initial value of the EAX register (BIST: Built-in Self Test)\r
+    ;\r
+    mov     esp, eax\r
+\r
+    debugInitialize\r
+\r
+    OneTimeCallRet EarlyInit16\r
+\r
diff --git a/OvmfPkg/ResetVector/Ia16/ResetVectorOldTools.asm b/OvmfPkg/ResetVector/Ia16/ResetVectorOldTools.asm
deleted file mode 100644 (file)
index 75e259b..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 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
-; 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
-;   Reset-16Bit-old-tools.asm\r
-;\r
-; Abstract:\r
-;\r
-;   First code exectuted by processor after resetting.\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
-BITS   16\r
-\r
-earlyInit_Real16:\r
-\r
-       jmp     real16InitSerialPort\r
-real16SerialPortInitReturn:\r
-\r
-       jmp     to32BitFlat\r
-\r
-ALIGN  16\r
-\r
-;\r
-; Junk data.  Old GenFv tool will modify data here.\r
-;\r
-       DQ      0, 0\r
-\r
-;\r
-; Reset Vector\r
-;\r
-; This is where the processor will begin execution\r
-;\r
-       jmp     short earlyInit_Real16\r
-\r
-;\r
-; Junk data.  Old GenFv tool will modify data here.\r
-;\r
-ALIGN  16\r
-\r
-fourGigabytes:\r
-\r
index 63aeaf6b24552ec5349a46a1cd59ae03a4a1fc2a..0eff743183a5c97ee1fcccb11b267788ca6861d0 100644 (file)
@@ -1,6 +1,8 @@
 ;------------------------------------------------------------------------------\r
+; @file\r
+; First code exectuted by processor after resetting.\r
 ;\r
-; Copyright (c) 2008, Intel Corporation\r
+; Copyright (c) 2008 - 2009, 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
 ; 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
-;   Reset-16Bit-vft0.asm\r
-;\r
-; Abstract:\r
-;\r
-;   First code exectuted by processor after resetting.\r
-;\r
 ;------------------------------------------------------------------------------\r
 \r
-BITS   16\r
-\r
-earlyInit_Real16:\r
+BITS    16\r
 \r
-       jmp     real16InitSerialPort\r
-real16SerialPortInitReturn:\r
+ALIGN   16\r
 \r
-       jmp     to32BitFlat\r
+applicationProcessorEntryPoint:\r
+;\r
+; Application Processors entry point\r
+;\r
+; GenFv generates code aligned on a 4k boundary which will jump to this\r
+; location.  (0xffffffe0)  This allows the Local APIC Startup IPI to be\r
+; used to wake up the application processors.\r
+;\r
+    jmp     short EarlyApInitReal16\r
 \r
-ALIGN  16\r
+ALIGN   8\r
 \r
-       DD      0, 0, 0\r
+    DD      0\r
 \r
 ;\r
 ; The VTF signature\r
@@ -39,16 +38,20 @@ ALIGN       16
 ; any fixups.\r
 ;\r
 vtfSignature:\r
-       DB      'V', 'T', 'F', 0\r
+    DB      'V', 'T', 'F', 0\r
+\r
+ALIGN   16\r
 \r
+resetVector:\r
 ;\r
 ; Reset Vector\r
 ;\r
 ; This is where the processor will begin execution\r
 ;\r
-       jmp     short earlyInit_Real16\r
+    wbinvd\r
+    jmp     short EarlyBspInitReal16\r
 \r
-ALIGN  16\r
+ALIGN   16\r
 \r
 fourGigabytes:\r
 \r
index f0528d4460fb7ef5f6426f06ef2121506b9135e9..a97f9cc70712dcc5f0eb6ef9aa509f02ec6d21bb 100644 (file)
@@ -1,6 +1,8 @@
 ;------------------------------------------------------------------------------\r
+; @file\r
+; Transition from 32 bit flat protected mode into 64 bit flat protected mode\r
 ;\r
-; Copyright (c) 2008, Intel Corporation\r
+; Copyright (c) 2008 - 2009, 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
 ; 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
-;   32FlatTo64Flat.asm\r
-;\r
-; Abstract:\r
-;\r
-;   Transition from 32 bit flat protected mode into 64 bit flat protected mode\r
-;\r
 ;------------------------------------------------------------------------------\r
 \r
 BITS    32\r
 \r
+;\r
+; Modified:  EAX\r
+;\r
 Transition32FlatTo64Flat:\r
 \r
     mov     eax, ((ADDR_OF_START_OF_RESET_CODE & ~0xfff) - 0x1000)\r
@@ -43,9 +40,7 @@ Transition32FlatTo64Flat:
 BITS    64\r
 jumpTo64BitAndLandHere:\r
 \r
-    writeToSerialPort '6'\r
-    writeToSerialPort '4'\r
-    writeToSerialPort ' '\r
+    debugShowPostCode POSTCODE_64BIT_MODE\r
 \r
     OneTimeCallRet Transition32FlatTo64Flat\r
 \r
index e6ca6e6ffbb8825d0f25f2e49380590f2077a52e..21b64f46e37b5be97f3069d0fa698ad3621a19d0 100644 (file)
@@ -1,6 +1,8 @@
 ;------------------------------------------------------------------------------\r
+; @file\r
+; Search for the Boot Firmware Volume (BFV) base address\r
 ;\r
-; Copyright (c) 2008, Intel Corporation\r
+; Copyright (c) 2008 - 2009, 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
@@ -9,14 +11,6 @@
 ; 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
-;   SearchForBfvBase.asm\r
-;\r
-; Abstract:\r
-;\r
-;   Search for the Boot FV Base Address\r
-;\r
 ;------------------------------------------------------------------------------\r
 \r
 ;#define EFI_FIRMWARE_FILE_SYSTEM2_GUID \\r
 BITS    32\r
 \r
 ;\r
-; Input:\r
-;   None\r
+; Modified:  EAX, EBX\r
+; Preserved: EDI, ESP\r
 ;\r
-; Output:\r
-;   EBP - BFV Base Address\r
-;\r
-; Modified:\r
-;   EAX, EBX\r
+; @param[out]  EBP  Address of Boot Firmware Volume (BFV)\r
 ;\r
 Flat32SearchForBfvBase:\r
 \r
     xor     eax, eax\r
 searchingForBfvHeaderLoop:\r
+    ;\r
+    ; We check for a firmware volume at every 4KB address in the top 16MB\r
+    ; just below 4GB.  (Addresses at 0xffHHH000 where H is any hex digit.)\r
+    ;\r
     sub     eax, 0x1000\r
-    cmp     eax, 0xff800000\r
+    cmp     eax, 0xff000000\r
     jb      searchedForBfvHeaderButNotFound\r
 \r
     ;\r
@@ -70,19 +64,23 @@ searchingForBfvHeaderLoop:
     jmp     searchedForBfvHeaderAndItWasFound\r
 \r
 searchedForBfvHeaderButNotFound:\r
-    writeToSerialPort '!'\r
-    xor     eax, eax\r
+    ;\r
+    ; Hang if the SEC entry point was not found\r
+    ;\r
+    debugShowPostCode POSTCODE_BFV_NOT_FOUND\r
 \r
-searchedForBfvHeaderAndItWasFound:\r
+    ;\r
+    ; 0xbfbfbfbf in the EAX & EBP registers helps signal what failed\r
+    ; for debugging purposes.\r
+    ;\r
+    mov     eax, 0xBFBFBFBF\r
     mov     ebp, eax\r
+    jmp     $\r
 \r
-    writeToSerialPort 'B'\r
-    writeToSerialPort 'F'\r
-    writeToSerialPort 'V'\r
-    writeToSerialPort ' '\r
+searchedForBfvHeaderAndItWasFound:\r
+    mov     ebp, eax\r
 \r
-    or      ebp, ebp\r
-    jz      $\r
+    debugShowPostCode POSTCODE_BFV_FOUND\r
 \r
     OneTimeCallRet Flat32SearchForBfvBase\r
 \r
diff --git a/OvmfPkg/ResetVector/Ia32/SearchForSecAndPeiEntries.asm b/OvmfPkg/ResetVector/Ia32/SearchForSecAndPeiEntries.asm
deleted file mode 100644 (file)
index 9bb0cd1..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 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
-; 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
-;   SearchForSecAndPeiEntry.asm\r
-;\r
-; Abstract:\r
-;\r
-;   Search for the SEC Core and PEI Core entry points\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
-BITS    32\r
-\r
-%define EFI_FV_FILETYPE_SECURITY_CORE         0x03\r
-%define EFI_FV_FILETYPE_PEI_CORE              0x04\r
-\r
-;\r
-; Input:\r
-;   EBP - BFV Base Address\r
-;\r
-; Output:\r
-;   ESI - SEC Core Entry Point Address (or 0 if not found)\r
-;   EDI - PEI Core Entry Point Address (or 0 if not found)\r
-;\r
-; Modified:\r
-;   EAX, EBX, ECX\r
-;\r
-Flat32SearchForSecAndPeiEntries:\r
-\r
-    ;\r
-    ; Initialize EBP and ESI to 0\r
-    ;\r
-    xor     ebx, ebx\r
-    mov     esi, ebx\r
-    mov     edi, ebx\r
-\r
-    ;\r
-    ; Pass over the BFV header\r
-    ;\r
-    mov     eax, ebp\r
-    mov     bx, [ebp + 0x30]\r
-    add     eax, ebx\r
-    jc      doneSeachingForSecAndPeiEntries\r
-\r
-    jmp     searchingForFfsFileHeaderLoop\r
-\r
-moveForwardWhileSearchingForFfsFileHeaderLoop:\r
-    ;\r
-    ; Make forward progress in the search\r
-    ;\r
-    inc     eax\r
-    jc      doneSeachingForSecAndPeiEntries\r
-\r
-searchingForFfsFileHeaderLoop:\r
-    test    eax, eax\r
-    jz      doneSeachingForSecAndPeiEntries\r
-\r
-    ;\r
-    ; Ensure 8 byte alignment\r
-    ;\r
-    add     eax, 7\r
-    jc      doneSeachingForSecAndPeiEntries\r
-    and     al, 0xf8\r
-\r
-    ;\r
-    ; Look to see if there is an FFS file at eax\r
-    ;\r
-    mov     bl, [eax + 0x17]\r
-    test    bl, 0x20\r
-    jz      moveForwardWhileSearchingForFfsFileHeaderLoop\r
-    mov     ecx, [eax + 0x14]\r
-    and     ecx, 0x00ffffff\r
-    or      ecx, ecx\r
-    jz      moveForwardWhileSearchingForFfsFileHeaderLoop\r
-;    jmp     $\r
-    add     ecx, eax\r
-    jz      jumpSinceWeFoundTheLastFfsFile\r
-    jc      moveForwardWhileSearchingForFfsFileHeaderLoop\r
-jumpSinceWeFoundTheLastFfsFile:\r
-\r
-    ;\r
-    ; There seems to be a valid file at eax\r
-    ;\r
-    mov     bl, [eax + 0x12] ; BL - File Type\r
-    cmp     bl, EFI_FV_FILETYPE_PEI_CORE\r
-    je      fileTypeIsPeiCore\r
-    cmp     bl, EFI_FV_FILETYPE_SECURITY_CORE\r
-    jne     readyToTryFfsFileAtEcx\r
-\r
-fileTypeIsSecCore:\r
-    callEdx GetEntryPointOfFfsFileReturnEdx\r
-    test    eax, eax\r
-    jz      readyToTryFfsFileAtEcx\r
-\r
-    mov     esi, eax\r
-    jmp     readyToTryFfsFileAtEcx\r
-\r
-fileTypeIsPeiCore:\r
-    callEdx GetEntryPointOfFfsFileReturnEdx\r
-    test    eax, eax\r
-    jz      readyToTryFfsFileAtEcx\r
-\r
-    mov     edi, eax\r
-\r
-readyToTryFfsFileAtEcx:\r
-    mov     eax, ecx\r
-    jmp     searchingForFfsFileHeaderLoop\r
-\r
-doneSeachingForSecAndPeiEntries:\r
-\r
-    test    esi, esi\r
-    jnz     secCoreEntryPointWasFound\r
-    writeToSerialPort '!'\r
-secCoreEntryPointWasFound:\r
-    writeToSerialPort 'S'\r
-    writeToSerialPort 'E'\r
-    writeToSerialPort 'C'\r
-    writeToSerialPort ' '\r
-\r
-    test    edi, edi\r
-    jnz     peiCoreEntryPointWasFound\r
-    writeToSerialPort '!'\r
-peiCoreEntryPointWasFound:\r
-    writeToSerialPort 'P'\r
-    writeToSerialPort 'E'\r
-    writeToSerialPort 'I'\r
-    writeToSerialPort ' '\r
-\r
-    OneTimeCallRet Flat32SearchForSecAndPeiEntries\r
-\r
-\r
-%define EFI_SECTION_PE32                  0x10\r
-\r
-;\r
-; Input:\r
-;   EAX - Start of FFS file\r
-;   ECX - End of FFS file\r
-;\r
-; Output:\r
-;   EAX - Entry point of PE32 (or 0 if not found)\r
-;\r
-; Modified:\r
-;   EBX\r
-;\r
-GetEntryPointOfFfsFileReturnEdx:\r
-    test    eax, eax\r
-    jz      getEntryPointOfFfsFileErrorReturn\r
-    add     eax, 0x18       ; EAX = Start of section\r
-\r
-getEntryPointOfFfsFileLoopForSections:\r
-    cmp     eax, ecx\r
-    jae     getEntryPointOfFfsFileErrorReturn\r
-\r
-    cmp     byte [eax + 3], EFI_SECTION_PE32\r
-    je      getEntryPointOfFfsFileFoundPe32Section\r
-\r
-    ;\r
-    ; The section type was not PE32, so move to next section\r
-    ;\r
-    mov     ebx, dword [eax]\r
-    and     ebx, 0x00ffffff\r
-    add     eax, ebx\r
-    jc      getEntryPointOfFfsFileErrorReturn\r
-\r
-    ;\r
-    ; Ensure that FFS section is 32-bit aligned\r
-    ;\r
-    add     eax, 3\r
-    jc      getEntryPointOfFfsFileErrorReturn\r
-    and     al, 0xfc\r
-    jmp     getEntryPointOfFfsFileLoopForSections\r
-\r
-getEntryPointOfFfsFileFoundPe32Section:\r
-    add     eax, 4       ; EAX = Start of PE32 image\r
-\r
-    mov     ebx, eax\r
-    cmp     word [eax], 'MZ'\r
-    jne     thereIsNotAnMzSignature\r
-    movzx   ebx, word [eax + 0x3c]\r
-    add     ebx, eax\r
-thereIsNotAnMzSignature:\r
-\r
-    ; if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE)\r
-    cmp     word [ebx], 'VZ'\r
-    jne     thereIsNoVzSignature\r
-    ; *EntryPoint = (VOID *)((UINTN)Pe32Data +\r
-    ;   (UINTN)(Hdr.Te->AddressOfEntryPoint & 0x0ffffffff) +\r
-    ;   sizeof(EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize);\r
-    add     eax, [ebx + 0x8]\r
-    add     eax, 0x28\r
-    movzx   ebx, word [ebx + 0x6]\r
-    sub     eax, ebx\r
-    jmp     getEntryPointOfFfsFileReturn\r
-\r
-thereIsNoVzSignature:\r
-\r
-    ; if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE)\r
-    cmp     dword [ebx], `PE\x00\x00`\r
-    jne     getEntryPointOfFfsFileErrorReturn\r
-\r
-    ; *EntryPoint = (VOID *)((UINTN)Pe32Data +\r
-    ;   (UINTN)(Hdr.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff));\r
-    add     eax, [ebx + 0x4 + 0x14 + 0x10]\r
-    jmp     getEntryPointOfFfsFileReturn\r
-\r
-getEntryPointOfFfsFileErrorReturn:\r
-    mov     eax, 0\r
-\r
-getEntryPointOfFfsFileReturn:\r
-    jmp     edx\r
-\r
-\r
diff --git a/OvmfPkg/ResetVector/Ia32/SearchForSecEntry.asm b/OvmfPkg/ResetVector/Ia32/SearchForSecEntry.asm
new file mode 100644 (file)
index 0000000..01d0519
--- /dev/null
@@ -0,0 +1,196 @@
+;------------------------------------------------------------------------------\r
+; @file\r
+; Search for the SEC Core entry point\r
+;\r
+; Copyright (c) 2008 - 2009, 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
+; 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
+BITS    32\r
+\r
+%define EFI_FV_FILETYPE_SECURITY_CORE         0x03\r
+\r
+;\r
+; Modified:  EAX, EBX, ECX, EDX\r
+; Preserved: EDI, EBP, ESP\r
+;\r
+; @param[in]   EBP  Address of Boot Firmware Volume (BFV)\r
+; @param[out]  ESI  SEC Core Entry Point Address\r
+;\r
+Flat32SearchForSecEntryPoint:\r
+\r
+    ;\r
+    ; Initialize EBP and ESI to 0\r
+    ;\r
+    xor     ebx, ebx\r
+    mov     esi, ebx\r
+\r
+    ;\r
+    ; Pass over the BFV header\r
+    ;\r
+    mov     eax, ebp\r
+    mov     bx, [ebp + 0x30]\r
+    add     eax, ebx\r
+    jc      secEntryPointWasNotFound\r
+\r
+    jmp     searchingForFfsFileHeaderLoop\r
+\r
+moveForwardWhileSearchingForFfsFileHeaderLoop:\r
+    ;\r
+    ; Make forward progress in the search\r
+    ;\r
+    inc     eax\r
+    jc      secEntryPointWasNotFound\r
+\r
+searchingForFfsFileHeaderLoop:\r
+    test    eax, eax\r
+    jz      secEntryPointWasNotFound\r
+\r
+    ;\r
+    ; Ensure 8 byte alignment\r
+    ;\r
+    add     eax, 7\r
+    jc      secEntryPointWasNotFound\r
+    and     al, 0xf8\r
+\r
+    ;\r
+    ; Look to see if there is an FFS file at eax\r
+    ;\r
+    mov     bl, [eax + 0x17]\r
+    test    bl, 0x20\r
+    jz      moveForwardWhileSearchingForFfsFileHeaderLoop\r
+    mov     ecx, [eax + 0x14]\r
+    and     ecx, 0x00ffffff\r
+    or      ecx, ecx\r
+    jz      moveForwardWhileSearchingForFfsFileHeaderLoop\r
+    add     ecx, eax\r
+    jz      jumpSinceWeFoundTheLastFfsFile\r
+    jc      moveForwardWhileSearchingForFfsFileHeaderLoop\r
+jumpSinceWeFoundTheLastFfsFile:\r
+\r
+    ;\r
+    ; There seems to be a valid file at eax\r
+    ;\r
+    cmp     byte [eax + 0x12], EFI_FV_FILETYPE_SECURITY_CORE ; Check File Type\r
+    jne     readyToTryFfsFileAtEcx\r
+\r
+fileTypeIsSecCore:\r
+    OneTimeCall GetEntryPointOfFfsFile\r
+    test    eax, eax\r
+    jnz     doneSeachingForSecEntryPoint\r
+\r
+readyToTryFfsFileAtEcx:\r
+    ;\r
+    ; Try the next FFS file at ECX\r
+    ;\r
+    mov     eax, ecx\r
+    jmp     searchingForFfsFileHeaderLoop\r
+\r
+secEntryPointWasNotFound:\r
+    xor     eax, eax\r
+\r
+doneSeachingForSecEntryPoint:\r
+    mov     esi, eax\r
+\r
+    test    esi, esi\r
+    jnz     secCoreEntryPointWasFound\r
+\r
+secCoreEntryPointWasNotFound:\r
+    ;\r
+    ; Hang if the SEC entry point was not found\r
+    ;\r
+    debugShowPostCode POSTCODE_SEC_NOT_FOUND\r
+    jz      $\r
+\r
+secCoreEntryPointWasFound:\r
+    debugShowPostCode POSTCODE_SEC_FOUND\r
+\r
+    OneTimeCallRet Flat32SearchForSecEntryPoint\r
+\r
+%define EFI_SECTION_PE32                  0x10\r
+\r
+;\r
+; Input:\r
+;   EAX - Start of FFS file\r
+;   ECX - End of FFS file\r
+;\r
+; Output:\r
+;   EAX - Entry point of PE32 (or 0 if not found)\r
+;\r
+; Modified:\r
+;   EBX\r
+;\r
+GetEntryPointOfFfsFile:\r
+    test    eax, eax\r
+    jz      getEntryPointOfFfsFileErrorReturn\r
+    add     eax, 0x18       ; EAX = Start of section\r
+\r
+getEntryPointOfFfsFileLoopForSections:\r
+    cmp     eax, ecx\r
+    jae     getEntryPointOfFfsFileErrorReturn\r
+\r
+    cmp     byte [eax + 3], EFI_SECTION_PE32\r
+    je      getEntryPointOfFfsFileFoundPe32Section\r
+\r
+    ;\r
+    ; The section type was not PE32, so move to next section\r
+    ;\r
+    mov     ebx, dword [eax]\r
+    and     ebx, 0x00ffffff\r
+    add     eax, ebx\r
+    jc      getEntryPointOfFfsFileErrorReturn\r
+\r
+    ;\r
+    ; Ensure that FFS section is 32-bit aligned\r
+    ;\r
+    add     eax, 3\r
+    jc      getEntryPointOfFfsFileErrorReturn\r
+    and     al, 0xfc\r
+    jmp     getEntryPointOfFfsFileLoopForSections\r
+\r
+getEntryPointOfFfsFileFoundPe32Section:\r
+    add     eax, 4       ; EAX = Start of PE32 image\r
+\r
+    mov     ebx, eax\r
+    cmp     word [eax], 'MZ'\r
+    jne     thereIsNotAnMzSignature\r
+    movzx   ebx, word [eax + 0x3c]\r
+    add     ebx, eax\r
+thereIsNotAnMzSignature:\r
+\r
+    ; if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE)\r
+    cmp     word [ebx], 'VZ'\r
+    jne     thereIsNoVzSignature\r
+    ; *EntryPoint = (VOID *)((UINTN)Pe32Data +\r
+    ;   (UINTN)(Hdr.Te->AddressOfEntryPoint & 0x0ffffffff) +\r
+    ;   sizeof(EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize);\r
+    add     eax, [ebx + 0x8]\r
+    add     eax, 0x28\r
+    movzx   ebx, word [ebx + 0x6]\r
+    sub     eax, ebx\r
+    jmp     getEntryPointOfFfsFileReturn\r
+\r
+thereIsNoVzSignature:\r
+\r
+    ; if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE)\r
+    cmp     dword [ebx], `PE\x00\x00`\r
+    jne     getEntryPointOfFfsFileErrorReturn\r
+\r
+    ; *EntryPoint = (VOID *)((UINTN)Pe32Data +\r
+    ;   (UINTN)(Hdr.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff));\r
+    add     eax, [ebx + 0x4 + 0x14 + 0x10]\r
+    jmp     getEntryPointOfFfsFileReturn\r
+\r
+getEntryPointOfFfsFileErrorReturn:\r
+    mov     eax, 0\r
+\r
+getEntryPointOfFfsFileReturn:\r
+    OneTimeCallRet GetEntryPointOfFfsFile\r
+\r
diff --git a/OvmfPkg/ResetVector/JumpToSec.asm b/OvmfPkg/ResetVector/JumpToSec.asm
deleted file mode 100644 (file)
index d7442f0..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 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
-; 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
-;   JumpToSec.asm\r
-;\r
-; Abstract:\r
-;\r
-;   Jump from the reset vector binary to SEC\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
-BITS    32\r
-\r
-TransitionFrom16RealTo32FlatComplete:\r
-\r
-    OneTimeCall Flat32SearchForBfvBase\r
-\r
-    OneTimeCall Flat32SearchForSecAndPeiEntries\r
-\r
-    ;\r
-    ; ESI - SEC Core entry point\r
-    ; EDI - PEI Core entry point\r
-    ; EBP - Start of BFV\r
-    ;\r
-    ; Jump to SEC Core entry point\r
-    ;\r
-\r
-%ifdef ARCH_IA32\r
-\r
-    jmp     esi\r
-\r
-%else\r
-\r
-    OneTimeCall Transition32FlatTo64Flat\r
-BITS    64\r
-\r
-    mov     rax, 0x00000000ffffffff\r
-    and     rsi, rax\r
-    and     rdi, rax\r
-    and     rbp, rax\r
-    ;\r
-    ; RSI - SEC Core entry point\r
-    ; RDI - PEI Core entry point\r
-    ; RBP - Start of BFV\r
-    ;\r
-    ; Jump to SEC Core entry point\r
-    ;\r
-\r
-    jmp     rsi\r
-\r
-%endif\r
-\r
-\r
diff --git a/OvmfPkg/ResetVector/Main.asm b/OvmfPkg/ResetVector/Main.asm
new file mode 100644 (file)
index 0000000..bc2a3b1
--- /dev/null
@@ -0,0 +1,106 @@
+;------------------------------------------------------------------------------\r
+; @file\r
+; Main routine of the pre-SEC code up through the jump into SEC\r
+;\r
+; Copyright (c) 2008 - 2009, 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
+; 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
+\r
+BITS    16\r
+\r
+;\r
+; Modified:  EBX, ECX, EDX, EBP\r
+;\r
+; @param[in,out]  RAX/EAX  Initial value of the EAX register\r
+;                          (BIST: Built-in Self Test)\r
+; @param[in,out]  DI       'BP': boot-strap processor, or\r
+;                          'AP': application processor\r
+; @param[out]     RBP/EBP  Address of Boot Firmware Volume (BFV)\r
+;\r
+; @return         None  This routine jumps to SEC and does not return\r
+;\r
+Main16:\r
+    OneTimeCall EarlyInit16\r
+\r
+    ;\r
+    ; Transition the processor from 16-bit real mode to 32-bit flat mode\r
+    ;\r
+    OneTimeCall TransitionFromReal16To32BitFlat\r
+\r
+BITS    32\r
+\r
+    ;\r
+    ; Search for the Boot Firmware Volume (BFV)\r
+    ;\r
+    OneTimeCall Flat32SearchForBfvBase\r
+\r
+    ;\r
+    ; EBP - Start of BFV\r
+    ;\r
+\r
+    ;\r
+    ; Search for the SEC entry point\r
+    ;\r
+    OneTimeCall Flat32SearchForSecEntryPoint\r
+\r
+    ;\r
+    ; ESI - SEC Core entry point\r
+    ; EBP - Start of BFV\r
+    ;\r
+\r
+%ifdef ARCH_IA32\r
+\r
+    ;\r
+    ; Restore initial EAX value into the EAX register\r
+    ;\r
+    mov     eax, esp\r
+\r
+    ;\r
+    ; Jump to the 32-bit SEC entry point\r
+    ;\r
+    jmp     esi\r
+\r
+%else\r
+\r
+    ;\r
+    ; Transition the processor from 32-bit flat mode to 64-bit flat mode\r
+    ;\r
+    OneTimeCall Transition32FlatTo64Flat\r
+\r
+BITS    64\r
+\r
+    ;\r
+    ; Some values were calculated in 32-bit mode.  Make sure the upper\r
+    ; 32-bits of 64-bit registers are zero for these values.\r
+    ;\r
+    mov     rax, 0x00000000ffffffff\r
+    and     rsi, rax\r
+    and     rbp, rax\r
+    and     rsp, rax\r
+\r
+    ;\r
+    ; RSI - SEC Core entry point\r
+    ; RBP - Start of BFV\r
+    ;\r
+\r
+    ;\r
+    ; Restore initial EAX value into the RAX register\r
+    ;\r
+    mov     rax, rsp\r
+\r
+    ;\r
+    ; Jump to the 64-bit SEC entry point\r
+    ;\r
+    jmp     rsi\r
+\r
+%endif\r
+\r
+\r
diff --git a/OvmfPkg/ResetVector/Port80Debug.asm b/OvmfPkg/ResetVector/Port80Debug.asm
new file mode 100644 (file)
index 0000000..2f9d086
--- /dev/null
@@ -0,0 +1,28 @@
+;------------------------------------------------------------------------------\r
+; @file\r
+; Port 0x80 debug support macros\r
+;\r
+; Copyright (c) 2009, 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
+; 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
+BITS    16\r
+\r
+%macro  debugInitialize 0\r
+    ;\r
+    ; No initialization is required\r
+    ;\r
+%endmacro\r
+\r
+%macro  debugShowPostCode 1\r
+    mov     al, %1\r
+    out     0x80, al\r
+%endmacro\r
+\r
diff --git a/OvmfPkg/ResetVector/PostCodes.inc b/OvmfPkg/ResetVector/PostCodes.inc
new file mode 100644 (file)
index 0000000..2556aed
--- /dev/null
@@ -0,0 +1,25 @@
+;------------------------------------------------------------------------------\r
+; @file\r
+; Definitions of POST CODES for the reset vector module\r
+;\r
+; Copyright (c) 2009, 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
+; 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
+%define POSTCODE_16BIT_MODE     0x16\r
+%define POSTCODE_32BIT_MODE     0x32\r
+%define POSTCODE_64BIT_MODE     0x64\r
+\r
+%define POSTCODE_BFV_NOT_FOUND  0xb0\r
+%define POSTCODE_BFV_FOUND      0xb1\r
+\r
+%define POSTCODE_SEC_NOT_FOUND  0xf0\r
+%define POSTCODE_SEC_FOUND      0xf1\r
+\r
index 4339505635569887ba3ac808aaab9fa88b3c11c3..8b139423045b25a2abf4540de68a0d958f84aad9 100644 (file)
@@ -1,6 +1,8 @@
 ;------------------------------------------------------------------------------\r
+; @file\r
+; This file includes all other code files to assemble the reset vector code\r
 ;\r
-; Copyright (c) 2008, Intel Corporation\r
+; Copyright (c) 2008 - 2009, 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
@@ -9,14 +11,6 @@
 ; 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
-;   ResetVectorCode.asm\r
-;\r
-; Abstract:\r
-;\r
-;   Create code for VTF raw section.\r
-;\r
 ;------------------------------------------------------------------------------\r
 \r
 %ifdef ARCH_IA32\r
 %endif\r
 \r
 %include "CommonMacros.inc"\r
-%include "SerialDebug.asm"\r
+\r
+%include "PostCodes.inc"\r
+\r
+%ifdef DEBUG_NONE\r
+  %include "DebugDisabled.asm"\r
+%elifdef DEBUG_PORT80\r
+  %include "Port80Debug.asm"\r
+%elifdef DEBUG_SERIAL\r
+  %include "SerialDebug.asm"\r
+%else\r
+  %error "No debug type was specified."\r
+%endif\r
+\r
 %include "Ia32/SearchForBfvBase.asm"\r
-%include "Ia32/SearchForSecAndPeiEntries.asm"\r
-%include "JumpToSec.asm"\r
-%include "Ia16/16RealTo32Flat.asm"\r
+%include "Ia32/SearchForSecEntry.asm"\r
 \r
 %ifdef ARCH_X64\r
 %include "Ia32/32FlatTo64Flat.asm"\r
 %endif\r
 \r
+%include "Ia16/16RealTo32Flat.asm"\r
+%include "Ia16/Init16.asm"\r
+\r
+%include "Main.asm"\r
+\r
 %include "Ia16/ResetVectorVtf0.asm"\r
 \r
index 2959fa5450ee17e16101102c8fbab760662d9f47..8c2ffc66d34a97e12ea60e377852303253544d46 100644 (file)
@@ -1,6 +1,8 @@
 ;------------------------------------------------------------------------------\r
+; @file\r
+; Serial port debug support macros\r
 ;\r
-; Copyright (c) 2008, Intel Corporation\r
+; Copyright (c) 2008 - 2009, 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
@@ -9,18 +11,8 @@
 ; 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
-;   SerialDebug.asm\r
-;\r
-; Abstract:\r
-;\r
-;   Serial port support macros\r
-;\r
 ;------------------------------------------------------------------------------\r
 \r
-BITS    16\r
-\r
 ;//---------------------------------------------\r
 ;// UART Register Offsets\r
 ;//---------------------------------------------\r
@@ -88,12 +80,38 @@ BITS    16
     out     dx, al\r
 %endmacro\r
 \r
-%macro  writeToSerialPort 1\r
+%macro  debugShowCharacter 1\r
     waitForSerialTxReady\r
     outToSerialPort 0, %1\r
 %endmacro\r
 \r
-real16InitSerialPort:\r
+%macro  debugShowHexDigit 1\r
+  %if (%1 < 0xa)\r
+    debugShowCharacter BYTE ('0' + (%1))\r
+  %else\r
+    debugShowCharacter BYTE ('a' + ((%1) - 0xa))\r
+  %endif\r
+%endmacro\r
+\r
+%macro  debugNewline 0\r
+    debugShowCharacter `\r`\r
+    debugShowCharacter `\n`\r
+%endmacro\r
+\r
+%macro  debugShowPostCode 1\r
+    debugShowHexDigit (((%1) >> 4) & 0xf)\r
+    debugShowHexDigit ((%1) & 0xf)\r
+    debugNewline\r
+%endmacro\r
+\r
+BITS    16\r
+\r
+%macro  debugInitialize 0\r
+       jmp     real16InitDebug\r
+real16InitDebugReturn:\r
+%endmacro\r
+\r
+real16InitDebug:\r
     ;\r
     ; Set communications format\r
     ;\r
@@ -110,5 +128,5 @@ real16InitSerialPort:
     ;\r
     outToSerialPort LCR_OFFSET, SERIAL_DEFAULT_LCR\r
 \r
-    jmp     real16SerialPortInitReturn\r
+    jmp     real16InitDebugReturn\r
 \r