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.79]) by mx.groups.io with SMTP id smtpd.web10.15413.1594126116460352320 for ; Tue, 07 Jul 2020 05:48:36 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=VqV3RpJW; spf=pass (domain: arm.com, ip: 40.107.8.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=SnCASzadBtCfGkblN5f57Eko0VQ2mJmmvYu1THWpOp8=; b=VqV3RpJWajCJ/vC9lm9OjtrGBbaZ8+IwEfgzGyrCIeLQQaahsi9BJ6as6biJ365H/CIejlZX1i9wokxE0jkY15gpPyXiJwuwzYymM9pEOGlcV+vr2aTR9brdDsA64YBoh0YyL+SVblBKxEWAMJBq3JGSQhE8b9sQt3FqEs0WlU4= Received: from AM5PR1001CA0027.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::40) by HE1PR0801MB2059.eurprd08.prod.outlook.com (2603:10a6:3:53::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24; Tue, 7 Jul 2020 12:48:32 +0000 Received: from VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:2:cafe::8e) by AM5PR1001CA0027.outlook.office365.com (2603:10a6:206:2::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.21 via Frontend Transport; Tue, 7 Jul 2020 12:48:32 +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 VE1EUR03FT048.mail.protection.outlook.com (10.152.19.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24 via Frontend Transport; Tue, 7 Jul 2020 12:48:32 +0000 Received: ("Tessian outbound 2dd9eeca983c:v62"); Tue, 07 Jul 2020 12:48:31 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6fa4c1e4cde77ab7 X-CR-MTA-TID: 64aa7808 Received: from 14480e58cb7a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id E9E7B11C-E7AF-4C04-B782-AA2F0A59DFBE.1; Tue, 07 Jul 2020 12:48:26 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 14480e58cb7a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 07 Jul 2020 12:48:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SZ+47i8RXobaV02mTh+s+fy3QC9kiH2sbuJuodgyuK5h/2GGcZJl1SC1Py8LF3PjDJCcUu9nWuZVF6gAFR3ofeYAU8vMK9WhDg2UJKI3ouT2Ra4pPN24lXcxG7UpykNxYDgmfD4d6q/lUe5Ak9+JxAomjw8PJizJEsTste0eqwrXOU6BOPh5DbkXO6Gp/bYxHY4bArm/kOUmdOslpnfMWyo3qAUVyCUNGUDl6giL3AV8kewcbkt0JpVZzTGeIVp4FrzZhKFQ4yM4wV5igsk2NJc/RQMVtSiMBURG8SzSQgWrhp8AGWyrTco/QAV2z1dM4jwQ+m9vdHapP4coLXk5+A== 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=SnCASzadBtCfGkblN5f57Eko0VQ2mJmmvYu1THWpOp8=; b=n0DyXRJhwMmocBcXyN+C9OaFJjPHRSUmcuI46WEhuh+yQg2rfYc6vgY2k3psREEjT4cFUUuSa7/eqJATNi2qqRictRx3euTp6FVCcNZnRO2lPikwIfD34gtVqH9LgSRvyhperhmR/WVN6SNadKPBqkJQaYALVJwxdLKxGurqzepQuHRvGbTwE0G6ZPYLBgOeAyBhL2+yz3+T9s+k8vl35sNoN+2wCmUY81+HZtCMoIqulOPgu3mWU2hEj6aSKipak0lu3sCMMLUgAfM0OV0cvoMV29W37fBQ+ehqmnS0rTY3mAoYCRNJRwZKzxaITjYpUIoICwtwQLnpg7FeLX2qGg== 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=SnCASzadBtCfGkblN5f57Eko0VQ2mJmmvYu1THWpOp8=; b=VqV3RpJWajCJ/vC9lm9OjtrGBbaZ8+IwEfgzGyrCIeLQQaahsi9BJ6as6biJ365H/CIejlZX1i9wokxE0jkY15gpPyXiJwuwzYymM9pEOGlcV+vr2aTR9brdDsA64YBoh0YyL+SVblBKxEWAMJBq3JGSQhE8b9sQt3FqEs0WlU4= Received: from DB6PR0501CA0011.eurprd05.prod.outlook.com (2603:10a6:4:8f::21) by AM6PR08MB3173.eurprd08.prod.outlook.com (2603:10a6:209:4c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.21; Tue, 7 Jul 2020 12:48:24 +0000 Received: from DB5EUR03FT047.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:8f:cafe::b8) by DB6PR0501CA0011.outlook.office365.com (2603:10a6:4:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22 via Frontend Transport; Tue, 7 Jul 2020 12:48:24 +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 DB5EUR03FT047.mail.protection.outlook.com (10.152.21.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3153.24 via Frontend Transport; Tue, 7 Jul 2020 12:48:24 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1415.2; Tue, 7 Jul 2020 12:48:23 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1779.2; Tue, 7 Jul 2020 12:48:22 +0000 Received: from E107187.Arm.com (10.57.21.15) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Tue, 7 Jul 2020 12:48:21 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , Subject: [PATCH v4 10/15] ArmVirtPkg: Add Kvmtool Platform Pei Lib Date: Tue, 7 Jul 2020 13:48:04 +0100 Message-ID: <20200707124810.50668-11-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 In-Reply-To: <20200707124810.50668-1-sami.mujawar@arm.com> References: <20200707124810.50668-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)(136003)(376002)(396003)(39860400002)(46966005)(83380400001)(1076003)(8936002)(4326008)(8676002)(2906002)(86362001)(19627235002)(70586007)(6916009)(5660300002)(70206006)(47076004)(82310400002)(44832011)(6666004)(7696005)(2616005)(966005)(82740400003)(426003)(316002)(336012)(81166007)(478600001)(26005)(356005)(36756003)(54906003)(186003);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b7abea69-3444-4a1d-0680-08d822740e3e X-MS-TrafficTypeDiagnostic: AM6PR08MB3173:|HE1PR0801MB2059: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2958;OLM:2958; X-Forefront-PRVS: 0457F11EAF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: +dyGU6t5Of/HfsWNLlb/jnmf/+9jHrWe9pMnpfMCzY++uZk25n9heWlqMQxrpYEWGYJqohmidAz1jJ+SyLLQey8Vd3m87oIrCugeVYeGeqEgJhk4R3AHs2Sw/rmZeBovjr8YIXK2s17L2f3xsnMD85UkJz8xKB3qsGLmTN8XrnMOFGjFsSzTsJF87qtyDtDFJaG6WMo00zpJum16SMPw1psR8z7hLpPIc2TUXK+0vVuKWiUKuXCt7cYUQlyJ1gK90575pw0Iu4VWWTRDi/lBXbGjgpMssHfQ7IA/S5M0dPw2ajuQ0R/3LUMZ23WCjBTpTis9QHBJY/PY7e4eV4pvK7saPqY81Cbn2RyXZ53hmLN3HAoa1SMyClbkqxZIrMWHf4UD+SivFD5LVZihsNx96cFWWH66JyhUY1hZisNMfNB78Q6Hufin6UqBR8RnU0VLoPRdVNo8868ILOZPJ8MIRrmSfsj1g//QneHOmwgoK5c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3173 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT048.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)(46966005)(498600001)(8676002)(36756003)(8936002)(47076004)(86362001)(54906003)(70206006)(70586007)(5660300002)(966005)(36906005)(4326008)(426003)(19627235002)(186003)(6666004)(1076003)(81166007)(26005)(336012)(6916009)(44832011)(2906002)(83380400001)(7696005)(82310400002)(2616005);DIR:OUT;SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: c158ed24-5c3d-419b-3936-08d8227409c5 X-Forefront-PRVS: 0457F11EAF X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aEH2JJOcOmP8z+OAtrEh+3F7c2MZ2DIQF2cMn7XGbPkWauEOfOOmslXkqdZzybUh+kMK6vdgCz3i8E2GIDtzeXG/eDIlFMKzxuwtsJTs8Q15/O4Rk49Y/wgLRB6G66tjVMWQDp0JUBZMDQ7MVoFnEGEcK2xdfVsYs1iWwjnvq/qLqTbqRRu9MeaTVwJU5AQvgT5yx3MjDdxDYjaM4OvgafawN+pYJngXLqWzxJYPOZtF4WGc5nhDLIp4lEIdSMxyTPxTqg76ekcGgtRwKqqdVmuYTgeSGXkqfU3j+BBcTp7ir4LNjHBnGtB2SY2RHEgyUCX9HEVgnXbB23vTWMT4rqP5CE3Vt2JJVH6Bv/Syyt+lZHJwOk1MG8JxEJWumvpVUQ3EKxZKWYqbwzDP2m8vYTPkhLcymdNpxtY447Z5Kr/2+35qN8HBGja5oCNSFSLwFbFQ+fhvEJgFLTemBa+OhhwSF2ZIgYQwWpbKb4/S5CE= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2020 12:48:32.2312 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7abea69-3444-4a1d-0680-08d822740e3e 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: VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB2059 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 Reviewed-by: Ard Biesheuvel --- Notes: v4: - No code change, resending patch with v4 series. [Sami] Ref: https://edk2.groups.io/g/devel/message/61722 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)'