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:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::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 32B632034EE1B for ; Sat, 4 Nov 2017 22:39:54 -0700 (PDT) Received: by mail-wr0-x243.google.com with SMTP id 4so1496121wrt.0 for ; Sat, 04 Nov 2017 22:43:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=vFrBTLVLleJy272ppHWCT6iWOs/SX7mu6GTGVWKdPug=; b=b8MCP6dIHPqwonQ0vb0zSRvJP+OcaKisOUcCZgH1g5EeFKcDrcbBJPbQz6Vu0ZaVGm Wis9wfn1Tj1Y6t3mNr602PSvgz92MHKRRW8BaRXA8HeP0Kz3NcNosCtP3uF1LamaYH8Z CdEjb59r0qU8Zs6DeVn/s2dKXAlZDFWcxFIvk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=vFrBTLVLleJy272ppHWCT6iWOs/SX7mu6GTGVWKdPug=; b=qO3cKdsYZMuxlD0lrmAPCbdgxpau0R/LymMvA5Nn1S8XfT9wBZZB9KaNqEmRFmH8f6 aP6Vcgr7oSHNqFjWLfBzoqjnX3qkbY7y7A8GrvydJpHBx/7kWPf9pHEgLAfIOTUr2B/M e14uMgtx6J2QgJacpHtNDqFANAPDvgJGkDbaGp/93l1czngtv6DZKYgadsCuVWVhKFje 8Nhn2mW5FFg+xTgojeB0P8MLJT9UG4hzlYV3h9A1dGr006cId3jIYlI8oyRASOvPkNrX 2o+u/6hwfpvzM10ClRD5HLIfm4/27BrB8aP6HJgPxKZDaPnCwoUbOJmPI48KRTZRL3UT +G+w== X-Gm-Message-State: AMCzsaWnvD1WbwRBALpRlnFZoOBf8Z1JbPdET6BrQJiY/4SmNs+a6iaE IxkV2iPQrEjsFwDvfE0WetcA0Q== X-Google-Smtp-Source: ABhQp+TZljrYiqxNVrNoLIS+gNpTMWWvt+HPbiHgwDF5QHAWdKmuxR9M7+HF7oQNsSf5isFqUan2qg== X-Received: by 10.223.196.156 with SMTP id m28mr10358504wrf.67.1509860630585; Sat, 04 Nov 2017 22:43:50 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id f27sm19470312wrf.63.2017.11.04.22.43.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 Nov 2017 22:43:49 -0700 (PDT) Date: Sun, 5 Nov 2017 05:43:47 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org, daniel.thompson@linaro.org Message-ID: <20171105054347.r2ccce3g7jtqqj2z@bivouac.eciton.net> References: <20171101131145.16459-1-ard.biesheuvel@linaro.org> <20171101131145.16459-3-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20171101131145.16459-3-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [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: Sun, 05 Nov 2017 05:39:55 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Nov 01, 2017 at 01:11:45PM +0000, Ard Biesheuvel wrote: > 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, Yes, it should. > 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 If you move that one up one line: Reviewed-by: Leif Lindholm > > [Ppis] > gEfiPeiMasterBootModePpiGuid # PPI ALWAYS_PRODUCED > -- > 2.11.0 >