From patchwork Wed Jun 24 19:48:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 50298 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 00A9B228FC for ; Wed, 24 Jun 2015 19:48:46 +0000 (UTC) Received: by laka10 with SMTP id a10sf13420204lak.2 for ; Wed, 24 Jun 2015 12:48:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=hwTv2IR+UH23D/AUZmSQ3qUttyCscEw6RyQrdZLvTR8=; b=ezVntVR1bMnKSWtviJ0OsCwHq+c6/v4nr1nYJ7Ur3x5B3hE2UjIAe7muiTHkTxeTU8 fy7DQei4UY4vSEce8h6kkUJYq6OpquO3WXl6Zjhwby8jCFKIWGoIs9g9QYdQEiM0KYbJ za4jnd/mxp5+lnR42r2C/R/gAQAdAYXjyzkTtryYhzqCjYhwUi+/JedpZwrQeL642eER YuJNsA3gzj2tPyWZTvK749Lr5Cba3PT8z0VCyqh9dKZUPl3miZ4k/uc2ASNYxhlCfsZ5 XOUX5ytqixAgttdvEAhrzELXIhf4FYlkYQNn+JIr86ZK3fLaKOEvZjwW/SCPvwJoi0Bd 9Xcw== X-Gm-Message-State: ALoCoQkN7JfUvwTvsahPR9NJFKFNgfjv89wSZAh8F/o2gdGiwQT2MYkogQ8P+Tne09lRlvCsudun X-Received: by 10.194.81.136 with SMTP id a8mr6752889wjy.2.1435175324785; Wed, 24 Jun 2015 12:48:44 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.105 with SMTP id x9ls263635laj.11.gmail; Wed, 24 Jun 2015 12:48:44 -0700 (PDT) X-Received: by 10.152.7.65 with SMTP id h1mr8140890laa.33.1435175324601; Wed, 24 Jun 2015 12:48:44 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id dx9si22797613lac.160.2015.06.24.12.48.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jun 2015 12:48:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lagx9 with SMTP id x9so32455101lag.1 for ; Wed, 24 Jun 2015 12:48:44 -0700 (PDT) X-Received: by 10.112.220.7 with SMTP id ps7mr41059929lbc.72.1435175324475; Wed, 24 Jun 2015 12:48:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp124177lbb; Wed, 24 Jun 2015 12:48:43 -0700 (PDT) X-Received: by 10.107.169.234 with SMTP id f103mr7244460ioj.42.1435175322693; Wed, 24 Jun 2015 12:48:42 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id ie6si2275729igb.37.2015.06.24.12.48.41 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 24 Jun 2015 12:48:42 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Z7qeq-0003hA-As; Wed, 24 Jun 2015 19:48:28 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Z7qep-0003h4-Ja for edk2-devel@lists.sourceforge.net; Wed, 24 Jun 2015 19:48:27 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.212.181 as permitted sender) client-ip=209.85.212.181; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wi0-f181.google.com; Received: from mail-wi0-f181.google.com ([209.85.212.181]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1Z7qeo-0006z5-GC for edk2-devel@lists.sourceforge.net; Wed, 24 Jun 2015 19:48:27 +0000 Received: by wiga1 with SMTP id a1so145179355wig.0 for ; Wed, 24 Jun 2015 12:48:20 -0700 (PDT) X-Received: by 10.180.11.225 with SMTP id t1mr7785323wib.94.1435175300455; Wed, 24 Jun 2015 12:48:20 -0700 (PDT) Received: from localhost.localdomain ([185.13.106.93]) by mx.google.com with ESMTPSA id a9sm4044734wiv.13.2015.06.24.12.48.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Jun 2015 12:48:19 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, lersek@redhat.com, olivier.martin@arm.com, jordan.l.justen@intel.com, jeff.fan@intel.com Date: Wed, 24 Jun 2015 21:48:14 +0200 Message-Id: <1435175294-21718-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <558AC496.9050508@redhat.com> References: <558AC496.9050508@redhat.com> X-Spam-Score: -1.4 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record 0.1 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1Z7qeo-0006z5-GC Subject: [edk2] [RFC PATCH] IntelFrameworkModulePkg: signal end-of-DXE event upon platform BDS invocation X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 According to paragraph 5.1.2.1 of the PI spec vol 2 version 1.4, the EFI_END_OF_DXE_EVENT_GUID event must be signalled prior to invoking any UEFI drivers, applications, or connecting consoles. This implements the event signalling in a new GenericBdsLib function BdsLibSignalEndOfDxeEvent (), and adds the invocation to BdsEntry () right before the point where it hands over to PlatformBdsInit(). In order to retain the mandated ordering between saving the ACPI S3 script and signalling the EFI_END_OF_DXE_EVENT_GUID event, saving of the S3 script is moved to BdsLibSignalEndOfDxeEvent () as well, right before the event is signalled. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- I am having trouble wrapping my head around all the interdependencies, but I do think that this may be a feasible approach. IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h | 14 +++ IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c | 70 ++++++++++-- IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf | 1 + IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h | 1 + IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c | 3 + 5 files changed, 79 insertions(+), 10 deletions(-) diff --git a/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h b/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h index ecd68a003bbb..86cda6615bf7 100644 --- a/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h +++ b/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h @@ -1110,5 +1110,19 @@ DisableQuietBoot ( VOID ); + +/** + Signal the event EFI_END_OF_DXE_EVENT_GUID as specified by the PI spec + vol 2 version 1.4 paragraph 5.1.2.1 + + @retval EFI_SUCCESS The event was signalled successfully + +**/ +EFI_STATUS +EFIAPI +BdsLibSignalEndOfDxeEvent ( + VOID + ); + #endif diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c index e02a71015edc..d84b0c1a453b 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c @@ -2233,7 +2233,6 @@ BdsLibBootViaBootOption ( EFI_DEVICE_PATH_PROTOCOL *FilePath; EFI_LOADED_IMAGE_PROTOCOL *ImageInfo; EFI_DEVICE_PATH_PROTOCOL *WorkingDevicePath; - EFI_ACPI_S3_SAVE_PROTOCOL *AcpiS3Save; LIST_ENTRY TempBootLists; EFI_BOOT_LOGO_PROTOCOL *BootLogo; @@ -2241,15 +2240,6 @@ BdsLibBootViaBootOption ( *ExitData = NULL; // - // Notes: this code can be remove after the s3 script table - // hook on the event EVT_SIGNAL_READY_TO_BOOT or - // EVT_SIGNAL_LEGACY_BOOT - // - Status = gBS->LocateProtocol (&gEfiAcpiS3SaveProtocolGuid, NULL, (VOID **) &AcpiS3Save); - if (!EFI_ERROR (Status)) { - AcpiS3Save->S3Save (AcpiS3Save, NULL); - } - // // If it's Device Path that starts with a hard drive path, append it with the front part to compose a // full device path // @@ -4363,3 +4353,63 @@ BdsLibUpdateFvFileDevicePath ( } return EFI_NOT_FOUND; } + +/** + An empty function to pass error checking of CreateEventEx (). + + @param Event Event whose notification function is being invoked. + @param Context Pointer to the notification function's context, + which is implementation-dependent. + +**/ +STATIC VOID +EFIAPI +BdsEmptyCallbackFunction ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ +} + +/** + Signal the event EFI_END_OF_DXE_EVENT_GUID as specified by the PI spec + vol 2 version 1.4 paragraph 5.1.2.1 + + @retval EFI_SUCCESS The event was signalled successfully + +**/ +EFI_STATUS +EFIAPI +BdsLibSignalEndOfDxeEvent ( + VOID + ) +{ + EFI_ACPI_S3_SAVE_PROTOCOL *AcpiS3Save; + EFI_EVENT EndOfDxeEvent; + EFI_STATUS Status; + + // + // Save the S3 resume script before signalling the end-of-DXE event. + // + Status = gBS->LocateProtocol (&gEfiAcpiS3SaveProtocolGuid, NULL, (VOID **) &AcpiS3Save); + if (!EFI_ERROR (Status)) { + AcpiS3Save->S3Save (AcpiS3Save, NULL); + } + + // + // Signal EndOfDxe PI Event + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + BdsEmptyCallbackFunction, + NULL, + &gEfiEndOfDxeEventGroupGuid, + &EndOfDxeEvent + ); + if (!EFI_ERROR (Status)) { + gBS->SignalEvent (EndOfDxeEvent); + } + + return Status; +} diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf b/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf index 5381e331ff8c..42ac1185f3ab 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf @@ -104,6 +104,7 @@ [Guids] ## SOMETIMES_CONSUMES ## Variable:L"LegacyDevOrder" gEfiLegacyDevOrderVariableGuid gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID + gEfiEndOfDxeEventGroupGuid [Protocols] gEfiSimpleFileSystemProtocolGuid ## SOMETIMES_CONSUMES diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h b/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h index c32579bfc577..658097ec22ea 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h @@ -52,6 +52,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c index ae7ad2153c51..0413d34fce02 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c @@ -623,6 +623,9 @@ BdsEntry ( InitializeLanguage (TRUE); InitializeFrontPage (TRUE); + Status = BdsLibSignalEndOfDxeEvent (); + ASSERT_EFI_ERROR (Status); + // // Do the platform init, can be customized by OEM/IBV //