From patchwork Wed Nov 21 11:58:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 151670 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1828916ljp; Wed, 21 Nov 2018 03:58:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/VeNmiGTQ9D8lt0kxK/wPuMT+tl1/dHsm+V/qSKa0ZSXuSDRR1hjMEiKZbgJkruY1iSOMa+ X-Received: by 2002:a24:b641:: with SMTP id d1-v6mr4874108itj.133.1542801523886; Wed, 21 Nov 2018 03:58:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542801523; cv=none; d=google.com; s=arc-20160816; b=vdoOLhHOjy+R4JpXNx5+Ix4gGU+uPjlSwcl2J/+NGCMrLWdE/abZvcEInaLtvPk6xj Pbd4+z0/IqTXf/sefgMejyyc3tWbNOAPhl1EGXbJR7dgeCSwhZuHad/nTZEaPznlitJ7 7Tm593Dt9wpU7KZ+oUuIgX8GbjapeGkS/lgS+/y/6TtbXDFx1Ff6pHeZEoQkDgxdAOYI FDhRbK5JYyRi2MmyqEb79Sqxecw/65IrBCA441bAlG3ycXaWRQq1QH4FoA4yPbfa9d6d 5AihH90/XV0CTczQeRr+4BzYZSWoRRBepr1ND7i8P3uZBynNWCFgzE+/VaITdfOlgmui oCHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=yCbcs1MZPlanZLU4a+Bjy4oXVRw5Kf0gbqVlLQzlrbw=; b=WJvkkzoFNf3mgWM9Z1maHA+ukL642HHMd2qb5hqyxEjZob94DTzNsv+oGAsWh4DEuP q7aO3FHlBG8TqMHrs6U7KcjPvG3+m/NqQUMfHHDQEf2hfSASYr4cb2baHBhPHVW2UhWs hnQno/2S191c2SNC6CtW3/vy3sy/9VCpwvxlOlQmVTSMpJzoyO8FhwK+tpL2mapPZ0Cf BTUI7U7EBssbfx5ucJve6fC+8vxffAqUGHXhOqAg9JSe6wKQnUtYiE3a2HkK1erWQ0G3 s79Ijtgx8BfcBGVd2qFXSNy35USdvE4EexuqtndqzIME1TonfrEMT2Z6n/xGs0pmrCpn g7NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ncr0cGgd; 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 sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id u7si1242743iom.121.2018.11.21.03.58.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:58:43 -0800 (PST) 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 header.s=google header.b=Ncr0cGgd; 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 sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C05142194D3AE; Wed, 21 Nov 2018 03:58:41 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::541; helo=mail-ed1-x541.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) (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 2895C2119376C for ; Wed, 21 Nov 2018 03:58:40 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id b14so4656921edt.6 for ; Wed, 21 Nov 2018 03:58:40 -0800 (PST) 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=W2WZ4XhSXcF0kAyNl4/Jdv466whNrXqAiZVg6B20t4U=; b=Ncr0cGgdzjcXnEbRv2wDfsTTCR4omBZnBHBuxDNSqwed13zYKlNjmTCPN8W8ltTWD7 nQUh69W+zoWm4QsrJAab0XpqDYv37n09P40cdRkluS28FO17l+cL/ii5c+1R9Mtldnm4 V0yHB6utFzDSdNa4rYnI5J+kjAf0mpgLuxIzw= 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=W2WZ4XhSXcF0kAyNl4/Jdv466whNrXqAiZVg6B20t4U=; b=fnKZ4T5/KGQsc0/t+uCNiGMocdkV3RiaAU6q32Kp5a/Gc+eEvefq4O0/covJOK1Mfb CZbXQ8KIrjH09oJ8Kos3Coq5fsrSfSZMu0/37eK6Ixorq1Pihp4tz2GnAtpRQKDWup/W JYQQ1UUJWGaMgLhDzNLKs0c4wE1sBaySYsiP7Se1S+cJbFoDs7lVLSs7UF0q3M+SWXbs Kt+ncFW+C8nf9zHZHE7Uy1oHHUkCcVUbPPCxpMoTfbANh2gGoxEQbzAaIJzbcRxuYy6n qP4PEd/BtuYiZhkQ45RTMHR21MHVY4cXjVdfTZCk2WCIsS9FORgikcGPGHWBK89OgVGO smUQ== X-Gm-Message-State: AGRZ1gISdMLoJKLm8jwwv72S7hEAv/2u/5iInTPsCWyCCr3EFW5nbAAE lLcshPgHFlploAkN3WAsoEsnctDlRW8/Pg== X-Received: by 2002:a17:906:359b:: with SMTP id o27-v6mr4908190ejb.14.1542801518252; Wed, 21 Nov 2018 03:58:38 -0800 (PST) Received: from mba13.wifi.ns.nl (dhcp-077-251-017-237.chello.nl. [77.251.17.237]) by smtp.gmail.com with ESMTPSA id x90sm4090716ede.35.2018.11.21.03.58.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:58:37 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 21 Nov 2018 12:58:24 +0100 Message-Id: <20181121115828.3026-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181121115828.3026-1-ard.biesheuvel@linaro.org> References: <20181121115828.3026-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 1/5] ArmPlatformPkg/NorFlashDxe: prepare for devicepath format change X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lersek@redhat.com, nariman.poushin@linaro.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" A subsequent patch will change the layout of devicepath nodes produced by this driver. In preparation, make some tweaks to the code to use a packed struct for the devicepath and to pass the device index to NorFlashCreateInstance(). These are cosmetic changes only, the resulting binaries should be identical. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek --- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c | 9 ++++++--- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Philippe Mathieu-Daudé diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c index 46e815beb343..53753a4721ac 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c @@ -82,7 +82,10 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = { { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, - { (UINT8)sizeof(VENDOR_DEVICE_PATH), (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8) } + { + (UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End)), + (UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End) >> 8) + } }, { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }, // GUID ... NEED TO BE FILLED }, @@ -99,7 +102,7 @@ NorFlashCreateInstance ( IN UINTN NorFlashDeviceBase, IN UINTN NorFlashRegionBase, IN UINTN NorFlashSize, - IN UINT32 MediaId, + IN UINT32 Index, IN UINT32 BlockSize, IN BOOLEAN SupportFvb, IN CONST GUID *NorFlashGuid, @@ -121,7 +124,7 @@ NorFlashCreateInstance ( Instance->Size = NorFlashSize; Instance->BlockIoProtocol.Media = &Instance->Media; - Instance->Media.MediaId = MediaId; + Instance->Media.MediaId = Index; Instance->Media.BlockSize = BlockSize; Instance->Media.LastBlock = (NorFlashSize / BlockSize)-1; diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h index 5c07694fbfaa..910681fd4412 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h @@ -122,10 +122,12 @@ typedef struct _NOR_FLASH_INSTANCE NOR_FLASH_INSTANCE; +#pragma pack(1) typedef struct { VENDOR_DEVICE_PATH Vendor; EFI_DEVICE_PATH_PROTOCOL End; } NOR_FLASH_DEVICE_PATH; +#pragma pack() struct _NOR_FLASH_INSTANCE { UINT32 Signature; From patchwork Wed Nov 21 11:58:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 151671 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1828941ljp; Wed, 21 Nov 2018 03:58:46 -0800 (PST) X-Google-Smtp-Source: AJdET5crirwzdCxYgoJZUzuWhujXJ6VrD6jVRIkel/n8ZkVtTYm50lGxHhBlkc4RWEE7JYW1SkhY X-Received: by 2002:a62:d504:: with SMTP id d4mr6493474pfg.38.1542801526565; Wed, 21 Nov 2018 03:58:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542801526; cv=none; d=google.com; s=arc-20160816; b=u+eeRbueQVShcy85ZJXEysxdv48wD8KEEbNVt/wDVeU6g+fNjsVboVlN37GjUS9mxo QTcySP90z16yI2ANNynHdBJTCoA0jBHDo4IZz1ZUP/lGRy2QLB5OrczML+FVEp940BQ/ 5zbtGVXzlPmyoccRfGMHqUygpCw+1AWznEip9MqL6KfOwh/B3HceM0k9NwytZgOGYLbk 3VaKHiTeganLYQ1PtCw2C1LJEJVhgMTeSIWT0eM1V3yr3Gjg4WIa4CuA3s5JN14UJFNi THV0Q6v7oxh8J5hhjD8gTQeawhGpIGqQAyI7xMXfgrf8ecCMW/JFbe5CQVmDok6NP1a+ Pv1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=nFgrfJuuTEBNJlVbmvRCk18GMsLHqOEDt7+hPN+ZrFI=; b=k6GZYe/KU/xC4jbcFve513lhLtT+eTanHNMFH0L1uaaWBpNSHr9XO0Amq30lameLea BrxG/CTuF0IumEYEJ5Es9QmbfneHzRkx/3gsRhELoJED5PjIDqmqJAE/DBC5a5QT2kU7 ubb2FTTG+BW1raqDwQ6uvDYA4+V++k2JwziqQrMIvCCKPJxbLHgK5m9m3Zg30X6hh+Mz kobR/soPsLobgbHFauONUVvpH0gOoVszY3MCTGm9bcVoOFeZWiR/sTtMPiY/Y8lQlLWh RKEaQfj5/sBkiejKWVot5kR0pZtpFSQxc7098H7EVIkvpspp9Tbd5ohxIYXEyFvng+Hl Y6TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=H66Pd+dA; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id c190-v6si16326123pfa.0.2018.11.21.03.58.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:58:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=H66Pd+dA; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id F26C121193781; Wed, 21 Nov 2018 03:58:43 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::543; helo=mail-ed1-x543.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) (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 630962119377D for ; Wed, 21 Nov 2018 03:58:41 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id h50so4660829ede.5 for ; Wed, 21 Nov 2018 03:58:41 -0800 (PST) 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=vWFOMqBVKz/PfsGLyHlpAU1qnj+bpsHP14OqCs/pMAw=; b=H66Pd+dAr9ZXoZJvsk5sXwzD+SN16OADRdcIDfNuaXibEGtpzpvcEobZvJT6n72Bjz Vw6P24Ck/Svx3dXyaeDLUIZ+3x2Ob0He1KUV5C/g+epmc3WvQUwu92FRyPlHPfPMKwGy 4rsD3ZiSCAHyIyatLWDB/ADulsFN9+6rRuIDM= 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=vWFOMqBVKz/PfsGLyHlpAU1qnj+bpsHP14OqCs/pMAw=; b=qKqHja/IommF7NYsSrRBaYk7DCy7QYzRiNneKkns3shqPCiaRO8lpu1HAaVeRjglA0 KbDaGFO7qBI/Rw+ZvEBdBWTPi4wS1vqLjfiUIhkgCHtZYwLiqVxf/VEcoDbB02wBjAau cAnIocfdbt3tRRsQS0AwmZaW4NXYW9rDn1c/UIyOB9QizMuqNu7IpC3W0DiRxOXTzGBC 7q/JCQcYWwohg9xVIlQh+AJfZeMDgupWmjKTGfHWVdYGx5GjRSXyZXq0BgUqRhPvOvyi JNXXO5Agy+zgM/lXe8J/TU9YuQHX78DHKywVzjDk+rN0BH7o9pUQz1kNXXX621oyNXP9 roMw== X-Gm-Message-State: AGRZ1gJT4s8hiFsQMvGb36s3WxJs96/vr3niH+hlEvRwpIMHDSDdOEo3 zzz+/HkGVXN4IYL+7bwhdi/i7djeOEe6nQ== X-Received: by 2002:a17:906:198b:: with SMTP id g11-v6mr4915984ejd.166.1542801519519; Wed, 21 Nov 2018 03:58:39 -0800 (PST) Received: from mba13.wifi.ns.nl (dhcp-077-251-017-237.chello.nl. [77.251.17.237]) by smtp.gmail.com with ESMTPSA id x90sm4090716ede.35.2018.11.21.03.58.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:58:38 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 21 Nov 2018 12:58:25 +0100 Message-Id: <20181121115828.3026-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181121115828.3026-1-ard.biesheuvel@linaro.org> References: <20181121115828.3026-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 2/5] ArmPlatformPkg/NorFlashDxe: use one GUID plus index to identify flash banks X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lersek@redhat.com, nariman.poushin@linaro.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Currently, each flash bank controlled by ArmPlatformPkg/NorFlashDxe has its own VendorHw GUID, and instances of NorFlashPlatformLib describe each bank to the driver, along with the GUID for each. This works ok for bare metal platforms, but it would be useful for virtual platforms if we could obtain this information from a device tree, which would require us to invent GUIDs on the fly, given that the 'cfi-flash' binding does not include a GUID. So instead, let's switch to a single GUID for all flash banks, and update the driver's device path handling to include an index to identify each bank uniquely. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek Reviewed-by: Leif Lindholm --- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c | 6 +++--- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Philippe Mathieu-Daudé diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c index 53753a4721ac..af40a4c88412 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c @@ -89,6 +89,7 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = { }, { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }, // GUID ... NEED TO BE FILLED }, + 0, // Index { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, @@ -105,7 +106,6 @@ NorFlashCreateInstance ( IN UINT32 Index, IN UINT32 BlockSize, IN BOOLEAN SupportFvb, - IN CONST GUID *NorFlashGuid, OUT NOR_FLASH_INSTANCE** NorFlashInstance ) { @@ -128,7 +128,8 @@ NorFlashCreateInstance ( Instance->Media.BlockSize = BlockSize; Instance->Media.LastBlock = (NorFlashSize / BlockSize)-1; - CopyGuid (&Instance->DevicePath.Vendor.Guid, NorFlashGuid); + CopyGuid (&Instance->DevicePath.Vendor.Guid, &gEfiCallerIdGuid); + Instance->DevicePath.Index = (UINT8)Index; Instance->ShadowBuffer = AllocateRuntimePool (BlockSize);; if (Instance->ShadowBuffer == NULL) { @@ -1314,7 +1315,6 @@ NorFlashInitialise ( Index, NorFlashDevices[Index].BlockSize, ContainVariableStorage, - &NorFlashDevices[Index].Guid, &mNorFlashInstances[Index] ); if (EFI_ERROR(Status)) { diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h index 910681fd4412..8886aa43d9f3 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h @@ -125,6 +125,7 @@ typedef struct _NOR_FLASH_INSTANCE NOR_FLASH_INSTANCE; #pragma pack(1) typedef struct { VENDOR_DEVICE_PATH Vendor; + UINT8 Index; EFI_DEVICE_PATH_PROTOCOL End; } NOR_FLASH_DEVICE_PATH; #pragma pack() From patchwork Wed Nov 21 11:58:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 151672 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1828979ljp; Wed, 21 Nov 2018 03:58:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/U0wQFxkRtF8NErNMQRWdb9otnUdeyITc71F/GrU7jAdAEfM2HJhit7/yzjbxl53f1zvltm X-Received: by 2002:a63:224f:: with SMTP id t15mr5649879pgm.69.1542801529302; Wed, 21 Nov 2018 03:58:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542801529; cv=none; d=google.com; s=arc-20160816; b=iI7QqMx6/DD1OgCEB2QKxv0ci9w2WdItLKcDJMEq8trHDBZGcMkZBqMDcRh6e675YV 35iIfHu3TBYp43n4hX8dOx4WLY8had4HCbJpO+MkLrN6lNC2cgLqMObBNweKfxI7qtdC qxnxLIriymOLIzaxM55nlZEHEJYjGZCW1rBW35NR0UUDMSi/P74+aA4wDiQgzQ5nmzSW zhFrfPJaukIiUOPnCf14swTV7Otr9v7K9iccf2dLkwHTn8jJS5mBzKesscquaMjQ8+UB GQc3zvCDl1UOey9JsC8Q3NjGz5dwCc30BH4pgZJndlP9XOq049FSGmJ5JCcEj7C51J0B ztGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=boDKu3FaX9LsAQe83vXPv2VCFMOf97lVmGs7ctcRlJw=; b=buTJLbrJjbC9707TpT6hjw/xZl/IdJzrrs0ysgFqDHtb4cdPKV94XXAaz/B/Ujm6n7 M1AC1rtTKxCFL89MHKV8aMFrsezp/RV2BAI8PF6tkJ511pSea9YNCExGBl0jbtIhoahV fqQi19UG6mC8tblOXKK66uAsNPVwpf8tWXX76QtLCEjHBojbmotT/EJPzNRELXNfk3/V Q/gasZyHPATuXtP0MVXskhKIC96o974nsHC81DUXxyBBoJZTcvQquFEjp1OaA7quKtNS FBaGGNZXiPvMMN1+5/tveFVN8Ggxy9kxVjl0Tzs8Xcw3jN42MqGXlw6yWaDgXPckfYRe yvCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HRw0SByh; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id q24si856340pls.325.2018.11.21.03.58.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:58:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HRw0SByh; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2DB3A2119376C; Wed, 21 Nov 2018 03:58:44 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::543; helo=mail-ed1-x543.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) (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 832BF2194D3B9 for ; Wed, 21 Nov 2018 03:58:42 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id d39so4631670edb.12 for ; Wed, 21 Nov 2018 03:58:42 -0800 (PST) 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=jDNsAZxgM2+Eo8XXOkKPVaoJBEcVPe4kmsU52EMbbEA=; b=HRw0SByhMpxzNH2rJ2StMZdM9UoI6yMXqOHHAXwPpjnIgwLEiUkj6/kqPw60cwuBk1 sAAvNL04GRg0C2M4tQxFmNl6WvR3iF60EywHqxSDMsNNsK9SeYCRA9nOtxd5/+sdYmpT XMXMbRBikSZjgBhOibYYoFsGidRxbOjbbQsXI= 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=jDNsAZxgM2+Eo8XXOkKPVaoJBEcVPe4kmsU52EMbbEA=; b=IPHuEY1E6sxd2RiSstMs58vyRm//VA53KK4yD8eU8ktRGlEOG7/ANDsSi3lS1en84g +zjMtdqpNTPIEN3rfwCe1RKE0Azcu3lSv/bsGGI+8/u49ccqYrtX5JkkVT5fYxLu1hi/ ZTvGEfcchap2sLCwc+IN7V7I7XJrikmWSUwqtyoWhgjO2Rm2+fs7CKZPgo1szmxDOtp6 R3xa+kOvUQ2L8Wq39eXOo673sXVL/qHZO42pyhnDku9kuJrOjDeBYQVxOV5iVR26J2VQ S9yi67SOM5rTHc5ciT5x5fqZauChj9o0nsLFa7kJ5ipMGOMgsyHfqD3rPLrzNdDL6NRy xR2Q== X-Gm-Message-State: AGRZ1gIUHpK2ud0zybr9FWObKHzCSdBp22WE3aosWI491HOuZ5hgxAh4 lTyD7H0Dki1AfOaWumM4AE2U7Eb0cb8txg== X-Received: by 2002:a17:906:195b:: with SMTP id b27-v6mr4900951eje.220.1542801520774; Wed, 21 Nov 2018 03:58:40 -0800 (PST) Received: from mba13.wifi.ns.nl (dhcp-077-251-017-237.chello.nl. [77.251.17.237]) by smtp.gmail.com with ESMTPSA id x90sm4090716ede.35.2018.11.21.03.58.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:58:39 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 21 Nov 2018 12:58:26 +0100 Message-Id: <20181121115828.3026-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181121115828.3026-1-ard.biesheuvel@linaro.org> References: <20181121115828.3026-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 3/5] ArmVirtPkg/FdtClientDxe: take DT node 'status' properties into account X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lersek@redhat.com, nariman.poushin@linaro.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" DT has a [pseudo-]standardized 'status' property that can be set on any node, and which signifies that a node should be treated as absent unless it is set to 'ok' or 'okay'. So take this into account when iterating over nodes. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/FdtClientDxe/FdtClientDxe.c | 38 +++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek Reviewed-by: Philippe Mathieu-Daudé diff --git a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c index fb6e0aeb9215..5bfde381ecd0 100644 --- a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c +++ b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c @@ -78,6 +78,33 @@ SetNodeProperty ( return EFI_SUCCESS; } +STATIC +BOOLEAN +IsNodeEnabled ( + INT32 Node + ) +{ + CONST CHAR8 *NodeStatus; + INT32 Len; + + // + // A missing status property implies 'ok' so ignore any errors that + // may occur here. If the status property is present, check whether + // it is set to 'ok' or 'okay', anything else is treated as 'disabled'. + // + NodeStatus = fdt_getprop (mDeviceTreeBase, Node, "status", &Len); + if (NodeStatus == NULL) { + return TRUE; + } + if (Len >= 5 && AsciiStrCmp (NodeStatus, "okay") == 0) { + return TRUE; + } + if (Len >= 3 && AsciiStrCmp (NodeStatus, "ok") == 0) { + return TRUE; + } + return FALSE; +} + STATIC EFI_STATUS EFIAPI @@ -101,6 +128,10 @@ FindNextCompatibleNode ( break; } + if (!IsNodeEnabled (Next)) { + continue; + } + Type = fdt_getprop (mDeviceTreeBase, Next, "compatible", &Len); if (Type == NULL) { continue; @@ -210,7 +241,6 @@ FindNextMemoryNodeReg ( { INT32 Prev, Next; CONST CHAR8 *DeviceType; - CONST CHAR8 *NodeStatus; INT32 Len; EFI_STATUS Status; @@ -223,10 +253,8 @@ FindNextMemoryNodeReg ( break; } - NodeStatus = fdt_getprop (mDeviceTreeBase, Next, "status", &Len); - if (NodeStatus != NULL && AsciiStrCmp (NodeStatus, "okay") != 0) { - DEBUG ((DEBUG_WARN, "%a: ignoring memory node with status \"%a\"\n", - __FUNCTION__, NodeStatus)); + if (!IsNodeEnabled (Next)) { + DEBUG ((DEBUG_WARN, "%a: ignoring disabled memory node\n", __FUNCTION__)); continue; } From patchwork Wed Nov 21 11:58:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 151673 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1829013ljp; Wed, 21 Nov 2018 03:58:52 -0800 (PST) X-Google-Smtp-Source: AJdET5fZu2MUoeUbpgICEf2D41gktI/LMH9oWFPhn8ZptRNYZEoIts2fE2/DkrJXqlXM1woTQKLz X-Received: by 2002:a62:8145:: with SMTP id t66mr6532382pfd.55.1542801532329; Wed, 21 Nov 2018 03:58:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542801532; cv=none; d=google.com; s=arc-20160816; b=m5qzHrrH4OW1yDD9QSqrpNhwveCjUwGxhondI5nJHyrtLGFrtDSzU0D2S/QXqfGJl5 O6siIbOnuJQOm3oCb/HZ+EoQ+rxRXSiPUWG3RDXaw6dI77mqKzKsrNVx03bjcVh7l+Nh BN9lMEPVqF0i3ZlOOen0znQ/weJlkHWl+WTcwgIUQz5ylgxnsfQm5JiWWH0OLOnAJN4C Wc+W5De7NfocF2V16uwUKlC4fWpQqkPNdbG2B0PP8Wr66NBVedCGvUobL0612Z/WLkLi UhpExtiL/5knylaQXbyw3BX+VRLSCaA/yjlR+p5A8QVhNawo/p5lEoabxP7uuAitGL4g qPVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=Wrr+gww9vlGJsiebKI2crB90CJb2UflLKUwli8zrWpw=; b=PHb5Zdk0n2d/1JnvnsiJVDZYQsW4PYv2ucTyX5KgIF2RCxnwDKiuiVGcBys9QfvLR3 Ix3CbiJz8LFXJT0HZX+YccsNE4ne7mNpe5qaeMq9p/PB8dnvKlx4p0WYX5BV33dRls/3 ENnv21llvxPkZdvY1orp7bD2EI1jGjbs9iFExSHcnaQ/DwrwPnrn04rP918kqL9kNu/C N+0Ch6lWh8HT3gyb3x+7vV4Tslv6w+WEHfABOrtcDWWsEMxWdUSIHrfBbR9qcT02nn5j nkDmIf33dfdHTOD4rJe5nWedrSZsUwhTcupViP4XWpS5oqXBcgN2EJdFWva8rgLWh4cD nMZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Np8+jRRv; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id g6si32684857pgr.472.2018.11.21.03.58.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:58:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Np8+jRRv; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 58E7D21193786; Wed, 21 Nov 2018 03:58:45 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::544; helo=mail-ed1-x544.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) (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 BB6032119377D for ; Wed, 21 Nov 2018 03:58:43 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id j6so4646337edp.9 for ; Wed, 21 Nov 2018 03:58:43 -0800 (PST) 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=4OacAZxi6bwjmYfaG2QlW79iKsCN+Q3rSHDaCWjt5+M=; b=Np8+jRRvLbwjY+1XDYo9rkMrap/RpKKULsXq37oWvteGS7qAiWjCi4V1wBfh8j+feR XaeaeLgsRCkw5Pmf4GwgIJi2Ez+YIQpEcneTMaqM+Sw4yS8QmKpz3/480BWrj60TSGXi yH5rJ20TYnwHfbDysI5tc65jT6GntzQkubJz0= 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=4OacAZxi6bwjmYfaG2QlW79iKsCN+Q3rSHDaCWjt5+M=; b=HCv2mIVU0tCkPVGrh+BXqRoTlxEjWPZcmSTXsEj7Jcf5OwTINsIjsEAMjSfB9mqUAT LoB4jLJ0BXg+UtegGVYHXKKGS2wVGhtSwx0DlVmUVPFRyIUKE/aTaDhKmSHS4Tx8mWUt 4QKl4K5qoGbM9cXuLLsnPgPN2P/7XamYu6ZmgW791EhLgOvAdtolRRK5SNWkRzJYSmPx FBlzb1gJx3bGFPBIIhOmFKA0oNSyieQf4Dtq6L9CPjSwumnbjHt19ttgCZxrwHRvo2T+ BuLAsI4D8jtKFyE7+lljr3NBWnBMNNveLOtFrfjCUuG27v6c81ToLTcQWB4vrOx9XmOu xjXQ== X-Gm-Message-State: AA+aEWbB9N5pI9I9XvGsxmkUCnqZ9E7hm6iCbz1LXWMv+X8L3H0iHh1B hmD8nYCRxYi653uX6DsFc+PWw7e7PB2SEQ== X-Received: by 2002:a50:aa31:: with SMTP id o46mr903937edc.23.1542801521970; Wed, 21 Nov 2018 03:58:41 -0800 (PST) Received: from mba13.wifi.ns.nl (dhcp-077-251-017-237.chello.nl. [77.251.17.237]) by smtp.gmail.com with ESMTPSA id x90sm4090716ede.35.2018.11.21.03.58.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:58:41 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 21 Nov 2018 12:58:27 +0100 Message-Id: <20181121115828.3026-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181121115828.3026-1-ard.biesheuvel@linaro.org> References: <20181121115828.3026-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 4/5] ArmVirtPkg/NorFlashQemuLib: discover NOR flash banks dynamically X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lersek@redhat.com, nariman.poushin@linaro.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" NorFlashQemuLib is one of the last remaining drivers in ArmVirtPkg that are not based on the device tree received from QEMU. For ArmVirtQemu, this does not really matter, given that the NOR flash banks are always the same: the PEI code is linked to execute in place from flash bank #0, and the fixed varstore PCDs refer to flash bank #1 directly. However, ArmVirtQemuKernel can execute at any offset, permitting it to be used as an intermediary loader when running QEMU with secure world emulation enabled, in which case NOR flash bank #0 is secure only and contains the secure world firmware. In this case, NorFlashQemuLib should not expose the first flash bank at all. To prevent introducing too much internal knowledge about which flash bank is accessible under which circumstances, let's switch to using the DTB to decide which flash banks to expose to the NOR flash driver. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c | 78 ++++++++++++++------ ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf | 12 +++ 2 files changed, 69 insertions(+), 21 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c index e3bbae5b06c5..2678f57eaaad 100644 --- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c +++ b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2014, Linaro Ltd. All rights reserved.
+ Copyright (c) 2014-2018, 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 @@ -12,13 +12,16 @@ **/ +#include +#include #include +#include + +#include #define QEMU_NOR_BLOCK_SIZE SIZE_256KB -#define QEMU_NOR0_BASE 0x0 -#define QEMU_NOR0_SIZE SIZE_64MB -#define QEMU_NOR1_BASE 0x04000000 -#define QEMU_NOR1_SIZE SIZE_64MB + +#define MAX_FLASH_BANKS 4 EFI_STATUS NorFlashPlatformInitialization ( @@ -28,21 +31,7 @@ NorFlashPlatformInitialization ( return EFI_SUCCESS; } -NOR_FLASH_DESCRIPTION mNorFlashDevices[] = { - { - QEMU_NOR0_BASE, - QEMU_NOR0_BASE, - QEMU_NOR0_SIZE, - QEMU_NOR_BLOCK_SIZE, - {0xF9B94AE2, 0x8BA6, 0x409B, {0x9D, 0x56, 0xB9, 0xB4, 0x17, 0xF5, 0x3C, 0xB3}} - }, { - QEMU_NOR1_BASE, - QEMU_NOR1_BASE, - QEMU_NOR1_SIZE, - QEMU_NOR_BLOCK_SIZE, - {0x8047DB4B, 0x7E9C, 0x4C0C, {0x8E, 0xBC, 0xDF, 0xBB, 0xAA, 0xCA, 0xCE, 0x8F}} - } -}; +NOR_FLASH_DESCRIPTION mNorFlashDevices[MAX_FLASH_BANKS]; EFI_STATUS NorFlashPlatformGetDevices ( @@ -50,7 +39,54 @@ NorFlashPlatformGetDevices ( OUT UINT32 *Count ) { + FDT_CLIENT_PROTOCOL *FdtClient; + INT32 Node; + EFI_STATUS Status; + EFI_STATUS FindNodeStatus; + CONST UINT32 *Reg; + UINT32 PropSize; + UINT32 Num; + UINT64 Base; + UINT64 Size; + + Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL, + (VOID **)&FdtClient); + ASSERT_EFI_ERROR (Status); + + Num = 0; + for (FindNodeStatus = FdtClient->FindCompatibleNode (FdtClient, + "cfi-flash", &Node); + !EFI_ERROR (FindNodeStatus) && Num < MAX_FLASH_BANKS; + FindNodeStatus = FdtClient->FindNextCompatibleNode (FdtClient, + "cfi-flash", Node, &Node)) { + + Status = FdtClient->GetNodeProperty (FdtClient, Node, "reg", + (CONST VOID **)&Reg, &PropSize); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: GetNodeProperty () failed (Status == %r)\n", + __FUNCTION__, Status)); + continue; + } + + ASSERT ((PropSize % (4 * sizeof (UINT32))) == 0); + + while (PropSize >= (4 * sizeof (UINT32)) && Num < MAX_FLASH_BANKS) { + Base = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[0])); + Size = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2])); + Reg += 4; + + mNorFlashDevices[Num].DeviceBaseAddress = (UINTN)Base; + mNorFlashDevices[Num].RegionBaseAddress = (UINTN)Base; + mNorFlashDevices[Num].Size = (UINTN)Size; + mNorFlashDevices[Num].BlockSize = QEMU_NOR_BLOCK_SIZE; + Num++; + + PropSize -= 4 * sizeof (UINT32); + } + } + *NorFlashDescriptions = mNorFlashDevices; - *Count = ARRAY_SIZE (mNorFlashDevices); + *Count = Num; + return EFI_SUCCESS; } diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf index 126d1671f544..d86ff36dbd58 100644 --- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf +++ b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf @@ -28,3 +28,15 @@ [Packages] MdePkg/MdePkg.dec ArmPlatformPkg/ArmPlatformPkg.dec + ArmVirtPkg/ArmVirtPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiBootServicesTableLib + +[Protocols] + gFdtClientProtocolGuid ## CONSUMES + +[Depex] + gFdtClientProtocolGuid From patchwork Wed Nov 21 11:58:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 151674 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1829057ljp; Wed, 21 Nov 2018 03:58:55 -0800 (PST) X-Google-Smtp-Source: AJdET5dwl/aEuIc5Bliq0zpIce/J37XMxdrR9KQ1vir2b9SeugFvRhNEaw0xZFaPXOgqOjhZ8VpD X-Received: by 2002:aa7:804e:: with SMTP id y14-v6mr6348185pfm.73.1542801535629; Wed, 21 Nov 2018 03:58:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542801535; cv=none; d=google.com; s=arc-20160816; b=PspMmJnqCj2YttOp+4J2whp2VuaXPR43U1p3wi05DSFNs9edEM+nNz8AQTAz23gkPH 6BYBfFH7sv9Ra4+eQyv9+AMVyeeET1LorBh4LsRfvc+TLmrh0kt6n2wJBRiyVLS0YN0y y2pdLs71vaKnfnwUSmrFc+HlLBnzWI1ta/jbPIP7Wx7d60LLsXcL8C2QyBi4DLIaOITA I8pb0IUqS9+ADZe6qJMIeKLbKM01soXmjLUXnqU6MLvnsL8Kd3yL3Stp9FWtg7s2ZkML 4RwqpL7ewLkDb850t4zy9x6KuiZzD2I3YL1Kjwm8ilBLsM5xplGyVYNMcdoaREmtsDH3 +hEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=MuuYuYp0ZGgwQryJX7WBouMuWc1Toe3XIY1JCn4Jpcw=; b=wKCMHj+xMfA1XG2MlP37W+1y314Xpw2kPYr6FkoH/yjk2XqBBJ/ZQEO2YHHS9t0ETS Ka5fqkfRJJJ/J+xtfXopzTwlSwaPTCkTqRrUAloGBndJOLLgm3VxHP+uxMaB/YhwYRnz h1+gUG0s4HbjZS7tj1Irh21xweQPoivL3J+2kLelvfzYDEG1ANpsqODlMYRXBVGgwH7G ANnyC5gwEXxg/LGG+PDg78rmZAqjGrHz02K1QV0vr/4HdXauhULV8tcXl6gLuPM0Smeh KtR2sOby1bXdrgfyeTM0y7HinRNyAxueKCoOjrh25Ca+8UsKPHqKuSj51z7tAm2zKval 7+Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kSNOkIys; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id 44si4171540plc.110.2018.11.21.03.58.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:58:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kSNOkIys; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9036021193780; Wed, 21 Nov 2018 03:58:47 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::541; helo=mail-ed1-x541.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) (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 051832119377D for ; Wed, 21 Nov 2018 03:58:45 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id y56so4633663edd.11 for ; Wed, 21 Nov 2018 03:58:44 -0800 (PST) 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=rPwfBOqdamYy20wgljlOy5SsBXVoWvejPOb00LUbO6E=; b=kSNOkIyslArxjoQrUx4xmzBprbQSbKe0jZK4DOW2VcDki48UU2LxYG2cidD/BQHwk7 JSHkQInDFcW3Z+MYi1AXif04mlVpnv7bevobO8bdjP0PwYCeWINoBEKxLVN/wssxDIsL 5DlQ9ky7u02mZVOec0uRcP6e4iS27U4rakDCM= 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=rPwfBOqdamYy20wgljlOy5SsBXVoWvejPOb00LUbO6E=; b=m0FKQsKXLziifJb6lmUwz1kJ4+JPnUxSUO+Gl4syD0tSfKlvKuv+zdQuX3rzGfy7XS 0elZcGJiYIbccpXJGRWffwVtgPZBOB3dXUW9xmBjMC4lFF4cldCAoJPHatgijYcgUZHi aE5ZeZsbQEJFV4Jvc3bbV504cIbmmHkeGpLdi3y0p0m/2NYr0w/jtb0ntOiXqQkOLv8M aCS8HhUpuH3hXv1X3tVizmgN62aI8FBl3AF6TLVh8usQeoWqzK8MYFQcVt9Jd6v3QJmj Y+bq7hIJ1fajSt0moXkYbYmflDRy9C431SOxRhb8H6XEpYw3a/Z7wB4qGR9GeoH5ifZl JpyQ== X-Gm-Message-State: AGRZ1gLwNkNpOpIdfl3n58LPOYKfP60OHuxf2yLS35MrnUznoRblWN+g 2OdlnXEMRit65MvrtrsqfFRa4x1cV8nFtg== X-Received: by 2002:a17:906:1f99:: with SMTP id t25-v6mr4932476ejr.36.1542801523247; Wed, 21 Nov 2018 03:58:43 -0800 (PST) Received: from mba13.wifi.ns.nl (dhcp-077-251-017-237.chello.nl. [77.251.17.237]) by smtp.gmail.com with ESMTPSA id x90sm4090716ede.35.2018.11.21.03.58.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:58:42 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 21 Nov 2018 12:58:28 +0100 Message-Id: <20181121115828.3026-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181121115828.3026-1-ard.biesheuvel@linaro.org> References: <20181121115828.3026-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 5/5] ArmPlatformPkg/NorFlashPlatformLib: remove unused Guid member from struct X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lersek@redhat.com, nariman.poushin@linaro.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" We no longer use per-instance GUIDs to identify NOR flash banks so there is no longer a need to define them. Drop the Guid member from the NOR_FLASH_DESCRIPTION type. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- This patch should not be merged before users in edk2-platforms have been updated. ArmPlatformPkg/Include/Library/NorFlashPlatformLib.h | 1 - 1 file changed, 1 deletion(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek diff --git a/ArmPlatformPkg/Include/Library/NorFlashPlatformLib.h b/ArmPlatformPkg/Include/Library/NorFlashPlatformLib.h index e9e1c060787d..e99a217c3a51 100644 --- a/ArmPlatformPkg/Include/Library/NorFlashPlatformLib.h +++ b/ArmPlatformPkg/Include/Library/NorFlashPlatformLib.h @@ -20,7 +20,6 @@ typedef struct { UINTN RegionBaseAddress; // Start address of one single region UINTN Size; UINTN BlockSize; - EFI_GUID Guid; } NOR_FLASH_DESCRIPTION; EFI_STATUS