]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/Sec: Moved Exception Vector Table to ArmPkg/DebugAgentBaseLib
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 28 Sep 2012 09:52:11 +0000 (09:52 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 28 Sep 2012 09:52:11 +0000 (09:52 +0000)
In case a DebugAgent library is supported for a specific debugger, we would
expect the exception be caught by DebugAgentLib.
The DebugAgentBaseLib exposes the cause of the exception to the user in the
Serial Terminal.

Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13765 6f19259b-4bc3-4df7-8a09-765794883524

17 files changed:
ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentException.S [new file with mode: 0644]
ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentException.asm [new file with mode: 0644]
ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.c [new file with mode: 0644]
ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf [new file with mode: 0644]
ArmPkg/Library/DebugAgentSymbolsOnlyLib/DebugAgentSymbolsOnlyLib.c [deleted file]
ArmPkg/Library/DebugAgentSymbolsOnlyLib/DebugAgentSymbolsOnlyLib.inf [deleted file]
ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc
ArmPlatformPkg/ArmPlatformPkg.dsc
ArmPlatformPkg/ArmRealViewEbPkg/ArmRealViewEb.dsc.inc
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
ArmPlatformPkg/Sec/Exception.S [deleted file]
ArmPlatformPkg/Sec/Exception.asm [deleted file]
ArmPlatformPkg/Sec/Sec.c
ArmPlatformPkg/Sec/Sec.inf
ArmPlatformPkg/Sec/SecEntryPoint.S
ArmPlatformPkg/Sec/SecEntryPoint.asm
ArmPlatformPkg/Sec/SecInternal.h

diff --git a/ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentException.S b/ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentException.S
new file mode 100644 (file)
index 0000000..3c17386
--- /dev/null
@@ -0,0 +1,276 @@
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
+# Copyright (c) 2011 - 2012, ARM Ltd. All rights reserved.<BR>
+#
+# 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.
+#
+#------------------------------------------------------------------------------
+
+#include <Library/PcdLib.h>
+
+/*
+
+This is the stack constructed by the exception handler (low address to high address)
+                # R0 - IFAR is EFI_SYSTEM_CONTEXT for ARM
+  Reg   Offset
+  ===   ======
+  R0    0x00    # stmfd     SP!,{R0-R12}
+  R1    0x04
+  R2    0x08
+  R3    0x0c
+  R4    0x10
+  R5    0x14
+  R6    0x18
+  R7    0x1c
+  R8    0x20
+  R9    0x24
+  R10   0x28
+  R11   0x2c
+  R12   0x30
+  SP    0x34    # reserved via adding 0x20 (32) to the SP
+  LR    0x38
+  PC    0x3c
+  CPSR  0x40
+  DFSR  0x44
+  DFAR  0x48
+  IFSR  0x4c
+  IFAR  0x50
+
+  LR    0x54    # SVC Link register (we need to restore it)
+
+  LR    0x58    # pushed by srsfd
+  CPSR  0x5c
+
+ */
+
+GCC_ASM_EXPORT(DebugAgentVectorTable)
+GCC_ASM_IMPORT(DefaultExceptionHandler)
+
+.text
+#if !defined(__APPLE__)
+.fpu neon    @ makes vpush/vpop assemble
+#endif
+.align 5
+
+
+//
+// This code gets copied to the ARM vector table
+// ExceptionHandlersStart - ExceptionHandlersEnd gets copied
+//
+ASM_PFX(DebugAgentVectorTable):
+  b ASM_PFX(ResetEntry)
+  b ASM_PFX(UndefinedInstructionEntry)
+  b ASM_PFX(SoftwareInterruptEntry)
+  b ASM_PFX(PrefetchAbortEntry)
+  b ASM_PFX(DataAbortEntry)
+  b ASM_PFX(ReservedExceptionEntry)
+  b ASM_PFX(IrqEntry)
+  b ASM_PFX(FiqEntry)
+
+ASM_PFX(ResetEntry):
+  srsdb     #0x13!                    @ Store return state on SVC stack
+                                      @ We are already in SVC mode
+
+  stmfd     SP!,{LR}                  @ Store the link register for the current mode
+  sub       SP,SP,#0x20               @ Save space for SP, LR, PC, IFAR - CPSR
+  stmfd     SP!,{R0-R12}              @ Store the register state
+  
+  mov       R0,#0                     @ ExceptionType
+  ldr       R1,ASM_PFX(CommonExceptionEntry)
+  bx        R1
+
+ASM_PFX(UndefinedInstructionEntry):
+  sub       LR, LR, #4                @ Only -2 for Thumb, adjust in CommonExceptionEntry
+  srsdb     #0x13!                    @ Store return state on SVC stack
+  cps       #0x13                     @ Switch to SVC for common stack
+  stmfd     SP!,{LR}                  @ Store the link register for the current mode
+  sub       SP,SP,#0x20               @ Save space for SP, LR, PC, IFAR - CPSR
+  stmfd     SP!,{R0-R12}              @ Store the register state
+
+  mov       R0,#1                     @ ExceptionType
+  ldr       R1,ASM_PFX(CommonExceptionEntry)
+  bx        R1
+
+ASM_PFX(SoftwareInterruptEntry):
+  sub       LR, LR, #4                @ Only -2 for Thumb, adjust in CommonExceptionEntry
+  srsdb     #0x13!                    @ Store return state on SVC stack
+                                      @ We are already in SVC mode
+  stmfd     SP!,{LR}                  @ Store the link register for the current mode
+  sub       SP,SP,#0x20               @ Save space for SP, LR, PC, IFAR - CPSR
+  stmfd     SP!,{R0-R12}              @ Store the register state
+
+  mov       R0,#2                     @ ExceptionType
+  ldr       R1,ASM_PFX(CommonExceptionEntry)
+  bx        R1
+
+ASM_PFX(PrefetchAbortEntry):
+  sub       LR,LR,#4
+  srsdb     #0x13!                    @ Store return state on SVC stack
+  cps       #0x13                     @ Switch to SVC for common stack
+  stmfd     SP!,{LR}                  @ Store the link register for the current mode
+  sub       SP,SP,#0x20               @ Save space for SP, LR, PC, IFAR - CPSR
+  stmfd     SP!,{R0-R12}              @ Store the register state
+
+  mov       R0,#3                     @ ExceptionType
+  ldr       R1,ASM_PFX(CommonExceptionEntry)
+  bx        R1
+
+ASM_PFX(DataAbortEntry):
+  sub       LR,LR,#8
+  srsdb     #0x13!                    @ Store return state on SVC stack
+  cps       #0x13                     @ Switch to SVC for common stack
+  stmfd     SP!,{LR}                  @ Store the link register for the current mode
+  sub       SP,SP,#0x20               @ Save space for SP, LR, PC, IFAR - CPSR
+  stmfd     SP!,{R0-R12}              @ Store the register state
+
+  mov       R0,#4
+  ldr       R1,ASM_PFX(CommonExceptionEntry)
+  bx        R1
+
+ASM_PFX(ReservedExceptionEntry):
+  srsdb     #0x13!                    @ Store return state on SVC stack
+  cps       #0x13                     @ Switch to SVC for common stack
+  stmfd     SP!,{LR}                  @ Store the link register for the current mode
+  sub       SP,SP,#0x20               @ Save space for SP, LR, PC, IFAR - CPSR
+  stmfd     SP!,{R0-R12}              @ Store the register state
+
+  mov       R0,#5
+  ldr       R1,ASM_PFX(CommonExceptionEntry)
+  bx        R1
+
+ASM_PFX(IrqEntry):
+  sub       LR,LR,#4
+  srsdb     #0x13!                    @ Store return state on SVC stack
+  cps       #0x13                     @ Switch to SVC for common stack
+  stmfd     SP!,{LR}                  @ Store the link register for the current mode
+  sub       SP,SP,#0x20               @ Save space for SP, LR, PC, IFAR - CPSR
+  stmfd     SP!,{R0-R12}              @ Store the register state
+
+  mov       R0,#6                     @ ExceptionType
+  ldr       R1,ASM_PFX(CommonExceptionEntry)
+  bx        R1
+
+ASM_PFX(FiqEntry):
+  sub       LR,LR,#4
+  srsdb     #0x13!                    @ Store return state on SVC stack
+  cps       #0x13                     @ Switch to SVC for common stack
+  stmfd     SP!,{LR}                  @ Store the link register for the current mode
+  sub       SP,SP,#0x20               @ Save space for SP, LR, PC, IFAR - CPSR
+  stmfd     SP!,{R0-R12}              @ Store the register state
+                                      @ Since we have already switch to SVC R8_fiq - R12_fiq
+                                      @ never get used or saved
+  mov       R0,#7                     @ ExceptionType
+  ldr       R1,ASM_PFX(CommonExceptionEntry)
+  bx        R1
+
+//
+// This gets patched by the C code that patches in the vector table
+//
+ASM_PFX(CommonExceptionEntry):
+  .word       ASM_PFX(AsmCommonExceptionEntry)
+
+ASM_PFX(ExceptionHandlersEnd):
+
+//
+// This code runs from CpuDxe driver loaded address. It is patched into
+// CommonExceptionEntry.
+//
+ASM_PFX(AsmCommonExceptionEntry):
+  mrc       p15, 0, R1, c6, c0, 2   @ Read IFAR
+  str       R1, [SP, #0x50]         @ Store it in EFI_SYSTEM_CONTEXT_ARM.IFAR
+
+  mrc       p15, 0, R1, c5, c0, 1   @ Read IFSR
+  str       R1, [SP, #0x4c]         @ Store it in EFI_SYSTEM_CONTEXT_ARM.IFSR
+
+  mrc       p15, 0, R1, c6, c0, 0   @ Read DFAR
+  str       R1, [SP, #0x48]         @ Store it in EFI_SYSTEM_CONTEXT_ARM.DFAR
+
+  mrc       p15, 0, R1, c5, c0, 0   @ Read DFSR
+  str       R1, [SP, #0x44]         @ Store it in EFI_SYSTEM_CONTEXT_ARM.DFSR
+
+  ldr       R1, [SP, #0x5c]         @ srsdb saved pre-exception CPSR on the stack
+  str       R1, [SP, #0x40]         @ Store it in EFI_SYSTEM_CONTEXT_ARM.CPSR
+
+  add       R2, SP, #0x38           @ Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
+  and       R3, R1, #0x1f           @ Check CPSR to see if User or System Mode
+  cmp       R3, #0x1f               @ if ((CPSR == 0x10) || (CPSR == 0x1df))
+  cmpne     R3, #0x10               @
+  stmeqed   R2, {lr}^               @   save unbanked lr
+                                    @ else
+  stmneed   R2, {lr}                @   save SVC lr
+
+
+  ldr       R5, [SP, #0x58]         @ PC is the LR pushed by srsfd
+                                    @ Check to see if we have to adjust for Thumb entry
+  sub       r4, r0, #1              @ if (ExceptionType == 1 || ExceptionType ==2)) {
+  cmp       r4, #1                  @   // UND & SVC have differnt LR adjust for Thumb
+  bhi       NoAdjustNeeded
+
+  tst       r1, #0x20               @   if ((CPSR & T)) == T) {  // Thumb Mode on entry
+  addne     R5, R5, #2              @     PC += 2@
+  str       R5,[SP,#0x58]           @ Update LR value pused by srsfd
+
+NoAdjustNeeded:
+
+  str       R5, [SP, #0x3c]         @ Store it in EFI_SYSTEM_CONTEXT_ARM.PC
+
+  sub       R1, SP, #0x60           @ We pused 0x60 bytes on the stack
+  str       R1, [SP, #0x34]         @ Store it in EFI_SYSTEM_CONTEXT_ARM.SP
+
+                                    @ R0 is ExceptionType
+  mov       R1,SP                   @ R1 is SystemContext
+
+#if (FixedPcdGet32(PcdVFPEnabled))
+  vpush     {d0-d15}                @ save vstm registers in case they are used in optimizations
+#endif
+
+/*
+VOID
+EFIAPI
+DefaultExceptionHandler (
+  IN     EFI_EXCEPTION_TYPE           ExceptionType,   R0
+  IN OUT EFI_SYSTEM_CONTEXT           SystemContext    R1
+  )
+
+*/
+  blx       ASM_PFX(DefaultExceptionHandler)  @ Call exception handler
+
+#if (FixedPcdGet32(PcdVFPEnabled))
+  vpop      {d0-d15}
+#endif
+
+  ldr       R1, [SP, #0x4c]         @ Restore EFI_SYSTEM_CONTEXT_ARM.IFSR
+  mcr       p15, 0, R1, c5, c0, 1   @ Write IFSR
+
+  ldr       R1, [SP, #0x44]         @ sRestore EFI_SYSTEM_CONTEXT_ARM.DFSR
+  mcr       p15, 0, R1, c5, c0, 0   @ Write DFSR
+
+  ldr       R1,[SP,#0x3c]           @ EFI_SYSTEM_CONTEXT_ARM.PC
+  str       R1,[SP,#0x58]           @ Store it back to srsfd stack slot so it can be restored
+
+  ldr       R1,[SP,#0x40]           @ EFI_SYSTEM_CONTEXT_ARM.CPSR
+  str       R1,[SP,#0x5c]           @ Store it back to srsfd stack slot so it can be restored
+
+  add       R3, SP, #0x54           @ Make R3 point to SVC LR saved on entry
+  add       R2, SP, #0x38           @ Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR
+  and       R1, R1, #0x1f           @ Check to see if User or System Mode
+  cmp       R1, #0x1f               @ if ((CPSR == 0x10) || (CPSR == 0x1f))
+  cmpne     R1, #0x10               @
+  ldmeqed   R2, {lr}^               @   restore unbanked lr
+                                    @ else
+  ldmneed   R3, {lr}                @   restore SVC lr, via ldmfd SP!, {LR}
+
+  ldmfd     SP!,{R0-R12}            @ Restore general purpose registers
+                                    @ Exception handler can not change SP
+
+  add       SP,SP,#0x20             @ Clear out the remaining stack space
+  ldmfd     SP!,{LR}                @ restore the link register for this context
+  rfefd     SP!                     @ return from exception via srsfd stack slot
+
diff --git a/ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentException.asm b/ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentException.asm
new file mode 100644 (file)
index 0000000..f281c06
--- /dev/null
@@ -0,0 +1,273 @@
+//------------------------------------------------------------------------------\r
+//\r
+// Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
+// Copyright (c) 2011 - 2012, ARM Ltd. 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
+// 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
+#include <Library/PcdLib.h>\r
+\r
+/*\r
+\r
+This is the stack constructed by the exception handler (low address to high address)\r
+                # R0 - IFAR is EFI_SYSTEM_CONTEXT for ARM\r
+  Reg   Offset\r
+  ===   ======\r
+  R0    0x00    # stmfd     SP!,{R0-R12}\r
+  R1    0x04\r
+  R2    0x08\r
+  R3    0x0c\r
+  R4    0x10\r
+  R5    0x14\r
+  R6    0x18\r
+  R7    0x1c\r
+  R8    0x20\r
+  R9    0x24\r
+  R10   0x28\r
+  R11   0x2c\r
+  R12   0x30\r
+  SP    0x34    # reserved via adding 0x20 (32) to the SP\r
+  LR    0x38\r
+  PC    0x3c\r
+  CPSR  0x40\r
+  DFSR  0x44\r
+  DFAR  0x48\r
+  IFSR  0x4c\r
+  IFAR  0x50\r
+\r
+  LR    0x54    # SVC Link register (we need to restore it)\r
+  \r
+  LR    0x58    # pushed by srsfd\r
+  CPSR  0x5c\r
+\r
+ */\r
+\r
+  EXPORT  DebugAgentVectorTable\r
+  IMPORT  DefaultExceptionHandler\r
+\r
+  PRESERVE8\r
+  AREA  DebugAgentException, CODE, READONLY, CODEALIGN, ALIGN=5\r
+\r
+//\r
+// This code gets copied to the ARM vector table\r
+// ExceptionHandlersStart - ExceptionHandlersEnd gets copied\r
+//\r
+DebugAgentVectorTable FUNCTION\r
+  b   ResetEntry\r
+  b   UndefinedInstructionEntry\r
+  b   SoftwareInterruptEntry\r
+  b   PrefetchAbortEntry\r
+  b   DataAbortEntry\r
+  b   ReservedExceptionEntry\r
+  b   IrqEntry\r
+  b   FiqEntry\r
+  ENDFUNC\r
+\r
+ResetEntry\r
+  srsfd     #0x13!                    ; Store return state on SVC stack\r
+                                      ; We are already in SVC mode\r
+  stmfd     SP!,{LR}                  ; Store the link register for the current mode\r
+  sub       SP,SP,#0x20               ; Save space for SP, LR, PC, IFAR - CPSR\r
+  stmfd     SP!,{R0-R12}              ; Store the register state\r
+  \r
+  mov       R0,#0                     ; ExceptionType\r
+  ldr       R1,CommonExceptionEntry\r
+  bx        R1\r
+\r
+UndefinedInstructionEntry\r
+  sub       LR, LR, #4                ; Only -2 for Thumb, adjust in CommonExceptionEntry\r
+  srsfd     #0x13!                    ; Store return state on SVC stack\r
+  cps       #0x13                     ; Switch to SVC for common stack\r
+  stmfd     SP!,{LR}                  ; Store the link register for the current mode\r
+  sub       SP,SP,#0x20               ; Save space for SP, LR, PC, IFAR - CPSR\r
+  stmfd     SP!,{R0-R12}              ; Store the register state\r
+\r
+  mov       R0,#1                     ; ExceptionType\r
+  ldr       R1,CommonExceptionEntry;\r
+  bx        R1\r
+\r
+SoftwareInterruptEntry\r
+  sub       LR, LR, #4                ; Only -2 for Thumb, adjust in CommonExceptionEntry\r
+  srsfd     #0x13!                    ; Store return state on SVC stack\r
+                                      ; We are already in SVC mode\r
+  stmfd     SP!,{LR}                  ; Store the link register for the current mode\r
+  sub       SP,SP,#0x20               ; Save space for SP, LR, PC, IFAR - CPSR\r
+  stmfd     SP!,{R0-R12}              ; Store the register state\r
+\r
+  mov       R0,#2                     ; ExceptionType\r
+  ldr       R1,CommonExceptionEntry\r
+  bx        R1\r
+\r
+PrefetchAbortEntry\r
+  sub       LR,LR,#4\r
+  srsfd     #0x13!                    ; Store return state on SVC stack\r
+  cps       #0x13                     ; Switch to SVC for common stack\r
+  stmfd     SP!,{LR}                  ; Store the link register for the current mode\r
+  sub       SP,SP,#0x20               ; Save space for SP, LR, PC, IFAR - CPSR\r
+  stmfd     SP!,{R0-R12}              ; Store the register state\r
+\r
+  mov       R0,#3                     ; ExceptionType\r
+  ldr       R1,CommonExceptionEntry\r
+  bx        R1\r
+\r
+DataAbortEntry\r
+  sub       LR,LR,#8\r
+  srsfd     #0x13!                    ; Store return state on SVC stack\r
+  cps       #0x13                     ; Switch to SVC for common stack\r
+  stmfd     SP!,{LR}                  ; Store the link register for the current mode\r
+  sub       SP,SP,#0x20               ; Save space for SP, LR, PC, IFAR - CPSR\r
+  stmfd     SP!,{R0-R12}              ; Store the register state\r
+\r
+  mov       R0,#4                     ; ExceptionType\r
+  ldr       R1,CommonExceptionEntry\r
+  bx        R1\r
+\r
+ReservedExceptionEntry\r
+  srsfd     #0x13!                    ; Store return state on SVC stack\r
+  cps       #0x13                     ; Switch to SVC for common stack\r
+  stmfd     SP!,{LR}                  ; Store the link register for the current mode\r
+  sub       SP,SP,#0x20               ; Save space for SP, LR, PC, IFAR - CPSR\r
+  stmfd     SP!,{R0-R12}              ; Store the register state\r
+\r
+  mov       R0,#5                     ; ExceptionType\r
+  ldr       R1,CommonExceptionEntry\r
+  bx        R1\r
+\r
+IrqEntry\r
+  sub       LR,LR,#4\r
+  srsfd     #0x13!                    ; Store return state on SVC stack\r
+  cps       #0x13                     ; Switch to SVC for common stack\r
+  stmfd     SP!,{LR}                  ; Store the link register for the current mode\r
+  sub       SP,SP,#0x20               ; Save space for SP, LR, PC, IFAR - CPSR\r
+  stmfd     SP!,{R0-R12}              ; Store the register state\r
+\r
+  mov       R0,#6                     ; ExceptionType\r
+  ldr       R1,CommonExceptionEntry\r
+  bx        R1\r
+\r
+FiqEntry\r
+  sub       LR,LR,#4\r
+  srsfd     #0x13!                    ; Store return state on SVC stack\r
+  cps       #0x13                     ; Switch to SVC for common stack\r
+  stmfd     SP!,{LR}                  ; Store the link register for the current mode\r
+  sub       SP,SP,#0x20               ; Save space for SP, LR, PC, IFAR - CPSR\r
+  stmfd     SP!,{R0-R12}              ; Store the register state\r
+                                      ; Since we have already switch to SVC R8_fiq - R12_fiq\r
+                                      ; never get used or saved\r
+  mov       R0,#7                     ; ExceptionType\r
+  ldr       R1,CommonExceptionEntry\r
+  bx        R1\r
+\r
+//\r
+// This gets patched by the C code that patches in the vector table\r
+//\r
+CommonExceptionEntry\r
+  dcd       AsmCommonExceptionEntry\r
+\r
+ExceptionHandlersEnd\r
+\r
+//\r
+// This code runs from CpuDxe driver loaded address. It is patched into\r
+// CommonExceptionEntry.\r
+//\r
+AsmCommonExceptionEntry\r
+  mrc       p15, 0, R1, c6, c0, 2   ; Read IFAR\r
+  str       R1, [SP, #0x50]         ; Store it in EFI_SYSTEM_CONTEXT_ARM.IFAR\r
+\r
+  mrc       p15, 0, R1, c5, c0, 1   ; Read IFSR\r
+  str       R1, [SP, #0x4c]         ; Store it in EFI_SYSTEM_CONTEXT_ARM.IFSR\r
+\r
+  mrc       p15, 0, R1, c6, c0, 0   ; Read DFAR\r
+  str       R1, [SP, #0x48]         ; Store it in EFI_SYSTEM_CONTEXT_ARM.DFAR\r
+\r
+  mrc       p15, 0, R1, c5, c0, 0   ; Read DFSR\r
+  str       R1, [SP, #0x44]         ; Store it in EFI_SYSTEM_CONTEXT_ARM.DFSR\r
+\r
+  ldr       R1, [SP, #0x5c]         ; srsfd saved pre-exception CPSR on the stack\r
+  str       R1, [SP, #0x40]         ; Store it in EFI_SYSTEM_CONTEXT_ARM.CPSR\r
+\r
+  add       R2, SP, #0x38           ; Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR\r
+  and       R3, R1, #0x1f           ; Check CPSR to see if User or System Mode\r
+  cmp       R3, #0x1f               ; if ((CPSR == 0x10) || (CPSR == 0x1df))\r
+  cmpne     R3, #0x10               ;\r
+  stmeqed   R2, {lr}^               ;   save unbanked lr\r
+                                    ; else\r
+  stmneed   R2, {lr}                ;   save SVC lr\r
+\r
+\r
+  ldr       R5, [SP, #0x58]         ; PC is the LR pushed by srsfd\r
+                                    ; Check to see if we have to adjust for Thumb entry\r
+  sub       r4, r0, #1              ; if (ExceptionType == 1 || ExceptionType ==2)) {\r
+  cmp       r4, #1                  ;   // UND & SVC have differnt LR adjust for Thumb\r
+  bhi       NoAdjustNeeded\r
+\r
+  tst       r1, #0x20               ;   if ((CPSR & T)) == T) {  // Thumb Mode on entry\r
+  addne     R5, R5, #2              ;     PC += 2;\r
+  str       R5,[SP,#0x58]           ; Update LR value pused by srsfd\r
+\r
+NoAdjustNeeded\r
+\r
+  str       R5, [SP, #0x3c]         ; Store it in EFI_SYSTEM_CONTEXT_ARM.PC\r
+\r
+  sub       R1, SP, #0x60           ; We pused 0x60 bytes on the stack\r
+  str       R1, [SP, #0x34]         ; Store it in EFI_SYSTEM_CONTEXT_ARM.SP\r
+\r
+                                    ; R0 is ExceptionType\r
+  mov       R1,SP                   ; R1 is SystemContext\r
+\r
+#if (FixedPcdGet32(PcdVFPEnabled))\r
+  vpush    {d0-d15}                  ; save vstm registers in case they are used in optimizations\r
+#endif\r
+\r
+/*\r
+VOID\r
+EFIAPI\r
+DefaultExceptionHandler (\r
+  IN     EFI_EXCEPTION_TYPE           ExceptionType,   R0\r
+  IN OUT EFI_SYSTEM_CONTEXT           SystemContext    R1\r
+  )\r
+\r
+*/\r
+  blx       DefaultExceptionHandler ; Call exception handler\r
+\r
+#if (FixedPcdGet32(PcdVFPEnabled))\r
+  vpop      {d0-d15}\r
+#endif\r
+\r
+  ldr       R1, [SP, #0x4c]         ; Restore EFI_SYSTEM_CONTEXT_ARM.IFSR\r
+  mcr       p15, 0, R1, c5, c0, 1   ; Write IFSR\r
+\r
+  ldr       R1, [SP, #0x44]         ; sRestore EFI_SYSTEM_CONTEXT_ARM.DFSR\r
+  mcr       p15, 0, R1, c5, c0, 0   ; Write DFSR\r
+\r
+  ldr       R1,[SP,#0x3c]           ; EFI_SYSTEM_CONTEXT_ARM.PC\r
+  str       R1,[SP,#0x58]           ; Store it back to srsfd stack slot so it can be restored\r
+\r
+  ldr       R1,[SP,#0x40]           ; EFI_SYSTEM_CONTEXT_ARM.CPSR\r
+  str       R1,[SP,#0x5c]           ; Store it back to srsfd stack slot so it can be restored\r
+\r
+  add       R3, SP, #0x54           ; Make R3 point to SVC LR saved on entry\r
+  add       R2, SP, #0x38           ; Make R2 point to EFI_SYSTEM_CONTEXT_ARM.LR\r
+  and       R1, R1, #0x1f           ; Check to see if User or System Mode\r
+  cmp       R1, #0x1f               ; if ((CPSR == 0x10) || (CPSR == 0x1f))\r
+  cmpne     R1, #0x10               ;\r
+  ldmeqed   R2, {lr}^               ;   restore unbanked lr\r
+                                    ; else\r
+  ldmneed   R3, {lr}                ;   restore SVC lr, via ldmfd SP!, {LR}\r
+\r
+  ldmfd     SP!,{R0-R12}            ; Restore general purpose registers\r
+                                    ; Exception handler can not change SP\r
+\r
+  add       SP,SP,#0x20             ; Clear out the remaining stack space\r
+  ldmfd     SP!,{LR}                ; restore the link register for this context\r
+  rfefd     SP!                     ; return from exception via srsfd stack slot\r
+\r
+  END\r
diff --git a/ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.c b/ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.c
new file mode 100644 (file)
index 0000000..5d98677
--- /dev/null
@@ -0,0 +1,351 @@
+/** @file\r
+*  Main file supporting the SEC Phase for Versatile Express\r
+*\r
+*  Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
+*\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
+#include <Uefi.h>\r
+#include <Library/ArmLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/DebugAgentLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/PeCoffExtraActionLib.h>\r
+#include <Library/PeCoffLib.h>\r
+\r
+#include <Pi/PiFirmwareFile.h>\r
+#include <Pi/PiFirmwareVolume.h>\r
+\r
+#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \\r
+  (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))\r
+\r
+\r
+// Vector Table for Sec Phase\r
+VOID\r
+DebugAgentVectorTable (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Returns the highest bit set of the State field\r
+\r
+  @param ErasePolarity   Erase Polarity  as defined by EFI_FVB2_ERASE_POLARITY\r
+                         in the Attributes field.\r
+  @param FfsHeader       Pointer to FFS File Header\r
+\r
+\r
+  @retval the highest bit in the State field\r
+\r
+**/\r
+STATIC\r
+EFI_FFS_FILE_STATE\r
+GetFileState (\r
+  IN UINT8                ErasePolarity,\r
+  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
+  )\r
+{\r
+  EFI_FFS_FILE_STATE  FileState;\r
+  EFI_FFS_FILE_STATE  HighestBit;\r
+\r
+  FileState = FfsHeader->State;\r
+\r
+  if (ErasePolarity != 0) {\r
+    FileState = (EFI_FFS_FILE_STATE)~FileState;\r
+  }\r
+\r
+  HighestBit = 0x80;\r
+  while (HighestBit != 0 && (HighestBit & FileState) == 0) {\r
+    HighestBit >>= 1;\r
+  }\r
+\r
+  return HighestBit;\r
+}\r
+\r
+/**\r
+  Calculates the checksum of the header of a file.\r
+  The header is a zero byte checksum, so zero means header is good\r
+\r
+  @param FfsHeader       Pointer to FFS File Header\r
+\r
+  @retval Checksum of the header\r
+\r
+**/\r
+STATIC\r
+UINT8\r
+CalculateHeaderChecksum (\r
+  IN EFI_FFS_FILE_HEADER  *FileHeader\r
+  )\r
+{\r
+  UINT8   Sum;\r
+\r
+  // Calculate the sum of the header\r
+  Sum = CalculateSum8 ((CONST VOID*)FileHeader,sizeof(EFI_FFS_FILE_HEADER));\r
+\r
+  // State field (since this indicates the different state of file).\r
+  Sum = (UINT8)(Sum - FileHeader->State);\r
+\r
+  // Checksum field of the file is not part of the header checksum.\r
+  Sum = (UINT8)(Sum - FileHeader->IntegrityCheck.Checksum.File);\r
+\r
+  return Sum;\r
+}\r
+\r
+EFI_STATUS\r
+GetFfsFile (\r
+  IN  EFI_FIRMWARE_VOLUME_HEADER           *FwVolHeader,\r
+  IN  EFI_FV_FILETYPE                      FileType,\r
+  OUT EFI_FFS_FILE_HEADER                  **FileHeader\r
+  )\r
+{\r
+  UINT64                                FvLength;\r
+  UINTN                                 FileOffset;\r
+  EFI_FFS_FILE_HEADER                   *FfsFileHeader;\r
+  UINT8                                 ErasePolarity;\r
+  UINT8                                 FileState;\r
+  UINT32                                FileLength;\r
+  UINT32                                FileOccupiedSize;\r
+\r
+  ASSERT (FwVolHeader->Signature == EFI_FVH_SIGNATURE);\r
+\r
+  FvLength = FwVolHeader->FvLength;\r
+  FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength);\r
+  FileOffset = FwVolHeader->HeaderLength;\r
+\r
+  if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {\r
+    ErasePolarity = 1;\r
+  } else {\r
+    ErasePolarity = 0;\r
+  }\r
+\r
+  while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {\r
+    // Get FileState which is the highest bit of the State\r
+    FileState = GetFileState (ErasePolarity, FfsFileHeader);\r
+\r
+    switch (FileState) {\r
+\r
+    case EFI_FILE_HEADER_INVALID:\r
+      FileOffset += sizeof(EFI_FFS_FILE_HEADER);\r
+      FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + sizeof(EFI_FFS_FILE_HEADER));\r
+      break;\r
+\r
+    case EFI_FILE_DATA_VALID:\r
+    case EFI_FILE_MARKED_FOR_UPDATE:\r
+      if (CalculateHeaderChecksum (FfsFileHeader) != 0) {\r
+        ASSERT (FALSE);\r
+        return EFI_NOT_FOUND;\r
+      }\r
+\r
+      if (FfsFileHeader->Type == FileType) {\r
+        *FileHeader = FfsFileHeader;\r
+        return EFI_SUCCESS;\r
+      }\r
+\r
+      FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;\r
+      FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);\r
+\r
+      FileOffset += FileOccupiedSize;\r
+      FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);\r
+      break;\r
+\r
+    case EFI_FILE_DELETED:\r
+      FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;\r
+      FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);\r
+      FileOffset += FileOccupiedSize;\r
+      FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);\r
+      break;\r
+\r
+    default:\r
+      return EFI_NOT_FOUND;\r
+    }\r
+  }\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+EFI_STATUS\r
+GetImageContext (\r
+  IN  EFI_FFS_FILE_HEADER           *FfsHeader,\r
+  OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+{\r
+  EFI_STATUS                              Status;\r
+  UINTN                                   ParsedLength;\r
+  UINTN                                   SectionSize;\r
+  UINTN                                   SectionLength;\r
+  EFI_COMMON_SECTION_HEADER               *Section;\r
+  VOID                                    *EfiImage;\r
+  UINTN                                   ImageAddress;\r
+  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY         *DebugEntry;\r
+  VOID                                    *CodeViewEntryPointer;\r
+\r
+  Section = (EFI_COMMON_SECTION_HEADER *)(FfsHeader + 1);\r
+  SectionSize = *(UINT32 *)(FfsHeader->Size) & 0x00FFFFFF;\r
+  SectionSize -= sizeof (EFI_FFS_FILE_HEADER);\r
+  ParsedLength = 0;\r
+  EfiImage = NULL;\r
+\r
+  while (ParsedLength < SectionSize) {\r
+    if ((Section->Type == EFI_SECTION_PE32) || (Section->Type == EFI_SECTION_TE)) {\r
+      EfiImage = (EFI_IMAGE_OPTIONAL_HEADER_UNION*)(Section + 1);\r
+      break;\r
+    }\r
+\r
+    //\r
+    // Size is 24 bits wide so mask upper 8 bits.\r
+    // SectionLength is adjusted it is 4 byte aligned.\r
+    // Go to the next section\r
+    //\r
+    SectionLength = *(UINT32 *)Section->Size & 0x00FFFFFF;\r
+    SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);\r
+    ASSERT (SectionLength != 0);\r
+    ParsedLength += SectionLength;\r
+    Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);\r
+  }\r
+\r
+  if (EfiImage == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  // Initialize the Image Context\r
+  ZeroMem (ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT));\r
+  ImageContext->Handle    = EfiImage;\r
+  ImageContext->ImageRead = PeCoffLoaderImageReadFromMemory;\r
+\r
+  Status =  PeCoffLoaderGetImageInfo (ImageContext);\r
+  if (!EFI_ERROR(Status) && ((VOID*)ImageContext->DebugDirectoryEntryRva != NULL)) {\r
+    ImageAddress = ImageContext->ImageAddress;\r
+    if (ImageContext->IsTeImage) {\r
+      ImageAddress += sizeof (EFI_TE_IMAGE_HEADER) - ((EFI_TE_IMAGE_HEADER*)EfiImage)->StrippedSize;\r
+    }\r
+\r
+    DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY*)(ImageAddress + ImageContext->DebugDirectoryEntryRva);\r
+    if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
+      CodeViewEntryPointer = (VOID *) (ImageAddress + (UINTN) DebugEntry->RVA);\r
+      switch (* (UINT32 *) CodeViewEntryPointer) {\r
+      case CODEVIEW_SIGNATURE_NB10:\r
+        ImageContext->PdbPointer = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);\r
+        break;\r
+      case CODEVIEW_SIGNATURE_RSDS:\r
+        ImageContext->PdbPointer = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);\r
+        break;\r
+      case CODEVIEW_SIGNATURE_MTOC:\r
+        ImageContext->PdbPointer = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY);\r
+        break;\r
+      default:\r
+        break;\r
+      }\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Initialize debug agent.\r
+\r
+  This function is used to set up debug environment to support source level debugging.\r
+  If certain Debug Agent Library instance has to save some private data in the stack,\r
+  this function must work on the mode that doesn't return to the caller, then\r
+  the caller needs to wrap up all rest of logic after InitializeDebugAgent() into one\r
+  function and pass it into InitializeDebugAgent(). InitializeDebugAgent() is\r
+  responsible to invoke the passing-in function at the end of InitializeDebugAgent().\r
+\r
+  If the parameter Function is not NULL, Debug Agent Libary instance will invoke it by\r
+  passing in the Context to be its parameter.\r
+\r
+  If Function() is NULL, Debug Agent Library instance will return after setup debug\r
+  environment.\r
+\r
+  @param[in] InitFlag     Init flag is used to decide the initialize process.\r
+  @param[in] Context      Context needed according to InitFlag; it was optional.\r
+  @param[in] Function     Continue function called by debug agent library; it was\r
+                          optional.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+InitializeDebugAgent (\r
+  IN UINT32                InitFlag,\r
+  IN VOID                  *Context, OPTIONAL\r
+  IN DEBUG_AGENT_CONTINUE  Function  OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_FFS_FILE_HEADER   *FfsHeader;\r
+  PE_COFF_LOADER_IMAGE_CONTEXT  ImageContext;\r
+\r
+  // Now we've got UART, make the check:\r
+  // - The Vector table must be 32-byte aligned\r
+  //TODO: Define a macro for the ARM Exception Table\r
+  ASSERT(((UINT32)DebugAgentVectorTable & ARM_VECTOR_TABLE_ALIGNMENT) == 0);\r
+  ArmWriteVBar (DebugAgentVectorTable);\r
+\r
+  // We use InitFlag to know if DebugAgent has been intialized from\r
+  // Sec (DEBUG_AGENT_INIT_PREMEM_SEC) or PrePi (DEBUG_AGENT_INIT_POSTMEM_SEC)\r
+  // modules\r
+  if (InitFlag == DEBUG_AGENT_INIT_PREMEM_SEC) {\r
+    //\r
+    // Get the Sec or PrePeiCore module (defined as SEC type module)\r
+    //\r
+    Status = GetFfsFile ((EFI_FIRMWARE_VOLUME_HEADER*)PcdGet32(PcdSecureFvBaseAddress), EFI_FV_FILETYPE_SECURITY_CORE, &FfsHeader);\r
+    if (!EFI_ERROR(Status)) {\r
+      Status = GetImageContext (FfsHeader,&ImageContext);\r
+      if (!EFI_ERROR(Status)) {\r
+        PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r
+      }\r
+    }\r
+  } else if (InitFlag == DEBUG_AGENT_INIT_POSTMEM_SEC) {\r
+    //\r
+    // Get the PrePi or PrePeiCore module (defined as SEC type module)\r
+    //\r
+    Status = GetFfsFile ((EFI_FIRMWARE_VOLUME_HEADER*)PcdGet32(PcdFvBaseAddress), EFI_FV_FILETYPE_SECURITY_CORE, &FfsHeader);\r
+    if (!EFI_ERROR(Status)) {\r
+      Status = GetImageContext (FfsHeader,&ImageContext);\r
+      if (!EFI_ERROR(Status)) {\r
+        PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r
+      }\r
+    }\r
+\r
+    //\r
+    // Get the PeiCore module (defined as PEI_CORE type module)\r
+    //\r
+    Status = GetFfsFile ((EFI_FIRMWARE_VOLUME_HEADER*)PcdGet32(PcdFvBaseAddress), EFI_FV_FILETYPE_PEI_CORE, &FfsHeader);\r
+    if (!EFI_ERROR(Status)) {\r
+      Status = GetImageContext (FfsHeader,&ImageContext);\r
+      if (!EFI_ERROR(Status)) {\r
+        PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+/**\r
+  Enable/Disable the interrupt of debug timer and return the interrupt state\r
+  prior to the operation.\r
+\r
+  If EnableStatus is TRUE, enable the interrupt of debug timer.\r
+  If EnableStatus is FALSE, disable the interrupt of debug timer.\r
+\r
+  @param[in] EnableStatus    Enable/Disable.\r
+\r
+  @return FALSE always.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+SaveAndSetDebugTimerInterrupt (\r
+  IN BOOLEAN                EnableStatus\r
+  )\r
+{\r
+  return FALSE;\r
+}\r
+\r
diff --git a/ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf b/ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
new file mode 100644 (file)
index 0000000..1cf0b33
--- /dev/null
@@ -0,0 +1,42 @@
+#  \r
+#  Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
+#  \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
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DebugAgentSymbolsBaseLib\r
+  FILE_GUID                      = 9055e2e0-9b33-11e0-a7d7-0002a5d5c51b\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = DebugAgentLib\r
+\r
+[Sources.common]\r
+  DebugAgentSymbolsBaseLib.c\r
+  DebugAgentException.asm        | RVCT\r
+  DebugAgentException.S          | GCC\r
+  \r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  ArmPkg/ArmPkg.dec\r
+\r
+[LibraryClasses]\r
+  ArmLib\r
+  DebugLib\r
+  DefaultExceptionHandlerLib\r
+  PcdLib\r
+  PeCoffExtraActionLib\r
+  PeCoffLib\r
+\r
+[Pcd]\r
+  gArmTokenSpaceGuid.PcdSecureFvBaseAddress\r
+  gArmTokenSpaceGuid.PcdFvBaseAddress\r
diff --git a/ArmPkg/Library/DebugAgentSymbolsOnlyLib/DebugAgentSymbolsOnlyLib.c b/ArmPkg/Library/DebugAgentSymbolsOnlyLib/DebugAgentSymbolsOnlyLib.c
deleted file mode 100755 (executable)
index 5faac33..0000000
+++ /dev/null
@@ -1,337 +0,0 @@
-/** @file\r
-*  Main file supporting the SEC Phase for Versatile Express\r
-*\r
-*  Copyright (c) 2011, ARM Limited. All rights reserved.\r
-*\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
-#include <Uefi.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/DebugAgentLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/PeCoffExtraActionLib.h>\r
-#include <Library/PeCoffLib.h>\r
-\r
-#include <Pi/PiFirmwareFile.h>\r
-#include <Pi/PiFirmwareVolume.h>\r
-\r
-#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \\r
-  (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))\r
-\r
-/**\r
-  Returns the highest bit set of the State field\r
-\r
-  @param ErasePolarity   Erase Polarity  as defined by EFI_FVB2_ERASE_POLARITY\r
-                         in the Attributes field.\r
-  @param FfsHeader       Pointer to FFS File Header\r
-\r
-\r
-  @retval the highest bit in the State field\r
-\r
-**/\r
-STATIC\r
-EFI_FFS_FILE_STATE\r
-GetFileState (\r
-  IN UINT8                ErasePolarity,\r
-  IN EFI_FFS_FILE_HEADER  *FfsHeader\r
-  )\r
-{\r
-  EFI_FFS_FILE_STATE  FileState;\r
-  EFI_FFS_FILE_STATE  HighestBit;\r
-\r
-  FileState = FfsHeader->State;\r
-\r
-  if (ErasePolarity != 0) {\r
-    FileState = (EFI_FFS_FILE_STATE)~FileState;\r
-  }\r
-\r
-  HighestBit = 0x80;\r
-  while (HighestBit != 0 && (HighestBit & FileState) == 0) {\r
-    HighestBit >>= 1;\r
-  }\r
-\r
-  return HighestBit;\r
-}\r
-\r
-/**\r
-  Calculates the checksum of the header of a file.\r
-  The header is a zero byte checksum, so zero means header is good\r
-\r
-  @param FfsHeader       Pointer to FFS File Header\r
-\r
-  @retval Checksum of the header\r
-\r
-**/\r
-STATIC\r
-UINT8\r
-CalculateHeaderChecksum (\r
-  IN EFI_FFS_FILE_HEADER  *FileHeader\r
-  )\r
-{\r
-  UINT8   Sum;\r
-\r
-  // Calculate the sum of the header\r
-  Sum = CalculateSum8 ((CONST VOID*)FileHeader,sizeof(EFI_FFS_FILE_HEADER));\r
-\r
-  // State field (since this indicates the different state of file).\r
-  Sum = (UINT8)(Sum - FileHeader->State);\r
-\r
-  // Checksum field of the file is not part of the header checksum.\r
-  Sum = (UINT8)(Sum - FileHeader->IntegrityCheck.Checksum.File);\r
-\r
-  return Sum;\r
-}\r
-\r
-EFI_STATUS\r
-GetFfsFile (\r
-  IN  EFI_FIRMWARE_VOLUME_HEADER           *FwVolHeader,\r
-  IN  EFI_FV_FILETYPE                      FileType,\r
-  OUT EFI_FFS_FILE_HEADER                  **FileHeader\r
-  )\r
-{\r
-  UINT64                                FvLength;\r
-  UINTN                                 FileOffset;\r
-  EFI_FFS_FILE_HEADER                   *FfsFileHeader;\r
-  UINT8                                 ErasePolarity;\r
-  UINT8                                 FileState;\r
-  UINT32                                FileLength;\r
-  UINT32                                FileOccupiedSize;\r
-\r
-  ASSERT (FwVolHeader->Signature == EFI_FVH_SIGNATURE);\r
-\r
-  FvLength = FwVolHeader->FvLength;\r
-  FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength);\r
-  FileOffset = FwVolHeader->HeaderLength;\r
-\r
-  if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {\r
-    ErasePolarity = 1;\r
-  } else {\r
-    ErasePolarity = 0;\r
-  }\r
-\r
-  while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {\r
-    // Get FileState which is the highest bit of the State\r
-    FileState = GetFileState (ErasePolarity, FfsFileHeader);\r
-\r
-    switch (FileState) {\r
-\r
-    case EFI_FILE_HEADER_INVALID:\r
-      FileOffset += sizeof(EFI_FFS_FILE_HEADER);\r
-      FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + sizeof(EFI_FFS_FILE_HEADER));\r
-      break;\r
-\r
-    case EFI_FILE_DATA_VALID:\r
-    case EFI_FILE_MARKED_FOR_UPDATE:\r
-      if (CalculateHeaderChecksum (FfsFileHeader) != 0) {\r
-        ASSERT (FALSE);\r
-        return EFI_NOT_FOUND;\r
-      }\r
-\r
-      if (FfsFileHeader->Type == FileType) {\r
-        *FileHeader = FfsFileHeader;\r
-        return EFI_SUCCESS;\r
-      }\r
-\r
-      FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;\r
-      FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);\r
-\r
-      FileOffset += FileOccupiedSize;\r
-      FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);\r
-      break;\r
-\r
-    case EFI_FILE_DELETED:\r
-      FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;\r
-      FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);\r
-      FileOffset += FileOccupiedSize;\r
-      FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);\r
-      break;\r
-\r
-    default:\r
-      return EFI_NOT_FOUND;\r
-    }\r
-  }\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-EFI_STATUS\r
-GetImageContext (\r
-  IN  EFI_FFS_FILE_HEADER           *FfsHeader,\r
-  OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  )\r
-{\r
-  EFI_STATUS                              Status;\r
-  UINTN                                   ParsedLength;\r
-  UINTN                                   SectionSize;\r
-  UINTN                                   SectionLength;\r
-  EFI_COMMON_SECTION_HEADER               *Section;\r
-  VOID                                    *EfiImage;\r
-  UINTN                                   ImageAddress;\r
-  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY         *DebugEntry;\r
-  VOID                                    *CodeViewEntryPointer;\r
-\r
-  Section = (EFI_COMMON_SECTION_HEADER *)(FfsHeader + 1);\r
-  SectionSize = *(UINT32 *)(FfsHeader->Size) & 0x00FFFFFF;\r
-  SectionSize -= sizeof (EFI_FFS_FILE_HEADER);\r
-  ParsedLength = 0;\r
-  EfiImage = NULL;\r
-\r
-  while (ParsedLength < SectionSize) {\r
-    if ((Section->Type == EFI_SECTION_PE32) || (Section->Type == EFI_SECTION_TE)) {\r
-      EfiImage = (EFI_IMAGE_OPTIONAL_HEADER_UNION*)(Section + 1);\r
-      break;\r
-    }\r
-\r
-    //\r
-    // Size is 24 bits wide so mask upper 8 bits.\r
-    // SectionLength is adjusted it is 4 byte aligned.\r
-    // Go to the next section\r
-    //\r
-    SectionLength = *(UINT32 *)Section->Size & 0x00FFFFFF;\r
-    SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);\r
-    ASSERT (SectionLength != 0);\r
-    ParsedLength += SectionLength;\r
-    Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);\r
-  }\r
-\r
-  if (EfiImage == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  // Initialize the Image Context\r
-  ZeroMem (ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT));\r
-  ImageContext->Handle    = EfiImage;\r
-  ImageContext->ImageRead = PeCoffLoaderImageReadFromMemory;\r
-\r
-  Status =  PeCoffLoaderGetImageInfo (ImageContext);\r
-  if (!EFI_ERROR(Status) && ((VOID*)ImageContext->DebugDirectoryEntryRva != NULL)) {\r
-    ImageAddress = ImageContext->ImageAddress;\r
-    if (ImageContext->IsTeImage) {\r
-      ImageAddress += sizeof (EFI_TE_IMAGE_HEADER) - ((EFI_TE_IMAGE_HEADER*)EfiImage)->StrippedSize;\r
-    }\r
-\r
-    DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY*)(ImageAddress + ImageContext->DebugDirectoryEntryRva);\r
-    if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
-      CodeViewEntryPointer = (VOID *) (ImageAddress + (UINTN) DebugEntry->RVA);\r
-      switch (* (UINT32 *) CodeViewEntryPointer) {\r
-      case CODEVIEW_SIGNATURE_NB10:\r
-        ImageContext->PdbPointer = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);\r
-        break;\r
-      case CODEVIEW_SIGNATURE_RSDS:\r
-        ImageContext->PdbPointer = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);\r
-        break;\r
-      case CODEVIEW_SIGNATURE_MTOC:\r
-        ImageContext->PdbPointer = (CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY);\r
-        break;\r
-      default:\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Initialize debug agent.\r
-\r
-  This function is used to set up debug environment to support source level debugging.\r
-  If certain Debug Agent Library instance has to save some private data in the stack,\r
-  this function must work on the mode that doesn't return to the caller, then\r
-  the caller needs to wrap up all rest of logic after InitializeDebugAgent() into one\r
-  function and pass it into InitializeDebugAgent(). InitializeDebugAgent() is\r
-  responsible to invoke the passing-in function at the end of InitializeDebugAgent().\r
-\r
-  If the parameter Function is not NULL, Debug Agent Libary instance will invoke it by\r
-  passing in the Context to be its parameter.\r
-\r
-  If Function() is NULL, Debug Agent Library instance will return after setup debug\r
-  environment.\r
-\r
-  @param[in] InitFlag     Init flag is used to decide the initialize process.\r
-  @param[in] Context      Context needed according to InitFlag; it was optional.\r
-  @param[in] Function     Continue function called by debug agent library; it was\r
-                          optional.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-InitializeDebugAgent (\r
-  IN UINT32                InitFlag,\r
-  IN VOID                  *Context, OPTIONAL\r
-  IN DEBUG_AGENT_CONTINUE  Function  OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_FFS_FILE_HEADER   *FfsHeader;\r
-  PE_COFF_LOADER_IMAGE_CONTEXT  ImageContext;\r
-\r
-  // We use InitFlag to know if DebugAgent has been intialized from\r
-  // Sec (DEBUG_AGENT_INIT_PREMEM_SEC) or PrePi (DEBUG_AGENT_INIT_POSTMEM_SEC)\r
-  // modules\r
-  if (InitFlag == DEBUG_AGENT_INIT_PREMEM_SEC) {\r
-    //\r
-    // Get the Sec or PrePeiCore module (defined as SEC type module)\r
-    //\r
-    Status = GetFfsFile ((EFI_FIRMWARE_VOLUME_HEADER*)PcdGet32(PcdSecureFvBaseAddress), EFI_FV_FILETYPE_SECURITY_CORE, &FfsHeader);\r
-    if (!EFI_ERROR(Status)) {\r
-      Status = GetImageContext (FfsHeader,&ImageContext);\r
-      if (!EFI_ERROR(Status)) {\r
-        PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r
-      }\r
-    }\r
-  } else if (InitFlag == DEBUG_AGENT_INIT_POSTMEM_SEC) {\r
-    //\r
-    // Get the PrePi or PrePeiCore module (defined as SEC type module)\r
-    //\r
-    Status = GetFfsFile ((EFI_FIRMWARE_VOLUME_HEADER*)PcdGet32(PcdFvBaseAddress), EFI_FV_FILETYPE_SECURITY_CORE, &FfsHeader);\r
-    if (!EFI_ERROR(Status)) {\r
-      Status = GetImageContext (FfsHeader,&ImageContext);\r
-      if (!EFI_ERROR(Status)) {\r
-        PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r
-      }\r
-    }\r
-\r
-    //\r
-    // Get the PeiCore module (defined as PEI_CORE type module)\r
-    //\r
-    Status = GetFfsFile ((EFI_FIRMWARE_VOLUME_HEADER*)PcdGet32(PcdFvBaseAddress), EFI_FV_FILETYPE_PEI_CORE, &FfsHeader);\r
-    if (!EFI_ERROR(Status)) {\r
-      Status = GetImageContext (FfsHeader,&ImageContext);\r
-      if (!EFI_ERROR(Status)) {\r
-        PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Enable/Disable the interrupt of debug timer and return the interrupt state\r
-  prior to the operation.\r
-\r
-  If EnableStatus is TRUE, enable the interrupt of debug timer.\r
-  If EnableStatus is FALSE, disable the interrupt of debug timer.\r
-\r
-  @param[in] EnableStatus    Enable/Disable.\r
-\r
-  @return FALSE always.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-SaveAndSetDebugTimerInterrupt (\r
-  IN BOOLEAN                EnableStatus\r
-  )\r
-{\r
-  return FALSE;\r
-}\r
-\r
diff --git a/ArmPkg/Library/DebugAgentSymbolsOnlyLib/DebugAgentSymbolsOnlyLib.inf b/ArmPkg/Library/DebugAgentSymbolsOnlyLib/DebugAgentSymbolsOnlyLib.inf
deleted file mode 100755 (executable)
index e2c7240..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#  \r
-#  Copyright (c) 2011, ARM Limited. All rights reserved.\r
-#  \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
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DebugAgentSymbolsOnlyLib\r
-  FILE_GUID                      = 9055e2e0-9b33-11e0-a7d7-0002a5d5c51b\r
-  MODULE_TYPE                    = BASE\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = DebugAgentLib\r
-\r
-[Sources.common]\r
-  DebugAgentSymbolsOnlyLib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  ArmPkg/ArmPkg.dec\r
-\r
-[LibraryClasses]\r
-  DebugLib\r
-  PcdLib\r
-  PeCoffExtraActionLib\r
-  PeCoffLib\r
-\r
-[Pcd]\r
-  gArmTokenSpaceGuid.PcdSecureFvBaseAddress\r
-  gArmTokenSpaceGuid.PcdFvBaseAddress\r
index 10959930ea8054b74faf2a87df1843830d846795..02778a807fc37a3d4bee5975bb7689e3b50478f1 100644 (file)
   ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.inf
 
   ArmPlatformSecExtraActionLib|ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf  
-  DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsOnlyLib/DebugAgentSymbolsOnlyLib.inf
+  DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
   
   PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
   ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
index 5b107c4b3713059ef703ce3290aed40b094140c7..c9ef38510f4b3e89b631e70a8be9cfd3329fbdcf 100644 (file)
   ArmPlatformSecExtraActionLib|ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf\r
   ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.inf\r
   \r
-  DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsOnlyLib/DebugAgentSymbolsOnlyLib.inf\r
+  DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf\r
 \r
 [LibraryClasses.common.PEI_CORE]\r
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
   #\r
   MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
   ArmPlatformPkg/Bds/Bds.inf\r
-  
+  \r
index 486992f5eb760d3155ee205a0bad80761cc7fafd..9d35b6fc6aab4758c2cde30b3149c614deae843a 100644 (file)
   ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.inf\r
   ArmTrustedMonitorLib|ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/ArmTrustedMonitorLibNull.inf\r
 \r
-  DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsOnlyLib/DebugAgentSymbolsOnlyLib.inf\r
+  DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf\r
   # Uncomment to turn on GDB stub in SEC. \r
   #DebugAgentLib|EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.inf\r
   \r
index 97f21d92c8cafd16a7224e9e161ed1def7234b03..59c821a2f0cb85795f49aef7dcde1493ec85d4f2 100644 (file)
   ArmPlatformSecExtraActionLib|ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf\r
   ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.inf\r
   \r
-  DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsOnlyLib/DebugAgentSymbolsOnlyLib.inf\r
+  DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf\r
   \r
 !ifdef $(EDK2_SKIP_PEICORE)\r
   PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf\r
diff --git a/ArmPlatformPkg/Sec/Exception.S b/ArmPlatformPkg/Sec/Exception.S
deleted file mode 100644 (file)
index 14e1fa8..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-//
-//  Copyright (c) 2011, ARM Limited. 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.             
-#
-#
-
-#include <AsmMacroIoLib.h>
-#include <AutoGen.h>
-#include "SecInternal.h"
-
-.text
-.align 5
-
-GCC_ASM_IMPORT(SecCommonExceptionEntry)
-GCC_ASM_EXPORT(SecVectorTable)
-
-//============================================================
-// Default Exception Handlers
-//============================================================
-  
-  
-ASM_PFX(SecVectorTable):
-  b _DefaultResetHandler
-  b _DefaultUndefined
-  b _DefaultSWI
-  b _DefaultPrefetchAbort
-  b _DefaultDataAbort
-  b _DefaultReserved
-  b _DefaultIrq
-  b _DefaultFiq
-
-//
-// Default Exception handlers: There is no plan to return from any of these exceptions.
-// No context saving at all.
-//
-_DefaultResetHandler:
-  mov  r1, lr
-  # Switch to SVC for common stack
-  cps  #0x13
-  mov  r0, #0
-  blx  ASM_PFX(SecCommonExceptionEntry)
-
-_DefaultUndefined:
-  sub  r1, LR, #4
-  # Switch to SVC for common stack
-  cps  #0x13
-  mov  r0, #1
-  blx  ASM_PFX(SecCommonExceptionEntry)
-
-_DefaultSWI:
-  sub  r1, LR, #4
-  # Switch to SVC for common stack
-  cps  #0x13
-  mov  r0, #2
-  blx  ASM_PFX(SecCommonExceptionEntry)
-
-_DefaultPrefetchAbort:
-  sub  r1, LR, #4
-  # Switch to SVC for common stack
-  cps  #0x13
-  mov  r0, #3
-  blx  ASM_PFX(SecCommonExceptionEntry)
-
-_DefaultDataAbort:
-  sub  r1, LR, #8
-  # Switch to SVC for common stack
-  cps  #0x13
-  mov  r0, #4
-  blx  ASM_PFX(SecCommonExceptionEntry)
-
-_DefaultReserved:
-  mov  r1, lr
-  # Switch to SVC for common stack
-  cps  #0x13
-  mov  r0, #5
-  blx  ASM_PFX(SecCommonExceptionEntry)
-
-_DefaultIrq:
-  sub  r1, LR, #4
-  # Switch to SVC for common stack
-  cps  #0x13
-  mov  r0, #6
-  blx  ASM_PFX(SecCommonExceptionEntry)
-
-_DefaultFiq:
-  sub  r1, LR, #4
-  # Switch to SVC for common stack
-  cps  #0x13
-  mov  r0, #7
-  blx  ASM_PFX(SecCommonExceptionEntry)
-
diff --git a/ArmPlatformPkg/Sec/Exception.asm b/ArmPlatformPkg/Sec/Exception.asm
deleted file mode 100644 (file)
index cf3825b..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-//\r
-//  Copyright (c) 2011, ARM Limited. All rights reserved.\r
-//  \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
-#include <AsmMacroIoLib.h>\r
-#include <Base.h>\r
-#include <AutoGen.h>\r
-\r
-  IMPORT  SecCommonExceptionEntry\r
-  EXPORT  SecVectorTable\r
-  \r
-  PRESERVE8\r
-  AREA    SecException, CODE, READONLY, CODEALIGN, ALIGN=5\r
-\r
-//============================================================\r
-//Default Exception Handlers\r
-//============================================================\r
-  \r
-  \r
-SecVectorTable\r
-  b _DefaultResetHandler\r
-  b _DefaultUndefined\r
-  b _DefaultSWI\r
-  b _DefaultPrefetchAbort\r
-  b _DefaultDataAbort\r
-  b _DefaultReserved\r
-  b _DefaultIrq\r
-  b _DefaultFiq\r
-\r
-//\r
-// Default Exception handlers: There is no plan to return from any of these exceptions.\r
-// No context saving at all.\r
-//\r
-_DefaultResetHandler\r
-   mov  r1, lr\r
-   cps       #0x13                     ; Switch to SVC for common stack\r
-   mov  r0, #0\r
-   blx   SecCommonExceptionEntry\r
-\r
-_DefaultUndefined\r
-   sub  r1, LR\r
-   cps       #0x13                     ; Switch to SVC for common stack\r
-   mov  r0, #1\r
-   blx   SecCommonExceptionEntry\r
-\r
-_DefaultSWI\r
-   sub  r1, LR, #4\r
-   cps       #0x13                     ; Switch to SVC for common stack\r
-   mov  r0, #2\r
-   blx   SecCommonExceptionEntry\r
-\r
-_DefaultPrefetchAbort\r
-   sub  r1, LR, #4\r
-   cps       #0x13                     ; Switch to SVC for common stack\r
-   mov  r0, #3\r
-   blx   SecCommonExceptionEntry\r
-\r
-_DefaultDataAbort\r
-   sub  r1, LR, #8\r
-   cps       #0x13                     ; Switch to SVC for common stack\r
-   mov  r0, #4\r
-   blx   SecCommonExceptionEntry\r
-\r
-_DefaultReserved\r
-   mov  r1, lr\r
-   cps       #0x13                     ; Switch to SVC for common stack\r
-   mov  r0, #5\r
-   blx   SecCommonExceptionEntry\r
-   \r
-_DefaultIrq\r
-   sub  r1, LR, #4\r
-   cps       #0x13                     ; Switch to SVC for common stack\r
-   mov  r0, #6\r
-   blx   SecCommonExceptionEntry\r
-\r
-_DefaultFiq\r
-   sub  r1, LR, #4\r
-   cps       #0x13                     ; Switch to SVC for common stack\r
-   mov  r0, #7\r
-   blx   SecCommonExceptionEntry\r
-\r
-  END\r
index b8cc4973d8f0afb05686fe1cc06c3708b9bceb4c..55807ec9d9dbb77e0c53e02063af22223bd24fc0 100644 (file)
@@ -80,10 +80,6 @@ CEntryPoint (
     InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, NULL, NULL);
     SaveAndSetDebugTimerInterrupt (TRUE);
 
-    // Now we've got UART, make the check:
-    // - The Vector table must be 32-byte aligned
-    ASSERT(((UINT32)SecVectorTable & ((1 << 5)-1)) == 0);
-
     // Enable the GIC distributor and CPU Interface
     // - no other Interrupts are enabled,  doesn't have to worry about the priority.
     // - all the cores are in secure state, use secure SGI's
@@ -197,44 +193,3 @@ NonTrustedWorldTransition (
   ASSERT (FALSE);
 }
 
-VOID
-SecCommonExceptionEntry (
-  IN UINT32 Entry,
-  IN UINT32 LR
-  )
-{
-  CHAR8           Buffer[100];
-  UINTN           CharCount;
-
-  switch (Entry) {
-  case 0:
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Reset Exception at 0x%X\n\r",LR);
-    break;
-  case 1:
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Undefined Exception at 0x%X\n\r",LR);
-    break;
-  case 2:
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"SWI Exception at 0x%X\n\r",LR);
-    break;
-  case 3:
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"PrefetchAbort Exception at 0x%X\n\r",LR);
-    break;
-  case 4:
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"DataAbort Exception at 0x%X\n\r",LR);
-    break;
-  case 5:
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Reserved Exception at 0x%X\n\r",LR);
-    break;
-  case 6:
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"IRQ Exception at 0x%X\n\r",LR);
-    break;
-  case 7:
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"FIQ Exception at 0x%X\n\r",LR);
-    break;
-  default:
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Unknown Exception at 0x%X\n\r",LR);
-    break;
-  }
-  SerialPortWrite ((UINT8 *) Buffer, CharCount);
-  while(1);
-}
index 0b7a9c04e83ecddb0913a7cad41f81a886a160cf..55ad00744cd222ffca96e2fa6aba421a75e6ca74 100644 (file)
@@ -26,8 +26,6 @@
   Sec.c\r
   SecEntryPoint.S      | GCC\r
   SecEntryPoint.asm    | RVCT\r
-  Exception.asm        | RVCT\r
-  Exception.S          | GCC\r
   \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
index 5095c41697a7a9dd26d67b90e747915a2bcc0aab..92035a1ffe1bea7ad0342423f3ecf4c3119a7593 100644 (file)
@@ -23,9 +23,7 @@ GCC_ASM_IMPORT(ArmPlatformSecBootAction)
 GCC_ASM_IMPORT(ArmPlatformSecBootMemoryInit)\r
 GCC_ASM_IMPORT(ArmDisableInterrupts)\r
 GCC_ASM_IMPORT(ArmDisableCachesAndMmu)\r
-GCC_ASM_IMPORT(ArmWriteVBar)\r
 GCC_ASM_IMPORT(ArmReadMpidr)\r
-GCC_ASM_IMPORT(SecVectorTable)\r
 GCC_ASM_IMPORT(ArmCallWFE)\r
 GCC_ASM_EXPORT(_ModuleEntryPoint)\r
 \r
@@ -44,10 +42,6 @@ ASM_PFX(_ModuleEntryPoint):
   // Jump to Platform Specific Boot Action function\r
   blx   ASM_PFX(ArmPlatformSecBootAction)\r
 \r
-  // Set VBAR to the start of the exception vectors in Secure Mode\r
-  LoadConstantToReg (ASM_PFX(SecVectorTable), r0)\r
-  bl    ASM_PFX(ArmWriteVBar)\r
-\r
 _IdentifyCpu:\r
   // Identify CPU ID\r
   bl    ASM_PFX(ArmReadMpidr)\r
index e0d5922f15eb80cdae297efad512fd11ffffba5b..42d2b0268fe1fe678760b2e7ba89542a9cce0b9d 100644 (file)
   IMPORT  ArmPlatformSecBootMemoryInit\r
   IMPORT  ArmDisableInterrupts\r
   IMPORT  ArmDisableCachesAndMmu\r
-  IMPORT  ArmWriteVBar\r
   IMPORT  ArmReadMpidr\r
   IMPORT  ArmCallWFE\r
-  IMPORT  SecVectorTable\r
   EXPORT  _ModuleEntryPoint\r
 \r
   PRESERVE8\r
@@ -46,10 +44,6 @@ _ModuleEntryPoint FUNCTION
   // Jump to Platform Specific Boot Action function\r
   blx   ArmPlatformSecBootAction\r
 \r
-  // Set VBAR to the start of the exception vectors in Secure Mode\r
-  ldr   r0, =SecVectorTable\r
-  blx   ArmWriteVBar\r
-\r
 _IdentifyCpu \r
   // Identify CPU ID\r
   bl    ArmReadMpidr\r
index 34a6feab1e15f5a0f9dd4b75bc0598b3d0741419..8bc21389e75cb666749cff3520473b17a78f4b5b 100644 (file)
@@ -44,12 +44,6 @@ ArmSetupGicNonSecure (
   IN  INTN                  GicInterruptInterfaceBase\r
 );\r
 \r
-// Vector Table for Sec Phase\r
-VOID\r
-SecVectorTable (\r
-  VOID\r
-  );\r
-\r
 VOID\r
 enter_monitor_mode (\r
   IN UINTN                  MonitorEntryPoint,\r