]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkPkg/Library/FrameworkHiiLib/HiiLib.c
clean up modules
[mirror_edk2.git] / IntelFrameworkPkg / Library / FrameworkHiiLib / HiiLib.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 // The package level header files this module uses
19 //
20 #include <FrameworkDxe.h>
21 //
22 // The protocols, PPI and GUID defintions for this module
23 //
24 //
25 // The Library classes this module consumes
26 //
27 #include <Library/FrameworkHiiLib.h>
28 #include <Library/DebugLib.h>
29 #include <Library/MemoryAllocationLib.h>
30
31 /**
32 This function allocates pool for an EFI_HII_PACKAGES structure
33 with enough space for the variable argument list of package pointers.
34 The allocated structure is initialized using NumberOfPackages, Guid,
35 and the variable length argument list of package pointers.
36
37 @param NumberOfPackages The number of HII packages to prepare.
38 @param Guid Package GUID.
39
40 @return The allocated and initialized packages.
41
42 **/
43 EFI_HII_PACKAGES *
44 EFIAPI
45 PreparePackages (
46 IN UINTN NumberOfPackages,
47 IN CONST EFI_GUID *Guid OPTIONAL,
48 ...
49 )
50 {
51 VA_LIST Args;
52 EFI_HII_PACKAGES *HiiPackages;
53 VOID **Package;
54 UINTN Index;
55
56 ASSERT (NumberOfPackages > 0);
57
58 HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));
59 ASSERT (HiiPackages != NULL);
60
61 HiiPackages->GuidId = (EFI_GUID *) Guid;
62 HiiPackages->NumberOfPackages = NumberOfPackages;
63 Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES));
64
65 VA_START (Args, Guid);
66
67 for (Index = 0; Index < NumberOfPackages; Index++) {
68 *Package = VA_ARG (Args, VOID *);
69 Package++;
70 }
71
72 VA_END (Args);
73
74 return HiiPackages;
75
76 }