From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::243; helo=mail-wm0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::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 D1D8221FCA285 for ; Wed, 1 Nov 2017 06:08:04 -0700 (PDT) Received: by mail-wm0-x243.google.com with SMTP id m72so4739104wmc.1 for ; Wed, 01 Nov 2017 06:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bF8nojY0qlyzrG7eynH7zGNcgV8CfWpU1OP5pKokWwk=; b=YmFeNjBMwo5/f/w8jW9juVRCWQ4+12rdh23cjeWAJXgLMEbQVGai+9Fsdy6Ra+XGdY FI80/qyuUjoT7YlFgsPtzL6LnxqeFKnf64jiPNjwbQEEYGDEimgLzovPOEwCcmBX6Blm 3mCzY4zcuiH+ilfJ59yZxPX+yRkfmp7hW5sEA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bF8nojY0qlyzrG7eynH7zGNcgV8CfWpU1OP5pKokWwk=; b=EQmHsRLZ+EtarB073WwDygR6xNWLk8SbsMmm8+MT7bdqgeM0jvbYp9KcSOVd/SxWW6 Tau8sEMcVXeFDYf3kEhavgAlCZYXHj2CalgSGH7vuYgWx27bE49yoSQi2NHTBQlcG+/6 +uo9GOpJXtWxs55JydPMfbaH02z45s92zEn4CkPhSD/Xi2XoKvA3uyUZVDIGQ2PtWp28 QUfphRctW1D4E9Ph7Bc7gxCkmW3/A1pBgsCMlWHxAOf1zidDrgXW2p1nwJ7LQa6Q/LA1 IZz9D/ypCuqaiQJHKu079D2MsncSj8NJmSB3tkQSOe2wPzLQPp/3clD2EpBTWcnLHoF7 sfpQ== X-Gm-Message-State: AMCzsaXVa7xflehCyYBN+YX1formJekAg64ZywsTTU77PLSxYqG+8WTM Lk2tQEEGYtUuPQf10Fd4rAD9/lSHQME= X-Google-Smtp-Source: ABhQp+SgNoy2in+iFTVOvV2g15dGfrnrMPuogaDSXdGy2/ZfoKO8xXzquIAbtAT/EnCW1fX1ycNXLA== X-Received: by 10.28.209.200 with SMTP id i191mr209731wmg.156.1509541915732; Wed, 01 Nov 2017 06:11:55 -0700 (PDT) Received: from localhost.localdomain ([105.129.222.2]) by smtp.gmail.com with ESMTPSA id o13sm636749wrc.10.2017.11.01.06.11.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Nov 2017 06:11:54 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Cc: daniel.thompson@linaro.org, Ard Biesheuvel Date: Wed, 1 Nov 2017 13:11:45 +0000 Message-Id: <20171101131145.16459-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171101131145.16459-1-ard.biesheuvel@linaro.org> References: <20171101131145.16459-1-ard.biesheuvel@linaro.org> Subject: [PATCH 2/2] ArmPlatformPkg/PlatformPeim: allow PlatformPeiLib to set the boot mode 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: Wed, 01 Nov 2017 13:08:05 -0000 The current interdepencies between the PrePeiCore SEC module, the platform PEIM and ArmPlatformLib is a bit awkward: due to the fact that ArmPlatformLib is also used by SEC modules, we cannot use PEI specific facilities in the implementation of ArmPlatformGetBootMode. However, given that we call that library function /after/ invoking PlatformPeiLib, there is no way for that library to set the boot mode other than resorting to tricks like notification callbacks on arbitrary unrelated events. ArmPlatformLib should probably be phased out anyway, given its quirky nature, but for now, let's fix this particular issue by deferring the call to PlatformPeim() to after the point where we set the boot mode by calling ArmPlatformGetBootMode (). While we're at it, clean up the code slightly by using PeiServicesLib instead of doing double pointer dereferencing. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmPlatformPkg/PlatformPei/PlatformPeim.c | 12 +++++++----- ArmPlatformPkg/PlatformPei/PlatformPeim.inf | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ArmPlatformPkg/PlatformPei/PlatformPeim.c b/ArmPlatformPkg/PlatformPei/PlatformPeim.c index e4535250c245..14f301e947a8 100644 --- a/ArmPlatformPkg/PlatformPei/PlatformPeim.c +++ b/ArmPlatformPkg/PlatformPei/PlatformPeim.c @@ -83,21 +83,23 @@ InitializePlatformPeim ( ) { EFI_STATUS Status; - UINTN BootMode; + EFI_BOOT_MODE BootMode; DEBUG ((EFI_D_LOAD | EFI_D_INFO, "Platform PEIM Loaded\n")); + Status = PeiServicesSetBootMode (ArmPlatformGetBootMode ()); + ASSERT_EFI_ERROR (Status); + PlatformPeim (); - BootMode = ArmPlatformGetBootMode (); - Status = (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode); + Status = PeiServicesGetBootMode (&BootMode); ASSERT_EFI_ERROR (Status); - Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListBootMode); + Status = PeiServicesInstallPpi (&mPpiListBootMode); ASSERT_EFI_ERROR (Status); if (BootMode == BOOT_IN_RECOVERY_MODE) { - Status = (**PeiServices).InstallPpi (PeiServices, &mPpiListRecoveryBootMode); + Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode); ASSERT_EFI_ERROR (Status); } diff --git a/ArmPlatformPkg/PlatformPei/PlatformPeim.inf b/ArmPlatformPkg/PlatformPei/PlatformPeim.inf index f466c1412ad3..21701cdc0731 100644 --- a/ArmPlatformPkg/PlatformPei/PlatformPeim.inf +++ b/ArmPlatformPkg/PlatformPei/PlatformPeim.inf @@ -43,6 +43,7 @@ [LibraryClasses] HobLib ArmPlatformLib PlatformPeiLib + PeiServicesLib [Ppis] gEfiPeiMasterBootModePpiGuid # PPI ALWAYS_PRODUCED -- 2.11.0