diff options
| author | Pierre Gondois <pierre.gondois@arm.com> | 2026-04-02 15:37:02 +0300 |
|---|---|---|
| committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2026-04-24 21:18:47 +0300 |
| commit | 65288416dfbeddc2ea54da26dfd1636a80f0260e (patch) | |
| tree | f8398c6faa49e43bfff8624e61af51b20e3284c2 /ShellPkg/Library/UefiShellDebug1CommandsLib | |
| parent | 5e8b0d6de5be64bf845aa0ae71f029e389f1065d (diff) | |
| download | edk2-65288416dfbeddc2ea54da26dfd1636a80f0260e.tar.xz | |
ShellPkg/SerMode: Add GetStopBits() function
Add a GetStopBits() utility function to convert
the StopBits to the EFI_STOP_BITS_TYPE type.
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Diffstat (limited to 'ShellPkg/Library/UefiShellDebug1CommandsLib')
| -rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c | 75 |
1 files changed, 51 insertions, 24 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c index 63d8024320..083803360c 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c @@ -89,7 +89,7 @@ DisplaySettings ( Parity = 'U';
}
- if (SerialIo->Mode->StopBits >= DefaultStopBits) {
+ if (SerialIo->Mode->StopBits <= TwoStopBits) {
StopBits = StopBitsName[SerialIo->Mode->StopBits];
} else {
StopBits = L"Unknown";
@@ -179,6 +179,51 @@ GetParityType ( }
/**
+ Get the Stop Bits.
+
+ @param[in] StopBitsInt Stop Bits integer.
+ @param[out] StopBitsType If success, contains the converted StopBits type.
+
+ @retval SHELL_INVALID_PARAMETER A parameter was invalid.
+ @retval SHELL_SUCCESS The operation was successful.
+**/
+STATIC
+EFI_STATUS
+GetStopBits (
+ IN UINTN StopBitsInt,
+ OUT EFI_STOP_BITS_TYPE *StopBitsType
+ )
+{
+ EFI_STATUS Status;
+ EFI_STOP_BITS_TYPE StopBits;
+
+ ASSERT (StopBitsType != NULL);
+ Status = EFI_SUCCESS;
+
+ switch (StopBitsInt) {
+ case 0:
+ StopBits = DefaultStopBits;
+ break;
+ case 1:
+ StopBits = OneStopBit;
+ break;
+ case 2:
+ StopBits = TwoStopBits;
+ break;
+ case 15:
+ StopBits = OneFiveStopBits;
+ break;
+ default:
+ StopBits = DefaultStopBits;
+ Status = EFI_INVALID_PARAMETER;
+ break;
+ }
+
+ *StopBitsType = StopBits;
+ return Status;
+}
+
+/**
Function for 'sermode' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@@ -201,7 +246,6 @@ ShellCommandRunSerMode ( UINTN HandleIdx;
UINTN BaudRate;
UINTN DataBits;
- UINTN Value;
EFI_SERIAL_IO_PROTOCOL *SerialIo;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
@@ -296,28 +340,11 @@ ShellCommandRunSerMode ( goto Done;
}
- Value = ShellStrToUintn (Temp);
- switch (Value) {
- case 0:
- StopBits = DefaultStopBits;
- break;
-
- case 1:
- StopBits = OneStopBit;
- break;
-
- case 2:
- StopBits = TwoStopBits;
- break;
-
- case 15:
- StopBits = OneFiveStopBits;
- break;
-
- default:
- ShellPrintHiiDefaultEx (STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
+ Status = GetStopBits (ShellStrToUintn (Temp), &StopBits);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiDefaultEx (STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"sermode", Temp);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ goto Done;
}
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiSerialIoProtocolGuid, NULL, &NoHandles, &Handles);
|
