From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::243; helo=mail-it0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x243.google.com (mail-it0-x243.google.com [IPv6:2607:f8b0:4001:c0b::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2D60D2034717F for ; Fri, 20 Oct 2017 07:07:59 -0700 (PDT) Received: by mail-it0-x243.google.com with SMTP id f187so14134240itb.1 for ; Fri, 20 Oct 2017 07:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ZWx4GMsYa+0F/jlO5ivTRVuOZBF6tas+WjgQAE/Iwi4=; b=kECsqKhLT6JW2TN3AGgt3nmvURGz5B1DUe06EueriGFAA5vl9j2X3z1uuX5ck1xLYf yWvUfs/bg0+Lxg0/1d7GNNg1ZfcmsjB5YB5A4TveEgjcikrH2chZc17guyc0e5ie8wLb qOwUnN2wYC9VigmbeaxK7fJyP1OiaKSeG/64Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ZWx4GMsYa+0F/jlO5ivTRVuOZBF6tas+WjgQAE/Iwi4=; b=mUGul/duu/I1R5224KaVlVcrwiHZzpag5IK2CznzbmId5KOtVU7Bml4Qkx9TgWsyw9 dlIgdnrbyuigjNfa7k6Tz05Ybf4SNMpX7V8208i2CZOdeMq1hl3KFhvsewK/KkxLFFiH 5+We7hh/op5rui8IKr69z31GS5U4/QrVf0KVRw5mdrRwMdVOmYRp/Jyc/k/hrSId/Mxs mZh5fwmwLfQnY0vXbKKx1oWTqoqJjZi0WcNZxabHM2S5EQ/h6Mh6y9Qbz+brQuOSfyUu x5rtq5IRwi/iRB5aty7C+grNw9yuWiaTlY/7rqpvvvLSbd9YLGwvfkfG0bcri71YoAQc fU8Q== X-Gm-Message-State: AMCzsaXwPwNq4AJiECAd4YdOkNjHc7e98tNtnwHHWJOzqxSqARh4VglL BYcy8NG55gT/BFaE87C5DcDZ8Hwx6TqmVLalL8t1tw== X-Google-Smtp-Source: ABhQp+RSZC5qdVAWiwzkcLVKeBQCrMxaGla0rt3kJxXFbl9wZjqVxVBph93NgoqV/R79zeTP//dXHEiRRur6CL9WLN8= X-Received: by 10.36.31.212 with SMTP id d203mr2549979itd.48.1508508697957; Fri, 20 Oct 2017 07:11:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.131.167 with HTTP; Fri, 20 Oct 2017 07:11:37 -0700 (PDT) In-Reply-To: <20171020135033.egr65y3fdgn6jfht@bivouac.eciton.net> References: <20171020133337.23372-1-ard.biesheuvel@linaro.org> <20171020135033.egr65y3fdgn6jfht@bivouac.eciton.net> From: Ard Biesheuvel Date: Fri, 20 Oct 2017 15:11:37 +0100 Message-ID: To: Leif Lindholm Cc: "edk2-devel@lists.01.org" , Laszlo Ersek Subject: Re: [PATCH] EmbeddedPkg: add driver to set graphical/serial console preference X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Oct 2017 14:07:59 -0000 Content-Type: text/plain; charset="UTF-8" On 20 October 2017 at 14:50, Leif Lindholm wrote: > On Fri, Oct 20, 2017 at 02:33:37PM +0100, Ard Biesheuvel wrote: >> Linux on ARM/arm64 will infer from the presence of a /chosen/stdout-path >> DT property or of a SPCR ACPI table that the primary console is the serial >> port, even if a graphical console is available as well. >> >> So let's introduce a driver that allows the user to set a preference >> between graphical and serial if both are available. If the preference >> is set to 'Graphical', and any GOP protocol instances have been installed >> by the time the ReadyToBoot event is signalled, remove the DT property >> and the table entirely. >> >> Contributed-under: TianoCore Contribution Agreement 1.1 >> Signed-off-by: Ard Biesheuvel >> --- >> EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c | 284 ++++++++++++++++++++ >> EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.h | 31 +++ >> EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf | 62 +++++ >> EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefHii.uni | 27 ++ >> EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefHii.vfr | 51 ++++ >> 5 files changed, 455 insertions(+) >> >> diff --git a/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c b/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c >> new file mode 100644 >> index 000000000000..cabe4f652cf5 >> --- /dev/null >> +++ b/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c >> @@ -0,0 +1,284 @@ >> +/** @file >> +* >> +* Copyright (c) 2017, Linaro, Ltd. All rights reserved. >> +* >> +* This program and the accompanying materials >> +* are licensed and made available under the terms and conditions of the BSD License >> +* which accompanies this distribution. The full text of the license may be found at >> +* http://opensource.org/licenses/bsd-license.php >> +* >> +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, >> +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. >> +* >> +**/ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> + >> +#include "ConsolePrefDxe.h" >> + >> +#define SPCR_SIG EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE >> + >> +extern UINT8 ConsolePrefHiiBin[]; >> +extern UINT8 ConsolePrefDxeStrings[]; >> + >> +typedef struct { >> + VENDOR_DEVICE_PATH VendorDevicePath; >> + EFI_DEVICE_PATH_PROTOCOL End; >> +} HII_VENDOR_DEVICE_PATH; >> + >> +STATIC HII_VENDOR_DEVICE_PATH mConsolePrefDxeVendorDevicePath = { >> + { >> + { >> + HARDWARE_DEVICE_PATH, >> + HW_VENDOR_DP, >> + { >> + (UINT8) (sizeof (VENDOR_DEVICE_PATH)), >> + (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) >> + } >> + }, >> + CONSOLE_PREF_FORMSET_GUID >> + }, >> + { >> + END_DEVICE_PATH_TYPE, >> + END_ENTIRE_DEVICE_PATH_SUBTYPE, >> + { >> + (UINT8) (END_DEVICE_PATH_LENGTH), >> + (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8) >> + } >> + } >> +}; >> + >> +STATIC EFI_EVENT mReadyToBootEvent; >> +STATIC UINTN mSpcrTableKey; >> + >> +STATIC >> +EFI_STATUS >> +InstallHiiPages ( >> + VOID >> + ) >> +{ >> + EFI_STATUS Status; >> + EFI_HII_HANDLE HiiHandle; >> + EFI_HANDLE DriverHandle; >> + >> + DriverHandle = NULL; >> + Status = gBS->InstallMultipleProtocolInterfaces (&DriverHandle, >> + &gEfiDevicePathProtocolGuid, >> + &mConsolePrefDxeVendorDevicePath, >> + NULL); >> + if (EFI_ERROR (Status)) { >> + return Status; >> + } >> + >> + HiiHandle = HiiAddPackages (&gConsolePrefFormSetGuid, >> + DriverHandle, >> + ConsolePrefDxeStrings, >> + ConsolePrefHiiBin, >> + NULL); >> + >> + if (HiiHandle == NULL) { >> + gBS->UninstallMultipleProtocolInterfaces (DriverHandle, >> + &gEfiDevicePathProtocolGuid, >> + &mConsolePrefDxeVendorDevicePath, >> + NULL); > > Something funky going on with indentation here. > > If you address that: > Reviewed-by: Leif Lindholm > > Thanks for putting this together. > Thanks. But it seems the SPCR handling is not robust yet: it worked with ArmVirtQemu, but not with a baremetal platform, due to dispatch order issues etc.