2 The entry of the embedded BDS. This BDS does not follow the Boot Manager requirements
3 of the UEFI specification as it is designed to implement an embedded systmes
4 propriatary boot scheme.
6 This template assume a DXE driver produces a SerialIo protocol not using the EFI
7 driver module and it will attempt to connect a console on top of this.
9 Copyright (c) 2008-2009, Apple Inc. All rights reserved.
11 All rights reserved. This program and the accompanying materials
12 are licensed and made available under the terms and conditions of the BSD License
13 which accompanies this distribution. The full text of the license may be found at
14 http://opensource.org/licenses/bsd-license.php
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
25 FindApplicationMatchingUiSection (
27 OUT EFI_HANDLE
*FvHandle
,
28 OUT EFI_GUID
**NameGuid
32 EFI_STATUS NextStatus
;
36 EFI_FV_FILETYPE FileType
;
37 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
39 EFI_FV_FILE_ATTRIBUTES Attributes
;
43 UINT32 Authentication
;
47 if (UiString
!= NULL
) {
48 UiStringLen
= StrLen (UiString
);
51 Status
= gBS
->LocateHandleBuffer (ByProtocol
, &gEfiFirmwareVolume2ProtocolGuid
, NULL
, &NoHandles
, &Buffer
);
52 if (!EFI_ERROR (Status
)) {
53 for (Index
= 0; Index
< NoHandles
; Index
++) {
54 Status
= gBS
->HandleProtocol (Buffer
[Index
], &gEfiFirmwareVolume2ProtocolGuid
, (VOID
**)&Fv
);
55 if (!EFI_ERROR (Status
)) {
56 Key
= AllocatePool (Fv
->KeySize
);
57 FileType
= EFI_FV_FILETYPE_APPLICATION
;
60 NextStatus
= Fv
->GetNextFile (Fv
, Key
, &FileType
, *NameGuid
, &Attributes
, &Size
);
61 if (!EFI_ERROR (NextStatus
)) {
62 if (UiString
== NULL
) {
64 // If UiString is NULL match first application we find.
66 *FvHandle
= Buffer
[Index
];
72 Status
= Fv
->ReadSection (
75 EFI_SECTION_USER_INTERFACE
,
81 if (!EFI_ERROR (Status
)) {
82 if (StrnCmp (UiString
, UiSection
, UiStringLen
)) {
84 // We found a UiString match.
86 *FvHandle
= Buffer
[Index
];
94 } while (!EFI_ERROR (NextStatus
));
103 return EFI_NOT_FOUND
;
109 IN EFI_HANDLE FvHandle
,
110 IN EFI_GUID
*NameGuid
113 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
114 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH NewNode
;
116 DevicePath
= DevicePathFromHandle (FvHandle
);
118 EfiInitializeFwVolDevicepathNode (&NewNode
, NameGuid
);
120 return AppendDevicePathNode (DevicePath
, (EFI_DEVICE_PATH_PROTOCOL
*)&NewNode
);
126 LoadPeCoffSectionFromFv (
127 IN EFI_HANDLE FvHandle
,
128 IN EFI_GUID
*NameGuid
132 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
135 UINT32 Authentication
;
136 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
137 EFI_HANDLE ImageHandle
;
139 Status
= gBS
->HandleProtocol (FvHandle
, &gEfiFirmwareVolume2ProtocolGuid
, (VOID
**)&Fv
);
140 if (EFI_ERROR (Status
)) {
144 Status
= Fv
->ReadSection (Fv
, NameGuid
, EFI_SECTION_PE32
, 0, &Buffer
, &BufferSize
, &Authentication
);
145 if (!EFI_ERROR (Status
)) {
146 DevicePath
= FvFileDevicePath (FvHandle
, NameGuid
);
147 Status
= gBS
->LoadImage (TRUE
, gImageHandle
, DevicePath
, Buffer
, BufferSize
, &ImageHandle
);
148 if (!EFI_ERROR (Status
)) {
149 // ExitData is NULL so we need to pass in a size of zero
151 Status
= gBS
->StartImage (ImageHandle
, &BufferSize
, NULL
);