]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmEbPkg/Sec/ModuleEntryPoint.asm
Fixup to point to real RAM and NOR addressess.
[mirror_edk2.git] / ArmEbPkg / Sec / ModuleEntryPoint.asm
index b669f2f7c14e92dff95a32d0c5d365ac0452f517..d9d5bb64f2e9d4e12471e83d36a0c1105055f9d7 100755 (executable)
 //------------------------------------------------------------------------------\r
 \r
 #include <AsmMacroIoLib.h>\r
+#include <Base.h>\r
 #include <Library/PcdLib.h>\r
+#include <ArmEb/ArmEb.h>\r
 #include <AutoGen.h>\r
+\r
   INCLUDE AsmMacroIoLib.inc\r
   \r
   IMPORT  CEntryPoint\r
 \r
 _ModuleEntryPoint\r
  \r
+  // Turn off remapping NOR to 0. We can now use DRAM in low memory\r
+  MmioOr32 (0x10001000 ,BIT8) //EB_SP810_CTRL_BASE\r
+\r
+  // Enable NEON register in case folks want to use them for optimizations (CopyMem)\r
+  mrc     p15, 0, r0, c1, c0, 2\r
+  orr     r0, r0, #0x00f00000   // Enable VPF access (V* instructions)\r
+  mcr     p15, 0, r0, c1, c0, 2\r
+  mov     r0, #0x40000000       // Set EN bit in FPEXC\r
+  msr     FPEXC,r0\r
+  \r
+   \r
+  // Set CPU vectors to start of DRAM\r
+  LoadConstantToReg (FixedPcdGet32(PcdCpuVectorBaseAddress) ,r0) // Get vector base\r
+  mcr     p15, 0, r0, c12, c0, 0\r
+  isb                               // Sync changes to control registers\r
+\r
+  // Fill vector table with branchs to current pc (jmp $)\r
+  // CPU DXE driver likes known values so it can let GDB stub hook vectors\r
+  ldr     r1, ShouldNeverGetHere\r
+  movs    r2, #0\r
+FillVectors\r
+  str     r1, [r0, r2]\r
+  adds    r2, r2, #4\r
+  cmp     r2, #32\r
+  bne     FillVectors\r
 \r
   //\r
   // Set stack based on PCD values. Need to do it this way to make C code work \r
   // when it runs from FLASH. \r
   //  \r
-  LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r2)    /* stack base arg2  */\r
-  LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3)    /* stack size arg3  */\r
+  LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r2)    // stack base arg2  \r
+  LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3)    // stack size arg3  \r
   add     r4, r2, r3\r
-\r
-  //Enter SVC mode and set up SVC stack pointer\r
-  mov     r0,#0x13|0x80|0x40\r
-  msr     CPSR_c,r0\r
-  mov     r13,r4\r
+  mov     r13, r4\r
 \r
   // Call C entry point\r
-  LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1)    /* memory size arg1          */\r
-  LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0)    /* memory size arg0         */\r
-  blx     CEntryPoint       /* Assume C code is thumb    */\r
+  LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1)    // memory size arg1      \r
+  LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0)    // memory size arg0       \r
+  blx     CEntryPoint \r
 \r
 ShouldNeverGetHere\r
-  /* _CEntryPoint should never return */\r
+  // _CEntryPoint should never return \r
   b       ShouldNeverGetHere\r
   \r
   END\r
 \r
+\r