3b0876cc3bf8bde61572f4dee3ea65f0f9608fc8
[mirror_edk2.git] / IntelFrameworkPkg / Library / HiiLib / 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 // Include common header file for this module.
19 //
20 #include "CommonHeader.h"
21
22 /**
23 This function allocates pool for an EFI_HII_PACKAGES structure
24 with enough space for the variable argument list of package pointers.
25 The allocated structure is initialized using NumberOfPackages, Guid,
26 and the variable length argument list of package pointers.
27
28 @param NumberOfPackages The number of HII packages to prepare.
29 @param Guid Package GUID.
30
31 @return The allocated and initialized packages.
32
33 **/
34 EFI_HII_PACKAGES *
35 EFIAPI
36 PreparePackages (
37 IN UINTN NumberOfPackages,
38 IN CONST EFI_GUID *Guid OPTIONAL,
39 ...
40 )
41 {
42 VA_LIST Args;
43 EFI_HII_PACKAGES *HiiPackages;
44 VOID **Package;
45 UINTN Index;
46
47 ASSERT (NumberOfPackages > 0);
48
49 HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));
50 ASSERT (HiiPackages != NULL);
51
52 HiiPackages->GuidId = (EFI_GUID *) Guid;
53 HiiPackages->NumberOfPackages = NumberOfPackages;
54 Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES));
55
56 VA_START (Args, Guid);
57
58 for (Index = 0; Index < NumberOfPackages; Index++) {
59 *Package = VA_ARG (Args, VOID *);
60 Package++;
61 }
62
63 VA_END (Args);
64
65 return HiiPackages;
66
67 }