* [PATCH 00/25] EFI improvements
@ 2021-12-13 21:08 Sascha Hauer
2021-12-13 21:08 ` [PATCH 01/25] efi-devicepath: Make efi_device_path argument const Sascha Hauer
` (25 more replies)
0 siblings, 26 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
This series contains several improvements for barebox running on EFI.
Most patches are around the efi-stdio driver in which handling of ansi
escape sequences is greatly improved. With this series efi-stdio is now
able to parse and handle the escape sequences barebox issues itself
properly.
The EFI SNP network driver suffered from packet loss on some machines
because other protocols were polling for packets as well. This is also
fixed with this series.
Sascha
Sascha Hauer (25):
efi-devicepath: Make efi_device_path argument const
efi: move device-path defines and types to header file
efi: Implement device_path_to_subtype()
efi: Do not register IPv[46] devices
console: Fix message colours
efi-stdio: remove unnecessary check
efi-stdio: rename to efi_process_escape
efi-stdio: return bytes actually consumed
efi-stdio: fix escape sequence end detection
efi-stdio: improve escape sequence parsing
efi-stdio: Fix out of bounds error in puts
efi-stdio: Fix tab printing
efi-stdio: Implement efi_console_putc() using efi_console_puts()
efi-stdio: Fix '\b' handling
efi-stdio: implement input buffering with a kfifo
efi-stdio: limit set_cursor to screen size boundaries
efi-stdio: implement getting the cursor position
efi-stdio: Implement setting cursor visibility
efi-stdio: Support different text modes
edit: improve screen size detection
edit: Improve behaviour on efi-stdio console
edit: send escape sequence only for smartscroll
net: efi-snp: Check for carrier before sending
efi: add efi_device hook to be called before an image is started
net: efi-snp: Open protocol exclusively
commands/edit.c | 107 ++++++++--
common/console_common.c | 12 +-
common/efi-devicepath.c | 405 ++-----------------------------------
common/efi/efi-image.c | 4 +
drivers/efi/efi-device.c | 42 +++-
drivers/net/efi-snp.c | 59 +++++-
drivers/serial/efi-stdio.c | 362 +++++++++++++++++++++------------
include/efi.h | 1 +
include/efi/device-path.h | 388 +++++++++++++++++++++++++++++++++++
include/efi/efi-device.h | 5 +
10 files changed, 840 insertions(+), 545 deletions(-)
create mode 100644 include/efi/device-path.h
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 01/25] efi-devicepath: Make efi_device_path argument const
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 02/25] efi: move device-path defines and types to header file Sascha Hauer
` (24 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
unpack_device_path() must not modify the efi_device_path * argument, so
make that sure by making it const.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/efi-devicepath.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/common/efi-devicepath.c b/common/efi-devicepath.c
index f17b9294cc..92c3ac8cee 100644
--- a/common/efi-devicepath.c
+++ b/common/efi-devicepath.c
@@ -468,9 +468,10 @@ device_path_from_handle(efi_handle_t Handle)
}
static struct efi_device_path *
-unpack_device_path(struct efi_device_path *dev_path)
+unpack_device_path(const struct efi_device_path *dev_path)
{
- struct efi_device_path *Src, *Dest, *new_path;
+ const struct efi_device_path *Src;
+ struct efi_device_path *Dest, *new_path;
unsigned long Size;
/* Walk device path and round sizes to valid boundaries */
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 02/25] efi: move device-path defines and types to header file
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
2021-12-13 21:08 ` [PATCH 01/25] efi-devicepath: Make efi_device_path argument const Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 03/25] efi: Implement device_path_to_subtype() Sascha Hauer
` (23 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/efi-devicepath.c | 385 +------------------------------------
include/efi/device-path.h | 388 ++++++++++++++++++++++++++++++++++++++
2 files changed, 389 insertions(+), 384 deletions(-)
create mode 100644 include/efi/device-path.h
diff --git a/common/efi-devicepath.c b/common/efi-devicepath.c
index 92c3ac8cee..3a3a8b9ebd 100644
--- a/common/efi-devicepath.c
+++ b/common/efi-devicepath.c
@@ -3,6 +3,7 @@
#include <malloc.h>
#include <string.h>
#include <wchar.h>
+#include <efi/device-path.h>
struct string {
char *str;
@@ -57,390 +58,6 @@ char *cprintf(struct string *str, const char *fmt, ...)
(a)->length = sizeof(struct efi_device_path); \
}
-/*
- * Hardware Device Path (UEFI 2.4 specification, version 2.4 § 9.3.2.)
- */
-
-#define HARDWARE_DEVICE_PATH 0x01
-
-#define HW_PCI_DP 0x01
-struct pci_device_path {
- struct efi_device_path header;
- u8 Function;
- u8 Device;
-};
-
-#define HW_PCCARD_DP 0x02
-struct pccard_device_path {
- struct efi_device_path header;
- u8 function_number;
-};
-
-#define HW_MEMMAP_DP 0x03
-struct memmap_device_path {
- struct efi_device_path header;
- u32 memory_type;
- efi_physical_addr_t starting_address;
- efi_physical_addr_t ending_address;
-};
-
-#define HW_VENDOR_DP 0x04
-struct vendor_device_path {
- struct efi_device_path header;
- efi_guid_t Guid;
-};
-
-struct unknown_device_vendor_device_path {
- struct vendor_device_path device_path;
- u8 legacy_drive_letter;
-};
-
-#define HW_CONTROLLER_DP 0x05
-struct controller_device_path {
- struct efi_device_path header;
- u32 Controller;
-};
-
-/*
- * ACPI Device Path (UEFI 2.4 specification, version 2.4 § 9.3.3 and 9.3.4.)
- */
-#define ACPI_DEVICE_PATH 0x02
-
-#define ACPI_DP 0x01
-struct acpi_hid_device_path {
- struct efi_device_path header;
- u32 HID;
- u32 UID;
-};
-
-#define EXPANDED_ACPI_DP 0x02
-struct expanded_acpi_hid_device_path {
- struct efi_device_path header;
- u32 HID;
- u32 UID;
- u32 CID;
- u8 hid_str[1];
-};
-
-#define ACPI_ADR_DP 3
-struct acpi_adr_device_path {
- struct efi_device_path header;
- u32 ADR;
-};
-
-/*
- * EISA ID Macro
- * EISA ID Definition 32-bits
- * bits[15:0] - three character compressed ASCII EISA ID.
- * bits[31:16] - binary number
- * Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z'
- */
-#define PNP_EISA_ID_CONST 0x41d0
-#define EISA_ID(_Name, _Num) ((u32) ((_Name) | (_Num) << 16))
-#define EISA_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
-
-#define PNP_EISA_ID_MASK 0xffff
-#define EISA_ID_TO_NUM(_Id) ((_Id) >> 16)
-
-/*
- * Messaging Device Path (UEFI 2.4 specification, version 2.4 § 9.3.5.)
- */
-#define MESSAGING_DEVICE_PATH 0x03
-
-#define MSG_ATAPI_DP 0x01
-struct atapi_device_path {
- struct efi_device_path header;
- u8 primary_secondary;
- u8 slave_master;
- u16 Lun;
-};
-
-#define MSG_SCSI_DP 0x02
-struct scsi_device_path {
- struct efi_device_path header;
- u16 Pun;
- u16 Lun;
-};
-
-#define MSG_FIBRECHANNEL_DP 0x03
-struct fibrechannel_device_path {
- struct efi_device_path header;
- u32 Reserved;
- u64 WWN;
- u64 Lun;
-};
-
-/**
- * Fibre Channel Ex sub_type.
- * UEFI 2.0 specification version 2.4 § 9.3.5.6.
- */
-#define MSG_FIBRECHANNELEX_DP 21
-struct fibrechannelex_device_path {
- struct efi_device_path header;
- u32 Reserved;
- u8 WWN[8]; /* World Wide Name */
- u8 Lun[8]; /* Logical unit, T-10 SCSI Architecture Model 4 specification */
-};
-
-#define MSG_1394_DP 0x04
-struct f1394_device_path {
- struct efi_device_path header;
- u32 Reserved;
- u64 Guid;
-};
-
-#define MSG_USB_DP 0x05
-struct usb_device_path {
- struct efi_device_path header;
- u8 Port;
- u8 Endpoint;
-};
-
-/**
- * SATA Device Path sub_type.
- * UEFI 2.0 specification version 2.4 § 9.3.5.6.
- */
-#define MSG_SATA_DP 18
-struct sata_device_path {
- struct efi_device_path header;
- u16 HBAPort_number;
- u16 port_multiplier_port_number;
- u16 Lun; /* Logical Unit Number */
-};
-
-/**
- * USB WWID Device Path sub_type.
- * UEFI 2.0 specification version 2.4 § 9.3.5.7.
- */
-#define MSG_USB_WWID_DP 16
-struct usb_wwid_device_path {
- struct efi_device_path header;
- u16 interface_number;
- u16 vendor_id;
- u16 product_id;
- s16 serial_number[1]; /* UTF-16 characters of the USB serial number */
-};
-
-/**
- * Device Logical Unit sub_type.
- * UEFI 2.0 specification version 2.4 § 9.3.5.8.
- */
-#define MSG_DEVICE_LOGICAL_UNIT_DP 17
-struct device_logical_unit_device_path {
- struct efi_device_path header;
- u8 Lun; /* Logical Unit Number */
-};
-
-#define MSG_USB_CLASS_DP 0x0_f
-struct usb_class_device_path {
- struct efi_device_path header;
- u16 vendor_id;
- u16 product_id;
- u8 device_class;
- u8 device_subclass;
- u8 device_protocol;
-};
-
-#define MSG_I2_o_DP 0x06
-struct i2_o_device_path {
- struct efi_device_path header;
- u32 Tid;
-};
-
-#define MSG_MAC_ADDR_DP 0x0b
-struct mac_addr_device_path {
- struct efi_device_path header;
- efi_mac_address mac_address;
- u8 if_type;
-};
-
-#define MSG_IPv4_DP 0x0c
-struct ipv4_device_path {
- struct efi_device_path header;
- efi_ipv4_address local_ip_address;
- efi_ipv4_address remote_ip_address;
- u16 local_port;
- u16 remote_port;
- u16 Protocol;
- bool static_ip_address;
- /* new from UEFI version 2, code must check length field in header */
- efi_ipv4_address gateway_ip_address;
- efi_ipv4_address subnet_mask;
-};
-
-#define MSG_IPv6_DP 0x0d
-struct ipv6_device_path {
- struct efi_device_path header;
- efi_ipv6_address local_ip_address;
- efi_ipv6_address remote_ip_address;
- u16 local_port;
- u16 remote_port;
- u16 Protocol;
- bool IPAddress_origin;
- /* new from UEFI version 2, code must check length field in header */
- u8 prefix_length;
- efi_ipv6_address gateway_ip_address;
-};
-
-/**
- * Device Logical Unit sub_type.
- * UEFI 2.0 specification version 2.4 § 9.3.5.8.
- */
-#define MSG_VLAN_DP 20
-struct vlan_device_path {
- struct efi_device_path header;
- u16 vlan_id;
-};
-
-#define MSG_INFINIBAND_DP 0x09
-struct infiniband_device_path {
- struct efi_device_path header;
- u32 resource_flags;
- efi_guid_t port_gid;
- u64 service_id;
- u64 target_port_id;
- u64 device_id;
-};
-
-#define MSG_UART_DP 0x0e
-struct uart_device_path {
- struct efi_device_path header;
- u32 Reserved;
- u64 baud_rate;
- u8 data_bits;
- u8 Parity;
- u8 stop_bits;
-};
-
-#define MSG_VENDOR_DP 0x0a
-/* Use VENDOR_DEVICE_PATH struct */
-
-#define DEVICE_PATH_MESSAGING_PC_ANSI \
- { 0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
-
-#define DEVICE_PATH_MESSAGING_VT_100 \
- { 0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
-
-#define DEVICE_PATH_MESSAGING_VT_100_PLUS \
- { 0x7baec70b , 0x57e0 , 0x4c76 , { 0x8e , 0x87 , 0x2f , 0x9e , 0x28 , 0x08 , 0x83 , 0x43 } }
-
-#define DEVICE_PATH_MESSAGING_VT_UTF8 \
- { 0xad15a0d6 , 0x8bec , 0x4acf , { 0xa0 , 0x73 , 0xd0 , 0x1d , 0xe7 , 0x7e , 0x2d , 0x88 } }
-
-#define EFI_PC_ANSI_GUID \
- { 0xe0c14753 , 0xf9be , 0x11d2 , 0x9a , 0x0c , 0x00 , 0x90 , 0x27 , 0x3f , 0xc1 , 0x4d }
-
-#define EFI_VT_100_GUID \
- { 0xdfa66065 , 0xb419 , 0x11d3 , 0x9a , 0x2d , 0x00 , 0x90 , 0x27 , 0x3f , 0xc1 , 0x4d }
-
-#define EFI_VT_100_PLUS_GUID \
- { 0x7baec70b , 0x57e0 , 0x4c76 , 0x8e , 0x87 , 0x2f , 0x9e , 0x28 , 0x08 , 0x83 , 0x43 }
-
-#define EFI_VT_UTF8_GUID \
- { 0xad15a0d6 , 0x8bec , 0x4acf , 0xa0 , 0x73 , 0xd0 , 0x1d , 0xe7 , 0x7e , 0x2d , 0x88 }
-
-/*
- * Media Device Path (UEFI 2.4 specification, version 2.4 § 9.3.6.)
- */
-#define MEDIA_DEVICE_PATH 0x04
-
-#define MEDIA_HARDDRIVE_DP 0x01
-struct harddrive_device_path {
- struct efi_device_path header;
- u32 partition_number;
- u64 partition_start;
- u64 partition_size;
- u8 signature[16];
- u8 mbr_type;
- u8 signature_type;
-};
-
-#define MBR_TYPE_PCAT 0x01
-#define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02
-
-#define SIGNATURE_TYPE_MBR 0x01
-#define SIGNATURE_TYPE_GUID 0x02
-
-#define MEDIA_CDROM_DP 0x02
-struct cdrom_device_path {
- struct efi_device_path header;
- u32 boot_entry;
- u64 partition_start;
- u64 partition_size;
-};
-
-#define MEDIA_VENDOR_DP 0x03
-/* Use VENDOR_DEVICE_PATH struct */
-
-#define MEDIA_FILEPATH_DP 0x04
-struct filepath_device_path {
- struct efi_device_path header;
- s16 path_name[1];
-};
-
-#define SIZE_OF_FILEPATH_DEVICE_PATH offsetof(FILEPATH_DEVICE_PATH,path_name)
-
-#define MEDIA_PROTOCOL_DP 0x05
-struct media_protocol_device_path {
- struct efi_device_path header;
- efi_guid_t Protocol;
-};
-
-/**
- * PIWG Firmware File sub_type.
- * UEFI 2.0 specification version 2.4 § 9.3.6.6.
- */
-#define MEDIA_PIWG_FW_FILE_DP 6
-struct media_fw_vol_filepath_device_path {
- struct efi_device_path header;
- efi_guid_t fv_file_name;
-};
-
-/**
- * PIWG Firmware Volume Device Path sub_type.
- * UEFI 2.0 specification version 2.4 § 9.3.6.7.
- */
-#define MEDIA_PIWG_FW_VOL_DP 7
-struct media_fw_vol_device_path {
- struct efi_device_path header;
- efi_guid_t fv_name;
-};
-
-/**
- * Media relative offset range device path.
- * UEFI 2.0 specification version 2.4 § 9.3.6.8.
- */
-#define MEDIA_RELATIVE_OFFSET_RANGE_DP 8
-struct media_relative_offset_range_device_path {
- struct efi_device_path header;
- u32 Reserved;
- u64 starting_offset;
- u64 ending_offset;
-};
-
-/*
- * BIOS Boot Specification Device Path (UEFI 2.4 specification, version 2.4 § 9.3.7.)
- */
-#define BBS_DEVICE_PATH 0x05
-
-#define BBS_BBS_DP 0x01
-struct bbs_bbs_device_path {
- struct efi_device_path header;
- u16 device_type;
- u16 status_flag;
- s8 String[1];
-};
-
-/* device_type definitions - from BBS specification */
-#define BBS_TYPE_FLOPPY 0x01
-#define BBS_TYPE_HARDDRIVE 0x02
-#define BBS_TYPE_CDROM 0x03
-#define BBS_TYPE_PCMCIA 0x04
-#define BBS_TYPE_USB 0x05
-#define BBS_TYPE_EMBEDDED_NETWORK 0x06
-#define BBS_TYPE_DEV 0x80
-#define BBS_TYPE_UNKNOWN 0x_fF
-
struct efi_device_path end_device_path = {
.type = END_DEVICE_PATH_TYPE,
.sub_type = END_ENTIRE_DEVICE_PATH_SUBTYPE,
diff --git a/include/efi/device-path.h b/include/efi/device-path.h
new file mode 100644
index 0000000000..f3af71465b
--- /dev/null
+++ b/include/efi/device-path.h
@@ -0,0 +1,388 @@
+#ifndef __EFI_DEVICE_PATH_H
+#define __EFI_DEVICE_PATH_H
+
+/*
+ * Hardware Device Path (UEFI 2.4 specification, version 2.4 § 9.3.2.)
+ */
+
+#define HARDWARE_DEVICE_PATH 0x01
+
+#define HW_PCI_DP 0x01
+struct pci_device_path {
+ struct efi_device_path header;
+ u8 Function;
+ u8 Device;
+};
+
+#define HW_PCCARD_DP 0x02
+struct pccard_device_path {
+ struct efi_device_path header;
+ u8 function_number;
+};
+
+#define HW_MEMMAP_DP 0x03
+struct memmap_device_path {
+ struct efi_device_path header;
+ u32 memory_type;
+ efi_physical_addr_t starting_address;
+ efi_physical_addr_t ending_address;
+};
+
+#define HW_VENDOR_DP 0x04
+struct vendor_device_path {
+ struct efi_device_path header;
+ efi_guid_t Guid;
+};
+
+struct unknown_device_vendor_device_path {
+ struct vendor_device_path device_path;
+ u8 legacy_drive_letter;
+};
+
+#define HW_CONTROLLER_DP 0x05
+struct controller_device_path {
+ struct efi_device_path header;
+ u32 Controller;
+};
+
+/*
+ * ACPI Device Path (UEFI 2.4 specification, version 2.4 § 9.3.3 and 9.3.4.)
+ */
+#define ACPI_DEVICE_PATH 0x02
+
+#define ACPI_DP 0x01
+struct acpi_hid_device_path {
+ struct efi_device_path header;
+ u32 HID;
+ u32 UID;
+};
+
+#define EXPANDED_ACPI_DP 0x02
+struct expanded_acpi_hid_device_path {
+ struct efi_device_path header;
+ u32 HID;
+ u32 UID;
+ u32 CID;
+ u8 hid_str[1];
+};
+
+#define ACPI_ADR_DP 3
+struct acpi_adr_device_path {
+ struct efi_device_path header;
+ u32 ADR;
+};
+
+/*
+ * EISA ID Macro
+ * EISA ID Definition 32-bits
+ * bits[15:0] - three character compressed ASCII EISA ID.
+ * bits[31:16] - binary number
+ * Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z'
+ */
+#define PNP_EISA_ID_CONST 0x41d0
+#define EISA_ID(_Name, _Num) ((u32) ((_Name) | (_Num) << 16))
+#define EISA_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
+
+#define PNP_EISA_ID_MASK 0xffff
+#define EISA_ID_TO_NUM(_Id) ((_Id) >> 16)
+
+/*
+ * Messaging Device Path (UEFI 2.4 specification, version 2.4 § 9.3.5.)
+ */
+#define MESSAGING_DEVICE_PATH 0x03
+
+#define MSG_ATAPI_DP 0x01
+struct atapi_device_path {
+ struct efi_device_path header;
+ u8 primary_secondary;
+ u8 slave_master;
+ u16 Lun;
+};
+
+#define MSG_SCSI_DP 0x02
+struct scsi_device_path {
+ struct efi_device_path header;
+ u16 Pun;
+ u16 Lun;
+};
+
+#define MSG_FIBRECHANNEL_DP 0x03
+struct fibrechannel_device_path {
+ struct efi_device_path header;
+ u32 Reserved;
+ u64 WWN;
+ u64 Lun;
+};
+
+/**
+ * Fibre Channel Ex sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.5.6.
+ */
+#define MSG_FIBRECHANNELEX_DP 21
+struct fibrechannelex_device_path {
+ struct efi_device_path header;
+ u32 Reserved;
+ u8 WWN[8]; /* World Wide Name */
+ u8 Lun[8]; /* Logical unit, T-10 SCSI Architecture Model 4 specification */
+};
+
+#define MSG_1394_DP 0x04
+struct f1394_device_path {
+ struct efi_device_path header;
+ u32 Reserved;
+ u64 Guid;
+};
+
+#define MSG_USB_DP 0x05
+struct usb_device_path {
+ struct efi_device_path header;
+ u8 Port;
+ u8 Endpoint;
+};
+
+/**
+ * SATA Device Path sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.5.6.
+ */
+#define MSG_SATA_DP 18
+struct sata_device_path {
+ struct efi_device_path header;
+ u16 HBAPort_number;
+ u16 port_multiplier_port_number;
+ u16 Lun; /* Logical Unit Number */
+};
+
+/**
+ * USB WWID Device Path sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.5.7.
+ */
+#define MSG_USB_WWID_DP 16
+struct usb_wwid_device_path {
+ struct efi_device_path header;
+ u16 interface_number;
+ u16 vendor_id;
+ u16 product_id;
+ s16 serial_number[1]; /* UTF-16 characters of the USB serial number */
+};
+
+/**
+ * Device Logical Unit sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.5.8.
+ */
+#define MSG_DEVICE_LOGICAL_UNIT_DP 17
+struct device_logical_unit_device_path {
+ struct efi_device_path header;
+ u8 Lun; /* Logical Unit Number */
+};
+
+#define MSG_USB_CLASS_DP 0x0_f
+struct usb_class_device_path {
+ struct efi_device_path header;
+ u16 vendor_id;
+ u16 product_id;
+ u8 device_class;
+ u8 device_subclass;
+ u8 device_protocol;
+};
+
+#define MSG_I2_o_DP 0x06
+struct i2_o_device_path {
+ struct efi_device_path header;
+ u32 Tid;
+};
+
+#define MSG_MAC_ADDR_DP 0x0b
+struct mac_addr_device_path {
+ struct efi_device_path header;
+ efi_mac_address mac_address;
+ u8 if_type;
+};
+
+#define MSG_IPv4_DP 0x0c
+struct ipv4_device_path {
+ struct efi_device_path header;
+ efi_ipv4_address local_ip_address;
+ efi_ipv4_address remote_ip_address;
+ u16 local_port;
+ u16 remote_port;
+ u16 Protocol;
+ bool static_ip_address;
+ /* new from UEFI version 2, code must check length field in header */
+ efi_ipv4_address gateway_ip_address;
+ efi_ipv4_address subnet_mask;
+};
+
+#define MSG_IPv6_DP 0x0d
+struct ipv6_device_path {
+ struct efi_device_path header;
+ efi_ipv6_address local_ip_address;
+ efi_ipv6_address remote_ip_address;
+ u16 local_port;
+ u16 remote_port;
+ u16 Protocol;
+ bool IPAddress_origin;
+ /* new from UEFI version 2, code must check length field in header */
+ u8 prefix_length;
+ efi_ipv6_address gateway_ip_address;
+};
+
+/**
+ * Device Logical Unit sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.5.8.
+ */
+#define MSG_VLAN_DP 20
+struct vlan_device_path {
+ struct efi_device_path header;
+ u16 vlan_id;
+};
+
+#define MSG_INFINIBAND_DP 0x09
+struct infiniband_device_path {
+ struct efi_device_path header;
+ u32 resource_flags;
+ efi_guid_t port_gid;
+ u64 service_id;
+ u64 target_port_id;
+ u64 device_id;
+};
+
+#define MSG_UART_DP 0x0e
+struct uart_device_path {
+ struct efi_device_path header;
+ u32 Reserved;
+ u64 baud_rate;
+ u8 data_bits;
+ u8 Parity;
+ u8 stop_bits;
+};
+
+#define MSG_VENDOR_DP 0x0a
+/* Use VENDOR_DEVICE_PATH struct */
+
+#define DEVICE_PATH_MESSAGING_PC_ANSI \
+ { 0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
+
+#define DEVICE_PATH_MESSAGING_VT_100 \
+ { 0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
+
+#define DEVICE_PATH_MESSAGING_VT_100_PLUS \
+ { 0x7baec70b , 0x57e0 , 0x4c76 , { 0x8e , 0x87 , 0x2f , 0x9e , 0x28 , 0x08 , 0x83 , 0x43 } }
+
+#define DEVICE_PATH_MESSAGING_VT_UTF8 \
+ { 0xad15a0d6 , 0x8bec , 0x4acf , { 0xa0 , 0x73 , 0xd0 , 0x1d , 0xe7 , 0x7e , 0x2d , 0x88 } }
+
+#define EFI_PC_ANSI_GUID \
+ { 0xe0c14753 , 0xf9be , 0x11d2 , 0x9a , 0x0c , 0x00 , 0x90 , 0x27 , 0x3f , 0xc1 , 0x4d }
+
+#define EFI_VT_100_GUID \
+ { 0xdfa66065 , 0xb419 , 0x11d3 , 0x9a , 0x2d , 0x00 , 0x90 , 0x27 , 0x3f , 0xc1 , 0x4d }
+
+#define EFI_VT_100_PLUS_GUID \
+ { 0x7baec70b , 0x57e0 , 0x4c76 , 0x8e , 0x87 , 0x2f , 0x9e , 0x28 , 0x08 , 0x83 , 0x43 }
+
+#define EFI_VT_UTF8_GUID \
+ { 0xad15a0d6 , 0x8bec , 0x4acf , 0xa0 , 0x73 , 0xd0 , 0x1d , 0xe7 , 0x7e , 0x2d , 0x88 }
+
+/*
+ * Media Device Path (UEFI 2.4 specification, version 2.4 § 9.3.6.)
+ */
+#define MEDIA_DEVICE_PATH 0x04
+
+#define MEDIA_HARDDRIVE_DP 0x01
+struct harddrive_device_path {
+ struct efi_device_path header;
+ u32 partition_number;
+ u64 partition_start;
+ u64 partition_size;
+ u8 signature[16];
+ u8 mbr_type;
+ u8 signature_type;
+};
+
+#define MBR_TYPE_PCAT 0x01
+#define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02
+
+#define SIGNATURE_TYPE_MBR 0x01
+#define SIGNATURE_TYPE_GUID 0x02
+
+#define MEDIA_CDROM_DP 0x02
+struct cdrom_device_path {
+ struct efi_device_path header;
+ u32 boot_entry;
+ u64 partition_start;
+ u64 partition_size;
+};
+
+#define MEDIA_VENDOR_DP 0x03
+/* Use VENDOR_DEVICE_PATH struct */
+
+#define MEDIA_FILEPATH_DP 0x04
+struct filepath_device_path {
+ struct efi_device_path header;
+ s16 path_name[1];
+};
+
+#define SIZE_OF_FILEPATH_DEVICE_PATH offsetof(FILEPATH_DEVICE_PATH,path_name)
+
+#define MEDIA_PROTOCOL_DP 0x05
+struct media_protocol_device_path {
+ struct efi_device_path header;
+ efi_guid_t Protocol;
+};
+
+/**
+ * PIWG Firmware File sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.6.6.
+ */
+#define MEDIA_PIWG_FW_FILE_DP 6
+struct media_fw_vol_filepath_device_path {
+ struct efi_device_path header;
+ efi_guid_t fv_file_name;
+};
+
+/**
+ * PIWG Firmware Volume Device Path sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.6.7.
+ */
+#define MEDIA_PIWG_FW_VOL_DP 7
+struct media_fw_vol_device_path {
+ struct efi_device_path header;
+ efi_guid_t fv_name;
+};
+
+/**
+ * Media relative offset range device path.
+ * UEFI 2.0 specification version 2.4 § 9.3.6.8.
+ */
+#define MEDIA_RELATIVE_OFFSET_RANGE_DP 8
+struct media_relative_offset_range_device_path {
+ struct efi_device_path header;
+ u32 Reserved;
+ u64 starting_offset;
+ u64 ending_offset;
+};
+
+/*
+ * BIOS Boot Specification Device Path (UEFI 2.4 specification, version 2.4 § 9.3.7.)
+ */
+#define BBS_DEVICE_PATH 0x05
+
+#define BBS_BBS_DP 0x01
+struct bbs_bbs_device_path {
+ struct efi_device_path header;
+ u16 device_type;
+ u16 status_flag;
+ s8 String[1];
+};
+
+/* device_type definitions - from BBS specification */
+#define BBS_TYPE_FLOPPY 0x01
+#define BBS_TYPE_HARDDRIVE 0x02
+#define BBS_TYPE_CDROM 0x03
+#define BBS_TYPE_PCMCIA 0x04
+#define BBS_TYPE_USB 0x05
+#define BBS_TYPE_EMBEDDED_NETWORK 0x06
+#define BBS_TYPE_DEV 0x80
+#define BBS_TYPE_UNKNOWN 0x_fF
+
+#endif /* __EFI_DEVICE_PATH_H */
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 03/25] efi: Implement device_path_to_subtype()
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
2021-12-13 21:08 ` [PATCH 01/25] efi-devicepath: Make efi_device_path argument const Sascha Hauer
2021-12-13 21:08 ` [PATCH 02/25] efi: move device-path defines and types to header file Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 04/25] efi: Do not register IPv[46] devices Sascha Hauer
` (22 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/efi-devicepath.c | 15 +++++++++++++++
include/efi.h | 1 +
2 files changed, 16 insertions(+)
diff --git a/common/efi-devicepath.c b/common/efi-devicepath.c
index 3a3a8b9ebd..11d865af41 100644
--- a/common/efi-devicepath.c
+++ b/common/efi-devicepath.c
@@ -782,6 +782,21 @@ u8 device_path_to_type(struct efi_device_path *dev_path)
return device_path_type(dev_path);
}
+u8 device_path_to_subtype(struct efi_device_path *dev_path)
+{
+ struct efi_device_path *dev_path_next;
+
+ dev_path = unpack_device_path(dev_path);
+ dev_path_next = next_device_path_node(dev_path);
+
+ while (!is_device_path_end(dev_path_next)) {
+ dev_path = dev_path_next;
+ dev_path_next = next_device_path_node(dev_path);
+ }
+
+ return dev_path->sub_type;
+}
+
char *device_path_to_partuuid(struct efi_device_path *dev_path)
{
struct efi_device_path *dev_path_node;
diff --git a/include/efi.h b/include/efi.h
index 439803c294..04dffaae5a 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -682,6 +682,7 @@ typedef union {
struct efi_device_path *device_path_from_handle(efi_handle_t Handle);
char *device_path_to_str(struct efi_device_path *dev_path);
u8 device_path_to_type(struct efi_device_path *dev_path);
+u8 device_path_to_subtype(struct efi_device_path *dev_path);
char *device_path_to_partuuid(struct efi_device_path *dev_path);
const char *efi_guid_string(efi_guid_t *g);
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 04/25] efi: Do not register IPv[46] devices
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (2 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 03/25] efi: Implement device_path_to_subtype() Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 05/25] console: Fix message colours Sascha Hauer
` (21 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
Some UEFI instances create IPv4 and IPv6 messaging devices as children
of the main MAC messaging device. Don't register these in
barebox as they would show up as duplicate ethernet devices.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/efi/efi-device.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/efi/efi-device.c b/drivers/efi/efi-device.c
index 25c8eeaf01..6c86a8ab1a 100644
--- a/drivers/efi/efi-device.c
+++ b/drivers/efi/efi-device.c
@@ -18,6 +18,7 @@
#include <efi.h>
#include <efi/efi.h>
#include <efi/efi-device.h>
+#include <efi/device-path.h>
#include <linux/err.h>
static int efi_locate_handle(enum efi_locate_search_type search_type,
@@ -180,13 +181,24 @@ static struct efi_device *efi_add_device(efi_handle_t *handle, efi_guid_t **guid
return efidev;
}
-
static int efi_register_device(struct efi_device *efidev)
{
char *dev_path_str;
struct efi_device *parent;
int ret;
+ /*
+ * Some UEFI instances create IPv4 and IPv6 messaging devices as children
+ * of the main MAC messaging device. Don't register these in barebox as
+ * they would show up as duplicate ethernet devices.
+ */
+ if (device_path_to_type(efidev->devpath) == MESSAGING_DEVICE_PATH) {
+ u8 subtype = device_path_to_subtype(efidev->devpath);
+
+ if (subtype == MSG_IPv4_DP || subtype == MSG_IPv6_DP)
+ return -EINVAL;
+ }
+
if (efi_find_device(efidev->handle))
return -EEXIST;
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 05/25] console: Fix message colours
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (3 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 04/25] efi: Do not register IPv[46] devices Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-16 12:21 ` Jules Maselbas
2021-12-13 21:08 ` [PATCH 06/25] efi-stdio: remove unnecessary check Sascha Hauer
` (20 subsequent siblings)
25 siblings, 1 reply; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
The correct code to change colours is "\033[1;31m", not "\033[31m". Fix
that.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/console_common.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/common/console_common.c b/common/console_common.c
index 91a81e50fa..7bef74c543 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -23,12 +23,12 @@
#ifndef CONFIG_CONSOLE_NONE
static const char *colored_log_level[] = {
- [MSG_EMERG] = "\033[31mEMERG:\033[0m ", /* red */
- [MSG_ALERT] = "\033[31mALERT:\033[0m ", /* red */
- [MSG_CRIT] = "\033[31mCRITICAL:\033[0m ", /* red */
- [MSG_ERR] = "\033[31mERROR:\033[0m ", /* red */
- [MSG_WARNING] = "\033[33mWARNING:\033[0m ", /* yellow */
- [MSG_NOTICE] = "\033[34mNOTICE:\033[0m ", /* blue */
+ [MSG_EMERG] = "\033[1;31mEMERG:\033[0m ", /* red */
+ [MSG_ALERT] = "\033[1;31mALERT:\033[0m ", /* red */
+ [MSG_CRIT] = "\033[1;31mCRITICAL:\033[0m ", /* red */
+ [MSG_ERR] = "\033[1;31mERROR:\033[0m ", /* red */
+ [MSG_WARNING] = "\033[1;33mWARNING:\033[0m ", /* yellow */
+ [MSG_NOTICE] = "\033[1;34mNOTICE:\033[0m ", /* blue */
};
int barebox_loglevel = CONFIG_DEFAULT_LOGLEVEL;
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 06/25] efi-stdio: remove unnecessary check
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (4 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 05/25] console: Fix message colours Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 07/25] efi-stdio: rename to efi_process_escape Sascha Hauer
` (19 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
the caller already makes sure that efi_process_key() is only called when
*inp has an escape character. No need to check that again.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index 7b943aaa3b..22e4e9635a 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -260,9 +260,6 @@ static int efi_process_key(struct efi_console_priv *priv, const char *inp)
c = *inp;
- if (c != 27)
- return 0;
-
inp++;
if (*inp == '[')
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 07/25] efi-stdio: rename to efi_process_escape
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (5 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 06/25] efi-stdio: remove unnecessary check Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 08/25] efi-stdio: return bytes actually consumed Sascha Hauer
` (18 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
efi_process_key() really parses an escape sequence, so rename the
function accordingly.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index 22e4e9635a..dec633a7d6 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -254,7 +254,7 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
return 8;
}
-static int efi_process_key(struct efi_console_priv *priv, const char *inp)
+static int efi_process_escape(struct efi_console_priv *priv, const char *inp)
{
char c;
@@ -280,7 +280,7 @@ static int efi_console_puts(struct console_device *cdev, const char *s,
priv->out->output_string(priv->out,
priv->efi_console_buffer);
n = 0;
- s += efi_process_key(priv, s);
+ s += efi_process_escape(priv, s);
continue;
}
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 08/25] efi-stdio: return bytes actually consumed
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (6 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 07/25] efi-stdio: rename to efi_process_escape Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 09/25] efi-stdio: fix escape sequence end detection Sascha Hauer
` (17 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
efi_process_square_bracket() returns the number of characters consumed
including the escape character which starts the escape sequence. That
escape character is not passed to efi_process_square_bracket(), so it
seems more consistent to return the number of characters without the
escape.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index dec633a7d6..0c804a5d97 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -195,27 +195,27 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
/* home */
case 'F':
/* end */
- return 3;
+ return 2;
case 'K':
clear_to_eol(priv);
- return 3;
+ return 2;
}
if (*inp == '2' && *(inp + 1) == 'J') {
priv->out->clear_screen(priv->out);
- return 4;
+ return 3;
}
if (*inp == '0' && *(inp + 1) == 'm') {
priv->out->set_attribute(priv->out,
EFI_TEXT_ATTR(EFI_WHITE, EFI_BLACK));
- return 4;
+ return 3;
}
if (*inp == '7' && *(inp + 1) == 'm') {
priv->out->set_attribute(priv->out,
EFI_TEXT_ATTR(EFI_BLACK, priv->current_color));
- return 4;
+ return 3;
}
if (*inp == '1' &&
@@ -239,7 +239,7 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
priv->out->set_attribute(priv->out,
EFI_TEXT_ATTR(color, EFI_BLACK));
- return 7;
+ return 6;
}
y = simple_strtoul(inp, &endp, 10);
@@ -247,11 +247,11 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
x = simple_strtoul(endp + 1, &endp, 10);
if (*endp == 'H') {
priv->out->set_cursor_position(priv->out, x - 1, y - 1);
- return endp - inp + 3;
+ return endp - inp + 2;
}
}
- return 8;
+ return 7;
}
static int efi_process_escape(struct efi_console_priv *priv, const char *inp)
@@ -263,7 +263,7 @@ static int efi_process_escape(struct efi_console_priv *priv, const char *inp)
inp++;
if (*inp == '[')
- return efi_process_square_bracket(priv, inp);
+ return efi_process_square_bracket(priv, inp) + 1;
return 1;
}
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 09/25] efi-stdio: fix escape sequence end detection
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (7 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 08/25] efi-stdio: return bytes actually consumed Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 10/25] efi-stdio: improve escape sequence parsing Sascha Hauer
` (16 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
So far we only correctly parse the escape sequence we know. Detect the
possible end characters of the escape sequence upfront so that we
at least consume the correct number of character, eventhough the escape
sequence might be unknown and ignored.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index 0c804a5d97..c00c05b843 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -179,10 +179,17 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
{
int x, y;
char *endp;
+ int retlen;
+
+ endp = strpbrk(inp, "ABCDEFGHJKmr");
+ if (!endp)
+ return 0;
+
+ retlen = endp - inp + 1;
inp++;
- switch (*inp) {
+ switch (*endp) {
case 'A':
/* Cursor up */
case 'B':
@@ -195,27 +202,27 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
/* home */
case 'F':
/* end */
- return 2;
+ return retlen;
case 'K':
clear_to_eol(priv);
- return 2;
+ return retlen;
}
if (*inp == '2' && *(inp + 1) == 'J') {
priv->out->clear_screen(priv->out);
- return 3;
+ return retlen;
}
if (*inp == '0' && *(inp + 1) == 'm') {
priv->out->set_attribute(priv->out,
EFI_TEXT_ATTR(EFI_WHITE, EFI_BLACK));
- return 3;
+ return retlen;
}
if (*inp == '7' && *(inp + 1) == 'm') {
priv->out->set_attribute(priv->out,
EFI_TEXT_ATTR(EFI_BLACK, priv->current_color));
- return 3;
+ return retlen;
}
if (*inp == '1' &&
@@ -239,7 +246,7 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
priv->out->set_attribute(priv->out,
EFI_TEXT_ATTR(color, EFI_BLACK));
- return 6;
+ return retlen;
}
y = simple_strtoul(inp, &endp, 10);
@@ -247,11 +254,11 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
x = simple_strtoul(endp + 1, &endp, 10);
if (*endp == 'H') {
priv->out->set_cursor_position(priv->out, x - 1, y - 1);
- return endp - inp + 2;
+ return retlen;
}
}
- return 7;
+ return retlen;
}
static int efi_process_escape(struct efi_console_priv *priv, const char *inp)
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 10/25] efi-stdio: improve escape sequence parsing
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (8 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 09/25] efi-stdio: fix escape sequence end detection Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 11/25] efi-stdio: Fix out of bounds error in puts Sascha Hauer
` (15 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
Instead of dispatching the escape sequences character by character,
parse the number arguments upfront and use them later. Also parse
background and foreground colours and also the inverse status
correctly.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 155 +++++++++++++++++++++----------------
1 file changed, 89 insertions(+), 66 deletions(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index c00c05b843..b3a49eeec8 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -68,7 +68,9 @@ struct efi_console_priv {
unsigned long columns, rows;
- int current_color;
+ int fg;
+ int bg;
+ bool inverse;
s16 *blank_line;
};
@@ -175,11 +177,45 @@ static void clear_to_eol(struct efi_console_priv *priv)
priv->out->output_string(priv->out, priv->blank_line + pos);
}
+static int ansi_to_efi_color(int ansi)
+{
+ switch (ansi) {
+ case 30:
+ return EFI_BLACK;
+ case 31:
+ return EFI_RED;
+ case 32:
+ return EFI_GREEN;
+ case 33:
+ return EFI_YELLOW;
+ case 34:
+ return EFI_BLUE;
+ case 35:
+ return EFI_MAGENTA;
+ case 36:
+ return EFI_CYAN;
+ case 37:
+ return EFI_WHITE;
+ case 39:
+ return EFI_LIGHTGRAY;
+ }
+
+ return -1;
+}
+
+static void set_fg_bg_colors(struct efi_console_priv *priv)
+{
+ int fg = priv->inverse ? priv->bg : priv->fg;
+ int bg = priv->inverse ? priv->fg : priv->bg;
+
+ priv->out->set_attribute(priv->out, EFI_TEXT_ATTR(fg , bg));
+}
+
static int efi_process_square_bracket(struct efi_console_priv *priv, const char *inp)
{
- int x, y;
char *endp;
int retlen;
+ int arg0 = -1, arg1 = -1, arg2 = -1;
endp = strpbrk(inp, "ABCDEFGHJKmr");
if (!endp)
@@ -189,73 +225,59 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
inp++;
- switch (*endp) {
- case 'A':
- /* Cursor up */
- case 'B':
- /* Cursor down */
- case 'C':
- /* Cursor right */
- case 'D':
- /* Cursor left */
- case 'H':
- /* home */
- case 'F':
- /* end */
- return retlen;
- case 'K':
- clear_to_eol(priv);
- return retlen;
- }
-
- if (*inp == '2' && *(inp + 1) == 'J') {
- priv->out->clear_screen(priv->out);
- return retlen;
- }
-
- if (*inp == '0' && *(inp + 1) == 'm') {
- priv->out->set_attribute(priv->out,
- EFI_TEXT_ATTR(EFI_WHITE, EFI_BLACK));
- return retlen;
- }
-
- if (*inp == '7' && *(inp + 1) == 'm') {
- priv->out->set_attribute(priv->out,
- EFI_TEXT_ATTR(EFI_BLACK, priv->current_color));
- return retlen;
- }
-
- if (*inp == '1' &&
- *(inp + 1) == ';' &&
- *(inp + 2) == '3' &&
- *(inp + 3) &&
- *(inp + 4) == 'm') {
- int color;
- switch (*(inp + 3)) {
- case '1': color = EFI_RED; break;
- case '4': color = EFI_BLUE; break;
- case '2': color = EFI_GREEN; break;
- case '6': color = EFI_CYAN; break;
- case '3': color = EFI_YELLOW; break;
- case '5': color = EFI_MAGENTA; break;
- case '7': color = EFI_WHITE; break;
- default: color = EFI_WHITE; break;
+ if (isdigit(*inp)) {
+ char *e;
+ arg0 = simple_strtoul(inp, &e, 10);
+ if (*e == ';') {
+ arg1 = simple_strtoul(e + 1, &e, 10);
+ if (*e == ';')
+ arg2 = simple_strtoul(e + 1, &e, 10);
}
-
- priv->current_color = color;
-
- priv->out->set_attribute(priv->out,
- EFI_TEXT_ATTR(color, EFI_BLACK));
- return retlen;
}
- y = simple_strtoul(inp, &endp, 10);
- if (*endp == ';') {
- x = simple_strtoul(endp + 1, &endp, 10);
- if (*endp == 'H') {
- priv->out->set_cursor_position(priv->out, x - 1, y - 1);
- return retlen;
+ switch (*endp) {
+ case 'K':
+ switch (arg0) {
+ case 0:
+ case -1:
+ clear_to_eol(priv);
+ break;
+ }
+ break;
+ case 'J':
+ switch (arg0) {
+ case 2:
+ priv->out->clear_screen(priv->out);
+ break;
+ }
+ break;
+ case 'H':
+ if (arg0 >= 0 && arg1 >= 0)
+ priv->out->set_cursor_position(priv->out, arg1 - 1, arg0 - 1);
+ break;
+ case 'm':
+ switch (arg0) {
+ case 0:
+ priv->inverse = false;
+ priv->fg = EFI_LIGHTGRAY;
+ priv->bg = EFI_BLACK;
+ set_fg_bg_colors(priv);
+ break;
+ case 7:
+ priv->inverse = true;
+ set_fg_bg_colors(priv);
+ break;
+ case 1:
+ priv->fg = ansi_to_efi_color(arg1);
+ if (priv->fg < 0)
+ priv->fg = EFI_LIGHTGRAY;
+ priv->bg = ansi_to_efi_color(arg2);
+ if (priv->bg < 0)
+ priv->bg = EFI_BLACK;
+ set_fg_bg_colors(priv);
+ break;
}
+ break;
}
return retlen;
@@ -388,7 +410,8 @@ static int efi_console_probe(struct device_d *dev)
dev_dbg(dev, "Using simple_text_input_ex_protocol\n");
}
- priv->current_color = EFI_WHITE;
+ priv->fg = EFI_LIGHTGRAY;
+ priv->bg = EFI_BLACK;
efi_set_mode(priv);
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 11/25] efi-stdio: Fix out of bounds error in puts
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (9 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 10/25] efi-stdio: improve escape sequence parsing Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 12/25] efi-stdio: Fix tab printing Sascha Hauer
` (14 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
In efi_console_puts we use 'nbytes' as counter to break out of iterating
over the input string. An escape sequence consumes more than 1 input
character, still nbytes is only decremented by one. This results in
iterating past the end of the input string once an escape sequence is
in the buffer.
This patch introduces efi_console_add_char() to write a character in the
buffer and efi_console_flush() to print out the current buffer. This
fixes the issue and also allows us to prevent writing past the end of
the internal output buffer.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 60 +++++++++++++++++++++++++-------------
1 file changed, 39 insertions(+), 21 deletions(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index b3a49eeec8..9cc2ca4196 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -64,7 +64,8 @@ struct efi_console_priv {
struct efi_simple_text_input_ex_protocol *inex;
struct console_device cdev;
int lastkey;
- u16 efi_console_buffer[CONFIG_CBSIZE];
+ u16 efi_console_buffer[CONFIG_CBSIZE + 1];
+ int pos;
unsigned long columns, rows;
@@ -297,34 +298,51 @@ static int efi_process_escape(struct efi_console_priv *priv, const char *inp)
return 1;
}
+static void efi_console_add_char(struct efi_console_priv *priv, int c)
+{
+ if (priv->pos >= CONFIG_CBSIZE)
+ return;
+
+ priv->efi_console_buffer[priv->pos] = c;
+ priv->pos++;
+}
+
+static void efi_console_flush(struct efi_console_priv *priv)
+{
+ priv->efi_console_buffer[priv->pos] = 0;
+
+ priv->out->output_string(priv->out, priv->efi_console_buffer);
+
+ priv->pos = 0;
+}
+
static int efi_console_puts(struct console_device *cdev, const char *s,
size_t nbytes)
{
struct efi_console_priv *priv = to_efi(cdev);
- int n = 0;
-
- while (nbytes--) {
- if (*s == 27) {
- priv->efi_console_buffer[n] = 0;
- priv->out->output_string(priv->out,
- priv->efi_console_buffer);
- n = 0;
- s += efi_process_escape(priv, s);
- continue;
- }
+ int pos = 0;
- if (*s == '\n')
- priv->efi_console_buffer[n++] = '\r';
- priv->efi_console_buffer[n] = *s;
- s++;
- n++;
+ while (pos < nbytes) {
+ switch (s[pos]) {
+ case 27:
+ efi_console_flush(priv);
+ pos += efi_process_escape(priv, s + pos);
+ break;
+ case '\n':
+ efi_console_add_char(priv, '\r');
+ efi_console_add_char(priv, '\n');
+ pos++;
+ break;
+ default:
+ efi_console_add_char(priv, s[pos]);
+ pos++;
+ break;
+ }
}
- priv->efi_console_buffer[n] = 0;
-
- priv->out->output_string(priv->out, priv->efi_console_buffer);
+ efi_console_flush(priv);
- return n;
+ return nbytes;
}
static int efi_console_tstc(struct console_device *cdev)
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 12/25] efi-stdio: Fix tab printing
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (10 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 11/25] efi-stdio: Fix out of bounds error in puts Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 13/25] efi-stdio: Implement efi_console_putc() using efi_console_puts() Sascha Hauer
` (13 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
Tabs are silently ignored by at least some UEFI instances. Replace them
with spaces in the output.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index 9cc2ca4196..d99eca9d5e 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -320,7 +320,7 @@ static int efi_console_puts(struct console_device *cdev, const char *s,
size_t nbytes)
{
struct efi_console_priv *priv = to_efi(cdev);
- int pos = 0;
+ int n, pos = 0;
while (pos < nbytes) {
switch (s[pos]) {
@@ -333,6 +333,13 @@ static int efi_console_puts(struct console_device *cdev, const char *s,
efi_console_add_char(priv, '\n');
pos++;
break;
+ case '\t':
+ efi_console_flush(priv);
+ n = 8 - priv->out->mode->cursor_column % 8;
+ while (n--)
+ efi_console_add_char(priv, ' ');
+ pos++;
+ break;
default:
efi_console_add_char(priv, s[pos]);
pos++;
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 13/25] efi-stdio: Implement efi_console_putc() using efi_console_puts()
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (11 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 12/25] efi-stdio: Fix tab printing Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-15 11:04 ` Ahmad Fatoum
2021-12-13 21:08 ` [PATCH 14/25] efi-stdio: Fix '\b' handling Sascha Hauer
` (12 subsequent siblings)
25 siblings, 1 reply; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
The current efi_console_putc() implementation bypasses the special
character handling. Fix that by using efi_console_puts() for the
implemenation of efi_console_putc().
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index d99eca9d5e..d512cc3e01 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -160,17 +160,6 @@ static int efi_read_key(struct efi_console_priv *priv, bool wait)
return xlate_keypress(&kd.key);
}
-static void efi_console_putc(struct console_device *cdev, char c)
-{
- uint16_t str[2] = {};
- struct efi_console_priv *priv = to_efi(cdev);
- struct efi_simple_text_output_protocol *con_out = priv->out;
-
- str[0] = c;
-
- con_out->output_string(con_out, str);
-}
-
static void clear_to_eol(struct efi_console_priv *priv)
{
int pos = priv->out->mode->cursor_column;
@@ -352,6 +341,11 @@ static int efi_console_puts(struct console_device *cdev, const char *s,
return nbytes;
}
+static void efi_console_putc(struct console_device *cdev, char c)
+{
+ efi_console_puts(cdev, &c, 1);
+}
+
static int efi_console_tstc(struct console_device *cdev)
{
struct efi_console_priv *priv = to_efi(cdev);
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 14/25] efi-stdio: Fix '\b' handling
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (12 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 13/25] efi-stdio: Implement efi_console_putc() using efi_console_puts() Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 15/25] efi-stdio: implement input buffering with a kfifo Sascha Hauer
` (11 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
In vt100 a '\b' moves the cursor left, but without deleting the
character under the cursor. In UEFI the character under the cursor is
removed instead. Catch '\b' and manually move the cursor left without
deleting the character.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index d512cc3e01..beef911a16 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -329,6 +329,13 @@ static int efi_console_puts(struct console_device *cdev, const char *s,
efi_console_add_char(priv, ' ');
pos++;
break;
+ case '\b':
+ n = priv->out->mode->cursor_column;
+ if (n > 0)
+ priv->out->set_cursor_position(priv->out,
+ n - 1, priv->out->mode->cursor_row);
+ pos++;
+ break;
default:
efi_console_add_char(priv, s[pos]);
pos++;
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 15/25] efi-stdio: implement input buffering with a kfifo
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (13 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 14/25] efi-stdio: Fix '\b' handling Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 16/25] efi-stdio: limit set_cursor to screen size boundaries Sascha Hauer
` (10 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
The efi-stdio tstc() implementation needs buffering an input character
in order to return that character later in getc(). To implement
retrieving the current cursor position later we'll have to buffer more
than only a single character, so re-implement input buffering with a
kfifo.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index beef911a16..dacdb74934 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -14,6 +14,7 @@
#include <readkey.h>
#include <linux/ctype.h>
#include <efi/efi.h>
+#include <kfifo.h>
#include <efi/efi-device.h>
#include "efi-stdio.h"
@@ -63,10 +64,11 @@ struct efi_console_priv {
struct efi_simple_input_interface *in;
struct efi_simple_text_input_ex_protocol *inex;
struct console_device cdev;
- int lastkey;
u16 efi_console_buffer[CONFIG_CBSIZE + 1];
int pos;
+ struct kfifo *inputbuffer;
+
unsigned long columns, rows;
int fg;
@@ -358,14 +360,14 @@ static int efi_console_tstc(struct console_device *cdev)
struct efi_console_priv *priv = to_efi(cdev);
int key;
- if (priv->lastkey > 0)
+ if (kfifo_len(priv->inputbuffer))
return 1;
key = efi_read_key(priv, 0);
if (key < 0)
return 0;
- priv->lastkey = key;
+ kfifo_putc(priv->inputbuffer, key);
return 1;
}
@@ -373,13 +375,10 @@ static int efi_console_tstc(struct console_device *cdev)
static int efi_console_getc(struct console_device *cdev)
{
struct efi_console_priv *priv = to_efi(cdev);
- int key;
+ unsigned char c;
- if (priv->lastkey > 0) {
- key = priv->lastkey;
- priv->lastkey = -1;
- return key;
- }
+ if (!kfifo_getc(priv->inputbuffer, &c))
+ return c;
return efi_read_key(priv, 1);
}
@@ -424,6 +423,10 @@ static int efi_console_probe(struct device_d *dev)
priv->out = efi_sys_table->con_out;
priv->in = efi_sys_table->con_in;
+ priv->inputbuffer = kfifo_alloc(128);
+ if (!priv->inputbuffer)
+ return -ENOMEM;
+
efiret = BS->open_protocol((void *)efi_sys_table->con_in_handle,
&inex_guid,
(void **)&inex,
@@ -454,8 +457,6 @@ static int efi_console_probe(struct device_d *dev)
cdev->putc = efi_console_putc;
cdev->puts = efi_console_puts;
- priv->lastkey = -1;
-
return console_register(cdev);
}
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 16/25] efi-stdio: limit set_cursor to screen size boundaries
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (14 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 15/25] efi-stdio: implement input buffering with a kfifo Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 17/25] efi-stdio: implement getting the cursor position Sascha Hauer
` (9 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
set_cursor_position() may only be called with values actually inside the
screen. Limit the values accordingly.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index dacdb74934..0ba8d3f6c0 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -244,8 +244,11 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
}
break;
case 'H':
- if (arg0 >= 0 && arg1 >= 0)
- priv->out->set_cursor_position(priv->out, arg1 - 1, arg0 - 1);
+ if (arg0 >= 0 && arg1 >= 0) {
+ int row = min_t(int, arg0, priv->rows);
+ int col = min_t(int, arg1, priv->columns);
+ priv->out->set_cursor_position(priv->out, col - 1, row - 1);
+ }
break;
case 'm':
switch (arg0) {
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 17/25] efi-stdio: implement getting the cursor position
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (15 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 16/25] efi-stdio: limit set_cursor to screen size boundaries Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 18/25] efi-stdio: Implement setting cursor visibility Sascha Hauer
` (8 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
the 'sedit' command uses "\e[6n" to retrieve the screen size. Implement
this in the efi-stdio driver to make this work.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index 0ba8d3f6c0..5364d02034 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -206,10 +206,11 @@ static void set_fg_bg_colors(struct efi_console_priv *priv)
static int efi_process_square_bracket(struct efi_console_priv *priv, const char *inp)
{
char *endp;
- int retlen;
+ int n, retlen;
int arg0 = -1, arg1 = -1, arg2 = -1;
+ char *buf;
- endp = strpbrk(inp, "ABCDEFGHJKmr");
+ endp = strpbrk(inp, "ABCDEFGHJKmrn");
if (!endp)
return 0;
@@ -273,6 +274,15 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
break;
}
break;
+ case 'n':
+ switch (arg0) {
+ case 6:
+ n = asprintf(&buf, "\033[%d;%dR", priv->out->mode->cursor_row + 1,
+ priv->out->mode->cursor_column + 1);
+ kfifo_put(priv->inputbuffer, buf, n);
+ free(buf);
+ break;
+ }
}
return retlen;
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 18/25] efi-stdio: Implement setting cursor visibility
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (16 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 17/25] efi-stdio: implement getting the cursor position Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:08 ` [PATCH 19/25] efi-stdio: Support different text modes Sascha Hauer
` (7 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
The sequence "\b[?25h" makes the cursor visible and "\b[?25l" makes it
invisible. Implement support for this sequence.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index 5364d02034..3f99ef5d97 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -210,7 +210,7 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
int arg0 = -1, arg1 = -1, arg2 = -1;
char *buf;
- endp = strpbrk(inp, "ABCDEFGHJKmrn");
+ endp = strpbrk(inp, "ABCDEFGHJKmrnhl");
if (!endp)
return 0;
@@ -226,6 +226,8 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
if (*e == ';')
arg2 = simple_strtoul(e + 1, &e, 10);
}
+ } else if (*inp == '?') {
+ arg0 = simple_strtoul(inp + 1, NULL, 10);
}
switch (*endp) {
@@ -283,6 +285,15 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
free(buf);
break;
}
+ break;
+ case 'h':
+ if (*inp == '?' && arg0 == 25)
+ priv->out->enable_cursor(priv->out, true);
+ break;
+ case 'l':
+ if (*inp == '?' && arg0 == 25)
+ priv->out->enable_cursor(priv->out, false);
+ break;
}
return retlen;
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 19/25] efi-stdio: Support different text modes
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (17 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 18/25] efi-stdio: Implement setting cursor visibility Sascha Hauer
@ 2021-12-13 21:08 ` Sascha Hauer
2021-12-13 21:09 ` [PATCH 20/25] edit: improve screen size detection Sascha Hauer
` (6 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:08 UTC (permalink / raw)
To: Barebox List
the EFI simple text output protocol supports different text modes. This
patch adds support for these modes using a device parameter attached to
the console device.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/efi-stdio.c | 64 ++++++++++++++++++++++++++------------
1 file changed, 44 insertions(+), 20 deletions(-)
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index 3f99ef5d97..7f348f82af 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -75,6 +75,11 @@ struct efi_console_priv {
int bg;
bool inverse;
s16 *blank_line;
+
+ struct param_d *param_mode;
+ const char **mode_names;
+ int *mode_num;
+ unsigned int var_mode;
};
static inline struct efi_console_priv *to_efi(struct console_device *cdev)
@@ -407,29 +412,45 @@ static int efi_console_getc(struct console_device *cdev)
return efi_read_key(priv, 1);
}
+static int efi_console_set_mode(struct param_d *param, void *p)
+{
+ struct efi_console_priv *priv = p;
+
+ priv->out->set_mode(priv->out, priv->mode_num[priv->var_mode]);
+
+ priv->out->query_mode(priv->out, priv->out->mode->mode,
+ &priv->columns, &priv->rows);
+ return 0;
+}
+
static void efi_set_mode(struct efi_console_priv *priv)
{
-#if 0
int i;
- unsigned long rows, columns, best = 0, mode = 0;
+ unsigned long rows, columns;
+ int n = 0;
efi_status_t efiret;
+ priv->mode_names = xzalloc(priv->out->mode->max_mode * sizeof(*priv->mode_names));
+ priv->mode_num = xzalloc(priv->out->mode->max_mode * sizeof(*priv->mode_num));
+
+ priv->out->query_mode(priv->out, priv->out->mode->mode, &priv->columns, &priv->rows);
+
for (i = 0; i < priv->out->mode->max_mode; i++) {
- priv->out->query_mode(priv->out, i, &columns, &rows);
- printf("%d: %ld %ld\n", i, columns, rows);
- if (rows * columns > best) {
- best = rows * columns;
- mode = i;
- }
+ efiret = priv->out->query_mode(priv->out, i, &columns, &rows);
+ if (EFI_ERROR(efiret))
+ continue;
+
+ if (columns == priv->columns && rows == priv->rows)
+ priv->var_mode = n;
+
+ priv->mode_names[n] = basprintf("%ldx%ld", columns, rows);
+ priv->mode_num[n] = i;
+ n++;
}
- /*
- * Setting the mode doesn't work as expected. set_mode succeeds, but
- * the graphics resolution is not changed.
- */
- priv->out->set_mode(priv->out, mode);
-#endif
- priv->out->query_mode(priv->out, priv->out->mode->mode, &priv->columns, &priv->rows);
+ priv->param_mode = dev_add_param_enum(&priv->cdev.class_dev, "mode",
+ efi_console_set_mode, NULL, &priv->var_mode,
+ priv->mode_names, n, priv);
}
static int efi_console_probe(struct device_d *dev)
@@ -439,8 +460,7 @@ static int efi_console_probe(struct device_d *dev)
struct console_device *cdev;
struct efi_console_priv *priv;
efi_status_t efiret;
-
- int i;
+ int i, ret;
priv = xzalloc(sizeof(*priv));
@@ -466,8 +486,6 @@ static int efi_console_probe(struct device_d *dev)
priv->fg = EFI_LIGHTGRAY;
priv->bg = EFI_BLACK;
- efi_set_mode(priv);
-
priv->out->enable_cursor(priv->out, 1);
priv->blank_line = xzalloc((priv->columns + 1) * sizeof(s16));
@@ -481,7 +499,13 @@ static int efi_console_probe(struct device_d *dev)
cdev->putc = efi_console_putc;
cdev->puts = efi_console_puts;
- return console_register(cdev);
+ ret = console_register(cdev);
+ if (ret)
+ return ret;
+
+ efi_set_mode(priv);
+
+ return 0;
}
static struct driver_d efi_console_driver = {
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 20/25] edit: improve screen size detection
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (18 preceding siblings ...)
2021-12-13 21:08 ` [PATCH 19/25] efi-stdio: Support different text modes Sascha Hauer
@ 2021-12-13 21:09 ` Sascha Hauer
2021-12-13 21:09 ` [PATCH 21/25] edit: Improve behaviour on efi-stdio console Sascha Hauer
` (5 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:09 UTC (permalink / raw)
To: Barebox List
When detecting the screen size iterate over all active consoles and
probe the screen size individually. The smallest sizes are then used
for the editor. This fixes the editor size when multiple consoles are
activated. Also not all consoles may support reading back the cursor
position, so do not wait forever for the answer, but use a timeout
instead.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/edit.c | 57 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 48 insertions(+), 9 deletions(-)
diff --git a/commands/edit.c b/commands/edit.c
index f1e4e4d5c2..30448cbc04 100644
--- a/commands/edit.c
+++ b/commands/edit.c
@@ -12,6 +12,7 @@
#include <errno.h>
#include <xfuncs.h>
#include <linux/stat.h>
+#include <console.h>
#define TABSPACE 8
@@ -347,19 +348,57 @@ static void merge_line(struct line *line)
static void getwinsize(void)
{
- int i = 0, r;
- char buf[100];
+ int n;
char *endp;
+ struct console_device *cdev;
+ const char esc[] = ESC "7" ESC "[r" ESC "[999;999H" ESC "[6n";
+ char buf[64];
- printf(ESC "7" ESC "[r" ESC "[999;999H" ESC "[6n");
+ screenwidth = screenheight = 256;
- while ((r = getchar()) != 'R') {
- buf[i] = r;
- i++;
- }
+ for_each_console(cdev) {
+ int width, height;
+ uint64_t start;
+
+ if (!(cdev->f_active & CONSOLE_STDIN))
+ continue;
+ if (!(cdev->f_active & CONSOLE_STDOUT))
+ continue;
+
+ memset(buf, 0, sizeof(buf));
+
+ cdev->puts(cdev, esc, sizeof(esc));
+
+ n = 0;
+
+ start = get_time_ns();
+
+ while (1) {
+ if (is_timeout(start, 100 * MSECOND))
+ break;
- screenheight = simple_strtoul(buf + 2, &endp, 10);
- screenwidth = simple_strtoul(endp + 1, NULL, 10);
+ if (!cdev->tstc(cdev))
+ continue;
+
+ buf[n] = cdev->getc(cdev);
+
+ if (buf[n] == 'R')
+ break;
+
+ n++;
+ }
+
+ if (buf[0] != 27)
+ continue;
+ if (buf[1] != '[')
+ continue;
+
+ height = simple_strtoul(buf + 2, &endp, 10);
+ width = simple_strtoul(endp + 1, NULL, 10);
+
+ screenwidth = min(screenwidth, width);
+ screenheight = min(screenheight, height);
+ }
pos(0, 0);
}
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 21/25] edit: Improve behaviour on efi-stdio console
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (19 preceding siblings ...)
2021-12-13 21:09 ` [PATCH 20/25] edit: improve screen size detection Sascha Hauer
@ 2021-12-13 21:09 ` Sascha Hauer
2021-12-16 12:41 ` Jules Maselbas
2021-12-13 21:09 ` [PATCH 22/25] edit: send escape sequence only for smartscroll Sascha Hauer
` (4 subsequent siblings)
25 siblings, 1 reply; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:09 UTC (permalink / raw)
To: Barebox List
Our console driver for the EFI simple text protocol does not support
the "\e[1S" escape sequence to scroll the window which means sedit
doesn't work properly. Disable smartscroll when the efi-stdio console
is active. While at it put the screen height reduction into the same
dynamic test.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/edit.c | 46 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 36 insertions(+), 10 deletions(-)
diff --git a/commands/edit.c b/commands/edit.c
index 30448cbc04..592cf4aa3d 100644
--- a/commands/edit.c
+++ b/commands/edit.c
@@ -522,6 +522,25 @@ static int read_modal_key(bool is_modal)
return -EAGAIN;
}
+static bool is_efi_console_active(void)
+{
+ struct console_device *cdev;
+
+ if (!IS_ENABLED(CONFIG_DRIVER_SERIAL_EFI_STDIO))
+ return false;
+
+ for_each_console(cdev) {
+ if (!(cdev->f_active & CONSOLE_STDIN))
+ continue;
+ if (!(cdev->f_active & CONSOLE_STDOUT))
+ continue;
+ if (!strcmp(dev_name(cdev->dev), "efi-stdio"))
+ return true;
+ }
+
+ return false;
+}
+
static int do_edit(int argc, char *argv[])
{
bool is_vi = false;
@@ -539,16 +558,7 @@ static int do_edit(int argc, char *argv[])
return 1;
screenwidth = 80;
-
- /*
- * The EFI simple text output protocol wraps to the next line and scrolls
- * down when we write to the right bottom screen position. Reduce the number
- * of rows by one to work around this.
- */
- if (IS_ENABLED(CONFIG_EFI_BOOTUP))
- screenheight = 24;
- else
- screenheight = 25;
+ screenheight = 25;
/* check if we are not called as "edit" */
if (*argv[0] != 'e') {
@@ -560,6 +570,22 @@ static int do_edit(int argc, char *argv[])
is_vi = true;
}
+ if (is_efi_console_active()) {
+ /*
+ * The EFI simple text output protocol wraps to the next line and
+ * scrolls down when we write to the right bottom screen position.
+ * Reduce the number of rows by one to work around this.
+ */
+ screenheight--;
+
+ /*
+ * Our console driver for the EFI simple text output protocol does
+ * not implement the "\e[1S" sequence we use for scrolling the
+ * screen.
+ */
+ smartscroll = 0;
+ }
+
cursx = 0;
cursy = 0;
textx = 0;
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 22/25] edit: send escape sequence only for smartscroll
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (20 preceding siblings ...)
2021-12-13 21:09 ` [PATCH 21/25] edit: Improve behaviour on efi-stdio console Sascha Hauer
@ 2021-12-13 21:09 ` Sascha Hauer
2021-12-13 21:09 ` [PATCH 23/25] net: efi-snp: Check for carrier before sending Sascha Hauer
` (3 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:09 UTC (permalink / raw)
To: Barebox List
"\e[2;<x>r" is needed to prevent the status line from scrolling out of
the window when smartscrolling is used. Only send it when smartscrolling
is actually active.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/edit.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/commands/edit.c b/commands/edit.c
index 592cf4aa3d..12695d39e4 100644
--- a/commands/edit.c
+++ b/commands/edit.c
@@ -610,7 +610,9 @@ static int do_edit(int argc, char *argv[])
argv[1]);
}
- printf("\x1b[2;%dr", screenheight);
+ if (smartscroll)
+ printf("\x1b[2;%dr", screenheight);
+
pos(0, 0);
screenheight--; /* status line */
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 23/25] net: efi-snp: Check for carrier before sending
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (21 preceding siblings ...)
2021-12-13 21:09 ` [PATCH 22/25] edit: send escape sequence only for smartscroll Sascha Hauer
@ 2021-12-13 21:09 ` Sascha Hauer
2021-12-13 21:09 ` [PATCH 24/25] efi: add efi_device hook to be called before an image is started Sascha Hauer
` (2 subsequent siblings)
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:09 UTC (permalink / raw)
To: Barebox List
We have carrier informations available, so check them before sending a
packet.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/efi-snp.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/efi-snp.c b/drivers/net/efi-snp.c
index def2714bee..3c0663c802 100644
--- a/drivers/net/efi-snp.c
+++ b/drivers/net/efi-snp.c
@@ -134,6 +134,9 @@ static int efi_snp_eth_send(struct eth_device *edev, void *packet, int length)
void *txbuf;
uint64_t start;
+ if (!priv->snp->Mode->MediaPresent)
+ return -ENOMEDIUM;
+
efiret = priv->snp->transmit(priv->snp, 0, length, packet, NULL, NULL, NULL);
if (EFI_ERROR(efiret)) {
dev_err(priv->dev, "failed to send: %s\n", efi_strerror(efiret));
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 24/25] efi: add efi_device hook to be called before an image is started
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (22 preceding siblings ...)
2021-12-13 21:09 ` [PATCH 23/25] net: efi-snp: Check for carrier before sending Sascha Hauer
@ 2021-12-13 21:09 ` Sascha Hauer
2021-12-13 21:09 ` [PATCH 25/25] net: efi-snp: Open protocol exclusively Sascha Hauer
2021-12-15 11:07 ` [PATCH 00/25] EFI improvements Ahmad Fatoum
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:09 UTC (permalink / raw)
To: Barebox List
boot_services::open_protocol supports opening protocols exclusively.
A protocol that is opened exclusively can not be used anymore by
an application that is called via boot_services::start_image.
We want to open the SNP protocol exclusively in the next step. That
would mean a chainloaded barebox could no longer use the SNP protocol
because it's exclusively opened by the current barebox already.
To work around this a efi_drv::dev_pause and efi_drv::dev_continue is
introduced. The former is called before an application is started and
the latter right after an application has exited. This will be used
by the SNP network driver to enter/leave exclusive mode.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/efi/efi-image.c | 4 ++++
drivers/efi/efi-device.c | 28 ++++++++++++++++++++++++++++
include/efi/efi-device.h | 5 +++++
3 files changed, 37 insertions(+)
diff --git a/common/efi/efi-image.c b/common/efi/efi-image.c
index bd1c58438e..7807d0653e 100644
--- a/common/efi/efi-image.c
+++ b/common/efi/efi-image.c
@@ -149,10 +149,14 @@ static int efi_execute_image(const char *file)
shutdown_barebox();
}
+ efi_pause_devices();
+
efiret = BS->start_image(handle, NULL, NULL);
if (EFI_ERROR(efiret))
pr_err("failed to StartImage: %s\n", efi_strerror(efiret));
+ efi_continue_devices();
+
if (!is_driver)
BS->unload_image(handle);
diff --git a/drivers/efi/efi-device.c b/drivers/efi/efi-device.c
index 6c86a8ab1a..f3f5452b98 100644
--- a/drivers/efi/efi-device.c
+++ b/drivers/efi/efi-device.c
@@ -466,6 +466,34 @@ static int efi_init_devices(void)
}
core_initcall(efi_init_devices);
+void efi_pause_devices(void)
+{
+ struct device_d *dev;
+
+ bus_for_each_device(&efi_bus, dev) {
+ struct driver_d *drv = dev->driver;
+ struct efi_device *efidev = to_efi_device(dev);
+ struct efi_driver *efidrv = to_efi_driver(drv);
+
+ if (efidrv->dev_pause)
+ efidrv->dev_pause(efidev);
+ }
+}
+
+void efi_continue_devices(void)
+{
+ struct device_d *dev;
+
+ bus_for_each_device(&efi_bus, dev) {
+ struct driver_d *drv = dev->driver;
+ struct efi_device *efidev = to_efi_device(dev);
+ struct efi_driver *efidrv = to_efi_driver(drv);
+
+ if (efidrv->dev_continue)
+ efidrv->dev_continue(efidev);
+ }
+}
+
static void efi_devpath(efi_handle_t handle)
{
efi_status_t efiret;
diff --git a/include/efi/efi-device.h b/include/efi/efi-device.h
index 5ec59a8a2d..729fbc8103 100644
--- a/include/efi/efi-device.h
+++ b/include/efi/efi-device.h
@@ -15,6 +15,8 @@ struct efi_driver {
struct driver_d driver;
int (*probe)(struct efi_device *efidev);
void (*remove)(struct efi_device *efidev);
+ int (*dev_pause)(struct efi_device *efidev);
+ int (*dev_continue)(struct efi_device *efidev);
efi_guid_t guid;
};
@@ -45,6 +47,9 @@ int efi_connect_all(void);
void efi_register_devices(void);
struct efi_device *efi_get_bootsource(void);
+void efi_pause_devices(void);
+void efi_continue_devices(void);
+
static inline bool efi_device_has_guid(struct efi_device *efidev, efi_guid_t guid)
{
int i;
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* [PATCH 25/25] net: efi-snp: Open protocol exclusively
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (23 preceding siblings ...)
2021-12-13 21:09 ` [PATCH 24/25] efi: add efi_device hook to be called before an image is started Sascha Hauer
@ 2021-12-13 21:09 ` Sascha Hauer
2021-12-15 11:07 ` [PATCH 00/25] EFI improvements Ahmad Fatoum
25 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-13 21:09 UTC (permalink / raw)
To: Barebox List
Open the SNP protocol exclusively. Without it other protocol instances
may poll for packets as well causing packet loss.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/efi-snp.c | 56 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/drivers/net/efi-snp.c b/drivers/net/efi-snp.c
index 3c0663c802..31ce272118 100644
--- a/drivers/net/efi-snp.c
+++ b/drivers/net/efi-snp.c
@@ -177,6 +177,32 @@ static int efi_snp_eth_rx(struct eth_device *edev)
return 0;
}
+static efi_guid_t snp_guid = EFI_SIMPLE_NETWORK_PROTOCOL_GUID;
+
+static int efi_snp_open_exclusive(struct efi_device *efidev)
+{
+ void *interface;
+ efi_status_t efiret;
+
+ /*
+ * Try to re-open SNP exlusively to close any active MNP protocol instance
+ * that may compete for packet polling
+ */
+ efiret = BS->open_protocol(efidev->handle, &snp_guid,
+ &interface, efi_parent_image, NULL, EFI_OPEN_PROTOCOL_EXCLUSIVE);
+ if (EFI_ERROR(efiret)) {
+ dev_err(&efidev->dev, "failed to open exclusively: %s\n", efi_strerror(efiret));
+ return -efi_errno(efiret);
+ }
+
+ return 0;
+}
+
+static void efi_snp_close_exclusive(struct efi_device *efidev)
+{
+ BS->close_protocol(efidev->handle, &snp_guid, efi_parent_image, NULL);
+}
+
static int efi_snp_eth_open(struct eth_device *edev)
{
struct efi_snp_priv *priv = to_priv(edev);
@@ -234,6 +260,20 @@ static int efi_snp_set_ethaddr(struct eth_device *edev, const unsigned char *adr
return 0;
}
+static int efi_snp_pause(struct efi_device *efidev)
+{
+ efi_snp_close_exclusive(efidev);
+
+ return 0;
+}
+
+static int efi_snp_continue(struct efi_device *efidev)
+{
+ efi_snp_open_exclusive(efidev);
+
+ return 0;
+}
+
static int efi_snp_probe(struct efi_device *efidev)
{
struct eth_device *edev;
@@ -272,16 +312,28 @@ static int efi_snp_probe(struct efi_device *efidev)
edev->get_ethaddr = efi_snp_get_ethaddr;
edev->set_ethaddr = efi_snp_set_ethaddr;
+ ret = efi_snp_open_exclusive(efidev);
+ if (ret)
+ return ret;
+
ret = eth_register(edev);
return ret;
}
+static void efi_snp_remove(struct efi_device *efidev)
+{
+ efi_snp_close_exclusive(efidev);
+}
+
static struct efi_driver efi_snp_driver = {
- .driver = {
+ .driver = {
.name = "efi-snp",
},
- .probe = efi_snp_probe,
+ .probe = efi_snp_probe,
+ .remove = efi_snp_remove,
+ .dev_pause = efi_snp_pause,
+ .dev_continue = efi_snp_continue,
.guid = EFI_SIMPLE_NETWORK_PROTOCOL_GUID,
};
device_efi_driver(efi_snp_driver);
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH 13/25] efi-stdio: Implement efi_console_putc() using efi_console_puts()
2021-12-13 21:08 ` [PATCH 13/25] efi-stdio: Implement efi_console_putc() using efi_console_puts() Sascha Hauer
@ 2021-12-15 11:04 ` Ahmad Fatoum
0 siblings, 0 replies; 35+ messages in thread
From: Ahmad Fatoum @ 2021-12-15 11:04 UTC (permalink / raw)
To: Sascha Hauer, Barebox List
Hi,
On 13.12.21 22:08, Sascha Hauer wrote:
> The current efi_console_putc() implementation bypasses the special
> character handling. Fix that by using efi_console_puts() for the
> implemenation of efi_console_putc().
Not saying that it matters much in practice, but this breaks xmodem,
doesn't it?
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> drivers/serial/efi-stdio.c | 16 +++++-----------
> 1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
> index d99eca9d5e..d512cc3e01 100644
> --- a/drivers/serial/efi-stdio.c
> +++ b/drivers/serial/efi-stdio.c
> @@ -160,17 +160,6 @@ static int efi_read_key(struct efi_console_priv *priv, bool wait)
> return xlate_keypress(&kd.key);
> }
>
> -static void efi_console_putc(struct console_device *cdev, char c)
> -{
> - uint16_t str[2] = {};
> - struct efi_console_priv *priv = to_efi(cdev);
> - struct efi_simple_text_output_protocol *con_out = priv->out;
> -
> - str[0] = c;
> -
> - con_out->output_string(con_out, str);
> -}
> -
> static void clear_to_eol(struct efi_console_priv *priv)
> {
> int pos = priv->out->mode->cursor_column;
> @@ -352,6 +341,11 @@ static int efi_console_puts(struct console_device *cdev, const char *s,
> return nbytes;
> }
>
> +static void efi_console_putc(struct console_device *cdev, char c)
> +{
> + efi_console_puts(cdev, &c, 1);
> +}
> +
> static int efi_console_tstc(struct console_device *cdev)
> {
> struct efi_console_priv *priv = to_efi(cdev);
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH 00/25] EFI improvements
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
` (24 preceding siblings ...)
2021-12-13 21:09 ` [PATCH 25/25] net: efi-snp: Open protocol exclusively Sascha Hauer
@ 2021-12-15 11:07 ` Ahmad Fatoum
2021-12-18 12:07 ` Michael Graichen
25 siblings, 1 reply; 35+ messages in thread
From: Ahmad Fatoum @ 2021-12-15 11:07 UTC (permalink / raw)
To: Sascha Hauer, Barebox List
On 13.12.21 22:08, Sascha Hauer wrote:
> This series contains several improvements for barebox running on EFI.
> Most patches are around the efi-stdio driver in which handling of ansi
> escape sequences is greatly improved. With this series efi-stdio is now
> able to parse and handle the escape sequences barebox issues itself
> properly.
> The EFI SNP network driver suffered from packet loss on some machines
> because other protocols were polling for packets as well. This is also
> fixed with this series.
Very nice. :-)
>
> Sascha
>
> Sascha Hauer (25):
> efi-devicepath: Make efi_device_path argument const
> efi: move device-path defines and types to header file
> efi: Implement device_path_to_subtype()
> efi: Do not register IPv[46] devices
> console: Fix message colours
> efi-stdio: remove unnecessary check
> efi-stdio: rename to efi_process_escape
> efi-stdio: return bytes actually consumed
> efi-stdio: fix escape sequence end detection
> efi-stdio: improve escape sequence parsing
> efi-stdio: Fix out of bounds error in puts
> efi-stdio: Fix tab printing
> efi-stdio: Implement efi_console_putc() using efi_console_puts()
> efi-stdio: Fix '\b' handling
> efi-stdio: implement input buffering with a kfifo
> efi-stdio: limit set_cursor to screen size boundaries
> efi-stdio: implement getting the cursor position
> efi-stdio: Implement setting cursor visibility
> efi-stdio: Support different text modes
> edit: improve screen size detection
> edit: Improve behaviour on efi-stdio console
> edit: send escape sequence only for smartscroll
> net: efi-snp: Check for carrier before sending
> efi: add efi_device hook to be called before an image is started
> net: efi-snp: Open protocol exclusively
>
> commands/edit.c | 107 ++++++++--
> common/console_common.c | 12 +-
> common/efi-devicepath.c | 405 ++-----------------------------------
> common/efi/efi-image.c | 4 +
> drivers/efi/efi-device.c | 42 +++-
> drivers/net/efi-snp.c | 59 +++++-
> drivers/serial/efi-stdio.c | 362 +++++++++++++++++++++------------
> include/efi.h | 1 +
> include/efi/device-path.h | 388 +++++++++++++++++++++++++++++++++++
> include/efi/efi-device.h | 5 +
> 10 files changed, 840 insertions(+), 545 deletions(-)
> create mode 100644 include/efi/device-path.h
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH 05/25] console: Fix message colours
2021-12-13 21:08 ` [PATCH 05/25] console: Fix message colours Sascha Hauer
@ 2021-12-16 12:21 ` Jules Maselbas
2021-12-17 13:23 ` Sascha Hauer
0 siblings, 1 reply; 35+ messages in thread
From: Jules Maselbas @ 2021-12-16 12:21 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Barebox List
Hi,
On Mon, Dec 13, 2021 at 10:08:45PM +0100, Sascha Hauer wrote:
> The correct code to change colours is "\033[1;31m", not "\033[31m". Fix
> that.
Uhmm I am curious why this is the "correct" way. From what I can tell
the terminfo for me says that 'setaf' red is '\e[31m'.
Maybe the EFI consol doesn't support setaf "termcap", an only has the
'sgr' capability, and the non-bold red selected as '\e[0;31m'.
cheers
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> common/console_common.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/common/console_common.c b/common/console_common.c
> index 91a81e50fa..7bef74c543 100644
> --- a/common/console_common.c
> +++ b/common/console_common.c
> @@ -23,12 +23,12 @@
> #ifndef CONFIG_CONSOLE_NONE
>
> static const char *colored_log_level[] = {
> - [MSG_EMERG] = "\033[31mEMERG:\033[0m ", /* red */
> - [MSG_ALERT] = "\033[31mALERT:\033[0m ", /* red */
> - [MSG_CRIT] = "\033[31mCRITICAL:\033[0m ", /* red */
> - [MSG_ERR] = "\033[31mERROR:\033[0m ", /* red */
> - [MSG_WARNING] = "\033[33mWARNING:\033[0m ", /* yellow */
> - [MSG_NOTICE] = "\033[34mNOTICE:\033[0m ", /* blue */
> + [MSG_EMERG] = "\033[1;31mEMERG:\033[0m ", /* red */
> + [MSG_ALERT] = "\033[1;31mALERT:\033[0m ", /* red */
> + [MSG_CRIT] = "\033[1;31mCRITICAL:\033[0m ", /* red */
> + [MSG_ERR] = "\033[1;31mERROR:\033[0m ", /* red */
> + [MSG_WARNING] = "\033[1;33mWARNING:\033[0m ", /* yellow */
> + [MSG_NOTICE] = "\033[1;34mNOTICE:\033[0m ", /* blue */
> };
>
> int barebox_loglevel = CONFIG_DEFAULT_LOGLEVEL;
> --
> 2.30.2
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
>
> To declare a filtering error, please use the following link : https://www.security-mail.net/reporter.php?mid=3e86.61b7b6f5.c4cd9.0&r=jmaselbas%40kalray.eu&s=barebox-bounces%2Bjmaselbas%3Dkalray.eu%40lists.infradead.org&o=%5BPATCH+05%2F25%5D+console%3A+Fix+message+colours&verdict=C&c=c280cd527bf219cdc889e73ba093616095b2dfa3
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH 21/25] edit: Improve behaviour on efi-stdio console
2021-12-13 21:09 ` [PATCH 21/25] edit: Improve behaviour on efi-stdio console Sascha Hauer
@ 2021-12-16 12:41 ` Jules Maselbas
2021-12-17 13:29 ` Sascha Hauer
0 siblings, 1 reply; 35+ messages in thread
From: Jules Maselbas @ 2021-12-16 12:41 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Barebox List
Hi,
On Mon, Dec 13, 2021 at 10:09:01PM +0100, Sascha Hauer wrote:
> Our console driver for the EFI simple text protocol does not support
> the "\e[1S" escape sequence to scroll the window which means sedit
> doesn't work properly. Disable smartscroll when the efi-stdio console
> is active. While at it put the screen height reduction into the same
> dynamic test.
FYI
>From the terminfo manpage:
In order to scroll text up, a program will go to the bottom left corner
of the screen and send the ind (index) string. [...] Parameterized
versions of the scrolling sequences are indn and rin which have the same
semantics as ind and ri except that they take one parameter, and scroll
that many lines. [...]
>From infocmp on my system: ind=\n and indn=\e[%p1$pS
So the smart scroll could be replaced by a move to the last line plus \n
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> commands/edit.c | 46 ++++++++++++++++++++++++++++++++++++----------
> 1 file changed, 36 insertions(+), 10 deletions(-)
>
> diff --git a/commands/edit.c b/commands/edit.c
> index 30448cbc04..592cf4aa3d 100644
> --- a/commands/edit.c
> +++ b/commands/edit.c
> @@ -522,6 +522,25 @@ static int read_modal_key(bool is_modal)
> return -EAGAIN;
> }
>
> +static bool is_efi_console_active(void)
> +{
> + struct console_device *cdev;
> +
> + if (!IS_ENABLED(CONFIG_DRIVER_SERIAL_EFI_STDIO))
> + return false;
> +
> + for_each_console(cdev) {
> + if (!(cdev->f_active & CONSOLE_STDIN))
> + continue;
> + if (!(cdev->f_active & CONSOLE_STDOUT))
> + continue;
> + if (!strcmp(dev_name(cdev->dev), "efi-stdio"))
> + return true;
> + }
> +
> + return false;
> +}
> +
> static int do_edit(int argc, char *argv[])
> {
> bool is_vi = false;
> @@ -539,16 +558,7 @@ static int do_edit(int argc, char *argv[])
> return 1;
>
> screenwidth = 80;
> -
> - /*
> - * The EFI simple text output protocol wraps to the next line and scrolls
> - * down when we write to the right bottom screen position. Reduce the number
> - * of rows by one to work around this.
> - */
> - if (IS_ENABLED(CONFIG_EFI_BOOTUP))
> - screenheight = 24;
> - else
> - screenheight = 25;
> + screenheight = 25;
>
> /* check if we are not called as "edit" */
> if (*argv[0] != 'e') {
> @@ -560,6 +570,22 @@ static int do_edit(int argc, char *argv[])
> is_vi = true;
> }
>
> + if (is_efi_console_active()) {
> + /*
> + * The EFI simple text output protocol wraps to the next line and
> + * scrolls down when we write to the right bottom screen position.
> + * Reduce the number of rows by one to work around this.
> + */
> + screenheight--;
> +
> + /*
> + * Our console driver for the EFI simple text output protocol does
> + * not implement the "\e[1S" sequence we use for scrolling the
> + * screen.
> + */
> + smartscroll = 0;
> + }
> +
> cursx = 0;
> cursy = 0;
> textx = 0;
> --
> 2.30.2
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
>
> To declare a filtering error, please use the following link : https://www.security-mail.net/reporter.php?mid=51ef.61b7b6ff.b5dfd.0&r=jmaselbas%40kalray.eu&s=barebox-bounces%2Bjmaselbas%3Dkalray.eu%40lists.infradead.org&o=%5BPATCH+21%2F25%5D+edit%3A+Improve+behaviour+on+efi-stdio+console&verdict=C&c=7aca3328f2dac1c6571b69dba9c6a9e04f98dc81
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH 05/25] console: Fix message colours
2021-12-16 12:21 ` Jules Maselbas
@ 2021-12-17 13:23 ` Sascha Hauer
2021-12-17 13:24 ` Jules Maselbas
0 siblings, 1 reply; 35+ messages in thread
From: Sascha Hauer @ 2021-12-17 13:23 UTC (permalink / raw)
To: Jules Maselbas; +Cc: Barebox List
Hi Jules,
On Thu, Dec 16, 2021 at 01:21:25PM +0100, Jules Maselbas wrote:
> Hi,
>
> On Mon, Dec 13, 2021 at 10:08:45PM +0100, Sascha Hauer wrote:
> > The correct code to change colours is "\033[1;31m", not "\033[31m". Fix
> > that.
>
> Uhmm I am curious why this is the "correct" way. From what I can tell
> the terminfo for me says that 'setaf' red is '\e[31m'.
> Maybe the EFI consol doesn't support setaf "termcap", an only has the
> 'sgr' capability, and the non-bold red selected as '\e[0;31m'.
Looking again at it, '\e[31m' is correct. Maybe it would have been
better to say "Change to what efi-stdio can parse"
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH 05/25] console: Fix message colours
2021-12-17 13:23 ` Sascha Hauer
@ 2021-12-17 13:24 ` Jules Maselbas
0 siblings, 0 replies; 35+ messages in thread
From: Jules Maselbas @ 2021-12-17 13:24 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Barebox List
On Fri, Dec 17, 2021 at 02:23:29PM +0100, Sascha Hauer wrote:
> Hi Jules,
>
> On Thu, Dec 16, 2021 at 01:21:25PM +0100, Jules Maselbas wrote:
> > Hi,
> >
> > On Mon, Dec 13, 2021 at 10:08:45PM +0100, Sascha Hauer wrote:
> > > The correct code to change colours is "\033[1;31m", not "\033[31m". Fix
> > > that.
> >
> > Uhmm I am curious why this is the "correct" way. From what I can tell
> > the terminfo for me says that 'setaf' red is '\e[31m'.
> > Maybe the EFI consol doesn't support setaf "termcap", an only has the
> > 'sgr' capability, and the non-bold red selected as '\e[0;31m'.
>
> Looking again at it, '\e[31m' is correct. Maybe it would have been
> better to say "Change to what efi-stdio can parse"
yeah, this is a nitpick
> Sascha
>
> --
> Pengutronix e.K. | |
> Steuerwalder Str. 21 | http://www.pengutronix.de/ |
> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
>
>
> To declare a filtering error, please use the following link : https://www.security-mail.net/reporter.php?mid=f35c.61bc8f52.89ac3.0&r=jmaselbas%40kalray.eu&s=sha%40pengutronix.de&o=Re%3A+%5BPATCH+05%2F25%5D+console%3A+Fix+message+colours&verdict=C&c=5c80bcf023a7e05c839c2ae283528cd6185478a1
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH 21/25] edit: Improve behaviour on efi-stdio console
2021-12-16 12:41 ` Jules Maselbas
@ 2021-12-17 13:29 ` Sascha Hauer
0 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-17 13:29 UTC (permalink / raw)
To: Jules Maselbas; +Cc: Barebox List
On Thu, Dec 16, 2021 at 01:41:34PM +0100, Jules Maselbas wrote:
> Hi,
>
> On Mon, Dec 13, 2021 at 10:09:01PM +0100, Sascha Hauer wrote:
> > Our console driver for the EFI simple text protocol does not support
> > the "\e[1S" escape sequence to scroll the window which means sedit
> > doesn't work properly. Disable smartscroll when the efi-stdio console
> > is active. While at it put the screen height reduction into the same
> > dynamic test.
>
> FYI
>
> From the terminfo manpage:
> In order to scroll text up, a program will go to the bottom left corner
> of the screen and send the ind (index) string. [...] Parameterized
> versions of the scrolling sequences are indn and rin which have the same
> semantics as ind and ri except that they take one parameter, and scroll
> that many lines. [...]
>
> From infocmp on my system: ind=\n and indn=\e[%p1$pS
>
> So the smart scroll could be replaced by a move to the last line plus \n
The efi-stdio code itself implements a terminal and translates the
escape sequences into things the EFI simple text protocol can
understand.
With the EFI simple text protocol the screen content indeed scrolls one
line up when the cursor is moved out of the screen. The problem comes
with the status line in the editor. This would be scrolled out of the
screen. The editor uses escape sequences to limit the window of what is
scrolled in a way that the first line is not part of the window. That
cannot be implemented with the EFI simple text protocol, at least not
without redrawing the whole screen. This is why it's simpler to just
not use this in the editor.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH 00/25] EFI improvements
2021-12-15 11:07 ` [PATCH 00/25] EFI improvements Ahmad Fatoum
@ 2021-12-18 12:07 ` Michael Graichen
2021-12-18 13:55 ` Sascha Hauer
0 siblings, 1 reply; 35+ messages in thread
From: Michael Graichen @ 2021-12-18 12:07 UTC (permalink / raw)
To: Ahmad Fatoum, Sascha Hauer, Barebox List
Hey,
Am 15.12.21 um 12:07 schrieb Ahmad Fatoum:
> On 13.12.21 22:08, Sascha Hauer wrote:
>> This series contains several improvements for barebox running on EFI.
>> Most patches are around the efi-stdio driver in which handling of ansi
>> escape sequences is greatly improved. With this series efi-stdio is now
>> able to parse and handle the escape sequences barebox issues itself
>> properly.
>> The EFI SNP network driver suffered from packet loss on some machines
>> because other protocols were polling for packets as well. This is also
>> fixed with this series.
>
> Very nice. :-)
>
yes, I have just started testing the efi boot methode and these patches
on one of my computers.
But how can i change the keyboard layout to QWERTZ (german)? Or where
would be the right place to implement that?
best regards
Michael
>>
>> Sascha
>>
>> Sascha Hauer (25):
>> efi-devicepath: Make efi_device_path argument const
>> efi: move device-path defines and types to header file
>> efi: Implement device_path_to_subtype()
>> efi: Do not register IPv[46] devices
>> console: Fix message colours
>> efi-stdio: remove unnecessary check
>> efi-stdio: rename to efi_process_escape
>> efi-stdio: return bytes actually consumed
>> efi-stdio: fix escape sequence end detection
>> efi-stdio: improve escape sequence parsing
>> efi-stdio: Fix out of bounds error in puts
>> efi-stdio: Fix tab printing
>> efi-stdio: Implement efi_console_putc() using efi_console_puts()
>> efi-stdio: Fix '\b' handling
>> efi-stdio: implement input buffering with a kfifo
>> efi-stdio: limit set_cursor to screen size boundaries
>> efi-stdio: implement getting the cursor position
>> efi-stdio: Implement setting cursor visibility
>> efi-stdio: Support different text modes
>> edit: improve screen size detection
>> edit: Improve behaviour on efi-stdio console
>> edit: send escape sequence only for smartscroll
>> net: efi-snp: Check for carrier before sending
>> efi: add efi_device hook to be called before an image is started
>> net: efi-snp: Open protocol exclusively
>>
>> commands/edit.c | 107 ++++++++--
>> common/console_common.c | 12 +-
>> common/efi-devicepath.c | 405 ++-----------------------------------
>> common/efi/efi-image.c | 4 +
>> drivers/efi/efi-device.c | 42 +++-
>> drivers/net/efi-snp.c | 59 +++++-
>> drivers/serial/efi-stdio.c | 362 +++++++++++++++++++++------------
>> include/efi.h | 1 +
>> include/efi/device-path.h | 388 +++++++++++++++++++++++++++++++++++
>> include/efi/efi-device.h | 5 +
>> 10 files changed, 840 insertions(+), 545 deletions(-)
>> create mode 100644 include/efi/device-path.h
>>
>
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH 00/25] EFI improvements
2021-12-18 12:07 ` Michael Graichen
@ 2021-12-18 13:55 ` Sascha Hauer
0 siblings, 0 replies; 35+ messages in thread
From: Sascha Hauer @ 2021-12-18 13:55 UTC (permalink / raw)
To: Michael Graichen; +Cc: Ahmad Fatoum, Barebox List
Hi Michael,
On Sat, Dec 18, 2021 at 01:07:42PM +0100, Michael Graichen wrote:
>
>
> Hey,
>
>
>
> Am 15.12.21 um 12:07 schrieb Ahmad Fatoum:
> > On 13.12.21 22:08, Sascha Hauer wrote:
> > > This series contains several improvements for barebox running on EFI.
> > > Most patches are around the efi-stdio driver in which handling of ansi
> > > escape sequences is greatly improved. With this series efi-stdio is now
> > > able to parse and handle the escape sequences barebox issues itself
> > > properly.
> > > The EFI SNP network driver suffered from packet loss on some machines
> > > because other protocols were polling for packets as well. This is also
> > > fixed with this series.
> >
> > Very nice. :-)
> >
>
> yes, I have just started testing the efi boot methode and these patches on
> one of my computers.
>
> But how can i change the keyboard layout to QWERTZ (german)? Or where would
> be the right place to implement that?
Neither barebox nor the underlying UEFI imeplements different keyboard
layouts. I think the right place to implement that in barebox would be
in drivers/input/. For that to work the driver for the simple text input
protocol would have to be converted to an input driver. You could also
implement it in drivers/serial/serial_efi.c, but there it would work
only for that single driver, not for USB keyboards.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 35+ messages in thread
end of thread, other threads:[~2021-12-18 13:57 UTC | newest]
Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-13 21:08 [PATCH 00/25] EFI improvements Sascha Hauer
2021-12-13 21:08 ` [PATCH 01/25] efi-devicepath: Make efi_device_path argument const Sascha Hauer
2021-12-13 21:08 ` [PATCH 02/25] efi: move device-path defines and types to header file Sascha Hauer
2021-12-13 21:08 ` [PATCH 03/25] efi: Implement device_path_to_subtype() Sascha Hauer
2021-12-13 21:08 ` [PATCH 04/25] efi: Do not register IPv[46] devices Sascha Hauer
2021-12-13 21:08 ` [PATCH 05/25] console: Fix message colours Sascha Hauer
2021-12-16 12:21 ` Jules Maselbas
2021-12-17 13:23 ` Sascha Hauer
2021-12-17 13:24 ` Jules Maselbas
2021-12-13 21:08 ` [PATCH 06/25] efi-stdio: remove unnecessary check Sascha Hauer
2021-12-13 21:08 ` [PATCH 07/25] efi-stdio: rename to efi_process_escape Sascha Hauer
2021-12-13 21:08 ` [PATCH 08/25] efi-stdio: return bytes actually consumed Sascha Hauer
2021-12-13 21:08 ` [PATCH 09/25] efi-stdio: fix escape sequence end detection Sascha Hauer
2021-12-13 21:08 ` [PATCH 10/25] efi-stdio: improve escape sequence parsing Sascha Hauer
2021-12-13 21:08 ` [PATCH 11/25] efi-stdio: Fix out of bounds error in puts Sascha Hauer
2021-12-13 21:08 ` [PATCH 12/25] efi-stdio: Fix tab printing Sascha Hauer
2021-12-13 21:08 ` [PATCH 13/25] efi-stdio: Implement efi_console_putc() using efi_console_puts() Sascha Hauer
2021-12-15 11:04 ` Ahmad Fatoum
2021-12-13 21:08 ` [PATCH 14/25] efi-stdio: Fix '\b' handling Sascha Hauer
2021-12-13 21:08 ` [PATCH 15/25] efi-stdio: implement input buffering with a kfifo Sascha Hauer
2021-12-13 21:08 ` [PATCH 16/25] efi-stdio: limit set_cursor to screen size boundaries Sascha Hauer
2021-12-13 21:08 ` [PATCH 17/25] efi-stdio: implement getting the cursor position Sascha Hauer
2021-12-13 21:08 ` [PATCH 18/25] efi-stdio: Implement setting cursor visibility Sascha Hauer
2021-12-13 21:08 ` [PATCH 19/25] efi-stdio: Support different text modes Sascha Hauer
2021-12-13 21:09 ` [PATCH 20/25] edit: improve screen size detection Sascha Hauer
2021-12-13 21:09 ` [PATCH 21/25] edit: Improve behaviour on efi-stdio console Sascha Hauer
2021-12-16 12:41 ` Jules Maselbas
2021-12-17 13:29 ` Sascha Hauer
2021-12-13 21:09 ` [PATCH 22/25] edit: send escape sequence only for smartscroll Sascha Hauer
2021-12-13 21:09 ` [PATCH 23/25] net: efi-snp: Check for carrier before sending Sascha Hauer
2021-12-13 21:09 ` [PATCH 24/25] efi: add efi_device hook to be called before an image is started Sascha Hauer
2021-12-13 21:09 ` [PATCH 25/25] net: efi-snp: Open protocol exclusively Sascha Hauer
2021-12-15 11:07 ` [PATCH 00/25] EFI improvements Ahmad Fatoum
2021-12-18 12:07 ` Michael Graichen
2021-12-18 13:55 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox