]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmEbPkg/Sec/Sec.c
Report correct MediaPresentSupported value from Nt32 SNP mode data.
[mirror_edk2.git] / ArmEbPkg / Sec / Sec.c
index 0f9e03bb0747a5e2b77c23177334bdaf319265fb..8b161ef4c7aa66a1fc427a464939d19727b824c1 100755 (executable)
@@ -1,9 +1,9 @@
 /** @file\r
   C Entry point for the SEC. First C code after the reset vector.\r
 \r
-  Copyright (c) 2008-2009, Apple Inc. All rights reserved.\r
+  Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
   \r
-  All rights reserved. This program and the accompanying materials\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
 #include <Library/IoLib.h>\r
 #include <Library/ArmLib.h>\r
 #include <Library/PeCoffGetEntryPointLib.h>\r
+#include <Library/DebugAgentLib.h>\r
 \r
 #include <Ppi/GuidedSectionExtraction.h>\r
 #include <Guid/LzmaDecompress.h>\r
 \r
+#include <ArmEb/ArmEb.h>\r
+\r
 #include "LzmaDecompress.h"\r
 \r
 VOID\r
@@ -56,6 +59,27 @@ UartInit (
   SerialPortInitialize ();\r
 }\r
 \r
+VOID\r
+TimerInit (\r
+  VOID\r
+  )\r
+{\r
+  // configure SP810 to use 1MHz clock and disable\r
+  MmioAndThenOr32 (EB_SP810_CTRL_BASE + SP810_SYS_CTRL_REG, ~SP810_SYS_CTRL_TIMER2_EN, SP810_SYS_CTRL_TIMER2_TIMCLK);\r
+  // Enable\r
+  MmioOr32 (EB_SP810_CTRL_BASE + SP810_SYS_CTRL_REG, SP810_SYS_CTRL_TIMER2_EN);\r
+\r
+  // configure timer 2 for one shot operation, 32 bits, no prescaler, and interrupt disabled\r
+  MmioOr32 (EB_SP804_TIMER2_BASE + SP804_TIMER_CONTROL_REG, SP804_TIMER_CTRL_ONESHOT | SP804_TIMER_CTRL_32BIT | SP804_PRESCALE_DIV_1);\r
+\r
+  // preload the timer count register\r
+  MmioWrite32 (EB_SP804_TIMER2_BASE + SP804_TIMER_LOAD_REG, 1);\r
+\r
+  // enable the timer\r
+  MmioOr32 (EB_SP804_TIMER2_BASE + SP804_TIMER_CONTROL_REG, SP804_TIMER_CTRL_ENABLE);\r
+}\r
+\r
+\r
 VOID\r
 InitCache (\r
   IN  UINT32  MemoryBase,\r
@@ -74,52 +98,6 @@ LzmaDecompressLibConstructor (
   VOID\r
   );\r
 \r
-/**\r
-  If the build is done on cygwin the paths are cygpaths. \r
-  /cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert\r
-  them to work with RVD commands\r
-\r
-  This is just code to help print out RVD symbol load command.\r
-  If you build with cygwin paths aren't compatible with RVD.\r
-\r
-  @param  Name  Path to convert if needed\r
-\r
-**/\r
-CHAR8 *\r
-SecDeCygwinPathIfNeeded (\r
-  IN  CHAR8   *Name\r
-  )\r
-{\r
-  CHAR8   *Ptr;\r
-  UINTN   Index;\r
-  UINTN   Len;\r
-  \r
-  Ptr = AsciiStrStr (Name, "/cygdrive/");\r
-  if (Ptr == NULL) {\r
-    return Name;\r
-  }\r
-  \r
-  Len = AsciiStrLen (Ptr);\r
-  \r
-  // convert "/cygdrive" to spaces\r
-  for (Index = 0; Index < 9; Index++) {\r
-    Ptr[Index] = ' ';\r
-  }\r
-\r
-  // convert /c to c:\r
-  Ptr[9]  = Ptr[10];\r
-  Ptr[10] = ':';\r
-  \r
-  // switch path seperators\r
-  for (Index = 11; Index < Len; Index++) {\r
-    if (Ptr[Index] == '/') {\r
-      Ptr[Index] = '\\' ;\r
-    }\r
-  }\r
-\r
-  return Name;\r
-}\r
-\r
 \r
 VOID\r
 CEntryPoint (\r
@@ -150,51 +128,14 @@ CEntryPoint (
 \r
   // Start talking\r
   UartInit ();\r
-  DEBUG ((EFI_D_ERROR, "UART Enabled\n"));\r
 \r
-  DEBUG_CODE_BEGIN ();\r
-    //\r
-    // On a debug build print out information about the SEC. This is really info about\r
-    // the PE/COFF file we are currently running from. Useful for loading symbols in a\r
-    // debugger. Remember our image is really part of the FV.\r
-    //\r
-    RETURN_STATUS       Status;\r
-    EFI_PEI_FV_HANDLE   VolumeHandle;\r
-    EFI_PEI_FILE_HANDLE FileHandle;\r
-    VOID                *PeCoffImage;\r
-    UINT32              Offset;\r
-    CHAR8               *FilePath;\r
-    FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_SECURITY_CORE, &VolumeHandle, &FileHandle);\r
-    Status = FfsFindSectionData (EFI_SECTION_TE, FileHandle, &PeCoffImage);\r
-    if (EFI_ERROR (Status)) {\r
-      // Usually is a TE (PI striped down PE/COFF), but could be a full PE/COFF\r
-      Status = FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffImage);\r
-    }\r
-    if (!EFI_ERROR (Status)) {\r
-      Offset = PeCoffGetSizeOfHeaders (PeCoffImage);\r
-      FilePath = PeCoffLoaderGetPdbPointer (PeCoffImage);\r
-      if (FilePath != NULL) {\r
-      \r
-        // \r
-        // In general you should never have to use #ifdef __CC_ARM in the code. It\r
-        // is hidden in the away in the MdePkg. But here we would like to print differnt things\r
-        // for different toolchains. \r
-        //\r
-#ifdef __CC_ARM\r
-        // Print out the command for the RVD debugger to load symbols for this image\r
-        DEBUG ((EFI_D_ERROR, "load /a /ni /np %a &0x%08x\n", SecDeCygwinPathIfNeeded (FilePath), (CHAR8 *)PeCoffImage + Offset));\r
-#elif __GNUC__\r
-        // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required\r
-        DEBUG ((EFI_D_ERROR, "add-symbol-file %a 0x%08x\n", FilePath, PeCoffImage + Offset));\r
-#else\r
-        DEBUG ((EFI_D_ERROR, "SEC starts at 0x%08x with an entry point at 0x%08x %a\n", PeCoffImage, _ModuleEntryPoint, FilePath));\r
-#endif\r
-      }\r
-    }\r
-\r
-   \r
-  DEBUG_CODE_END ();\r
+  InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, NULL);\r
+  SaveAndSetDebugTimerInterrupt (TRUE);\r
+\r
+  DEBUG ((EFI_D_ERROR, "UART Enabled\n"));\r
 \r
+  // Start up a free running timer so that the timer lib will work\r
+  TimerInit ();\r
 \r
   // SEC phase needs to run library constructors by hand.\r
   ExtractGuidedSectionLibConstructor ();\r