aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-02-04 16:36:49 +0100
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-02-05 20:20:01 +0100
commit915623c0d3f504dce8a2310c1ddf5dcc638e5d93 (patch)
treef0ec9918e5dfd181938ed5d9aae93ac0d035d0bb
parentb1193fa9576c988ebbe04334f10bf38279cc72ec (diff)
efi_loader: fix text output for Uart() DP nodes
The UEFI specification concerning Uart() device path nodes has been clarified: Parity and stop bits can either both use keywords or both use numbers but numbers and keywords should not be mixed. Let's go for keywords as this is what EDK II does. For illegal values fall back to numbers. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
-rw-r--r--lib/efi_loader/efi_device_path_to_text.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
index 97b3d3e815ea..4d73954ef89e 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -122,16 +122,26 @@ static char *dp_msging(char *s, struct efi_device_path *dp)
case DEVICE_PATH_SUB_TYPE_MSG_UART: {
struct efi_device_path_uart *uart =
(struct efi_device_path_uart *)dp;
- s += sprintf(s, "Uart(%lld,%d,%d,", uart->baud_rate,
- uart->data_bits, uart->parity);
- switch (uart->stop_bits) {
- case 2:
- s += sprintf(s, "1.5)");
- break;
- default:
+ const char parity_str[6] = {'D', 'N', 'E', 'O', 'M', 'S'};
+ const char *stop_bits_str[4] = { "D", "1", "1.5", "2" };
+
+ s += sprintf(s, "Uart(%lld,%d,", uart->baud_rate,
+ uart->data_bits);
+
+ /*
+ * Parity and stop bits can either both use keywords or both use
+ * numbers but numbers and keywords should not be mixed. Let's
+ * go for keywords as this is what EDK II does. For illegal
+ * values fall back to numbers.
+ */
+ if (uart->parity < 6)
+ s += sprintf(s, "%c,", parity_str[uart->parity]);
+ else
+ s += sprintf(s, "%d,", uart->parity);
+ if (uart->stop_bits < 4)
+ s += sprintf(s, "%s)", stop_bits_str[uart->stop_bits]);
+ else
s += sprintf(s, "%d)", uart->stop_bits);
- break;
- }
break;
}
case DEVICE_PATH_SUB_TYPE_MSG_USB: {