From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43])
 by mx.groups.io with SMTP id smtpd.web08.5694.1665655233564332104
 for <devel@edk2.groups.io>;
 Thu, 13 Oct 2022 03:00:33 -0700
Authentication-Results: mx.groups.io;
 dkim=pass header.i=@ventanamicro.com header.s=google header.b=SgEWr//D;
 spf=pass (domain: ventanamicro.com, ip: 209.85.160.43, mailfrom: sunilvl@ventanamicro.com)
Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-1322d768ba7so1700457fac.5
        for <devel@edk2.groups.io>; Thu, 13 Oct 2022 03:00:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=ventanamicro.com; s=google;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to;
        bh=fo4FSohLRwNRa1a9qzgCaY+L/doGRGW7QYtvS3xrbKQ=;
        b=SgEWr//DGYgiCFWH1ylTgzVupVVvhRwIL4/jlclPaLgesuvoAA3a0dGJrvdOO1nHW0
         kVlGl5cwnFAhxfMDZfBM/3JQCFb7WXZDw0/epgnHTDqNeoXje5lBby+jeYBaCgPCt5fI
         7EqpxgwZBNWxW8SMEVyQ9s8v+zyhu2p8t9EPzbTu90g+iCEH93sWIXtoClVHIsnAa4SH
         wSeF6l2phZcxB4F9RlgTwQg47jT+y0XGJkSQ0EGFGhUrNNmpwdNl2zzJrcYhE6k1N+EB
         edfZP6rr3z534fC4QB86k2TooMzSwL7SDpibaexu99d5W90zNnCu+LCnrQGMF0qiVaDL
         QJ2A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20210112;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to;
        bh=fo4FSohLRwNRa1a9qzgCaY+L/doGRGW7QYtvS3xrbKQ=;
        b=41kVUFA/xzQBbo33O1AFda2TSDcsHQX6xd8peLxk66MA75IbQGGPiqxtmMxN0qCixb
         vb6WycqudMW2OF3sHXFE+xYdPLiYXtXaSs5VEVwLfx2SpZ0ZsmvBRZw1OF26DBvCpWfD
         /wYmR9FG68gB+8DRkcj0XORRl/mxxtt1tPNBehTOli+HO+lbBUZjbyon4kHEhp/Gu9ey
         UG2Z3XxyzKLkPDofAIy7nqH3maAcdYl3o19ly5KZPESfj/OtT3ftIMSZR+QOfo0Yiq1o
         F2Rqzl1W0zO/IDsnLIem5q9+5rOoQQZEM3LGxQTtLBxtcW3coCh8Do4d4h4thVcLPNHQ
         flLg==
X-Gm-Message-State: ACrzQf1bU86c/jm6dOuI2pi/wMy6qmY0oiL8G/Pm3StxwOExpIPhmkIv
	NGdq6DZU9laMZ8uXvLmlZg9ll1yXkzZawQ==
X-Google-Smtp-Source: AMsMyM5D5Nq/FF4NjxJ9wcjWPtdJdHDDKhmDyCHa92aR9ch/uzXxQuQvg528oWPWoR+VNh2C0gHDbA==
X-Received: by 2002:a17:90b:3901:b0:20b:210d:d5d9 with SMTP id ob1-20020a17090b390100b0020b210dd5d9mr9728986pjb.83.1665655150253;
        Thu, 13 Oct 2022 02:59:10 -0700 (PDT)
Return-Path: <sunilvl@ventanamicro.com>
Received: from localhost.localdomain ([49.206.13.138])
        by smtp.gmail.com with ESMTPSA id w8-20020a17090abc0800b0020d43c5c9a0sm2931845pjr.18.2022.10.13.02.59.08
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 13 Oct 2022 02:59:09 -0700 (PDT)
From: "Sunil V L" <sunilvl@ventanamicro.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Jordan Justen <jordan.l.justen@intel.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [edk2-staging/RiscV64QemuVirt PATCH V3 11/34] OvmfPkg/PlatformPei: Refactor to allow other architectures
Date: Thu, 13 Oct 2022 15:28:06 +0530
Message-Id: <20221013095829.1454581-12-sunilvl@ventanamicro.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20221013095829.1454581-1-sunilvl@ventanamicro.com>
References: <20221013095829.1454581-1-sunilvl@ventanamicro.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4076

Currently, PlatformPei supports only X86 architecture. So,
refactor it to allow other CPU architectures.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
---
 OvmfPkg/PlatformPei/PlatformPei.inf           | 34 +++++++++++--------
 OvmfPkg/PlatformPei/{ => Ia32_X64}/Platform.h |  0
 OvmfPkg/PlatformPei/{ => Ia32_X64}/AmdSev.c   |  0
 .../PlatformPei/{ => Ia32_X64}/ClearCache.c   |  0
 .../{ => Ia32_X64}/FeatureControl.c           |  0
 OvmfPkg/PlatformPei/{ => Ia32_X64}/Fv.c       |  0
 OvmfPkg/PlatformPei/{ => Ia32_X64}/IntelTdx.c |  0
 .../PlatformPei/{ => Ia32_X64}/MemDetect.c    |  0
 .../PlatformPei/{ => Ia32_X64}/MemTypeInfo.c  |  0
 OvmfPkg/PlatformPei/{ => Ia32_X64}/Platform.c |  0
 10 files changed, 19 insertions(+), 15 deletions(-)
 rename OvmfPkg/PlatformPei/{ => Ia32_X64}/Platform.h (100%)
 rename OvmfPkg/PlatformPei/{ => Ia32_X64}/AmdSev.c (100%)
 rename OvmfPkg/PlatformPei/{ => Ia32_X64}/ClearCache.c (100%)
 rename OvmfPkg/PlatformPei/{ => Ia32_X64}/FeatureControl.c (100%)
 rename OvmfPkg/PlatformPei/{ => Ia32_X64}/Fv.c (100%)
 rename OvmfPkg/PlatformPei/{ => Ia32_X64}/IntelTdx.c (100%)
 rename OvmfPkg/PlatformPei/{ => Ia32_X64}/MemDetect.c (100%)
 rename OvmfPkg/PlatformPei/{ => Ia32_X64}/MemTypeInfo.c (100%)
 rename OvmfPkg/PlatformPei/{ => Ia32_X64}/Platform.c (100%)

diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
index 3cd83e6ec3e5..683ebf1a440a 100644
--- a/OvmfPkg/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/PlatformPei/PlatformPei.inf
@@ -22,16 +22,16 @@ [Defines]
 #  VALID_ARCHITECTURES           = IA32 X64 EBC
 #
 
-[Sources]
-  AmdSev.c
-  ClearCache.c
-  FeatureControl.c
-  Fv.c
-  MemDetect.c
-  MemTypeInfo.c
-  Platform.c
-  Platform.h
-  IntelTdx.c
+[Sources.IA32, Sources.X64]
+  Ia32_X64/AmdSev.c
+  Ia32_X64/ClearCache.c
+  Ia32_X64/FeatureControl.c
+  Ia32_X64/Fv.c
+  Ia32_X64/MemDetect.c
+  Ia32_X64/MemTypeInfo.c
+  Ia32_X64/Platform.c
+  Ia32_X64/Platform.h
+  Ia32_X64/IntelTdx.c
 
 [Packages]
   EmbeddedPkg/EmbeddedPkg.dec
@@ -57,14 +57,16 @@ [LibraryClasses]
   PeiServicesLib
   PeiServicesTablePointerLib
   PeimEntryPoint
+  PcdLib
+  PlatformInitLib
+
+[LibraryClasses.IA32, LibraryClasses.X64]
+  MtrrLib
+  VmgExitLib
   QemuFwCfgLib
   QemuFwCfgS3Lib
   QemuFwCfgSimpleParserLib
-  MtrrLib
   MemEncryptSevLib
-  PcdLib
-  VmgExitLib
-  PlatformInitLib
 
 [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase
@@ -99,7 +101,6 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved
-  gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
   gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
@@ -116,6 +117,9 @@ [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdGhcbHypervisorFeatures
   gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask
 
+[Pcd.IA32, Pcd.X64]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
+
 [FixedPcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidBase
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidSize
diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Ia32_X64/Platform.h
similarity index 100%
rename from OvmfPkg/PlatformPei/Platform.h
rename to OvmfPkg/PlatformPei/Ia32_X64/Platform.h
diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/Ia32_X64/AmdSev.c
similarity index 100%
rename from OvmfPkg/PlatformPei/AmdSev.c
rename to OvmfPkg/PlatformPei/Ia32_X64/AmdSev.c
diff --git a/OvmfPkg/PlatformPei/ClearCache.c b/OvmfPkg/PlatformPei/Ia32_X64/ClearCache.c
similarity index 100%
rename from OvmfPkg/PlatformPei/ClearCache.c
rename to OvmfPkg/PlatformPei/Ia32_X64/ClearCache.c
diff --git a/OvmfPkg/PlatformPei/FeatureControl.c b/OvmfPkg/PlatformPei/Ia32_X64/FeatureControl.c
similarity index 100%
rename from OvmfPkg/PlatformPei/FeatureControl.c
rename to OvmfPkg/PlatformPei/Ia32_X64/FeatureControl.c
diff --git a/OvmfPkg/PlatformPei/Fv.c b/OvmfPkg/PlatformPei/Ia32_X64/Fv.c
similarity index 100%
rename from OvmfPkg/PlatformPei/Fv.c
rename to OvmfPkg/PlatformPei/Ia32_X64/Fv.c
diff --git a/OvmfPkg/PlatformPei/IntelTdx.c b/OvmfPkg/PlatformPei/Ia32_X64/IntelTdx.c
similarity index 100%
rename from OvmfPkg/PlatformPei/IntelTdx.c
rename to OvmfPkg/PlatformPei/Ia32_X64/IntelTdx.c
diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/Ia32_X64/MemDetect.c
similarity index 100%
rename from OvmfPkg/PlatformPei/MemDetect.c
rename to OvmfPkg/PlatformPei/Ia32_X64/MemDetect.c
diff --git a/OvmfPkg/PlatformPei/MemTypeInfo.c b/OvmfPkg/PlatformPei/Ia32_X64/MemTypeInfo.c
similarity index 100%
rename from OvmfPkg/PlatformPei/MemTypeInfo.c
rename to OvmfPkg/PlatformPei/Ia32_X64/MemTypeInfo.c
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Ia32_X64/Platform.c
similarity index 100%
rename from OvmfPkg/PlatformPei/Platform.c
rename to OvmfPkg/PlatformPei/Ia32_X64/Platform.c
-- 
2.25.1