[PATCH v6 46/52] KabylakeOpenBoardPkg/PeiSerialPortLibSpiFlash: Update for new SPI PPI API


Michael Kubacki
 

From: Michael Kubacki <michael.kubacki@...>

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

Updates usage of gPchSpiPpiGuid to use the new interface that
identifies SPI flash regions by GUID.

Cc: Chasel Chiu <chasel.chiu@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Signed-off-by: Michael Kubacki <michael.kubacki@...>
Reviewed-by: Chasel Chiu <chasel.chiu@...>
Tested-by: Benjamin Doron <benjamin.doron00@...>
---
Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlash/Pei=
SerialPortLibSpiFlash.c | 46 ++++++++++----------
Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlash/Pei=
SerialPortLibSpiFlash.inf | 3 +-
2 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLib=
SpiFlash/PeiSerialPortLibSpiFlash.c b/Platform/Intel/KabylakeOpenBoardPkg=
/Library/PeiSerialPortLibSpiFlash/PeiSerialPortLibSpiFlash.c
index fc48bdc6fccb..17fa328add1c 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlas=
h/PeiSerialPortLibSpiFlash.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlas=
h/PeiSerialPortLibSpiFlash.c
@@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
=20
#include <Base.h>
-#include <Ppi/Spi.h>
+#include <Ppi/Spi2.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/HobLib.h>
@@ -24,29 +24,29 @@ typedef struct {
/**
Returns a pointer to the PCH SPI PPI.
=20
- @return Pointer to PCH_SPI_PPI If an instance of the PCH SPI PPI is=
found
+ @return Pointer to PCH_SPI2_PPI If an instance of the PCH SPI PPI is=
found
@return NULL If an instance of the PCH SPI PPI is=
not found
=20
**/
-PCH_SPI_PPI *
+PCH_SPI2_PPI *
GetSpiPpi (
VOID
)
{
EFI_STATUS Status;
- PCH_SPI_PPI *PchSpiPpi;
+ PCH_SPI2_PPI *PchSpi2Ppi;
=20
Status =3D PeiServicesLocatePpi (
- &gPchSpiPpiGuid,
+ &gPchSpi2PpiGuid,
0,
NULL,
- (VOID **) &PchSpiPpi
+ (VOID **) &PchSpi2Ppi
);
if (EFI_ERROR (Status)) {
return NULL;
}
=20
- return PchSpiPpi;
+ return PchSpi2Ppi;
}
=20
/**
@@ -67,7 +67,7 @@ SerialPortWrite (
EFI_STATUS Status;
EFI_HOB_GUID_TYPE *GuidHob;
SPI_FLASH_DEBUG_CONTEXT *Context;
- PCH_SPI_PPI *PchSpiPpi;
+ PCH_SPI2_PPI *PchSpi2Ppi;
UINT32 BytesWritten;
UINT32 SourceBufferOffset;
UINT32 NvMessageAreaSize;
@@ -89,19 +89,19 @@ SerialPortWrite (
if (Context =3D=3D NULL || Context->CurrentWriteOffset >=3D NvMessageA=
reaSize) {
return 0;
}
- PchSpiPpi =3D GetSpiPpi ();
- if (PchSpiPpi =3D=3D NULL) {
+ PchSpi2Ppi =3D GetSpiPpi ();
+ if (PchSpi2Ppi =3D=3D NULL) {
return 0;
}
=20
if ((Context->CurrentWriteOffset + NumberOfBytes) / NvMessageAreaSize =
0) {
LinearOffset =3D (UINT32) (FixedPcdGet32 (PcdFlashNvDebugMessageBase=
) - FixedPcdGet32 (PcdFlashAreaBaseAddress));
- Status =3D PchSpiPpi->FlashErase (
- PchSpiPpi,
- FlashRegionBios,
- LinearOffset,
- NvMessageAreaSize
- );
+ Status =3D PchSpi2Ppi->FlashErase (
+ PchSpi2Ppi,
+ &gFlashRegionBiosGuid,
+ LinearOffset,
+ NvMessageAreaSize
+ );
if (!EFI_ERROR (Status)) {
Context->CurrentWriteOffset =3D 0;
} else {
@@ -116,13 +116,13 @@ SerialPortWrite (
=20
LinearOffset =3D (FixedPcdGet32 (PcdFlashNvDebugMessageBase) + Context=
->CurrentWriteOffset) - FixedPcdGet32 (PcdFlashAreaBaseAddress);
=20
- Status =3D PchSpiPpi->FlashWrite (
- PchSpiPpi,
- FlashRegionBios,
- LinearOffset,
- BytesWritten,
- (UINT8 *) &Buffer[SourceBufferOffset]
- );
+ Status =3D PchSpi2Ppi->FlashWrite (
+ PchSpi2Ppi,
+ &gFlashRegionBiosGuid,
+ LinearOffset,
+ BytesWritten,
+ (UINT8 *) &Buffer[SourceBufferOffset]
+ );
if (!EFI_ERROR (Status)) {
Context->CurrentWriteOffset +=3D BytesWritten;
return BytesWritten;
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLib=
SpiFlash/PeiSerialPortLibSpiFlash.inf b/Platform/Intel/KabylakeOpenBoardP=
kg/Library/PeiSerialPortLibSpiFlash/PeiSerialPortLibSpiFlash.inf
index b959cd1f4612..651bf93faf62 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlas=
h/PeiSerialPortLibSpiFlash.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlas=
h/PeiSerialPortLibSpiFlash.inf
@@ -40,9 +40,10 @@ [Sources]
PeiSerialPortLibSpiFlash.c
=20
[Ppis]
- gPchSpiPpiGuid
+ gPchSpi2PpiGuid
=20
[Guids]
+ gFlashRegionBiosGuid
gSpiFlashDebugHobGuid
=20
[Pcd]
--=20
2.28.0.windows.1


Nate DeSimone
 

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@...>

-----Original Message-----
From: mikuback@... <mikuback@...>
Sent: Thursday, October 28, 2021 3:09 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel <chasel.chiu@...>; Desimone, Nathaniel L <nathaniel.l.desimone@...>; Benjamin Doron <benjamin.doron00@...>
Subject: [PATCH v6 46/52] KabylakeOpenBoardPkg/PeiSerialPortLibSpiFlash: Update for new SPI PPI API

From: Michael Kubacki <michael.kubacki@...>

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

Updates usage of gPchSpiPpiGuid to use the new interface that identifies SPI flash regions by GUID.

Cc: Chasel Chiu <chasel.chiu@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Signed-off-by: Michael Kubacki <michael.kubacki@...>
Reviewed-by: Chasel Chiu <chasel.chiu@...>
Tested-by: Benjamin Doron <benjamin.doron00@...>
---
Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlash/PeiSerialPortLibSpiFlash.c | 46 ++++++++++----------
Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlash/PeiSerialPortLibSpiFlash.inf | 3 +-
2 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlash/PeiSerialPortLibSpiFlash.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlash/PeiSerialPortLibSpiFlash.c
index fc48bdc6fccb..17fa328add1c 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlash/PeiSerialPortLibSpiFlash.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFla
+++ sh/PeiSerialPortLibSpiFlash.c
@@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/

#include <Base.h>
-#include <Ppi/Spi.h>
+#include <Ppi/Spi2.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/HobLib.h>
@@ -24,29 +24,29 @@ typedef struct {
/**
Returns a pointer to the PCH SPI PPI.

- @return Pointer to PCH_SPI_PPI If an instance of the PCH SPI PPI is found
+ @return Pointer to PCH_SPI2_PPI If an instance of the PCH SPI PPI is found
@return NULL If an instance of the PCH SPI PPI is not found

**/
-PCH_SPI_PPI *
+PCH_SPI2_PPI *
GetSpiPpi (
VOID
)
{
EFI_STATUS Status;
- PCH_SPI_PPI *PchSpiPpi;
+ PCH_SPI2_PPI *PchSpi2Ppi;

Status = PeiServicesLocatePpi (
- &gPchSpiPpiGuid,
+ &gPchSpi2PpiGuid,
0,
NULL,
- (VOID **) &PchSpiPpi
+ (VOID **) &PchSpi2Ppi
);
if (EFI_ERROR (Status)) {
return NULL;
}

- return PchSpiPpi;
+ return PchSpi2Ppi;
}

/**
@@ -67,7 +67,7 @@ SerialPortWrite (
EFI_STATUS Status;
EFI_HOB_GUID_TYPE *GuidHob;
SPI_FLASH_DEBUG_CONTEXT *Context;
- PCH_SPI_PPI *PchSpiPpi;
+ PCH_SPI2_PPI *PchSpi2Ppi;
UINT32 BytesWritten;
UINT32 SourceBufferOffset;
UINT32 NvMessageAreaSize;
@@ -89,19 +89,19 @@ SerialPortWrite (
if (Context == NULL || Context->CurrentWriteOffset >= NvMessageAreaSize) {
return 0;
}
- PchSpiPpi = GetSpiPpi ();
- if (PchSpiPpi == NULL) {
+ PchSpi2Ppi = GetSpiPpi ();
+ if (PchSpi2Ppi == NULL) {
return 0;
}

if ((Context->CurrentWriteOffset + NumberOfBytes) / NvMessageAreaSize > 0) {
LinearOffset = (UINT32) (FixedPcdGet32 (PcdFlashNvDebugMessageBase) - FixedPcdGet32 (PcdFlashAreaBaseAddress));
- Status = PchSpiPpi->FlashErase (
- PchSpiPpi,
- FlashRegionBios,
- LinearOffset,
- NvMessageAreaSize
- );
+ Status = PchSpi2Ppi->FlashErase (
+ PchSpi2Ppi,
+ &gFlashRegionBiosGuid,
+ LinearOffset,
+ NvMessageAreaSize
+ );
if (!EFI_ERROR (Status)) {
Context->CurrentWriteOffset = 0;
} else {
@@ -116,13 +116,13 @@ SerialPortWrite (

LinearOffset = (FixedPcdGet32 (PcdFlashNvDebugMessageBase) + Context->CurrentWriteOffset) - FixedPcdGet32 (PcdFlashAreaBaseAddress);

- Status = PchSpiPpi->FlashWrite (
- PchSpiPpi,
- FlashRegionBios,
- LinearOffset,
- BytesWritten,
- (UINT8 *) &Buffer[SourceBufferOffset]
- );
+ Status = PchSpi2Ppi->FlashWrite (
+ PchSpi2Ppi,
+ &gFlashRegionBiosGuid,
+ LinearOffset,
+ BytesWritten,
+ (UINT8 *) &Buffer[SourceBufferOffset]
+ );
if (!EFI_ERROR (Status)) {
Context->CurrentWriteOffset += BytesWritten;
return BytesWritten;
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlash/PeiSerialPortLibSpiFlash.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlash/PeiSerialPortLibSpiFlash.inf
index b959cd1f4612..651bf93faf62 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFlash/PeiSerialPortLibSpiFlash.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/PeiSerialPortLibSpiFla
+++ sh/PeiSerialPortLibSpiFlash.inf
@@ -40,9 +40,10 @@ [Sources]
PeiSerialPortLibSpiFlash.c

[Ppis]
- gPchSpiPpiGuid
+ gPchSpi2PpiGuid

[Guids]
+ gFlashRegionBiosGuid
gSpiFlashDebugHobGuid

[Pcd]
--
2.28.0.windows.1