Fix typo in comment.
[mirror_edk2.git] / IntelFrameworkPkg / Library / HiiLibFramework / HiiLibFramework.c
CommitLineData
61789197 1/** @file\r
2 HII Library implementation that uses DXE protocols and services.\r
3\r
4 Copyright (c) 2006, Intel Corporation<BR>\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
61789197 13**/\r
14\r
15\r
16#include <FrameworkDxe.h>\r
17\r
18\r
19#include <Protocol/FrameworkHii.h>\r
20\r
21#include <Library/HiiLib.h>\r
22#include <Library/DebugLib.h>\r
23#include <Library/UefiBootServicesTableLib.h>\r
24#include <Library/MemoryAllocationLib.h>\r
25\r
26EFI_HII_PROTOCOL *gHiiProtocol = NULL;\r
27\r
b2cefd7c 28/**\r
29 The constructor function for HiiLibFramework library instance\r
30\r
31 The constructor function locates Hii protocol from protocol database.\r
32 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.\r
61789197 33\r
b2cefd7c 34 @param ImageHandle The firmware allocated handle for the EFI image.\r
35 @param SystemTable A pointer to the EFI System Table.\r
36\r
37 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
38\r
39**/\r
61789197 40EFI_STATUS\r
41EFIAPI\r
42HiiLibFrameworkConstructor (\r
43 IN EFI_HANDLE ImageHandle,\r
44 IN EFI_SYSTEM_TABLE *SystemTable\r
45 )\r
46{\r
47 EFI_STATUS Status;\r
48\r
49 Status = gBS->LocateProtocol (\r
50 &gEfiHiiProtocolGuid,\r
51 NULL,\r
568f78ab 52 (VOID **) &gHiiProtocol\r
61789197 53 );\r
54 ASSERT_EFI_ERROR (Status);\r
55\r
56 return Status;\r
57 \r
58}\r
59\r
60/**\r
61 This function allocates pool for an EFI_HII_PACKAGES structure\r
62 with enough space for the variable argument list of package pointers.\r
63 The allocated structure is initialized using NumberOfPackages, Guid,\r
64 and the variable length argument list of package pointers.\r
65\r
66 @param NumberOfPackages The number of HII packages to prepare.\r
7459094d 67 @param Guid Package GUID.\r
68 @param Args Package contents\r
61789197 69\r
70 @return The allocated and initialized packages.\r
71\r
72**/\r
73EFI_HII_PACKAGES *\r
74InternalPreparePackages (\r
75 IN UINTN NumberOfPackages,\r
76 IN CONST EFI_GUID *Guid OPTIONAL,\r
77 IN VA_LIST Args\r
78 )\r
79{\r
80 EFI_HII_PACKAGES *HiiPackages;\r
81 VOID **Package;\r
82 UINTN Index;\r
83\r
84 ASSERT (NumberOfPackages > 0);\r
85\r
86 HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));\r
87 ASSERT (HiiPackages != NULL);\r
88\r
89 HiiPackages->GuidId = (EFI_GUID *) Guid;\r
90 HiiPackages->NumberOfPackages = NumberOfPackages;\r
91 Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES));\r
92\r
93 for (Index = 0; Index < NumberOfPackages; Index++) {\r
94 *Package = VA_ARG (Args, VOID *);\r
95 Package++;\r
96 }\r
97\r
98 return HiiPackages;\r
99\r
100}\r
101\r
61789197 102\r