#include <Library/IoLib.h>\r
#include <Library/OmapLib.h>\r
#include <Library/ArmLib.h>\r
+#include <Library/PeCoffGetEntryPointLib.h>\r
\r
#include <Ppi/GuidedSectionExtraction.h>\r
-\r
+#include <Guid/LzmaDecompress.h>\r
#include <Omap3530/Omap3530.h>\r
\r
+#include "LzmaDecompress.h"\r
+\r
+VOID\r
+EFIAPI \r
+_ModuleEntryPoint(\r
+ VOID\r
+ );\r
+\r
+CHAR8 *\r
+DeCygwinPathIfNeeded (\r
+ IN CHAR8 *Name\r
+ );\r
+\r
VOID\r
PadConfiguration (\r
VOID\r
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
IN VOID *MemoryBase,\r
\r
// Start talking\r
UartInit();\r
- DEBUG((EFI_D_ERROR, "UART Test Line\n"));\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);
+ 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);\r
+ 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__\r
+ // 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\r
+ DEBUG ((EFI_D_ERROR, "SEC starts at 0x%08x with an entry point at 0x%08x %a\n", PeCoffImage, _ModuleEntryPoint, FilePath));
+#endif\r
+ }\r
+ }
+
+ DEBUG_CODE_END ();\r
+\r
+\r
\r
// Start up a free running time so that the timer lib will work\r
TimerInit();\r
ExtractGuidedSectionLibConstructor();\r
LzmaDecompressLibConstructor();\r
\r
+ // Build HOBs to pass up our version of stuff the DXE Core needs to save space\r
+#if 0\r
+ BuildPeCoffLoaderHob ();\r
+ BuildExtractSectionHob (\r
+ &gLzmaCustomDecompressGuid,\r
+ LzmaGuidedSectionGetInfo,\r
+ LzmaGuidedSectionExtraction\r
+ );\r
+#endif\r
+\r
+ DecompressFirstFv ();\r
+\r
// Load the DXE Core and transfer control to it\r
LoadDxeCoreFromFv(NULL, 0);\r
\r