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