summaryrefslogtreecommitdiff
path: root/ArmEbPkg/Sec
diff options
context:
space:
mode:
Diffstat (limited to 'ArmEbPkg/Sec')
-rwxr-xr-xArmEbPkg/Sec/Sec.c119
-rwxr-xr-xArmEbPkg/Sec/Sec.inf4
2 files changed, 34 insertions, 89 deletions
diff --git a/ArmEbPkg/Sec/Sec.c b/ArmEbPkg/Sec/Sec.c
index 3118abb9df..8b161ef4c7 100755
--- a/ArmEbPkg/Sec/Sec.c
+++ b/ArmEbPkg/Sec/Sec.c
@@ -21,10 +21,13 @@
#include <Library/IoLib.h>
#include <Library/ArmLib.h>
#include <Library/PeCoffGetEntryPointLib.h>
+#include <Library/DebugAgentLib.h>
#include <Ppi/GuidedSectionExtraction.h>
#include <Guid/LzmaDecompress.h>
+#include <ArmEb/ArmEb.h>
+
#include "LzmaDecompress.h"
VOID
@@ -57,6 +60,27 @@ UartInit (
}
VOID
+TimerInit (
+ VOID
+ )
+{
+ // configure SP810 to use 1MHz clock and disable
+ MmioAndThenOr32 (EB_SP810_CTRL_BASE + SP810_SYS_CTRL_REG, ~SP810_SYS_CTRL_TIMER2_EN, SP810_SYS_CTRL_TIMER2_TIMCLK);
+ // Enable
+ MmioOr32 (EB_SP810_CTRL_BASE + SP810_SYS_CTRL_REG, SP810_SYS_CTRL_TIMER2_EN);
+
+ // configure timer 2 for one shot operation, 32 bits, no prescaler, and interrupt disabled
+ MmioOr32 (EB_SP804_TIMER2_BASE + SP804_TIMER_CONTROL_REG, SP804_TIMER_CTRL_ONESHOT | SP804_TIMER_CTRL_32BIT | SP804_PRESCALE_DIV_1);
+
+ // preload the timer count register
+ MmioWrite32 (EB_SP804_TIMER2_BASE + SP804_TIMER_LOAD_REG, 1);
+
+ // enable the timer
+ MmioOr32 (EB_SP804_TIMER2_BASE + SP804_TIMER_CONTROL_REG, SP804_TIMER_CTRL_ENABLE);
+}
+
+
+VOID
InitCache (
IN UINT32 MemoryBase,
IN UINT32 MemoryLength
@@ -74,52 +98,6 @@ LzmaDecompressLibConstructor (
VOID
);
-/**
- If the build is done on cygwin the paths are cygpaths.
- /cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert
- them to work with RVD commands
-
- This is just code to help print out RVD symbol load command.
- If you build with cygwin paths aren't compatible with RVD.
-
- @param Name Path to convert if needed
-
-**/
-CHAR8 *
-SecDeCygwinPathIfNeeded (
- IN CHAR8 *Name
- )
-{
- CHAR8 *Ptr;
- UINTN Index;
- UINTN Len;
-
- Ptr = AsciiStrStr (Name, "/cygdrive/");
- if (Ptr == NULL) {
- return Name;
- }
-
- Len = AsciiStrLen (Ptr);
-
- // convert "/cygdrive" to spaces
- for (Index = 0; Index < 9; Index++) {
- Ptr[Index] = ' ';
- }
-
- // convert /c to c:
- Ptr[9] = Ptr[10];
- Ptr[10] = ':';
-
- // switch path seperators
- for (Index = 11; Index < Len; Index++) {
- if (Ptr[Index] == '/') {
- Ptr[Index] = '\\' ;
- }
- }
-
- return Name;
-}
-
VOID
CEntryPoint (
@@ -150,51 +128,14 @@ CEntryPoint (
// Start talking
UartInit ();
- DEBUG ((EFI_D_ERROR, "UART Enabled\n"));
- DEBUG_CODE_BEGIN ();
- //
- // On a debug build print out information about the SEC. This is really info about
- // the PE/COFF file we are currently running from. Useful for loading symbols in a
- // debugger. Remember our image is really part of the FV.
- //
- RETURN_STATUS Status;
- EFI_PEI_FV_HANDLE VolumeHandle;
- EFI_PEI_FILE_HANDLE FileHandle;
- VOID *PeCoffImage;
- UINT32 Offset;
- CHAR8 *FilePath;
- FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_SECURITY_CORE, &VolumeHandle, &FileHandle);
- Status = FfsFindSectionData (EFI_SECTION_TE, FileHandle, &PeCoffImage);
- if (EFI_ERROR (Status)) {
- // Usually is a TE (PI striped down PE/COFF), but could be a full PE/COFF
- Status = FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffImage);
- }
- if (!EFI_ERROR (Status)) {
- Offset = PeCoffGetSizeOfHeaders (PeCoffImage);
- FilePath = PeCoffLoaderGetPdbPointer (PeCoffImage);
- if (FilePath != NULL) {
-
- //
- // In general you should never have to use #ifdef __CC_ARM in the code. It
- // is hidden in the away in the MdePkg. But here we would like to print differnt things
- // for different toolchains.
- //
-#ifdef __CC_ARM
- // Print out the command for the RVD debugger to load symbols for this image
- DEBUG ((EFI_D_ERROR, "load /a /ni /np %a &0x%08x\n", SecDeCygwinPathIfNeeded (FilePath), (CHAR8 *)PeCoffImage + Offset));
-#elif __GNUC__
- // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required
- DEBUG ((EFI_D_ERROR, "add-symbol-file %a 0x%08x\n", FilePath, PeCoffImage + Offset));
-#else
- DEBUG ((EFI_D_ERROR, "SEC starts at 0x%08x with an entry point at 0x%08x %a\n", PeCoffImage, _ModuleEntryPoint, FilePath));
-#endif
- }
- }
-
-
- DEBUG_CODE_END ();
+ InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, NULL);
+ SaveAndSetDebugTimerInterrupt (TRUE);
+
+ DEBUG ((EFI_D_ERROR, "UART Enabled\n"));
+ // Start up a free running timer so that the timer lib will work
+ TimerInit ();
// SEC phase needs to run library constructors by hand.
ExtractGuidedSectionLibConstructor ();
diff --git a/ArmEbPkg/Sec/Sec.inf b/ArmEbPkg/Sec/Sec.inf
index d9b96e77be..ed46f96f21 100755
--- a/ArmEbPkg/Sec/Sec.inf
+++ b/ArmEbPkg/Sec/Sec.inf
@@ -35,6 +35,8 @@
EmbeddedPkg/EmbeddedPkg.dec
ArmPkg/ArmPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
+ ArmEbPkg/ArmEbPkg.dec
+
[LibraryClasses]
BaseLib
@@ -44,6 +46,8 @@
ExtractGuidedSectionLib
LzmaDecompressLib
PeCoffGetEntryPointLib
+ DebugAgentLib
+
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdCacheEnable