From ec90508b3d3ff22a698a0446cb09d551d7466045 Mon Sep 17 00:00:00 2001 From: eric_tian Date: Tue, 23 Sep 2008 07:35:34 +0000 Subject: move header files in MdeModulePkg\Core\Dxe except DxeMain.h into their corresponding sub-module directories. It is used to provide good modularity. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5949 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/DebugImageInfo.h | 84 ----- MdeModulePkg/Core/Dxe/DxeMain.h | 177 +++++++++- MdeModulePkg/Core/Dxe/DxeMain.inf | 16 +- MdeModulePkg/Core/Dxe/Event.h | 108 ------ MdeModulePkg/Core/Dxe/Event/Event.c | 1 + MdeModulePkg/Core/Dxe/Event/Event.h | 91 +++++ MdeModulePkg/Core/Dxe/Event/Timer.c | 1 + MdeModulePkg/Core/Dxe/Event/Tpl.c | 2 +- MdeModulePkg/Core/Dxe/FwVol/Ffs.c | 1 + MdeModulePkg/Core/Dxe/FwVol/FwVol.c | 6 +- MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c | 1 + MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h | 458 +++++++++++++++++++++++++ MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c | 10 +- MdeModulePkg/Core/Dxe/FwVol/FwVolWrite.c | 2 +- MdeModulePkg/Core/Dxe/FwVolBlock.h | 300 ---------------- MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c | 5 +- MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.h | 237 +++++++++++++ MdeModulePkg/Core/Dxe/FwVolDriver.h | 469 -------------------------- MdeModulePkg/Core/Dxe/Gcd.h | 45 --- MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 1 + MdeModulePkg/Core/Dxe/Gcd/Gcd.h | 45 +++ MdeModulePkg/Core/Dxe/Hand/DriverSupport.c | 1 + MdeModulePkg/Core/Dxe/Hand/Handle.c | 1 + MdeModulePkg/Core/Dxe/Hand/Handle.h | 270 +++++++++++++++ MdeModulePkg/Core/Dxe/Hand/Locate.c | 1 + MdeModulePkg/Core/Dxe/Hand/Notify.c | 1 + MdeModulePkg/Core/Dxe/Handle.h | 273 --------------- MdeModulePkg/Core/Dxe/Image.h | 233 ------------- MdeModulePkg/Core/Dxe/Image/Image.c | 3 +- MdeModulePkg/Core/Dxe/Image/Image.h | 215 ++++++++++++ MdeModulePkg/Core/Dxe/Image/ImageFile.c | 1 + MdeModulePkg/Core/Dxe/Imem.h | 155 --------- MdeModulePkg/Core/Dxe/Library.h | 68 ---- MdeModulePkg/Core/Dxe/Mem/Imem.h | 155 +++++++++ MdeModulePkg/Core/Dxe/Mem/Page.c | 1 + MdeModulePkg/Core/Dxe/Mem/Pool.c | 1 + MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c | 2 + 37 files changed, 1672 insertions(+), 1769 deletions(-) delete mode 100644 MdeModulePkg/Core/Dxe/DebugImageInfo.h delete mode 100644 MdeModulePkg/Core/Dxe/Event.h create mode 100644 MdeModulePkg/Core/Dxe/Event/Event.h create mode 100644 MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h delete mode 100644 MdeModulePkg/Core/Dxe/FwVolBlock.h create mode 100644 MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.h delete mode 100644 MdeModulePkg/Core/Dxe/FwVolDriver.h delete mode 100644 MdeModulePkg/Core/Dxe/Gcd.h create mode 100644 MdeModulePkg/Core/Dxe/Gcd/Gcd.h create mode 100644 MdeModulePkg/Core/Dxe/Hand/Handle.h delete mode 100644 MdeModulePkg/Core/Dxe/Handle.h delete mode 100644 MdeModulePkg/Core/Dxe/Image.h create mode 100644 MdeModulePkg/Core/Dxe/Image/Image.h delete mode 100644 MdeModulePkg/Core/Dxe/Imem.h delete mode 100644 MdeModulePkg/Core/Dxe/Library.h create mode 100644 MdeModulePkg/Core/Dxe/Mem/Imem.h (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Core/Dxe/DebugImageInfo.h b/MdeModulePkg/Core/Dxe/DebugImageInfo.h deleted file mode 100644 index 317546b5ba..0000000000 --- a/MdeModulePkg/Core/Dxe/DebugImageInfo.h +++ /dev/null @@ -1,84 +0,0 @@ -/** @file - Support functions for managing debug image info table when loading and unloading - images. - -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __DEBUG_IMAGE_INFO_H__ -#define __DEBUG_IMAGE_INFO_H__ - -#define FOUR_MEG_ALIGNMENT 0x400000 - -#define EFI_DEBUG_TABLE_ENTRY_SIZE (sizeof (VOID *)) - - -/** - Creates and initializes the DebugImageInfo Table. Also creates the configuration - table and registers it into the system table. - - Note: - This function allocates memory, frees it, and then allocates memory at an - address within the initial allocation. Since this function is called early - in DXE core initialization (before drivers are dispatched), this should not - be a problem. - -**/ -VOID -CoreInitializeDebugImageInfoTable ( - VOID - ); - - -/** - Update the CRC32 in the Debug Table. - Since the CRC32 service is made available by the Runtime driver, we have to - wait for the Runtime Driver to be installed before the CRC32 can be computed. - This function is called elsewhere by the core when the runtime architectural - protocol is produced. - -**/ -VOID -CoreUpdateDebugTableCrc32 ( - VOID - ); - - -/** - Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates - the table if it's not large enough to accomidate another entry. - - @param ImageInfoType type of debug image information - @param LoadedImage pointer to the loaded image protocol for the image being - loaded - @param ImageHandle image handle for the image being loaded - -**/ -VOID -CoreNewDebugImageInfoEntry ( - IN UINT32 ImageInfoType, - IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, - IN EFI_HANDLE ImageHandle - ); - - -/** - Removes and frees an entry from the DebugImageInfo Table. - - @param ImageHandle image handle for the image being unloaded - -**/ -VOID -CoreRemoveDebugImageInfoEntry ( - EFI_HANDLE ImageHandle - ); - -#endif diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index 30fffb9f38..e46acf4147 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -80,16 +80,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include -#include "DebugImageInfo.h" -#include "Library.h" -#include "FwVolBlock.h" -#include "FwVolDriver.h" -#include "Gcd.h" -#include "Imem.h" -#include "Image.h" -#include "Event.h" -#include "Handle.h" - // // attributes for reserved memory before it is promoted to system memory // @@ -916,6 +906,20 @@ CoreRegisterProtocolNotify ( ); +/** + Removes all the events in the protocol database that match Event. + + @param Event The event to search for in the protocol + database. + + @return EFI_SUCCESS when done searching the entire database. + +**/ +EFI_STATUS +CoreUnregisterProtocolNotify ( + IN EFI_EVENT Event + ); + /** Locates the requested handle(s) and returns them in Buffer. @@ -2307,4 +2311,157 @@ CloseSectionStream ( IN UINTN StreamHandleToClose ); +/** + Creates and initializes the DebugImageInfo Table. Also creates the configuration + table and registers it into the system table. + + Note: + This function allocates memory, frees it, and then allocates memory at an + address within the initial allocation. Since this function is called early + in DXE core initialization (before drivers are dispatched), this should not + be a problem. + +**/ +VOID +CoreInitializeDebugImageInfoTable ( + VOID + ); + + +/** + Update the CRC32 in the Debug Table. + Since the CRC32 service is made available by the Runtime driver, we have to + wait for the Runtime Driver to be installed before the CRC32 can be computed. + This function is called elsewhere by the core when the runtime architectural + protocol is produced. + +**/ +VOID +CoreUpdateDebugTableCrc32 ( + VOID + ); + + +/** + Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates + the table if it's not large enough to accomidate another entry. + + @param ImageInfoType type of debug image information + @param LoadedImage pointer to the loaded image protocol for the image being + loaded + @param ImageHandle image handle for the image being loaded + +**/ +VOID +CoreNewDebugImageInfoEntry ( + IN UINT32 ImageInfoType, + IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, + IN EFI_HANDLE ImageHandle + ); + + +/** + Removes and frees an entry from the DebugImageInfo Table. + + @param ImageHandle image handle for the image being unloaded + +**/ +VOID +CoreRemoveDebugImageInfoEntry ( + EFI_HANDLE ImageHandle + ); + + +/** + This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate. + + @param ImageHandle The image handle. + @param SystemTable The system table. + + @retval EFI_SUCCESS Successfully initialized firmware volume block + driver. + +**/ +EFI_STATUS +EFIAPI +FwVolBlockDriverInit ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + + +/** + This routine produces a firmware volume block protocol on a given + buffer. + + @param BaseAddress base address of the firmware volume image + @param Length length of the firmware volume image + @param ParentHandle handle of parent firmware volume, if this image + came from an FV image file in another firmware + volume (ala capsules) + @param FvProtocol Firmware volume block protocol produced. + + @retval EFI_VOLUME_CORRUPTED Volume corrupted. + @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated. + @retval EFI_SUCCESS Successfully produced a FVB protocol on given + buffer. + +**/ +EFI_STATUS +ProduceFVBProtocolOnBuffer ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN EFI_HANDLE ParentHandle, + OUT EFI_HANDLE *FvProtocol OPTIONAL + ); + + +/** + Raising to the task priority level of the mutual exclusion + lock, and then acquires ownership of the lock. + + @param Lock The lock to acquire + + @return Lock owned + +**/ +VOID +CoreAcquireLock ( + IN EFI_LOCK *Lock + ); + + +/** + Initialize a basic mutual exclusion lock. Each lock + provides mutual exclusion access at it's task priority + level. Since there is no-premption (at any TPL) or + multiprocessor support, acquiring the lock only consists + of raising to the locks TPL. + + @param Lock The EFI_LOCK structure to initialize + + @retval EFI_SUCCESS Lock Owned. + @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned. + +**/ +EFI_STATUS +CoreAcquireLockOrFail ( + IN EFI_LOCK *Lock + ); + + +/** + Releases ownership of the mutual exclusion lock, and + restores the previous task priority level. + + @param Lock The lock to release + + @return Lock unowned + +**/ +VOID +CoreReleaseLock ( + IN EFI_LOCK *Lock + ); + #endif diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf index e6ba388bf4..5617880209 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -29,19 +29,11 @@ # VALID_ARCHITECTURES = IA32 X64 IPF [Sources.common] - Library.h - Imem.h - Image.h - Handle.h - Gcd.h - FwVolDriver.h - FwVolBlock.h - Event.h DxeMain.h - DebugImageInfo.h SectionExtraction/CoreSectionExtraction.c Image/ImageFile.c Image/Image.c + Image/Image.h Misc/DebugImageInfo.c Misc/Stall.c Misc/SetWatchdogTimer.c @@ -51,19 +43,25 @@ Hand/Notify.c Hand/Locate.c Hand/Handle.c + Hand/Handle.h Gcd/Gcd.c + Gcd/Gcd.h Mem/Pool.c Mem/Page.c Mem/MemData.c + Mem/Imem.h FwVolBlock/FwVolBlock.c + FwVolBlock/FwVolBlock.h FwVol/FwVolWrite.c FwVol/FwVolRead.c FwVol/FwVolAttrib.c FwVol/Ffs.c FwVol/FwVol.c + FwVol/FwVolDriver.h Event/Tpl.c Event/Timer.c Event/Event.c + Event/Event.h Dispatcher/Dependency.c Dispatcher/Dispatcher.c DxeMain/DxeProtocolNotify.c diff --git a/MdeModulePkg/Core/Dxe/Event.h b/MdeModulePkg/Core/Dxe/Event.h deleted file mode 100644 index 1709290a9f..0000000000 --- a/MdeModulePkg/Core/Dxe/Event.h +++ /dev/null @@ -1,108 +0,0 @@ -/** @file - UEFI Event support functions and structure. - -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __EVENT_H__ -#define __EVENT_H__ - -#define VALID_TPL(a) ((a) <= TPL_HIGH_LEVEL) - -// -// EFI_EVENT -// -#define EVENT_SIGNATURE EFI_SIGNATURE_32('e','v','n','t') -typedef struct { - UINTN Signature; - UINT32 Type; - UINT32 SignalCount; - - // - // Entry if the event is registered to be signalled - // - - LIST_ENTRY SignalLink; - - // - // Notification information for this event - // - - EFI_TPL NotifyTpl; - EFI_EVENT_NOTIFY NotifyFunction; - VOID *NotifyContext; - EFI_GUID EventGroup; - LIST_ENTRY NotifyLink; - BOOLEAN ExFlag; - - // - // A list of all runtime events - // - EFI_RUNTIME_EVENT_ENTRY RuntimeData; - - // - // Information by event type - // - - union { - // - // For timer events - // - struct { - LIST_ENTRY Link; - UINT64 TriggerTime; - UINT64 Period; - } Timer; - } u; - -} IEVENT; - -// -// Internal prototypes -// - - -/** - Dispatches all pending events. - - @param Priority The task priority level of event notifications - to dispatch - -**/ -VOID -CoreDispatchEventNotifies ( - IN EFI_TPL Priority - ); - - - -// -// Exported functions -// -/** - Initializes timer support. - -**/ -VOID -CoreInitializeTimer ( - VOID - ); - -// -// extern data declarations -// - -extern EFI_LOCK gEventQueueLock; -extern UINTN gEventPending; -extern LIST_ENTRY gEventQueue[]; -extern LIST_ENTRY gEventSignalQueue; - -#endif diff --git a/MdeModulePkg/Core/Dxe/Event/Event.c b/MdeModulePkg/Core/Dxe/Event/Event.c index 0e32aa4b66..204e9b3b70 100644 --- a/MdeModulePkg/Core/Dxe/Event/Event.c +++ b/MdeModulePkg/Core/Dxe/Event/Event.c @@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "DxeMain.h" +#include "Event.h" /// /// gEfiCurrentTpl - Current Task priority level diff --git a/MdeModulePkg/Core/Dxe/Event/Event.h b/MdeModulePkg/Core/Dxe/Event/Event.h new file mode 100644 index 0000000000..f9384bc6cb --- /dev/null +++ b/MdeModulePkg/Core/Dxe/Event/Event.h @@ -0,0 +1,91 @@ +/** @file + UEFI Event support functions and structure. + +Copyright (c) 2006 - 2008, Intel Corporation.
+All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __EVENT_H__ +#define __EVENT_H__ + + +#define VALID_TPL(a) ((a) <= TPL_HIGH_LEVEL) +extern UINTN gEventPending; + + +// +// EFI_EVENT +// +#define EVENT_SIGNATURE EFI_SIGNATURE_32('e','v','n','t') +typedef struct { + UINTN Signature; + UINT32 Type; + UINT32 SignalCount; + /// + /// Entry if the event is registered to be signalled + /// + LIST_ENTRY SignalLink; + /// + /// Notification information for this event + /// + EFI_TPL NotifyTpl; + EFI_EVENT_NOTIFY NotifyFunction; + VOID *NotifyContext; + EFI_GUID EventGroup; + LIST_ENTRY NotifyLink; + BOOLEAN ExFlag; + /// + /// A list of all runtime events + /// + EFI_RUNTIME_EVENT_ENTRY RuntimeData; + /// + /// Information by event type + /// + union { + /// + /// For timer events + /// + struct { + LIST_ENTRY Link; + UINT64 TriggerTime; + UINT64 Period; + } Timer; + } u; + +} IEVENT; + +// +// Internal prototypes +// + + +/** + Dispatches all pending events. + + @param Priority The task priority level of event notifications + to dispatch + +**/ +VOID +CoreDispatchEventNotifies ( + IN EFI_TPL Priority + ); + + +/** + Initializes timer support. + +**/ +VOID +CoreInitializeTimer ( + VOID + ); + +#endif diff --git a/MdeModulePkg/Core/Dxe/Event/Timer.c b/MdeModulePkg/Core/Dxe/Event/Timer.c index e1df72153d..eefd5a70c2 100644 --- a/MdeModulePkg/Core/Dxe/Event/Timer.c +++ b/MdeModulePkg/Core/Dxe/Event/Timer.c @@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "DxeMain.h" +#include "Event.h" // // Internal data diff --git a/MdeModulePkg/Core/Dxe/Event/Tpl.c b/MdeModulePkg/Core/Dxe/Event/Tpl.c index 43bc8add36..dd9c57e1d3 100644 --- a/MdeModulePkg/Core/Dxe/Event/Tpl.c +++ b/MdeModulePkg/Core/Dxe/Event/Tpl.c @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" - +#include "Event.h" /** Set Interrupt State. diff --git a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c index 1c11dde036..3a50f9dd00 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c +++ b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c @@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "DxeMain.h" +#include "FwVolDriver.h" /** diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c index 16d66fa0d4..9e26e4f020 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c @@ -15,8 +15,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" +#include "FwVolDriver.h" -#define KEYSIZE sizeof (UINTN) // // Protocol notify related globals @@ -34,8 +34,8 @@ FV_DEVICE mFvDevice = { FvReadFile, FvReadFileSection, FvWriteFile, - FvGetNextFile, - KEYSIZE, + FvGetNextFile, + sizeof (UINTN), NULL, FvGetVolumeInfo, FvSetVolumeInfo diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c b/MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c index 4c7dd99b57..f60af526e4 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" +#include "FwVolDriver.h" /** diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h b/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h new file mode 100644 index 0000000000..bb29cc4d44 --- /dev/null +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h @@ -0,0 +1,458 @@ +/** @file + Firmware File System protocol. Layers on top of Firmware + Block protocol to produce a file abstraction of FV based files. + +Copyright (c) 2006 - 2008, Intel Corporation.
+All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __FW_VOL_DRIVER_H_ +#define __FW_VOL_DRIVER_H_ + + +#define FV2_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', '2') + +// +// Used to track all non-deleted files +// +typedef struct { + LIST_ENTRY Link; + EFI_FFS_FILE_HEADER *FfsHeader; + UINTN StreamHandle; +} FFS_FILE_LIST_ENTRY; + +typedef struct { + UINTN Signature; + EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb; + EFI_HANDLE Handle; + EFI_FIRMWARE_VOLUME2_PROTOCOL Fv; + + EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; + UINT8 *CachedFv; + UINT8 *EndOfCachedFv; + + FFS_FILE_LIST_ENTRY *LastKey; + + LIST_ENTRY FfsFileListHeader; + + UINT8 ErasePolarity; +} FV_DEVICE; + +#define FV_DEVICE_FROM_THIS(a) CR(a, FV_DEVICE, Fv, FV2_DEVICE_SIGNATURE) + +/** + Retrieves attributes, insures positive polarity of attribute bits, returns + resulting attributes in output parameter. + + @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. + @param Attributes output buffer which contains attributes. + + @retval EFI_SUCCESS Successfully got volume attributes. + +**/ +EFI_STATUS +EFIAPI +FvGetVolumeAttributes ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + OUT EFI_FV_ATTRIBUTES *Attributes + ); + + +/** + Sets current attributes for volume + + @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. + @param Attributes At input, contains attributes to be set. At output + contains new value of FV. + + @retval EFI_UNSUPPORTED Could not be set. + +**/ +EFI_STATUS +EFIAPI +FvSetVolumeAttributes ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN OUT EFI_FV_ATTRIBUTES *Attributes + ); + + +/** + Given the input key, search for the next matching file in the volume. + + @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. + @param Key Key is a pointer to a caller allocated + buffer that contains implementation specific + data that is used to track where to begin + the search for the next file. The size of + the buffer must be at least This->KeySize + bytes long. To reinitialize the search and + begin from the beginning of the firmware + volume, the entire buffer must be cleared to + zero. Other than clearing the buffer to + initiate a new search, the caller must not + modify the data in the buffer between calls + to GetNextFile(). + @param FileType FileType is a pointer to a caller allocated + EFI_FV_FILETYPE. The GetNextFile() API can + filter it's search for files based on the + value of *FileType input. A *FileType input + of 0 causes GetNextFile() to search for + files of all types. If a file is found, the + file's type is returned in *FileType. + *FileType is not modified if no file is + found. + @param NameGuid NameGuid is a pointer to a caller allocated + EFI_GUID. If a file is found, the file's + name is returned in *NameGuid. *NameGuid is + not modified if no file is found. + @param Attributes Attributes is a pointer to a caller + allocated EFI_FV_FILE_ATTRIBUTES. If a file + is found, the file's attributes are returned + in *Attributes. *Attributes is not modified + if no file is found. + @param Size Size is a pointer to a caller allocated + UINTN. If a file is found, the file's size + is returned in *Size. *Size is not modified + if no file is found. + + @retval EFI_SUCCESS Successfully find the file. + @retval EFI_DEVICE_ERROR Device error. + @retval EFI_ACCESS_DENIED Fv could not read. + @retval EFI_NOT_FOUND No matching file found. + @retval EFI_INVALID_PARAMETER Invalid parameter + +**/ +EFI_STATUS +EFIAPI +FvGetNextFile ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN OUT VOID *Key, + IN OUT EFI_FV_FILETYPE *FileType, + OUT EFI_GUID *NameGuid, + OUT EFI_FV_FILE_ATTRIBUTES *Attributes, + OUT UINTN *Size + ); + + + +/** + Locates a file in the firmware volume and + copies it to the supplied buffer. + + @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. + @param NameGuid Pointer to an EFI_GUID, which is the + filename. + @param Buffer Buffer is a pointer to pointer to a buffer + in which the file or section contents or are + returned. + @param BufferSize BufferSize is a pointer to caller allocated + UINTN. On input *BufferSize indicates the + size in bytes of the memory region pointed + to by Buffer. On output, *BufferSize + contains the number of bytes required to + read the file. + @param FoundType FoundType is a pointer to a caller allocated + EFI_FV_FILETYPE that on successful return + from Read() contains the type of file read. + This output reflects the file type + irrespective of the value of the SectionType + input. + @param FileAttributes FileAttributes is a pointer to a caller + allocated EFI_FV_FILE_ATTRIBUTES. On + successful return from Read(), + *FileAttributes contains the attributes of + the file read. + @param AuthenticationStatus AuthenticationStatus is a pointer to a + caller allocated UINTN in which the + authentication status is returned. + + @retval EFI_SUCCESS Successfully read to memory buffer. + @retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small. + @retval EFI_NOT_FOUND Not found. + @retval EFI_DEVICE_ERROR Device error. + @retval EFI_ACCESS_DENIED Could not read. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated. + +**/ +EFI_STATUS +EFIAPI +FvReadFile ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN CONST EFI_GUID *NameGuid, + IN OUT VOID **Buffer, + IN OUT UINTN *BufferSize, + OUT EFI_FV_FILETYPE *FoundType, + OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes, + OUT UINT32 *AuthenticationStatus + ); + + +/** + Locates a section in a given FFS File and + copies it to the supplied buffer (not including section header). + + @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. + @param NameGuid Pointer to an EFI_GUID, which is the + filename. + @param SectionType Indicates the section type to return. + @param SectionInstance Indicates which instance of sections with a + type of SectionType to return. + @param Buffer Buffer is a pointer to pointer to a buffer + in which the file or section contents or are + returned. + @param BufferSize BufferSize is a pointer to caller allocated + UINTN. + @param AuthenticationStatus AuthenticationStatus is a pointer to a + caller allocated UINT32 in which the + authentication status is returned. + + @retval EFI_SUCCESS Successfully read the file section into + buffer. + @retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small. + @retval EFI_NOT_FOUND Section not found. + @retval EFI_DEVICE_ERROR Device error. + @retval EFI_ACCESS_DENIED Could not read. + @retval EFI_INVALID_PARAMETER Invalid parameter. + +**/ +EFI_STATUS +EFIAPI +FvReadFileSection ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN CONST EFI_GUID *NameGuid, + IN EFI_SECTION_TYPE SectionType, + IN UINTN SectionInstance, + IN OUT VOID **Buffer, + IN OUT UINTN *BufferSize, + OUT UINT32 *AuthenticationStatus + ); + + +/** + Writes one or more files to the firmware volume. + + @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. + @param NumberOfFiles Number of files. + @param WritePolicy WritePolicy indicates the level of reliability + for the write in the event of a power failure or + other system failure during the write operation. + @param FileData FileData is an pointer to an array of + EFI_FV_WRITE_DATA. Each element of array + FileData represents a file to be written. + + @retval EFI_SUCCESS Files successfully written to firmware volume + @retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated. + @retval EFI_DEVICE_ERROR Device error. + @retval EFI_WRITE_PROTECTED Write protected. + @retval EFI_NOT_FOUND Not found. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_UNSUPPORTED This function not supported. + +**/ +EFI_STATUS +EFIAPI +FvWriteFile ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN UINT32 NumberOfFiles, + IN EFI_FV_WRITE_POLICY WritePolicy, + IN EFI_FV_WRITE_FILE_DATA *FileData + ); + + +/** + Return information of type InformationType for the requested firmware + volume. + + @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. + @param InformationType InformationType for requested. + @param BufferSize On input, size of Buffer.On output, the amount of data + returned in Buffer. + @param Buffer A poniter to the data buffer to return. + + @retval EFI_SUCCESS Successfully got volume Information. + +**/ +EFI_STATUS +EFIAPI +FvGetVolumeInfo ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN CONST EFI_GUID *InformationType, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer + ); + + + +/** + Set information of type InformationType for the requested firmware + volume. + + @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. + @param InformationType InformationType for requested. + @param BufferSize On input, size of Buffer.On output, the amount of data + returned in Buffer. + @param Buffer A poniter to the data buffer to return. + + @retval EFI_SUCCESS Successfully set volume Information. + +**/ +EFI_STATUS +EFIAPI +FvSetVolumeInfo ( + IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, + IN CONST EFI_GUID *InformationType, + IN UINTN BufferSize, + IN CONST VOID *Buffer + ); + + + +/** + Check if a block of buffer is erased. + + @param ErasePolarity Erase polarity attribute of the firmware volume + @param InBuffer The buffer to be checked + @param BufferSize Size of the buffer in bytes + + @retval TRUE The block of buffer is erased + @retval FALSE The block of buffer is not erased + +**/ +BOOLEAN +IsBufferErased ( + IN UINT8 ErasePolarity, + IN VOID *InBuffer, + IN UINTN BufferSize + ); + + +/** + Get the FFS file state by checking the highest bit set in the header's state field. + + @param ErasePolarity Erase polarity attribute of the firmware volume + @param FfsHeader Points to the FFS file header + + @return FFS File state + +**/ +EFI_FFS_FILE_STATE +GetFileState ( + IN UINT8 ErasePolarity, + IN EFI_FFS_FILE_HEADER *FfsHeader + ); + + +/** + Set the FFS file state. + + @param State The state to be set. + @param FfsHeader Points to the FFS file header + + @return None. + +**/ +VOID +SetFileState ( + IN UINT8 State, + IN EFI_FFS_FILE_HEADER *FfsHeader + ); + + +/** + Verify checksum of the firmware volume header. + + @param FvHeader Points to the firmware volume header to be checked + + @retval TRUE Checksum verification passed + @retval FALSE Checksum verification failed + +**/ +BOOLEAN +VerifyFvHeaderChecksum ( + IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader + ); + + +/** + Check if it's a valid FFS file header. + + @param ErasePolarity Erase polarity attribute of the firmware volume + @param FfsHeader Points to the FFS file header to be checked + @param FileState FFS file state to be returned + + @retval TRUE Valid FFS file header + @retval FALSE Invalid FFS file header + +**/ +BOOLEAN +IsValidFfsHeader ( + IN UINT8 ErasePolarity, + IN EFI_FFS_FILE_HEADER *FfsHeader, + OUT EFI_FFS_FILE_STATE *FileState + ); + + +/** + Check if it's a valid FFS file. + Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first. + + @param ErasePolarity Erase polarity attribute of the firmware volume + @param FfsHeader Points to the FFS file to be checked + + @retval TRUE Valid FFS file + @retval FALSE Invalid FFS file + +**/ +BOOLEAN +IsValidFfsFile ( + IN UINT8 ErasePolarity, + IN EFI_FFS_FILE_HEADER *FfsHeader + ); + + +/** + given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and + copy the volume header into it. + + @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to + read the volume header + @param FwVolHeader Pointer to pointer to allocated buffer in which + the volume header is returned. + + @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated. + @retval EFI_SUCCESS Successfully read volume header to the allocated + buffer. + +**/ +EFI_STATUS +GetFwVolHeader ( + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb, + OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader + ); + + + +/** + Check if an FV is consistent and allocate cache for it. + + @param FvDevice A pointer to the FvDevice to be checked. + + @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated. + @retval EFI_SUCCESS FV is consistent and cache is allocated. + @retval EFI_VOLUME_CORRUPTED File system is corrupted. + +**/ +EFI_STATUS +FvCheck ( + IN OUT FV_DEVICE *FvDevice + ); + +#endif diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c index fbf6d0a1ba..e7cac455ff 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c @@ -13,10 +13,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" +#include "FwVolDriver.h" -/*++ - -Required Alignment Alignment Value in FFS Alignment Value in +/** +Required Alignment Alignment Value in FFS Alignment Value in (bytes) Attributes Field Firmware Volume Interfaces 1 0 0 2 0 1 @@ -29,9 +29,7 @@ Required Alignment Alignment Value in FFS Alignment Value in 4 KB 5 12 32 KB 6 15 64 KB 7 16 - ---*/ - +**/ UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16}; diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolWrite.c b/MdeModulePkg/Core/Dxe/FwVol/FwVolWrite.c index 1e0263e844..b54053e1c2 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolWrite.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolWrite.c @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" - +#include "FwVolDriver.h" /** diff --git a/MdeModulePkg/Core/Dxe/FwVolBlock.h b/MdeModulePkg/Core/Dxe/FwVolBlock.h deleted file mode 100644 index 18199ef896..0000000000 --- a/MdeModulePkg/Core/Dxe/FwVolBlock.h +++ /dev/null @@ -1,300 +0,0 @@ -/** @file - Firmware Volume Block protocol functions. - Consumes FV hobs and creates appropriate block protocols. - -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _FWVOL_BLOCK_H_ -#define _FWVOL_BLOCK_H_ - - -#define FVB_DEVICE_SIGNATURE EFI_SIGNATURE_32('_','F','V','B') - -typedef struct { - UINTN Base; - UINTN Length; -} LBA_CACHE; - -typedef struct { - MEMMAP_DEVICE_PATH MemMapDevPath; - EFI_DEVICE_PATH_PROTOCOL EndDevPath; -} FV_DEVICE_PATH; - - -typedef struct { - UINTN Signature; - EFI_HANDLE Handle; - FV_DEVICE_PATH DevicePath; - EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance; - UINTN NumBlocks; - LBA_CACHE *LbaCache; - UINT32 FvbAttributes; - EFI_PHYSICAL_ADDRESS BaseAddress; -} EFI_FW_VOL_BLOCK_DEVICE; - -#define FVB_DEVICE_FROM_THIS(a) \ - CR(a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE) - - - -/** - This routine is the driver initialization entry point. It initializes the - libraries, consumes FV hobs and NT_NON_MM_FV environment variable and - produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate. - - @param ImageHandle The image handle. - @param SystemTable The system table. - - @retval EFI_SUCCESS Successfully initialized firmware volume block - driver. - -**/ -EFI_STATUS -EFIAPI -FwVolBlockDriverInit ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - - - -/** - Retrieves Volume attributes. No polarity translations are done. - - @param This Calling context - @param Attributes output buffer which contains attributes - - @retval EFI_SUCCESS The firmware volume attributes were returned. - -**/ -EFI_STATUS -EFIAPI -FwVolBlockGetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_FVB_ATTRIBUTES_2 *Attributes - ); - - - -/** - Modifies the current settings of the firmware volume according to the input parameter. - - @param This Calling context - @param Attributes input buffer which contains attributes - - @retval EFI_SUCCESS The firmware volume attributes were returned. - @retval EFI_INVALID_PARAMETER The attributes requested are in conflict with - the capabilities as declared in the firmware - volume header. - @retval EFI_UNSUPPORTED Not supported. - -**/ -EFI_STATUS -EFIAPI -FwVolBlockSetAttributes ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN CONST EFI_FVB_ATTRIBUTES_2 *Attributes - ); - - - -/** - The EraseBlock() function erases one or more blocks as denoted by the - variable argument list. The entire parameter list of blocks must be verified - prior to erasing any blocks. If a block is requested that does not exist - within the associated firmware volume (it has a larger index than the last - block of the firmware volume), the EraseBlock() function must return - EFI_INVALID_PARAMETER without modifying the contents of the firmware volume. - - @param This Calling context - @param ... Starting LBA followed by Number of Lba to erase. - a -1 to terminate the list. - - @retval EFI_SUCCESS The erase request was successfully completed. - @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled - state. - @retval EFI_DEVICE_ERROR The block device is not functioning correctly - and could not be written. The firmware device - may have been partially erased. - @retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable - argument list do - @retval EFI_UNSUPPORTED Not supported. - -**/ -EFI_STATUS -EFIAPI -FwVolBlockEraseBlock ( - IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - ... - ); - - - -/** - Read the specified number of bytes from the block to the input buffer. - - @param This Indicates the calling context. - @param Lba The starting logical block index to read. - @param Offset Offset into the block at which to begin reading. - @param NumBytes Pointer to a UINT32. At entry, *NumBytes - contains the total size of the buffer. At exit, - *NumBytes contains the total number of bytes - actually read. - @param Buffer Pinter to a caller-allocated buffer that - contains the destine for the read. - - @retval EFI_SUCCESS The firmware volume was read successfully. - @retval EFI_BAD_BUFFER_SIZE The read was attempted across an LBA boundary. - @retval EFI_ACCESS_DENIED Access denied. - @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not - be read. - -**/ -EFI_STATUS -EFIAPI -FwVolBlockReadBlock ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN CONST EFI_LBA Lba, - IN CONST UINTN Offset, - IN OUT UINTN *NumBytes, - IN OUT UINT8 *Buffer - ); - - - -/** - Writes the specified number of bytes from the input buffer to the block. - - @param This Indicates the calling context. - @param Lba The starting logical block index to write to. - @param Offset Offset into the block at which to begin writing. - @param NumBytes Pointer to a UINT32. At entry, *NumBytes - contains the total size of the buffer. At exit, - *NumBytes contains the total number of bytes - actually written. - @param Buffer Pinter to a caller-allocated buffer that - contains the source for the write. - - @retval EFI_SUCCESS The firmware volume was written successfully. - @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary. - On output, NumBytes contains the total number of - bytes actually written. - @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled - state. - @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not - be written. - @retval EFI_UNSUPPORTED Not supported. - -**/ -EFI_STATUS -EFIAPI -FwVolBlockWriteBlock ( - IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN EFI_LBA Lba, - IN UINTN Offset, - IN OUT UINTN *NumBytes, - IN UINT8 *Buffer - ); - - - -/** - Get Fvb's base address. - - @param This Indicates the calling context. - @param Address Fvb device base address. - - @retval EFI_SUCCESS Successfully got Fvb's base address. - @retval EFI_UNSUPPORTED Not supported. - -**/ -EFI_STATUS -EFIAPI -FwVolBlockGetPhysicalAddress ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - OUT EFI_PHYSICAL_ADDRESS *Address - ); - - - -/** - Retrieves the size in bytes of a specific block within a firmware volume. - - @param This Indicates the calling context. - @param Lba Indicates the block for which to return the - size. - @param BlockSize Pointer to a caller-allocated UINTN in which the - size of the block is returned. - @param NumberOfBlocks Pointer to a caller-allocated UINTN in which the - number of consecutive blocks starting with Lba - is returned. All blocks in this range have a - size of BlockSize. - - @retval EFI_SUCCESS The firmware volume base address is returned. - @retval EFI_INVALID_PARAMETER The requested LBA is out of range. - -**/ -EFI_STATUS -EFIAPI -FwVolBlockGetBlockSize ( - IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, - IN CONST EFI_LBA Lba, - IN OUT UINTN *BlockSize, - IN OUT UINTN *NumberOfBlocks - ); - -/** - This routine is the driver initialization entry point. It initializes the - libraries, consumes FV hobs and NT_NON_MM_FV environment variable and - produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate. - - @param ImageHandle The image handle. - @param SystemTable The system table. - - @retval EFI_SUCCESS Successfully initialized firmware volume block - driver. - -**/ -EFI_STATUS -EFIAPI -FwVolBlockDriverInit ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - - -/** - This routine produces a firmware volume block protocol on a given - buffer. - - @param BaseAddress base address of the firmware volume image - @param Length length of the firmware volume image - @param ParentHandle handle of parent firmware volume, if this image - came from an FV image file in another firmware - volume (ala capsules) - @param FvProtocol Firmware volume block protocol produced. - - @retval EFI_VOLUME_CORRUPTED Volume corrupted. - @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated. - @retval EFI_SUCCESS Successfully produced a FVB protocol on given - buffer. - -**/ -EFI_STATUS -ProduceFVBProtocolOnBuffer ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length, - IN EFI_HANDLE ParentHandle, - OUT EFI_HANDLE *FvProtocol OPTIONAL - ); - -#endif diff --git a/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c index 26e3dde57d..3966daf5b8 100644 --- a/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c +++ b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c @@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" +#include "FwVolBlock.h" EFI_FW_VOL_BLOCK_DEVICE mFwVolBlock = { @@ -511,9 +512,7 @@ ProduceFVBProtocolOnBuffer ( /** - This routine is the driver initialization entry point. It initializes the - libraries, consumes FV hobs and NT_NON_MM_FV environment variable and - produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate. + This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate. @param ImageHandle The image handle. @param SystemTable The system table. diff --git a/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.h b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.h new file mode 100644 index 0000000000..0fa4c296bc --- /dev/null +++ b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.h @@ -0,0 +1,237 @@ +/** @file + Firmware Volume Block protocol functions. + Consumes FV hobs and creates appropriate block protocols. + +Copyright (c) 2006 - 2008, Intel Corporation.
+All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _FWVOL_BLOCK_H_ +#define _FWVOL_BLOCK_H_ + + +#define FVB_DEVICE_SIGNATURE EFI_SIGNATURE_32('_','F','V','B') + + +typedef struct { + UINTN Base; + UINTN Length; +} LBA_CACHE; + + +typedef struct { + MEMMAP_DEVICE_PATH MemMapDevPath; + EFI_DEVICE_PATH_PROTOCOL EndDevPath; +} FV_DEVICE_PATH; + + +typedef struct { + UINTN Signature; + EFI_HANDLE Handle; + FV_DEVICE_PATH DevicePath; + EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance; + UINTN NumBlocks; + LBA_CACHE *LbaCache; + UINT32 FvbAttributes; + EFI_PHYSICAL_ADDRESS BaseAddress; +} EFI_FW_VOL_BLOCK_DEVICE; + + +#define FVB_DEVICE_FROM_THIS(a) \ + CR(a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE) + + +/** + Retrieves Volume attributes. No polarity translations are done. + + @param This Calling context + @param Attributes output buffer which contains attributes + + @retval EFI_SUCCESS The firmware volume attributes were returned. + +**/ +EFI_STATUS +EFIAPI +FwVolBlockGetAttributes ( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + OUT EFI_FVB_ATTRIBUTES_2 *Attributes + ); + + + +/** + Modifies the current settings of the firmware volume according to the input parameter. + + @param This Calling context + @param Attributes input buffer which contains attributes + + @retval EFI_SUCCESS The firmware volume attributes were returned. + @retval EFI_INVALID_PARAMETER The attributes requested are in conflict with + the capabilities as declared in the firmware + volume header. + @retval EFI_UNSUPPORTED Not supported. + +**/ +EFI_STATUS +EFIAPI +FwVolBlockSetAttributes ( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + IN CONST EFI_FVB_ATTRIBUTES_2 *Attributes + ); + + + +/** + The EraseBlock() function erases one or more blocks as denoted by the + variable argument list. The entire parameter list of blocks must be verified + prior to erasing any blocks. If a block is requested that does not exist + within the associated firmware volume (it has a larger index than the last + block of the firmware volume), the EraseBlock() function must return + EFI_INVALID_PARAMETER without modifying the contents of the firmware volume. + + @param This Calling context + @param ... Starting LBA followed by Number of Lba to erase. + a -1 to terminate the list. + + @retval EFI_SUCCESS The erase request was successfully completed. + @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled + state. + @retval EFI_DEVICE_ERROR The block device is not functioning correctly + and could not be written. The firmware device + may have been partially erased. + @retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable + argument list do + @retval EFI_UNSUPPORTED Not supported. + +**/ +EFI_STATUS +EFIAPI +FwVolBlockEraseBlock ( + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + ... + ); + + + +/** + Read the specified number of bytes from the block to the input buffer. + + @param This Indicates the calling context. + @param Lba The starting logical block index to read. + @param Offset Offset into the block at which to begin reading. + @param NumBytes Pointer to a UINT32. At entry, *NumBytes + contains the total size of the buffer. At exit, + *NumBytes contains the total number of bytes + actually read. + @param Buffer Pinter to a caller-allocated buffer that + contains the destine for the read. + + @retval EFI_SUCCESS The firmware volume was read successfully. + @retval EFI_BAD_BUFFER_SIZE The read was attempted across an LBA boundary. + @retval EFI_ACCESS_DENIED Access denied. + @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not + be read. + +**/ +EFI_STATUS +EFIAPI +FwVolBlockReadBlock ( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + IN CONST EFI_LBA Lba, + IN CONST UINTN Offset, + IN OUT UINTN *NumBytes, + IN OUT UINT8 *Buffer + ); + + + +/** + Writes the specified number of bytes from the input buffer to the block. + + @param This Indicates the calling context. + @param Lba The starting logical block index to write to. + @param Offset Offset into the block at which to begin writing. + @param NumBytes Pointer to a UINT32. At entry, *NumBytes + contains the total size of the buffer. At exit, + *NumBytes contains the total number of bytes + actually written. + @param Buffer Pinter to a caller-allocated buffer that + contains the source for the write. + + @retval EFI_SUCCESS The firmware volume was written successfully. + @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary. + On output, NumBytes contains the total number of + bytes actually written. + @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled + state. + @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not + be written. + @retval EFI_UNSUPPORTED Not supported. + +**/ +EFI_STATUS +EFIAPI +FwVolBlockWriteBlock ( + IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + IN EFI_LBA Lba, + IN UINTN Offset, + IN OUT UINTN *NumBytes, + IN UINT8 *Buffer + ); + + + +/** + Get Fvb's base address. + + @param This Indicates the calling context. + @param Address Fvb device base address. + + @retval EFI_SUCCESS Successfully got Fvb's base address. + @retval EFI_UNSUPPORTED Not supported. + +**/ +EFI_STATUS +EFIAPI +FwVolBlockGetPhysicalAddress ( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + OUT EFI_PHYSICAL_ADDRESS *Address + ); + + + +/** + Retrieves the size in bytes of a specific block within a firmware volume. + + @param This Indicates the calling context. + @param Lba Indicates the block for which to return the + size. + @param BlockSize Pointer to a caller-allocated UINTN in which the + size of the block is returned. + @param NumberOfBlocks Pointer to a caller-allocated UINTN in which the + number of consecutive blocks starting with Lba + is returned. All blocks in this range have a + size of BlockSize. + + @retval EFI_SUCCESS The firmware volume base address is returned. + @retval EFI_INVALID_PARAMETER The requested LBA is out of range. + +**/ +EFI_STATUS +EFIAPI +FwVolBlockGetBlockSize ( + IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, + IN CONST EFI_LBA Lba, + IN OUT UINTN *BlockSize, + IN OUT UINTN *NumberOfBlocks + ); + + +#endif diff --git a/MdeModulePkg/Core/Dxe/FwVolDriver.h b/MdeModulePkg/Core/Dxe/FwVolDriver.h deleted file mode 100644 index 5acbacc7c7..0000000000 --- a/MdeModulePkg/Core/Dxe/FwVolDriver.h +++ /dev/null @@ -1,469 +0,0 @@ -/** @file - Firmware File System protocol. Layers on top of Firmware - Block protocol to produce a file abstraction of FV based files. - -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __FW_VOL_DRIVER_H_ -#define __FW_VOL_DRIVER_H_ - - -#define FV2_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', '2') - -// -// Used to track all non-deleted files -// -typedef struct { - LIST_ENTRY Link; - EFI_FFS_FILE_HEADER *FfsHeader; - UINTN StreamHandle; -} FFS_FILE_LIST_ENTRY; - -typedef struct { - UINTN Signature; - EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb; - EFI_HANDLE Handle; - EFI_FIRMWARE_VOLUME2_PROTOCOL Fv; - - EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; - UINT8 *CachedFv; - UINT8 *EndOfCachedFv; - - FFS_FILE_LIST_ENTRY *LastKey; - - LIST_ENTRY FfsFileListHeader; - - UINT8 ErasePolarity; -} FV_DEVICE; - -#define FV_DEVICE_FROM_THIS(a) CR(a, FV_DEVICE, Fv, FV2_DEVICE_SIGNATURE) - -/** - Retrieves attributes, insures positive polarity of attribute bits, returns - resulting attributes in output parameter. - - @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. - @param Attributes output buffer which contains attributes. - - @retval EFI_SUCCESS Successfully got volume attributes. - -**/ -EFI_STATUS -EFIAPI -FvGetVolumeAttributes ( - IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, - OUT EFI_FV_ATTRIBUTES *Attributes - ); - - -/** - Sets current attributes for volume - - @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. - @param Attributes At input, contains attributes to be set. At output - contains new value of FV. - - @retval EFI_UNSUPPORTED Could not be set. - -**/ -EFI_STATUS -EFIAPI -FvSetVolumeAttributes ( - IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, - IN OUT EFI_FV_ATTRIBUTES *Attributes - ); - - -/** - Given the input key, search for the next matching file in the volume. - - @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. - @param Key Key is a pointer to a caller allocated - buffer that contains implementation specific - data that is used to track where to begin - the search for the next file. The size of - the buffer must be at least This->KeySize - bytes long. To reinitialize the search and - begin from the beginning of the firmware - volume, the entire buffer must be cleared to - zero. Other than clearing the buffer to - initiate a new search, the caller must not - modify the data in the buffer between calls - to GetNextFile(). - @param FileType FileType is a pointer to a caller allocated - EFI_FV_FILETYPE. The GetNextFile() API can - filter it's search for files based on the - value of *FileType input. A *FileType input - of 0 causes GetNextFile() to search for - files of all types. If a file is found, the - file's type is returned in *FileType. - *FileType is not modified if no file is - found. - @param NameGuid NameGuid is a pointer to a caller allocated - EFI_GUID. If a file is found, the file's - name is returned in *NameGuid. *NameGuid is - not modified if no file is found. - @param Attributes Attributes is a pointer to a caller - allocated EFI_FV_FILE_ATTRIBUTES. If a file - is found, the file's attributes are returned - in *Attributes. *Attributes is not modified - if no file is found. - @param Size Size is a pointer to a caller allocated - UINTN. If a file is found, the file's size - is returned in *Size. *Size is not modified - if no file is found. - - @retval EFI_SUCCESS Successfully find the file. - @retval EFI_DEVICE_ERROR Device error. - @retval EFI_ACCESS_DENIED Fv could not read. - @retval EFI_NOT_FOUND No matching file found. - @retval EFI_INVALID_PARAMETER Invalid parameter - -**/ -EFI_STATUS -EFIAPI -FvGetNextFile ( - IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, - IN OUT VOID *Key, - IN OUT EFI_FV_FILETYPE *FileType, - OUT EFI_GUID *NameGuid, - OUT EFI_FV_FILE_ATTRIBUTES *Attributes, - OUT UINTN *Size - ); - - - -/** - Locates a file in the firmware volume and - copies it to the supplied buffer. - - @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. - @param NameGuid Pointer to an EFI_GUID, which is the - filename. - @param Buffer Buffer is a pointer to pointer to a buffer - in which the file or section contents or are - returned. - @param BufferSize BufferSize is a pointer to caller allocated - UINTN. On input *BufferSize indicates the - size in bytes of the memory region pointed - to by Buffer. On output, *BufferSize - contains the number of bytes required to - read the file. - @param FoundType FoundType is a pointer to a caller allocated - EFI_FV_FILETYPE that on successful return - from Read() contains the type of file read. - This output reflects the file type - irrespective of the value of the SectionType - input. - @param FileAttributes FileAttributes is a pointer to a caller - allocated EFI_FV_FILE_ATTRIBUTES. On - successful return from Read(), - *FileAttributes contains the attributes of - the file read. - @param AuthenticationStatus AuthenticationStatus is a pointer to a - caller allocated UINTN in which the - authentication status is returned. - - @retval EFI_SUCCESS Successfully read to memory buffer. - @retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small. - @retval EFI_NOT_FOUND Not found. - @retval EFI_DEVICE_ERROR Device error. - @retval EFI_ACCESS_DENIED Could not read. - @retval EFI_INVALID_PARAMETER Invalid parameter. - @retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated. - -**/ -EFI_STATUS -EFIAPI -FvReadFile ( - IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, - IN CONST EFI_GUID *NameGuid, - IN OUT VOID **Buffer, - IN OUT UINTN *BufferSize, - OUT EFI_FV_FILETYPE *FoundType, - OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes, - OUT UINT32 *AuthenticationStatus - ); - - -/** - Locates a section in a given FFS File and - copies it to the supplied buffer (not including section header). - - @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. - @param NameGuid Pointer to an EFI_GUID, which is the - filename. - @param SectionType Indicates the section type to return. - @param SectionInstance Indicates which instance of sections with a - type of SectionType to return. - @param Buffer Buffer is a pointer to pointer to a buffer - in which the file or section contents or are - returned. - @param BufferSize BufferSize is a pointer to caller allocated - UINTN. - @param AuthenticationStatus AuthenticationStatus is a pointer to a - caller allocated UINT32 in which the - authentication status is returned. - - @retval EFI_SUCCESS Successfully read the file section into - buffer. - @retval EFI_WARN_BUFFER_TOO_SMALL Buffer too small. - @retval EFI_NOT_FOUND Section not found. - @retval EFI_DEVICE_ERROR Device error. - @retval EFI_ACCESS_DENIED Could not read. - @retval EFI_INVALID_PARAMETER Invalid parameter. - -**/ -EFI_STATUS -EFIAPI -FvReadFileSection ( - IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, - IN CONST EFI_GUID *NameGuid, - IN EFI_SECTION_TYPE SectionType, - IN UINTN SectionInstance, - IN OUT VOID **Buffer, - IN OUT UINTN *BufferSize, - OUT UINT32 *AuthenticationStatus - ); - - -/** - Writes one or more files to the firmware volume. - - @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. - @param NumberOfFiles Number of files. - @param WritePolicy WritePolicy indicates the level of reliability - for the write in the event of a power failure or - other system failure during the write operation. - @param FileData FileData is an pointer to an array of - EFI_FV_WRITE_DATA. Each element of array - FileData represents a file to be written. - - @retval EFI_SUCCESS Files successfully written to firmware volume - @retval EFI_OUT_OF_RESOURCES Not enough buffer to be allocated. - @retval EFI_DEVICE_ERROR Device error. - @retval EFI_WRITE_PROTECTED Write protected. - @retval EFI_NOT_FOUND Not found. - @retval EFI_INVALID_PARAMETER Invalid parameter. - @retval EFI_UNSUPPORTED This function not supported. - -**/ -EFI_STATUS -EFIAPI -FvWriteFile ( - IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, - IN UINT32 NumberOfFiles, - IN EFI_FV_WRITE_POLICY WritePolicy, - IN EFI_FV_WRITE_FILE_DATA *FileData - ); - - -/** - Return information of type InformationType for the requested firmware - volume. - - @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. - @param InformationType InformationType for requested. - @param BufferSize On input, size of Buffer.On output, the amount of data - returned in Buffer. - @param Buffer A poniter to the data buffer to return. - - @retval EFI_SUCCESS Successfully got volume Information. - -**/ -EFI_STATUS -EFIAPI -FvGetVolumeInfo ( - IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, - IN CONST EFI_GUID *InformationType, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer - ); - - - -/** - Set information of type InformationType for the requested firmware - volume. - - @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL. - @param InformationType InformationType for requested. - @param BufferSize On input, size of Buffer.On output, the amount of data - returned in Buffer. - @param Buffer A poniter to the data buffer to return. - - @retval EFI_SUCCESS Successfully set volume Information. - -**/ -EFI_STATUS -EFIAPI -FvSetVolumeInfo ( - IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This, - IN CONST EFI_GUID *InformationType, - IN UINTN BufferSize, - IN CONST VOID *Buffer - ); - -// -//Internal functions -// -typedef enum { - EfiCheckSumUint8 = 0, - EfiCheckSumUint16 = 1, - EfiCheckSumUint32 = 2, - EfiCheckSumUint64 = 3, - EfiCheckSumMaximum = 4 -} EFI_CHECKSUM_TYPE; - - - -/** - Check if a block of buffer is erased. - - @param ErasePolarity Erase polarity attribute of the firmware volume - @param InBuffer The buffer to be checked - @param BufferSize Size of the buffer in bytes - - @retval TRUE The block of buffer is erased - @retval FALSE The block of buffer is not erased - -**/ -BOOLEAN -IsBufferErased ( - IN UINT8 ErasePolarity, - IN VOID *InBuffer, - IN UINTN BufferSize - ); - - -/** - Get the FFS file state by checking the highest bit set in the header's state field. - - @param ErasePolarity Erase polarity attribute of the firmware volume - @param FfsHeader Points to the FFS file header - - @return FFS File state - -**/ -EFI_FFS_FILE_STATE -GetFileState ( - IN UINT8 ErasePolarity, - IN EFI_FFS_FILE_HEADER *FfsHeader - ); - - -/** - Set the FFS file state. - - @param State The state to be set. - @param FfsHeader Points to the FFS file header - - @return None. - -**/ -VOID -SetFileState ( - IN UINT8 State, - IN EFI_FFS_FILE_HEADER *FfsHeader - ); - - -/** - Verify checksum of the firmware volume header. - - @param FvHeader Points to the firmware volume header to be checked - - @retval TRUE Checksum verification passed - @retval FALSE Checksum verification failed - -**/ -BOOLEAN -VerifyFvHeaderChecksum ( - IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader - ); - - -/** - Check if it's a valid FFS file header. - - @param ErasePolarity Erase polarity attribute of the firmware volume - @param FfsHeader Points to the FFS file header to be checked - @param FileState FFS file state to be returned - - @retval TRUE Valid FFS file header - @retval FALSE Invalid FFS file header - -**/ -BOOLEAN -IsValidFfsHeader ( - IN UINT8 ErasePolarity, - IN EFI_FFS_FILE_HEADER *FfsHeader, - OUT EFI_FFS_FILE_STATE *FileState - ); - - -/** - Check if it's a valid FFS file. - Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first. - - @param ErasePolarity Erase polarity attribute of the firmware volume - @param FfsHeader Points to the FFS file to be checked - - @retval TRUE Valid FFS file - @retval FALSE Invalid FFS file - -**/ -BOOLEAN -IsValidFfsFile ( - IN UINT8 ErasePolarity, - IN EFI_FFS_FILE_HEADER *FfsHeader - ); - - -/** - given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and - copy the volume header into it. - - @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to - read the volume header - @param FwVolHeader Pointer to pointer to allocated buffer in which - the volume header is returned. - - @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated. - @retval EFI_SUCCESS Successfully read volume header to the allocated - buffer. - -**/ -EFI_STATUS -GetFwVolHeader ( - IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb, - OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader - ); - - - -/** - Check if an FV is consistent and allocate cache for it. - - @param FvDevice A pointer to the FvDevice to be checked. - - @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated. - @retval EFI_SUCCESS FV is consistent and cache is allocated. - @retval EFI_VOLUME_CORRUPTED File system is corrupted. - -**/ -EFI_STATUS -FvCheck ( - IN OUT FV_DEVICE *FvDevice - ); - -#endif diff --git a/MdeModulePkg/Core/Dxe/Gcd.h b/MdeModulePkg/Core/Dxe/Gcd.h deleted file mode 100644 index a2005f8832..0000000000 --- a/MdeModulePkg/Core/Dxe/Gcd.h +++ /dev/null @@ -1,45 +0,0 @@ -/** @file - GCD Operations and data structure used to - convert from GCD attributes to EFI Memory Map attributes. - -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _GCD_H_ -#define _GCD_H_ - -// -// GCD Operations -// -#define GCD_MEMORY_SPACE_OPERATION 0x20 -#define GCD_IO_SPACE_OPERATION 0x40 - -#define GCD_ADD_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 0) -#define GCD_ALLOCATE_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 1) -#define GCD_FREE_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 2) -#define GCD_REMOVE_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 3) -#define GCD_SET_ATTRIBUTES_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 4) - -#define GCD_ADD_IO_OPERATION (GCD_IO_SPACE_OPERATION | 0) -#define GCD_ALLOCATE_IO_OPERATION (GCD_IO_SPACE_OPERATION | 1) -#define GCD_FREE_IO_OPERATION (GCD_IO_SPACE_OPERATION | 2) -#define GCD_REMOVE_IO_OPERATION (GCD_IO_SPACE_OPERATION | 3) - -// -// The data structure used to convert from GCD attributes to EFI Memory Map attributes -// -typedef struct { - UINT64 Attribute; - UINT64 Capability; - BOOLEAN Memory; -} GCD_ATTRIBUTE_CONVERSION_ENTRY; - -#endif diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c index 88a11a6ffc..a379e5c5a7 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -15,6 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" +#include "Gcd.h" #define MINIMUM_INITIAL_MEMORY_SIZE 0x10000 diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.h b/MdeModulePkg/Core/Dxe/Gcd/Gcd.h new file mode 100644 index 0000000000..a2005f8832 --- /dev/null +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.h @@ -0,0 +1,45 @@ +/** @file + GCD Operations and data structure used to + convert from GCD attributes to EFI Memory Map attributes. + +Copyright (c) 2006 - 2008, Intel Corporation.
+All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _GCD_H_ +#define _GCD_H_ + +// +// GCD Operations +// +#define GCD_MEMORY_SPACE_OPERATION 0x20 +#define GCD_IO_SPACE_OPERATION 0x40 + +#define GCD_ADD_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 0) +#define GCD_ALLOCATE_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 1) +#define GCD_FREE_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 2) +#define GCD_REMOVE_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 3) +#define GCD_SET_ATTRIBUTES_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 4) + +#define GCD_ADD_IO_OPERATION (GCD_IO_SPACE_OPERATION | 0) +#define GCD_ALLOCATE_IO_OPERATION (GCD_IO_SPACE_OPERATION | 1) +#define GCD_FREE_IO_OPERATION (GCD_IO_SPACE_OPERATION | 2) +#define GCD_REMOVE_IO_OPERATION (GCD_IO_SPACE_OPERATION | 3) + +// +// The data structure used to convert from GCD attributes to EFI Memory Map attributes +// +typedef struct { + UINT64 Attribute; + UINT64 Capability; + BOOLEAN Memory; +} GCD_ATTRIBUTE_CONVERSION_ENTRY; + +#endif diff --git a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c index 74cc5dfca7..203a6e6b04 100644 --- a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c +++ b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" +#include "Handle.h" // diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c b/MdeModulePkg/Core/Dxe/Hand/Handle.c index 38e27c4dfd..e817357cd3 100644 --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" +#include "Handle.h" // diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.h b/MdeModulePkg/Core/Dxe/Hand/Handle.h new file mode 100644 index 0000000000..f7b85dba26 --- /dev/null +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.h @@ -0,0 +1,270 @@ +/** @file + Support functions for managing protocol. + +Copyright (c) 2006 - 2008, Intel Corporation.
+All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _HAND_H_ +#define _HAND_H_ + + +#define EFI_HANDLE_SIGNATURE EFI_SIGNATURE_32('h','n','d','l') + +/// +/// IHANDLE - contains a list of protocol handles +/// +typedef struct { + UINTN Signature; + /// All handles list of IHANDLE + LIST_ENTRY AllHandles; + /// List of PROTOCOL_INTERFACE's for this handle + LIST_ENTRY Protocols; + UINTN LocateRequest; + /// The Handle Database Key value when this handle was last created or modified + UINT64 Key; +} IHANDLE; + +#define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE) + +#define PROTOCOL_ENTRY_SIGNATURE EFI_SIGNATURE_32('p','r','t','e') + +/// +/// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol +/// database. Each handler that supports this protocol is listed, along +/// with a list of registered notifies. +/// +typedef struct { + UINTN Signature; + /// Link Entry inserted to mProtocolDatabase + LIST_ENTRY AllEntries; + /// ID of the protocol + EFI_GUID ProtocolID; + /// All protocol interfaces + LIST_ENTRY Protocols; + /// Registerd notification handlers + LIST_ENTRY Notify; +} PROTOCOL_ENTRY; + + +#define PROTOCOL_INTERFACE_SIGNATURE EFI_SIGNATURE_32('p','i','f','c') + +/// +/// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked +/// with a protocol interface structure +/// +typedef struct { + UINTN Signature; + /// Link on IHANDLE.Protocols + LIST_ENTRY Link; + /// Back pointer + IHANDLE *Handle; + /// Link on PROTOCOL_ENTRY.Protocols + LIST_ENTRY ByProtocol; + /// The protocol ID + PROTOCOL_ENTRY *Protocol; + /// The interface value + VOID *Interface; + /// OPEN_PROTOCOL_DATA list + LIST_ENTRY OpenList; + UINTN OpenListCount; + +} PROTOCOL_INTERFACE; + +#define OPEN_PROTOCOL_DATA_SIGNATURE EFI_SIGNATURE_32('p','o','d','l') + +typedef struct { + UINTN Signature; + ///Link on PROTOCOL_INTERFACE.OpenList + LIST_ENTRY Link; + + EFI_HANDLE AgentHandle; + EFI_HANDLE ControllerHandle; + UINT32 Attributes; + UINT32 OpenCount; +} OPEN_PROTOCOL_DATA; + + +#define PROTOCOL_NOTIFY_SIGNATURE EFI_SIGNATURE_32('p','r','t','n') + +/// +/// PROTOCOL_NOTIFY - used for each register notification for a protocol +/// +typedef struct { + UINTN Signature; + PROTOCOL_ENTRY *Protocol; + /// All notifications for this protocol + LIST_ENTRY Link; + /// Event to notify + EFI_EVENT Event; + /// Last position notified + LIST_ENTRY *Position; +} PROTOCOL_NOTIFY; + + + +/** + Finds the protocol entry for the requested protocol. + The gProtocolDatabaseLock must be owned + + @param Protocol The ID of the protocol + @param Create Create a new entry if not found + + @return Protocol entry + +**/ +PROTOCOL_ENTRY * +CoreFindProtocolEntry ( + IN EFI_GUID *Protocol, + IN BOOLEAN Create + ); + + +/** + Signal event for every protocol in protocol entry. + + @param ProtEntry Protocol entry + +**/ +VOID +CoreNotifyProtocolEntry ( + IN PROTOCOL_ENTRY *ProtEntry + ); + + +/** + Finds the protocol instance for the requested handle and protocol. + Note: This function doesn't do parameters checking, it's caller's responsibility + to pass in valid parameters. + + @param Handle The handle to search the protocol on + @param Protocol GUID of the protocol + @param Interface The interface for the protocol being searched + + @return Protocol instance (NULL: Not found) + +**/ +PROTOCOL_INTERFACE * +CoreFindProtocolInterface ( + IN IHANDLE *Handle, + IN EFI_GUID *Protocol, + IN VOID *Interface + ); + + +/** + Removes Protocol from the protocol list (but not the handle list). + + @param Handle The handle to remove protocol on. + @param Protocol GUID of the protocol to be moved + @param Interface The interface of the protocol + + @return Protocol Entry + +**/ +PROTOCOL_INTERFACE * +CoreRemoveInterfaceFromProtocol ( + IN IHANDLE *Handle, + IN EFI_GUID *Protocol, + IN VOID *Interface + ); + + +/** + Connects a controller to a driver. + + @param ControllerHandle Handle of the controller to be + connected. + @param ContextDriverImageHandles DriverImageHandle A pointer to an + ordered list of driver image + handles. + @param RemainingDevicePath RemainingDevicePath A pointer to + the device path that specifies a + child of the controller + specified by ControllerHandle. + + @retval EFI_SUCCESS One or more drivers were + connected to ControllerHandle. + @retval EFI_OUT_OF_RESOURCES No enough system resources to + complete the request. + @retval EFI_NOT_FOUND No drivers were connected to + ControllerHandle. + +**/ +EFI_STATUS +CoreConnectSingleController ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE *ContextDriverImageHandles OPTIONAL, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ); + +/** + Attempts to disconnect all drivers that are using the protocol interface being queried. + If failed, reconnect all drivers disconnected. + Note: This function doesn't do parameters checking, it's caller's responsibility + to pass in valid parameters. + + @param UserHandle The handle on which the protocol is installed + @param Prot The protocol to disconnect drivers from + + @retval EFI_SUCCESS Drivers using the protocol interface are all + disconnected + @retval EFI_ACCESS_DENIED Failed to disconnect one or all of the drivers + +**/ +EFI_STATUS +CoreDisconnectControllersUsingProtocolInterface ( + IN EFI_HANDLE UserHandle, + IN PROTOCOL_INTERFACE *Prot + ); + + +/** + Acquire lock on gProtocolDatabaseLock. + +**/ +VOID +CoreAcquireProtocolLock ( + VOID + ); + + +/** + Release lock on gProtocolDatabaseLock. + +**/ +VOID +CoreReleaseProtocolLock ( + VOID + ); + + +/** + Check whether a handle is a valid EFI_HANDLE + + @param UserHandle The handle to check + + @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE. + @retval EFI_SUCCESS The handle is valid EFI_HANDLE. + +**/ +EFI_STATUS +CoreValidateHandle ( + IN EFI_HANDLE UserHandle + ); + +// +// Externs +// +extern EFI_LOCK gProtocolDatabaseLock; +extern LIST_ENTRY gHandleList; +extern UINT64 gHandleDatabaseKey; + +#endif diff --git a/MdeModulePkg/Core/Dxe/Hand/Locate.c b/MdeModulePkg/Core/Dxe/Hand/Locate.c index de3152107b..2b961c14d4 100644 --- a/MdeModulePkg/Core/Dxe/Hand/Locate.c +++ b/MdeModulePkg/Core/Dxe/Hand/Locate.c @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" +#include "Handle.h" // // ProtocolRequest - Last LocateHandle request ID diff --git a/MdeModulePkg/Core/Dxe/Hand/Notify.c b/MdeModulePkg/Core/Dxe/Hand/Notify.c index 572ba12eed..dd170ac1cc 100644 --- a/MdeModulePkg/Core/Dxe/Hand/Notify.c +++ b/MdeModulePkg/Core/Dxe/Hand/Notify.c @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" +#include "Handle.h" /** diff --git a/MdeModulePkg/Core/Dxe/Handle.h b/MdeModulePkg/Core/Dxe/Handle.h deleted file mode 100644 index b73bad99e1..0000000000 --- a/MdeModulePkg/Core/Dxe/Handle.h +++ /dev/null @@ -1,273 +0,0 @@ -/** @file - Support functions for managing protocol. - -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _HAND_H_ -#define _HAND_H_ - - -// -// IHANDLE - contains a list of protocol handles -// - -#define EFI_HANDLE_SIGNATURE EFI_SIGNATURE_32('h','n','d','l') -typedef struct { - UINTN Signature; - LIST_ENTRY AllHandles; // All handles list of IHANDLE - LIST_ENTRY Protocols; // List of PROTOCOL_INTERFACE's for this handle - UINTN LocateRequest; // - UINT64 Key; // The Handle Database Key value when this handle was last created or modified -} IHANDLE; - -#define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE) - - -// -// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol -// database. Each handler that supports this protocol is listed, along -// with a list of registered notifies. -// - -#define PROTOCOL_ENTRY_SIGNATURE EFI_SIGNATURE_32('p','r','t','e') -typedef struct { - UINTN Signature; - LIST_ENTRY AllEntries; // Link Entry inserted to mProtocolDatabase - EFI_GUID ProtocolID; // ID of the protocol - LIST_ENTRY Protocols; // All protocol interfaces - LIST_ENTRY Notify; // Registerd notification handlers -} PROTOCOL_ENTRY; - -// -// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked -// with a protocol interface structure -// - -#define PROTOCOL_INTERFACE_SIGNATURE EFI_SIGNATURE_32('p','i','f','c') -typedef struct { - UINTN Signature; - LIST_ENTRY Link; // Link on IHANDLE.Protocols - IHANDLE *Handle; // Back pointer - LIST_ENTRY ByProtocol; // Link on PROTOCOL_ENTRY.Protocols - PROTOCOL_ENTRY *Protocol; // The protocol ID - VOID *Interface; // The interface value - - LIST_ENTRY OpenList; // OPEN_PROTOCOL_DATA list. - UINTN OpenListCount; - -} PROTOCOL_INTERFACE; - -#define OPEN_PROTOCOL_DATA_SIGNATURE EFI_SIGNATURE_32('p','o','d','l') - -typedef struct { - UINTN Signature; - LIST_ENTRY Link; //Link on PROTOCOL_INTERFACE.OpenList - - EFI_HANDLE AgentHandle; - EFI_HANDLE ControllerHandle; - UINT32 Attributes; - UINT32 OpenCount; -} OPEN_PROTOCOL_DATA; - - -// -// PROTOCOL_NOTIFY - used for each register notification for a protocol -// - -#define PROTOCOL_NOTIFY_SIGNATURE EFI_SIGNATURE_32('p','r','t','n') -typedef struct { - UINTN Signature; - PROTOCOL_ENTRY *Protocol; - LIST_ENTRY Link; // All notifications for this protocol - EFI_EVENT Event; // Event to notify - LIST_ENTRY *Position; // Last position notified -} PROTOCOL_NOTIFY; - -// -// Internal prototypes -// - - - -/** - Finds the protocol entry for the requested protocol. - The gProtocolDatabaseLock must be owned - - @param Protocol The ID of the protocol - @param Create Create a new entry if not found - - @return Protocol entry - -**/ -PROTOCOL_ENTRY * -CoreFindProtocolEntry ( - IN EFI_GUID *Protocol, - IN BOOLEAN Create - ); - - -/** - Signal event for every protocol in protocol entry. - - @param ProtEntry Protocol entry - -**/ -VOID -CoreNotifyProtocolEntry ( - IN PROTOCOL_ENTRY *ProtEntry - ); - - -/** - Finds the protocol instance for the requested handle and protocol. - Note: This function doesn't do parameters checking, it's caller's responsibility - to pass in valid parameters. - - @param Handle The handle to search the protocol on - @param Protocol GUID of the protocol - @param Interface The interface for the protocol being searched - - @return Protocol instance (NULL: Not found) - -**/ -PROTOCOL_INTERFACE * -CoreFindProtocolInterface ( - IN IHANDLE *Handle, - IN EFI_GUID *Protocol, - IN VOID *Interface - ); - - -/** - Removes Protocol from the protocol list (but not the handle list). - - @param Handle The handle to remove protocol on. - @param Protocol GUID of the protocol to be moved - @param Interface The interface of the protocol - - @return Protocol Entry - -**/ -PROTOCOL_INTERFACE * -CoreRemoveInterfaceFromProtocol ( - IN IHANDLE *Handle, - IN EFI_GUID *Protocol, - IN VOID *Interface - ); - - -/** - Removes all the events in the protocol database that match Event. - - @param Event The event to search for in the protocol - database. - - @return EFI_SUCCESS when done searching the entire database. - -**/ -EFI_STATUS -CoreUnregisterProtocolNotify ( - IN EFI_EVENT Event - ); - -/** - Connects a controller to a driver. - - @param ControllerHandle Handle of the controller to be - connected. - @param ContextDriverImageHandles DriverImageHandle A pointer to an - ordered list of driver image - handles. - @param RemainingDevicePath RemainingDevicePath A pointer to - the device path that specifies a - child of the controller - specified by ControllerHandle. - - @retval EFI_SUCCESS One or more drivers were - connected to ControllerHandle. - @retval EFI_OUT_OF_RESOURCES No enough system resources to - complete the request. - @retval EFI_NOT_FOUND No drivers were connected to - ControllerHandle. - -**/ -EFI_STATUS -CoreConnectSingleController ( - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE *ContextDriverImageHandles OPTIONAL, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ); - -/** - Attempts to disconnect all drivers that are using the protocol interface being queried. - If failed, reconnect all drivers disconnected. - Note: This function doesn't do parameters checking, it's caller's responsibility - to pass in valid parameters. - - @param UserHandle The handle on which the protocol is installed - @param Prot The protocol to disconnect drivers from - - @retval EFI_SUCCESS Drivers using the protocol interface are all - disconnected - @retval EFI_ACCESS_DENIED Failed to disconnect one or all of the drivers - -**/ -EFI_STATUS -CoreDisconnectControllersUsingProtocolInterface ( - IN EFI_HANDLE UserHandle, - IN PROTOCOL_INTERFACE *Prot - ); - - -/** - Acquire lock on gProtocolDatabaseLock. - -**/ -VOID -CoreAcquireProtocolLock ( - VOID - ); - - -/** - Release lock on gProtocolDatabaseLock. - -**/ -VOID -CoreReleaseProtocolLock ( - VOID - ); - - -/** - Check whether a handle is a valid EFI_HANDLE - - @param UserHandle The handle to check - - @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE. - @retval EFI_SUCCESS The handle is valid EFI_HANDLE. - -**/ -EFI_STATUS -CoreValidateHandle ( - IN EFI_HANDLE UserHandle - ); - -// -// Externs -// - -extern EFI_LOCK gProtocolDatabaseLock; -extern LIST_ENTRY gHandleList; -extern UINT64 gHandleDatabaseKey; - -#endif diff --git a/MdeModulePkg/Core/Dxe/Image.h b/MdeModulePkg/Core/Dxe/Image.h deleted file mode 100644 index 040941db14..0000000000 --- a/MdeModulePkg/Core/Dxe/Image.h +++ /dev/null @@ -1,233 +0,0 @@ -/** @file - Data structure and functions to load and unload PeImage. - -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - - -#ifndef _IMAGE_H_ -#define _IMAGE_H_ - - - -#define LOADED_IMAGE_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32('l','d','r','i') - -typedef struct { - UINTN Signature; - EFI_HANDLE Handle; // Image handle - UINTN Type; // Image type - - BOOLEAN Started; // If entrypoint has been called - - EFI_IMAGE_ENTRY_POINT EntryPoint; // The image's entry point - EFI_LOADED_IMAGE_PROTOCOL Info; // loaded image protocol - - EFI_PHYSICAL_ADDRESS ImageBasePage; // Location in memory - UINTN NumberOfPages; // Number of pages - - CHAR8 *FixupData; // Original fixup data - - EFI_TPL Tpl; // Tpl of started image - EFI_STATUS Status; // Status returned by started image - - UINTN ExitDataSize; // Size of ExitData from started image - VOID *ExitData; // Pointer to exit data from started image - VOID *JumpBuffer; // Pointer to pool allocation for context save/retore - BASE_LIBRARY_JUMP_BUFFER *JumpContext; // Pointer to buffer for context save/retore - UINT16 Machine; // Machine type from PE image - - EFI_EBC_PROTOCOL *Ebc; // EBC Protocol pointer - - EFI_RUNTIME_IMAGE_ENTRY *RuntimeData; // Runtime image list - - EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath; // Pointer to Loaded Image Device Path Protocl - - PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; // PeCoffLoader ImageContext - -} LOADED_IMAGE_PRIVATE_DATA; - -#define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \ - CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE) - - - -#define LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32('l','p','e','i') - -typedef struct { - UINTN Signature; - EFI_HANDLE Handle; // Image handle - EFI_PE32_IMAGE_PROTOCOL Pe32Image; -} LOAD_PE32_IMAGE_PRIVATE_DATA; - -#define LOAD_PE32_IMAGE_PRIVATE_DATA_FROM_THIS(a) \ - CR(a, LOAD_PE32_IMAGE_PRIVATE_DATA, Pe32Image, LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE) - - - -// -// Private Data Types -// -#define IMAGE_FILE_HANDLE_SIGNATURE EFI_SIGNATURE_32('i','m','g','f') -typedef struct { - UINTN Signature; - BOOLEAN FreeBuffer; - VOID *Source; - UINTN SourceSize; -} IMAGE_FILE_HANDLE; - - -// -// Abstractions for reading image contents -// - - -/** - Opens a file for (simple) reading. The simple read abstraction - will access the file either from a memory copy, from a file - system interface, or from the load file interface. - - @param BootPolicy Policy for Open Image File. - @param SourceBuffer Pointer to the memory location containing copy - of the image to be loaded. - @param SourceSize The size in bytes of SourceBuffer. - @param FilePath The specific file path from which the image is - loaded - @param DeviceHandle Pointer to the return device handle. - @param ImageFileHandle Pointer to the image file handle. - @param AuthenticationStatus Pointer to a caller-allocated UINT32 in which - the authentication status is returned. - - @retval EFI_SUCCESS Image file successfully opened. - @retval EFI_LOAD_ERROR If the caller passed a copy of the file, and - SourceSize is 0. - @retval EFI_INVALID_PARAMETER File path is not valid. - @retval EFI_NOT_FOUND File not found. - -**/ -EFI_STATUS -CoreOpenImageFile ( - IN BOOLEAN BootPolicy, - IN VOID *SourceBuffer OPTIONAL, - IN UINTN SourceSize, - IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath, - OUT EFI_HANDLE *DeviceHandle, - IN IMAGE_FILE_HANDLE *ImageFileHandle, - OUT UINT32 *AuthenticationStatus - ); - - - -/** - Read image file (specified by UserHandle) into user specified buffer with specified offset - and length. - - @param UserHandle Image file handle - @param Offset Offset to the source file - @param ReadSize For input, pointer of size to read; For output, - pointer of size actually read. - @param Buffer Buffer to write into - - @retval EFI_SUCCESS Successfully read the specified part of file - into buffer. - -**/ -EFI_STATUS -EFIAPI -CoreReadImageFile ( - IN VOID *UserHandle, - IN UINTN Offset, - IN OUT UINTN *ReadSize, - OUT VOID *Buffer - ); - - -/** - A function out of date, should be removed. - - @param ImageFileHandle Handle of the file to close - -**/ -VOID -EFIAPI -CoreCloseImageFile ( - IN IMAGE_FILE_HANDLE *ImageFileHandle - ); - - - -// -// Exported Image functions -// - - -/** - Loads an EFI image into memory and returns a handle to the image with extended parameters. - - @param This Calling context - @param ParentImageHandle The caller's image handle. - @param FilePath The specific file path from which the image is - loaded. - @param SourceBuffer If not NULL, a pointer to the memory location - containing a copy of the image to be loaded. - @param SourceSize The size in bytes of SourceBuffer. - @param DstBuffer The buffer to store the image. - @param NumberOfPages For input, specifies the space size of the - image by caller if not NULL. For output, - specifies the actual space size needed. - @param ImageHandle Image handle for output. - @param EntryPoint Image entry point for output. - @param Attribute The bit mask of attributes to set for the load - PE image. - - @retval EFI_SUCCESS The image was loaded into memory. - @retval EFI_NOT_FOUND The FilePath was not found. - @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. - @retval EFI_UNSUPPORTED The image type is not supported, or the device - path cannot be parsed to locate the proper - protocol for loading the file. - @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient - resources. - -**/ -EFI_STATUS -EFIAPI -CoreLoadImageEx ( - IN EFI_PE32_IMAGE_PROTOCOL *This, - IN EFI_HANDLE ParentImageHandle, - IN EFI_DEVICE_PATH_PROTOCOL *FilePath, - IN VOID *SourceBuffer OPTIONAL, - IN UINTN SourceSize, - IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL, - OUT UINTN *NumberOfPages OPTIONAL, - OUT EFI_HANDLE *ImageHandle, - OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL, - IN UINT32 Attribute - ); - - -/** - Unload the specified image. - - @param This Indicates the calling context. - @param ImageHandle The specified image handle. - - @retval EFI_INVALID_PARAMETER Image handle is NULL. - @retval EFI_UNSUPPORTED Attempt to unload an unsupported image. - @retval EFI_SUCCESS Image successfully unloaded. - -**/ -EFI_STATUS -EFIAPI -CoreUnloadImageEx ( - IN EFI_PE32_IMAGE_PROTOCOL *This, - IN EFI_HANDLE ImageHandle - ); -#endif diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index 954710c38f..6f89ddc24b 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -13,10 +13,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" +#include "Image.h" + // // Module Globals // - LOADED_IMAGE_PRIVATE_DATA *mCurrentImage = NULL; LOAD_PE32_IMAGE_PRIVATE_DATA mLoadPe32PrivateData = { diff --git a/MdeModulePkg/Core/Dxe/Image/Image.h b/MdeModulePkg/Core/Dxe/Image/Image.h new file mode 100644 index 0000000000..37660201b1 --- /dev/null +++ b/MdeModulePkg/Core/Dxe/Image/Image.h @@ -0,0 +1,215 @@ +/** @file + Data structure and functions to load and unload PeImage. + +Copyright (c) 2006 - 2008, Intel Corporation.
+All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + + +#ifndef _IMAGE_H_ +#define _IMAGE_H_ + +#define LOADED_IMAGE_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32('l','d','r','i') + +typedef struct { + UINTN Signature; + /// Image handle + EFI_HANDLE Handle; + /// Image type + UINTN Type; + /// If entrypoint has been called + BOOLEAN Started; + /// The image's entry point + EFI_IMAGE_ENTRY_POINT EntryPoint; + /// loaded image protocol + EFI_LOADED_IMAGE_PROTOCOL Info; + /// Location in memory + EFI_PHYSICAL_ADDRESS ImageBasePage; + /// Number of pages + UINTN NumberOfPages; + /// Original fixup data + CHAR8 *FixupData; + /// Tpl of started image + EFI_TPL Tpl; + /// Status returned by started image + EFI_STATUS Status; + /// Size of ExitData from started image + UINTN ExitDataSize; + /// Pointer to exit data from started image + VOID *ExitData; + /// Pointer to pool allocation for context save/retore + VOID *JumpBuffer; + /// Pointer to buffer for context save/retore + BASE_LIBRARY_JUMP_BUFFER *JumpContext; + /// Machine type from PE image + UINT16 Machine; + /// EBC Protocol pointer + EFI_EBC_PROTOCOL *Ebc; + /// Runtime image list + EFI_RUNTIME_IMAGE_ENTRY *RuntimeData; + /// Pointer to Loaded Image Device Path Protocl + EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath; + /// PeCoffLoader ImageContext + PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; + +} LOADED_IMAGE_PRIVATE_DATA; + +#define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \ + CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE) + + +#define LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32('l','p','e','i') + +typedef struct { + UINTN Signature; + /// Image handle + EFI_HANDLE Handle; + EFI_PE32_IMAGE_PROTOCOL Pe32Image; +} LOAD_PE32_IMAGE_PRIVATE_DATA; + +#define LOAD_PE32_IMAGE_PRIVATE_DATA_FROM_THIS(a) \ + CR(a, LOAD_PE32_IMAGE_PRIVATE_DATA, Pe32Image, LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE) + + +// +// Private Data Types +// +#define IMAGE_FILE_HANDLE_SIGNATURE EFI_SIGNATURE_32('i','m','g','f') +typedef struct { + UINTN Signature; + BOOLEAN FreeBuffer; + VOID *Source; + UINTN SourceSize; +} IMAGE_FILE_HANDLE; + + +/** + Opens a file for (simple) reading. The simple read abstraction + will access the file either from a memory copy, from a file + system interface, or from the load file interface. + + @param BootPolicy Policy for Open Image File. + @param SourceBuffer Pointer to the memory location containing copy + of the image to be loaded. + @param SourceSize The size in bytes of SourceBuffer. + @param FilePath The specific file path from which the image is + loaded + @param DeviceHandle Pointer to the return device handle. + @param ImageFileHandle Pointer to the image file handle. + @param AuthenticationStatus Pointer to a caller-allocated UINT32 in which + the authentication status is returned. + + @retval EFI_SUCCESS Image file successfully opened. + @retval EFI_LOAD_ERROR If the caller passed a copy of the file, and + SourceSize is 0. + @retval EFI_INVALID_PARAMETER File path is not valid. + @retval EFI_NOT_FOUND File not found. + +**/ +EFI_STATUS +CoreOpenImageFile ( + IN BOOLEAN BootPolicy, + IN VOID *SourceBuffer OPTIONAL, + IN UINTN SourceSize, + IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath, + OUT EFI_HANDLE *DeviceHandle, + IN IMAGE_FILE_HANDLE *ImageFileHandle, + OUT UINT32 *AuthenticationStatus + ); + + + +/** + Read image file (specified by UserHandle) into user specified buffer with specified offset + and length. + + @param UserHandle Image file handle + @param Offset Offset to the source file + @param ReadSize For input, pointer of size to read; For output, + pointer of size actually read. + @param Buffer Buffer to write into + + @retval EFI_SUCCESS Successfully read the specified part of file + into buffer. + +**/ +EFI_STATUS +EFIAPI +CoreReadImageFile ( + IN VOID *UserHandle, + IN UINTN Offset, + IN OUT UINTN *ReadSize, + OUT VOID *Buffer + ); + + +/** + Loads an EFI image into memory and returns a handle to the image with extended parameters. + + @param This Calling context + @param ParentImageHandle The caller's image handle. + @param FilePath The specific file path from which the image is + loaded. + @param SourceBuffer If not NULL, a pointer to the memory location + containing a copy of the image to be loaded. + @param SourceSize The size in bytes of SourceBuffer. + @param DstBuffer The buffer to store the image. + @param NumberOfPages For input, specifies the space size of the + image by caller if not NULL. For output, + specifies the actual space size needed. + @param ImageHandle Image handle for output. + @param EntryPoint Image entry point for output. + @param Attribute The bit mask of attributes to set for the load + PE image. + + @retval EFI_SUCCESS The image was loaded into memory. + @retval EFI_NOT_FOUND The FilePath was not found. + @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. + @retval EFI_UNSUPPORTED The image type is not supported, or the device + path cannot be parsed to locate the proper + protocol for loading the file. + @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient + resources. + +**/ +EFI_STATUS +EFIAPI +CoreLoadImageEx ( + IN EFI_PE32_IMAGE_PROTOCOL *This, + IN EFI_HANDLE ParentImageHandle, + IN EFI_DEVICE_PATH_PROTOCOL *FilePath, + IN VOID *SourceBuffer OPTIONAL, + IN UINTN SourceSize, + IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL, + OUT UINTN *NumberOfPages OPTIONAL, + OUT EFI_HANDLE *ImageHandle, + OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL, + IN UINT32 Attribute + ); + + +/** + Unload the specified image. + + @param This Indicates the calling context. + @param ImageHandle The specified image handle. + + @retval EFI_INVALID_PARAMETER Image handle is NULL. + @retval EFI_UNSUPPORTED Attempt to unload an unsupported image. + @retval EFI_SUCCESS Image successfully unloaded. + +**/ +EFI_STATUS +EFIAPI +CoreUnloadImageEx ( + IN EFI_PE32_IMAGE_PROTOCOL *This, + IN EFI_HANDLE ImageHandle + ); +#endif diff --git a/MdeModulePkg/Core/Dxe/Image/ImageFile.c b/MdeModulePkg/Core/Dxe/Image/ImageFile.c index 65ecde2cf4..453e88b940 100644 --- a/MdeModulePkg/Core/Dxe/Image/ImageFile.c +++ b/MdeModulePkg/Core/Dxe/Image/ImageFile.c @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" +#include "Image.h" /** Search a handle to a device on a specified device path that supports a specified protocol, diff --git a/MdeModulePkg/Core/Dxe/Imem.h b/MdeModulePkg/Core/Dxe/Imem.h deleted file mode 100644 index 23e6d097fd..0000000000 --- a/MdeModulePkg/Core/Dxe/Imem.h +++ /dev/null @@ -1,155 +0,0 @@ -/** @file - Data structure and functions to allocate and free memory space. - -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _IMEM_H_ -#define _IMEM_H_ - -#if defined (MDE_CPU_IPF) -// -// For Itanium machines make the default allocations 8K aligned -// -#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2) -#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2) - -#else -// -// For genric EFI machines make the default allocations 4K aligned -// -#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE) -#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE) - -#endif - - -// -// MEMORY_MAP_ENTRY -// - -#define MEMORY_MAP_SIGNATURE EFI_SIGNATURE_32('m','m','a','p') -typedef struct { - UINTN Signature; - LIST_ENTRY Link; - BOOLEAN FromPages; - - EFI_MEMORY_TYPE Type; - UINT64 Start; - UINT64 End; - - UINT64 VirtualStart; - UINT64 Attribute; -} MEMORY_MAP; - -// -// Internal prototypes -// - - -/** - Internal function. Used by the pool functions to allocate pages - to back pool allocation requests. - - @param PoolType The type of memory for the new pool pages - @param NumberOfPages No of pages to allocate - @param Alignment Bits to align. - - @return The allocated memory, or NULL - -**/ -VOID * -CoreAllocatePoolPages ( - IN EFI_MEMORY_TYPE PoolType, - IN UINTN NumberOfPages, - IN UINTN Alignment - ); - - - -/** - Internal function. Frees pool pages allocated via AllocatePoolPages () - - @param Memory The base address to free - @param NumberOfPages The number of pages to free - -**/ -VOID -CoreFreePoolPages ( - IN EFI_PHYSICAL_ADDRESS Memory, - IN UINTN NumberOfPages - ); - - - -/** - Internal function to allocate pool of a particular type. - Caller must have the memory lock held - - @param PoolType Type of pool to allocate - @param Size The amount of pool to allocate - - @return The allocate pool, or NULL - -**/ -VOID * -CoreAllocatePoolI ( - IN EFI_MEMORY_TYPE PoolType, - IN UINTN Size - ); - - - -/** - Internal function to free a pool entry. - Caller must have the memory lock held - - @param Buffer The allocated pool entry to free - - @retval EFI_INVALID_PARAMETER Buffer not valid - @retval EFI_SUCCESS Buffer successfully freed. - -**/ -EFI_STATUS -CoreFreePoolI ( - IN VOID *Buffer - ); - - - -/** - Enter critical section by gaining lock on gMemoryLock. - -**/ -VOID -CoreAcquireMemoryLock ( - VOID - ); - - -/** - Exit critical section by releasing lock on gMemoryLock. - -**/ -VOID -CoreReleaseMemoryLock ( - VOID - ); - - -// -// Internal Global data -// - -extern EFI_LOCK gMemoryLock; -extern LIST_ENTRY gMemoryMap; -extern LIST_ENTRY mGcdMemorySpaceMap; -#endif diff --git a/MdeModulePkg/Core/Dxe/Library.h b/MdeModulePkg/Core/Dxe/Library.h deleted file mode 100644 index 0d907d8341..0000000000 --- a/MdeModulePkg/Core/Dxe/Library.h +++ /dev/null @@ -1,68 +0,0 @@ -/** @file - Internal functions shared in DxeCore module. - -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _DXE_LIBRARY_H_ -#define _DXE_LIBRARY_H_ - - -/** - Raising to the task priority level of the mutual exclusion - lock, and then acquires ownership of the lock. - - @param Lock The lock to acquire - - @return Lock owned - -**/ -VOID -CoreAcquireLock ( - IN EFI_LOCK *Lock - ); - - -/** - Initialize a basic mutual exclusion lock. Each lock - provides mutual exclusion access at it's task priority - level. Since there is no-premption (at any TPL) or - multiprocessor support, acquiring the lock only consists - of raising to the locks TPL. - - @param Lock The EFI_LOCK structure to initialize - - @retval EFI_SUCCESS Lock Owned. - @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned. - -**/ -EFI_STATUS -CoreAcquireLockOrFail ( - IN EFI_LOCK *Lock - ); - - -/** - Releases ownership of the mutual exclusion lock, and - restores the previous task priority level. - - @param Lock The lock to release - - @return Lock unowned - -**/ -VOID -CoreReleaseLock ( - IN EFI_LOCK *Lock - ); - - -#endif diff --git a/MdeModulePkg/Core/Dxe/Mem/Imem.h b/MdeModulePkg/Core/Dxe/Mem/Imem.h new file mode 100644 index 0000000000..8a60d59f4c --- /dev/null +++ b/MdeModulePkg/Core/Dxe/Mem/Imem.h @@ -0,0 +1,155 @@ +/** @file + Data structure and functions to allocate and free memory space. + +Copyright (c) 2006 - 2008, Intel Corporation.
+All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _IMEM_H_ +#define _IMEM_H_ + +#if defined (MDE_CPU_IPF) +/// +/// For Itanium machines make the default allocations 8K aligned +/// +#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2) +#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2) + +#else +/// +/// For genric EFI machines make the default allocations 4K aligned +/// +#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE) +#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE) + +#endif + + +// +// MEMORY_MAP_ENTRY +// + +#define MEMORY_MAP_SIGNATURE EFI_SIGNATURE_32('m','m','a','p') +typedef struct { + UINTN Signature; + LIST_ENTRY Link; + BOOLEAN FromPages; + + EFI_MEMORY_TYPE Type; + UINT64 Start; + UINT64 End; + + UINT64 VirtualStart; + UINT64 Attribute; +} MEMORY_MAP; + +// +// Internal prototypes +// + + +/** + Internal function. Used by the pool functions to allocate pages + to back pool allocation requests. + + @param PoolType The type of memory for the new pool pages + @param NumberOfPages No of pages to allocate + @param Alignment Bits to align. + + @return The allocated memory, or NULL + +**/ +VOID * +CoreAllocatePoolPages ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN NumberOfPages, + IN UINTN Alignment + ); + + + +/** + Internal function. Frees pool pages allocated via AllocatePoolPages () + + @param Memory The base address to free + @param NumberOfPages The number of pages to free + +**/ +VOID +CoreFreePoolPages ( + IN EFI_PHYSICAL_ADDRESS Memory, + IN UINTN NumberOfPages + ); + + + +/** + Internal function to allocate pool of a particular type. + Caller must have the memory lock held + + @param PoolType Type of pool to allocate + @param Size The amount of pool to allocate + + @return The allocate pool, or NULL + +**/ +VOID * +CoreAllocatePoolI ( + IN EFI_MEMORY_TYPE PoolType, + IN UINTN Size + ); + + + +/** + Internal function to free a pool entry. + Caller must have the memory lock held + + @param Buffer The allocated pool entry to free + + @retval EFI_INVALID_PARAMETER Buffer not valid + @retval EFI_SUCCESS Buffer successfully freed. + +**/ +EFI_STATUS +CoreFreePoolI ( + IN VOID *Buffer + ); + + + +/** + Enter critical section by gaining lock on gMemoryLock. + +**/ +VOID +CoreAcquireMemoryLock ( + VOID + ); + + +/** + Exit critical section by releasing lock on gMemoryLock. + +**/ +VOID +CoreReleaseMemoryLock ( + VOID + ); + + +// +// Internal Global data +// + +extern EFI_LOCK gMemoryLock; +extern LIST_ENTRY gMemoryMap; +extern LIST_ENTRY mGcdMemorySpaceMap; +#endif diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c index 179376dc31..5e3c81d786 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" +#include "Imem.h" #define EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE) diff --git a/MdeModulePkg/Core/Dxe/Mem/Pool.c b/MdeModulePkg/Core/Dxe/Mem/Pool.c index 2764a8ef9f..cea6fada4c 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Pool.c +++ b/MdeModulePkg/Core/Dxe/Mem/Pool.c @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeMain.h" +#include "Imem.h" #define POOL_FREE_SIGNATURE EFI_SIGNATURE_32('p','f','r','0') typedef struct { diff --git a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c b/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c index 556c14c585..295f32f43e 100644 --- a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c +++ b/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c @@ -24,7 +24,9 @@ EFI_DEBUG_IMAGE_INFO_TABLE_HEADER mDebugInfoTableHeader = { EFI_SYSTEM_TABLE_POINTER *mDebugTable = NULL; +#define FOUR_MEG_ALIGNMENT 0x400000 +#define EFI_DEBUG_TABLE_ENTRY_SIZE (sizeof (VOID *)) /** Creates and initializes the DebugImageInfo Table. Also creates the configuration -- cgit v1.2.3