Fix function comments.
[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 **/
14
15
16 #include <FrameworkDxe.h>
17
18
19 #include <Protocol/FrameworkHii.h>
20
21 #include <Library/HiiLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/UefiBootServicesTableLib.h>
24 #include <Library/MemoryAllocationLib.h>
25
26 EFI_HII_PROTOCOL *gHiiProtocol = NULL;
27
28 /**
29 The constructor function for HiiLibFramework library instance
30
31 The constructor function locates Hii protocol from protocol database.
32 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
33
34 @param ImageHandle The firmware allocated handle for the EFI image.
35 @param SystemTable A pointer to the EFI System Table.
36
37 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
38
39 **/
40 EFI_STATUS
41 EFIAPI
42 HiiLibFrameworkConstructor (
43 IN EFI_HANDLE ImageHandle,
44 IN EFI_SYSTEM_TABLE *SystemTable
45 )
46 {
47 EFI_STATUS Status;
48
49 Status = gBS->LocateProtocol (
50 &gEfiHiiProtocolGuid,
51 NULL,
52 (VOID **) &gHiiProtocol
53 );
54 ASSERT_EFI_ERROR (Status);
55
56 return Status;
57
58 }
59
60 /**
61 This function allocates pool for an EFI_HII_PACKAGES structure
62 with enough space for the variable argument list of package pointers.
63 The allocated structure is initialized using NumberOfPackages, Guid,
64 and the variable length argument list of package pointers.
65
66 @param NumberOfPackages The number of HII packages to prepare.
67 @param Guid Package GUID.
68
69 @return The allocated and initialized packages.
70
71 **/
72 EFI_HII_PACKAGES *
73 InternalPreparePackages (
74 IN UINTN NumberOfPackages,
75 IN CONST EFI_GUID *Guid OPTIONAL,
76 IN VA_LIST Args
77 )
78 {
79 EFI_HII_PACKAGES *HiiPackages;
80 VOID **Package;
81 UINTN Index;
82
83 ASSERT (NumberOfPackages > 0);
84
85 HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));
86 ASSERT (HiiPackages != NULL);
87
88 HiiPackages->GuidId = (EFI_GUID *) Guid;
89 HiiPackages->NumberOfPackages = NumberOfPackages;
90 Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES));
91
92 for (Index = 0; Index < NumberOfPackages; Index++) {
93 *Package = VA_ARG (Args, VOID *);
94 Package++;
95 }
96
97 return HiiPackages;
98
99 }
100
101 EFI_STATUS
102 EFIAPI
103 PrepareAndCreateNewPackages (
104 IN UINTN NumberOfPackages,
105 IN CONST EFI_GUID *GuidId,
106 OUT VOID **HiiHandle, //Framework is FRAMEWORK_HII_HANDLE; UEFI is EFI_HII_HANDLE;
107 // C:\D\Work\Tiano\Tiano_Main_Trunk\TIANO\Platform\IntelEpg\SR870BN4\MemorySubClassDriver\DualChannelDdr\MemorySubClass.c make use of this output value
108 ...
109 )
110 {
111 EFI_STATUS Status;
112 EFI_HII_PACKAGES *PackageList;
113 VA_LIST Args;
114 FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle;
115
116
117 VA_START (Args, HiiHandle);
118 PackageList = InternalPreparePackages (NumberOfPackages, GuidId, Args);
119 VA_END (Args);
120
121 Status = gHiiProtocol->NewPack (gHiiProtocol, PackageList, &FrameworkHiiHandle);
122 *HiiHandle = (VOID *) (UINTN) FrameworkHiiHandle;
123
124 return Status;
125 }
126
127