From patchwork Fri Apr 8 09:44:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 65370 Delivered-To: patch@linaro.org Received: by 10.112.43.237 with SMTP id z13csp569173lbl; Fri, 8 Apr 2016 02:45:37 -0700 (PDT) X-Received: by 10.98.67.67 with SMTP id q64mr11535870pfa.44.1460108733766; Fri, 08 Apr 2016 02:45:33 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id xd4si11226pab.110.2016.04.08.02.45.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Apr 2016 02:45:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CB11F1A1FBD; Fri, 8 Apr 2016 02:45:30 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com [IPv6:2a00:1450:400c:c09::22e]) (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 EF2FB1A1EA0 for ; Fri, 8 Apr 2016 02:45:28 -0700 (PDT) Received: by mail-wm0-x22e.google.com with SMTP id u206so15472462wme.1 for ; Fri, 08 Apr 2016 02:45:28 -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=PWwi6b1+Xgb57EFfpMxrlpo4O2CBwmh7vxYo+uMnoYw=; b=jGT6va2Oi854P/4CHZETfBmpcyRVpJnTywaEOoCOsBnK5Jqi49JOK24uHN88seohlw kE2+W06Tj+2w3SQr2YJ0VG3I+YXp1uQcT9jIsKBU2dn8znSzY/9gOuHBBaje6muirMCh Xi+5lKGkPwLHRWf6qGjyn2SmqwPLX/MjY3Y5Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PWwi6b1+Xgb57EFfpMxrlpo4O2CBwmh7vxYo+uMnoYw=; b=E0j85KDYH3FssfIVV3f0x4zToFTaes00z4mNNb2aDH4J4nHmybrucuPwJVcjnbZrBf goPGRYRTWG6uETy/ltTUIHorHCCm0H8nTIy/L2ECoK6uhGAepavs+QZk5FfjUzvjArkP gCDQEFW5KpTpliCwGulLE/lDIYIpHY3nvC/BDXlXhF0NHoZMAHBmAinBtPw1aXTsXkn9 yx7EaVWuFGfT6ntoRVvPvJ6gGm246dU2zkw7SW9AiQY8ZfVd5dysdrY70PXQMchf3dsO OQw7OpS/GqlboAfSGDD1CJ54I8OGXDkphB0hQw1p9ELP0o3UzuGWjkYxG+ekx3bB8pFt sPbw== X-Gm-Message-State: AD7BkJLoHgkm14la/rON5alyJ3YjdF6YWhd8K2uS/s5PJx8WO/mHJDK6y3ytgSoE5XCyi60l X-Received: by 10.194.239.99 with SMTP id vr3mr8343598wjc.135.1460108727676; Fri, 08 Apr 2016 02:45:27 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id s10sm9710681wjp.3.2016.04.08.02.45.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Apr 2016 02:45:26 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Fri, 8 Apr 2016 11:44:53 +0200 Message-Id: <1460108711-12122-7-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1460108711-12122-1-git-send-email-ard.biesheuvel@linaro.org> References: <1460108711-12122-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 06/24] ArmVirtPkg/ArmVirtPsciResetSystemLib: move to FDT client protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Instead of relying on VirtFdtDxe to detect the PSCI method, move our EfiResetSystemLib to the FDT client protocol to interrogate the device tree directly. Since this library is only consumed by EmbeddedPkg/ResetRuntimeDxe, and considering that the PCD is no longer set, and even removed completely in a subsequent patch, this conversion is guaranteed to be safe. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.c | 31 ++++++++++++++++++-- ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.inf | 9 ++++-- 2 files changed, 34 insertions(+), 6 deletions(-) -- 2.5.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.c b/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.c index 88332f56fd9c..189519ccccda 100644 --- a/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.c +++ b/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.c @@ -26,19 +26,44 @@ #include #include #include +#include #include +#include + STATIC UINT32 mArmPsciMethod; RETURN_STATUS -EFIAPI ArmPsciResetSystemLibConstructor ( VOID ) { - mArmPsciMethod = PcdGet32 (PcdArmPsciMethod); - return RETURN_SUCCESS; + EFI_STATUS Status; + FDT_CLIENT_PROTOCOL *FdtClient; + CONST VOID *Prop; + + Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL, (VOID **)&FdtClient); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = FdtClient->FindCompatibleNodeProperty (FdtClient, "arm,psci-0.2", + "method", &Prop, NULL); + if (EFI_ERROR (Status)) { + return Status; + } + + if (AsciiStrnCmp (Prop, "hvc", 3) == 0) { + mArmPsciMethod = 1; + } else if (AsciiStrnCmp (Prop, "smc", 3) == 0) { + mArmPsciMethod = 2; + } else { + DEBUG ((EFI_D_ERROR, "%a: Unknown PSCI method \"%a\"\n", __FUNCTION__, + Prop)); + return EFI_NOT_FOUND; + } + return EFI_SUCCESS; } /** diff --git a/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.inf b/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.inf index 86d6104ca258..875591766d04 100644 --- a/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.inf +++ b/ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.inf @@ -20,7 +20,7 @@ [Defines] FILE_GUID = c81d76ed-66fa-44a3-ac4a-f163120187a9 MODULE_TYPE = BASE VERSION_STRING = 1.0 - LIBRARY_CLASS = EfiResetSystemLib + LIBRARY_CLASS = EfiResetSystemLib|DXE_DRIVER DXE_RUNTIME_DRIVER CONSTRUCTOR = ArmPsciResetSystemLibConstructor [Sources] @@ -38,5 +38,8 @@ [LibraryClasses] ArmSmcLib ArmHvcLib -[Pcd] - gArmVirtTokenSpaceGuid.PcdArmPsciMethod +[Protocols] + gFdtClientProtocolGuid ## CONSUMES + +[Depex] + gFdtClientProtocolGuid