BaseTools: Add PcdValueCommon logic into C source CommonLib
[mirror_edk2.git] / BaseTools / Source / C / Common / PcdValueCommon.h
1 /** @file
2 Header file for PcdValue structure definition.
3
4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
5 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 #ifndef _PCD_VALUE_COMMON_H
16 #define _PCD_VALUE_COMMON_H
17
18 #include <Common/UefiBaseTypes.h>
19 #include <Common/UefiInternalFormRepresentation.h>
20
21 #define __FIELD_SIZE(TYPE, Field) (sizeof((TYPE *)0)->Field)
22 #define __ARRAY_ELEMENT_SIZE(TYPE, Field) (sizeof((TYPE *)0)->Field[0])
23 #define __OFFSET_OF(TYPE, Field) ((UINT32) &(((TYPE *)0)->Field))
24 #define __FLEXIBLE_SIZE(Size, TYPE, Field, MaxIndex) if (__FIELD_SIZE(TYPE, Field) == 0) Size = MAX((__OFFSET_OF(TYPE, Field) + __ARRAY_ELEMENT_SIZE(TYPE, Field) * (MaxIndex)), Size)
25
26 VOID
27 PcdEntryPoint (
28 VOID
29 )
30 /*++
31
32 Routine Description:
33
34 Main function updates PCD values. It is auto generated by Build
35
36 Arguments:
37
38 None
39
40 Returns:
41 None
42 --*/
43 ;
44
45 int
46 PcdValueMain (
47 int argc,
48 char *argv[]
49 )
50 /*++
51
52 Routine Description:
53
54 Main function updates PCD values.
55
56 Arguments:
57
58 argc Number of command line parameters.
59 argv Array of pointers to parameter strings.
60
61 Returns:
62 EXIT_SUCCESS
63 --*/
64 ;
65
66 VOID
67 __PcdSet (
68 CHAR8 *SkuName OPTIONAL,
69 CHAR8 *DefaultValueName OPTIONAL,
70 CHAR8 *TokenSpaceGuidName,
71 CHAR8 *TokenName,
72 UINT64 Value
73 )
74 /*++
75
76 Routine Description:
77
78 Get PCD value
79
80 Arguments:
81
82 SkuName SkuName String
83 DefaultValueName DefaultValueName String
84 TokenSpaceGuidName TokenSpaceGuidName String
85 TokenName TokenName String
86
87 Returns:
88
89 PCD value
90 --*/
91 ;
92
93 VOID
94 __PcdSet (
95 CHAR8 *SkuName OPTIONAL,
96 CHAR8 *DefaultValueName OPTIONAL,
97 CHAR8 *TokenSpaceGuidName,
98 CHAR8 *TokenName,
99 UINT64 Value
100 )
101 /*++
102
103 Routine Description:
104
105 Set PCD value
106
107 Arguments:
108
109 SkuName SkuName String
110 DefaultValueName DefaultValueName String
111 TokenSpaceGuidName TokenSpaceGuidName String
112 TokenName TokenName String
113 Value PCD value to be set
114
115 Returns:
116
117 None
118 --*/
119 ;
120
121 VOID *
122 __PcdGetPtr (
123 CHAR8 *SkuName OPTIONAL,
124 CHAR8 *DefaultValueName OPTIONAL,
125 CHAR8 *TokenSpaceGuidName,
126 CHAR8 *TokenName,
127 UINT32 *Size
128 )
129 /*++
130
131 Routine Description:
132
133 Get PCD value buffer
134
135 Arguments:
136
137 SkuName SkuName String
138 DefaultValueName DefaultValueName String
139 TokenSpaceGuidName TokenSpaceGuidName String
140 TokenName TokenName String
141 Size Size of PCD value buffer
142
143 Returns:
144
145 PCD value buffer
146 --*/
147 ;
148
149 VOID
150 __PcdSetPtr (
151 CHAR8 *SkuName OPTIONAL,
152 CHAR8 *DefaultValueName OPTIONAL,
153 CHAR8 *TokenSpaceGuidName,
154 CHAR8 *TokenName,
155 UINT32 Size,
156 UINT8 *Value
157 )
158 /*++
159
160 Routine Description:
161
162 Set PCD value buffer
163
164 Arguments:
165
166 SkuName SkuName String
167 DefaultValueName DefaultValueName String
168 TokenSpaceGuidName TokenSpaceGuidName String
169 TokenName TokenName String
170 Size Size of PCD value
171 Value Pointer to the updated PCD value buffer
172
173 Returns:
174
175 None
176 --*/
177 ;
178
179 #define PcdGet(A, B, C, D) __PcdGet(#A, #B, #C, #D)
180 #define PcdSet(A, B, C, D, Value) __PcdSet(#A, #B, #C, #D, Value)
181 #define PcdGetPtr(A, B, C, D, Size) __PcdGetPtr(#A, #B, #C, #D, Size)
182 #define PcdSetPtr(A, B, C, D, Size, Value) __PcdSetPtr(#A, #B, #C, #D, Size, Value)
183
184 #endif