]> git.proxmox.com Git - mirror_edk2.git/blob - DynamicTablesPkg/Include/Library/TableHelperLib.h
DynamicTablesPkg: Add code for finding duplicate values in arrays
[mirror_edk2.git] / DynamicTablesPkg / Include / Library / TableHelperLib.h
1 /** @file
2
3 Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 @par Glossary:
8 - PFN - Pointer to a Function
9
10 **/
11
12 #ifndef TABLE_HELPER_LIB_H_
13 #define TABLE_HELPER_LIB_H_
14
15 /** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_INFO
16 object from the Configuration Manager.
17
18 @param [in] CfgMgrProtocol Pointer to the Configuration Manager protocol
19 interface.
20 @param [out] CfgMfrInfo Pointer to the Configuration Manager Info
21 object structure.
22
23 @retval EFI_SUCCESS The object is returned.
24 @retval EFI_INVALID_PARAMETER The Object ID is invalid.
25 @retval EFI_NOT_FOUND The requested Object is not found.
26 @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
27 Manager is less than the Object size.
28 **/
29 EFI_STATUS
30 EFIAPI
31 GetCgfMgrInfo (
32 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
33 OUT CM_STD_OBJ_CONFIGURATION_MANAGER_INFO ** CfgMfrInfo
34 );
35
36 /** The AddAcpiHeader function updates the ACPI header structure. It uses the
37 ACPI table Generator and the Configuration Manager protocol to obtain the
38 information required for constructing the header.
39
40 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
41 protocol interface.
42 @param [in] Generator Pointer to the ACPI table Generator.
43 @param [in,out] AcpiHeader Pointer to the ACPI table header to be
44 updated.
45 @param [in] AcpiTableInfo Pointer to the ACPI table info structure.
46 @param [in] Length Length of the ACPI table.
47
48 @retval EFI_SUCCESS The ACPI table is updated successfully.
49 @retval EFI_INVALID_PARAMETER A parameter is invalid.
50 @retval EFI_NOT_FOUND The required object information is not found.
51 @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
52 Manager is less than the Object size for the
53 requested object.
54 **/
55 EFI_STATUS
56 EFIAPI
57 AddAcpiHeader (
58 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
59 IN CONST ACPI_TABLE_GENERATOR * CONST Generator,
60 IN OUT EFI_ACPI_DESCRIPTION_HEADER * CONST AcpiHeader,
61 IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo,
62 IN CONST UINT32 Length
63 );
64
65 /**
66 Function prototype for testing if two arbitrary objects are equal.
67
68 @param [in] Object1 Pointer to the first object to compare.
69 @param [in] Object2 Pointer to the second object to compare.
70 @param [in] Index1 Index of Object1. This value is optional and
71 can be ignored by the specified implementation.
72 @param [in] Index2 Index of Object2. This value is optional and
73 can be ignored by the specified implementation.
74
75 @retval TRUE Object1 and Object2 are equal.
76 @retval FALSE Object1 and Object2 are NOT equal.
77 **/
78 typedef
79 BOOLEAN
80 (EFIAPI *PFN_IS_EQUAL)(
81 IN CONST VOID * Object1,
82 IN CONST VOID * Object2,
83 IN UINTN Index1 OPTIONAL,
84 IN UINTN Index2 OPTIONAL
85 );
86
87 /**
88 Test and report if a duplicate entry exists in the given array of comparable
89 elements.
90
91 @param [in] Array Array of elements to test for duplicates.
92 @param [in] Count Number of elements in Array.
93 @param [in] ElementSize Size of an element in bytes
94 @param [in] EqualTestFunction The function to call to check if any two
95 elements are equal.
96
97 @retval TRUE A duplicate element was found or one of
98 the input arguments is invalid.
99 @retval FALSE Every element in Array is unique.
100 **/
101 BOOLEAN
102 EFIAPI
103 FindDuplicateValue (
104 IN CONST VOID * Array,
105 IN CONST UINTN Count,
106 IN CONST UINTN ElementSize,
107 IN PFN_IS_EQUAL EqualTestFunction
108 );
109
110 #endif // TABLE_HELPER_LIB_H_