]> git.proxmox.com Git - mirror_edk2.git/blame - ArmEbPkg/Sec/Sec.c
Report correct MediaPresentSupported value from Nt32 SNP mode data.
[mirror_edk2.git] / ArmEbPkg / Sec / Sec.c
CommitLineData
1fde2f61 1/** @file\r
2 C Entry point for the SEC. First C code after the reset vector.\r
3\r
cf748a1a 4 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
1fde2f61 5 \r
cf748a1a 6 This program and the accompanying materials\r
1fde2f61 7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include <PiPei.h>\r
17\r
18#include <Library/DebugLib.h>\r
19#include <Library/PrePiLib.h>\r
20#include <Library/PcdLib.h>\r
21#include <Library/IoLib.h>\r
22#include <Library/ArmLib.h>\r
23#include <Library/PeCoffGetEntryPointLib.h>\r
ebeffc42 24#include <Library/DebugAgentLib.h>\r
1fde2f61 25\r
26#include <Ppi/GuidedSectionExtraction.h>\r
27#include <Guid/LzmaDecompress.h>\r
28\r
ebeffc42 29#include <ArmEb/ArmEb.h>\r
30\r
1fde2f61 31#include "LzmaDecompress.h"\r
32\r
33VOID\r
34EFIAPI \r
35_ModuleEntryPoint(\r
36 VOID\r
37 );\r
38\r
39CHAR8 *\r
40DeCygwinPathIfNeeded (\r
41 IN CHAR8 *Name\r
42 );\r
43\r
44RETURN_STATUS\r
45EFIAPI\r
46SerialPortInitialize (\r
47 VOID\r
48 );\r
49 \r
50 \r
51VOID\r
52UartInit (\r
53 VOID\r
54 )\r
55{\r
56 // SEC phase needs to run library constructors by hand.\r
57 // This assumes we are linked agains the SerialLib\r
58 // In non SEC modules the init call is in autogenerated code.\r
59 SerialPortInitialize ();\r
60}\r
61\r
ebeffc42 62VOID\r
63TimerInit (\r
64 VOID\r
65 )\r
66{\r
67 // configure SP810 to use 1MHz clock and disable\r
68 MmioAndThenOr32 (EB_SP810_CTRL_BASE + SP810_SYS_CTRL_REG, ~SP810_SYS_CTRL_TIMER2_EN, SP810_SYS_CTRL_TIMER2_TIMCLK);\r
69 // Enable\r
70 MmioOr32 (EB_SP810_CTRL_BASE + SP810_SYS_CTRL_REG, SP810_SYS_CTRL_TIMER2_EN);\r
71\r
72 // configure timer 2 for one shot operation, 32 bits, no prescaler, and interrupt disabled\r
73 MmioOr32 (EB_SP804_TIMER2_BASE + SP804_TIMER_CONTROL_REG, SP804_TIMER_CTRL_ONESHOT | SP804_TIMER_CTRL_32BIT | SP804_PRESCALE_DIV_1);\r
74\r
75 // preload the timer count register\r
76 MmioWrite32 (EB_SP804_TIMER2_BASE + SP804_TIMER_LOAD_REG, 1);\r
77\r
78 // enable the timer\r
79 MmioOr32 (EB_SP804_TIMER2_BASE + SP804_TIMER_CONTROL_REG, SP804_TIMER_CTRL_ENABLE);\r
80}\r
81\r
82\r
1fde2f61 83VOID\r
84InitCache (\r
85 IN UINT32 MemoryBase,\r
86 IN UINT32 MemoryLength\r
87 );\r
88\r
89EFI_STATUS\r
90EFIAPI\r
91ExtractGuidedSectionLibConstructor (\r
92 VOID\r
93 );\r
94\r
95EFI_STATUS\r
96EFIAPI\r
97LzmaDecompressLibConstructor (\r
98 VOID\r
99 );\r
100\r
1fde2f61 101\r
102VOID\r
103CEntryPoint (\r
104 IN VOID *MemoryBase,\r
105 IN UINTN MemorySize,\r
106 IN VOID *StackBase,\r
107 IN UINTN StackSize\r
108 )\r
109{\r
110 VOID *HobBase;\r
111\r
112 // Build a basic HOB list\r
113 HobBase = (VOID *)(UINTN)(FixedPcdGet32(PcdEmbeddedFdBaseAddress) + FixedPcdGet32(PcdEmbeddedFdSize));\r
114 CreateHobList (MemoryBase, MemorySize, HobBase, StackBase);\r
115\r
116\r
117 // Enable program flow prediction, if supported.\r
118 ArmEnableBranchPrediction ();\r
119\r
120 // Initialize CPU cache\r
121 InitCache ((UINT32)MemoryBase, (UINT32)MemorySize);\r
122\r
123 // Add memory allocation hob for relocated FD\r
124 BuildMemoryAllocationHob (FixedPcdGet32(PcdEmbeddedFdBaseAddress), FixedPcdGet32(PcdEmbeddedFdSize), EfiBootServicesData);\r
125\r
126 // Add the FVs to the hob list\r
127 BuildFvHob (PcdGet32(PcdFlashFvMainBase), PcdGet32(PcdFlashFvMainSize));\r
128\r
129 // Start talking\r
130 UartInit ();\r
1fde2f61 131\r
ebeffc42 132 InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, NULL);\r
133 SaveAndSetDebugTimerInterrupt (TRUE);\r
134\r
135 DEBUG ((EFI_D_ERROR, "UART Enabled\n"));\r
1fde2f61 136\r
ebeffc42 137 // Start up a free running timer so that the timer lib will work\r
138 TimerInit ();\r
1fde2f61 139\r
140 // SEC phase needs to run library constructors by hand.\r
141 ExtractGuidedSectionLibConstructor ();\r
142 LzmaDecompressLibConstructor ();\r
143\r
144 // Build HOBs to pass up our version of stuff the DXE Core needs to save space\r
145 BuildPeCoffLoaderHob ();\r
146 BuildExtractSectionHob (\r
147 &gLzmaCustomDecompressGuid,\r
148 LzmaGuidedSectionGetInfo,\r
149 LzmaGuidedSectionExtraction\r
150 );\r
151\r
152 // Assume the FV that contains the SEC (our code) also contains a compressed FV.\r
153 DecompressFirstFv ();\r
154\r
155 // Load the DXE Core and transfer control to it\r
156 LoadDxeCoreFromFv (NULL, 0);\r
157 \r
158 // DXE Core should always load and never return\r
159 ASSERT (FALSE);\r
160}\r
161\r