From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Leif Lindholm <leif.lindholm@linaro.org>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
Laszlo Ersek <lersek@redhat.com>
Subject: Re: [PATCH] EmbeddedPkg: add driver to set graphical/serial console preference
Date: Fri, 20 Oct 2017 15:11:37 +0100 [thread overview]
Message-ID: <CAKv+Gu-RU+i=G5uoOD4GqmxObXJZr_GYGgpSVD2d9svwRhoSYg@mail.gmail.com> (raw)
In-Reply-To: <20171020135033.egr65y3fdgn6jfht@bivouac.eciton.net>
On 20 October 2017 at 14:50, Leif Lindholm <leif.lindholm@linaro.org> 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 <ard.biesheuvel@linaro.org>
>> ---
>> 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 <IndustryStandard/Acpi.h>
>> +#include <libfdt.h>
>> +#include <Library/BaseLib.h>
>> +#include <Library/DebugLib.h>
>> +#include <Library/DevicePathLib.h>
>> +#include <Library/HiiLib.h>
>> +#include <Library/UefiBootServicesTableLib.h>
>> +#include <Library/UefiBootServicesTableLib.h>
>> +#include <Library/UefiDriverEntryPoint.h>
>> +#include <Library/UefiLib.h>
>> +#include <Library/UefiRuntimeServicesTableLib.h>
>> +
>> +#include <Protocol/AcpiTable.h>
>> +#include <Protocol/AcpiSystemDescriptionTable.h>
>> +
>> +#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 <leif.lindholm@linaro.org>
>
> 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.
prev parent reply other threads:[~2017-10-20 14:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-20 13:33 [PATCH] EmbeddedPkg: add driver to set graphical/serial console preference Ard Biesheuvel
2017-10-20 13:40 ` Ard Biesheuvel
2017-10-20 13:50 ` Leif Lindholm
2017-10-20 14:11 ` Ard Biesheuvel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKv+Gu-RU+i=G5uoOD4GqmxObXJZr_GYGgpSVD2d9svwRhoSYg@mail.gmail.com' \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox