]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Drivers/CpuDxe/Exception.c
ArmPlatformPkg: Remove PcdStandalone from Sec module and Introduce ArmPlatformSecExtr...
[mirror_edk2.git] / ArmPkg / Drivers / CpuDxe / Exception.c
index 17e463f97b7c3acf9d42853976500c159970755c..55a71321935007376be89a792b6899a3a0ea8347 100644 (file)
@@ -92,7 +92,6 @@ CommonCExceptionHandler (
   IN OUT EFI_SYSTEM_CONTEXT           SystemContext\r
   )\r
 {\r
-\r
   if (ExceptionType <= MAX_ARM_EXCEPTION) {\r
     if (gExceptionHandlers[ExceptionType]) {\r
       gExceptionHandlers[ExceptionType] (ExceptionType, SystemContext);\r
@@ -130,6 +129,8 @@ InitializeExceptions (
   UINT32               *VectorBase;\r
 \r
   Status = EFI_SUCCESS;\r
+  ZeroMem (gExceptionHandlers,sizeof(*gExceptionHandlers));\r
+\r
   //\r
   // Disable interrupts\r
   //\r
@@ -149,6 +150,14 @@ InitializeExceptions (
     //\r
     Length = (UINTN)ExceptionHandlersEnd - (UINTN)ExceptionHandlersStart;\r
 \r
+    // Check if the exception vector is in the low address\r
+    if (PcdGet32 (PcdCpuVectorBaseAddress) == 0x0) {\r
+      // Set SCTLR.V to 0 to enable VBAR to be used\r
+      ArmSetLowVectors ();\r
+    } else {\r
+      ArmSetHighVectors ();\r
+    }\r
+\r
     //\r
     // Reserve space for the exception handlers\r
     //\r
@@ -197,10 +206,13 @@ InitializeExceptions (
 \r
     //Note: On ARM processor with the Security Extension, the Vector Table can be located anywhere in the memory.\r
     //      The Vector Base Address Register defines the location\r
-    ArmWriteVBar(PcdGet32(PcdCpuVectorBaseAddress));\r
+    ArmWriteVBar (PcdGet32(PcdCpuVectorBaseAddress));\r
   } else {\r
+    // The Vector table must be 32-byte aligned\r
+    ASSERT(((UINT32)ExceptionHandlersStart & ((1 << 5)-1)) == 0);\r
+\r
     // We do not copy the Exception Table at PcdGet32(PcdCpuVectorBaseAddress). We just set Vector Base Address to point into CpuDxe code.\r
-    ArmWriteVBar((UINT32)ExceptionHandlersStart);\r
+    ArmWriteVBar ((UINT32)ExceptionHandlersStart);\r
   }\r
 \r
   if (FiqEnabled) {\r