From bb89ec1a7ec2f8d35033df9e47b3604925da3bd3 Mon Sep 17 00:00:00 2001 From: jljusten Date: Tue, 28 Jun 2011 16:47:23 +0000 Subject: InOsEmuPkg: Rename package to EmulatorPkg & Sec to Host * Rename InOsEmuPkg to EmulatorPkg * Rename Unix/Sec to Unix/Host Signed-off-by: jljusten Reviewed-by: andrewfish Reviewed-by: geekboy15a git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11918 6f19259b-4bc3-4df7-8a09-765794883524 --- EmulatorPkg/Include/Guid/EmuPhysicalDisk.h | 24 ++ EmulatorPkg/Include/Guid/EmuSystemConfig.h | 36 ++ EmulatorPkg/Include/Guid/EmuVirtualDisk.h | 24 ++ EmulatorPkg/Include/Library/EmuMagicPageLib.h | 38 ++ EmulatorPkg/Include/Library/EmuThunkLib.h | 42 +++ EmulatorPkg/Include/Library/KeyMapLib.h | 43 +++ EmulatorPkg/Include/Library/PpiListLib.h | 21 ++ EmulatorPkg/Include/Library/ThunkPpiList.h | 33 ++ EmulatorPkg/Include/Library/ThunkProtocolList.h | 35 ++ EmulatorPkg/Include/Ppi/EmuThunk.h | 127 +++++++ EmulatorPkg/Include/Protocol/EmuBlockIo.h | 192 ++++++++++ EmulatorPkg/Include/Protocol/EmuFileSystem.h | 140 +++++++ EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h | 134 +++++++ EmulatorPkg/Include/Protocol/EmuIoThunk.h | 51 +++ EmulatorPkg/Include/Protocol/EmuSnp.h | 459 +++++++++++++++++++++++ EmulatorPkg/Include/Protocol/EmuThread.h | 103 +++++ EmulatorPkg/Include/Protocol/EmuThunk.h | 264 +++++++++++++ 17 files changed, 1766 insertions(+) create mode 100644 EmulatorPkg/Include/Guid/EmuPhysicalDisk.h create mode 100644 EmulatorPkg/Include/Guid/EmuSystemConfig.h create mode 100644 EmulatorPkg/Include/Guid/EmuVirtualDisk.h create mode 100644 EmulatorPkg/Include/Library/EmuMagicPageLib.h create mode 100644 EmulatorPkg/Include/Library/EmuThunkLib.h create mode 100644 EmulatorPkg/Include/Library/KeyMapLib.h create mode 100644 EmulatorPkg/Include/Library/PpiListLib.h create mode 100644 EmulatorPkg/Include/Library/ThunkPpiList.h create mode 100644 EmulatorPkg/Include/Library/ThunkProtocolList.h create mode 100644 EmulatorPkg/Include/Ppi/EmuThunk.h create mode 100644 EmulatorPkg/Include/Protocol/EmuBlockIo.h create mode 100644 EmulatorPkg/Include/Protocol/EmuFileSystem.h create mode 100644 EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h create mode 100644 EmulatorPkg/Include/Protocol/EmuIoThunk.h create mode 100644 EmulatorPkg/Include/Protocol/EmuSnp.h create mode 100644 EmulatorPkg/Include/Protocol/EmuThread.h create mode 100644 EmulatorPkg/Include/Protocol/EmuThunk.h (limited to 'EmulatorPkg/Include') diff --git a/EmulatorPkg/Include/Guid/EmuPhysicalDisk.h b/EmulatorPkg/Include/Guid/EmuPhysicalDisk.h new file mode 100644 index 0000000..324dc04 --- /dev/null +++ b/EmulatorPkg/Include/Guid/EmuPhysicalDisk.h @@ -0,0 +1,24 @@ +/** @file + Setup Variable data structure for Emu platform. + +Copyright (c) 2009, 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 __EMU_PHYSICAL_DISK_H__ +#define __EMU_PHYSICAL_DISK_H__ + +#define EFI_EMU_PHYSICAL_DISK_GUID \ + { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } } + +extern EFI_GUID gEmuPhysicalDisksGuid; + +#endif diff --git a/EmulatorPkg/Include/Guid/EmuSystemConfig.h b/EmulatorPkg/Include/Guid/EmuSystemConfig.h new file mode 100644 index 0000000..b3a7d9b --- /dev/null +++ b/EmulatorPkg/Include/Guid/EmuSystemConfig.h @@ -0,0 +1,36 @@ +/** @file + Setup Variable data structure for Emu platform. + +Copyright (c) 2009, 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 __EMU_SYSTEM_CONFIG_H__ +#define __EMU_SYSTEM_CONFIG_H__ + +#define EFI_EMU_SYSTEM_CONFIG_GUID \ + { 0x9C4FB516, 0x3A1E, 0xD847, { 0xA1, 0xA1, 0x70, 0x58, 0xB6, 0x98, 0x67, 0x32 } } + + +#pragma pack(1) +typedef struct { + // + // Console output mode + // + UINT32 ConOutColumn; + UINT32 ConOutRow; +} EMU_SYSTEM_CONFIGURATION; +#pragma pack() + + +extern EFI_GUID gEmuSystemConfigGuid; + +#endif diff --git a/EmulatorPkg/Include/Guid/EmuVirtualDisk.h b/EmulatorPkg/Include/Guid/EmuVirtualDisk.h new file mode 100644 index 0000000..17b97dc --- /dev/null +++ b/EmulatorPkg/Include/Guid/EmuVirtualDisk.h @@ -0,0 +1,24 @@ +/** @file + Setup Variable data structure for Emu platform. + +Copyright (c) 2009, 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 __EMU_VIRTUAL_DISK_H__ +#define __EMU_VIRTUAL_DISK_H__ + +#define EFI_EMU_VIRTUAL_DISK_GUID \ + { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } } + +extern EFI_GUID gEmuVirtualDisksGuid; + +#endif diff --git a/EmulatorPkg/Include/Library/EmuMagicPageLib.h b/EmulatorPkg/Include/Library/EmuMagicPageLib.h new file mode 100644 index 0000000..a701b76 --- /dev/null +++ b/EmulatorPkg/Include/Library/EmuMagicPageLib.h @@ -0,0 +1,38 @@ +/*++ @file +The PCD, gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage, points to a magic page +of memory that is like SRAM on an embedded system. This file defines what goes +where in the magic page. + +Copyright (c) 2011, Apple Inc. 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 __EMU_MAGIC_PAGE_LIB_H__ +#define __EMU_MAGIC_PAGE_LIB_H__ + +#include +#include +#include + +typedef struct { + // Used by PEI Core and PEIMs to store the PEI Services pointer. + // Privilege issues prevent using the PI mechanism in the emulator. + CONST EFI_PEI_SERVICES **PeiServicesTablePointer; + + // Used by SecPeiServicesLib + EFI_PEI_PPI_DESCRIPTOR *PpiList; + + // Needed by PEI PEI PeCoffLoaderExtraActionLib + EMU_THUNK_PROTOCOL *Thunk; +} EMU_MAGIC_PAGE_LAYOUT; + +#define EMU_MAGIC_PAGE() ((EMU_MAGIC_PAGE_LAYOUT *)((UINTN)PcdGet64 (PcdPeiServicesTablePage))) + +#endif diff --git a/EmulatorPkg/Include/Library/EmuThunkLib.h b/EmulatorPkg/Include/Library/EmuThunkLib.h new file mode 100644 index 0000000..9d69d4f --- /dev/null +++ b/EmulatorPkg/Include/Library/EmuThunkLib.h @@ -0,0 +1,42 @@ +/*++ @file + +Copyright (c) 2011, Apple Inc. 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 __EMU_THUNK_LIB_H__ +#define __EMU_THUNK_LIB_H__ + +#include + + +extern EMU_THUNK_PROTOCOL *gEmuThunk; + + +/** + Serach the EMU IO Thunk database for a matching EMU IO Thunk + Protocol instance. + + @param Protocol Protocol to search for. + @param Instance Instance of protocol to search for. + + @retval NULL Protocol and Instance not found. + @retval other EMU IO Thunk protocol that matched. + +**/ +EMU_IO_THUNK_PROTOCOL * +EFIAPI +GetIoThunkInstance ( + IN EFI_GUID *Protocol, + IN UINTN Instance + ); + + +#endif diff --git a/EmulatorPkg/Include/Library/KeyMapLib.h b/EmulatorPkg/Include/Library/KeyMapLib.h new file mode 100644 index 0000000..7bd29a7 --- /dev/null +++ b/EmulatorPkg/Include/Library/KeyMapLib.h @@ -0,0 +1,43 @@ +/*++ @file + +Copyright (c) 2011, Apple Inc. 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. + +**/ + +#include + + +/** + KeyMapMake gets called on key presses. + + @param KeyData Key that was pressed. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +KeyMapMake ( + IN EFI_KEY_DATA *KeyData + ); + +/** + KeyMapBreak gets called on key releases. + + @param KeyData Key that was pressed. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +KeyMapBreak ( + IN EFI_KEY_DATA *KeyData + ); diff --git a/EmulatorPkg/Include/Library/PpiListLib.h b/EmulatorPkg/Include/Library/PpiListLib.h new file mode 100644 index 0000000..061cfca --- /dev/null +++ b/EmulatorPkg/Include/Library/PpiListLib.h @@ -0,0 +1,21 @@ +/*++ @file + +Copyright (c) 2011, Apple Inc. 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 __PPI_LIST_LIB_H__ +#define __PPI_LIST_LIB_H__ + + +extern CONST EFI_PEI_PPI_DESCRIPTOR *gPpiList; + + +#endif diff --git a/EmulatorPkg/Include/Library/ThunkPpiList.h b/EmulatorPkg/Include/Library/ThunkPpiList.h new file mode 100644 index 0000000..febc972 --- /dev/null +++ b/EmulatorPkg/Include/Library/ThunkPpiList.h @@ -0,0 +1,33 @@ +/** @file + All 3rd parties to register the PPIs passed into PEI Core + + Copyright (c) 2008 - 2011, Apple Inc. 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. + +**/ + +#include + + +EFI_PEI_PPI_DESCRIPTOR * +GetThunkPpiList ( + VOID + ); + + +EFI_STATUS +EFIAPI +AddThunkPpi ( + IN UINTN Flags, + IN EFI_GUID *Guid, + IN VOID *Ppi + ); + + diff --git a/EmulatorPkg/Include/Library/ThunkProtocolList.h b/EmulatorPkg/Include/Library/ThunkProtocolList.h new file mode 100644 index 0000000..5b25f9c --- /dev/null +++ b/EmulatorPkg/Include/Library/ThunkProtocolList.h @@ -0,0 +1,35 @@ +/** @file + Emulator Thunk to abstract OS services from pure EFI code + + Copyright (c) 2008 - 2011, Apple Inc. 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. + +**/ + +#include +#include + + +EFI_STATUS +EFIAPI +AddThunkProtocol ( + IN EMU_IO_THUNK_PROTOCOL *ThunkIo, + IN CHAR16 *ConfigString, + IN BOOLEAN EmuBusDriver + ); + +EFI_STATUS +EFIAPI +GetNextThunkProtocol ( + IN BOOLEAN EmuBusDriver, + OUT EMU_IO_THUNK_PROTOCOL **Instance + ); + + diff --git a/EmulatorPkg/Include/Ppi/EmuThunk.h b/EmulatorPkg/Include/Ppi/EmuThunk.h new file mode 100644 index 0000000..20cdc46 --- /dev/null +++ b/EmulatorPkg/Include/Ppi/EmuThunk.h @@ -0,0 +1,127 @@ +/** @file + Emulator Thunk to abstract OS services from pure EFI code + + Copyright (c) 2008 - 2011, Apple Inc. 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 __EMU_THUNK_PPI_H__ +#define __EMU_THUNK_PPI_H__ + +#define EMU_THUNK_PPI_GUID \ + { 0xB958B78C, 0x1D3E, 0xEE40, { 0x8B, 0xF4, 0xF0, 0x63, 0x2D, 0x06, 0x39, 0x16 } } + + + +/*++ + +Routine Description: + This service is called from Index == 0 until it returns EFI_UNSUPPORTED. + It allows discontiguous memory regions to be supported by the emulator. + +Arguments: + Index - Which memory region to use + MemoryBase - Return Base address of memory region + MemorySize - Return size in bytes of the memory region + +Returns: + EFI_SUCCESS - If memory region was mapped + EFI_UNSUPPORTED - If Index is not supported + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_PEI_AUTOSCAN) ( + IN UINTN Index, + OUT EFI_PHYSICAL_ADDRESS *MemoryBase, + OUT UINT64 *MemorySize + ); + + +/*++ + +Routine Description: + Return the FD Size and base address. Since the FD is loaded from a + file into host memory only the SEC will know it's address. + +Arguments: + Index - Which FD, starts at zero. + FdSize - Size of the FD in bytes + FdBase - Start address of the FD. Assume it points to an FV Header + FixUp - Difference between actual FD address and build address + +Returns: + EFI_SUCCESS - Return the Base address and size of the FV + EFI_UNSUPPORTED - Index does nto map to an FD in the system + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_PEI_FD_INFORMATION) ( + IN UINTN Index, + IN OUT EFI_PHYSICAL_ADDRESS *FdBase, + IN OUT UINT64 *FdSize, + IN OUT EFI_PHYSICAL_ADDRESS *FixUp + ); + + +/*++ + +Routine Description: + Export of EMU_THUNK_PROTOCOL from the SEC. + +Returns: + EFI_SUCCESS - Data returned + +**/ +typedef +VOID * +(EFIAPI *EMU_PEI_THUNK_INTERFACE) ( + VOID + ); + + + +/*++ + +Routine Description: + Loads and relocates a PE/COFF image into memory. + +Arguments: + Pe32Data - The base address of the PE/COFF file that is to be loaded and relocated + ImageAddress - The base address of the relocated PE/COFF image + ImageSize - The size of the relocated PE/COFF image + EntryPoint - The entry point of the relocated PE/COFF image + +Returns: + EFI_SUCCESS - The file was loaded and relocated + EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_PEI_LOAD_FILE) ( + VOID *Pe32Data, + EFI_PHYSICAL_ADDRESS *ImageAddress, + UINT64 *ImageSize, + EFI_PHYSICAL_ADDRESS *EntryPoint + ); + + +typedef struct { + EMU_PEI_AUTOSCAN MemoryAutoScan; + EMU_PEI_FD_INFORMATION FirmwareDevices; + EMU_PEI_THUNK_INTERFACE Thunk; +} EMU_THUNK_PPI; + +extern EFI_GUID gEmuThunkPpiGuid; + +#endif diff --git a/EmulatorPkg/Include/Protocol/EmuBlockIo.h b/EmulatorPkg/Include/Protocol/EmuBlockIo.h new file mode 100644 index 0000000..26d6bb8 --- /dev/null +++ b/EmulatorPkg/Include/Protocol/EmuBlockIo.h @@ -0,0 +1,192 @@ +/** @file + Emu Block IO2 protocol as defined in the UEFI 2.3.1 specification. + + The Block IO2 protocol defines an extension to the Block IO protocol which + enables the ability to read and write data at a block level in a non-blocking + manner. + + Copyright (c) 2011, 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 __EMU_BLOCK_IO_H__ +#define __EMU_BLOCK_IO_H__ + +#include +#include + +#define EMU_BLOCK_IO_PROTOCOL_GUID \ +{ 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } } + +typedef struct _EMU_BLOCK_IO_PROTOCOL EMU_BLOCK_IO_PROTOCOL; + + + +/** + Reset the block device hardware. + + @param[in] This Indicates a pointer to the calling context. + @param[in] ExtendedVerification Indicates that the driver may perform a more + exhausive verfication operation of the device + during reset. + + @retval EFI_SUCCESS The device was reset. + @retval EFI_DEVICE_ERROR The device is not functioning properly and could + not be reset. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_BLOCK_RESET) ( + IN EMU_BLOCK_IO_PROTOCOL *This, + IN BOOLEAN ExtendedVerification + ); + +/** + Read BufferSize bytes from Lba into Buffer. + + This function reads the requested number of blocks from the device. All the + blocks are read, or an error is returned. + If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and + non-blocking I/O is being used, the Event associated with this request will + not be signaled. + + @param[in] This Indicates a pointer to the calling context. + @param[in] MediaId Id of the media, changes every time the media is + replaced. + @param[in] Lba The starting Logical Block Address to read from. + @param[in, out] Token A pointer to the token associated with the transaction. + @param[in] BufferSize Size of Buffer, must be a multiple of device block size. + @param[out] Buffer A pointer to the destination buffer for the data. The + caller is responsible for either having implicit or + explicit ownership of the buffer. + + @retval EFI_SUCCESS The read request was queued if Token->Event is + not NULL.The data was read correctly from the + device if the Token->Event is NULL. + @retval EFI_DEVICE_ERROR The device reported an error while performing + the read. + @retval EFI_NO_MEDIA There is no media in the device. + @retval EFI_MEDIA_CHANGED The MediaId is not for the current media. + @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the + intrinsic block size of the device. + @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, + or the buffer is not on proper alignment. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack + of resources. +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_BLOCK_READ) ( + IN EMU_BLOCK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA LBA, + IN OUT EFI_BLOCK_IO2_TOKEN *Token, + IN UINTN BufferSize, + OUT VOID *Buffer + ); + +/** + Write BufferSize bytes from Lba into Buffer. + + This function writes the requested number of blocks to the device. All blocks + are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA, + EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is + being used, the Event associated with this request will not be signaled. + + @param[in] This Indicates a pointer to the calling context. + @param[in] MediaId The media ID that the write request is for. + @param[in] Lba The starting logical block address to be written. The + caller is responsible for writing to only legitimate + locations. + @param[in, out] Token A pointer to the token associated with the transaction. + @param[in] BufferSize Size of Buffer, must be a multiple of device block size. + @param[in] Buffer A pointer to the source buffer for the data. + + @retval EFI_SUCCESS The write request was queued if Event is not NULL. + The data was written correctly to the device if + the Event is NULL. + @retval EFI_WRITE_PROTECTED The device can not be written to. + @retval EFI_NO_MEDIA There is no media in the device. + @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device. + @retval EFI_DEVICE_ERROR The device reported an error while performing the write. + @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device. + @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, + or the buffer is not on proper alignment. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack + of resources. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_BLOCK_WRITE) ( + IN EMU_BLOCK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA LBA, + IN OUT EFI_BLOCK_IO2_TOKEN *Token, + IN UINTN BufferSize, + IN VOID *Buffer + ); + +/** + Flush the Block Device. + + If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED + is returned and non-blocking I/O is being used, the Event associated with + this request will not be signaled. + + @param[in] This Indicates a pointer to the calling context. + @param[in,out] Token A pointer to the token associated with the transaction + + @retval EFI_SUCCESS The flush request was queued if Event is not NULL. + All outstanding data was written correctly to the + device if the Event is NULL. + @retval EFI_DEVICE_ERROR The device reported an error while writting back + the data. + @retval EFI_WRITE_PROTECTED The device cannot be written to. + @retval EFI_NO_MEDIA There is no media in the device. + @retval EFI_MEDIA_CHANGED The MediaId is not for the current media. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack + of resources. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_BLOCK_FLUSH) ( + IN EMU_BLOCK_IO_PROTOCOL *This, + IN OUT EFI_BLOCK_IO2_TOKEN *Token + ); + + +typedef +EFI_STATUS +(EFIAPI *EMU_BLOCK_CREATE_MAPPING) ( + IN EMU_BLOCK_IO_PROTOCOL *This, + IN EFI_BLOCK_IO_MEDIA *Media + ); + + +/// +/// The Block I/O2 protocol defines an extension to the Block I/O protocol which +/// enables the ability to read and write data at a block level in a non-blocking +// manner. +/// +struct _EMU_BLOCK_IO_PROTOCOL { + EMU_BLOCK_RESET Reset; + EMU_BLOCK_READ ReadBlocks; + EMU_BLOCK_WRITE WriteBlocks; + EMU_BLOCK_FLUSH FlushBlocks; + EMU_BLOCK_CREATE_MAPPING CreateMapping; +}; + +extern EFI_GUID gEmuBlockIoProtocolGuid; + +#endif + diff --git a/EmulatorPkg/Include/Protocol/EmuFileSystem.h b/EmulatorPkg/Include/Protocol/EmuFileSystem.h new file mode 100644 index 0000000..3713acf --- /dev/null +++ b/EmulatorPkg/Include/Protocol/EmuFileSystem.h @@ -0,0 +1,140 @@ +/** @file + SimpleFileSystem protocol as defined in the UEFI 2.0 specification. + + The SimpleFileSystem protocol is the programmatic access to the FAT (12,16,32) + file system specified in UEFI 2.0. It can also be used to abstract a file + system other than FAT. + + UEFI 2.0 can boot from any valid EFI image contained in a SimpleFileSystem. + +Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Portions copyright (c) 2011, Apple Inc. All rights reserved. +This program and the accompanying materials are licensed and made available under +the terms and conditions of the BSD License that 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 _EMU_UGA_IO_H_ +#define _EMU_UGA_IO_H_ + +#include +#include +#include +#include + +#define EMU_GRAPHICS_WINDOW_PROTOCOL_GUID \ + { 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 0xC1 } } + +typedef struct _EMU_GRAPHICS_WINDOW_PROTOCOL EMU_GRAPHICS_WINDOW_PROTOCOL; + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_CLOSE)( + EMU_GRAPHICS_WINDOW_PROTOCOL *Uga + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_SIZE)( + EMU_GRAPHICS_WINDOW_PROTOCOL *Uga, + UINT32 Width, + UINT32 Height + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_CHECK_KEY)( + EMU_GRAPHICS_WINDOW_PROTOCOL *Uga + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_GET_KEY)( + EMU_GRAPHICS_WINDOW_PROTOCOL *Uga, + EFI_KEY_DATA *key + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_KEY_SET_STATE) ( + IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, + IN EFI_KEY_TOGGLE_STATE *KeyToggleState + ); + + +typedef +VOID +(EFIAPI *EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK) ( + IN VOID *Context, + IN EFI_KEY_DATA *KeyData + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY) ( + IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, + IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK CallBack, + IN VOID *Context + ); + + +typedef struct { + UINTN SourceX; + UINTN SourceY; + UINTN DestinationX; + UINTN DestinationY; + UINTN Width; + UINTN Height; + UINTN Delta; +} EMU_GRAPHICS_WINDOWS__BLT_ARGS; + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_BLT)( + IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, + IN EFI_UGA_PIXEL *BltBuffer OPTIONAL, + IN EFI_UGA_BLT_OPERATION BltOperation, + IN EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args + ); + +typedef +BOOLEAN +(EFIAPI *EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED) ( + IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, + IN EFI_KEY_DATA *KeyData + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_CHECK_POINTER)( + EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE)( + EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, + EFI_SIMPLE_POINTER_STATE *state + ); + +struct _EMU_GRAPHICS_WINDOW_PROTOCOL { + EMU_GRAPHICS_WINDOWS_SIZE Size; + EMU_GRAPHICS_WINDOWS_CHECK_KEY CheckKey; + EMU_GRAPHICS_WINDOWS_KEY_SET_STATE KeySetState; + EMU_GRAPHICS_WINDOWS_GET_KEY GetKey; + EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY RegisterKeyNotify; + EMU_GRAPHICS_WINDOWS_BLT Blt; + EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED IsKeyPressed; + EMU_GRAPHICS_WINDOWS_CHECK_POINTER CheckPointer; + EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE GetPointerState; +}; + + +extern EFI_GUID gEmuGraphicsWindowProtocolGuid; + +#endif diff --git a/EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h b/EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h new file mode 100644 index 0000000..e1afa0e --- /dev/null +++ b/EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h @@ -0,0 +1,134 @@ +/*++ @file + +Copyright (c) 2006, Tristan Gingold. All rights reserved.
+Portitions copyright (c) 2010 - 2011, Apple Inc. 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 _EMU_UGA_IO_H_ +#define _EMU_UGA_IO_H_ + +#include +#include +#include +#include + +#define EMU_GRAPHICS_WINDOW_PROTOCOL_GUID \ + { 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 0xC1 } } + +typedef struct _EMU_GRAPHICS_WINDOW_PROTOCOL EMU_GRAPHICS_WINDOW_PROTOCOL; + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_CLOSE)( + EMU_GRAPHICS_WINDOW_PROTOCOL *Uga + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_SIZE)( + EMU_GRAPHICS_WINDOW_PROTOCOL *Uga, + UINT32 Width, + UINT32 Height + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_CHECK_KEY)( + EMU_GRAPHICS_WINDOW_PROTOCOL *Uga + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_GET_KEY)( + EMU_GRAPHICS_WINDOW_PROTOCOL *Uga, + EFI_KEY_DATA *key + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_KEY_SET_STATE) ( + IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, + IN EFI_KEY_TOGGLE_STATE *KeyToggleState + ); + + +typedef +VOID +(EFIAPI *EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK) ( + IN VOID *Context, + IN EFI_KEY_DATA *KeyData + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY) ( + IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, + IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack, + IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack, + IN VOID *Context + ); + + +typedef struct { + UINTN SourceX; + UINTN SourceY; + UINTN DestinationX; + UINTN DestinationY; + UINTN Width; + UINTN Height; + UINTN Delta; +} EMU_GRAPHICS_WINDOWS__BLT_ARGS; + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_BLT)( + IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, + IN EFI_UGA_PIXEL *BltBuffer OPTIONAL, + IN EFI_UGA_BLT_OPERATION BltOperation, + IN EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args + ); + +typedef +BOOLEAN +(EFIAPI *EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED) ( + IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, + IN EFI_KEY_DATA *KeyData + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_CHECK_POINTER)( + EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE)( + EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, + EFI_SIMPLE_POINTER_STATE *state + ); + +struct _EMU_GRAPHICS_WINDOW_PROTOCOL { + EMU_GRAPHICS_WINDOWS_SIZE Size; + EMU_GRAPHICS_WINDOWS_CHECK_KEY CheckKey; + EMU_GRAPHICS_WINDOWS_KEY_SET_STATE KeySetState; + EMU_GRAPHICS_WINDOWS_GET_KEY GetKey; + EMU_GRAPHICS_WINDOWS_REGISTER_KEY_NOTIFY RegisterKeyNotify; + EMU_GRAPHICS_WINDOWS_BLT Blt; + EMU_GRAPHICS_WINDOWS_IS_KEY_PRESSED IsKeyPressed; + EMU_GRAPHICS_WINDOWS_CHECK_POINTER CheckPointer; + EMU_GRAPHICS_WINDOWS_GET_POINTER_STATE GetPointerState; +}; + + +extern EFI_GUID gEmuGraphicsWindowProtocolGuid; + +#endif diff --git a/EmulatorPkg/Include/Protocol/EmuIoThunk.h b/EmulatorPkg/Include/Protocol/EmuIoThunk.h new file mode 100644 index 0000000..af132be --- /dev/null +++ b/EmulatorPkg/Include/Protocol/EmuIoThunk.h @@ -0,0 +1,51 @@ +/** @file + Emulator Thunk to abstract OS services from pure EFI code + + Copyright (c) 2010 - 2011, Apple Inc. 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 __EMU_IO_THUNK__ +#define __EMU_IO_THUNK__ + + +#define EMU_IO_THUNK_PROTOCO_GUID \ + { 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } } + + +typedef struct _EMU_IO_THUNK_PROTOCOL EMU_IO_THUNK_PROTOCOL; + + +typedef +EFI_STATUS +(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN) ( + IN EMU_IO_THUNK_PROTOCOL *This + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE) ( + IN EMU_IO_THUNK_PROTOCOL *This + ); + +struct _EMU_IO_THUNK_PROTOCOL { + EFI_GUID *Protocol; + VOID *Interface; /// Only be valid after Open() is called + CHAR16 *ConfigString; + UINT16 Instance; + EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN Open; + EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE Close; + VOID *Private; /// Used by implementation +}; + +extern EFI_GUID gEmuIoThunkProtocolGuid; + +#endif diff --git a/EmulatorPkg/Include/Protocol/EmuSnp.h b/EmulatorPkg/Include/Protocol/EmuSnp.h new file mode 100644 index 0000000..fc8e24c --- /dev/null +++ b/EmulatorPkg/Include/Protocol/EmuSnp.h @@ -0,0 +1,459 @@ +/** @file + The EMU_SNP_PROTOCOL provides services to initialize a network interface, + transmit packets, receive packets, and close a network interface. + + +Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Portitions copyright (c) 2011, Apple Inc. All rights reserved. +This program and the accompanying materials are licensed and made available under +the terms and conditions of the BSD License that 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 __EMU_SNP_H__ +#define __EMU_SNP_H__ + +#include + +#define EMU_SNP_PROTOCOL_GUID \ + { 0xFD5FBE54, 0x8C35, 0xB345, { 0x8A, 0x0F, 0x7A, 0xC8, 0xA5, 0xFD, 0x05, 0x21 } } + +typedef struct _EMU_SNP_PROTOCOL EMU_SNP_PROTOCOL; + + +/** + Register storage for SNP Mode. + + @param This Protocol instance pointer. + @param Mode SimpleNetworkProtocol Mode structure passed into driver. + + @retval EFI_SUCCESS The network interface was started. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_CREATE_MAPPING)( + IN EMU_SNP_PROTOCOL *This, + IN EFI_SIMPLE_NETWORK_MODE *Mode + ); + + +/** + Changes the state of a network interface from "stopped" to "started". + + @param This Protocol instance pointer. + + @retval EFI_SUCCESS The network interface was started. + @retval EFI_ALREADY_STARTED The network interface is already in the started state. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. + @retval EFI_UNSUPPORTED This function is not supported by the network interface. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_START)( + IN EMU_SNP_PROTOCOL *This + ); + +/** + Changes the state of a network interface from "started" to "stopped". + + @param This Protocol instance pointer. + + @retval EFI_SUCCESS The network interface was stopped. + @retval EFI_ALREADY_STARTED The network interface is already in the stopped state. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. + @retval EFI_UNSUPPORTED This function is not supported by the network interface. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_STOP)( + IN EMU_SNP_PROTOCOL *This + ); + +/** + Resets a network adapter and allocates the transmit and receive buffers + required by the network interface; optionally, also requests allocation + of additional transmit and receive buffers. + + @param This The protocol instance pointer. + @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space + that the driver should allocate for the network interface. + Some network interfaces will not be able to use the extra + buffer, and the caller will not know if it is actually + being used. + @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space + that the driver should allocate for the network interface. + Some network interfaces will not be able to use the extra + buffer, and the caller will not know if it is actually + being used. + + @retval EFI_SUCCESS The network interface was initialized. + @retval EFI_NOT_STARTED The network interface has not been started. + @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit and + receive buffers. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. + @retval EFI_UNSUPPORTED This function is not supported by the network interface. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_INITIALIZE)( + IN EMU_SNP_PROTOCOL *This, + IN UINTN ExtraRxBufferSize OPTIONAL, + IN UINTN ExtraTxBufferSize OPTIONAL + ); + +/** + Resets a network adapter and re-initializes it with the parameters that were + provided in the previous call to Initialize(). + + @param This The protocol instance pointer. + @param ExtendedVerification Indicates that the driver may perform a more + exhaustive verification operation of the device + during reset. + + @retval EFI_SUCCESS The network interface was reset. + @retval EFI_NOT_STARTED The network interface has not been started. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. + @retval EFI_UNSUPPORTED This function is not supported by the network interface. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_RESET)( + IN EMU_SNP_PROTOCOL *This, + IN BOOLEAN ExtendedVerification + ); + +/** + Resets a network adapter and leaves it in a state that is safe for + another driver to initialize. + + @param This Protocol instance pointer. + + @retval EFI_SUCCESS The network interface was shutdown. + @retval EFI_NOT_STARTED The network interface has not been started. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. + @retval EFI_UNSUPPORTED This function is not supported by the network interface. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_SHUTDOWN)( + IN EMU_SNP_PROTOCOL *This + ); + +/** + Manages the multicast receive filters of a network interface. + + @param This The protocol instance pointer. + @param Enable A bit mask of receive filters to enable on the network interface. + @param Disable A bit mask of receive filters to disable on the network interface. + @param ResetMCastFilter Set to TRUE to reset the contents of the multicast receive + filters on the network interface to their default values. + @param McastFilterCnt Number of multicast HW MAC addresses in the new + MCastFilter list. This value must be less than or equal to + the MCastFilterCnt field of EMU_SNP_MODE. This + field is optional if ResetMCastFilter is TRUE. + @param MCastFilter A pointer to a list of new multicast receive filter HW MAC + addresses. This list will replace any existing multicast + HW MAC address list. This field is optional if + ResetMCastFilter is TRUE. + + @retval EFI_SUCCESS The multicast receive filter list was updated. + @retval EFI_NOT_STARTED The network interface has not been started. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. + @retval EFI_UNSUPPORTED This function is not supported by the network interface. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_RECEIVE_FILTERS)( + IN EMU_SNP_PROTOCOL *This, + IN UINT32 Enable, + IN UINT32 Disable, + IN BOOLEAN ResetMCastFilter, + IN UINTN MCastFilterCnt OPTIONAL, + IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL + ); + +/** + Modifies or resets the current station address, if supported. + + @param This The protocol instance pointer. + @param Reset Flag used to reset the station address to the network interfaces + permanent address. + @param New The new station address to be used for the network interface. + + @retval EFI_SUCCESS The network interfaces station address was updated. + @retval EFI_NOT_STARTED The network interface has not been started. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. + @retval EFI_UNSUPPORTED This function is not supported by the network interface. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_STATION_ADDRESS)( + IN EMU_SNP_PROTOCOL *This, + IN BOOLEAN Reset, + IN EFI_MAC_ADDRESS *New OPTIONAL + ); + +/** + Resets or collects the statistics on a network interface. + + @param This Protocol instance pointer. + @param Reset Set to TRUE to reset the statistics for the network interface. + @param StatisticsSize On input the size, in bytes, of StatisticsTable. On + output the size, in bytes, of the resulting table of + statistics. + @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that + contains the statistics. + + @retval EFI_SUCCESS The statistics were collected from the network interface. + @retval EFI_NOT_STARTED The network interface has not been started. + @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer + size needed to hold the statistics is returned in + StatisticsSize. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. + @retval EFI_UNSUPPORTED This function is not supported by the network interface. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_STATISTICS)( + IN EMU_SNP_PROTOCOL *This, + IN BOOLEAN Reset, + IN OUT UINTN *StatisticsSize OPTIONAL, + OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL + ); + +/** + Converts a multicast IP address to a multicast HW MAC address. + + @param This The protocol instance pointer. + @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set + to FALSE if the multicast IP address is IPv4 [RFC 791]. + @param IP The multicast IP address that is to be converted to a multicast + HW MAC address. + @param MAC The multicast HW MAC address that is to be generated from IP. + + @retval EFI_SUCCESS The multicast IP address was mapped to the multicast + HW MAC address. + @retval EFI_NOT_STARTED The network interface has not been started. + @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer + size needed to hold the statistics is returned in + StatisticsSize. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. + @retval EFI_UNSUPPORTED This function is not supported by the network interface. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_MCAST_IP_TO_MAC)( + IN EMU_SNP_PROTOCOL *This, + IN BOOLEAN IPv6, + IN EFI_IP_ADDRESS *IP, + OUT EFI_MAC_ADDRESS *MAC + ); + +/** + Performs read and write operations on the NVRAM device attached to a + network interface. + + @param This The protocol instance pointer. + @param ReadWrite TRUE for read operations, FALSE for write operations. + @param Offset Byte offset in the NVRAM device at which to start the read or + write operation. This must be a multiple of NvRamAccessSize and + less than NvRamSize. + @param BufferSize The number of bytes to read or write from the NVRAM device. + This must also be a multiple of NvramAccessSize. + @param Buffer A pointer to the data buffer. + + @retval EFI_SUCCESS The NVRAM access was performed. + @retval EFI_NOT_STARTED The network interface has not been started. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. + @retval EFI_UNSUPPORTED This function is not supported by the network interface. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_NVDATA)( + IN EMU_SNP_PROTOCOL *This, + IN BOOLEAN ReadWrite, + IN UINTN Offset, + IN UINTN BufferSize, + IN OUT VOID *Buffer + ); + +/** + Reads the current interrupt status and recycled transmit buffer status from + a network interface. + + @param This The protocol instance pointer. + @param InterruptStatus A pointer to the bit mask of the currently active interrupts + If this is NULL, the interrupt status will not be read from + the device. If this is not NULL, the interrupt status will + be read from the device. When the interrupt status is read, + it will also be cleared. Clearing the transmit interrupt + does not empty the recycled transmit buffer array. + @param TxBuf Recycled transmit buffer address. The network interface will + not transmit if its internal recycled transmit buffer array + is full. Reading the transmit buffer does not clear the + transmit interrupt. If this is NULL, then the transmit buffer + status will not be read. If there are no transmit buffers to + recycle and TxBuf is not NULL, * TxBuf will be set to NULL. + + @retval EFI_SUCCESS The status of the network interface was retrieved. + @retval EFI_NOT_STARTED The network interface has not been started. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. + @retval EFI_UNSUPPORTED This function is not supported by the network interface. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_GET_STATUS)( + IN EMU_SNP_PROTOCOL *This, + OUT UINT32 *InterruptStatus OPTIONAL, + OUT VOID **TxBuf OPTIONAL + ); + +/** + Places a packet in the transmit queue of a network interface. + + @param This The protocol instance pointer. + @param HeaderSize The size, in bytes, of the media header to be filled in by + the Transmit() function. If HeaderSize is non-zero, then it + must be equal to This->Mode->MediaHeaderSize and the DestAddr + and Protocol parameters must not be NULL. + @param BufferSize The size, in bytes, of the entire packet (media header and + data) to be transmitted through the network interface. + @param Buffer A pointer to the packet (media header followed by data) to be + transmitted. This parameter cannot be NULL. If HeaderSize is zero, + then the media header in Buffer must already be filled in by the + caller. If HeaderSize is non-zero, then the media header will be + filled in by the Transmit() function. + @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter + is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then + This->Mode->CurrentAddress is used for the source HW MAC address. + @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this + parameter is ignored. + @param Protocol The type of header to build. If HeaderSize is zero, then this + parameter is ignored. See RFC 1700, section "Ether Types", for + examples. + + @retval EFI_SUCCESS The packet was placed on the transmit queue. + @retval EFI_NOT_STARTED The network interface has not been started. + @retval EFI_NOT_READY The network interface is too busy to accept this transmit request. + @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. + @retval EFI_UNSUPPORTED This function is not supported by the network interface. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_TRANSMIT)( + IN EMU_SNP_PROTOCOL *This, + IN UINTN HeaderSize, + IN UINTN BufferSize, + IN VOID *Buffer, + IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL, + IN EFI_MAC_ADDRESS *DestAddr OPTIONAL, + IN UINT16 *Protocol OPTIONAL + ); + +/** + Receives a packet from a network interface. + + @param This The protocol instance pointer. + @param HeaderSize The size, in bytes, of the media header received on the network + interface. If this parameter is NULL, then the media header size + will not be returned. + @param BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in + bytes, of the packet that was received on the network interface. + @param Buffer A pointer to the data buffer to receive both the media header and + the data. + @param SrcAddr The source HW MAC address. If this parameter is NULL, the + HW MAC source address will not be extracted from the media + header. + @param DestAddr The destination HW MAC address. If this parameter is NULL, + the HW MAC destination address will not be extracted from the + media header. + @param Protocol The media header type. If this parameter is NULL, then the + protocol will not be extracted from the media header. See + RFC 1700 section "Ether Types" for examples. + + @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has + been updated to the number of bytes received. + @retval EFI_NOT_STARTED The network interface has not been started. + @retval EFI_NOT_READY The network interface is too busy to accept this transmit + request. + @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small. + @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value. + @retval EFI_DEVICE_ERROR The command could not be sent to the network interface. + @retval EFI_UNSUPPORTED This function is not supported by the network interface. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_SNP_RECEIVE)( + IN EMU_SNP_PROTOCOL *This, + OUT UINTN *HeaderSize OPTIONAL, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer, + OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL, + OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL, + OUT UINT16 *Protocol OPTIONAL + ); + +#define EMU_SNP_PROTOCOL_REVISION 0x00010000 + +// +// Revision defined in EFI1.1 +// +#define EMU_SNP_INTERFACE_REVISION EMU_SNP_PROTOCOL_REVISION + +/// +/// The EMU_SNP_PROTOCOL protocol abstracts OS network sercices +/// from the EFI driver that produces EFI Simple Network Protocol. +/// +struct _EMU_SNP_PROTOCOL { + EMU_SNP_CREATE_MAPPING CreateMapping; + EMU_SNP_START Start; + EMU_SNP_STOP Stop; + EMU_SNP_INITIALIZE Initialize; + EMU_SNP_RESET Reset; + EMU_SNP_SHUTDOWN Shutdown; + EMU_SNP_RECEIVE_FILTERS ReceiveFilters; + EMU_SNP_STATION_ADDRESS StationAddress; + EMU_SNP_STATISTICS Statistics; + EMU_SNP_MCAST_IP_TO_MAC MCastIpToMac; + EMU_SNP_NVDATA NvData; + EMU_SNP_GET_STATUS GetStatus; + EMU_SNP_TRANSMIT Transmit; + EMU_SNP_RECEIVE Receive; +}; + +extern EFI_GUID gEmuSnpProtocolGuid; + +#endif diff --git a/EmulatorPkg/Include/Protocol/EmuThread.h b/EmulatorPkg/Include/Protocol/EmuThread.h new file mode 100644 index 0000000..e518bb1 --- /dev/null +++ b/EmulatorPkg/Include/Protocol/EmuThread.h @@ -0,0 +1,103 @@ +/** @file + Emulator Thunk to abstract OS services from pure EFI code + + Copyright (c) 2010 - 2011, Apple Inc. All rights reserved.
+ Copyright (c) 2011, 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 __EMU_THREAD_THUNK__ +#define __EMU_THREAD_THUNK__ + + +typedef struct _EMU_THREAD_THUNK_PROTOCOL EMU_THREAD_THUNK_PROTOCOL; + + +typedef +UINTN +(EFIAPI *THREAD_THUNK_MUTEX_LOCK) ( + IN VOID *Mutex + ); + + +typedef +UINTN +(EFIAPI *THREAD_THUNK_MUTEX_UNLOCK) ( + IN VOID *Mutex + ); + + +typedef +UINTN +(EFIAPI *THREAD_THUNK_MUTEX_TRY_LOCK) ( + IN VOID *Mutex + ); + + +typedef +VOID * +(EFIAPI *THREAD_THUNK_MUTEX_INIT) ( + IN VOID + ); + + +typedef +UINTN +(EFIAPI *THREAD_THUNK_MUTEX_DISTROY) ( + IN VOID *Mutex + ); + + + +typedef +VOID * +(EFIAPI *THREAD_THUNK_THREAD_ENTRY) ( + IN VOID *Context + ); + +typedef +UINTN +(EFIAPI *THREAD_THUNK_CREATE_THREAD) ( + IN VOID *Thread, + IN VOID *Attribute, + IN THREAD_THUNK_THREAD_ENTRY Start, + IN VOID *Context + ); + +typedef +VOID +(EFIAPI *THREAD_THUNK_EXIT_THREAD) ( + IN VOID *ValuePtr + ); + + +typedef +UINTN +(EFIAPI *THREAD_THUNK_SELF) ( + VOID + ); + + +struct _EMU_THREAD_THUNK_PROTOCOL { + THREAD_THUNK_MUTEX_LOCK MutexLock; + THREAD_THUNK_MUTEX_UNLOCK MutexUnlock; + THREAD_THUNK_MUTEX_TRY_LOCK MutexTryLock; + THREAD_THUNK_MUTEX_INIT MutexInit; + THREAD_THUNK_MUTEX_DISTROY MutexDistroy; + THREAD_THUNK_CREATE_THREAD CreateThread; + THREAD_THUNK_EXIT_THREAD ExitThread; + THREAD_THUNK_SELF Self; +}; + +extern EFI_GUID gEmuThreadThunkProtocolGuid; + +#endif + diff --git a/EmulatorPkg/Include/Protocol/EmuThunk.h b/EmulatorPkg/Include/Protocol/EmuThunk.h new file mode 100644 index 0000000..27921b1 --- /dev/null +++ b/EmulatorPkg/Include/Protocol/EmuThunk.h @@ -0,0 +1,264 @@ +/** @file + Emulator Thunk to abstract OS services from pure EFI code + + Copyright (c) 2008 - 2011, Apple Inc. 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 __EMU_THUNK_PROTOCOL_H__ +#define __EMU_THUNK_PROTOCOL_H__ + +#define EMU_THUNK_PROTOCOL_GUID \ + { 0x5CF32E0B, 0x8EDF, 0x2E44, { 0x9C, 0xDA, 0x93, 0x20, 0x5E, 0x99, 0xEC, 0x1C } } + +// neded for things like EFI_TIME_CAPABILITIES +#include + +#include + +#include +#include + + +typedef struct { + VENDOR_DEVICE_PATH VendorDevicePath; + UINT32 Instance; +} EMU_VENDOR_DEVICE_PATH_NODE; + +typedef struct { + EMU_VENDOR_DEVICE_PATH_NODE Vendor; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} EMU_THUNK_DEVICE_PATH; + + + +typedef struct _EMU_THUNK_PROTOCOL EMU_THUNK_PROTOCOL; + + + +typedef +UINTN +(EFIAPI *EMU_WRITE_STD_ERROR) ( + IN UINT8 *Buffer, + IN UINTN NumberOfBytes + ); + +typedef +EFI_STATUS +(EFIAPI *EMU_CONFIG_STD_IN) ( + VOID + ); + +typedef +UINTN +(EFIAPI *EMU_WRITE_STD_OUT) ( + IN UINT8 *Buffer, + IN UINTN NumberOfBytes + ); + +typedef +UINTN +(EFIAPI *EMU_READ_STD_IN) ( + OUT UINT8 *Buffer, + IN UINTN NumberOfBytes + ); + +typedef +BOOLEAN +(EFIAPI *EMU_POLL_STD_IN) ( + VOID + ); + + +typedef +VOID * +(EFIAPI *EMU_OS_MALLOC) ( + IN UINTN Size + ); + +typedef +VOID * +(EFIAPI *EMU_OS_VMALLOC) ( + IN UINTN Size + ); + +typedef +BOOLEAN +(EFIAPI *EMU_OS_FREE) ( + IN VOID *Ptr + ); + + +typedef +EFI_STATUS +(EFIAPI *EMU_PE_COFF_GET_ENTRY_POINT) ( + IN VOID *Pe32Data, + IN OUT VOID **EntryPoint + ); + +typedef +VOID +(EFIAPI *EMU_PE_COFF_RELOCATE_EXTRA_ACTION) ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ); + +typedef +VOID +(EFIAPI *EMU_PE_COFF_UNLOAD_EXTRA_ACTION) ( + IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ); + +typedef +VOID +(EFIAPI *EMU_ENABLE_INERRUPTS) ( + VOID + ); + +typedef +VOID +(EFIAPI *EMU_DISABLE_INERRUPTS) ( + VOID + ); + +typedef +UINT64 +(EFIAPI *EMU_QUERY_PERFORMANCE_FREQENCY) ( + VOID + ); + +typedef +UINT64 +(EFIAPI *EMU_QUERY_PERFORMANCE_COUNTER) ( + VOID + ); + +typedef +VOID +(EFIAPI *EMU_SLEEP) ( + IN UINT64 Milliseconds + ); + +typedef +VOID +(EFIAPI *EMU_CPU_SLEEP) ( + VOID + ); + +typedef +VOID +(EFIAPI *EMU_EXIT) ( + IN UINTN Status + ); + +typedef +VOID +(EFIAPI *EMU_GET_TIME) ( + OUT EFI_TIME *Time, + OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL + ); + +typedef +VOID +(EFIAPI *EMU_SET_TIME) ( + IN EFI_TIME *Time + ); + + +typedef +VOID +(EFIAPI EMU_SET_TIMER_CALLBACK) ( + IN UINT64 DeltaMs + ); + +typedef +VOID +(EFIAPI *EMU_SET_TIMER) ( + IN UINT64 PeriodMs, + IN EMU_SET_TIMER_CALLBACK CallBack + ); + + + +/** + Enumerates the current set of protocol instances that abstract OS services from EFI. + + A given protocol can have multiple instances. Usually a protocol is configured via a + single PCD string. The data associated for each instance is seperated via a ! in the string. + EMU_IO_THUNK_PROTOCOL_CLOSE.ConfigString will contain the information in the PCD string up to the next !. + Thus each instance has a unique ConfigString. + + @param EmuBusDriver TRUE means only return protocol instances that need to be produced + by the EmuBusDriver. FALSE means return all possible protocols + @param Instance On input the protocol to search for, or NULL to start a search + of all the supported protocol instances. + @param NextProtocol On output it represents the next value to be passed into Protocol. + @param Interface A pointer to the EMU_IO_THUNK_PROTOCOL_CLOSE interface. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_NOT_FOUND The next protocol instance was not found. + @retval EFI_INVALID_PARAMETER Instance is NULL. + +**/ +typedef +EFI_STATUS +(EFIAPI *EMU_GET_NEXT_PROTOCOL) ( + IN BOOLEAN EmuBusDriver, + OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL + ); + + +struct _EMU_THUNK_PROTOCOL { + // Used for early debug printing + EMU_WRITE_STD_ERROR WriteStdErr; + EMU_CONFIG_STD_IN ConfigStdIn; + EMU_WRITE_STD_OUT WriteStdOut; + EMU_READ_STD_IN ReadStdIn; + EMU_POLL_STD_IN PollStdIn; + + // + // Map OS malloc/free so we can use OS based guard malloc + // + EMU_OS_MALLOC Malloc; + EMU_OS_VMALLOC Valloc; + EMU_OS_FREE Free; + + + /// + /// PE/COFF loader hooks to get symbols loaded + /// + EMU_PE_COFF_GET_ENTRY_POINT PeCoffGetEntryPoint; + EMU_PE_COFF_RELOCATE_EXTRA_ACTION PeCoffRelocateImageExtraAction; + EMU_PE_COFF_UNLOAD_EXTRA_ACTION PeCoffUnloadImageExtraAction; + + /// + /// DXE Architecture Protocol Services + /// + EMU_ENABLE_INERRUPTS EnableInterrupt; + EMU_DISABLE_INERRUPTS DisableInterrupt; + EMU_QUERY_PERFORMANCE_FREQENCY QueryPerformanceFrequency; + EMU_QUERY_PERFORMANCE_COUNTER QueryPerformanceCounter; + + EMU_SLEEP Sleep; + EMU_CPU_SLEEP CpuSleep; + EMU_EXIT Exit; + EMU_GET_TIME GetTime; + EMU_SET_TIME SetTime; + EMU_SET_TIMER SetTimer; + + /// + /// Generic System Services + /// + EMU_GET_NEXT_PROTOCOL GetNextProtocol; +}; + +extern EFI_GUID gEmuThunkProtocolGuid; + +#endif -- cgit v1.1