Re: [edk2-devel] [edk2-platforms:PATCH] Intel/IntelSiliconPkg Implement SmmAccess in IntelSiliconPkg

2019-08-24 Thread Marc W Chen
Thanks Ray and Sai for reviewing, please see my below reply for your questions.

1. The reason why I put the Library folder in Feature/SmmAccess folder is 
because I saw Feature/Capsule also doing it this way, so I thought we want to 
put all related implementation in the same feature folder including library, 
please let me know if you want me to move the PeiSmmAccessLib to root Library 
folder.

2. I saw that Vtd also depend on MdeModulePkg, so I thought IntelSiliconPkg is 
allowed to use MdeModulePkg, and SmmAccess code need SmmAccess.h, which is in 
MdeModulePkg, even we can change to use MmAccess.h from MdePkg now, but I 
thought the SMM is belong to x86 silicon, so use SmmAccess.h is better than 
MmAccess.h, let me know if you prefer to use MmAccess, then I'll modify the 
Patch to use that.

Thanks,
Marc

> -Original Message-
> From: Ni, Ray
> Sent: Saturday, August 24, 2019 5:03 AM
> To: Chaganty, Rangasai V ; Chen, Marc W
> ; devel@edk2.groups.io
> Subject: RE: [edk2-platforms:PATCH] Intel/IntelSiliconPkg Implement
> SmmAccess in IntelSiliconPkg
> 
> It's not recommended to make IntelSiliconPkg depend on MdeModulePkg.
> 
> > -Original Message-
> > From: Chaganty, Rangasai V
> > Sent: Friday, August 23, 2019 11:34 AM
> > To: Chen, Marc W ; devel@edk2.groups.io
> > Cc: Ni, Ray 
> > Subject: RE: [edk2-platforms:PATCH] Intel/IntelSiliconPkg Implement
> SmmAccess in IntelSiliconPkg
> >
> > May I know the reason to implement the SmmAccessLib instance under
> \Feature folder?
> > Can we move it under IntelSiliconPkg\Library (We need to create a library
> folder in the root) and keep just the module in the
> > \Feature folder?
> >
> > I've noticed there is a dependency on MdeModulePkg with this change.
> > Could you provide the reason to have such dependency as part of this
> change?
> >
> > Thanks,
> > Sai
> >
> > -Original Message-
> > From: Chen, Marc W
> > Sent: Friday, August 23, 2019 3:28 AM
> > To: devel@edk2.groups.io
> > Cc: Chen, Marc W ; Ni, Ray ;
> Chaganty, Rangasai V
> > 
> > Subject: [edk2-platforms:PATCH] Intel/IntelSiliconPkg Implement
> SmmAccess in IntelSiliconPkg
> >
> > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2121
> >
> > Implement SmmAccess for PEI and DXE phase in IntelSiliconPkg
> >
> > Signed-off-by: Marc Chen 
> > Cc: Ray Ni 
> > Cc: Rangasai V Chaganty 
> > ---
> >  .../Library/PeiSmmAccessLib/PeiSmmAccessLib.c  | 343
> +
> >  .../Library/PeiSmmAccessLib/PeiSmmAccessLib.inf|  42 +++
> >  .../Feature/SmmAccess/SmmAccessDxe/SmmAccess.inf   |  47 +++
> >  .../SmmAccess/SmmAccessDxe/SmmAccessDriver.c   | 267
> 
> >  .../SmmAccess/SmmAccessDxe/SmmAccessDriver.h   | 160 ++
> >  .../IntelSiliconPkg/Include/Library/SmmAccessLib.h |  32 ++
> >  6 files changed, 891 insertions(+)
> >  create mode 100644
> Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/
> PeiSmmAccessLib.c
> >  create mode 100644
> Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/
> PeiSmmAccessLib.inf
> >  create mode 100644
> Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/SmmAccessDxe/SmmAcce
> ss.inf
> >  create mode 100644
> Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/SmmAccessDxe/SmmAcce
> ssDriver.c
> >  create mode 100644
> Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/SmmAccessDxe/SmmAcce
> ssDriver.h
> >  create mode 100644
> Silicon/Intel/IntelSiliconPkg/Include/Library/SmmAccessLib.h
> >
> > diff --git
> a/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLi
> b/PeiSmmAccessLib.c
> >
> b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLi
> b/PeiSmmAccessLib.c
> > new file mode 100644
> > index 00..88eb217d2a
> > --- /dev/null
> > +++
> b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAcce
> > +++ ssLib/PeiSmmAccessLib.c
> > @@ -0,0 +1,343 @@
> > +/** @file
> > +  This is to publish the SMM Access Ppi instance.
> > +
> > +  Copyright (c) 2019, Intel Corporation. All rights reserved.
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +#include 
> > +#include 
> > +#include  #include
> > + #include  #include
> > + #include  #include
> > +
> > +
> > +#include 
> > +#include 
> > +
> > +#define SMM_ACCESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('4',
> '5', 's',
> > +'a')
> > +
> > +///
> > +/// Private data
> > +///
> > +type

Re: [edk2-devel] [edk2-platforms:PATCH] Intel/IntelSiliconPkg Implement SmmAccess in IntelSiliconPkg

2019-08-23 Thread Ni, Ray
It's not recommended to make IntelSiliconPkg depend on MdeModulePkg.

> -Original Message-
> From: Chaganty, Rangasai V
> Sent: Friday, August 23, 2019 11:34 AM
> To: Chen, Marc W ; devel@edk2.groups.io
> Cc: Ni, Ray 
> Subject: RE: [edk2-platforms:PATCH] Intel/IntelSiliconPkg Implement SmmAccess 
> in IntelSiliconPkg
> 
> May I know the reason to implement the SmmAccessLib instance under \Feature 
> folder?
> Can we move it under IntelSiliconPkg\Library (We need to create a library 
> folder in the root) and keep just the module in the
> \Feature folder?
> 
> I've noticed there is a dependency on MdeModulePkg with this change.
> Could you provide the reason to have such dependency as part of this change?
> 
> Thanks,
> Sai
> 
> -Original Message-
> From: Chen, Marc W
> Sent: Friday, August 23, 2019 3:28 AM
> To: devel@edk2.groups.io
> Cc: Chen, Marc W ; Ni, Ray ; 
> Chaganty, Rangasai V
> 
> Subject: [edk2-platforms:PATCH] Intel/IntelSiliconPkg Implement SmmAccess in 
> IntelSiliconPkg
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2121
> 
> Implement SmmAccess for PEI and DXE phase in IntelSiliconPkg
> 
> Signed-off-by: Marc Chen 
> Cc: Ray Ni 
> Cc: Rangasai V Chaganty 
> ---
>  .../Library/PeiSmmAccessLib/PeiSmmAccessLib.c  | 343 
> +
>  .../Library/PeiSmmAccessLib/PeiSmmAccessLib.inf|  42 +++
>  .../Feature/SmmAccess/SmmAccessDxe/SmmAccess.inf   |  47 +++
>  .../SmmAccess/SmmAccessDxe/SmmAccessDriver.c   | 267 
>  .../SmmAccess/SmmAccessDxe/SmmAccessDriver.h   | 160 ++
>  .../IntelSiliconPkg/Include/Library/SmmAccessLib.h |  32 ++
>  6 files changed, 891 insertions(+)
>  create mode 100644 
> Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
>  create mode 100644 
> Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.inf
>  create mode 100644 
> Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/SmmAccessDxe/SmmAccess.inf
>  create mode 100644 
> Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/SmmAccessDxe/SmmAccessDriver.c
>  create mode 100644 
> Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/SmmAccessDxe/SmmAccessDriver.h
>  create mode 100644 
> Silicon/Intel/IntelSiliconPkg/Include/Library/SmmAccessLib.h
> 
> diff --git 
> a/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
> b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
> new file mode 100644
> index 00..88eb217d2a
> --- /dev/null
> +++ b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAcce
> +++ ssLib/PeiSmmAccessLib.c
> @@ -0,0 +1,343 @@
> +/** @file
> +  This is to publish the SMM Access Ppi instance.
> +
> +  Copyright (c) 2019, Intel Corporation. All rights reserved.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include 
> +#include 
> +#include  #include
> + #include  #include
> + #include  #include
> +
> +
> +#include 
> +#include 
> +
> +#define SMM_ACCESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('4', '5', 's',
> +'a')
> +
> +///
> +/// Private data
> +///
> +typedef struct {
> +  UINTN Signature;
> +  EFI_HANDLEHandle;
> +  PEI_SMM_ACCESS_PPISmmAccess;
> +  //
> +  // Local Data for SMM Access interface goes here
> +  //
> +  UINTN NumberRegions;
> +  EFI_SMRAM_DESCRIPTOR  *SmramDesc;
> +} SMM_ACCESS_PRIVATE_DATA;
> +
> +#define SMM_ACCESS_PRIVATE_DATA_FROM_THIS(a) \
> +CR (a, \
> +  SMM_ACCESS_PRIVATE_DATA, \
> +  SmmAccess, \
> +  SMM_ACCESS_PRIVATE_DATA_SIGNATURE \
> +  )
> +
> +/**
> +  This routine accepts a request to "open" a region of SMRAM.  The
> +  region could be legacy ABSEG, HSEG, or TSEG near top of physical memory.
> +  The use of "open" means that the memory is visible from all PEIM
> +  and SMM agents.
> +
> +  @param[in] This -  Pointer to the SMM Access Interface.
> +  @param[in] DescriptorIndex  -  Region of SMRAM to Open.
> +  @param[in] PeiServices  -  General purpose services available to every 
> PEIM.
> +
> +  @retval EFI_SUCCESS-  The region was successfully opened.
> +  @retval EFI_DEVICE_ERROR   -  The region could not be opened because 
> locked by
> +chipset.
> +  @retval EFI_INVALID_PARAMETER  -  The descriptor index was out of bounds.
> +**/
> +EFI_STATUS
> +EFIAPI
> +Open (
> +  IN EFI_PEI_SERVICES   **PeiServices,
> +  IN PEI_SMM_ACCESS_PPI *This,
> +  IN UINTN  DescriptorIndex
> +  )
> +{
> +  SMM_ACCESS_PRIVATE_DATA *SmmAccess;
> +
> +  SmmAccess = SMM_ACCESS_PRIVATE_DATA_FROM_THIS (This);  if
> + (DescriptorIndex >= SmmAccess->NumberRegions) {
> +DEBUG ((DEBUG_WARN, "SMRAM region out of range\n"));
> +
> +return EFI_INVALID_PARAMETER;
> +  } else if (SmmAccess->SmramDesc[DescriptorIndex].RegionState & 
> EFI_SMRAM_LOCKED) {
> +   

Re: [edk2-devel] [edk2-platforms:PATCH] Intel/IntelSiliconPkg Implement SmmAccess in IntelSiliconPkg

2019-08-23 Thread Chaganty, Rangasai V
May I know the reason to implement the SmmAccessLib instance under \Feature 
folder?
Can we move it under IntelSiliconPkg\Library (We need to create a library 
folder in the root) and keep just the module in the \Feature folder?

I've noticed there is a dependency on MdeModulePkg with this change. 
Could you provide the reason to have such dependency as part of this change?

Thanks,
Sai

-Original Message-
From: Chen, Marc W 
Sent: Friday, August 23, 2019 3:28 AM
To: devel@edk2.groups.io
Cc: Chen, Marc W ; Ni, Ray ; Chaganty, 
Rangasai V 
Subject: [edk2-platforms:PATCH] Intel/IntelSiliconPkg Implement SmmAccess in 
IntelSiliconPkg

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

Implement SmmAccess for PEI and DXE phase in IntelSiliconPkg

Signed-off-by: Marc Chen 
Cc: Ray Ni 
Cc: Rangasai V Chaganty 
---
 .../Library/PeiSmmAccessLib/PeiSmmAccessLib.c  | 343 +
 .../Library/PeiSmmAccessLib/PeiSmmAccessLib.inf|  42 +++
 .../Feature/SmmAccess/SmmAccessDxe/SmmAccess.inf   |  47 +++
 .../SmmAccess/SmmAccessDxe/SmmAccessDriver.c   | 267 
 .../SmmAccess/SmmAccessDxe/SmmAccessDriver.h   | 160 ++
 .../IntelSiliconPkg/Include/Library/SmmAccessLib.h |  32 ++
 6 files changed, 891 insertions(+)
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.inf
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/SmmAccessDxe/SmmAccess.inf
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/SmmAccessDxe/SmmAccessDriver.c
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/SmmAccessDxe/SmmAccessDriver.h
 create mode 100644 Silicon/Intel/IntelSiliconPkg/Include/Library/SmmAccessLib.h

diff --git 
a/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
 
b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
new file mode 100644
index 00..88eb217d2a
--- /dev/null
+++ b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAcce
+++ ssLib/PeiSmmAccessLib.c
@@ -0,0 +1,343 @@
+/** @file
+  This is to publish the SMM Access Ppi instance.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include 
+#include 
+#include  #include 
+ #include  #include 
+ #include  #include 
+
+
+#include 
+#include 
+
+#define SMM_ACCESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('4', '5', 's', 
+'a')
+
+///
+/// Private data
+///
+typedef struct {
+  UINTN Signature;
+  EFI_HANDLEHandle;
+  PEI_SMM_ACCESS_PPISmmAccess;
+  //
+  // Local Data for SMM Access interface goes here
+  //
+  UINTN NumberRegions;
+  EFI_SMRAM_DESCRIPTOR  *SmramDesc;
+} SMM_ACCESS_PRIVATE_DATA;
+
+#define SMM_ACCESS_PRIVATE_DATA_FROM_THIS(a) \
+CR (a, \
+  SMM_ACCESS_PRIVATE_DATA, \
+  SmmAccess, \
+  SMM_ACCESS_PRIVATE_DATA_SIGNATURE \
+  )
+
+/**
+  This routine accepts a request to "open" a region of SMRAM.  The
+  region could be legacy ABSEG, HSEG, or TSEG near top of physical memory.
+  The use of "open" means that the memory is visible from all PEIM
+  and SMM agents.
+
+  @param[in] This -  Pointer to the SMM Access Interface.
+  @param[in] DescriptorIndex  -  Region of SMRAM to Open.
+  @param[in] PeiServices  -  General purpose services available to every 
PEIM.
+
+  @retval EFI_SUCCESS-  The region was successfully opened.
+  @retval EFI_DEVICE_ERROR   -  The region could not be opened because 
locked by
+chipset.
+  @retval EFI_INVALID_PARAMETER  -  The descriptor index was out of bounds.
+**/
+EFI_STATUS
+EFIAPI
+Open (
+  IN EFI_PEI_SERVICES   **PeiServices,
+  IN PEI_SMM_ACCESS_PPI *This,
+  IN UINTN  DescriptorIndex
+  )
+{
+  SMM_ACCESS_PRIVATE_DATA *SmmAccess;
+
+  SmmAccess = SMM_ACCESS_PRIVATE_DATA_FROM_THIS (This);  if 
+ (DescriptorIndex >= SmmAccess->NumberRegions) {
+DEBUG ((DEBUG_WARN, "SMRAM region out of range\n"));
+
+return EFI_INVALID_PARAMETER;
+  } else if (SmmAccess->SmramDesc[DescriptorIndex].RegionState & 
EFI_SMRAM_LOCKED) {
+//
+// Cannot open a "locked" region
+//
+DEBUG ((DEBUG_WARN, "Cannot open a locked SMRAM region\n"));
+
+return EFI_DEVICE_ERROR;
+  }
+
+  SmmAccess->SmramDesc[DescriptorIndex].RegionState &= (UINT64) 
+~(EFI_SMRAM_CLOSED | EFI_ALLOCATED);
+  SmmAccess->SmramDesc[DescriptorIndex].RegionState |= (UINT64) 
+EFI_SMRAM_OPEN;
+  SmmAccess->SmmAccess.OpenState = TRUE;
+  return EFI_SUCCESS;
+}
+
+/**
+  This routine accepts a request to "close" a region of SMRAM.  This is 
+valid for
+  compatible SMRAM region.
+
+  @param[in] PeiServices  -  General purpose services 

[edk2-devel] [edk2-platforms:PATCH] Intel/IntelSiliconPkg Implement SmmAccess in IntelSiliconPkg

2019-08-23 Thread Marc W Chen
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2121

Implement SmmAccess for PEI and DXE phase in IntelSiliconPkg

Signed-off-by: Marc Chen 
Cc: Ray Ni 
Cc: Rangasai V Chaganty 
---
 .../Library/PeiSmmAccessLib/PeiSmmAccessLib.c  | 343 +
 .../Library/PeiSmmAccessLib/PeiSmmAccessLib.inf|  42 +++
 .../Feature/SmmAccess/SmmAccessDxe/SmmAccess.inf   |  47 +++
 .../SmmAccess/SmmAccessDxe/SmmAccessDriver.c   | 267 
 .../SmmAccess/SmmAccessDxe/SmmAccessDriver.h   | 160 ++
 .../IntelSiliconPkg/Include/Library/SmmAccessLib.h |  32 ++
 6 files changed, 891 insertions(+)
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.inf
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/SmmAccessDxe/SmmAccess.inf
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/SmmAccessDxe/SmmAccessDriver.c
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/SmmAccessDxe/SmmAccessDriver.h
 create mode 100644 Silicon/Intel/IntelSiliconPkg/Include/Library/SmmAccessLib.h

diff --git 
a/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
 
b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
new file mode 100644
index 00..88eb217d2a
--- /dev/null
+++ 
b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
@@ -0,0 +1,343 @@
+/** @file
+  This is to publish the SMM Access Ppi instance.
+
+  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define SMM_ACCESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('4', '5', 's', 'a')
+
+///
+/// Private data
+///
+typedef struct {
+  UINTN Signature;
+  EFI_HANDLEHandle;
+  PEI_SMM_ACCESS_PPISmmAccess;
+  //
+  // Local Data for SMM Access interface goes here
+  //
+  UINTN NumberRegions;
+  EFI_SMRAM_DESCRIPTOR  *SmramDesc;
+} SMM_ACCESS_PRIVATE_DATA;
+
+#define SMM_ACCESS_PRIVATE_DATA_FROM_THIS(a) \
+CR (a, \
+  SMM_ACCESS_PRIVATE_DATA, \
+  SmmAccess, \
+  SMM_ACCESS_PRIVATE_DATA_SIGNATURE \
+  )
+
+/**
+  This routine accepts a request to "open" a region of SMRAM.  The
+  region could be legacy ABSEG, HSEG, or TSEG near top of physical memory.
+  The use of "open" means that the memory is visible from all PEIM
+  and SMM agents.
+
+  @param[in] This -  Pointer to the SMM Access Interface.
+  @param[in] DescriptorIndex  -  Region of SMRAM to Open.
+  @param[in] PeiServices  -  General purpose services available to every 
PEIM.
+
+  @retval EFI_SUCCESS-  The region was successfully opened.
+  @retval EFI_DEVICE_ERROR   -  The region could not be opened because 
locked by
+chipset.
+  @retval EFI_INVALID_PARAMETER  -  The descriptor index was out of bounds.
+**/
+EFI_STATUS
+EFIAPI
+Open (
+  IN EFI_PEI_SERVICES   **PeiServices,
+  IN PEI_SMM_ACCESS_PPI *This,
+  IN UINTN  DescriptorIndex
+  )
+{
+  SMM_ACCESS_PRIVATE_DATA *SmmAccess;
+
+  SmmAccess = SMM_ACCESS_PRIVATE_DATA_FROM_THIS (This);
+  if (DescriptorIndex >= SmmAccess->NumberRegions) {
+DEBUG ((DEBUG_WARN, "SMRAM region out of range\n"));
+
+return EFI_INVALID_PARAMETER;
+  } else if (SmmAccess->SmramDesc[DescriptorIndex].RegionState & 
EFI_SMRAM_LOCKED) {
+//
+// Cannot open a "locked" region
+//
+DEBUG ((DEBUG_WARN, "Cannot open a locked SMRAM region\n"));
+
+return EFI_DEVICE_ERROR;
+  }
+
+  SmmAccess->SmramDesc[DescriptorIndex].RegionState &= (UINT64) 
~(EFI_SMRAM_CLOSED | EFI_ALLOCATED);
+  SmmAccess->SmramDesc[DescriptorIndex].RegionState |= (UINT64) EFI_SMRAM_OPEN;
+  SmmAccess->SmmAccess.OpenState = TRUE;
+  return EFI_SUCCESS;
+}
+
+/**
+  This routine accepts a request to "close" a region of SMRAM.  This is valid 
for
+  compatible SMRAM region.
+
+  @param[in] PeiServices  -  General purpose services available to every 
PEIM.
+  @param[in] This -  Pointer to the SMM Access Interface.
+  @param[in] DescriptorIndex  -  Region of SMRAM to Close.
+
+  @retval EFI_SUCCESS-  The region was successfully closed.
+  @retval EFI_DEVICE_ERROR   -  The region could not be closed because 
locked by
+chipset.
+  @retval EFI_INVALID_PARAMETER  -  The descriptor index was out of bounds.
+**/
+EFI_STATUS
+EFIAPI
+Close (
+  IN EFI_PEI_SERVICES**PeiServices,
+  IN PEI_SMM_ACCESS_PPI  *This,
+  IN UINTN   DescriptorIndex
+  )
+{
+  SMM_ACCESS_PRIVATE_DATA *SmmAccess;
+  BOOLEAN