Bds.h revision f6c07313d1f7317c328e9ef80cfb272beec0a249
15c08e1173703234cc2913757f237ee916087498aklu/** @file
25c08e1173703234cc2913757f237ee916087498aklu  Head file for BDS Architectural Protocol implementation
35c08e1173703234cc2913757f237ee916087498aklu
4ff8438477f2dcea28149514de25368ac0b2c02eeniruiyuCopyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
5180a5a35cb49699bd249dee19e41cee34c856a58hhtianThis program and the accompanying materials
65c08e1173703234cc2913757f237ee916087498akluare licensed and made available under the terms and conditions of the BSD License
75c08e1173703234cc2913757f237ee916087498akluwhich accompanies this distribution.  The full text of the license may be found at
85c08e1173703234cc2913757f237ee916087498akluhttp://opensource.org/licenses/bsd-license.php
95c08e1173703234cc2913757f237ee916087498aklu
105c08e1173703234cc2913757f237ee916087498akluTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
115c08e1173703234cc2913757f237ee916087498akluWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
125c08e1173703234cc2913757f237ee916087498aklu
135c08e1173703234cc2913757f237ee916087498aklu**/
145c08e1173703234cc2913757f237ee916087498aklu
155c08e1173703234cc2913757f237ee916087498aklu#ifndef _BDS_MODULE_H_
165c08e1173703234cc2913757f237ee916087498aklu#define _BDS_MODULE_H_
175c08e1173703234cc2913757f237ee916087498aklu
1879bc7a89f7da2c5c17332a55e514dd69e849ce87mdkinney#include <FrameworkDxe.h>
1967d632277d0650197002996fb98cb3cb41dce9e8lgao#include <IndustryStandard/PeImage.h>
20a2ded1d652cef1f2aaf85e73fc8f5bc5626723beqhuang#include <Guid/MdeModuleHii.h>
215c08e1173703234cc2913757f237ee916087498aklu#include <Guid/FileSystemVolumeLabelInfo.h>
22ab4da12626934cf13fa3f7265cb220eb7f3f31fcgikidy#include <Guid/HiiPlatformSetupFormset.h>
235c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/DevicePath.h>
246cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang#include <IndustryStandard/SmBios.h>
255c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/LoadFile.h>
265c08e1173703234cc2913757f237ee916087498aklu#include <Guid/FileInfo.h>
275c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/HiiConfigRouting.h>
285c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/Bds.h>
296cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang#include <Protocol/Smbios.h>
305c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/UgaDraw.h>
315c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/BlockIo.h>
325c08e1173703234cc2913757f237ee916087498aklu#include <Guid/GlobalVariable.h>
335c08e1173703234cc2913757f237ee916087498aklu#include <Guid/CapsuleVendor.h>
3455e1864e6bff2fb719e0745b35ed386aa74065c3lgao#include <Guid/StatusCodeDataTypeId.h>
35e24fc1032db5d5d2395260f6d7af94aa5a2a0802lgao#include <Guid/LegacyDevOrder.h>
36e24fc1032db5d5d2395260f6d7af94aa5a2a0802lgao#include <Guid/BdsHii.h>
375676ccca070b261ff70e93bc32b5f7496c1b8c83czhang#include <Guid/ConnectConInEvent.h>
38f6c07313d1f7317c328e9ef80cfb272beec0a249lzeng#include <Guid/Performance.h>
395c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/GenericMemoryTest.h>
405c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/FormBrowser2.h>
415c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/HiiConfigAccess.h>
425c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/GraphicsOutput.h>
435c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/SimpleFileSystem.h>
445c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/HiiDatabase.h>
455c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/HiiString.h>
465c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/SerialIo.h>
475c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/LegacyBios.h>
485c08e1173703234cc2913757f237ee916087498aklu#include <Protocol/SimpleTextInEx.h>
49ab4da12626934cf13fa3f7265cb220eb7f3f31fcgikidy#include <Protocol/DriverHealth.h>
50a637802c2f8765549cf41a5694f53860b24601c9xdu#include <Protocol/BootLogo.h>
51ff8438477f2dcea28149514de25368ac0b2c02eeniruiyu#include <Protocol/VariableLock.h>
525c08e1173703234cc2913757f237ee916087498aklu
535c08e1173703234cc2913757f237ee916087498aklu#include <Library/UefiDriverEntryPoint.h>
545c08e1173703234cc2913757f237ee916087498aklu#include <Library/PrintLib.h>
555c08e1173703234cc2913757f237ee916087498aklu#include <Library/DebugLib.h>
565c08e1173703234cc2913757f237ee916087498aklu#include <Library/BaseMemoryLib.h>
575c08e1173703234cc2913757f237ee916087498aklu#include <Library/UefiBootServicesTableLib.h>
585c08e1173703234cc2913757f237ee916087498aklu#include <Library/UefiLib.h>
595c08e1173703234cc2913757f237ee916087498aklu#include <Library/MemoryAllocationLib.h>
605c08e1173703234cc2913757f237ee916087498aklu#include <Library/PerformanceLib.h>
615c08e1173703234cc2913757f237ee916087498aklu#include <Library/ReportStatusCodeLib.h>
625c08e1173703234cc2913757f237ee916087498aklu#include <Library/UefiRuntimeServicesTableLib.h>
635c08e1173703234cc2913757f237ee916087498aklu#include <Library/HobLib.h>
645c08e1173703234cc2913757f237ee916087498aklu#include <Library/BaseLib.h>
655c08e1173703234cc2913757f237ee916087498aklu#include <Library/DevicePathLib.h>
665c08e1173703234cc2913757f237ee916087498aklu#include <Library/PcdLib.h>
675c08e1173703234cc2913757f237ee916087498aklu#include <Library/CapsuleLib.h>
685c08e1173703234cc2913757f237ee916087498aklu#include <Library/HiiLib.h>
69f6f910dd125144707e3516bbb517b8ec7a388c06rsun#include <Library/DevicePathLib.h>
7033bb6326576a3f4f722b60d8a8d996af882009d1qhuang#include <Library/UefiHiiServicesLib.h>
715c08e1173703234cc2913757f237ee916087498aklu
725c08e1173703234cc2913757f237ee916087498aklu#include <Library/GenericBdsLib.h>
735c08e1173703234cc2913757f237ee916087498aklu#include <Library/PlatformBdsLib.h>
745c08e1173703234cc2913757f237ee916087498aklu
75f6f910dd125144707e3516bbb517b8ec7a388c06rsun#pragma pack(1)
76f6f910dd125144707e3516bbb517b8ec7a388c06rsun
77f6f910dd125144707e3516bbb517b8ec7a388c06rsun///
78f6f910dd125144707e3516bbb517b8ec7a388c06rsun/// HII specific Vendor Device Path definition.
79f6f910dd125144707e3516bbb517b8ec7a388c06rsun///
80f6f910dd125144707e3516bbb517b8ec7a388c06rsuntypedef struct {
81f6f910dd125144707e3516bbb517b8ec7a388c06rsun  VENDOR_DEVICE_PATH             VendorDevicePath;
82f6f910dd125144707e3516bbb517b8ec7a388c06rsun  EFI_DEVICE_PATH_PROTOCOL       End;
83f6f910dd125144707e3516bbb517b8ec7a388c06rsun} HII_VENDOR_DEVICE_PATH;
84f6f910dd125144707e3516bbb517b8ec7a388c06rsun
85f6f910dd125144707e3516bbb517b8ec7a388c06rsun#pragma pack()
86f6f910dd125144707e3516bbb517b8ec7a388c06rsun
875c08e1173703234cc2913757f237ee916087498aklu/**
885c08e1173703234cc2913757f237ee916087498aklu
895c08e1173703234cc2913757f237ee916087498aklu  Show progress bar with title above it. It only works in Graphics mode.
905c08e1173703234cc2913757f237ee916087498aklu
915c08e1173703234cc2913757f237ee916087498aklu  @param TitleForeground Foreground color for Title.
925c08e1173703234cc2913757f237ee916087498aklu  @param TitleBackground Background color for Title.
935c08e1173703234cc2913757f237ee916087498aklu  @param Title           Title above progress bar.
945c08e1173703234cc2913757f237ee916087498aklu  @param ProgressColor   Progress bar color.
955c08e1173703234cc2913757f237ee916087498aklu  @param Progress        Progress (0-100)
965c08e1173703234cc2913757f237ee916087498aklu  @param PreviousValue   The previous value of the progress.
975c08e1173703234cc2913757f237ee916087498aklu
985c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_STATUS       Success update the progress bar
995c08e1173703234cc2913757f237ee916087498aklu
1005c08e1173703234cc2913757f237ee916087498aklu**/
1015c08e1173703234cc2913757f237ee916087498akluEFI_STATUS
1025c08e1173703234cc2913757f237ee916087498akluPlatformBdsShowProgress (
1035c08e1173703234cc2913757f237ee916087498aklu  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,
1045c08e1173703234cc2913757f237ee916087498aklu  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,
1055c08e1173703234cc2913757f237ee916087498aklu  IN CHAR16                        *Title,
1065c08e1173703234cc2913757f237ee916087498aklu  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,
1075c08e1173703234cc2913757f237ee916087498aklu  IN UINTN                         Progress,
1085c08e1173703234cc2913757f237ee916087498aklu  IN UINTN                         PreviousValue
1095c08e1173703234cc2913757f237ee916087498aklu  );
1105c08e1173703234cc2913757f237ee916087498aklu
1115c08e1173703234cc2913757f237ee916087498aklu//
1125c08e1173703234cc2913757f237ee916087498aklu// Prototypes
1135c08e1173703234cc2913757f237ee916087498aklu//
1145c08e1173703234cc2913757f237ee916087498aklu
1155c08e1173703234cc2913757f237ee916087498aklu/**
1165c08e1173703234cc2913757f237ee916087498aklu
1175c08e1173703234cc2913757f237ee916087498aklu  Install Boot Device Selection Protocol
1185c08e1173703234cc2913757f237ee916087498aklu
1195c08e1173703234cc2913757f237ee916087498aklu  @param ImageHandle     The image handle.
1205c08e1173703234cc2913757f237ee916087498aklu  @param SystemTable     The system table.
1215c08e1173703234cc2913757f237ee916087498aklu
1225c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_SUCEESS  BDS has finished initializing.
1235c08e1173703234cc2913757f237ee916087498aklu                        Return the dispatcher and recall BDS.Entry
1245c08e1173703234cc2913757f237ee916087498aklu  @retval  Other        Return status from AllocatePool() or gBS->InstallProtocolInterface
1255c08e1173703234cc2913757f237ee916087498aklu
1265c08e1173703234cc2913757f237ee916087498aklu**/
1275c08e1173703234cc2913757f237ee916087498akluEFI_STATUS
1285c08e1173703234cc2913757f237ee916087498akluEFIAPI
1295c08e1173703234cc2913757f237ee916087498akluBdsInitialize (
1305c08e1173703234cc2913757f237ee916087498aklu  IN EFI_HANDLE                     ImageHandle,
1315c08e1173703234cc2913757f237ee916087498aklu  IN EFI_SYSTEM_TABLE               *SystemTable
1325c08e1173703234cc2913757f237ee916087498aklu  );
1335c08e1173703234cc2913757f237ee916087498aklu
1345c08e1173703234cc2913757f237ee916087498aklu/**
1355c08e1173703234cc2913757f237ee916087498aklu
1365c08e1173703234cc2913757f237ee916087498aklu  Service routine for BdsInstance->Entry(). Devices are connected, the
1375c08e1173703234cc2913757f237ee916087498aklu  consoles are initialized, and the boot options are tried.
1385c08e1173703234cc2913757f237ee916087498aklu
1395c08e1173703234cc2913757f237ee916087498aklu  @param This            Protocol Instance structure.
1405c08e1173703234cc2913757f237ee916087498aklu
1415c08e1173703234cc2913757f237ee916087498aklu**/
1425c08e1173703234cc2913757f237ee916087498akluVOID
1435c08e1173703234cc2913757f237ee916087498akluEFIAPI
1445c08e1173703234cc2913757f237ee916087498akluBdsEntry (
1455c08e1173703234cc2913757f237ee916087498aklu  IN  EFI_BDS_ARCH_PROTOCOL *This
1465c08e1173703234cc2913757f237ee916087498aklu  );
1475c08e1173703234cc2913757f237ee916087498aklu
14819bf20e11acd88a02922201f97e6d64edcd16390lgao
14919bf20e11acd88a02922201f97e6d64edcd16390lgao/**
15019bf20e11acd88a02922201f97e6d64edcd16390lgao  Perform the memory test base on the memory test intensive level,
15119bf20e11acd88a02922201f97e6d64edcd16390lgao  and update the memory resource.
15219bf20e11acd88a02922201f97e6d64edcd16390lgao
15319bf20e11acd88a02922201f97e6d64edcd16390lgao  @param  Level         The memory test intensive level.
15419bf20e11acd88a02922201f97e6d64edcd16390lgao
15519bf20e11acd88a02922201f97e6d64edcd16390lgao  @retval EFI_STATUS    Success test all the system memory and update
15619bf20e11acd88a02922201f97e6d64edcd16390lgao                        the memory resource
15719bf20e11acd88a02922201f97e6d64edcd16390lgao
15819bf20e11acd88a02922201f97e6d64edcd16390lgao**/
15919bf20e11acd88a02922201f97e6d64edcd16390lgaoEFI_STATUS
1608861fc792ce90cb7ab18a91bd3d6596d77ee0170jljustenEFIAPI
16119bf20e11acd88a02922201f97e6d64edcd16390lgaoBdsMemoryTest (
16219bf20e11acd88a02922201f97e6d64edcd16390lgao  IN EXTENDMEM_COVERAGE_LEVEL Level
16319bf20e11acd88a02922201f97e6d64edcd16390lgao  );
16419bf20e11acd88a02922201f97e6d64edcd16390lgao
16519bf20e11acd88a02922201f97e6d64edcd16390lgao/**
16619bf20e11acd88a02922201f97e6d64edcd16390lgao
16719bf20e11acd88a02922201f97e6d64edcd16390lgao  This routine is called to see if there are any capsules we need to process.
16819bf20e11acd88a02922201f97e6d64edcd16390lgao  If the boot mode is not UPDATE, then we do nothing. Otherwise find the
16919bf20e11acd88a02922201f97e6d64edcd16390lgao  capsule HOBS and produce firmware volumes for them via the DXE service.
17019bf20e11acd88a02922201f97e6d64edcd16390lgao  Then call the dispatcher to dispatch drivers from them. Finally, check
17119bf20e11acd88a02922201f97e6d64edcd16390lgao  the status of the updates.
17219bf20e11acd88a02922201f97e6d64edcd16390lgao
17319bf20e11acd88a02922201f97e6d64edcd16390lgao  This function should be called by BDS in case we need to do some
17419bf20e11acd88a02922201f97e6d64edcd16390lgao  sort of processing even if there is no capsule to process. We
17519bf20e11acd88a02922201f97e6d64edcd16390lgao  need to do this if an earlier update went away and we need to
17619bf20e11acd88a02922201f97e6d64edcd16390lgao  clear the capsule variable so on the next reset PEI does not see it and
17719bf20e11acd88a02922201f97e6d64edcd16390lgao  think there is a capsule available.
17819bf20e11acd88a02922201f97e6d64edcd16390lgao
17919bf20e11acd88a02922201f97e6d64edcd16390lgao  @param BootMode                 the current boot mode
18019bf20e11acd88a02922201f97e6d64edcd16390lgao
18119bf20e11acd88a02922201f97e6d64edcd16390lgao  @retval EFI_INVALID_PARAMETER   boot mode is not correct for an update
18219bf20e11acd88a02922201f97e6d64edcd16390lgao  @retval EFI_SUCCESS             There is no error when processing capsule
18319bf20e11acd88a02922201f97e6d64edcd16390lgao
18419bf20e11acd88a02922201f97e6d64edcd16390lgao**/
18519bf20e11acd88a02922201f97e6d64edcd16390lgaoEFI_STATUS
1868861fc792ce90cb7ab18a91bd3d6596d77ee0170jljustenEFIAPI
18719bf20e11acd88a02922201f97e6d64edcd16390lgaoBdsProcessCapsules (
18819bf20e11acd88a02922201f97e6d64edcd16390lgao  EFI_BOOT_MODE BootMode
18919bf20e11acd88a02922201f97e6d64edcd16390lgao  );
19019bf20e11acd88a02922201f97e6d64edcd16390lgao
1915c08e1173703234cc2913757f237ee916087498aklu#endif
192