• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2 
3 Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution.  The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8 
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 
12 
13 **/
14 
15 #ifndef _EFI_EDB_SUPPORT_H_
16 #define _EFI_EDB_SUPPORT_H_
17 
18 #include <Uefi.h>
19 
20 #define EFI_DEBUG_PROMPT_STRING      L"EDB > "
21 #define EFI_DEBUG_PROMPT_COLUMN      5
22 #define EFI_DEBUG_INPUS_BUFFER_SIZE  64
23 
24 #define EFI_DEBUGGER_LINE_NUMBER_IN_PAGE  0x10
25 
26 #define EFI_DEBUG_MAX_PRINT_BUFFER   (80 * 4)
27 
28 /**
29 
30   Convert hex string to uint.
31 
32   @param  Str  -  The string
33 
34 **/
35 UINTN
36 EFIAPI
37 Xtoi (
38   CHAR16  *Str
39   );
40 
41 /**
42 
43   Convert hex string to uint.
44 
45   @param  Str  -  The string
46 
47 **/
48 UINT64
49 EFIAPI
50 LXtoi (
51   CHAR16  *Str
52   );
53 
54 /**
55 
56   Convert hex string to uint.
57 
58   @param Str  -  The string
59 
60 **/
61 UINTN
62 EFIAPI
63 Atoi (
64   CHAR16  *Str
65   );
66 
67 /**
68 
69   Convert hex string to uint.
70 
71   @param  Str  -  The string
72 
73 **/
74 UINTN
75 EFIAPI
76 AsciiXtoi (
77   CHAR8  *Str
78   );
79 
80 /**
81 
82   Convert hex string to uint.
83 
84   @param Str  -  The string
85 
86 **/
87 UINTN
88 EFIAPI
89 AsciiAtoi (
90   CHAR8  *Str
91   );
92 
93 /**
94   Compare the Unicode and Ascii string pointed by String to the string pointed by String2.
95 
96   @param String - Unicode String to process
97 
98   @param String2 - Ascii string to process
99 
100   @return Return a positive integer if String is lexicall greater than String2; Zero if
101   the two strings are identical; and a negative interger if String is lexically
102   less than String2.
103 
104 **/
105 INTN
106 EFIAPI
107 StrCmpUnicodeAndAscii (
108   IN CHAR16   *String,
109   IN CHAR8    *String2
110   );
111 
112 /**
113 
114   Compare the Unicode string pointed by String to the string pointed by String2.
115 
116   @param  String - Unicode String to process
117   @param  String2 - Unicode string to process
118 
119   @return Return a positive integer if String is lexically greater than String2; Zero if
120   the two strings are identical; and a negative integer if String is lexically
121   less than String2.
122 
123 **/
124 INTN
125 EFIAPI
126 StriCmp (
127   IN CHAR16   *String,
128   IN CHAR16   *String2
129   );
130 
131 /**
132 
133   Compare the Unicode and Ascii string pointed by String to the string pointed by String2.
134 
135   @param  String - Unicode String to process
136   @param  String2 - Ascii string to process
137 
138   @return Return a positive integer if String is lexically greater than String2; Zero if
139   the two strings are identical; and a negative integer if String is lexically
140   less than String2.
141 
142 **/
143 INTN
144 EFIAPI
145 StriCmpUnicodeAndAscii (
146   IN CHAR16   *String,
147   IN CHAR8    *String2
148   );
149 
150 /**
151 
152   Verify if the string is end with the sub string.
153 
154   @param  Str - The string where to search the sub string
155   @param  SubStr - The substring.
156 
157 **/
158 BOOLEAN
159 EFIAPI
160 StrEndWith (
161   IN CHAR16                       *Str,
162   IN CHAR16                       *SubStr
163   );
164 
165 /**
166   Duplicate a string.
167 
168   @param  Src  The string to be duplicated.
169 
170 **/
171 CHAR16 *
172 EFIAPI
173 StrDuplicate (
174   IN CHAR16   *Src
175   );
176 
177 /**
178 
179   Find the next token after one or more specified characters.
180 
181   @param  String    Point to the string where to find the substring.
182   @param  CharSet   Point to the string to be found.
183 
184 **/
185 CHAR16 *
186 EFIAPI
187 StrGetNewTokenLine (
188   IN CHAR16                       *String,
189   IN CHAR16                       *CharSet
190   );
191 
192 /**
193 
194   Find the next token after one or more specified characters.
195 
196   @param  CharSet   Point to the string to be found.
197 
198 **/
199 CHAR16 *
200 EFIAPI
201 StrGetNextTokenLine (
202   IN CHAR16                       *CharSet
203   );
204 
205 /**
206 
207   Find the next token after one specificed characters.
208 
209   @param  String    Point to the string where to find the substring.
210   @param  CharSet   Point to the string to be found.
211 
212 **/
213 CHAR16 *
214 EFIAPI
215 StrGetNewTokenField (
216   IN CHAR16                       *String,
217   IN CHAR16                       *CharSet
218   );
219 
220 /**
221 
222   Find the next token after one specificed characters.
223 
224   @param  CharSet   Point to the string to be found.
225 
226 **/
227 CHAR16 *
228 EFIAPI
229 StrGetNextTokenField (
230   IN CHAR16                       *CharSet
231   );
232 
233 /**
234 
235   Patch a character to the end of a string.
236 
237   @param  Buffer   The string to be patched.
238   @param  Patch    The patch character.
239 
240 **/
241 VOID
242 EFIAPI
243 PatchForStrTokenAfter (
244   IN CHAR16    *Buffer,
245   IN CHAR16    Patch
246   );
247 
248 /**
249   Patch a character at the beginning of a string.
250 
251   @param  Buffer   The string to be patched.
252   @param  Patch    The patch character.
253 
254 **/
255 VOID
256 EFIAPI
257 PatchForStrTokenBefore (
258   IN CHAR16    *Buffer,
259   IN CHAR16    Patch
260   );
261 
262 /**
263 
264   Find the next token after one or more specified characters.
265 
266   @param  String    Point to the string where to find the substring.
267   @param  CharSet   Point to the string to be found.
268 
269 **/
270 CHAR8 *
271 EFIAPI
272 AsciiStrGetNewTokenLine (
273   IN CHAR8                       *String,
274   IN CHAR8                       *CharSet
275   );
276 
277 /**
278 
279   Find the next token after one or more specified characters.
280 
281   @param  CharSet   Point to the string to be found.
282 
283 **/
284 CHAR8 *
285 EFIAPI
286 AsciiStrGetNextTokenLine (
287   IN CHAR8                       *CharSet
288   );
289 
290 /**
291 
292   Find the next token after one specificed characters.
293 
294   @param  String    Point to the string where to find the substring.
295   @param  CharSet   Point to the string to be found.
296 
297 **/
298 CHAR8 *
299 EFIAPI
300 AsciiStrGetNewTokenField (
301   IN CHAR8                       *String,
302   IN CHAR8                       *CharSet
303   );
304 
305 /**
306 
307   Find the next token after one specificed characters.
308 
309   @param  CharSet   Point to the string to be found.
310 
311 **/
312 CHAR8 *
313 EFIAPI
314 AsciiStrGetNextTokenField (
315   IN CHAR8                       *CharSet
316   );
317 
318 /**
319 
320   Patch a character to the end of a string.
321 
322   @param  Buffer   The string to be patched.
323   @param  Patch    The patch character.
324 
325 **/
326 VOID
327 EFIAPI
328 PatchForAsciiStrTokenAfter (
329   IN CHAR8    *Buffer,
330   IN CHAR8    Patch
331   );
332 
333 /**
334   Patch a character at the beginning of a string.
335 
336   @param  Buffer   The string to be patched.
337   @param  Patch    The patch character.
338 
339 **/
340 VOID
341 EFIAPI
342 PatchForAsciiStrTokenBefore (
343   IN CHAR8    *Buffer,
344   IN CHAR8    Patch
345   );
346 
347 /**
348 
349   Shell Library.
350   Get user input.
351 
352   @param  Prompt    The prompt string.
353   @param  InStr     Point to the input string.
354   @param  StrLen    The max length of string user can input.
355 
356 **/
357 VOID
358 EFIAPI
359 Input (
360   IN CHAR16    *Prompt OPTIONAL,
361   OUT CHAR16   *InStr,
362   IN UINTN     StrLen
363   );
364 
365 /**
366 
367   SetPageBreak.
368 
369 **/
370 BOOLEAN
371 EFIAPI
372 SetPageBreak (
373   VOID
374   );
375 
376 /**
377   Print a Unicode string to the output device.
378 
379   @param  Format    A Null-terminated Unicode format string.
380   @param  ...       The variable argument list that contains pointers to Null-
381                     terminated Unicode strings to be printed
382 
383 **/
384 UINTN
385 EFIAPI
386 EDBPrint (
387   IN CONST CHAR16  *Format,
388   ...
389   );
390 
391 /**
392   Print a Unicode string to the output buffer.
393 
394   @param  Buffer          A pointer to the output buffer for the produced Null-terminated
395                           Unicode string.
396   @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.
397   @param  Format          A Null-terminated Unicode format string.
398   @param  ...             The variable argument list that contains pointers to Null-
399                           terminated Unicode strings to be printed
400 
401 **/
402 UINTN
403 EFIAPI
404 EDBSPrint (
405   OUT CHAR16        *Buffer,
406   IN  INTN          BufferSize,
407   IN  CONST CHAR16  *Format,
408   ...
409   );
410 
411 /**
412   Print a Unicode string to the output buffer with specified offset..
413 
414   @param  Buffer          A pointer to the output buffer for the produced Null-terminated
415                           Unicode string.
416   @param  BufferSize      The size, in bytes, of the output buffer specified by StartOfBuffer.
417   @param  Offset          The offset of the buffer.
418   @param  Format          A Null-terminated Unicode format string.
419   @param  ...             The variable argument list that contains pointers to Null-
420                           terminated Unicode strings to be printed
421 
422 **/
423 UINTN
424 EFIAPI
425 EDBSPrintWithOffset (
426   OUT CHAR16        *Buffer,
427   IN  INTN          BufferSize,
428   IN  UINTN         Offset,
429   IN  CONST CHAR16  *Format,
430   ...
431   );
432 
433 /**
434 
435   Read a file.
436   If ScanFs is FLASE, it will use DebuggerPrivate->Vol as default Fs.
437   If ScanFs is TRUE, it will scan all FS and check the file.
438   If there is only one file match the name, it will be read.
439   If there is more than one file match the name, it will return Error.
440 
441   @param  DebuggerPrivate - EBC Debugger private data structure
442   @param  FileName        - The file to be read.
443   @param  BufferSize      - The file buffer size
444   @param  Buffer          - The file buffer
445   @param  ScanFs          - Need Scan all FS
446 
447   @retval EFI_SUCCESS    - read file successfully
448   @retval EFI_NOT_FOUND  - file not found
449   @retval EFI_NO_MAPPING - there is duplicated files found
450 
451 **/
452 EFI_STATUS
453 EFIAPI
454 ReadFileToBuffer (
455   IN  EFI_DEBUGGER_PRIVATE_DATA   *DebuggerPrivate,
456   IN  CHAR16                      *FileName,
457   OUT UINTN                       *BufferSize,
458   OUT VOID                        **Buffer,
459   IN  BOOLEAN                     ScanFs
460   );
461 
462 /**
463 
464   Get file name under this dir with index
465 
466   @param  DebuggerPrivate - EBC Debugger private data structure
467   @param  DirName         - The dir to be read.
468   @param  FileName        - The file name pattern under this dir
469   @param  Index           - The file index under this dir
470 
471   @return File Name which match the pattern and index.
472 
473 **/
474 CHAR16 *
475 EFIAPI
476 GetFileNameUnderDir (
477   IN  EFI_DEBUGGER_PRIVATE_DATA   *DebuggerPrivate,
478   IN  CHAR16                      *DirName,
479   IN  CHAR16                      *FileName,
480   IN OUT UINTN                    *Index
481   );
482 
483 #endif
484