]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Common/ParseInf.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / BaseTools / Source / C / Common / ParseInf.h
1 /** @file
2 Header file for helper functions useful for parsing INF files.
3
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef _EFI_PARSE_INF_H
10 #define _EFI_PARSE_INF_H
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <Common/UefiBaseTypes.h>
15 #include <MemoryFile.h>
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 //
21 // Functions declarations
22 //
23 CHAR8 *
24 ReadLine (
25 IN MEMORY_FILE *InputFile,
26 IN OUT CHAR8 *InputBuffer,
27 IN UINTN MaxLength
28 )
29 ;
30
31 /*++
32
33 Routine Description:
34
35 This function reads a line, stripping any comments.
36 The function reads a string from the input stream argument and stores it in
37 the input string. ReadLine reads characters from the current file position
38 to and including the first newline character, to the end of the stream, or
39 until the number of characters read is equal to MaxLength - 1, whichever
40 comes first. The newline character, if read, is replaced with a \0.
41
42 Arguments:
43
44 InputFile Memory file image.
45 InputBuffer Buffer to read into, must be MaxLength size.
46 MaxLength The maximum size of the input buffer.
47
48 Returns:
49
50 NULL if error or EOF
51 InputBuffer otherwise
52
53 --*/
54 BOOLEAN
55 FindSection (
56 IN MEMORY_FILE *InputFile,
57 IN CHAR8 *Section
58 )
59 ;
60
61 /*++
62
63 Routine Description:
64
65 This function parses a file from the beginning to find a section.
66 The section string may be anywhere within a line.
67
68 Arguments:
69
70 InputFile Memory file image.
71 Section Section to search for
72
73 Returns:
74
75 FALSE if error or EOF
76 TRUE if section found
77
78 --*/
79 EFI_STATUS
80 FindToken (
81 IN MEMORY_FILE *InputFile,
82 IN CHAR8 *Section,
83 IN CHAR8 *Token,
84 IN UINTN Instance,
85 OUT CHAR8 *Value
86 )
87 ;
88
89 /*++
90
91 Routine Description:
92
93 Finds a token value given the section and token to search for.
94
95 Arguments:
96
97 InputFile Memory file image.
98 Section The section to search for, a string within [].
99 Token The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file.
100 Instance The instance of the token to search for. Zero is the first instance.
101 Value The string that holds the value following the =. Must be MAX_LONG_FILE_PATH in size.
102
103 Returns:
104
105 EFI_SUCCESS Value found.
106 EFI_ABORTED Format error detected in INF file.
107 EFI_INVALID_PARAMETER Input argument was null.
108 EFI_LOAD_ERROR Error reading from the file.
109 EFI_NOT_FOUND Section/Token/Value not found.
110
111 --*/
112 EFI_STATUS
113 StringToGuid (
114 IN CHAR8 *AsciiGuidBuffer,
115 OUT EFI_GUID *GuidBuffer
116 )
117 ;
118
119 /*++
120
121 Routine Description:
122
123 Converts a string to an EFI_GUID. The string must be in the
124 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.
125
126 Arguments:
127
128 GuidBuffer - pointer to destination Guid
129 AsciiGuidBuffer - pointer to ascii string
130
131 Returns:
132
133 EFI_ABORTED Could not convert the string
134 EFI_SUCCESS The string was successfully converted
135
136 --*/
137 EFI_STATUS
138 AsciiStringToUint64 (
139 IN CONST CHAR8 *AsciiString,
140 IN BOOLEAN IsHex,
141 OUT UINT64 *ReturnValue
142 )
143 ;
144
145 /*++
146
147 Routine Description:
148
149 Converts a null terminated ascii string that represents a number into a
150 UINT64 value. A hex number may be preceded by a 0x, but may not be
151 succeeded by an h. A number without 0x or 0X is considered to be base 10
152 unless the IsHex input is true.
153
154 Arguments:
155
156 AsciiString The string to convert.
157 IsHex Force the string to be treated as a hex number.
158 ReturnValue The return value.
159
160 Returns:
161
162 EFI_SUCCESS Number successfully converted.
163 EFI_ABORTED Invalid character encountered.
164
165 --*/
166 CHAR8 *
167 ReadLineInStream (
168 IN FILE *InputFile,
169 IN OUT CHAR8 *InputBuffer
170 )
171 ;
172
173 /*++
174
175 Routine Description:
176
177 This function reads a line, stripping any comments.
178
179 Arguments:
180
181 InputFile Stream pointer.
182 InputBuffer Buffer to read into, must be MAX_LONG_FILE_PATH size.
183
184 Returns:
185
186 NULL if error or EOF
187 InputBuffer otherwise
188
189 --*/
190 BOOLEAN
191 FindSectionInStream (
192 IN FILE *InputFile,
193 IN CHAR8 *Section
194 )
195 ;
196
197 /*++
198
199 Routine Description:
200
201 This function parses a stream file from the beginning to find a section.
202 The section string may be anywhere within a line.
203
204 Arguments:
205
206 InputFile Stream pointer.
207 Section Section to search for
208
209 Returns:
210
211 FALSE if error or EOF
212 TRUE if section found
213
214 --*/
215
216 #ifdef __cplusplus
217 }
218 #endif
219
220 #endif