From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.55]) by mx.groups.io with SMTP id smtpd.web12.7589.1666184768698137083 for ; Wed, 19 Oct 2022 06:06:09 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=vC8plvuS; spf=pass (domain: arm.com, ip: 40.107.8.55, mailfrom: sami.mujawar@arm.com) ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=ZQLJRKa64CnO8ud4DJlPmzf/k+bERGBUh0rxg2uhp4IcwFYuhb4ywktRPMUdtVpZsLrNx1iIqlufIDuUpXnD6ggCzwwnu7A86pFzJECb914fxhJbLlLTj8A0t21tqQ6ctfYl16mODpZw365YqyA8qwVeZQCIdI6RKhuy8+mMokLbYPTN38DBO3Tt5ltnnznUw/Uw1aQhvfF7DZfS+rcmGZnO2NMFriW11YVgkc7KZocJiDUmFQ/nvooxVgnhcLXfN3ewO3yV/Y+rIGJdnhuJJXVhzpHgnhw7fow/2E3K2jvln0uMF3KMaWSFtHJSG67JqPt+bqHvchFXixW77Z8HGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JpaP1qu5ZzuPF3ZCWxVrsK3K2O12QniUeD81S6sbyAI=; b=Wdh8CYJMdIx92ywxyTSf2OazVygUgKzFUBrVPKI0nJHVQolNkFxdNpqkc2yo5PnvVTwNktU4xgHmsCqweR3ioWblPYi43Wewd246eQYG6PPeAAQp4KR1Zyn/wkrwYT47kRtg001ol2Y0mmsiy2m7nR3De/iPmABS9t5d8Al6MueQVu59KqSDlsWr70Ei+WkSarCo4djJSzNYp/430kTy1VjFhDrNtBcSZck4ZfmNnhnlH0zAtMdSPtwyE7fu28N5UiJywbmHsNOqhM4eFMm2Gf0HQ3h30CPOjY5ay424ioocjRTCTpIw5tKm52DY2lIq/rZ8VD60APwrS0aw97V7fA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JpaP1qu5ZzuPF3ZCWxVrsK3K2O12QniUeD81S6sbyAI=; b=vC8plvuS0ZPro7cwZ8DC9cOPWenJ+qw394MCl+eaiUTGoi+sl7NFv0mkv7YGIhr3h6NBLNgLpUeco+et1AqI7ueQU/n6+o86pZVDuplrNK+/h+M4JKV3fD8tZ4h5fy3TKji3/TZfGCFzoXyw26Py8dL2jlIfQfzqHvviI2yKjC8= Received: from AS9PR06CA0147.eurprd06.prod.outlook.com (2603:10a6:20b:467::19) by GV1PR08MB8057.eurprd08.prod.outlook.com (2603:10a6:150:97::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Wed, 19 Oct 2022 13:05:56 +0000 Received: from VI1EUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:467:cafe::be) by AS9PR06CA0147.outlook.office365.com (2603:10a6:20b:467::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 13:05:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VI1EUR03FT046.mail.protection.outlook.com (100.127.144.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32 via Frontend Transport; Wed, 19 Oct 2022 13:05:56 +0000 Received: ("Tessian outbound 0800d254cb3b:v130"); Wed, 19 Oct 2022 13:05:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e66fc28cf9365a85 X-CR-MTA-TID: 64aa7808 Received: from e3844f8ed625.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 52EA13FA-FAA8-45B4-B02B-973F5E109230.1; Wed, 19 Oct 2022 13:05:48 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e3844f8ed625.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 19 Oct 2022 13:05:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M0+0xDB4k5jGJVNmZPV+us5PaIRvb9gasqyBkw337HifHBA9lYhZJiltFVYi2YIB50fRzMhcSB2+BRkRl4qypXwXfs8a2OPk4EB4n3O0++gMfrhHHLNYJWuHKRCUkjy7bipzQnwhNwwu3X/y1AKcWfcQPNBRjou4mxadoFK+UlIfl5miPoL/KerXhvj9IXwMGT5qOjmAP4tZWaUQWEt13vjWzTCeHpjZR1P6SKr+Fc78IotGolGAJvhwSYZDzfTQAJYTK8A6eCt+1G7xFOXQ9a31+r7lmi7QSHCj4hvATeSDbO7Z3JnQH/o0UHGiX1LaaYJ+GoBaR//9XeETczZm6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JpaP1qu5ZzuPF3ZCWxVrsK3K2O12QniUeD81S6sbyAI=; b=Cnw9+ZaxRQuptZ8sfCiLYv+8nqVCSzHS06fYBPgg2MwGmzUmgcO7DetPKyIDVoy6kNLrMocnFcKrLXtadUjmpNHNUjk3xOmeybAaMoRQoCMYyldFGmtKj7k4V9MqTVWnGcrpAXwZfCmEx4uGUZx4jj5u+qO3+htJdJHIZKt7caWVNxxa58zk2g2vNXjxCRXGT/cm3YslpQHt4h1CRi2J2F2zee6Az50n1Q+L3XL2yRy5nXKrjjgvRgHG0Mtqfxl8d5fBCBqo+I86LBrNDwWQKWFwGiw+QSdf5XXJ+TvEgjQA5RoxjS32bRLOIYCmxdWES2BDhZQtx40D9BysL565wg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JpaP1qu5ZzuPF3ZCWxVrsK3K2O12QniUeD81S6sbyAI=; b=vC8plvuS0ZPro7cwZ8DC9cOPWenJ+qw394MCl+eaiUTGoi+sl7NFv0mkv7YGIhr3h6NBLNgLpUeco+et1AqI7ueQU/n6+o86pZVDuplrNK+/h+M4JKV3fD8tZ4h5fy3TKji3/TZfGCFzoXyw26Py8dL2jlIfQfzqHvviI2yKjC8= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) by AS4PR08MB8021.eurprd08.prod.outlook.com (2603:10a6:20b:584::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34; Wed, 19 Oct 2022 13:05:46 +0000 Received: from AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::283c:fe2e:699d:2bf]) by AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::283c:fe2e:699d:2bf%5]) with mapi id 15.20.5723.033; Wed, 19 Oct 2022 13:05:45 +0000 Message-ID: <2f9cdb28-7fa0-c2a2-d53c-7f2f7e87aef3@arm.com> Date: Wed, 19 Oct 2022 14:05:44 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH 25/29] OvmfPkg: Add NorFlashQemuLib library To: devel@edk2.groups.io, ardb@kernel.org, Sunil V L Cc: Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann , Daniel Schaefer , "nd@arm.com" References: <20221010101202.1146624-1-sunilvl@ventanamicro.com> <20221010101202.1146624-26-sunilvl@ventanamicro.com> From: "Sami Mujawar" In-Reply-To: X-ClientProxiedBy: LO4P265CA0006.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ad::20) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6806:EE_|AS4PR08MB8021:EE_|VI1EUR03FT046:EE_|GV1PR08MB8057:EE_ X-MS-Office365-Filtering-Correlation-Id: 21d8a85f-8f9c-4993-badc-08dab1d2a8f5 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: KlAsqGil+GW47YJVO3t06g35RN+hv2kUh8qpsmGiAO4irLvkhIZ1D7Ors/LexvQrfxLfCTGNlAEy6ys4HLgM29S0VR0dfPlh3BEtzFyBiWng9oj6pNWIcQxN3tNtMZBEO9xgswqfRFwxHhZNuuGbfaJfXL/7kaoyGVubOm6ftGbfOnXHfJHTUhwML/tRuyb4jH5qSq8wd1c0wIVaYtV5zNVutbHlxRdN7wZ7aVInx/Yx6PxbszkMpnH+aeT7MCmZ9U0zs0adEYhWjOkDMIXyYjb899c5nD+pkjWAmnAOdtolABMIpF0cvy4N2XHfFfB4lFSP7LPExW9HJjykvYKebGvEpfTKN2fd8I1ZVm45Mt8Ujpw1YdhbXEaT8lu00gLDJ8ac/Gw4jbOcYjv1bo/cE4m5jb/5UL5MaBtj8qSAOq8vx2qzeRxyO53LOQtEdZ++Ez1ChIp1jokessWA8LlQy/7uFOxK7n6eu7bIqd24v8S6JpYerW/elIDEdX5Q2hImE10zMNeiia6CoPUIX2Pw9oEwwJ6Kju+Ofxwb1sovOlcHcEOL8nX7fZAqnTjFs/g+CmwuywIFlAE2HNtSRhx2N/IEdO3gfCttbKC35gxCQzRFJIUuN2B+jvaMmyTX5VbqLtyUObxabe9JqvjrsUn4zC0GObcUNEWW5BHwMgbjDzd/6FdCk4iOlHdPAeSIM4B0Ye2gto/SrFNdAXoVFXDKnMoFxtAbSXTPs9I+qf+2p0HnW/0X9pX3F+JITvTl28GkZeJWnQCf3yyvAGB4JYGPo5mIBvamvZmJiTgL/aYFbZF+G3WfQjCUxuyXreBckMw21aWy+673TnEwhKJ963RgLkYqRXJKYiGuMM71Qg5Q5s4LgV/VBzEsRH0svkS9rQ0K X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR08MB6806.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(346002)(366004)(376002)(136003)(39860400002)(451199015)(31686004)(66899015)(36756003)(8676002)(66556008)(4326008)(44832011)(66476007)(83380400001)(38100700002)(8936002)(2906002)(5660300002)(41300700001)(66946007)(316002)(54906003)(30864003)(26005)(6916009)(6512007)(2616005)(186003)(6486002)(966005)(31696002)(86362001)(6506007)(478600001)(53546011)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB8021 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VI1EUR03FT046.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 61a84370-75d4-4630-aa37-08dab1d2a2be X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L5FJyAEbyECXD+EdOPzHNz0r1eXaWadhygKAvPEy2z7e9YdGkzgt8Jb5yu1lEBy5K+CPOLTqlwyGXYDyK9wtcHREZ2oGMu+QoJ7NG1Un5m8FR3xn96dHVvSBRqMo/cGYqv/QEcYa2oUC4HEb/EA4gdM06rh3lbY7BcllS108wCJpuNZK9AzF9Uyj/n644P1Uo3dPFiWKqUiN2jqqM83bI+tZpfAb53foCRtTFFB007sPNu+R2TPpFUt/araECUh1YuKbALrDrrThkPZB/KcCmYcPUX4+EUsus916YTfoCbEqgZAyHJFdJEL5+mXJ2cYdND/JzofAAJuWgfjwonbJx4nBvbsH23emrD0ura7eZMi77YhE4W6zaYhA2bZTUsAJ55T/wI0BZg4Rd44p9iXfUvpx0/r0329F15kef8BhH4ZFOZyUYLfgaFgvc4FEQVGNX07ODfnufwZoA3r5ApkxJNCDsOibZQlaBCxjXlTgdOy87kNb1MppM3zjrQkUgIgjw1wWrXzzouoA+jc3+QZWZpRWgcxFCNHH/ESQGTsVerg4WYMSfWkhg0+1kkMfGkWqGnjlWcvNgmqoCRGfPThlrDmULsVAWu84kqLdVPxjJCLA4tXVP7Dt0SGQGFFQYtlhbApVucPuJOrZrpfYU8T8YsTJUWWYrwTC6Sd/F6W2LfVvrHwxeYOqh+K9kPn8pivK79ffiFLNKd1xh6bL82ImaArxUlYYj3cinMEMoLc4wZYlXvno2/KxCwDX+s0V09u5oZW5Zsv5lv4FWKDQ1lvZyjfbP+L68NN0aZ3UsZjZwVRuRfnAGF5LqN3qzbX2l/r+cNZbOYGUaAvEodd0v9WnnETwYutWbTiGXi4LoYaEyUIaFVlRvr/VJ8E5F23iXXQ+ X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(346002)(39860400002)(396003)(451199015)(40470700004)(36840700001)(46966006)(316002)(2616005)(36860700001)(86362001)(6862004)(26005)(8936002)(44832011)(6512007)(5660300002)(36756003)(40480700001)(30864003)(70206006)(4326008)(70586007)(8676002)(336012)(41300700001)(53546011)(186003)(31696002)(2906002)(6506007)(31686004)(6486002)(966005)(40460700003)(83380400001)(66899015)(54906003)(82310400005)(356005)(47076005)(82740400003)(478600001)(81166007)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 13:05:56.0240 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 21d8a85f-8f9c-4993-badc-08dab1d2a8f5 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VI1EUR03FT046.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8057 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Ard, Please see my query inline marked [SAMI]. Regards, Sami Mujawar On 19/10/2022 01:19 pm, Ard Biesheuvel via groups.io wrote: > On Mon, 10 Oct 2022 at 12:13, Sunil V L wrote: >> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076 >> >> This is copied from ArmVirtPkg since it is required for >> other architectures also. >> >> It also adds the instance for single flash drive which has >> both code and variables. This is copied from SbsaQemu. >> >> Cc: Ard Biesheuvel >> Cc: Jiewen Yao >> Cc: Jordan Justen >> Cc: Gerd Hoffmann >> Cc: Daniel Schaefer >> Signed-off-by: Sunil V L > Let's call these > > QemuNorFlashPlatformLib [for the library class] > > QemuNorFlashDeviceTreeLib > QemuNorFlashStaticLib > > and for the driver > > QemuNorFlashDxe [SAMI] We use the NorFlashDxe for the Kvmtool guest firmware, see https://github.com/tianocore/edk2/blob/master/ArmVirtPkg/ArmVirtKvmTool.dsc#L294 Considering this, should QemuNorFlashDxe be called OvmfNorFlashDxe? [/SAMI] > > > i sent out some patches for edk2-platforms to eliminate the dependency > on ArmPlatformPkg's NorFlashDxe and NorFlashPlatformLib definitions. > Once we move everything in OvmfPkg over to these ones, we can drop the > old one altogether. > > > >> --- >> OvmfPkg/OvmfPkg.dec | 8 ++ >> .../NorFlashQemuLib/NorFlashQemuLib.inf | 40 ++++++ >> .../NorFlashQemuUnifiedLib.inf | 30 ++++ >> OvmfPkg/Include/Library/NorFlashPlatformLib.h | 30 ++++ >> .../Library/NorFlashQemuLib/NorFlashQemuLib.c | 136 ++++++++++++++++++ >> .../NorFlashQemuLib/NorFlashQemuUnifiedLib.c | 40 ++++++ >> 6 files changed, 284 insertions(+) >> create mode 100644 OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf >> create mode 100644 OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.inf >> create mode 100644 OvmfPkg/Include/Library/NorFlashPlatformLib.h >> create mode 100644 OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c >> create mode 100644 OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.c >> >> diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec >> index 7d2acc5ea0e0..0697c91c6836 100644 >> --- a/OvmfPkg/OvmfPkg.dec >> +++ b/OvmfPkg/OvmfPkg.dec >> @@ -129,6 +129,10 @@ [LibraryClasses] >> # >> HardwareInfoLib|Include/Library/HardwareInfoLib.h >> >> + ## @libraryclass NorFlashQemuLib >> + # >> + NorFlashPlatformLib|Include/Library/NorFlashPlatformLib.h >> + >> [Guids] >> gUefiOvmfPkgTokenSpaceGuid = {0x93bb96af, 0xb9f2, 0x4eb8, {0x94, 0x62, 0xe0, 0xba, 0x74, 0x56, 0x42, 0x36}} >> gEfiXenInfoGuid = {0xd3b46f3b, 0xd441, 0x1244, {0x9a, 0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d}} >> @@ -405,6 +409,10 @@ [PcdsFixedAtBuild] >> # check to decide whether to abort dispatch of the driver it is linked into. >> gUefiOvmfPkgTokenSpaceGuid.PcdEntryPointOverrideFwCfgVarName|""|VOID*|0x68 >> >> + ## The base address and size of the FVMAIN >> + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvBaseAddress|0|UINT64|0x71 >> + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvSize|0|UINT32|0x72 >> + >> [PcdsDynamic, PcdsDynamicEx] >> gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2 >> gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10 >> diff --git a/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf >> new file mode 100644 >> index 000000000000..ecd8059b3508 >> --- /dev/null >> +++ b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf >> @@ -0,0 +1,40 @@ >> +#/** @file >> +# >> +# Component description file for NorFlashQemuLib module >> +# >> +# Copyright (c) 2014, Linaro Ltd. All rights reserved.
>> +# >> +# SPDX-License-Identifier: BSD-2-Clause-Patent >> +# >> +#**/ >> + >> +[Defines] >> + INF_VERSION = 0x00010005 >> + BASE_NAME = NorFlashQemuLib >> + FILE_GUID = 42C30D8E-BFAD-4E77-9041-E7DAAE88DF7A >> + MODULE_TYPE = DXE_DRIVER >> + VERSION_STRING = 1.0 >> + LIBRARY_CLASS = NorFlashPlatformLib >> + >> +[Sources.common] >> + NorFlashQemuLib.c >> + >> +[Packages] >> + MdePkg/MdePkg.dec >> + OvmfPkg/OvmfPkg.dec >> + EmbeddedPkg/EmbeddedPkg.dec >> + >> +[LibraryClasses] >> + BaseLib >> + DebugLib >> + UefiBootServicesTableLib >> + >> +[Protocols] >> + gFdtClientProtocolGuid ## CONSUMES >> + >> +[Depex] >> + gFdtClientProtocolGuid >> + >> +[Pcd] >> + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvBaseAddress >> + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFvSize >> diff --git a/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.inf b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.inf >> new file mode 100644 >> index 000000000000..91d1406fc3e7 >> --- /dev/null >> +++ b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.inf >> @@ -0,0 +1,30 @@ >> +#/** @file >> +# >> +# Component description file for NorFlashQemuLib module >> +# >> +# Copyright (c) 2014, Linaro Ltd. All rights reserved.
>> +# >> +# SPDX-License-Identifier: BSD-2-Clause-Patent >> +# >> +#**/ >> + >> +[Defines] >> + INF_VERSION = 0x00010005 >> + BASE_NAME = NorFlashQemuUnifiedLib >> + FILE_GUID = 064742F1-E531-4D7D-A154-22315889CC23 >> + MODULE_TYPE = DXE_DRIVER >> + VERSION_STRING = 1.0 >> + LIBRARY_CLASS = NorFlashPlatformLib >> + >> +[Sources.common] >> + NorFlashQemuUnifiedLib.c >> + >> +[Packages] >> + MdePkg/MdePkg.dec >> + MdeModulePkg/MdeModulePkg.dec >> + OvmfPkg/OvmfPkg.dec >> + >> +[Pcd] >> + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress >> + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize >> + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase >> diff --git a/OvmfPkg/Include/Library/NorFlashPlatformLib.h b/OvmfPkg/Include/Library/NorFlashPlatformLib.h >> new file mode 100644 >> index 000000000000..6ef5b70e9948 >> --- /dev/null >> +++ b/OvmfPkg/Include/Library/NorFlashPlatformLib.h >> @@ -0,0 +1,30 @@ >> +/** @file >> + >> + Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
>> + >> + SPDX-License-Identifier: BSD-2-Clause-Patent >> + >> + **/ >> + >> +#ifndef _NORFLASHPLATFORMLIB_H_ >> +#define _NORFLASHPLATFORMLIB_H_ >> + >> +typedef struct { >> + UINTN DeviceBaseAddress; // Start address of the Device Base Address (DBA) >> + UINTN RegionBaseAddress; // Start address of one single region >> + UINTN Size; >> + UINTN BlockSize; >> +} NOR_FLASH_DESCRIPTION; >> + >> +EFI_STATUS >> +NorFlashPlatformInitialization ( >> + VOID >> + ); >> + >> +EFI_STATUS >> +NorFlashPlatformGetDevices ( >> + OUT NOR_FLASH_DESCRIPTION **NorFlashDescriptions, >> + OUT UINT32 *Count >> + ); >> + >> +#endif /* _NORFLASHPLATFORMLIB_H_ */ >> diff --git a/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c >> new file mode 100644 >> index 000000000000..3632fa9e7a98 >> --- /dev/null >> +++ b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c >> @@ -0,0 +1,136 @@ >> +/** @file >> + >> + Copyright (c) 2014-2018, Linaro Ltd. All rights reserved.
>> + >> + SPDX-License-Identifier: BSD-2-Clause-Patent >> + >> + **/ >> + >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> + >> +#define QEMU_NOR_BLOCK_SIZE SIZE_256KB >> + >> +#define MAX_FLASH_BANKS 4 >> + >> +EFI_STATUS >> +NorFlashPlatformInitialization ( >> + VOID >> + ) >> +{ >> + return EFI_SUCCESS; >> +} >> + >> +NOR_FLASH_DESCRIPTION mNorFlashDevices[MAX_FLASH_BANKS]; >> + >> +EFI_STATUS >> +NorFlashPlatformGetDevices ( >> + OUT NOR_FLASH_DESCRIPTION **NorFlashDescriptions, >> + 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; >> + >> + PropSize -= 4 * sizeof (UINT32); >> + >> + // >> + // Disregard any flash devices that overlap with the primary FV. >> + // The firmware is not updatable from inside the guest anyway. >> + // >> + if ((PcdGet64 (PcdOvmfFvBaseAddress) + PcdGet32 (PcdOvmfFvSize) > Base) && >> + ((Base + Size) > PcdGet64 (PcdOvmfFvBaseAddress))) >> + { >> + continue; >> + } >> + >> + mNorFlashDevices[Num].DeviceBaseAddress = (UINTN)Base; >> + mNorFlashDevices[Num].RegionBaseAddress = (UINTN)Base; >> + mNorFlashDevices[Num].Size = (UINTN)Size; >> + mNorFlashDevices[Num].BlockSize = QEMU_NOR_BLOCK_SIZE; >> + Num++; >> + } >> + >> + // >> + // UEFI takes ownership of the NOR flash, and exposes its functionality >> + // through the UEFI Runtime Services GetVariable, SetVariable, etc. This >> + // means we need to disable it in the device tree to prevent the OS from >> + // attaching its device driver as well. >> + // Note that this also hides other flash banks, but the only other flash >> + // bank we expect to encounter is the one that carries the UEFI executable >> + // code, which is not intended to be guest updatable, and is usually backed >> + // in a readonly manner by QEMU anyway. >> + // >> + Status = FdtClient->SetNodeProperty ( >> + FdtClient, >> + Node, >> + "status", >> + "disabled", >> + sizeof ("disabled") >> + ); >> + if (EFI_ERROR (Status)) { >> + DEBUG ((DEBUG_WARN, "Failed to set NOR flash status to 'disabled'\n")); >> + } >> + } >> + >> + *NorFlashDescriptions = mNorFlashDevices; >> + *Count = Num; >> + >> + return EFI_SUCCESS; >> +} >> diff --git a/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.c b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.c >> new file mode 100644 >> index 000000000000..1420fb5b596c >> --- /dev/null >> +++ b/OvmfPkg/Library/NorFlashQemuLib/NorFlashQemuUnifiedLib.c >> @@ -0,0 +1,40 @@ >> +/** @file >> + >> + Copyright (c) 2019, Linaro Ltd. All rights reserved >> + >> + SPDX-License-Identifier: BSD-2-Clause-Patent >> + >> + **/ >> + >> +#include >> +#include >> +#include >> + >> +#define QEMU_NOR_BLOCK_SIZE SIZE_256KB >> + >> +EFI_STATUS >> +NorFlashPlatformInitialization ( >> + VOID >> + ) >> +{ >> + return EFI_SUCCESS; >> +} >> + >> +NOR_FLASH_DESCRIPTION mNorFlashDevice = >> +{ >> + FixedPcdGet32 (PcdOvmfFdBaseAddress), >> + FixedPcdGet64 (PcdFlashNvStorageVariableBase), >> + FixedPcdGet32 (PcdOvmfFirmwareFdSize), >> + QEMU_NOR_BLOCK_SIZE >> +}; >> + >> +EFI_STATUS >> +NorFlashPlatformGetDevices ( >> + OUT NOR_FLASH_DESCRIPTION **NorFlashDescriptions, >> + OUT UINT32 *Count >> + ) >> +{ >> + *NorFlashDescriptions = &mNorFlashDevice; >> + *Count = 1; >> + return EFI_SUCCESS; >> +} >> -- >> 2.25.1 >> > > > >