Function to perform the shell prompt looping. It will do a single prompt, dispatch the result, and then return. It is expected that the caller will call this function in a loop many times. @retval EFI_SUCCESS @retval RETURN_ABORTED **/
| 1342 | @retval RETURN_ABORTED |
| 1343 | **/ |
| 1344 | EFI_STATUS |
| 1345 | DoShellPrompt ( |
| 1346 | VOID |
| 1347 | ) |
| 1348 | { |
| 1349 | UINTN Column; |
| 1350 | UINTN Row; |
| 1351 | CHAR16 *CmdLine; |
| 1352 | CONST CHAR16 *CurDir; |
| 1353 | UINTN BufferSize; |
| 1354 | EFI_STATUS Status; |
| 1355 | LIST_ENTRY OldBufferList; |
| 1356 | |
| 1357 | CurDir = NULL; |
| 1358 | |
| 1359 | // |
| 1360 | // Get screen setting to decide size of the command line buffer |
| 1361 | // |
| 1362 | gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &Column, &Row); |
| 1363 | BufferSize = Column * Row * sizeof (CHAR16); |
| 1364 | CmdLine = AllocateZeroPool (BufferSize); |
| 1365 | if (CmdLine == NULL) { |
| 1366 | return EFI_OUT_OF_RESOURCES; |
| 1367 | } |
| 1368 | |
| 1369 | SaveBufferList(&OldBufferList); |
| 1370 | CurDir = ShellInfoObject.NewEfiShellProtocol->GetEnv(L"cwd"); |
| 1371 | |
| 1372 | // |
| 1373 | // Prompt for input |
| 1374 | // |
| 1375 | gST->ConOut->SetCursorPosition (gST->ConOut, 0, gST->ConOut->Mode->CursorRow); |
| 1376 | |
| 1377 | if (CurDir != NULL && StrLen(CurDir) > 1) { |
| 1378 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_CURDIR), ShellInfoObject.HiiHandle, CurDir); |
| 1379 | } else { |
| 1380 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_SHELL), ShellInfoObject.HiiHandle); |
| 1381 | } |
| 1382 | |
| 1383 | // |
| 1384 | // Read a line from the console |
| 1385 | // |
| 1386 | Status = ShellInfoObject.NewEfiShellProtocol->ReadFile(ShellInfoObject.NewShellParametersProtocol->StdIn, &BufferSize, CmdLine); |
| 1387 | |
| 1388 | // |
| 1389 | // Null terminate the string and parse it |
| 1390 | // |
| 1391 | if (!EFI_ERROR (Status)) { |
| 1392 | CmdLine[BufferSize / sizeof (CHAR16)] = CHAR_NULL; |
| 1393 | Status = RunCommand(CmdLine); |
| 1394 | } |
| 1395 | |
| 1396 | // |
| 1397 | // Done with this command |
| 1398 | // |
| 1399 | RestoreBufferList(&OldBufferList); |
| 1400 | FreePool (CmdLine); |
| 1401 | return Status; |
no test coverage detected