]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkPkg/Library/HiiLibFramework/HiiLibFramework.c
ca7febda4b652b68bb1feab2d68e8716a454a0c1
[mirror_edk2.git] / IntelFrameworkPkg / Library / HiiLibFramework / HiiLibFramework.c
1 /** @file
2 HII Library implementation that uses DXE protocols and services.
3
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 Module Name: HiiLib.c
14
15 **/
16
17
18 #include <FrameworkDxe.h>
19
20
21 #include <Protocol/FrameworkHii.h>
22
23 #include <Library/HiiLib.h>
24 #include <Library/DebugLib.h>
25 #include <Library/UefiBootServicesTableLib.h>
26 #include <Library/MemoryAllocationLib.h>
27
28 EFI_HII_PROTOCOL *gHiiProtocol = NULL;
29
30
31 EFI_STATUS
32 EFIAPI
33 HiiLibFrameworkConstructor (
34 IN EFI_HANDLE ImageHandle,
35 IN EFI_SYSTEM_TABLE *SystemTable
36 )
37 {
38 EFI_STATUS Status;
39
40 Status = gBS->LocateProtocol (
41 &gEfiHiiProtocolGuid,
42 NULL,
43 &gHiiProtocol
44 );
45 ASSERT_EFI_ERROR (Status);
46
47 return Status;
48
49 }
50
51 /**
52 This function allocates pool for an EFI_HII_PACKAGES structure
53 with enough space for the variable argument list of package pointers.
54 The allocated structure is initialized using NumberOfPackages, Guid,
55 and the variable length argument list of package pointers.
56
57 @param NumberOfPackages The number of HII packages to prepare.
58 @param Guid Package GUID.
59
60 @return The allocated and initialized packages.
61
62 **/
63 EFI_HII_PACKAGES *
64 InternalPreparePackages (
65 IN UINTN NumberOfPackages,
66 IN CONST EFI_GUID *Guid OPTIONAL,
67 IN VA_LIST Args
68 )
69 {
70 EFI_HII_PACKAGES *HiiPackages;
71 VOID **Package;
72 UINTN Index;
73
74 ASSERT (NumberOfPackages > 0);
75
76 HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));
77 ASSERT (HiiPackages != NULL);
78
79 HiiPackages->GuidId = (EFI_GUID *) Guid;
80 HiiPackages->NumberOfPackages = NumberOfPackages;
81 Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES));
82
83 for (Index = 0; Index < NumberOfPackages; Index++) {
84 *Package = VA_ARG (Args, VOID *);
85 Package++;
86 }
87
88 return HiiPackages;
89
90 }
91
92 EFI_STATUS
93 EFIAPI
94 PrepareAndCreateNewPackages (
95 IN UINTN NumberOfPackages,
96 IN CONST EFI_GUID *GuidId,
97 OUT VOID **HiiHandle, //Framework is FRAMEWORK_HII_HANDLE; UEFI is EFI_HII_HANDLE;
98 // C:\D\Work\Tiano\Tiano_Main_Trunk\TIANO\Platform\IntelEpg\SR870BN4\MemorySubClassDriver\DualChannelDdr\MemorySubClass.c make use of this output value
99 ...
100 )
101 {
102 EFI_STATUS Status;
103 EFI_HII_PACKAGES *PackageList;
104 VA_LIST Args;
105 FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle;
106
107
108 VA_START (Args, HiiHandle);
109 PackageList = InternalPreparePackages (NumberOfPackages, GuidId, Args);
110 VA_END (Args);
111
112 Status = gHiiProtocol->NewPack (gHiiProtocol, PackageList, &FrameworkHiiHandle);
113 *HiiHandle = (VOID *) (UINTN) FrameworkHiiHandle;
114
115 return Status;
116 }
117
118