naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
2aacef
From 071cef46b87b605f8b4918a95dcecae08b843e23 Mon Sep 17 00:00:00 2001
2aacef
From: Jan Janssen <medhefgo@web.de>
2aacef
Date: Sun, 27 Nov 2022 13:38:18 +0100
2aacef
Subject: [PATCH] boot: Use EFI_BOOT_MANAGER_POLICY_PROTOCOL to connect console
2aacef
 devices
2aacef
2aacef
(cherry picked from commit b99bf5811850afdb2502ba37251c48348da63c82)
2aacef
2aacef
Related: #2138081
2aacef
---
2aacef
 src/boot/efi/console.c     | 16 ++++++++++++++++
2aacef
 src/boot/efi/missing_efi.h | 19 +++++++++++++++++++
2aacef
 2 files changed, 35 insertions(+)
2aacef
2aacef
diff --git a/src/boot/efi/console.c b/src/boot/efi/console.c
2aacef
index 14c0008afb..cd980fd535 100644
2aacef
--- a/src/boot/efi/console.c
2aacef
+++ b/src/boot/efi/console.c
2aacef
@@ -12,6 +12,20 @@
2aacef
 #define VERTICAL_MAX_OK 1080
2aacef
 #define VIEWPORT_RATIO 10
2aacef
 
2aacef
+static EFI_STATUS console_connect(void) {
2aacef
+        EFI_BOOT_MANAGER_POLICY_PROTOCOL *boot_policy;
2aacef
+        EFI_STATUS err;
2aacef
+
2aacef
+        /* This should make console devices appear/fully initialize on fastboot firmware. */
2aacef
+
2aacef
+        err = BS->LocateProtocol(
2aacef
+                        &(EFI_GUID) EFI_BOOT_MANAGER_POLICY_PROTOCOL_GUID, NULL, (void **) &boot_policy);
2aacef
+        if (err != EFI_SUCCESS)
2aacef
+                return err;
2aacef
+
2aacef
+        return boot_policy->ConnectDeviceClass(boot_policy, &(EFI_GUID) EFI_BOOT_MANAGER_POLICY_CONSOLE_GUID);
2aacef
+}
2aacef
+
2aacef
 static inline void event_closep(EFI_EVENT *event) {
2aacef
         if (!*event)
2aacef
                 return;
2aacef
@@ -47,6 +61,8 @@ EFI_STATUS console_key_read(uint64_t *key, uint64_t timeout_usec) {
2aacef
         assert(key);
2aacef
 
2aacef
         if (!checked) {
2aacef
+                console_connect();
2aacef
+
2aacef
                 /* Get the *first* TextInputEx device.*/
2aacef
                 err = BS->LocateProtocol(&SimpleTextInputExProtocol, NULL, (void **) &extraInEx);
2aacef
                 if (err != EFI_SUCCESS || BS->CheckEvent(extraInEx->WaitForKeyEx) == EFI_INVALID_PARAMETER)
2aacef
diff --git a/src/boot/efi/missing_efi.h b/src/boot/efi/missing_efi.h
2aacef
index 250c84c248..b446e0399f 100644
2aacef
--- a/src/boot/efi/missing_efi.h
2aacef
+++ b/src/boot/efi/missing_efi.h
2aacef
@@ -398,3 +398,22 @@ typedef struct {
2aacef
         void *StdErr;
2aacef
 } EFI_SHELL_PARAMETERS_PROTOCOL;
2aacef
 #endif
2aacef
+
2aacef
+#ifndef EFI_BOOT_MANAGER_POLICY_PROTOCOL_GUID
2aacef
+#define EFI_BOOT_MANAGER_POLICY_PROTOCOL_GUID \
2aacef
+        { 0xFEDF8E0C, 0xE147, 0x11E3, { 0x99, 0x03, 0xB8, 0xE8, 0x56, 0x2C, 0xBA, 0xFA } }
2aacef
+#define EFI_BOOT_MANAGER_POLICY_CONSOLE_GUID \
2aacef
+        { 0xCAB0E94C, 0xE15F, 0x11E3, { 0x91, 0x8D, 0xB8, 0xE8, 0x56, 0x2C, 0xBA, 0xFA } }
2aacef
+
2aacef
+typedef struct EFI_BOOT_MANAGER_POLICY_PROTOCOL EFI_BOOT_MANAGER_POLICY_PROTOCOL;
2aacef
+struct EFI_BOOT_MANAGER_POLICY_PROTOCOL {
2aacef
+        UINT64 Revision;
2aacef
+        EFI_STATUS (EFIAPI *ConnectDevicePath)(
2aacef
+                EFI_BOOT_MANAGER_POLICY_PROTOCOL *This,
2aacef
+                EFI_DEVICE_PATH *DevicePath,
2aacef
+                BOOLEAN Recursive);
2aacef
+        EFI_STATUS (EFIAPI *ConnectDeviceClass)(
2aacef
+                EFI_BOOT_MANAGER_POLICY_PROTOCOL *This,
2aacef
+                EFI_GUID *Class);
2aacef
+};
2aacef
+#endif