From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (EUR02-HE1-obe.outbound.protection.outlook.com [40.107.1.79]) by mx.groups.io with SMTP id smtpd.web12.13759.1593005734662299586 for ; Wed, 24 Jun 2020 06:35:35 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=A3nizAEr; spf=pass (domain: arm.com, ip: 40.107.1.79, mailfrom: sami.mujawar@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=vkdDOZGyT6CNSqMneY9qt/hOgWyoD13sXfSoPj/LurA=; b=A3nizAErg57v3Uu//yvVMiXPCbPepbrlkU7xGwpx3fpXYC+Jv49eEhrBSRxac+P3/dUYfxaKgnK+yJL/C9tsUTdaUdn2FrY67AstEkd1bKD90A/0iozLrsyQuvznpd0+YuZK8SoFnfx2/AAAzU0LUXbyfP7+dOf00gQ1kq/DBBg= Received: from DB6PR1001CA0038.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:55::24) by VI1PR0802MB2319.eurprd08.prod.outlook.com (2603:10a6:800:a0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.25; Wed, 24 Jun 2020 13:35:30 +0000 Received: from DB5EUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:55:cafe::b) by DB6PR1001CA0038.outlook.office365.com (2603:10a6:4:55::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21 via Frontend Transport; Wed, 24 Jun 2020 13:35:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT037.mail.protection.outlook.com (10.152.20.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20 via Frontend Transport; Wed, 24 Jun 2020 13:35:29 +0000 Received: ("Tessian outbound 839770a6d413:v59"); Wed, 24 Jun 2020 13:35:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6aea2370e8aa80d9 X-CR-MTA-TID: 64aa7808 Received: from a5dbdaeb9d47.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 41B1C8B6-AA56-4B13-A1BF-BE705B6599A1.1; Wed, 24 Jun 2020 13:35:24 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a5dbdaeb9d47.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 24 Jun 2020 13:35:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eG+NaxXZGJS3Uo38kFT8WvLcgZ8Lr+QShBwsjvReI6o5n7GWosg4szXyJntw2z86dgwmCwoNpFCv4l2R4SQQfo/24s6ge+J2kNcN+VzWSv6u6oUGGhFI9a2s89yQvkmLXTVmZbHYTXUhFXeD49QAPXpynFciRwy4ngbDAoPrHIdbT0NA7thz5/WxhZbndBWSde/SSczqVs/ZYRCo0/pXIjRonCdi+F8tXJYoRVn/hbbL1465mDRsNx/syv32K9Br0RsbMRb4nSxBBNVvjzqSlI0pnDeQCthJWgCpV6xP8FVITB2JqVheaxh1T7J4uBViIwPZ2SHZBs1bMw0z8Cn7sQ== 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-SenderADCheck; bh=vkdDOZGyT6CNSqMneY9qt/hOgWyoD13sXfSoPj/LurA=; b=drU0Xih3hsqJ3kYPTCFI3RMmBTAz662NofbYWJJc+k01Ud5NONtisBn2tllhDjaI3xo9rO+6Af18mrLRQ7pHrRaJtE+0MyHsuiQgPhUKs6ZTBIZMQl/zsVdJjoOvgBScv+rNgc7wlcA6bX9V1VxkBZ9ttYfnxHgPFAk2sGqnpxKBY8iSSjYX+Z5bRFkAtQm6z4/HXbQKy35TyO5c4X6AzlLCEbvCbX6bmQOV5qSpQg9B08lLARPxdlOjQDV0EkSdYqnIlZ92HK5NCFDf2ZH0u3/1oUCArzx2e5YoUCG1QxkS1pXcB0WjnXFqZaEob7Wwv4vx/ey/qWtcS2S1cwf8dA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); 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=vkdDOZGyT6CNSqMneY9qt/hOgWyoD13sXfSoPj/LurA=; b=A3nizAErg57v3Uu//yvVMiXPCbPepbrlkU7xGwpx3fpXYC+Jv49eEhrBSRxac+P3/dUYfxaKgnK+yJL/C9tsUTdaUdn2FrY67AstEkd1bKD90A/0iozLrsyQuvznpd0+YuZK8SoFnfx2/AAAzU0LUXbyfP7+dOf00gQ1kq/DBBg= Received: from AM6P191CA0072.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:7f::49) by DB7PR08MB3675.eurprd08.prod.outlook.com (2603:10a6:10:4c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Wed, 24 Jun 2020 13:35:23 +0000 Received: from AM5EUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:7f:cafe::a7) by AM6P191CA0072.outlook.office365.com (2603:10a6:209:7f::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21 via Frontend Transport; Wed, 24 Jun 2020 13:35:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT052.mail.protection.outlook.com (10.152.17.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3131.20 via Frontend Transport; Wed, 24 Jun 2020 13:35:23 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Wed, 24 Jun 2020 13:35:12 +0000 Received: from E107187.Arm.com (10.57.22.181) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Wed, 24 Jun 2020 13:35:11 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , Subject: [PATCH v3 11/15] ArmVirtPkg: Add Kvmtool Platform Pei Lib Date: Wed, 24 Jun 2020 14:34:54 +0100 Message-ID: <20200624133458.61920-12-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 In-Reply-To: <20200624133458.61920-1-sami.mujawar@arm.com> References: <20200624133458.61920-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFTY:;SFS:(4636009)(346002)(376002)(39860400002)(396003)(136003)(46966005)(2616005)(86362001)(44832011)(186003)(19627235002)(82310400002)(478600001)(426003)(316002)(356005)(7696005)(6916009)(26005)(54906003)(81166007)(70206006)(82740400003)(8936002)(5660300002)(6666004)(47076004)(4326008)(36756003)(2906002)(8676002)(70586007)(336012)(83380400001)(1076003);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d0626758-c3a6-436e-5cb6-08d818437649 X-MS-TrafficTypeDiagnostic: DB7PR08MB3675:|VI1PR0802MB2319: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2958;OLM:2958; X-Forefront-PRVS: 0444EB1997 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 9rVHVzCI1fdlG2UT3/bRMWiYAfcuOPnD0uwKcg5C4vb/9i079GEkWjsZLBZhJbFY9A8u3MH1gC1rHNneaoMoT0z8BxHQ2uNcmwH2OXmsyWnAXz5H2O5e8qAr4xCo0OXlwuFRtgISvv9RlSAzb3Y/FshCROj6CxxMbZhmMcN2bH7KXppT5xMVzCLK4iDCrtM8RR/UsePGBY3saZ7jpPptwqlSp5CODeJM64+SA7y+U6KmR0HrF8Q3an1JhsOHjZqLuTRrdVrkyLfHi0EcL/CsXgeZYDzZ7mkuJ0Y4W+PewuJCYKy0/Nu+U26c5K/D8FktlpurJepqUAz6rUBu92BPg3U3e1yFNlEtuAguk1Ruh0aW7sTVvqDgOQwNcQ2jPfZJ08Imn7siS9ZI4OZgfmI+NA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3675 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT037.eop-EUR03.prod.protection.outlook.com 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;SFTY:;SFS:(4636009)(39860400002)(136003)(346002)(396003)(376002)(46966005)(1076003)(70206006)(70586007)(83380400001)(8676002)(2906002)(186003)(81166007)(426003)(47076004)(6916009)(26005)(4326008)(82740400003)(8936002)(82310400002)(36756003)(5660300002)(86362001)(316002)(19627235002)(54906003)(2616005)(44832011)(6666004)(336012)(7696005)(478600001);DIR:OUT;SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 9e14571f-72ff-4cb6-8b39-08d818437280 X-Forefront-PRVS: 0444EB1997 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C0OhTwSJpoTXohE6SR2TzNl79MTHCm3D3Q9yKWpkFIpqgi0Ymboc3ucOUIHXwBoSSFHmOpCQBQtBo+DVbCGpxSwzcECYqUwSblSlrjZhdthNNABKpFbs+lFoWxe3CQ2ruF2fdZ1xvpYBbXjGFcHDxSN6C8V/lL4s47/ioPbQIHlO+CP98BO7bIx6WPltu4keVNlRbYsZUiqyZEdHCmr55/DVSOC0T3nVh3pfgyk4Gj10jfyJOK2gLUr4iTpoYSehIb9mHRChnRFjiY+oHdrnEPNiT0Uf6QokUlISYyRgEWBVdgy7yxmE2R7fJynGlZERMFpZv+HG0X7lKuBYGb3yvbFPsk80Hl2qK3drspYPaOgiTSTvsrfGv7I0Rs43PD0zwGnLOICdtkrBuamwNnbSjg== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2020 13:35:29.9250 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d0626758-c3a6-436e-5cb6-08d818437649 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2319 Content-Type: text/plain The PlatformPeim() in the PlatformPeiLib is invoked by the PrePiMain() and provides the platform an opportunity to setup the plaform specific HOBs. This PlatfromPeiLib initialises the Kvmtool platform HOBs like the Fdt, 16550BaseAddress, etc. Signed-off-by: Sami Mujawar --- ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.c | 78 ++++++++++++++++++++ ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.inf | 48 ++++++++++++ 2 files changed, 126 insertions(+) diff --git a/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.c b/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.c new file mode 100644 index 0000000000000000000000000000000000000000..a97b31537fbc8071eed030f912ade60de3945356 --- /dev/null +++ b/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.c @@ -0,0 +1,78 @@ +/** @file +* +* Copyright (c) 2020, ARM Limited. All rights reserved. +* +* SPDX-License-Identifier: BSD-2-Clause-Patent +* +**/ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +/** Initialise Platform HOBs + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_OUT_OF_RESOURCES Out of resources. +**/ +EFI_STATUS +EFIAPI +PlatformPeim ( + VOID + ) +{ + VOID *Base; + VOID *NewBase; + UINTN FdtSize; + UINTN FdtPages; + UINT64 *FdtHobData; + UINT64 *UartHobData; + + Base = (VOID*)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress); + if ((Base == NULL) || (fdt_check_header (Base) != 0)) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding); + FdtPages = EFI_SIZE_TO_PAGES (FdtSize); + NewBase = AllocatePages (FdtPages); + if (NewBase == NULL) { + ASSERT (0); + return EFI_OUT_OF_RESOURCES; + } + + fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages)); + + FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof (*FdtHobData)); + if (FdtHobData == NULL) { + ASSERT (0); + return EFI_OUT_OF_RESOURCES; + } + + *FdtHobData = (UINTN)NewBase; + + UartHobData = BuildGuidHob ( + &gEarly16550UartBaseAddressGuid, + sizeof (*UartHobData) + ); + if (UartHobData == NULL) { + ASSERT (0); + return EFI_OUT_OF_RESOURCES; + } + + *UartHobData = PcdGet64 (PcdSerialRegisterBase); + + BuildFvHob (PcdGet64 (PcdFvBaseAddress), PcdGet32 (PcdFvSize)); + + return EFI_SUCCESS; +} diff --git a/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.inf b/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.inf new file mode 100644 index 0000000000000000000000000000000000000000..9f44b8885d3c131de1d41ac6947bd9218cfdf3e7 --- /dev/null +++ b/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.inf @@ -0,0 +1,48 @@ +#/** @file +# +# Copyright (c) 2020, ARM Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +#**/ + +[Defines] + INF_VERSION = 0x0001001B + BASE_NAME = PlatformPeiLib + FILE_GUID = 21073FB3-BA6F-43EB-83F0-4A840C648165 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = KvmtoolPlatformPeiLib + +[Sources] + KvmtoolPlatformPeiLib.c + +[Packages] + ArmPkg/ArmPkg.dec + ArmVirtPkg/ArmVirtPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib + HobLib + FdtLib + PcdLib + PeiServicesLib + +[FixedPcd] + gArmTokenSpaceGuid.PcdFvSize + gArmVirtTokenSpaceGuid.PcdDeviceTreeAllocationPadding + +[Pcd] + gArmTokenSpaceGuid.PcdFvBaseAddress + gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase + +[Guids] + gFdtHobGuid + gEarly16550UartBaseAddressGuid + +[Depex] + gEfiPeiMemoryDiscoveredPpiGuid -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'