summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UnixPkg/Include/Library/SecDispatchTableLib.h33
-rw-r--r--UnixPkg/Include/Protocol/UnixThunk.h14
-rw-r--r--UnixPkg/Library/SecDispatchTableLib/SecDispatchTableLib.c41
-rw-r--r--UnixPkg/Library/SecDispatchTableLib/SecDispatchTableLib.inf1
-rw-r--r--UnixPkg/Sec/SecMain.c11
-rw-r--r--UnixPkg/UnixPkg.dsc2
6 files changed, 78 insertions, 24 deletions
diff --git a/UnixPkg/Include/Library/SecDispatchTableLib.h b/UnixPkg/Include/Library/SecDispatchTableLib.h
index 6cebb58..9e22007 100644
--- a/UnixPkg/Include/Library/SecDispatchTableLib.h
+++ b/UnixPkg/Include/Library/SecDispatchTableLib.h
@@ -17,21 +17,40 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#ifndef __SEC_DISPATCH_TABLE_LIB_H__
#define __SEC_DISPATCH_TABLE_LIB_H__
+
/**
- Allow an override of the Sec PPI Dispatch Table. This table contains PPIs passed
- up from SEC to PEI. This function is responcible for allocating space for the
- overridden table.
+ Return the number of bytes that OverrideDispatchTable() will append to
+ the dispatch table.
+
+ @return Size of table in bytes OverrideDispatchTable() will return
+**/
+UINTN
+EFIAPI
+OverrideDispatchTableExtraSize (
+ VOID
+ );
+
+
+/**
+ Allow an override of the Sec PPI Dispatch Table. This table contains PPIs passed
+ up from SEC to PEI.
- @param OriginalTable SECs default PPI dispatch table
+ @param OriginalTable SECs default PPI dispatch table
+ @param OriginalTableSize Size of SECs default PPI dispatch table
+ @param NewTable New dispatch table
+ @param NewTableSize Size of of the NewTable in bytes
- @return OriginalTable or override of the table
+ @return EFI_SUCCESS table was copied
**/
-EFI_PEI_PPI_DESCRIPTOR *
+EFI_STATUS
EFIAPI
OverrideDispatchTable (
- IN CONST EFI_PEI_PPI_DESCRIPTOR *OriginalTable
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *OriginalTable,
+ IN UINTN OriginalTableSize,
+ IN OUT EFI_PEI_PPI_DESCRIPTOR *NewTable,
+ IN UINTN NewTableSize
);
diff --git a/UnixPkg/Include/Protocol/UnixThunk.h b/UnixPkg/Include/Protocol/UnixThunk.h
index 689e32f..12d07f9 100644
--- a/UnixPkg/Include/Protocol/UnixThunk.h
+++ b/UnixPkg/Include/Protocol/UnixThunk.h
@@ -373,13 +373,13 @@ typedef struct _EFI_UNIX_THUNK_PROTOCOL {
UnixGetTimeZone GetTimeZone;
UnixGetDayLight GetDayLight;
UnixPoll Poll;
- UnixRead Read;
- UnixWrite Write;
- UnixGetenv Getenv;
- UnixOpen Open;
- UnixSeek Lseek;
- UnixFtruncate FTruncate;
- UnixClose Close;
+ UnixRead Read;
+ UnixWrite Write;
+ UnixGetenv Getenv;
+ UnixOpen Open;
+ UnixSeek Lseek;
+ UnixFtruncate FTruncate;
+ UnixClose Close;
UnixMkdir MkDir;
UnixRmDir RmDir;
UnixUnLink UnLink;
diff --git a/UnixPkg/Library/SecDispatchTableLib/SecDispatchTableLib.c b/UnixPkg/Library/SecDispatchTableLib/SecDispatchTableLib.c
index da3d182..924547d 100644
--- a/UnixPkg/Library/SecDispatchTableLib/SecDispatchTableLib.c
+++ b/UnixPkg/Library/SecDispatchTableLib/SecDispatchTableLib.c
@@ -14,23 +14,48 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
--*/
#include <PiPei.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/SecDispatchTableLib.h>
+
/**
- Allow an override of the Sec PPI Dispatch Table. This table contains PPIs passed
- up from SEC to PEI. This function is responcible for allocating space for the
- overridden table.
+ Return the number of bytes that OverrideDispatchTable() will append to
+ the dispatch table.
+ @return Size of table in bytes OverrideDispatchTable() will return
- @param OriginalTable SECs default PPI dispatch table
+**/
+UINTN
+EFIAPI
+OverrideDispatchTableExtraSize (
+ )
+{
+ return 0;
+}
- @return OriginalTable or override of the table
+
+/**
+ Allow an override of the Sec PPI Dispatch Table. This table contains PPIs passed
+ up from SEC to PEI.
+
+ @param OriginalTable SECs default PPI dispatch table
+ @param OriginalTableSize Size of SECs default PPI dispatch table
+ @param NewTable New dispatch table
+ @param NewTableSize Size of of the NewTable in bytes
+
+ @return EFI_SUCCESS table was copied
**/
-EFI_PEI_PPI_DESCRIPTOR *
+EFI_STATUS
EFIAPI
OverrideDispatchTable (
- IN CONST EFI_PEI_PPI_DESCRIPTOR *OriginalTable
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *OriginalTable,
+ IN UINTN OriginalTableSize,
+ IN OUT EFI_PEI_PPI_DESCRIPTOR *NewTable,
+ IN UINTN NewTableSize
)
{
- return (EFI_PEI_PPI_DESCRIPTOR *)OriginalTable;
+ CopyMem (NewTable, OriginalTable, OriginalTableSize);
+
+ return EFI_SUCCESS;
}
diff --git a/UnixPkg/Library/SecDispatchTableLib/SecDispatchTableLib.inf b/UnixPkg/Library/SecDispatchTableLib/SecDispatchTableLib.inf
index 858a140..2900fdb 100644
--- a/UnixPkg/Library/SecDispatchTableLib/SecDispatchTableLib.inf
+++ b/UnixPkg/Library/SecDispatchTableLib/SecDispatchTableLib.inf
@@ -38,5 +38,6 @@
[LibraryClasses]
BaseLib
+ BaseMemoryLib
diff --git a/UnixPkg/Sec/SecMain.c b/UnixPkg/Sec/SecMain.c
index b2046b6..06dbccb 100644
--- a/UnixPkg/Sec/SecMain.c
+++ b/UnixPkg/Sec/SecMain.c
@@ -544,6 +544,7 @@ Returns:
EFI_SEC_PEI_HAND_OFF *SecCoreData;
UINTN PeiStackSize;
EFI_PEI_PPI_DESCRIPTOR *DispatchTable;
+ UINTN DispatchTableSize;
//
// Compute Top Of Memory for Stack and PEI Core Allocations
@@ -597,11 +598,19 @@ Returns:
return ;
}
+ DispatchTableSize = sizeof (gPrivateDispatchTable);
+ DispatchTableSize += OverrideDispatchTableExtraSize ();
+
+ DispatchTable = malloc (DispatchTableSize);
+ if (DispatchTable == NULL) {
+ return;
+ }
+
//
// Allow an override for extra PPIs to be passed up to PEI
// This is an easy way to enable OS specific customizations
//
- DispatchTable = OverrideDispatchTable (&gPrivateDispatchTable[0]);
+ OverrideDispatchTable (&gPrivateDispatchTable[0], sizeof (gPrivateDispatchTable), DispatchTable, DispatchTableSize);
//
// Transfer control to the PEI Core
diff --git a/UnixPkg/UnixPkg.dsc b/UnixPkg/UnixPkg.dsc
index 50a9594..c76ea25 100644
--- a/UnixPkg/UnixPkg.dsc
+++ b/UnixPkg/UnixPkg.dsc
@@ -223,7 +223,7 @@
# generated for it, but the binary will not be put into any firmware volume.
#
###################################################################################################
-[Components.common]
+[Components]
##
# SEC Phase modules
##