]> git.proxmox.com Git - mirror_edk2.git/blame - BeagleBoardPkg/Bds/FirmwareVolume.c
Updating ArmLib.h to add functions needed to turn on paging in CpuDxe. Also added...
[mirror_edk2.git] / BeagleBoardPkg / Bds / FirmwareVolume.c
CommitLineData
2ef2b01e
A
1/** @file\r
2 The entry of the embedded BDS. This BDS does not follow the Boot Manager requirements \r
3 of the UEFI specification as it is designed to implement an embedded systmes \r
4 propriatary boot scheme.\r
5\r
6 This template assume a DXE driver produces a SerialIo protocol not using the EFI \r
7 driver module and it will attempt to connect a console on top of this.\r
8\r
9 \r
10 Copyright (c) 2009 Apple, Inc. All rights reserved. \r
11 Portions copyright (c) 2008-2009, Apple Inc. All rights reserved.\r
12\r
13\r
14 This document is the property of Apple, Inc.\r
15 It is considered confidential and proprietary.\r
16 \r
17 This document may not be reproduced or transmitted in any form,\r
18 in whole or in part, without the express written permission of\r
19 Apple, Inc.\r
20\r
21**/\r
22\r
23#include "BdsEntry.h"\r
24\r
25\r
26EFI_STATUS\r
27FindApplicationMatchingUiSection (\r
28 IN CHAR16 *UiString,\r
29 OUT EFI_HANDLE *FvHandle,\r
30 OUT EFI_GUID *NameGuid\r
31 )\r
32{\r
33 EFI_STATUS Status;\r
34 EFI_STATUS NextStatus;\r
35 UINTN NoHandles;\r
36 EFI_HANDLE *Buffer;\r
37 UINTN Index;\r
38 EFI_FV_FILETYPE FileType;\r
39 EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
40 VOID *Key;\r
41 EFI_FV_FILE_ATTRIBUTES Attributes;\r
42 UINTN Size;\r
43 UINTN UiStringLen;\r
44 CHAR16 *UiSection;\r
45 UINT32 Authentication;\r
46 \r
47 \r
48 UiStringLen = 0;\r
49 if (UiString != NULL) {\r
50 DEBUG ((DEBUG_ERROR, "UiString %s\n", UiString));\r
51 UiStringLen = StrLen (UiString);\r
52 }\r
53 \r
54 Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiFirmwareVolume2ProtocolGuid, NULL, &NoHandles, &Buffer);\r
55 if (!EFI_ERROR (Status)) {\r
56 for (Index = 0; Index < NoHandles; Index++) {\r
57 Status = gBS->HandleProtocol (Buffer[Index], &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&Fv);\r
58 if (!EFI_ERROR (Status)) {\r
59 Key = AllocatePool (Fv->KeySize);\r
60 ASSERT (Key != NULL);\r
61 ZeroMem (Key, Fv->KeySize);\r
62 \r
63 FileType = EFI_FV_FILETYPE_APPLICATION;\r
64 \r
65 do {\r
66 NextStatus = Fv->GetNextFile (Fv, Key, &FileType, NameGuid, &Attributes, &Size);\r
67 if (!EFI_ERROR (NextStatus)) {\r
68 if (UiString == NULL) {\r
69 //\r
70 // If UiString is NULL match first application we find.\r
71 //\r
72 *FvHandle = Buffer[Index];\r
73 FreePool (Key);\r
74 return Status;\r
75 }\r
76 \r
77 UiSection = NULL;\r
78 Status = Fv->ReadSection (\r
79 Fv, \r
80 NameGuid, \r
81 EFI_SECTION_USER_INTERFACE, \r
82 0,\r
83 (VOID **)&UiSection,\r
84 &Size,\r
85 &Authentication\r
86 );\r
87 if (!EFI_ERROR (Status)) {\r
88 if (StrnCmp (UiString, UiSection, UiStringLen) == 0) {\r
89 //\r
90 // We found a UiString match. \r
91 //\r
92 *FvHandle = Buffer[Index];\r
93 FreePool (Key);\r
94 FreePool (UiSection);\r
95 return Status;\r
96 }\r
97 FreePool (UiSection);\r
98 }\r
99 }\r
100 } while (!EFI_ERROR (NextStatus));\r
101 \r
102 FreePool (Key);\r
103 }\r
104 }\r
105 \r
106 FreePool (Buffer);\r
107 }\r
108\r
109 return EFI_NOT_FOUND;\r
110}\r
111\r
112\r
113EFI_DEVICE_PATH *\r
114FvFileDevicePath (\r
115 IN EFI_HANDLE FvHandle,\r
116 IN EFI_GUID *NameGuid\r
117 )\r
118{ \r
119 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
120 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH NewNode;\r
121\r
122 DevicePath = DevicePathFromHandle (FvHandle);\r
123\r
124 EfiInitializeFwVolDevicepathNode (&NewNode, NameGuid);\r
125 \r
126 return AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&NewNode);\r
127}\r
128\r
129\r
130\r
131EFI_STATUS\r
132LoadPeCoffSectionFromFv (\r
133 IN EFI_HANDLE FvHandle, \r
134 IN EFI_GUID *NameGuid\r
135 )\r
136{\r
137 EFI_STATUS Status;\r
138 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
139 EFI_HANDLE ImageHandle;\r
140\r
141 DevicePath = FvFileDevicePath (FvHandle, NameGuid);\r
142 \r
143 Status = gBS->LoadImage (TRUE, gImageHandle, DevicePath, NULL, 0, &ImageHandle);\r
144 if (!EFI_ERROR (Status)) {\r
145 Status = gBS->StartImage (ImageHandle, NULL, NULL);\r
146 }\r
147 \r
148 return Status;\r
149}\r
150 \r