| 3 | #include <Library/MemLogLib.h> |
| 4 | |
| 5 | EFI_STATUS |
| 6 | EFIAPI |
| 7 | BdmesgMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) |
| 8 | { |
| 9 | static CHAR16 const NoMemLog[] = L"%EUnsuccessful getting memory log%N\n"; |
| 10 | static CHAR16 const Usage[] = L"%HUsage: bdmesg [-b]\n -b: paginate%N\n"; |
| 11 | CHAR8 const* log; |
| 12 | LIST_ENTRY* Package; |
| 13 | UINTN logLength, numPrinted; |
| 14 | EFI_STATUS Status; |
| 15 | BOOLEAN SkipLn; |
| 16 | |
| 17 | logLength = GetMemLogLen(); |
| 18 | log = GetMemLogBuffer(); |
| 19 | if (!log) { |
| 20 | ShellPrintEx(-1, -1, &NoMemLog[0]); |
| 21 | return EFI_NOT_FOUND; |
| 22 | } |
| 23 | Status = ShellCommandLineParseEx(&EmptyParamList[0], &Package, NULL, TRUE, FALSE); |
| 24 | if (EFI_ERROR(Status)) { |
| 25 | ShellPrintEx(-1, -1, &Usage[0]); |
| 26 | return EFI_INVALID_PARAMETER; |
| 27 | } |
| 28 | ShellCommandLineFreeVarList(Package); |
| 29 | Status = EFI_SUCCESS; |
| 30 | SkipLn = TRUE; |
| 31 | while (logLength) { |
| 32 | numPrinted = Print(L"%.*a", logLength, log); |
| 33 | if (!numPrinted) { |
| 34 | SkipLn = FALSE; |
| 35 | Status = EFI_ABORTED; |
| 36 | break; |
| 37 | } |
| 38 | if (ShellGetExecutionBreakFlag()) { |
| 39 | Status = EFI_ABORTED; |
| 40 | break; |
| 41 | } |
| 42 | if (numPrinted >= logLength) |
| 43 | break; |
| 44 | logLength -= numPrinted; |
| 45 | log += numPrinted; |
| 46 | } |
| 47 | ShellSetPageBreakMode(FALSE); |
| 48 | if (SkipLn) |
| 49 | Print(L"\n"); |
| 50 | return Status; |
| 51 | } |
nothing calls this directly
no test coverage detected