]>
Commit | Line | Data |
---|---|---|
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 | |
26 | EFI_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 | 40 | EFI_STATUS\r |
41 | EFIAPI\r | |
42 | HiiLibFrameworkConstructor (\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 | |
67 | @param Guid Package GUID.\r | |
68 | \r | |
69 | @return The allocated and initialized packages.\r | |
70 | \r | |
71 | **/\r | |
72 | EFI_HII_PACKAGES *\r | |
73 | InternalPreparePackages (\r | |
74 | IN UINTN NumberOfPackages,\r | |
75 | IN CONST EFI_GUID *Guid OPTIONAL,\r | |
76 | IN VA_LIST Args\r | |
77 | )\r | |
78 | {\r | |
79 | EFI_HII_PACKAGES *HiiPackages;\r | |
80 | VOID **Package;\r | |
81 | UINTN Index;\r | |
82 | \r | |
83 | ASSERT (NumberOfPackages > 0);\r | |
84 | \r | |
85 | HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));\r | |
86 | ASSERT (HiiPackages != NULL);\r | |
87 | \r | |
88 | HiiPackages->GuidId = (EFI_GUID *) Guid;\r | |
89 | HiiPackages->NumberOfPackages = NumberOfPackages;\r | |
90 | Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES));\r | |
91 | \r | |
92 | for (Index = 0; Index < NumberOfPackages; Index++) {\r | |
93 | *Package = VA_ARG (Args, VOID *);\r | |
94 | Package++;\r | |
95 | }\r | |
96 | \r | |
97 | return HiiPackages;\r | |
98 | \r | |
99 | }\r | |
100 | \r | |
61789197 | 101 | \r |