]> git.proxmox.com Git - mirror_edk2.git/commitdiff
InOsEmuPkg: Rename package to EmulatorPkg & Sec to Host
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 28 Jun 2011 16:47:23 +0000 (16:47 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 28 Jun 2011 16:47:23 +0000 (16:47 +0000)
* 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

382 files changed:
EmulatorPkg/AutoScanPei/AutoScanPei.c [new file with mode: 0644]
EmulatorPkg/AutoScanPei/AutoScanPei.inf [new file with mode: 0644]
EmulatorPkg/BootModePei/BootModePei.c [new file with mode: 0644]
EmulatorPkg/BootModePei/BootModePei.inf [new file with mode: 0644]
EmulatorPkg/CpuRuntimeDxe/Cpu.c [new file with mode: 0644]
EmulatorPkg/CpuRuntimeDxe/Cpu.inf [new file with mode: 0644]
EmulatorPkg/CpuRuntimeDxe/CpuDriver.h [new file with mode: 0644]
EmulatorPkg/CpuRuntimeDxe/CpuIo.c [new file with mode: 0644]
EmulatorPkg/CpuRuntimeDxe/MpService.c [new file with mode: 0644]
EmulatorPkg/CpuRuntimeDxe/Strings.uni [new file with mode: 0644]
EmulatorPkg/EmuBlockIoDxe/ComponentName.c [new file with mode: 0644]
EmulatorPkg/EmuBlockIoDxe/DriverConfiguration.c [new file with mode: 0644]
EmulatorPkg/EmuBlockIoDxe/DriverDiagnostics.c [new file with mode: 0644]
EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c [new file with mode: 0644]
EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.h [new file with mode: 0644]
EmulatorPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf [new file with mode: 0644]
EmulatorPkg/EmuBusDriverDxe/ComponentName.c [new file with mode: 0644]
EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.c [new file with mode: 0644]
EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.h [new file with mode: 0644]
EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.inf [new file with mode: 0644]
EmulatorPkg/EmuGopDxe/ComponentName.c [new file with mode: 0644]
EmulatorPkg/EmuGopDxe/EmuGopDxe.inf [new file with mode: 0644]
EmulatorPkg/EmuGopDxe/Gop.h [new file with mode: 0644]
EmulatorPkg/EmuGopDxe/GopDriver.c [new file with mode: 0644]
EmulatorPkg/EmuGopDxe/GopInput.c [new file with mode: 0644]
EmulatorPkg/EmuGopDxe/GopScreen.c [new file with mode: 0644]
EmulatorPkg/EmuSimpleFileSystemDxe/ComponentName.c [new file with mode: 0644]
EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c [new file with mode: 0644]
EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.h [new file with mode: 0644]
EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf [new file with mode: 0644]
EmulatorPkg/EmuSnpDxe/ComponentName.c [new file with mode: 0644]
EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c [new file with mode: 0644]
EmulatorPkg/EmuSnpDxe/EmuSnpDxe.h [new file with mode: 0644]
EmulatorPkg/EmuSnpDxe/EmuSnpDxe.inf [new file with mode: 0644]
EmulatorPkg/EmuThunkDxe/EmuThunk.c [new file with mode: 0644]
EmulatorPkg/EmuThunkDxe/EmuThunk.inf [new file with mode: 0644]
EmulatorPkg/EmulatorPkg.dec [new file with mode: 0644]
EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.c [new file with mode: 0644]
EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.inf [new file with mode: 0644]
EmulatorPkg/FlashMapPei/FlashMapPei.c [new file with mode: 0644]
EmulatorPkg/FlashMapPei/FlashMapPei.inf [new file with mode: 0644]
EmulatorPkg/FvbServicesRuntimeDxe/FWBlockService.c [new file with mode: 0644]
EmulatorPkg/FvbServicesRuntimeDxe/FvbInfo.c [new file with mode: 0644]
EmulatorPkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf [new file with mode: 0644]
EmulatorPkg/FvbServicesRuntimeDxe/FwBlockService.h [new file with mode: 0644]
EmulatorPkg/Include/Guid/EmuPhysicalDisk.h [new file with mode: 0644]
EmulatorPkg/Include/Guid/EmuSystemConfig.h [new file with mode: 0644]
EmulatorPkg/Include/Guid/EmuVirtualDisk.h [new file with mode: 0644]
EmulatorPkg/Include/Library/EmuMagicPageLib.h [new file with mode: 0644]
EmulatorPkg/Include/Library/EmuThunkLib.h [new file with mode: 0644]
EmulatorPkg/Include/Library/KeyMapLib.h [new file with mode: 0644]
EmulatorPkg/Include/Library/PpiListLib.h [new file with mode: 0644]
EmulatorPkg/Include/Library/ThunkPpiList.h [new file with mode: 0644]
EmulatorPkg/Include/Library/ThunkProtocolList.h [new file with mode: 0644]
EmulatorPkg/Include/Ppi/EmuThunk.h [new file with mode: 0644]
EmulatorPkg/Include/Protocol/EmuBlockIo.h [new file with mode: 0644]
EmulatorPkg/Include/Protocol/EmuFileSystem.h [new file with mode: 0644]
EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h [new file with mode: 0644]
EmulatorPkg/Include/Protocol/EmuIoThunk.h [new file with mode: 0644]
EmulatorPkg/Include/Protocol/EmuSnp.h [new file with mode: 0644]
EmulatorPkg/Include/Protocol/EmuThread.h [new file with mode: 0644]
EmulatorPkg/Include/Protocol/EmuThunk.h [new file with mode: 0644]
EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c [new file with mode: 0644]
EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.inf [new file with mode: 0644]
EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c [new file with mode: 0644]
EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.inf [new file with mode: 0644]
EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c [new file with mode: 0644]
EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.inf [new file with mode: 0644]
EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.c [new file with mode: 0644]
EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf [new file with mode: 0644]
EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c [new file with mode: 0644]
EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf [new file with mode: 0644]
EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c [new file with mode: 0644]
EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf [new file with mode: 0644]
EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c [new file with mode: 0644]
EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.inf [new file with mode: 0644]
EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c [new file with mode: 0644]
EmulatorPkg/Library/EmuBdsLib/BdsPlatform.h [new file with mode: 0644]
EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf [new file with mode: 0644]
EmulatorPkg/Library/EmuBdsLib/PlatformData.c [new file with mode: 0644]
EmulatorPkg/Library/GuardUefiMemoryAllocationLib/GuardUefiMemoryAllocationLib.inf [new file with mode: 0644]
EmulatorPkg/Library/GuardUefiMemoryAllocationLib/MemoryAllocationLib.c [new file with mode: 0644]
EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c [new file with mode: 0644]
EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.inf [new file with mode: 0644]
EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiCoreServicesTablePointerLib.inf [new file with mode: 0644]
EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c [new file with mode: 0644]
EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c [new file with mode: 0644]
EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf [new file with mode: 0644]
EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.c [new file with mode: 0644]
EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.inf [new file with mode: 0644]
EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c [new file with mode: 0644]
EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf [new file with mode: 0644]
EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c [new file with mode: 0644]
EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf [new file with mode: 0644]
EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c [new file with mode: 0644]
EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointerLibMagicPage.inf [new file with mode: 0644]
EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c [new file with mode: 0644]
EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.inf [new file with mode: 0644]
EmulatorPkg/Library/SecPeiServicesLib/FwVol.c [new file with mode: 0644]
EmulatorPkg/Library/SecPeiServicesLib/PeiServicesLib.c [new file with mode: 0644]
EmulatorPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf [new file with mode: 0644]
EmulatorPkg/Library/SecPpiListLib/PpiListLib.c [new file with mode: 0644]
EmulatorPkg/Library/SecPpiListLib/SecPpiListLib.inf [new file with mode: 0644]
EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.c [new file with mode: 0644]
EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.inf [new file with mode: 0644]
EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.c [new file with mode: 0644]
EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.inf [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturer.uni [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerData.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendor.uni [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendorData.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscBootInformationData.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscBootInformationFunction.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturer.uni [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerData.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscDevicePath.h [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesData.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesFunction.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscOemString.uni [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscOemStringData.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignator.uni [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorData.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesData.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesFunction.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.h [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.inf [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.uni [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSubclassDriverDataTable.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageString.uni [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringData.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturer.uni [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerData.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionString.uni [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringData.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignation.uni [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationData.c [new file with mode: 0644]
EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c [new file with mode: 0644]
EmulatorPkg/RealTimeClockRuntimeDxe/RealTimeClock.c [new file with mode: 0644]
EmulatorPkg/RealTimeClockRuntimeDxe/RealTimeClock.inf [new file with mode: 0644]
EmulatorPkg/ResetRuntimeDxe/Reset.c [new file with mode: 0644]
EmulatorPkg/ResetRuntimeDxe/Reset.inf [new file with mode: 0644]
EmulatorPkg/Sec/Ia32/SwitchRam.S [new file with mode: 0644]
EmulatorPkg/Sec/Ia32/TempRam.c [new file with mode: 0644]
EmulatorPkg/Sec/Sec.c [new file with mode: 0644]
EmulatorPkg/Sec/Sec.h [new file with mode: 0644]
EmulatorPkg/Sec/Sec.inf [new file with mode: 0644]
EmulatorPkg/Sec/X64/SwitchRam.S [new file with mode: 0644]
EmulatorPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.c [new file with mode: 0644]
EmulatorPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.inf [new file with mode: 0644]
EmulatorPkg/TimerDxe/Timer.c [new file with mode: 0644]
EmulatorPkg/TimerDxe/Timer.h [new file with mode: 0644]
EmulatorPkg/TimerDxe/Timer.inf [new file with mode: 0644]
EmulatorPkg/Unix/.gdbinit [new file with mode: 0644]
EmulatorPkg/Unix/GdbRun [new file with mode: 0644]
EmulatorPkg/Unix/Host/BerkeleyPacketFilter.c [new file with mode: 0644]
EmulatorPkg/Unix/Host/BlockIo.c [new file with mode: 0644]
EmulatorPkg/Unix/Host/EmuThunk.c [new file with mode: 0644]
EmulatorPkg/Unix/Host/Gasket.h [new file with mode: 0644]
EmulatorPkg/Unix/Host/Ia32/Gasket.S [new file with mode: 0644]
EmulatorPkg/Unix/Host/Ia32/SwitchStack.c [new file with mode: 0644]
EmulatorPkg/Unix/Host/LinuxPacketFilter.c [new file with mode: 0644]
EmulatorPkg/Unix/Host/MemoryAllocationLib.c [new file with mode: 0644]
EmulatorPkg/Unix/Host/PosixFileSystem.c [new file with mode: 0644]
EmulatorPkg/Unix/Host/Pthreads.c [new file with mode: 0644]
EmulatorPkg/Unix/Host/SecMain.c [new file with mode: 0644]
EmulatorPkg/Unix/Host/SecMain.h [new file with mode: 0644]
EmulatorPkg/Unix/Host/SecMain.inf [new file with mode: 0644]
EmulatorPkg/Unix/Host/X11GraphicsWindow.c [new file with mode: 0644]
EmulatorPkg/Unix/Host/X64/Gasket.S [new file with mode: 0644]
EmulatorPkg/Unix/Host/X64/SwitchStack.S [new file with mode: 0644]
EmulatorPkg/Unix/UnixX64.dsc [new file with mode: 0644]
EmulatorPkg/Unix/UnixX64.fdf [new file with mode: 0644]
EmulatorPkg/Unix/Xcode/xcode_project32/XcodeBuild.sh [new file with mode: 0755]
EmulatorPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/default.pbxuser [new file with mode: 0644]
EmulatorPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/project.pbxproj [new file with mode: 0644]
EmulatorPkg/Unix/Xcode/xcode_project64/XcodeBuild.sh [new file with mode: 0755]
EmulatorPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/default.pbxuser [new file with mode: 0644]
EmulatorPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/project.pbxproj [new file with mode: 0644]
EmulatorPkg/Unix/build.sh [new file with mode: 0755]
EmulatorPkg/Unix/build64.sh [new file with mode: 0755]
EmulatorPkg/build.sh [new file with mode: 0755]
EmulatorPkg/build64.sh [new file with mode: 0755]
InOsEmuPkg/AutoScanPei/AutoScanPei.c [deleted file]
InOsEmuPkg/AutoScanPei/AutoScanPei.inf [deleted file]
InOsEmuPkg/BootModePei/BootModePei.c [deleted file]
InOsEmuPkg/BootModePei/BootModePei.inf [deleted file]
InOsEmuPkg/CpuRuntimeDxe/Cpu.c [deleted file]
InOsEmuPkg/CpuRuntimeDxe/Cpu.inf [deleted file]
InOsEmuPkg/CpuRuntimeDxe/CpuDriver.h [deleted file]
InOsEmuPkg/CpuRuntimeDxe/CpuIo.c [deleted file]
InOsEmuPkg/CpuRuntimeDxe/MpService.c [deleted file]
InOsEmuPkg/CpuRuntimeDxe/Strings.uni [deleted file]
InOsEmuPkg/EmuBlockIoDxe/ComponentName.c [deleted file]
InOsEmuPkg/EmuBlockIoDxe/DriverConfiguration.c [deleted file]
InOsEmuPkg/EmuBlockIoDxe/DriverDiagnostics.c [deleted file]
InOsEmuPkg/EmuBlockIoDxe/EmuBlockIo.c [deleted file]
InOsEmuPkg/EmuBlockIoDxe/EmuBlockIo.h [deleted file]
InOsEmuPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf [deleted file]
InOsEmuPkg/EmuBusDriverDxe/ComponentName.c [deleted file]
InOsEmuPkg/EmuBusDriverDxe/EmuBusDriverDxe.c [deleted file]
InOsEmuPkg/EmuBusDriverDxe/EmuBusDriverDxe.h [deleted file]
InOsEmuPkg/EmuBusDriverDxe/EmuBusDriverDxe.inf [deleted file]
InOsEmuPkg/EmuGopDxe/ComponentName.c [deleted file]
InOsEmuPkg/EmuGopDxe/EmuGopDxe.inf [deleted file]
InOsEmuPkg/EmuGopDxe/Gop.h [deleted file]
InOsEmuPkg/EmuGopDxe/GopDriver.c [deleted file]
InOsEmuPkg/EmuGopDxe/GopInput.c [deleted file]
InOsEmuPkg/EmuGopDxe/GopScreen.c [deleted file]
InOsEmuPkg/EmuSimpleFileSystemDxe/ComponentName.c [deleted file]
InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c [deleted file]
InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.h [deleted file]
InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf [deleted file]
InOsEmuPkg/EmuSnpDxe/ComponentName.c [deleted file]
InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.c [deleted file]
InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.h [deleted file]
InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf [deleted file]
InOsEmuPkg/EmuThunkDxe/EmuThunk.c [deleted file]
InOsEmuPkg/EmuThunkDxe/EmuThunk.inf [deleted file]
InOsEmuPkg/FirmwareVolumePei/FirmwareVolumePei.c [deleted file]
InOsEmuPkg/FirmwareVolumePei/FirmwareVolumePei.inf [deleted file]
InOsEmuPkg/FlashMapPei/FlashMapPei.c [deleted file]
InOsEmuPkg/FlashMapPei/FlashMapPei.inf [deleted file]
InOsEmuPkg/FvbServicesRuntimeDxe/FWBlockService.c [deleted file]
InOsEmuPkg/FvbServicesRuntimeDxe/FvbInfo.c [deleted file]
InOsEmuPkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf [deleted file]
InOsEmuPkg/FvbServicesRuntimeDxe/FwBlockService.h [deleted file]
InOsEmuPkg/InOsEmuPkg.dec [deleted file]
InOsEmuPkg/Include/Guid/EmuPhysicalDisk.h [deleted file]
InOsEmuPkg/Include/Guid/EmuSystemConfig.h [deleted file]
InOsEmuPkg/Include/Guid/EmuVirtualDisk.h [deleted file]
InOsEmuPkg/Include/Library/EmuMagicPageLib.h [deleted file]
InOsEmuPkg/Include/Library/EmuThunkLib.h [deleted file]
InOsEmuPkg/Include/Library/KeyMapLib.h [deleted file]
InOsEmuPkg/Include/Library/PpiListLib.h [deleted file]
InOsEmuPkg/Include/Library/ThunkPpiList.h [deleted file]
InOsEmuPkg/Include/Library/ThunkProtocolList.h [deleted file]
InOsEmuPkg/Include/Ppi/EmuThunk.h [deleted file]
InOsEmuPkg/Include/Protocol/EmuBlockIo.h [deleted file]
InOsEmuPkg/Include/Protocol/EmuFileSystem.h [deleted file]
InOsEmuPkg/Include/Protocol/EmuGraphicsWindow.h [deleted file]
InOsEmuPkg/Include/Protocol/EmuIoThunk.h [deleted file]
InOsEmuPkg/Include/Protocol/EmuSnp.h [deleted file]
InOsEmuPkg/Include/Protocol/EmuThread.h [deleted file]
InOsEmuPkg/Include/Protocol/EmuThunk.h [deleted file]
InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c [deleted file]
InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf [deleted file]
InOsEmuPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c [deleted file]
InOsEmuPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.inf [deleted file]
InOsEmuPkg/Library/DxeEmuLib/DxeEmuLib.c [deleted file]
InOsEmuPkg/Library/DxeEmuLib/DxeEmuLib.inf [deleted file]
InOsEmuPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.c [deleted file]
InOsEmuPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf [deleted file]
InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c [deleted file]
InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf [deleted file]
InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c [deleted file]
InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf [deleted file]
InOsEmuPkg/Library/DxeTimerLib/DxeTimerLib.c [deleted file]
InOsEmuPkg/Library/DxeTimerLib/DxeTimerLib.inf [deleted file]
InOsEmuPkg/Library/EmuBdsLib/BdsPlatform.c [deleted file]
InOsEmuPkg/Library/EmuBdsLib/BdsPlatform.h [deleted file]
InOsEmuPkg/Library/EmuBdsLib/EmuBdsLib.inf [deleted file]
InOsEmuPkg/Library/EmuBdsLib/PlatformData.c [deleted file]
InOsEmuPkg/Library/GuardUefiMemoryAllocationLib/GuardUefiMemoryAllocationLib.inf [deleted file]
InOsEmuPkg/Library/GuardUefiMemoryAllocationLib/MemoryAllocationLib.c [deleted file]
InOsEmuPkg/Library/KeyMapLibNull/KeyMapLibNull.c [deleted file]
InOsEmuPkg/Library/KeyMapLibNull/KeyMapLibNull.inf [deleted file]
InOsEmuPkg/Library/PeiCoreServicesTablePointerLib/PeiCoreServicesTablePointerLib.inf [deleted file]
InOsEmuPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c [deleted file]
InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c [deleted file]
InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf [deleted file]
InOsEmuPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.c [deleted file]
InOsEmuPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.inf [deleted file]
InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c [deleted file]
InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf [deleted file]
InOsEmuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c [deleted file]
InOsEmuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf [deleted file]
InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c [deleted file]
InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointerLibMagicPage.inf [deleted file]
InOsEmuPkg/Library/PeiTimerLib/PeiTimerLib.c [deleted file]
InOsEmuPkg/Library/PeiTimerLib/PeiTimerLib.inf [deleted file]
InOsEmuPkg/Library/SecPeiServicesLib/FwVol.c [deleted file]
InOsEmuPkg/Library/SecPeiServicesLib/PeiServicesLib.c [deleted file]
InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf [deleted file]
InOsEmuPkg/Library/SecPpiListLib/PpiListLib.c [deleted file]
InOsEmuPkg/Library/SecPpiListLib/SecPpiListLib.inf [deleted file]
InOsEmuPkg/Library/ThunkPpiList/ThunkPpiList.c [deleted file]
InOsEmuPkg/Library/ThunkPpiList/ThunkPpiList.inf [deleted file]
InOsEmuPkg/Library/ThunkProtocolList/ThunkProtocolList.c [deleted file]
InOsEmuPkg/Library/ThunkProtocolList/ThunkProtocolList.inf [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturer.uni [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerData.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscBiosVendor.uni [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscBiosVendorData.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscBootInformationData.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscBootInformationFunction.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscChassisManufacturer.uni [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerData.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscDevicePath.h [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesData.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesFunction.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscOemString.uni [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscOemStringData.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignator.uni [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorData.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesData.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesFunction.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.h [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.inf [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.uni [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubclassDriverDataTable.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemLanguageString.uni [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringData.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemManufacturer.uni [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerData.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemOptionString.uni [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringData.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignation.uni [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationData.c [deleted file]
InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c [deleted file]
InOsEmuPkg/RealTimeClockRuntimeDxe/RealTimeClock.c [deleted file]
InOsEmuPkg/RealTimeClockRuntimeDxe/RealTimeClock.inf [deleted file]
InOsEmuPkg/ResetRuntimeDxe/Reset.c [deleted file]
InOsEmuPkg/ResetRuntimeDxe/Reset.inf [deleted file]
InOsEmuPkg/Sec/Ia32/SwitchRam.S [deleted file]
InOsEmuPkg/Sec/Ia32/TempRam.c [deleted file]
InOsEmuPkg/Sec/Sec.c [deleted file]
InOsEmuPkg/Sec/Sec.h [deleted file]
InOsEmuPkg/Sec/Sec.inf [deleted file]
InOsEmuPkg/Sec/X64/SwitchRam.S [deleted file]
InOsEmuPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.c [deleted file]
InOsEmuPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.inf [deleted file]
InOsEmuPkg/TimerDxe/Timer.c [deleted file]
InOsEmuPkg/TimerDxe/Timer.h [deleted file]
InOsEmuPkg/TimerDxe/Timer.inf [deleted file]
InOsEmuPkg/Unix/.gdbinit [deleted file]
InOsEmuPkg/Unix/GdbRun [deleted file]
InOsEmuPkg/Unix/Sec/BerkeleyPacketFilter.c [deleted file]
InOsEmuPkg/Unix/Sec/BlockIo.c [deleted file]
InOsEmuPkg/Unix/Sec/EmuThunk.c [deleted file]
InOsEmuPkg/Unix/Sec/Gasket.h [deleted file]
InOsEmuPkg/Unix/Sec/Ia32/Gasket.S [deleted file]
InOsEmuPkg/Unix/Sec/Ia32/SwitchStack.c [deleted file]
InOsEmuPkg/Unix/Sec/LinuxPacketFilter.c [deleted file]
InOsEmuPkg/Unix/Sec/MemoryAllocationLib.c [deleted file]
InOsEmuPkg/Unix/Sec/PosixFileSystem.c [deleted file]
InOsEmuPkg/Unix/Sec/Pthreads.c [deleted file]
InOsEmuPkg/Unix/Sec/SecMain.c [deleted file]
InOsEmuPkg/Unix/Sec/SecMain.h [deleted file]
InOsEmuPkg/Unix/Sec/SecMain.inf [deleted file]
InOsEmuPkg/Unix/Sec/X11GraphicsWindow.c [deleted file]
InOsEmuPkg/Unix/Sec/X64/Gasket.S [deleted file]
InOsEmuPkg/Unix/Sec/X64/SwitchStack.S [deleted file]
InOsEmuPkg/Unix/UnixX64.dsc [deleted file]
InOsEmuPkg/Unix/UnixX64.fdf [deleted file]
InOsEmuPkg/Unix/Xcode/xcode_project32/XcodeBuild.sh [deleted file]
InOsEmuPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/default.pbxuser [deleted file]
InOsEmuPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/project.pbxproj [deleted file]
InOsEmuPkg/Unix/Xcode/xcode_project64/XcodeBuild.sh [deleted file]
InOsEmuPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/default.pbxuser [deleted file]
InOsEmuPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/project.pbxproj [deleted file]
InOsEmuPkg/Unix/build.sh [deleted file]
InOsEmuPkg/Unix/build64.sh [deleted file]
InOsEmuPkg/build.sh [deleted file]
InOsEmuPkg/build64.sh [deleted file]

diff --git a/EmulatorPkg/AutoScanPei/AutoScanPei.c b/EmulatorPkg/AutoScanPei/AutoScanPei.c
new file mode 100644 (file)
index 0000000..78cdd34
--- /dev/null
@@ -0,0 +1,109 @@
+/*++ @file\r
+\r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#include "PiPei.h"\r
+#include <Ppi/EmuThunk.h>\r
+#include <Ppi/MemoryDiscovered.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializeAutoScanPei (\r
+  IN       EFI_PEI_FILE_HANDLE       FileHandle,\r
+  IN CONST EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a call-back into the SEC simulator to get a memory value\r
+\r
+Arguments:\r
+  FfsHeader   - General purpose data available to every PEIM\r
+  PeiServices - General purpose services available to every PEIM.\r
+    \r
+Returns:\r
+  None\r
+\r
+**/\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_PEI_PPI_DESCRIPTOR      *PpiDescriptor;\r
+  EMU_THUNK_PPI               *Thunk;\r
+  UINT64                      MemorySize;\r
+  EFI_PHYSICAL_ADDRESS        MemoryBase;\r
+  UINTN                       Index;\r
+  EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;\r
+\r
+\r
+  DEBUG ((EFI_D_ERROR, "Emu Autoscan PEIM Loaded\n"));\r
+\r
+  //\r
+  // Get the PEI UNIX Autoscan PPI\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+             &gEmuThunkPpiGuid,      // GUID\r
+             0,                      // INSTANCE\r
+             &PpiDescriptor,         // EFI_PEI_PPI_DESCRIPTOR\r
+             (VOID **)&Thunk         // PPI\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Index = 0;\r
+  do {\r
+    Status = Thunk->MemoryAutoScan (Index, &MemoryBase, &MemorySize);\r
+    if (!EFI_ERROR (Status)) {\r
+      Attributes =\r
+        (\r
+          EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
+          EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
+          EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
+          EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r
+          EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
+          EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE\r
+        );\r
+\r
+      if (Index == 0) {\r
+        //\r
+        // Register the memory with the PEI Core\r
+        //\r
+        Status = PeiServicesInstallPeiMemory (MemoryBase, MemorySize);\r
+        ASSERT_EFI_ERROR (Status);\r
+\r
+        Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED;\r
+      }\r
+      \r
+      BuildResourceDescriptorHob (\r
+        EFI_RESOURCE_SYSTEM_MEMORY,\r
+        Attributes,\r
+        MemoryBase,\r
+        MemorySize\r
+        );\r
+    }\r
+    Index++;\r
+  } while (!EFI_ERROR (Status));\r
+\r
+  //\r
+  // Build the CPU hob with 36-bit addressing and 16-bits of IO space.\r
+  //\r
+  BuildCpuHob (36, 16);\r
+  \r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/AutoScanPei/AutoScanPei.inf b/EmulatorPkg/AutoScanPei/AutoScanPei.inf
new file mode 100644 (file)
index 0000000..9fd4a7d
--- /dev/null
@@ -0,0 +1,58 @@
+## @file\r
+# Component description file for EmuAutoScan module\r
+#\r
+# This module abstracts memory auto-scan in a Emu environment.\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = AutoScanPei\r
+  FILE_GUID                      = 2D6F6BCC-9681-8E42-8579-B57DCD0060F0\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = PeimInitializeAutoScanPei\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  AutoScanPei.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+#  MdeModulePkg/MdeModulePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  PeiServicesTablePointerLib\r
+  PeiServicesLib\r
+  HobLib\r
+  BaseMemoryLib\r
+  BaseLib\r
+  PeimEntryPoint\r
+  DebugLib\r
+\r
+\r
+[Ppis]\r
+  gEfiPeiMemoryDiscoveredPpiGuid                # PPI ALWAYS_PRODUCED\r
+  gEmuThunkPpiGuid                              # PPI ALWAYS_CONSUMED\r
+\r
+\r
+[Depex]\r
+  gEmuThunkPpiGuid AND gEfiPeiMasterBootModePpiGuid\r
+\r
diff --git a/EmulatorPkg/BootModePei/BootModePei.c b/EmulatorPkg/BootModePei/BootModePei.c
new file mode 100644 (file)
index 0000000..e26e929
--- /dev/null
@@ -0,0 +1,94 @@
+/** @file\r
+\r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+\r
+#include <Library/PcdLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+\r
+\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Ppi/MasterBootMode.h>\r
+#include <Ppi/BootInRecoveryMode.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+\r
+\r
+//\r
+// Module globals\r
+//\r
+EFI_PEI_PPI_DESCRIPTOR  mPpiListBootMode = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiPeiMasterBootModePpiGuid,\r
+  NULL\r
+};\r
+\r
+EFI_PEI_PPI_DESCRIPTOR  mPpiListRecoveryBootMode = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiPeiBootInRecoveryModePpiGuid,\r
+  NULL\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeBootMode (\r
+  IN       EFI_PEI_FILE_HANDLE       FileHandle,\r
+  IN CONST EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Peform the boot mode determination logic\r
+\r
+Arguments:\r
+\r
+  PeiServices - General purpose services available to every PEIM.\r
+    \r
+Returns:\r
+\r
+  Status -  EFI_SUCCESS if the boot mode could be set\r
+\r
+**/\r
+{\r
+  EFI_STATUS    Status;\r
+  EFI_BOOT_MODE BootMode;\r
+\r
+  DEBUG ((EFI_D_ERROR, "Emu Boot Mode PEIM Loaded\n"));\r
+\r
+  BootMode  = FixedPcdGet32 (PcdEmuBootMode);\r
+\r
+  Status    = PeiServicesSetBootMode (BootMode);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = PeiServicesInstallPpi (&mPpiListBootMode);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  if (BootMode == BOOT_IN_RECOVERY_MODE) {\r
+    Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/BootModePei/BootModePei.inf b/EmulatorPkg/BootModePei/BootModePei.inf
new file mode 100644 (file)
index 0000000..34172bb
--- /dev/null
@@ -0,0 +1,59 @@
+## @file\r
+# Component description file for BootMode module\r
+#\r
+# This module provides platform specific function to detect boot mode.\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = BootModePei\r
+  FILE_GUID                      = 64196C76-58E3-0B4D-9484-B54F7C4349CA\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = InitializeBootMode\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  BootModePei.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+  PeiServicesTablePointerLib\r
+  PeiServicesLib\r
+  BaseLib\r
+  PeimEntryPoint\r
+  DebugLib\r
+\r
+\r
+[Ppis]\r
+  gEfiPeiMasterBootModePpiGuid                  # PPI ALWAYS_PRODUCED\r
+  gEfiPeiBootInRecoveryModePpiGuid              # PPI SOMETIMES_PRODUCED\r
+\r
+[FixedPcd]\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuBootMode\r
+\r
+[Depex]\r
+  TRUE\r
+\r
diff --git a/EmulatorPkg/CpuRuntimeDxe/Cpu.c b/EmulatorPkg/CpuRuntimeDxe/Cpu.c
new file mode 100644 (file)
index 0000000..5ec315b
--- /dev/null
@@ -0,0 +1,374 @@
+/*++ @file\r
+  Emu driver to produce CPU Architectural Protocol.\r
+  \r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "CpuDriver.h"\r
+\r
+UINT64  mTimerPeriod;\r
+\r
+CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {\r
+  CPU_ARCH_PROT_PRIVATE_SIGNATURE,\r
+  NULL,\r
+  {\r
+    EmuFlushCpuDataCache,\r
+    EmuEnableInterrupt,\r
+    EmuDisableInterrupt,\r
+    EmuGetInterruptState,\r
+    EmuInit,\r
+    EmuRegisterInterruptHandler,\r
+    EmuGetTimerValue,\r
+    EmuSetMemoryAttributes,\r
+    0,\r
+    4\r
+  },\r
+  {\r
+    {\r
+      CpuMemoryServiceRead,\r
+      CpuMemoryServiceWrite\r
+    },\r
+    {\r
+      CpuIoServiceRead,\r
+      CpuIoServiceWrite\r
+    }\r
+  },\r
+  TRUE\r
+};\r
+\r
+#define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100\r
+\r
+\r
+\r
+//\r
+// Service routines for the driver\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+EmuFlushCpuDataCache (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
+  IN EFI_PHYSICAL_ADDRESS   Start,\r
+  IN UINT64                 Length,\r
+  IN EFI_CPU_FLUSH_TYPE     FlushType\r
+  )\r
+{\r
+  if (FlushType == EfiCpuFlushTypeWriteBackInvalidate) {\r
+    //\r
+    // Only WB flush is supported. We actually need do nothing on Emu emulator\r
+    // environment. Classify this to follow EFI spec\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+  //\r
+  // Other flush types are not supported by Emu emulator\r
+  //\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuEnableInterrupt (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This\r
+  )\r
+{\r
+  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
+\r
+  Private                 = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
+  Private->InterruptState = TRUE;\r
+  gEmuThunk->EnableInterrupt ();\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuDisableInterrupt (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This\r
+  )\r
+{\r
+  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
+\r
+  Private                 = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
+  Private->InterruptState = FALSE;\r
+  gEmuThunk->DisableInterrupt ();\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuGetInterruptState (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
+  OUT BOOLEAN               *State\r
+  )\r
+{\r
+  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
+\r
+  if (State == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
+  *State  = Private->InterruptState;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuInit (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
+  IN EFI_CPU_INIT_TYPE      InitType\r
+  )\r
+{\r
+  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
+\r
+  Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuRegisterInterruptHandler (\r
+  IN EFI_CPU_ARCH_PROTOCOL      *This,\r
+  IN EFI_EXCEPTION_TYPE         InterruptType,\r
+  IN EFI_CPU_INTERRUPT_HANDLER  InterruptHandler\r
+  )\r
+{\r
+  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
+\r
+  //\r
+  // Do parameter checking for EFI spec conformance\r
+  //\r
+  if (InterruptType < 0 || InterruptType > 0xff) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Do nothing for Emu emulation\r
+  //\r
+  Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuGetTimerValue (\r
+  IN  EFI_CPU_ARCH_PROTOCOL *This,\r
+  IN  UINT32                TimerIndex,\r
+  OUT UINT64                *TimerValue,\r
+  OUT UINT64                *TimerPeriod OPTIONAL\r
+  )\r
+{\r
+  if (TimerValue == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (TimerIndex != 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  *TimerValue = gEmuThunk->QueryPerformanceCounter ();\r
+  \r
+  if (TimerPeriod != NULL) {\r
+    *TimerPeriod = mTimerPeriod;\r
+  } \r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSetMemoryAttributes (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
+  IN EFI_PHYSICAL_ADDRESS   BaseAddress,\r
+  IN UINT64                 Length,\r
+  IN UINT64                 Attributes\r
+  )\r
+{\r
+  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
+\r
+  //\r
+  // Check for invalid parameter for Spec conformance\r
+  //\r
+  if (Length == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Do nothing for Nt32 emulation\r
+  //\r
+  Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Logs SMBIOS record.\r
+\r
+  @param  Smbios   Pointer to SMBIOS protocol instance.\r
+  @param  Buffer   Pointer to the data buffer.\r
+\r
+**/\r
+VOID\r
+LogSmbiosData (\r
+  IN  EFI_SMBIOS_PROTOCOL        *Smbios,\r
+  IN  UINT8                      *Buffer\r
+  )\r
+{\r
+  EFI_STATUS         Status;\r
+  EFI_SMBIOS_HANDLE  SmbiosHandle;\r
+  \r
+  SmbiosHandle = 0;\r
+  Status = Smbios->Add (\r
+                     Smbios,\r
+                     NULL,\r
+                     &SmbiosHandle,\r
+                     (EFI_SMBIOS_TABLE_HEADER*)Buffer\r
+                     );\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+VOID\r
+CpuUpdateSmbios (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  UINT32                      TotalSize;\r
+  EFI_SMBIOS_PROTOCOL         *Smbios;\r
+  EFI_HII_HANDLE              HiiHandle;\r
+  STRING_REF                  Token;\r
+  UINTN                       CpuVerStrLen;\r
+  EFI_STRING                  CpuVerStr;\r
+  SMBIOS_TABLE_TYPE4          *SmbiosRecord;\r
+  CHAR8                       *OptionalStrStart;\r
+\r
+  //\r
+  // Locate Smbios protocol.\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);\r
+  \r
+  if (EFI_ERROR (Status)) {\r
+    return;\r
+  }\r
+\r
+  //\r
+  // Initialize strings to HII database\r
+  //\r
+  HiiHandle = HiiAddPackages (\r
+                &gEfiCallerIdGuid,\r
+                NULL,\r
+                CpuStrings,\r
+                NULL\r
+                );\r
+  ASSERT (HiiHandle != NULL);\r
+\r
+  Token  = STRING_TOKEN (STR_PROCESSOR_VERSION);\r
+  CpuVerStr = HiiGetPackageString(&gEfiCallerIdGuid, Token, NULL);\r
+  CpuVerStrLen = StrLen(CpuVerStr);\r
+  ASSERT (CpuVerStrLen <= SMBIOS_STRING_MAX_LENGTH);\r
+\r
+  TotalSize = sizeof(SMBIOS_TABLE_TYPE4) + CpuVerStrLen + 1 + 1;\r
+  SmbiosRecord = AllocatePool(TotalSize);\r
+  ZeroMem(SmbiosRecord, TotalSize);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE4);\r
+  //\r
+  // Make handle chosen by smbios protocol.add automatically.\r
+  //\r
+  SmbiosRecord->Hdr.Handle = 0;  \r
+  //\r
+  // Processor version is the 1st string.\r
+  //\r
+  SmbiosRecord->ProcessorVersion = 1;\r
+  //\r
+  // Store CPU frequency data record to data hub - It's an emulator so make up a value\r
+  //\r
+  SmbiosRecord->CurrentSpeed  = 1234;\r
+\r
+  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
+  UnicodeStrToAsciiStr(CpuVerStr, OptionalStrStart);\r
+\r
+  //\r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  LogSmbiosData(Smbios, (UINT8 *) SmbiosRecord);\r
+  FreePool (SmbiosRecord);\r
+}\r
+\r
+\r
+\r
+/**\r
+  Callback function for idle events.\r
\r
+  @param  Event                 Event whose notification function is being invoked.\r
+  @param  Context               The pointer to the notification function's context,\r
+                                which is implementation-dependent.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+IdleLoopEventCallback (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  )\r
+{\r
+  gEmuThunk->CpuSleep ();\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeCpu (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+  UINT64        Frequency;\r
+  EFI_EVENT     IdleLoopEvent;\r
+\r
+  //\r
+  // Retrieve the frequency of the performance counter in Hz.\r
+  //  \r
+  Frequency = gEmuThunk->QueryPerformanceFrequency ();\r
+  \r
+  //\r
+  // Convert frequency in Hz to a clock period in femtoseconds.\r
+  //\r
+  mTimerPeriod = DivU64x64Remainder (1000000000000000ULL, Frequency, NULL);\r
+\r
+  CpuUpdateSmbios ();\r
+  \r
+  CpuMpServicesInit ();\r
+  \r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
+                  IdleLoopEventCallback,\r
+                  NULL,\r
+                  &gIdleLoopEventGuid,\r
+                  &IdleLoopEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &mCpuTemplate.Handle,\r
+                  &gEfiCpuArchProtocolGuid,   &mCpuTemplate.Cpu,\r
+                  &gEfiCpuIo2ProtocolGuid,    &mCpuTemplate.CpuIo,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/CpuRuntimeDxe/Cpu.inf b/EmulatorPkg/CpuRuntimeDxe/Cpu.inf
new file mode 100644 (file)
index 0000000..ed8237f
--- /dev/null
@@ -0,0 +1,76 @@
+## @file\r
+# Component description file for Cpu module.\r
+#\r
+# This CPU module abstracts the interrupt subsystem of a platform and the CPU-specific setjump-long pair.\r
+#\r
+# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = Cpu\r
+  FILE_GUID                      = f3794b60-8985-11db-8e53-0040d02b1835\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = InitializeCpu\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  CpuIo.c\r
+  Cpu.c\r
+  CpuDriver.h\r
+  Strings.uni\r
+  MpService.c\r
+  \r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  BaseMemoryLib\r
+  UefiDriverEntryPoint\r
+  UefiLib\r
+  HiiLib\r
+  DebugLib\r
+  BaseLib\r
+  EmuThunkLib\r
+  PcdLib\r
+\r
+[Protocols]\r
+  gEmuIoThunkProtocolGuid                       # PROTOCOL_NOTIFY SOMETIMES_CONSUMED\r
+  gEfiSmbiosProtocolGuid                        # PROTOCOL SOMETIMES_CONSUMED\r
+  gEfiHiiProtocolGuid                           # PROTOCOL SOMETIMES_CONSUMED\r
+  gEfiCpuIo2ProtocolGuid                        # PROTOCOL ALWAYS_PRODUCED\r
+  gEfiCpuArchProtocolGuid                       # PROTOCOL ALWAYS_PRODUCED\r
+  gEmuThreadThunkProtocolGuid\r
+  gEfiMpServiceProtocolGuid\r
+\r
+[Guids]\r
+  gIdleLoopEventGuid                            ## CONSUMES ## GUID\r
+\r
+[Pcd]\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuMpServicesPollingInterval\r
+\r
+[Depex]\r
+  gEfiSmbiosProtocolGuid\r
diff --git a/EmulatorPkg/CpuRuntimeDxe/CpuDriver.h b/EmulatorPkg/CpuRuntimeDxe/CpuDriver.h
new file mode 100644 (file)
index 0000000..69505ff
--- /dev/null
@@ -0,0 +1,246 @@
+/*++ @file\r
+\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#ifndef _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_\r
+#define _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_\r
+\r
+\r
+#include <FrameworkDxe.h>\r
+#include <IndustryStandard/SmBios.h>\r
+\r
+#include <Protocol/Cpu.h>\r
+#include <Protocol/Smbios.h>\r
+#include <Protocol/FrameworkHii.h>\r
+#include <Protocol/MpService.h>\r
+#include <Protocol/EmuThread.h>\r
+#include <Protocol/CpuIo2.h>\r
+\r
+#include <Guid/DataHubRecords.h>\r
+#include <Guid/IdleLoopEvent.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/EmuThunkLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+\r
+extern UINT8  CpuStrings[];\r
+\r
+//\r
+// Internal Data Structures\r
+//\r
+#define CPU_ARCH_PROT_PRIVATE_SIGNATURE SIGNATURE_32 ('c', 'a', 'p', 'd')\r
+\r
+typedef struct {\r
+  UINTN                 Signature;\r
+  EFI_HANDLE            Handle;\r
+\r
+  EFI_CPU_ARCH_PROTOCOL Cpu;\r
+  EFI_CPU_IO2_PROTOCOL  CpuIo;\r
+\r
+  //\r
+  // Local Data for CPU interface goes here\r
+  //\r
+  BOOLEAN               InterruptState;\r
+\r
+} CPU_ARCH_PROTOCOL_PRIVATE;\r
+\r
+#define CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \\r
+  CR (a, \\r
+      CPU_ARCH_PROTOCOL_PRIVATE, \\r
+      Cpu, \\r
+      CPU_ARCH_PROT_PRIVATE_SIGNATURE \\r
+      )\r
+\r
+\r
+\r
+typedef enum {\r
+  CPU_STATE_IDLE,\r
+  CPU_STATE_BLOCKED,\r
+  CPU_STATE_READY,\r
+  CPU_STATE_BUSY,\r
+  CPU_STATE_FINISHED\r
+} PROCESSOR_STATE;\r
+\r
+\r
+//\r
+// Define Individual Processor Data block.\r
+//\r
+typedef struct {\r
+  EFI_PROCESSOR_INFORMATION   Info;\r
+  EFI_AP_PROCEDURE            Procedure;\r
+  VOID                        *Parameter;\r
+  VOID                        *StateLock;\r
+  VOID                        *ProcedureLock;\r
+  PROCESSOR_STATE             State;\r
+  EFI_EVENT                   CheckThisAPEvent;   \r
+} PROCESSOR_DATA_BLOCK;\r
+\r
+\r
+//\r
+// Define MP data block which consumes individual processor block.\r
+//\r
+typedef struct {\r
+  UINTN                       NumberOfProcessors;\r
+  UINTN                       NumberOfEnabledProcessors;\r
+  EFI_EVENT                   CheckAllAPsEvent;\r
+  EFI_EVENT                   WaitEvent;\r
+  UINTN                       FinishCount;\r
+  UINTN                       StartCount;\r
+  EFI_AP_PROCEDURE            Procedure;\r
+  VOID                        *ProcedureArgument;\r
+  BOOLEAN                     SingleThread;\r
+  UINTN                       StartedNumber;\r
+  PROCESSOR_DATA_BLOCK        *ProcessorData;\r
+  UINTN                       Timeout;\r
+  UINTN                       *FailedList;\r
+  UINTN                       FailedListIndex;\r
+  BOOLEAN                     TimeoutActive;\r
+} MP_SYSTEM_DATA;\r
+\r
+\r
+\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceRead (\r
+  IN  EFI_CPU_IO2_PROTOCOL              *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceWrite (\r
+  IN EFI_CPU_IO2_PROTOCOL               *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceRead (\r
+  IN EFI_CPU_IO2_PROTOCOL               *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            UserAddress,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *UserBuffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceWrite (\r
+  IN EFI_CPU_IO2_PROTOCOL               *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            UserAddress,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *UserBuffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeCpu (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuFlushCpuDataCache (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
+  IN EFI_PHYSICAL_ADDRESS   Start,\r
+  IN UINT64                 Length,\r
+  IN EFI_CPU_FLUSH_TYPE     FlushType\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuEnableInterrupt (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuDisableInterrupt (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuGetInterruptState (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
+  OUT BOOLEAN               *State\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuInit (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
+  IN EFI_CPU_INIT_TYPE      InitType\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuRegisterInterruptHandler (\r
+  IN EFI_CPU_ARCH_PROTOCOL      *This,\r
+  IN EFI_EXCEPTION_TYPE         InterruptType,\r
+  IN EFI_CPU_INTERRUPT_HANDLER  InterruptHandler\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuGetTimerValue (\r
+  IN  EFI_CPU_ARCH_PROTOCOL *This,\r
+  IN  UINT32                TimerIndex,\r
+  OUT UINT64                *TimerValue,\r
+  OUT UINT64                *TimerPeriod OPTIONAL\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSetMemoryAttributes (\r
+  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
+  IN EFI_PHYSICAL_ADDRESS   BaseAddress,\r
+  IN UINT64                 Length,\r
+  IN UINT64                 Attributes\r
+  );\r
+\r
+EFI_STATUS\r
+CpuMpServicesInit (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMpServicesWhoAmI (\r
+  IN EFI_MP_SERVICES_PROTOCOL  *This,\r
+  OUT UINTN                    *ProcessorNumber\r
+  );\r
+\r
+extern EFI_MP_SERVICES_PROTOCOL  mMpSercicesTemplate;\r
+\r
+\r
+#endif\r
diff --git a/EmulatorPkg/CpuRuntimeDxe/CpuIo.c b/EmulatorPkg/CpuRuntimeDxe/CpuIo.c
new file mode 100644 (file)
index 0000000..6f63375
--- /dev/null
@@ -0,0 +1,333 @@
+/*++ @file\r
+  This is the code that publishes the CPU I/O Protocol.\r
+  The intent herein is to have a single I/O service that can load\r
+  as early as possible, extend into runtime, and be layered upon by \r
+  the implementations of architectural protocols and the PCI Root\r
+  Bridge I/O Protocol.\r
+\r
+\r
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#include <FrameworkDxe.h>\r
+#include <Protocol/Cpu.h>\r
+#include <Protocol/DataHub.h>\r
+#include <Guid/DataHubRecords.h>\r
+#include <Protocol/CpuIo2.h>\r
+#include <Protocol/FrameworkHii.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <CpuDriver.h>\r
+\r
+#define IA32_MAX_IO_ADDRESS   0xFFFF\r
+#define IA32_MAX_MEM_ADDRESS  0xFFFFFFFF\r
+\r
+EFI_STATUS\r
+CpuIoCheckAddressRange (\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  VOID                              *Buffer,\r
+  IN  UINT64                            Limit\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceRead (\r
+  IN  EFI_CPU_IO2_PROTOCOL              *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Perform the Memory Access Read service for the CPU I/O Protocol\r
+\r
+Arguments:\r
+\r
+  Pointer to an instance of the CPU I/O Protocol\r
+  Width of the Memory Access\r
+  Address of the Memory access\r
+  Count of the number of accesses to perform\r
+  Pointer to the buffer to read or write from memory\r
+\r
+Returns:\r
+\r
+  Status\r
+\r
+  EFI_SUCCESS             - The data was read from or written to the EFI \r
+                            System.\r
+  EFI_INVALID_PARAMETER   - Width is invalid for this EFI System.\r
+  EFI_INVALID_PARAMETER   - Buffer is NULL.\r
+  EFI_UNSUPPORTED         - The Buffer is not aligned for the given Width.\r
+  EFI_UNSUPPORTED         - The address range specified by Address, Width, \r
+                            and Count is not valid for this EFI System.\r
+\r
+**/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (!Buffer) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Do nothing for Nt32 version\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceWrite (\r
+  IN EFI_CPU_IO2_PROTOCOL               *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Perform the Memory Access Read service for the CPU I/O Protocol\r
+\r
+Arguments:\r
+\r
+  Pointer to an instance of the CPU I/O Protocol\r
+  Width of the Memory Access\r
+  Address of the Memory access\r
+  Count of the number of accesses to perform\r
+  Pointer to the buffer to read or write from memory\r
+\r
+Returns:\r
+\r
+  Status\r
+\r
+  EFI_SUCCESS             - The data was read from or written to the EFI System.\r
+  EFI_INVALID_PARAMETER   - Width is invalid for this EFI System.\r
+  EFI_INVALID_PARAMETER   - Buffer is NULL.\r
+  EFI_UNSUPPORTED         - The Buffer is not aligned for the given Width.\r
+  EFI_UNSUPPORTED         - The address range specified by Address, Width, and \r
+                            Count is not valid for this EFI System.\r
+\r
+**/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (!Buffer) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Do nothing for Nt32 version\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceRead (\r
+  IN EFI_CPU_IO2_PROTOCOL               *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            UserAddress,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *UserBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  This is the service that implements the I/O read\r
+\r
+Arguments:\r
+\r
+  Pointer to an instance of the CPU I/O Protocol\r
+  Width of the Memory Access\r
+  Address of the I/O access\r
+  Count of the number of accesses to perform\r
+  Pointer to the buffer to read or write from I/O space\r
+\r
+Returns:\r
+\r
+  Status\r
+  EFI_SUCCESS             - The data was read from or written to the EFI System.\r
+  EFI_INVALID_PARAMETER   - Width is invalid for this EFI System.\r
+  EFI_INVALID_PARAMETER   - Buffer is NULL.\r
+  EFI_UNSUPPORTED         - The Buffer is not aligned for the given Width.\r
+  EFI_UNSUPPORTED         - The address range specified by Address, Width, and \r
+                            Count is not valid for this EFI System.\r
+**/\r
+{\r
+  UINTN       Address;\r
+  EFI_STATUS  Status;\r
+\r
+  if (!UserBuffer) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Address = (UINTN) UserAddress;\r
+\r
+  if (Width >= EfiCpuIoWidthMaximum) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = CpuIoCheckAddressRange (Width, Address, Count, UserBuffer, IA32_MAX_IO_ADDRESS);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Do nothing for Nt32 version\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceWrite (\r
+  IN EFI_CPU_IO2_PROTOCOL               *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            UserAddress,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *UserBuffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  \r
+  This is the service that implements the I/O Write\r
+\r
+Arguments:\r
+\r
+  Pointer to an instance of the CPU I/O Protocol\r
+  Width of the Memory Access\r
+  Address of the I/O access\r
+  Count of the number of accesses to perform\r
+  Pointer to the buffer to read or write from I/O space\r
+\r
+Returns:\r
+\r
+  Status\r
+\r
+  Status\r
+  EFI_SUCCESS             - The data was read from or written to the EFI System.\r
+  EFI_INVALID_PARAMETER   - Width is invalid for this EFI System.\r
+  EFI_INVALID_PARAMETER   - Buffer is NULL.\r
+  EFI_UNSUPPORTED         - The Buffer is not aligned for the given Width.\r
+  EFI_UNSUPPORTED         - The address range specified by Address, Width, and \r
+                            Count is not valid for this EFI System.\r
+\r
+**/\r
+{\r
+  UINTN       Address;\r
+  EFI_STATUS  Status;\r
+\r
+  if (!UserBuffer) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Address = (UINTN) UserAddress;\r
+\r
+  if (Width >= EfiCpuIoWidthMaximum) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = CpuIoCheckAddressRange (Width, Address, Count, UserBuffer, IA32_MAX_IO_ADDRESS);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Do nothing for Nt32 version\r
+  //\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+  Width   - TODO: add argument description\r
+  Address - TODO: add argument description\r
+  Count   - TODO: add argument description\r
+  Buffer  - TODO: add argument description\r
+  Limit   - TODO: add argument description\r
+\r
+Returns:\r
+\r
+  EFI_UNSUPPORTED - TODO: Add description for return value\r
+  EFI_UNSUPPORTED - TODO: Add description for return value\r
+  EFI_UNSUPPORTED - TODO: Add description for return value\r
+  EFI_SUCCESS - TODO: Add description for return value\r
+\r
+**/\r
+EFI_STATUS\r
+CpuIoCheckAddressRange (\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  VOID                              *Buffer,\r
+  IN  UINT64                            Limit\r
+  )\r
+{\r
+  UINTN AlignMask;\r
+\r
+  if (Address > Limit) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // For FiFo type, the target address won't increase during the access, so treat count as 1\r
+  //\r
+  if (Width >= EfiCpuIoWidthFifoUint8 && Width <= EfiCpuIoWidthFifoUint64) {\r
+    Count = 1;\r
+  }\r
+\r
+  Width = Width & 0x03;\r
+  if (Address - 1 + (1 << Width) * Count > Limit) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  AlignMask = (1 << Width) - 1;\r
+  if ((UINTN) Buffer & AlignMask) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
diff --git a/EmulatorPkg/CpuRuntimeDxe/MpService.c b/EmulatorPkg/CpuRuntimeDxe/MpService.c
new file mode 100644 (file)
index 0000000..7f3b199
--- /dev/null
@@ -0,0 +1,1366 @@
+/** @file\r
+  Construct MP Services Protocol on top of the EMU Thread protocol.\r
+  This code makes APs show up in the emulator. PcdEmuApCount is the\r
+  number of APs the emulator should produce.\r
+\r
+  The MP Services Protocol provides a generalized way of performing following tasks:\r
+    - Retrieving information of multi-processor environment and MP-related status of\r
+      specific processors.\r
+    - Dispatching user-provided function to APs.\r
+    - Maintain MP-related processor status.\r
+\r
+  The MP Services Protocol must be produced on any system with more than one logical\r
+  processor.\r
+\r
+  The Protocol is available only during boot time.\r
+\r
+  MP Services Protocol is hardware-independent. Most of the logic of this protocol\r
+  is architecturally neutral. It abstracts the multi-processor environment and \r
+  status of processors, and provides interfaces to retrieve information, maintain, \r
+  and dispatch.\r
+\r
+  MP Services Protocol may be consumed by ACPI module. The ACPI module may use this \r
+  protocol to retrieve data that are needed for an MP platform and report them to OS.\r
+  MP Services Protocol may also be used to program and configure processors, such \r
+  as MTRR synchronization for memory space attributes setting in DXE Services.\r
+  MP Services Protocol may be used by non-CPU DXE drivers to speed up platform boot \r
+  by taking advantage of the processing capabilities of the APs, for example, using \r
+  APs to help test system memory in parallel with other device initialization.\r
+  Diagnostics applications may also use this protocol for multi-processor.\r
+\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Portitions Copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials are licensed and made available under\r
+the terms and conditions of the BSD License that accompanies this distribution.\r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php.\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+**/\r
+\r
+#include "CpuDriver.h"\r
+\r
+\r
+MP_SYSTEM_DATA                gMPSystem;\r
+EMU_THREAD_THUNK_PROTOCOL     *gThread = NULL; \r
+EFI_EVENT                     gReadToBootEvent;\r
+BOOLEAN                       gReadToBoot = FALSE;\r
+UINTN                         gPollInterval;\r
+\r
+\r
+BOOLEAN\r
+IsBSP (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       ProcessorNumber;\r
+  \r
+  Status = CpuMpServicesWhoAmI (&mMpSercicesTemplate, &ProcessorNumber);\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
+  \r
+  return (gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0;\r
+}\r
+\r
+\r
+VOID\r
+SetApProcedure (\r
+  IN   PROCESSOR_DATA_BLOCK  *Processor,\r
+  IN   EFI_AP_PROCEDURE      Procedure,\r
+  IN   VOID                  *ProcedureArgument\r
+  )\r
+{\r
+  gThread->MutexLock (Processor->ProcedureLock);\r
+  Processor->Parameter  = ProcedureArgument;\r
+  Processor->Procedure  = Procedure;\r
+  gThread->MutexUnlock (Processor->ProcedureLock);\r
+}\r
+\r
+\r
+EFI_STATUS\r
+GetNextBlockedNumber (\r
+  OUT UINTN                               *NextNumber\r
+  )\r
+{\r
+  UINTN                 Number;\r
+  PROCESSOR_STATE       ProcessorState;\r
+  PROCESSOR_DATA_BLOCK  *Data;\r
+\r
+  for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {\r
+    Data = &gMPSystem.ProcessorData[Number];\r
+    if ((Data->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0) {\r
+      // Skip BSP\r
+      continue;\r
+    }\r
+\r
+    gThread->MutexLock (Data->StateLock);\r
+    ProcessorState = Data->State;\r
+    gThread->MutexUnlock (Data->StateLock);\r
+\r
+    if (ProcessorState == CPU_STATE_BLOCKED) {\r
+      *NextNumber = Number;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+\r
+\r
+\r
+/**\r
+  This service retrieves the number of logical processor in the platform\r
+  and the number of those logical processors that are enabled on this boot.\r
+  This service may only be called from the BSP.\r
+\r
+  This function is used to retrieve the following information:\r
+    - The number of logical processors that are present in the system.\r
+    - The number of enabled logical processors in the system at the instant \r
+      this call is made.\r
+\r
+  Because MP Service Protocol provides services to enable and disable processors \r
+  dynamically, the number of enabled logical processors may vary during the \r
+  course of a boot session.\r
+  \r
+  If this service is called from an AP, then EFI_DEVICE_ERROR is returned. \r
+  If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then \r
+  EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors \r
+  is returned in NumberOfProcessors, the number of currently enabled processor \r
+  is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.\r
+\r
+  @param[in]  This                        A pointer to the EFI_MP_SERVICES_PROTOCOL\r
+                                          instance.\r
+  @param[out] NumberOfProcessors          Pointer to the total number of logical\r
+                                          processors in the system, including the BSP\r
+                                          and disabled APs.\r
+  @param[out] NumberOfEnabledProcessors   Pointer to the number of enabled logical\r
+                                          processors that exist in system, including\r
+                                          the BSP.\r
+\r
+  @retval EFI_SUCCESS             The number of logical processors and enabled \r
+                                  logical processors was retrieved.\r
+  @retval EFI_DEVICE_ERROR        The calling processor is an AP.\r
+  @retval EFI_INVALID_PARAMETER   NumberOfProcessors is NULL.\r
+  @retval EFI_INVALID_PARAMETER   NumberOfEnabledProcessors is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMpServicesGetNumberOfProcessors (\r
+  IN  EFI_MP_SERVICES_PROTOCOL  *This,\r
+  OUT UINTN                     *NumberOfProcessors,\r
+  OUT UINTN                     *NumberOfEnabledProcessors\r
+  )\r
+{\r
+  if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  if (!IsBSP ()) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  \r
+  *NumberOfProcessors        = gMPSystem.NumberOfProcessors;\r
+  *NumberOfEnabledProcessors = gMPSystem.NumberOfEnabledProcessors;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Gets detailed MP-related information on the requested processor at the\r
+  instant this call is made. This service may only be called from the BSP.\r
+\r
+  This service retrieves detailed MP-related information about any processor \r
+  on the platform. Note the following:\r
+    - The processor information may change during the course of a boot session.\r
+    - The information presented here is entirely MP related.\r
+  \r
+  Information regarding the number of caches and their sizes, frequency of operation,\r
+  slot numbers is all considered platform-related information and is not provided \r
+  by this service.\r
+\r
+  @param[in]  This                  A pointer to the EFI_MP_SERVICES_PROTOCOL\r
+                                    instance.\r
+  @param[in]  ProcessorNumber       The handle number of processor.\r
+  @param[out] ProcessorInfoBuffer   A pointer to the buffer where information for\r
+                                    the requested processor is deposited.\r
+\r
+  @retval EFI_SUCCESS             Processor information was returned.\r
+  @retval EFI_DEVICE_ERROR        The calling processor is an AP.\r
+  @retval EFI_INVALID_PARAMETER   ProcessorInfoBuffer is NULL.\r
+  @retval EFI_NOT_FOUND           The processor with the handle specified by\r
+                                  ProcessorNumber does not exist in the platform.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMpServicesGetProcessorInfo (\r
+  IN  EFI_MP_SERVICES_PROTOCOL   *This,\r
+  IN  UINTN                      ProcessorNumber,\r
+  OUT EFI_PROCESSOR_INFORMATION  *ProcessorInfoBuffer\r
+  )\r
+{\r
+  if (ProcessorInfoBuffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  if (!IsBSP ()) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  \r
+  if (ProcessorNumber >= gMPSystem.NumberOfProcessors) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  \r
+  CopyMem (ProcessorInfoBuffer, &gMPSystem.ProcessorData[ProcessorNumber], sizeof (EFI_PROCESSOR_INFORMATION));\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  This service executes a caller provided function on all enabled APs. APs can \r
+  run either simultaneously or one at a time in sequence. This service supports \r
+  both blocking and non-blocking requests. The non-blocking requests use EFI \r
+  events so the BSP can detect when the APs have finished. This service may only \r
+  be called from the BSP.\r
+\r
+  This function is used to dispatch all the enabled APs to the function specified \r
+  by Procedure.  If any enabled AP is busy, then EFI_NOT_READY is returned \r
+  immediately and Procedure is not started on any AP.\r
+\r
+  If SingleThread is TRUE, all the enabled APs execute the function specified by \r
+  Procedure one by one, in ascending order of processor handle number. Otherwise, \r
+  all the enabled APs execute the function specified by Procedure simultaneously.\r
+\r
+  If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all \r
+  APs finish or TimeoutInMicroseconds expires. Otherwise, execution is in non-blocking \r
+  mode, and the BSP returns from this service without waiting for APs. If a \r
+  non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT \r
+  is signaled, then EFI_UNSUPPORTED must be returned.\r
+\r
+  If the timeout specified by TimeoutInMicroseconds expires before all APs return \r
+  from Procedure, then Procedure on the failed APs is terminated. All enabled APs \r
+  are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r
+  and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its \r
+  content points to the list of processor handle numbers in which Procedure was \r
+  terminated.\r
+\r
+  Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() \r
+  to make sure that the nature of the code that is executed on the BSP and the \r
+  dispatched APs is well controlled. The MP Services Protocol does not guarantee \r
+  that the Procedure function is MP-safe. Hence, the tasks that can be run in \r
+  parallel are limited to certain independent tasks and well-controlled exclusive \r
+  code. EFI services and protocols may not be called by APs unless otherwise \r
+  specified.\r
+\r
+  In blocking execution mode, BSP waits until all APs finish or \r
+  TimeoutInMicroseconds expires.\r
+\r
+  In non-blocking execution mode, BSP is freed to return to the caller and then \r
+  proceed to the next task without having to wait for APs. The following \r
+  sequence needs to occur in a non-blocking execution mode:\r
+\r
+    -# The caller that intends to use this MP Services Protocol in non-blocking \r
+       mode creates WaitEvent by calling the EFI CreateEvent() service.  The caller \r
+       invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent \r
+       is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests \r
+       the function specified by Procedure to be started on all the enabled APs, \r
+       and releases the BSP to continue with other tasks.\r
+    -# The caller can use the CheckEvent() and WaitForEvent() services to check \r
+       the state of the WaitEvent created in step 1.\r
+    -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP \r
+       Service signals WaitEvent by calling the EFI SignalEvent() function. If \r
+       FailedCpuList is not NULL, its content is available when WaitEvent is \r
+       signaled. If all APs returned from Procedure prior to the timeout, then \r
+       FailedCpuList is set to NULL. If not all APs return from Procedure before \r
+       the timeout, then FailedCpuList is filled in with the list of the failed \r
+       APs. The buffer is allocated by MP Service Protocol using AllocatePool(). \r
+       It is the caller's responsibility to free the buffer with FreePool() service.\r
+    -# This invocation of SignalEvent() function informs the caller that invoked\r
+       EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed\r
+       the specified task or a timeout occurred. The contents of FailedCpuList \r
+       can be examined to determine which APs did not complete the specified task \r
+       prior to the timeout.\r
+\r
+  @param[in]  This                    A pointer to the EFI_MP_SERVICES_PROTOCOL\r
+                                      instance.\r
+  @param[in]  Procedure               A pointer to the function to be run on \r
+                                      enabled APs of the system. See type\r
+                                      EFI_AP_PROCEDURE.\r
+  @param[in]  SingleThread            If TRUE, then all the enabled APs execute \r
+                                      the function specified by Procedure one by \r
+                                      one, in ascending order of processor handle \r
+                                      number.  If FALSE, then all the enabled APs \r
+                                      execute the function specified by Procedure\r
+                                      simultaneously.\r
+  @param[in]  WaitEvent               The event created by the caller with CreateEvent()\r
+                                      service.  If it is NULL, then execute in \r
+                                      blocking mode. BSP waits until all APs finish \r
+                                      or TimeoutInMicroseconds expires.  If it's \r
+                                      not NULL, then execute in non-blocking mode. \r
+                                      BSP requests the function specified by \r
+                                      Procedure to be started on all the enabled \r
+                                      APs, and go on executing immediately. If \r
+                                      all return from Procedure, or TimeoutInMicroseconds\r
+                                      expires, this event is signaled. The BSP \r
+                                      can use the CheckEvent() or WaitForEvent() \r
+                                      services to check the state of event.  Type \r
+                                      EFI_EVENT is defined in CreateEvent() in \r
+                                      the Unified Extensible Firmware Interface \r
+                                      Specification.  \r
+  @param[in]  TimeoutInMicrosecsond   Indicates the time limit in microseconds for \r
+                                      APs to return from Procedure, either for \r
+                                      blocking or non-blocking mode. Zero means \r
+                                      infinity.  If the timeout expires before \r
+                                      all APs return from Procedure, then Procedure\r
+                                      on the failed APs is terminated. All enabled \r
+                                      APs are available for next function assigned \r
+                                      by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() \r
+                                      or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().\r
+                                      If the timeout expires in blocking mode, \r
+                                      BSP returns EFI_TIMEOUT.  If the timeout \r
+                                      expires in non-blocking mode, WaitEvent \r
+                                      is signaled with SignalEvent().\r
+  @param[in]  ProcedureArgument       The parameter passed into Procedure for \r
+                                      all APs.\r
+  @param[out] FailedCpuList           If NULL, this parameter is ignored. Otherwise, \r
+                                      if all APs finish successfully, then its \r
+                                      content is set to NULL. If not all APs \r
+                                      finish before timeout expires, then its \r
+                                      content is set to address of the buffer \r
+                                      holding handle numbers of the failed APs. \r
+                                      The buffer is allocated by MP Service Protocol, \r
+                                      and it's the caller's responsibility to \r
+                                      free the buffer with FreePool() service.\r
+                                      In blocking mode, it is ready for consumption \r
+                                      when the call returns. In non-blocking mode, \r
+                                      it is ready when WaitEvent is signaled.  The \r
+                                      list of failed CPU is terminated by \r
+                                      END_OF_CPU_LIST.\r
+\r
+  @retval EFI_SUCCESS             In blocking mode, all APs have finished before \r
+                                  the timeout expired.\r
+  @retval EFI_SUCCESS             In non-blocking mode, function has been dispatched \r
+                                  to all enabled APs.\r
+  @retval EFI_UNSUPPORTED         A non-blocking mode request was made after the \r
+                                  UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was \r
+                                  signaled.\r
+  @retval EFI_DEVICE_ERROR        Caller processor is AP.\r
+  @retval EFI_NOT_STARTED         No enabled APs exist in the system.\r
+  @retval EFI_NOT_READY           Any enabled APs are busy.\r
+  @retval EFI_TIMEOUT             In blocking mode, the timeout expired before \r
+                                  all enabled APs have finished.\r
+  @retval EFI_INVALID_PARAMETER   Procedure is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMpServicesStartupAllAps (\r
+  IN  EFI_MP_SERVICES_PROTOCOL  *This,\r
+  IN  EFI_AP_PROCEDURE          Procedure,\r
+  IN  BOOLEAN                   SingleThread,\r
+  IN  EFI_EVENT                 WaitEvent               OPTIONAL,\r
+  IN  UINTN                     TimeoutInMicroseconds,\r
+  IN  VOID                      *ProcedureArgument      OPTIONAL,\r
+  OUT UINTN                     **FailedCpuList         OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  PROCESSOR_DATA_BLOCK  *ProcessorData;\r
+  UINTN                 ListIndex;\r
+  UINTN                 Number;\r
+  UINTN                 NextNumber;\r
+  PROCESSOR_STATE       APInitialState;\r
+  PROCESSOR_STATE       ProcessorState;\r
+  INTN                  Timeout;\r
+\r
+\r
+  if (!IsBSP ()) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  \r
+  if (gMPSystem.NumberOfProcessors == 1) {\r
+    return EFI_NOT_STARTED;\r
+  }\r
+\r
+  if (Procedure == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  if ((WaitEvent != NULL)  && gReadToBoot) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  \r
+  if (FailedCpuList != NULL) {\r
+    gMPSystem.FailedList = AllocatePool ((gMPSystem.NumberOfProcessors + 1) * sizeof (UINTN));\r
+    if (gMPSystem.FailedList == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+    SetMemN (gMPSystem.FailedList, (gMPSystem.NumberOfProcessors + 1) * sizeof (UINTN), END_OF_CPU_LIST);\r
+    gMPSystem.FailedListIndex = 0;\r
+    *FailedCpuList = gMPSystem.FailedList;\r
+  }\r
+\r
+  Timeout = TimeoutInMicroseconds;\r
+\r
+  ListIndex                   = 0;\r
+  ProcessorData               = NULL;\r
+\r
+  gMPSystem.FinishCount   = 0;\r
+  gMPSystem.StartCount    = 0;\r
+  gMPSystem.SingleThread  = SingleThread;\r
+  APInitialState          = CPU_STATE_READY;\r
+\r
+  for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {\r
+    ProcessorData = &gMPSystem.ProcessorData[Number];\r
+\r
+    if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {\r
+      // Skip BSP\r
+      continue;\r
+    }\r
+\r
+    if ((ProcessorData->Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0) {\r
+      // Skip Disabled processors\r
+      gMPSystem.FailedList[gMPSystem.FailedListIndex++] = Number;\r
+      continue;\r
+    }\r
+\r
+    //\r
+    // Get APs prepared, and put failing APs into FailedCpuList\r
+    // if "SingleThread", only 1 AP will put to ready state, other AP will be put to ready\r
+    // state 1 by 1, until the previous 1 finished its task\r
+    // if not "SingleThread", all APs are put to ready state from the beginning\r
+    //\r
+    if (ProcessorData->State == CPU_STATE_IDLE) {\r
+      gMPSystem.StartCount++;\r
+\r
+      gThread->MutexLock (&ProcessorData->StateLock);\r
+      ProcessorData->State = APInitialState;\r
+      gThread->MutexUnlock (&ProcessorData->StateLock);\r
+\r
+      if (SingleThread) {\r
+        APInitialState = CPU_STATE_BLOCKED;\r
+      }\r
+    } else {\r
+      return EFI_NOT_READY;\r
+    }\r
+  }\r
+  \r
+  if (WaitEvent != NULL) {\r
+    for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {\r
+      ProcessorData = &gMPSystem.ProcessorData[Number];  \r
+      if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {\r
+       // Skip BSP\r
+        continue;\r
+      }\r
+\r
+      if ((ProcessorData->Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0) {\r
+        // Skip Disabled processors\r
+        continue;\r
+      }\r
+    \r
+      SetApProcedure (ProcessorData, Procedure, ProcedureArgument);\r
+    }\r
+\r
+    //\r
+    // Save data into private data structure, and create timer to poll AP state before exiting\r
+    //\r
+    gMPSystem.Procedure         = Procedure;\r
+    gMPSystem.ProcedureArgument = ProcedureArgument;\r
+    gMPSystem.WaitEvent         = WaitEvent;\r
+    gMPSystem.Timeout           = TimeoutInMicroseconds;\r
+    gMPSystem.TimeoutActive     = (BOOLEAN)(TimeoutInMicroseconds != 0);\r
+    Status = gBS->SetTimer (\r
+                    gMPSystem.CheckAllAPsEvent,\r
+                    TimerPeriodic,\r
+                    gPollInterval\r
+                    );\r
+    return Status;\r
+\r
+  }\r
+\r
+  while (TRUE) {\r
+    for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {\r
+      ProcessorData = &gMPSystem.ProcessorData[Number];  \r
+      if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {\r
+       // Skip BSP\r
+        continue;\r
+      }\r
+\r
+      if ((ProcessorData->Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0) {\r
+        // Skip Disabled processors\r
+        continue;\r
+      }\r
+\r
+      gThread->MutexLock (ProcessorData->StateLock);\r
+      ProcessorState = ProcessorData->State;\r
+      gThread->MutexUnlock (ProcessorData->StateLock);\r
+\r
+      switch (ProcessorState) {\r
+      case CPU_STATE_READY:\r
+        SetApProcedure (ProcessorData, Procedure, ProcedureArgument);\r
+        break;\r
+\r
+      case CPU_STATE_FINISHED:\r
+        gMPSystem.FinishCount++;\r
+        if (SingleThread) {\r
+          Status = GetNextBlockedNumber (&NextNumber);\r
+          if (!EFI_ERROR (Status)) {\r
+            gMPSystem.ProcessorData[NextNumber].State = CPU_STATE_READY;\r
+          }\r
+        }\r
+\r
+        ProcessorData->State = CPU_STATE_IDLE;\r
+        break;\r
+\r
+      default:\r
+        break;\r
+      }\r
+    }\r
+\r
+    if (gMPSystem.FinishCount == gMPSystem.StartCount) {\r
+      Status = EFI_SUCCESS;\r
+      goto Done;\r
+    }\r
+\r
+    if ((TimeoutInMicroseconds != 0) && (Timeout < 0)) {\r
+      Status = EFI_TIMEOUT;\r
+      goto Done;\r
+    }\r
+\r
+    gBS->Stall (gPollInterval);\r
+    Timeout -= gPollInterval;\r
+  }\r
+\r
+Done:\r
+  if (FailedCpuList != NULL) {\r
+    if (gMPSystem.FailedListIndex == 0) {\r
+      FreePool (*FailedCpuList);\r
+      *FailedCpuList = NULL;\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  This service lets the caller get one enabled AP to execute a caller-provided \r
+  function. The caller can request the BSP to either wait for the completion \r
+  of the AP or just proceed with the next task by using the EFI event mechanism. \r
+  See EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() for more details on non-blocking \r
+  execution support.  This service may only be called from the BSP.\r
+\r
+  This function is used to dispatch one enabled AP to the function specified by \r
+  Procedure passing in the argument specified by ProcedureArgument.  If WaitEvent \r
+  is NULL, execution is in blocking mode. The BSP waits until the AP finishes or \r
+  TimeoutInMicroSecondss expires. Otherwise, execution is in non-blocking mode. \r
+  BSP proceeds to the next task without waiting for the AP. If a non-blocking mode \r
+  is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled, \r
+  then EFI_UNSUPPORTED must be returned.\r
+  \r
+  If the timeout specified by TimeoutInMicroseconds expires before the AP returns \r
+  from Procedure, then execution of Procedure by the AP is terminated. The AP is \r
+  available for subsequent calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and \r
+  EFI_MP_SERVICES_PROTOCOL.StartupThisAP().\r
+\r
+  @param[in]  This                    A pointer to the EFI_MP_SERVICES_PROTOCOL\r
+                                      instance.\r
+  @param[in]  Procedure               A pointer to the function to be run on \r
+                                      enabled APs of the system. See type\r
+                                      EFI_AP_PROCEDURE.\r
+  @param[in]  ProcessorNumber         The handle number of the AP. The range is \r
+                                      from 0 to the total number of logical\r
+                                      processors minus 1. The total number of \r
+                                      logical processors can be retrieved by\r
+                                      EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
+  @param[in]  WaitEvent               The event created by the caller with CreateEvent()\r
+                                      service.  If it is NULL, then execute in \r
+                                      blocking mode. BSP waits until all APs finish \r
+                                      or TimeoutInMicroseconds expires.  If it's \r
+                                      not NULL, then execute in non-blocking mode. \r
+                                      BSP requests the function specified by \r
+                                      Procedure to be started on all the enabled \r
+                                      APs, and go on executing immediately. If \r
+                                      all return from Procedure or TimeoutInMicroseconds\r
+                                      expires, this event is signaled. The BSP \r
+                                      can use the CheckEvent() or WaitForEvent() \r
+                                      services to check the state of event.  Type \r
+                                      EFI_EVENT is defined in CreateEvent() in \r
+                                      the Unified Extensible Firmware Interface \r
+                                      Specification.  \r
+  @param[in]  TimeoutInMicrosecsond   Indicates the time limit in microseconds for \r
+                                      APs to return from Procedure, either for \r
+                                      blocking or non-blocking mode. Zero means \r
+                                      infinity.  If the timeout expires before \r
+                                      all APs return from Procedure, then Procedure\r
+                                      on the failed APs is terminated. All enabled \r
+                                      APs are available for next function assigned \r
+                                      by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() \r
+                                      or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().\r
+                                      If the timeout expires in blocking mode, \r
+                                      BSP returns EFI_TIMEOUT.  If the timeout \r
+                                      expires in non-blocking mode, WaitEvent \r
+                                      is signaled with SignalEvent().\r
+  @param[in]  ProcedureArgument       The parameter passed into Procedure for \r
+                                      all APs.\r
+  @param[out] Finished                If NULL, this parameter is ignored.  In \r
+                                      blocking mode, this parameter is ignored.\r
+                                      In non-blocking mode, if AP returns from \r
+                                      Procedure before the timeout expires, its\r
+                                      content is set to TRUE. Otherwise, the \r
+                                      value is set to FALSE. The caller can\r
+                                      determine if the AP returned from Procedure \r
+                                      by evaluating this value.\r
+\r
+  @retval EFI_SUCCESS             In blocking mode, specified AP finished before \r
+                                  the timeout expires.\r
+  @retval EFI_SUCCESS             In non-blocking mode, the function has been \r
+                                  dispatched to specified AP.\r
+  @retval EFI_UNSUPPORTED         A non-blocking mode request was made after the \r
+                                  UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was \r
+                                  signaled.\r
+  @retval EFI_DEVICE_ERROR        The calling processor is an AP.\r
+  @retval EFI_TIMEOUT             In blocking mode, the timeout expired before \r
+                                  the specified AP has finished.\r
+  @retval EFI_NOT_READY           The specified AP is busy.\r
+  @retval EFI_NOT_FOUND           The processor with the handle specified by \r
+                                  ProcessorNumber does not exist.\r
+  @retval EFI_INVALID_PARAMETER   ProcessorNumber specifies the BSP or disabled AP.\r
+  @retval EFI_INVALID_PARAMETER   Procedure is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMpServicesStartupThisAP (\r
+  IN  EFI_MP_SERVICES_PROTOCOL  *This,\r
+  IN  EFI_AP_PROCEDURE          Procedure,\r
+  IN  UINTN                     ProcessorNumber,\r
+  IN  EFI_EVENT                 WaitEvent               OPTIONAL,\r
+  IN  UINTN                     TimeoutInMicroseconds,\r
+  IN  VOID                      *ProcedureArgument      OPTIONAL,\r
+  OUT BOOLEAN                   *Finished               OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS      Status;\r
+  INTN            Timeout;\r
+  \r
+  if (!IsBSP ()) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  \r
+  if (Procedure == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+    \r
+  if (ProcessorNumber >= gMPSystem.NumberOfProcessors) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  \r
+  if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (gMPSystem.ProcessorData[ProcessorNumber].State != CPU_STATE_IDLE) {\r
+    return EFI_NOT_READY;\r
+  }\r
+\r
+  if ((WaitEvent != NULL)  && gReadToBoot) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Timeout = TimeoutInMicroseconds;\r
+\r
+  gMPSystem.StartCount   = 1;\r
+  gMPSystem.FinishCount  = 0;\r
+\r
+  SetApProcedure (&gMPSystem.ProcessorData[ProcessorNumber], Procedure, ProcedureArgument);\r
+\r
+  if (WaitEvent != NULL) {\r
+      // Non Blocking\r
+      gMPSystem.WaitEvent = WaitEvent;\r
+      Status = gBS->SetTimer (\r
+                      gMPSystem.ProcessorData[ProcessorNumber].CheckThisAPEvent,\r
+                      TimerPeriodic,\r
+                      gPollInterval\r
+                      );\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  // Blocking\r
+  while (TRUE) {\r
+    gThread->MutexLock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
+    if (gMPSystem.ProcessorData[ProcessorNumber].State == CPU_STATE_FINISHED) {\r
+      gMPSystem.ProcessorData[ProcessorNumber].State = CPU_STATE_IDLE;\r
+      gThread->MutexUnlock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
+      break;\r
+    }\r
+\r
+    gThread->MutexUnlock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
+\r
+    if ((TimeoutInMicroseconds != 0) && (Timeout < 0)) {\r
+      return EFI_TIMEOUT;\r
+    }\r
+\r
+    gBS->Stall (gPollInterval);\r
+    Timeout -= gPollInterval;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+\r
+}\r
+\r
+\r
+/**\r
+  This service switches the requested AP to be the BSP from that point onward. \r
+  This service changes the BSP for all purposes.   This call can only be performed \r
+  by the current BSP.\r
+\r
+  This service switches the requested AP to be the BSP from that point onward. \r
+  This service changes the BSP for all purposes. The new BSP can take over the \r
+  execution of the old BSP and continue seamlessly from where the old one left \r
+  off. This service may not be supported after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT \r
+  is signaled.\r
+\r
+  If the BSP cannot be switched prior to the return from this service, then \r
+  EFI_UNSUPPORTED must be returned.\r
+\r
+  @param[in] This              A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
+  @param[in] ProcessorNumber   The handle number of AP that is to become the new \r
+                               BSP. The range is from 0 to the total number of \r
+                               logical processors minus 1. The total number of \r
+                               logical processors can be retrieved by\r
+                               EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
+  @param[in] EnableOldBSP      If TRUE, then the old BSP will be listed as an \r
+                               enabled AP. Otherwise, it will be disabled.\r
+\r
+  @retval EFI_SUCCESS             BSP successfully switched.\r
+  @retval EFI_UNSUPPORTED         Switching the BSP cannot be completed prior to \r
+                                  this service returning.\r
+  @retval EFI_UNSUPPORTED         Switching the BSP is not supported.\r
+  @retval EFI_SUCCESS             The calling processor is an AP.\r
+  @retval EFI_NOT_FOUND           The processor with the handle specified by\r
+                                  ProcessorNumber does not exist.\r
+  @retval EFI_INVALID_PARAMETER   ProcessorNumber specifies the current BSP or \r
+                                  a disabled AP.\r
+  @retval EFI_NOT_READY           The specified AP is busy.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMpServicesSwitchBSP (\r
+  IN EFI_MP_SERVICES_PROTOCOL  *This,\r
+  IN  UINTN                    ProcessorNumber,\r
+  IN  BOOLEAN                  EnableOldBSP\r
+  )\r
+{\r
+  UINTN   Index;\r
+  \r
+  if (!IsBSP ()) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  \r
+  if (ProcessorNumber >= gMPSystem.NumberOfProcessors) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  \r
+  if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  for (Index = 0; Index < gMPSystem.NumberOfProcessors; Index++) {\r
+    if ((gMPSystem.ProcessorData[Index].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0) {\r
+      break;\r
+    }\r
+  }\r
+  ASSERT (Index != gMPSystem.NumberOfProcessors);\r
+  \r
+  if (gMPSystem.ProcessorData[ProcessorNumber].State != CPU_STATE_IDLE) {\r
+    return EFI_NOT_READY;\r
+  }\r
+  \r
+  // Skip for now as we need switch a bunch of stack stuff around and it's complex\r
+  // May not be worth it?\r
+  return EFI_NOT_READY;\r
+}\r
+\r
+\r
+/**\r
+  This service lets the caller enable or disable an AP from this point onward.  \r
+  This service may only be called from the BSP.\r
+\r
+  This service allows the caller enable or disable an AP from this point onward. \r
+  The caller can optionally specify the health status of the AP by Health. If \r
+  an AP is being disabled, then the state of the disabled AP is implementation \r
+  dependent. If an AP is enabled, then the implementation must guarantee that a \r
+  complete initialization sequence is performed on the AP, so the AP is in a state \r
+  that is compatible with an MP operating system. This service may not be supported \r
+  after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled.\r
+\r
+  If the enable or disable AP operation cannot be completed prior to the return \r
+  from this service, then EFI_UNSUPPORTED must be returned.\r
+\r
+  @param[in] This              A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
+  @param[in] ProcessorNumber   The handle number of AP that is to become the new \r
+                               BSP. The range is from 0 to the total number of \r
+                               logical processors minus 1. The total number of \r
+                               logical processors can be retrieved by\r
+                               EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
+  @param[in] EnableAP          Specifies the new state for the processor for \r
+                               enabled, FALSE for disabled.\r
+  @param[in] HealthFlag        If not NULL, a pointer to a value that specifies \r
+                               the new health status of the AP. This flag \r
+                               corresponds to StatusFlag defined in \r
+                               EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only \r
+                               the PROCESSOR_HEALTH_STATUS_BIT is used. All other \r
+                               bits are ignored.  If it is NULL, this parameter \r
+                               is ignored.\r
+\r
+  @retval EFI_SUCCESS             The specified AP was enabled or disabled successfully.\r
+  @retval EFI_UNSUPPORTED         Enabling or disabling an AP cannot be completed \r
+                                  prior to this service returning.\r
+  @retval EFI_UNSUPPORTED         Enabling or disabling an AP is not supported.\r
+  @retval EFI_DEVICE_ERROR        The calling processor is an AP.\r
+  @retval EFI_NOT_FOUND           Processor with the handle specified by ProcessorNumber\r
+                                  does not exist.\r
+  @retval EFI_INVALID_PARAMETER   ProcessorNumber specifies the BSP.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMpServicesEnableDisableAP (\r
+  IN  EFI_MP_SERVICES_PROTOCOL  *This,\r
+  IN  UINTN                     ProcessorNumber,\r
+  IN  BOOLEAN                   EnableAP,\r
+  IN  UINT32                    *HealthFlag OPTIONAL\r
+  )\r
+{\r
+  if (!IsBSP ()) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  \r
+  if (ProcessorNumber >= gMPSystem.NumberOfProcessors) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  \r
+  if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }  \r
+\r
+  if (gMPSystem.ProcessorData[ProcessorNumber].State != CPU_STATE_IDLE) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  gThread->MutexLock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
+  \r
+  if (EnableAP) {\r
+    if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0 ) {\r
+      gMPSystem.NumberOfEnabledProcessors++;\r
+    }\r
+    gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_ENABLED_BIT;\r
+  } else {\r
+    if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == PROCESSOR_ENABLED_BIT ) {\r
+      gMPSystem.NumberOfEnabledProcessors--;\r
+    }\r
+    gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag &= ~PROCESSOR_ENABLED_BIT;\r
+  }\r
+  \r
+  if (HealthFlag != NULL) {\r
+    gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag &= ~PROCESSOR_HEALTH_STATUS_BIT;\r
+    gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= (*HealthFlag & PROCESSOR_HEALTH_STATUS_BIT);\r
+  }\r
+  \r
+  gThread->MutexUnlock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  This return the handle number for the calling processor.  This service may be \r
+  called from the BSP and APs.\r
+\r
+  This service returns the processor handle number for the calling processor. \r
+  The returned value is in the range from 0 to the total number of logical \r
+  processors minus 1. The total number of logical processors can be retrieved \r
+  with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be \r
+  called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER \r
+  is returned. Otherwise, the current processors handle number is returned in \r
+  ProcessorNumber, and EFI_SUCCESS is returned.\r
+\r
+  @param[in] This              A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
+  @param[in] ProcessorNumber   The handle number of AP that is to become the new \r
+                               BSP. The range is from 0 to the total number of \r
+                               logical processors minus 1. The total number of \r
+                               logical processors can be retrieved by\r
+                               EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
+\r
+  @retval EFI_SUCCESS             The current processor handle number was returned \r
+                                  in ProcessorNumber.\r
+  @retval EFI_INVALID_PARAMETER   ProcessorNumber is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMpServicesWhoAmI (\r
+  IN EFI_MP_SERVICES_PROTOCOL  *This,\r
+  OUT UINTN                    *ProcessorNumber\r
+  )\r
+{\r
+  UINTN   Index;\r
+  UINT64  ProcessorId;\r
+  \r
+  if (ProcessorNumber == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  ProcessorId = gThread->Self ();\r
+  for (Index = 0; Index < gMPSystem.NumberOfProcessors; Index++) {\r
+    if (gMPSystem.ProcessorData[Index].Info.ProcessorId == ProcessorId) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  *ProcessorNumber = Index;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+EFI_MP_SERVICES_PROTOCOL  mMpSercicesTemplate = {\r
+  CpuMpServicesGetNumberOfProcessors,\r
+  CpuMpServicesGetProcessorInfo,\r
+  CpuMpServicesStartupAllAps,\r
+  CpuMpServicesStartupThisAP,\r
+  CpuMpServicesSwitchBSP,\r
+  CpuMpServicesEnableDisableAP,\r
+  CpuMpServicesWhoAmI\r
+};\r
+\r
+\r
+\r
+/*++\r
+  If timeout occurs in StartupAllAps(), a timer is set, which invokes this\r
+  procedure periodically to check whether all APs have finished.\r
+\r
+\r
+--*/\r
+VOID\r
+EFIAPI\r
+CpuCheckAllAPsStatus (\r
+  IN  EFI_EVENT   Event,\r
+  IN  VOID        *Context\r
+  )\r
+{\r
+  UINTN                 ProcessorNumber;\r
+  UINTN                 NextNumber;\r
+  PROCESSOR_DATA_BLOCK  *ProcessorData;\r
+  PROCESSOR_DATA_BLOCK  *NextData;\r
+  EFI_STATUS            Status;\r
+  PROCESSOR_STATE       ProcessorState;\r
+  UINTN                 Cpu;\r
+  BOOLEAN               Found;\r
+\r
+  if (gMPSystem.TimeoutActive) {\r
+    gMPSystem.Timeout -= gPollInterval;\r
+  }\r
+  \r
+  ProcessorData = (PROCESSOR_DATA_BLOCK *) Context;\r
+\r
+  for (ProcessorNumber = 0; ProcessorNumber < gMPSystem.NumberOfProcessors; ProcessorNumber++) {\r
+    if ((ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {\r
+     // Skip BSP\r
+      continue;\r
+    }\r
+\r
+    if ((ProcessorData->Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0) {\r
+      // Skip Disabled processors\r
+      continue;\r
+    }\r
+\r
+    // This is an Interrupt Service routine.\r
+    // This can grab a lock that is held in a non-interrupt\r
+    // context. Meaning deadlock. Which is a bad thing.\r
+    // So, try lock it. If we can get it, cool, do our thing.\r
+    // otherwise, just dump out & try again on the next iteration.\r
+    Status = gThread->MutexTryLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
+    if (EFI_ERROR(Status)) {\r
+      return;\r
+    }\r
+    ProcessorState = gMPSystem.ProcessorData[ProcessorNumber].State;\r
+    gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
+\r
+    switch (ProcessorState) {\r
+    case CPU_STATE_READY:\r
+      SetApProcedure (ProcessorData, gMPSystem.Procedure, gMPSystem.ProcedureArgument);\r
+      break;\r
+\r
+    case CPU_STATE_FINISHED:\r
+      if (gMPSystem.SingleThread) {\r
+        Status = GetNextBlockedNumber (&NextNumber);\r
+        if (!EFI_ERROR (Status)) {\r
+          NextData = &gMPSystem.ProcessorData[NextNumber];\r
+\r
+          gThread->MutexLock (&NextData->ProcedureLock);\r
+          NextData->State = CPU_STATE_READY;\r
+          gThread->MutexUnlock (&NextData->ProcedureLock);\r
+\r
+          SetApProcedure (NextData, gMPSystem.Procedure, gMPSystem.ProcedureArgument);\r
+        }\r
+      }\r
+\r
+      gMPSystem.ProcessorData[ProcessorNumber].State = CPU_STATE_IDLE;\r
+      gMPSystem.FinishCount++;\r
+      break;\r
+\r
+    default:\r
+      break;\r
+    }\r
+  }\r
+  \r
+  if (gMPSystem.TimeoutActive && gMPSystem.Timeout < 0) {\r
+    //\r
+    // Timeout\r
+    //\r
+    if (gMPSystem.FailedList != NULL) {\r
+      for (ProcessorNumber = 0; ProcessorNumber < gMPSystem.NumberOfProcessors; ProcessorNumber++) {\r
+        if ((ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {\r
+         // Skip BSP\r
+          continue;\r
+        }\r
+\r
+        if ((ProcessorData->Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0) {\r
+          // Skip Disabled processors\r
+          continue;\r
+        }\r
+    \r
+        // Mark the \r
+        Status = gThread->MutexTryLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
+        if (EFI_ERROR(Status)) {\r
+          return;\r
+        }\r
+        ProcessorState = gMPSystem.ProcessorData[ProcessorNumber].State;\r
+        gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
+    \r
+        if (ProcessorState != CPU_STATE_IDLE) {\r
+          // If we are retrying make sure we don't double count\r
+          for (Cpu = 0, Found = FALSE; Cpu < gMPSystem.NumberOfProcessors; Cpu++) {\r
+            if (gMPSystem.FailedList[Cpu] == END_OF_CPU_LIST) {\r
+              break;\r
+            }\r
+            if (gMPSystem.FailedList[ProcessorNumber] == Cpu) {\r
+              Found = TRUE;\r
+              break;\r
+            }\r
+          }\r
+          if (!Found) {\r
+            gMPSystem.FailedList[gMPSystem.FailedListIndex++] = Cpu;\r
+          }\r
+        }\r
+      }\r
+    }\r
+    // Force terminal exit\r
+    gMPSystem.FinishCount = gMPSystem.StartCount;\r
+  }\r
+\r
+  if (gMPSystem.FinishCount != gMPSystem.StartCount) {\r
+    return;\r
+  }\r
+  \r
+  gBS->SetTimer (\r
+         gMPSystem.CheckAllAPsEvent,\r
+         TimerCancel,\r
+         0\r
+         );\r
+\r
+  if (gMPSystem.FailedListIndex == 0) {\r
+    if (gMPSystem.FailedList != NULL) {\r
+      FreePool (gMPSystem.FailedList);\r
+      gMPSystem.FailedList = NULL;\r
+    }\r
+  }\r
+\r
+  Status = gBS->SignalEvent (gMPSystem.WaitEvent);\r
+\r
+  return ;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+CpuCheckThisAPStatus (\r
+  IN  EFI_EVENT                           Event,\r
+  IN  VOID                                *Context\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  PROCESSOR_DATA_BLOCK  *ProcessorData;\r
+  PROCESSOR_STATE       ProcessorState;\r
+\r
+  ProcessorData = (PROCESSOR_DATA_BLOCK *) Context;\r
+\r
+  //\r
+  // This is an Interrupt Service routine.\r
+  // that can grab a lock that is held in a non-interrupt\r
+  // context. Meaning deadlock. Which is a badddd thing.\r
+  // So, try lock it. If we can get it, cool, do our thing.\r
+  // otherwise, just dump out & try again on the next iteration.\r
+  //\r
+  Status = gThread->MutexTryLock (ProcessorData->StateLock);\r
+  if (EFI_ERROR(Status)) {\r
+    return;\r
+  }\r
+  ProcessorState = ProcessorData->State;\r
+  gThread->MutexUnlock (ProcessorData->StateLock);\r
+\r
+  if (ProcessorState == CPU_STATE_FINISHED) {\r
+    Status = gBS->SetTimer (ProcessorData->CheckThisAPEvent, TimerCancel, 0);\r
+    ASSERT_EFI_ERROR (Status);\r
+    \r
+    Status = gBS->SignalEvent (gMPSystem.WaitEvent);\r
+    ASSERT_EFI_ERROR (Status);\r
+    \r
+    gThread->MutexLock (ProcessorData->StateLock);\r
+    ProcessorData->State = CPU_STATE_IDLE;\r
+    gThread->MutexUnlock (ProcessorData->StateLock);\r
+  }\r
+\r
+  return ;\r
+}\r
+\r
+\r
+/*++\r
+  This function is called by all processors (both BSP and AP) once and collects MP related data\r
+\r
+  MPSystemData  - Pointer to the data structure containing MP related data\r
+  BSP           - TRUE if the CPU is BSP\r
+\r
+  EFI_SUCCESS   - Data for the processor collected and filled in\r
+\r
+--*/\r
+EFI_STATUS\r
+FillInProcessorInformation (\r
+  IN     BOOLEAN              BSP,\r
+  IN     UINTN                ProcessorNumber\r
+  )\r
+{\r
+  PROCESSOR_DATA_BLOCK            *ProcessorData;\r
+\r
+  ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];\r
+  \r
+  gMPSystem.ProcessorData[ProcessorNumber].Info.ProcessorId  = gThread->Self ();\r
+  gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag   = PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT;\r
+  if (BSP) {\r
+    gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_AS_BSP_BIT;\r
+  }\r
+  \r
+  gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Package = ProcessorNumber;\r
+  gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Core    = 0;\r
+  gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Thread  = 0;\r
+  gMPSystem.ProcessorData[ProcessorNumber].State = BSP ? CPU_STATE_BUSY : CPU_STATE_IDLE;\r
+  \r
+  gMPSystem.ProcessorData[ProcessorNumber].Procedure        = NULL;\r
+  gMPSystem.ProcessorData[ProcessorNumber].Parameter        = NULL;\r
+  gMPSystem.ProcessorData[ProcessorNumber].StateLock        = gThread->MutexInit ();\r
+  gMPSystem.ProcessorData[ProcessorNumber].ProcedureLock    = gThread->MutexInit ();\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID *\r
+EFIAPI\r
+CpuDriverApIdolLoop (\r
+  VOID  *Context\r
+  )\r
+{\r
+  EFI_AP_PROCEDURE      Procedure;\r
+  VOID                  *Parameter;\r
+  UINTN                 ProcessorNumber;\r
+  PROCESSOR_DATA_BLOCK  *ProcessorData;\r
+  \r
+  ProcessorNumber = (UINTN)Context;\r
+  ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];\r
+    \r
+  ProcessorData->Info.ProcessorId = gThread->Self ();\r
\r
+  while (TRUE) {\r
+    //\r
+    // Make a local copy on the stack to be extra safe\r
+    //\r
+    gThread->MutexLock (ProcessorData->ProcedureLock);\r
+    Procedure = ProcessorData->Procedure;\r
+    Parameter = ProcessorData->Parameter;\r
+    gThread->MutexUnlock (ProcessorData->ProcedureLock);\r
+  \r
+    if (Procedure != NULL) {\r
+      gThread->MutexLock (ProcessorData->StateLock);\r
+      ProcessorData->State = CPU_STATE_BUSY;\r
+      gThread->MutexUnlock (ProcessorData->StateLock);\r
+  \r
+      Procedure (Parameter);\r
+    \r
+      gThread->MutexLock (ProcessorData->ProcedureLock);\r
+      ProcessorData->Procedure = NULL;\r
+      gThread->MutexUnlock (ProcessorData->ProcedureLock);\r
+  \r
+      gThread->MutexLock (ProcessorData->StateLock);\r
+      ProcessorData->State = CPU_STATE_FINISHED;\r
+      gThread->MutexUnlock (ProcessorData->StateLock);  \r
+    }\r
+    \r
+    // Poll 5 times a seconds, 200ms\r
+    // Don't want to burn too many system resources doing nothing.\r
+    gEmuThunk->Sleep (200 * 1000);\r
+  }\r
+  \r
+  return 0;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+InitializeMpSystemData (\r
+  IN   UINTN     NumberOfProcessors\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  UINTN                   Index;\r
+\r
+  \r
+  //\r
+  // Clear the data structure area first.\r
+  //\r
+  ZeroMem (&gMPSystem, sizeof (MP_SYSTEM_DATA));\r
+\r
+  //\r
+  // First BSP fills and inits all known values, including it's own records.\r
+  //\r
+  gMPSystem.NumberOfProcessors         = NumberOfProcessors;\r
+  gMPSystem.NumberOfEnabledProcessors  = NumberOfProcessors;\r
+  \r
+  gMPSystem.ProcessorData = AllocateZeroPool (gMPSystem.NumberOfProcessors * sizeof (PROCESSOR_DATA_BLOCK));\r
+  ASSERT (gMPSystem.ProcessorData != NULL);\r
+\r
+  FillInProcessorInformation (TRUE, 0);\r
+  \r
+  Status = gBS->CreateEvent (\r
+                  EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
+                  TPL_CALLBACK,\r
+                  CpuCheckAllAPsStatus,\r
+                  NULL,\r
+                  &gMPSystem.CheckAllAPsEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+  \r
+\r
+  for (Index = 0; Index < gMPSystem.NumberOfProcessors; Index++) {\r
+    if ((gMPSystem.ProcessorData[Index].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {\r
+     // Skip BSP\r
+      continue;\r
+    }\r
+    \r
+    FillInProcessorInformation (FALSE, Index);\r
+    \r
+    Status = gThread->CreateThread (\r
+                        (VOID *)&gMPSystem.ProcessorData[Index].Info.ProcessorId, \r
+                        NULL,\r
+                        CpuDriverApIdolLoop,\r
+                        (VOID *)Index\r
+                        );\r
+                      \r
+              \r
+    Status = gBS->CreateEvent (\r
+                         EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
+                         TPL_CALLBACK,\r
+                         CpuCheckThisAPStatus,\r
+                         (VOID *)  &gMPSystem.ProcessorData[Index],\r
+                         &gMPSystem.ProcessorData[Index].CheckThisAPEvent\r
+                         );\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Invoke a notification event\r
+\r
+  @param  Event                 Event whose notification function is being invoked.\r
+  @param  Context               The pointer to the notification function's context,\r
+                                which is implementation-dependent.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuReadToBootFunction (\r
+  IN  EFI_EVENT                Event,\r
+  IN  VOID                     *Context\r
+  )\r
+{\r
+  gReadToBoot = TRUE;\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+CpuMpServicesInit (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_HANDLE              Handle;\r
+  EMU_IO_THUNK_PROTOCOL   *IoThunk;\r
+  UINTN                   MaxCpus;\r
+\r
+  MaxCpus = 1; // BSP\r
+  \r
+  IoThunk = GetIoThunkInstance (&gEmuThreadThunkProtocolGuid, 0);\r
+  if (IoThunk != NULL) {\r
+    Status = IoThunk->Open (IoThunk);\r
+    if (!EFI_ERROR (Status)) {\r
+      if (IoThunk->ConfigString != NULL) {\r
+        MaxCpus += StrDecimalToUintn (IoThunk->ConfigString);\r
+        gThread = IoThunk->Interface;\r
+      }\r
+    }\r
+  }\r
+\r
+  if (MaxCpus == 1) {\r
+    // We are not MP so nothing to do\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  gPollInterval = PcdGet64 (PcdEmuMpServicesPollingInterval);\r
+\r
+  Status  = InitializeMpSystemData (MaxCpus);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Status = EfiCreateEventReadyToBootEx (TPL_CALLBACK, CpuReadToBootFunction, NULL, &gReadToBootEvent);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Now install the MP services protocol.\r
+  //\r
+  Handle = NULL;\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Handle,\r
+                  &gEfiMpServiceProtocolGuid,   &mMpSercicesTemplate,\r
+                  NULL\r
+                  );\r
+  return Status;\r
+}\r
+\r
+\r
diff --git a/EmulatorPkg/CpuRuntimeDxe/Strings.uni b/EmulatorPkg/CpuRuntimeDxe/Strings.uni
new file mode 100644 (file)
index 0000000..c8a226e
Binary files /dev/null and b/EmulatorPkg/CpuRuntimeDxe/Strings.uni differ
diff --git a/EmulatorPkg/EmuBlockIoDxe/ComponentName.c b/EmulatorPkg/EmuBlockIoDxe/ComponentName.c
new file mode 100644 (file)
index 0000000..2cad6ca
--- /dev/null
@@ -0,0 +1,354 @@
+/**@file\r
+\r
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ComponentName.c\r
+\r
+Abstract:\r
+\r
+**/\r
+\r
+#include "EmuBlockIo.h"\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                driver specified by This in the language\r
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the controller\r
+  that is being managed by a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+\r
+  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified in\r
+                                RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  );\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED  EFI_COMPONENT_NAME_PROTOCOL     gEmuBlockIoComponentName = {\r
+  EmuBlockIoComponentNameGetDriverName,\r
+  EmuBlockIoComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+//\r
+// EFI Component Name 2 Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBlockIoComponentName2 = {\r
+  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuBlockIoComponentNameGetDriverName,\r
+  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuBlockIoComponentNameGetControllerName,\r
+  "en"\r
+};\r
+\r
+\r
+EFI_UNICODE_STRING_TABLE mEmuBlockIoDriverNameTable[] = {\r
+  { "eng;en", L"Emu Block I/O Driver" },\r
+  { NULL , NULL }\r
+};\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                driver specified by This in the language\r
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+{\r
+  return LookupUnicodeString2 (\r
+          Language,\r
+          This->SupportedLanguages,\r
+          mEmuBlockIoDriverNameTable,\r
+          DriverName,\r
+           (BOOLEAN)(This == &gEmuBlockIoComponentName)\r
+          );\r
+}\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the controller\r
+  that is being managed by a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+\r
+  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified in\r
+                                RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_BLOCK_IO_PROTOCOL   *BlockIo;\r
+  EMU_BLOCK_IO_PRIVATE    *Private;\r
+\r
+  //\r
+  // This is a device driver, so ChildHandle must be NULL.\r
+  //\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Make sure this driver is currently managing ControllerHandle\r
+  //\r
+  Status = EfiTestManagedDevice (\r
+             ControllerHandle,\r
+             gEmuBlockIoDriverBinding.DriverBindingHandle,\r
+             &gEmuIoThunkProtocolGuid\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Get our context back\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiBlockIoProtocolGuid,\r
+                  (VOID  **)&BlockIo,\r
+                  gEmuBlockIoDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo);\r
+\r
+  return LookupUnicodeString2 (\r
+          Language,\r
+           This->SupportedLanguages,\r
+           Private->ControllerNameTable,\r
+           ControllerName,\r
+           (BOOLEAN)(This == &gEmuBlockIoComponentName)\r
+          );\r
+}\r
diff --git a/EmulatorPkg/EmuBlockIoDxe/DriverConfiguration.c b/EmulatorPkg/EmuBlockIoDxe/DriverConfiguration.c
new file mode 100644 (file)
index 0000000..44a3cc3
--- /dev/null
@@ -0,0 +1,338 @@
+/**@file\r
+\r
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DriverConfiguration.c\r
+\r
+Abstract:\r
+\r
+**/\r
+\r
+#include "EmuBlockIo.h"\r
+\r
+//\r
+// EFI Driver Configuration Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoDriverConfigurationSetOptions (\r
+  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL                      *This,\r
+  IN  EFI_HANDLE                                             ControllerHandle,\r
+  IN  EFI_HANDLE                                             ChildHandle  OPTIONAL,\r
+  IN  CHAR8                                                  *Language,\r
+  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED               *ActionRequired\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoDriverConfigurationOptionsValid (\r
+  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL               *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle  OPTIONAL\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoDriverConfigurationForceDefaults (\r
+  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL                      *This,\r
+  IN  EFI_HANDLE                                             ControllerHandle,\r
+  IN  EFI_HANDLE                                             ChildHandle  OPTIONAL,\r
+  IN  UINT32                                                 DefaultType,\r
+  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED               *ActionRequired\r
+  );\r
+\r
+//\r
+// EFI Driver Configuration Protocol\r
+//\r
+EFI_DRIVER_CONFIGURATION_PROTOCOL gEmuBlockIoDriverConfiguration = {\r
+  EmuBlockIoDriverConfigurationSetOptions,\r
+  EmuBlockIoDriverConfigurationOptionsValid,\r
+  EmuBlockIoDriverConfigurationForceDefaults,\r
+  "eng"\r
+};\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Allows the user to set controller specific options for a controller that a \r
+    driver is currently managing.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.\r
+    ControllerHandle - The handle of the controller to set options on.\r
+    ChildHandle      - The handle of the child controller to set options on.  This\r
+                       is an optional parameter that may be NULL.  It will be NULL \r
+                       for device drivers, and for a bus drivers that wish to set \r
+                       options for the bus controller.  It will not be NULL for a \r
+                       bus driver that wishes to set options for one of its child \r
+                       controllers.\r
+    Language         - A pointer to a three character ISO 639-2 language identifier.\r
+                       This is the language of the user interface that should be \r
+                       presented to the user, and it must match one of the languages \r
+                       specified in SupportedLanguages.  The number of languages \r
+                       supported by a driver is up to the driver writer.\r
+    ActionRequired   - A pointer to the action that the calling agent is required \r
+                       to perform when this function returns.  See "Related \r
+                       Definitions" for a list of the actions that the calling \r
+                       agent is required to perform prior to accessing \r
+                       ControllerHandle again.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The driver specified by This successfully set the \r
+                            configuration options for the controller specified \r
+                            by ControllerHandle..\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support setting \r
+                            configuration options for the controller specified by \r
+                            ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+    EFI_DEVICE_ERROR      - A device error occurred while attempt to set the \r
+                            configuration options for the controller specified \r
+                            by ControllerHandle and ChildHandle.\r
+    EFI_OUT_RESOURCES     - There are not enough resources available to set the \r
+                            configuration options for the controller specified \r
+                            by ControllerHandle and ChildHandle.\r
+\r
+--*/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoDriverConfigurationSetOptions (\r
+  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL                      *This,\r
+  IN  EFI_HANDLE                                             ControllerHandle,\r
+  IN  EFI_HANDLE                                             ChildHandle  OPTIONAL,\r
+  IN  CHAR8                                                  *Language,\r
+  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED               *ActionRequired\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+  CHAR8                 *SupportedLanguage;\r
+\r
+  SupportedLanguage = This->SupportedLanguages;\r
+\r
+  Status            = EFI_UNSUPPORTED;\r
+  while (*SupportedLanguage != 0) {\r
+    if (AsciiStrnCmp (Language, SupportedLanguage, 3) == 0) {\r
+      Status = EFI_SUCCESS;\r
+    }\r
+\r
+    SupportedLanguage += 3;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if (ActionRequired == NULL || ControllerHandle == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Validate controller handle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&BlockIo,\r
+                  gEmuBlockIoDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEmuIoThunkProtocolGuid,\r
+          gEmuBlockIoDriverBinding.DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (Status == EFI_UNSUPPORTED) {\r
+    return Status;\r
+  } else if (Status != EFI_ALREADY_STARTED) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *ActionRequired = EfiDriverConfigurationActionNone;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Tests to see if a controller's current configuration options are valid.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.\r
+    ControllerHandle - The handle of the controller to test if it's current \r
+                       configuration options are valid.\r
+    ChildHandle      - The handle of the child controller to test if it's current\r
+                       configuration options are valid.  This is an optional \r
+                       parameter that may be NULL.  It will be NULL for device \r
+                       drivers.  It will also be NULL for a bus drivers that wish\r
+                       to test the configuration options for the bus controller.\r
+                       It will not be NULL for a bus driver that wishes to test \r
+                       configuration options for one of its child controllers.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The controller specified by ControllerHandle and \r
+                            ChildHandle that is being managed by the driver \r
+                            specified by This has a valid set of  configuration\r
+                            options.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_UNSUPPORTED       - The driver specified by This is not currently \r
+                            managing the controller specified by ControllerHandle \r
+                            and ChildHandle.\r
+    EFI_DEVICE_ERROR      - The controller specified by ControllerHandle and \r
+                            ChildHandle that is being managed by the driver \r
+                            specified by This has an invalid set of configuration \r
+                            options.\r
+\r
+--*/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoDriverConfigurationOptionsValid (\r
+  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL               *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle  OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (ControllerHandle == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Validate controller handle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&BlockIo,\r
+                  gEmuBlockIoDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEmuIoThunkProtocolGuid,\r
+          gEmuBlockIoDriverBinding.DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (Status == EFI_UNSUPPORTED) {\r
+    return Status;\r
+  } else if (Status != EFI_ALREADY_STARTED) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/*++\r
+\r
+  Routine Description:\r
+    Forces a driver to set the default configuration options for a controller.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.\r
+    ControllerHandle - The handle of the controller to force default configuration options on.\r
+    ChildHandle      - The handle of the child controller to force default configuration options on  This is an optional parameter that may be NULL.  It will be NULL for device drivers.  It will also be NULL for a bus drivers that wish to force default configuration options for the bus controller.  It will not be NULL for a bus driver that wishes to force default configuration options for one of its child controllers.\r
+    DefaultType      - The type of default configuration options to force on the controller specified by ControllerHandle and ChildHandle.  See Table 9-1 for legal values.  A DefaultType of 0x00000000 must be supported by this protocol.\r
+    ActionRequired   - A pointer to the action that the calling agent is required to perform when this function returns.  See "Related Definitions" in Section 9.1for a list of the actions that the calling agent is required to perform prior to accessing ControllerHandle again.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the configuration type specified by DefaultType.\r
+    EFI_DEVICE_ERROR      - A device error occurred while attempt to force the default configuration options on the controller specified by  ControllerHandle and ChildHandle.\r
+    EFI_OUT_RESOURCES     - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
+\r
+--*/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoDriverConfigurationForceDefaults (\r
+  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL                      *This,\r
+  IN  EFI_HANDLE                                             ControllerHandle,\r
+  IN  EFI_HANDLE                                             ChildHandle  OPTIONAL,\r
+  IN  UINT32                                                 DefaultType,\r
+  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED               *ActionRequired\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (ActionRequired == NULL || ControllerHandle == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Validate controller handle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&BlockIo,\r
+                  gEmuBlockIoDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEmuIoThunkProtocolGuid,\r
+          gEmuBlockIoDriverBinding.DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (Status == EFI_UNSUPPORTED) {\r
+    return Status;\r
+  } else if (Status != EFI_ALREADY_STARTED) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *ActionRequired = EfiDriverConfigurationActionNone;\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EmulatorPkg/EmuBlockIoDxe/DriverDiagnostics.c b/EmulatorPkg/EmuBlockIoDxe/DriverDiagnostics.c
new file mode 100644 (file)
index 0000000..ebb730b
--- /dev/null
@@ -0,0 +1,219 @@
+/**@file\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  DriverDiagnostics.c\r
+\r
+Abstract:\r
+\r
+**/\r
+\r
+#include "EmuBlockIo.h"\r
+\r
+//\r
+// EFI Driver Diagnostics Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoDriverDiagnosticsRunDiagnostics (\r
+  IN  EFI_DRIVER_DIAGNOSTICS_PROTOCOL               *This,\r
+  IN  EFI_HANDLE                                    ControllerHandle,\r
+  IN  EFI_HANDLE                                    ChildHandle  OPTIONAL,\r
+  IN  EFI_DRIVER_DIAGNOSTIC_TYPE                    DiagnosticType,\r
+  IN  CHAR8                                         *Language,\r
+  OUT EFI_GUID                                      **ErrorType,\r
+  OUT UINTN                                         *BufferSize,\r
+  OUT CHAR16                                        **Buffer\r
+  );\r
+\r
+//\r
+// EFI Driver Diagnostics Protocol\r
+//\r
+EFI_DRIVER_DIAGNOSTICS_PROTOCOL gEmuBlockIoDriverDiagnostics = {\r
+  EmuBlockIoDriverDiagnosticsRunDiagnostics,\r
+  "eng"\r
+};\r
+\r
+//\r
+// EFI Driver Diagnostics 2 Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gEmuBlockIoDriverDiagnostics2 = {\r
+  (EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS) EmuBlockIoDriverDiagnosticsRunDiagnostics,\r
+  "en"\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoDriverDiagnosticsRunDiagnostics (\r
+  IN  EFI_DRIVER_DIAGNOSTICS_PROTOCOL               *This,\r
+  IN  EFI_HANDLE                                    ControllerHandle,\r
+  IN  EFI_HANDLE                                    ChildHandle  OPTIONAL,\r
+  IN  EFI_DRIVER_DIAGNOSTIC_TYPE                    DiagnosticType,\r
+  IN  CHAR8                                         *Language,\r
+  OUT EFI_GUID                                      **ErrorType,\r
+  OUT UINTN                                         *BufferSize,\r
+  OUT CHAR16                                        **Buffer\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Runs diagnostics on a controller.\r
+\r
+  Arguments:\r
+    This             - A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOL instance.\r
+    ControllerHandle - The handle of the controller to run diagnostics on.\r
+    ChildHandle      - The handle of the child controller to run diagnostics on  \r
+                       This is an optional parameter that may be NULL.  It will \r
+                       be NULL for device drivers.  It will also be NULL for a \r
+                       bus drivers that wish to run diagnostics on the bus \r
+                       controller.  It will not be NULL for a bus driver that \r
+                       wishes to run diagnostics on one of its child controllers.\r
+    DiagnosticType   - Indicates type of diagnostics to perform on the controller \r
+                       specified by ControllerHandle and ChildHandle.   See \r
+                       "Related Definitions" for the list of supported types.\r
+    Language         - A pointer to a three character ISO 639-2 language \r
+                       identifier or a Null-terminated ASCII string array indicating\r
+                       the language.  This is the language in which the optional\r
+                       error message should be returned in Buffer, and it must \r
+                       match one of the languages specified in SupportedLanguages.\r
+                       The number of languages supported by a driver is up to \r
+                       the driver writer.  \r
+    ErrorType        - A GUID that defines the format of the data returned in \r
+                       Buffer.  \r
+    BufferSize       - The size, in bytes, of the data returned in Buffer.  \r
+    Buffer           - A buffer that contains a Null-terminated Unicode string \r
+                       plus some additional data whose format is defined by \r
+                       ErrorType.  Buffer is allocated by this function with \r
+                       AllocatePool(), and it is the caller's responsibility \r
+                       to free it with a call to FreePool().  \r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The controller specified by ControllerHandle and \r
+                            ChildHandle passed the diagnostic.\r
+    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
+                            EFI_HANDLE.\r
+    EFI_INVALID_PARAMETER - Language is NULL.\r
+    EFI_INVALID_PARAMETER - ErrorType is NULL.\r
+    EFI_INVALID_PARAMETER - BufferType is NULL.\r
+    EFI_INVALID_PARAMETER - Buffer is NULL.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support \r
+                            running diagnostics for the controller specified \r
+                            by ControllerHandle and ChildHandle.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            type of diagnostic specified by DiagnosticType.\r
+    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
+                            language specified by Language.\r
+    EFI_OUT_OF_RESOURCES  - There are not enough resources available to complete\r
+                            the diagnostics.\r
+    EFI_OUT_OF_RESOURCES  - There are not enough resources available to return\r
+                            the status information in ErrorType, BufferSize, \r
+                            and Buffer.\r
+    EFI_DEVICE_ERROR      - The controller specified by ControllerHandle and \r
+                            ChildHandle did not pass the diagnostic.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+  CHAR8                 *SupportedLanguages;\r
+  BOOLEAN               Iso639Language;\r
+  BOOLEAN               Found;\r
+  UINTN                 Index;\r
+\r
+  if (Language         == NULL ||\r
+      ErrorType        == NULL ||\r
+      Buffer           == NULL ||\r
+      ControllerHandle == NULL ||\r
+      BufferSize       == NULL) {\r
+\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  SupportedLanguages = This->SupportedLanguages;\r
+  Iso639Language = (BOOLEAN)(This == &gEmuBlockIoDriverDiagnostics);\r
+  //\r
+  // Make sure Language is in the set of Supported Languages\r
+  //\r
+  Found = FALSE;\r
+  while (*SupportedLanguages != 0) {\r
+    if (Iso639Language) {\r
+      if (CompareMem (Language, SupportedLanguages, 3) == 0) {\r
+        Found = TRUE;\r
+      break;\r
+    }\r
+      SupportedLanguages += 3;\r
+    } else {\r
+      for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);\r
+      if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) {\r
+        Found = TRUE;\r
+        break;\r
+  }\r
+      SupportedLanguages += Index;\r
+      for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);\r
+    }\r
+  }\r
+  //\r
+  // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED\r
+  //\r
+  if (!Found) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  *ErrorType  = NULL;\r
+  *BufferSize = 0;\r
+  if (DiagnosticType != EfiDriverDiagnosticTypeStandard) {\r
+    *ErrorType  = &gEfiBlockIoProtocolGuid;\r
+    *BufferSize = 0x60;\r
+    Buffer = AllocatePool ((UINTN) (*BufferSize));\r
+    CopyMem (*Buffer, L"Windows Block I/O Driver Diagnostics Failed\n", *BufferSize);\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  //\r
+  // This is a device driver, so ChildHandle must be NULL.\r
+  //\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Validate controller handle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&BlockIo,\r
+                  gEmuBlockIoDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEmuIoThunkProtocolGuid,\r
+          gEmuBlockIoDriverBinding.DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  if (Status == EFI_UNSUPPORTED) {\r
+    return Status;\r
+  } else if (Status != EFI_ALREADY_STARTED) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c b/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c
new file mode 100644 (file)
index 0000000..b679d8f
--- /dev/null
@@ -0,0 +1,747 @@
+/**@file\r
+\r
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+bbe\r
+**/\r
+\r
+#include "EmuBlockIo.h"\r
+\r
+\r
+/**\r
+  Reset the block device hardware.\r
+\r
+  @param[in]  This                 Indicates a pointer to the calling context.\r
+  @param[in]  ExtendedVerification Indicates that the driver may perform a more\r
+                                   exhausive verfication operation of the device\r
+                                   during reset.\r
+\r
+  @retval EFI_SUCCESS          The device was reset.\r
+  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
+                               not be reset.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIo2Reset (\r
+  IN EFI_BLOCK_IO2_PROTOCOL  *This,\r
+  IN BOOLEAN                 ExtendedVerification\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_BLOCK_IO_PRIVATE    *Private;\r
+  EFI_TPL                 OldTpl;\r
+\r
+  Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+  Status = Private->Io->Reset (Private->Io, ExtendedVerification);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Read BufferSize bytes from Lba into Buffer.\r
+  \r
+  This function reads the requested number of blocks from the device. All the\r
+  blocks are read, or an error is returned.\r
+  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and\r
+  non-blocking I/O is being used, the Event associated with this request will\r
+  not be signaled.\r
+\r
+  @param[in]       This       Indicates a pointer to the calling context.\r
+  @param[in]       MediaId    Id of the media, changes every time the media is \r
+                              replaced.\r
+  @param[in]       Lba        The starting Logical Block Address to read from.\r
+  @param[in, out]  Token           A pointer to the token associated with the transaction.\r
+  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.  \r
+  @param[out]      Buffer     A pointer to the destination buffer for the data. The \r
+                              caller is responsible for either having implicit or \r
+                              explicit ownership of the buffer.\r
+\r
+  @retval EFI_SUCCESS           The read request was queued if Token->Event is\r
+                                not NULL.The data was read correctly from the\r
+                                device if the Token->Event is NULL.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error while performing\r
+                                the read.\r
+  @retval EFI_NO_MEDIA          There is no media in the device.\r
+  @retval EFI_MEDIA_CHANGED     The MediaId is not for the current media.\r
+  @retval EFI_BAD_BUFFER_SIZE   The BufferSize parameter is not a multiple of the\r
+                                intrinsic block size of the device.\r
+  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
+                                or the buffer is not on proper alignment.\r
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack\r
+                                of resources.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIo2ReadBlocksEx (\r
+  IN     EFI_BLOCK_IO2_PROTOCOL *This,\r
+  IN     UINT32                 MediaId,\r
+  IN     EFI_LBA                LBA,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
+  IN     UINTN                  BufferSize,\r
+     OUT VOID                  *Buffer\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_BLOCK_IO_PRIVATE    *Private;\r
+  EFI_TPL                 OldTpl;\r
+\r
+  Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+  Status = Private->Io->ReadBlocks (Private->Io, MediaId, LBA, Token, BufferSize, Buffer);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Write BufferSize bytes from Lba into Buffer.\r
+\r
+  This function writes the requested number of blocks to the device. All blocks\r
+  are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,\r
+  EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is\r
+  being used, the Event associated with this request will not be signaled.\r
+\r
+  @param[in]       This       Indicates a pointer to the calling context.\r
+  @param[in]       MediaId    The media ID that the write request is for.\r
+  @param[in]       Lba        The starting logical block address to be written. The\r
+                              caller is responsible for writing to only legitimate\r
+                              locations.\r
+  @param[in, out]  Token      A pointer to the token associated with the transaction.\r
+  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.\r
+  @param[in]       Buffer     A pointer to the source buffer for the data.\r
+\r
+  @retval EFI_SUCCESS           The write request was queued if Event is not NULL.\r
+                                The data was written correctly to the device if\r
+                                the Event is NULL.\r
+  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
+  @retval EFI_NO_MEDIA          There is no media in the device.\r
+  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
+  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
+  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
+                                or the buffer is not on proper alignment.\r
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack\r
+                                of resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI \r
+EmuBlockIo2WriteBlocksEx (\r
+  IN     EFI_BLOCK_IO2_PROTOCOL  *This,\r
+  IN     UINT32                 MediaId,\r
+  IN     EFI_LBA                LBA,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
+  IN     UINTN                  BufferSize,\r
+  IN     VOID                   *Buffer\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_BLOCK_IO_PRIVATE    *Private;\r
+  EFI_TPL                 OldTpl;\r
+\r
+  Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+  Status = Private->Io->WriteBlocks (Private->Io, MediaId, LBA, Token, BufferSize, Buffer);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Flush the Block Device.\r
\r
+  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED\r
+  is returned and non-blocking I/O is being used, the Event associated with\r
+  this request will not be signaled.  \r
+\r
+  @param[in]      This     Indicates a pointer to the calling context.\r
+  @param[in,out]  Token    A pointer to the token associated with the transaction\r
+\r
+  @retval EFI_SUCCESS          The flush request was queued if Event is not NULL.\r
+                               All outstanding data was written correctly to the\r
+                               device if the Event is NULL.\r
+  @retval EFI_DEVICE_ERROR     The device reported an error while writting back\r
+                               the data.\r
+  @retval EFI_WRITE_PROTECTED  The device cannot be written to.\r
+  @retval EFI_NO_MEDIA         There is no media in the device.\r
+  @retval EFI_MEDIA_CHANGED    The MediaId is not for the current media.\r
+  @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
+                               of resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIo2Flush (\r
+  IN     EFI_BLOCK_IO2_PROTOCOL   *This,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN      *Token\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_BLOCK_IO_PRIVATE    *Private;\r
+  EFI_TPL                 OldTpl;\r
+\r
+  Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+  Status = Private->Io->FlushBlocks (Private->Io, Token);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Reset the Block Device.\r
+\r
+  @param  This                 Indicates a pointer to the calling context.\r
+  @param  ExtendedVerification Driver may perform diagnostics on reset.\r
+\r
+  @retval EFI_SUCCESS          The device was reset.\r
+  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
+                               not be reset.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoReset (\r
+  IN EFI_BLOCK_IO_PROTOCOL          *This,\r
+  IN BOOLEAN                        ExtendedVerification\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_BLOCK_IO_PRIVATE    *Private;\r
+  EFI_TPL                 OldTpl;\r
+\r
+  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+  Status = Private->Io->Reset (Private->Io, ExtendedVerification);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Read BufferSize bytes from Lba into Buffer.\r
+\r
+  @param  This       Indicates a pointer to the calling context.\r
+  @param  MediaId    Id of the media, changes every time the media is replaced.\r
+  @param  Lba        The starting Logical Block Address to read from\r
+  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
+  @param  Buffer     A pointer to the destination buffer for the data. The caller is\r
+                     responsible for either having implicit or explicit ownership of the buffer.\r
+\r
+  @retval EFI_SUCCESS           The data was read correctly from the device.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error while performing the read.\r
+  @retval EFI_NO_MEDIA          There is no media in the device.\r
+  @retval EFI_MEDIA_CHANGED     The MediaId does not matched the current device.\r
+  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
+  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
+                                or the buffer is not on proper alignment.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoReadBlocks (\r
+  IN EFI_BLOCK_IO_PROTOCOL          *This,\r
+  IN UINT32                         MediaId,\r
+  IN EFI_LBA                        Lba,\r
+  IN UINTN                          BufferSize,\r
+  OUT VOID                          *Buffer\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_BLOCK_IO_PRIVATE    *Private;\r
+  EFI_TPL                 OldTpl;\r
+  EFI_BLOCK_IO2_TOKEN     Token;\r
+\r
+  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+  Token.Event = NULL;\r
+  Status = Private->Io->ReadBlocks (Private->Io, MediaId, Lba, &Token, BufferSize, Buffer);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Write BufferSize bytes from Lba into Buffer.\r
+\r
+  @param  This       Indicates a pointer to the calling context.\r
+  @param  MediaId    The media ID that the write request is for.\r
+  @param  Lba        The starting logical block address to be written. The caller is\r
+                     responsible for writing to only legitimate locations.\r
+  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
+  @param  Buffer     A pointer to the source buffer for the data.\r
+\r
+  @retval EFI_SUCCESS           The data was written correctly to the device.\r
+  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
+  @retval EFI_NO_MEDIA          There is no media in the device.\r
+  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
+  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
+  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
+                                or the buffer is not on proper alignment.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoWriteBlocks (\r
+  IN EFI_BLOCK_IO_PROTOCOL          *This,\r
+  IN UINT32                         MediaId,\r
+  IN EFI_LBA                        Lba,\r
+  IN UINTN                          BufferSize,\r
+  IN VOID                           *Buffer\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_BLOCK_IO_PRIVATE    *Private;\r
+  EFI_TPL                 OldTpl;\r
+  EFI_BLOCK_IO2_TOKEN     Token;\r
+\r
+  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+  Token.Event = NULL;\r
+  Status = Private->Io->WriteBlocks (Private->Io, MediaId, Lba, &Token, BufferSize, Buffer);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Flush the Block Device.\r
+\r
+  @param  This              Indicates a pointer to the calling context.\r
+\r
+  @retval EFI_SUCCESS       All outstanding data was written to the device\r
+  @retval EFI_DEVICE_ERROR  The device reported an error while writting back the data\r
+  @retval EFI_NO_MEDIA      There is no media in the device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoFlushBlocks (\r
+  IN EFI_BLOCK_IO_PROTOCOL  *This\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_BLOCK_IO_PRIVATE    *Private;\r
+  EFI_TPL                 OldTpl;\r
+  EFI_BLOCK_IO2_TOKEN     Token;\r
+\r
+  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+  Token.Event = NULL;\r
+  Status = Private->Io->FlushBlocks (Private->Io, &Token);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Tests to see if this driver supports a given controller. If a child device is provided, \r
+  it further tests to see if this driver supports creating a handle for the specified child device.\r
+\r
+  This function checks to see if the driver specified by This supports the device specified by \r
+  ControllerHandle. Drivers will typically use the device path attached to \r
+  ControllerHandle and/or the services from the bus I/O abstraction attached to \r
+  ControllerHandle to determine if the driver supports ControllerHandle. This function \r
+  may be called many times during platform initialization. In order to reduce boot times, the tests \r
+  performed by this function must be very small, and take as little time as possible to execute. This \r
+  function must not change the state of any hardware devices, and this function must be aware that the \r
+  device specified by ControllerHandle may already be managed by the same driver or a \r
+  different driver. This function must match its calls to AllocatePages() with FreePages(), \r
+  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().  \r
+  Because ControllerHandle may have been previously started by the same driver, if a protocol is \r
+  already in the opened state, then it must not be closed with CloseProtocol(). This is required \r
+  to guarantee the state of ControllerHandle is not modified by this function.\r
+\r
+  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle     The handle of the controller to test. This handle \r
+                                   must support a protocol interface that supplies \r
+                                   an I/O abstraction to the driver.\r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
+                                   parameter is ignored by device drivers, and is optional for bus \r
+                                   drivers. For bus drivers, if this parameter is not NULL, then \r
+                                   the bus driver must determine if the bus controller specified \r
+                                   by ControllerHandle and the child controller specified \r
+                                   by RemainingDevicePath are both supported by this \r
+                                   bus driver.\r
+\r
+  @retval EFI_SUCCESS              The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is supported by the driver specified by This.\r
+  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is already being managed by the driver\r
+                                   specified by This.\r
+  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is already being managed by a different\r
+                                   driver or an application that requires exclusive access.\r
+                                   Currently not implemented.\r
+  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is not supported by the driver specified by This.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_IO_THUNK_PROTOCOL   *EmuIoThunk;\r
+\r
+  //\r
+  // Open the IO Abstraction(s) needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&EmuIoThunk,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Make sure GUID is for a File System handle.\r
+  //\r
+  Status = EFI_UNSUPPORTED;\r
+  if (CompareGuid (EmuIoThunk->Protocol, &gEmuBlockIoProtocolGuid)) {\r
+    Status = EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
+  gBS->CloseProtocol (\r
+        Handle,\r
+        &gEmuIoThunkProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Handle\r
+        );\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Starts a device controller or a bus controller.\r
+\r
+  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
+  As a result, much of the error checking on the parameters to Start() has been moved into this \r
+  common boot service. It is legal to call Start() from other locations, \r
+  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE.\r
+  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
+     EFI_DEVICE_PATH_PROTOCOL.\r
+  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
+     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.  \r
+\r
+  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle     The handle of the controller to start. This handle \r
+                                   must support a protocol interface that supplies \r
+                                   an I/O abstraction to the driver.\r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
+                                   parameter is ignored by device drivers, and is optional for bus \r
+                                   drivers. For a bus driver, if this parameter is NULL, then handles \r
+                                   for all the children of Controller are created by this driver.  \r
+                                   If this parameter is not NULL and the first Device Path Node is \r
+                                   not the End of Device Path Node, then only the handle for the \r
+                                   child device specified by the first Device Path Node of \r
+                                   RemainingDevicePath is created by this driver.\r
+                                   If the first Device Path Node of RemainingDevicePath is \r
+                                   the End of Device Path Node, no child handle is created by this\r
+                                   driver.\r
+\r
+  @retval EFI_SUCCESS              The device was started.\r
+  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.Currently not implemented.\r
+  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
+  @retval Others                   The driver failded to start the device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
+  IN  EFI_HANDLE                    Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EMU_IO_THUNK_PROTOCOL       *EmuIoThunk;\r
+  EMU_BLOCK_IO_PRIVATE        *Private = NULL;\r
+\r
+  //\r
+  // Grab the protocols we need\r
+  //\r
+  \r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (void *)&EmuIoThunk,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  \r
+  if (!CompareGuid (EmuIoThunk->Protocol, &gEmuBlockIoProtocolGuid)) {\r
+    Status = EFI_UNSUPPORTED;\r
+    goto Done;\r
+  }\r
+\r
+  Status = EmuIoThunk->Open (EmuIoThunk);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  Private = AllocatePool (sizeof (EMU_BLOCK_IO_PRIVATE));\r
+  if (Private == NULL) {\r
+    goto Done;\r
+  }\r
+\r
+  Private->Signature = EMU_BLOCK_IO_PRIVATE_SIGNATURE;\r
+  Private->IoThunk   = EmuIoThunk;\r
+  Private->Io        = EmuIoThunk->Interface;\r
+  Private->EfiHandle = Handle;\r
+  \r
+  Private->BlockIo.Revision    = EFI_BLOCK_IO_PROTOCOL_REVISION2;\r
+  Private->BlockIo.Media       = &Private->Media;\r
+  Private->BlockIo.Reset       = EmuBlockIoReset;\r
+  Private->BlockIo.ReadBlocks  = EmuBlockIoReadBlocks;\r
+  Private->BlockIo.WriteBlocks = EmuBlockIoWriteBlocks;\r
+  Private->BlockIo.FlushBlocks = EmuBlockIoFlushBlocks;\r
+\r
+  Private->BlockIo2.Media         = &Private->Media;\r
+  Private->BlockIo2.Reset         = EmuBlockIo2Reset;\r
+  Private->BlockIo2.ReadBlocksEx  = EmuBlockIo2ReadBlocksEx;\r
+  Private->BlockIo2.WriteBlocksEx = EmuBlockIo2WriteBlocksEx;\r
+  Private->BlockIo2.FlushBlocksEx = EmuBlockIo2Flush;\r
+\r
+  Private->ControllerNameTable = NULL;\r
+\r
+  Status = Private->Io->CreateMapping (Private->Io, &Private->Media);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  AddUnicodeString2 (\r
+    "eng",\r
+    gEmuBlockIoComponentName.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    EmuIoThunk->ConfigString,\r
+    TRUE\r
+    );\r
+    \r
+  AddUnicodeString2 (\r
+    "en",\r
+    gEmuBlockIoComponentName2.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    EmuIoThunk->ConfigString,\r
+    FALSE\r
+    );\r
+\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Handle,\r
+                  &gEfiBlockIoProtocolGuid,    &Private->BlockIo,\r
+                  &gEfiBlockIo2ProtocolGuid,   &Private->BlockIo2,\r
+                  NULL\r
+                  );\r
+\r
+Done:\r
+  if (EFI_ERROR (Status)) {\r
+    if (Private != NULL) {\r
+      if (Private->ControllerNameTable != NULL) {\r
+        FreeUnicodeStringTable (Private->ControllerNameTable);\r
+      }\r
+      \r
+      gBS->FreePool (Private);\r
+    \r
+    }\r
+    \r
+    gBS->CloseProtocol (\r
+          Handle,\r
+          &gEmuIoThunkProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          Handle\r
+          );\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Stops a device controller or a bus controller.\r
+  \r
+  The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
+  As a result, much of the error checking on the parameters to Stop() has been moved \r
+  into this common boot service. It is legal to call Stop() from other locations, \r
+  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
+     same driver's Start() function.\r
+  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
+     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
+     Start() function, and the Start() function must have called OpenProtocol() on\r
+     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+  \r
+  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must \r
+                                support a bus specific I/O protocol for the driver \r
+                                to use to stop the device.\r
+  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
+  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL \r
+                                if NumberOfChildren is 0.\r
+\r
+  @retval EFI_SUCCESS           The device was stopped.\r
+  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBlockIoDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+{\r
+  EFI_BLOCK_IO_PROTOCOL   *BlockIo;\r
+  EFI_STATUS              Status;\r
+  EMU_BLOCK_IO_PRIVATE *Private;\r
+\r
+  //\r
+  // Get our context back\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEfiBlockIoProtocolGuid,\r
+                  (void *)&BlockIo,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo);\r
+  Status = Private->IoThunk->Close (Private->IoThunk);\r
+\r
+  Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                  Private->EfiHandle,\r
+                  &gEfiBlockIoProtocolGuid,   &Private->BlockIo,\r
+                  &gEfiBlockIo2ProtocolGuid,  &Private->BlockIo2,\r
+                  NULL\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    Status = gBS->CloseProtocol (\r
+                    Handle,\r
+                    &gEmuIoThunkProtocolGuid,\r
+                    This->DriverBindingHandle,\r
+                    Handle\r
+                    );\r
+  }\r
+  \r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Free our instance data\r
+    //\r
+    FreeUnicodeStringTable (Private->ControllerNameTable);\r
+    gBS->FreePool (Private);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gEmuBlockIoDriverBinding = {\r
+  EmuBlockIoDriverBindingSupported,\r
+  EmuBlockIoDriverBindingStart,\r
+  EmuBlockIoDriverBindingStop,\r
+  0xa,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+\r
+\r
+\r
+/**\r
+  The user Entry Point for module EmuBlockIo . The user code starts with this function.\r
+\r
+  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
+  @param[in] SystemTable    A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
+  @retval other             Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeEmuBlockIo (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+\r
+  Status = EfiLibInstallAllDriverProtocols2 (\r
+             ImageHandle,\r
+             SystemTable,\r
+             &gEmuBlockIoDriverBinding,\r
+             ImageHandle,\r
+             &gEmuBlockIoComponentName,\r
+             &gEmuBlockIoComponentName2,\r
+             NULL,\r
+             NULL,\r
+             &gEmuBlockIoDriverDiagnostics,\r
+             &gEmuBlockIoDriverDiagnostics2\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+\r
diff --git a/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.h b/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.h
new file mode 100644 (file)
index 0000000..b11f305
--- /dev/null
@@ -0,0 +1,84 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  EmuBlockIo.h\r
+\r
+Abstract:\r
+\r
+  Produce block IO abstractions for real devices on your PC using Posix APIs.\r
+  The configuration of what devices to mount or emulate comes from UNIX \r
+  environment variables. The variables must be visible to the Microsoft* \r
+  Developer Studio for them to work.\r
+\r
+  * Other names and brands may be claimed as the property of others.\r
+\r
+**/\r
+\r
+#ifndef _EMU_BLOCK_IO_H_\r
+#define _EMU_BLOCK_IO_H_\r
+\r
+#include <PiDxe.h>\r
+#include <Protocol/EmuIoThunk.h>\r
+#include <Protocol/BlockIo.h>\r
+#include <Protocol/BlockIo2.h>\r
+#include <Protocol/EmuBlockIo.h>\r
+\r
+#include <Guid/EmuPhysicalDisk.h>\r
+#include <Guid/EmuVirtualDisk.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+\r
+//\r
+// Language supported for driverconfiguration protocol\r
+//\r
+\r
+#define EMU_BLOCK_IO_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'M', 'b', 'k')\r
+typedef struct {\r
+  UINTN                       Signature;\r
+  EMU_IO_THUNK_PROTOCOL       *IoThunk;\r
+  EMU_BLOCK_IO_PROTOCOL       *Io;\r
+\r
+  EFI_HANDLE                  EfiHandle;\r
+  EFI_BLOCK_IO_PROTOCOL       BlockIo;\r
+  EFI_BLOCK_IO2_PROTOCOL      BlockIo2;\r
+  EFI_BLOCK_IO_MEDIA          Media;\r
+\r
+  EFI_UNICODE_STRING_TABLE    *ControllerNameTable;\r
+\r
+} EMU_BLOCK_IO_PRIVATE;\r
+\r
+#define EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \\r
+         CR(a, EMU_BLOCK_IO_PRIVATE, BlockIo, EMU_BLOCK_IO_PRIVATE_SIGNATURE)\r
+\r
+#define EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS(a) \\r
+         CR(a, EMU_BLOCK_IO_PRIVATE, BlockIo2, EMU_BLOCK_IO_PRIVATE_SIGNATURE)\r
+\r
+\r
+//\r
+// Block I/O Global Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL        gEmuBlockIoDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL        gEmuBlockIoComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL       gEmuBlockIoComponentName2;\r
+extern EFI_DRIVER_CONFIGURATION_PROTOCOL  gEmuBlockIoDriverConfiguration;\r
+extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL    gEmuBlockIoDriverDiagnostics;\r
+extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL   gEmuBlockIoDriverDiagnostics2;\r
+\r
+#endif\r
diff --git a/EmulatorPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf b/EmulatorPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf
new file mode 100644 (file)
index 0000000..0e07822
--- /dev/null
@@ -0,0 +1,69 @@
+## @file\r
+# Block Io driver\r
+#\r
+# Produce block IO abstractions for real devices on your PC using Unix APIs.\r
+#  The configuration of what devices to mount or emulate comes from\r
+#  environment variables.\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuBlockIo\r
+  FILE_GUID                      = C6760651-A38D-5F4F-AEAF-F6661549DF75\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = InitializeEmuBlockIo\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+#  DRIVER_BINDING                =  gUnixBlockIoDriverBinding                    \r
+#  COMPONENT_NAME                =  gUnixBlockIoComponentName                    \r
+#  DRIVER_DIAG                   =  gUnixBlockIoDriverDiagnostics                \r
+#\r
+\r
+[Sources]\r
+  DriverDiagnostics.c\r
+  DriverConfiguration.c\r
+  ComponentName.c\r
+  EmuBlockIo.c\r
+  EmuBlockIo.h\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  BaseMemoryLib\r
+  UefiLib\r
+  UefiDriverEntryPoint\r
+  BaseLib\r
+  DebugLib\r
+\r
+\r
+[Guids]\r
+  gEmuPhysicalDisksGuid                    # SOMETIMES_CONSUMED\r
+  gEmuVirtualDisksGuid                     # ALWAYS_CONSUMED\r
+\r
+\r
+[Protocols]\r
+  gEfiBlockIoProtocolGuid                     # PROTOCOL BY_START\r
+  gEfiBlockIo2ProtocolGuid                    # PROTOCOL BY_START\r
+  gEmuIoThunkProtocolGuid                     # PROTOCOL TO_START\r
+  gEmuBlockIoProtocolGuid                     # PROTOCOL BY_START\r
diff --git a/EmulatorPkg/EmuBusDriverDxe/ComponentName.c b/EmulatorPkg/EmuBusDriverDxe/ComponentName.c
new file mode 100644 (file)
index 0000000..e8be214
--- /dev/null
@@ -0,0 +1,247 @@
+/** @file\r
+\r
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+**/\r
+\r
+#include "EmuBusDriverDxe.h"\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBusDriverComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBusDriverComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  );\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL     gEmuBusDriverComponentName = {\r
+  EmuBusDriverComponentNameGetDriverName,\r
+  EmuBusDriverComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+//\r
+// EFI Component Name 2 Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2 = {\r
+  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuBusDriverComponentNameGetDriverName,\r
+  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuBusDriverComponentNameGetControllerName,\r
+  "en"\r
+};\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuBusDriverNameTable[] = {\r
+  { "eng", L"Emu Bus Driver" },\r
+  { NULL , NULL }\r
+};\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                driver specified by This in the language\r
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBusDriverComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+{\r
+  return LookupUnicodeString2 (\r
+          Language,\r
+          This->SupportedLanguages,\r
+          mEmuBusDriverNameTable,\r
+          DriverName,\r
+          (BOOLEAN)(This == &gEmuBusDriverComponentName)\r
+          );\r
+}\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the controller\r
+  that is being managed by a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+\r
+  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified in\r
+                                RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBusDriverComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_IO_THUNK_PROTOCOL   *EmuIo;\r
+  EMU_IO_DEVICE           *Private;\r
+\r
+  //\r
+  // Make sure this driver is currently managing ControllHandle\r
+  //\r
+  Status = EfiTestManagedDevice (\r
+             ControllerHandle,\r
+             gEmuBusDriverBinding.DriverBindingHandle,\r
+             &gEmuThunkProtocolGuid\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // This is a bus driver, so ChildHandle can not be NULL.\r
+  //\r
+  if (ChildHandle == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Status = EfiTestChildHandle (\r
+             ControllerHandle,\r
+             ChildHandle,\r
+             &gEmuThunkProtocolGuid\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Get our context back\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ChildHandle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID**)&EmuIo,\r
+                  gEmuBusDriverBinding.DriverBindingHandle,\r
+                  ChildHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = EMU_IO_DEVICE_FROM_THIS (EmuIo);\r
+\r
+  return LookupUnicodeString2 (\r
+           Language,\r
+           This->SupportedLanguages,\r
+           Private->ControllerNameTable,\r
+           ControllerName,\r
+           (BOOLEAN)(This == &gEmuBusDriverComponentName)\r
+          );\r
+}\r
diff --git a/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.c b/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.c
new file mode 100644 (file)
index 0000000..0430ec3
--- /dev/null
@@ -0,0 +1,529 @@
+/** @file\r
+ Emu Bus driver\r
+\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+**/\r
+\r
+#include "EmuBusDriverDxe.h"\r
+\r
+\r
+\r
+//\r
+// DriverBinding protocol global\r
+//\r
+EFI_DRIVER_BINDING_PROTOCOL           gEmuBusDriverBinding = {\r
+  EmuBusDriverBindingSupported,\r
+  EmuBusDriverBindingStart,\r
+  EmuBusDriverBindingStop,\r
+  0xa,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBusDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
+  EMU_THUNK_PROTOCOL        *EmuThunk;\r
+\r
+  //\r
+  // Check the contents of the first Device Path Node of RemainingDevicePath to make sure\r
+  // it is a legal Device Path Node for this bus driver's children.\r
+  //\r
+  if (RemainingDevicePath != NULL) {\r
+    //\r
+    // Check if RemainingDevicePath is the End of Device Path Node, \r
+    // if yes, go on checking other conditions\r
+    //\r
+    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath isn't the End of Device Path Node,\r
+      // check its validation\r
+      //\r
+      if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||\r
+          RemainingDevicePath->SubType != HW_VENDOR_DP ||\r
+          DevicePathNodeLength(RemainingDevicePath) != sizeof(EMU_VENDOR_DEVICE_PATH_NODE)) {\r
+        return EFI_UNSUPPORTED;\r
+      }\r
+    }\r
+  }\r
+  \r
+  //\r
+  // Open the IO Abstraction(s) needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuThunkProtocolGuid,\r
+                  (VOID **)&EmuThunk   ,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (Status == EFI_ALREADY_STARTED) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
+  gBS->CloseProtocol (\r
+        ControllerHandle,\r
+        &gEmuThunkProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        ControllerHandle\r
+        );\r
+\r
+  //\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **)&ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (Status == EFI_ALREADY_STARTED) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+\r
+  //\r
+  // Close protocol, don't use device path protocol in the Support() function\r
+  //\r
+  gBS->CloseProtocol (\r
+        ControllerHandle,\r
+        &gEfiDevicePathProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        ControllerHandle\r
+        );\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBusDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_STATUS                      InstallStatus;\r
+  EMU_THUNK_PROTOCOL              *EmuThunk;\r
+  EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;\r
+  EMU_IO_DEVICE                   *EmuDevice;\r
+  EMU_BUS_DEVICE                  *EmuBusDevice;\r
+  EMU_IO_THUNK_PROTOCOL           *EmuIoThunk;\r
+  UINT16                          ComponentName[512];\r
+  EMU_VENDOR_DEVICE_PATH_NODE     *Node;\r
+  BOOLEAN                         CreateDevice;\r
+\r
+  InstallStatus = EFI_UNSUPPORTED;\r
+  Status = EFI_UNSUPPORTED;\r
+\r
+  //\r
+  // Grab the protocols we need\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **)&ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+    return Status;\r
+  }\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuThunkProtocolGuid,\r
+                  (VOID **)&EmuThunk,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
+    return Status;\r
+  }\r
+\r
+  if (Status != EFI_ALREADY_STARTED) {\r
+    EmuBusDevice = AllocatePool (sizeof (EMU_BUS_DEVICE));\r
+    if (EmuBusDevice == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    EmuBusDevice->Signature           = EMU_BUS_DEVICE_SIGNATURE;\r
+    EmuBusDevice->ControllerNameTable = NULL;\r
+\r
+    AddUnicodeString2 (\r
+      "eng",\r
+      gEmuBusDriverComponentName.SupportedLanguages,\r
+      &EmuBusDevice->ControllerNameTable,\r
+      L"Emulator Bus Controller",\r
+      TRUE\r
+      );\r
+    AddUnicodeString2 (\r
+      "en",\r
+      gEmuBusDriverComponentName2.SupportedLanguages,\r
+      &EmuBusDevice->ControllerNameTable,\r
+      L"Emulator Bus Controller",\r
+      FALSE\r
+      );\r
+\r
+\r
+    Status = gBS->InstallMultipleProtocolInterfaces (\r
+                    &ControllerHandle,\r
+                    &gEfiCallerIdGuid, EmuBusDevice,\r
+                    NULL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      FreeUnicodeStringTable (EmuBusDevice->ControllerNameTable);\r
+      gBS->FreePool (EmuBusDevice);\r
+      return Status;\r
+    }\r
+  }\r
+\r
+\r
+  for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) {\r
+    Status = EmuThunk->GetNextProtocol (TRUE, &EmuIoThunk);\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+\r
+    CreateDevice = TRUE;\r
+    if (RemainingDevicePath != NULL) {\r
+      CreateDevice  = FALSE;\r
+      //\r
+      // Check if RemainingDevicePath is the End of Device Path Node, \r
+      // if yes, don't create any child device \r
+      //\r
+      if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+        //\r
+        // If RemainingDevicePath isn't the End of Device Path Node,\r
+        // check its validation\r
+        //\r
+        Node          = (EMU_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;\r
+        if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&\r
+            Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&\r
+            DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (EMU_VENDOR_DEVICE_PATH_NODE)\r
+            ) {\r
+          if (CompareGuid (&Node->VendorDevicePath.Guid, EmuIoThunk->Protocol) && Node->Instance == EmuIoThunk->Instance) {\r
+            CreateDevice = TRUE;\r
+          }\r
+        }\r
+      }\r
+    }\r
+\r
+    if (CreateDevice) {\r
+      //\r
+      // Allocate instance structure, and fill in parent information.\r
+      //\r
+      EmuDevice = AllocatePool (sizeof (EMU_IO_DEVICE));\r
+      if (EmuDevice == NULL) {\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      EmuDevice->Handle             = NULL;\r
+      EmuDevice->ControllerHandle   = ControllerHandle;\r
+      EmuDevice->ParentDevicePath   = ParentDevicePath;\r
+      CopyMem (&EmuDevice->EmuIoThunk, EmuIoThunk, sizeof (EMU_IO_THUNK_PROTOCOL));\r
+      \r
+      EmuDevice->ControllerNameTable = NULL;\r
+\r
+      StrnCpy (ComponentName, EmuIoThunk->ConfigString, sizeof (ComponentName)/sizeof (CHAR16));\r
+\r
+      EmuDevice->DevicePath = EmuBusCreateDevicePath (\r
+                                  ParentDevicePath,\r
+                                  EmuIoThunk->Protocol,\r
+                                  EmuIoThunk->Instance\r
+                                  );\r
+      if (EmuDevice->DevicePath == NULL) {\r
+        gBS->FreePool (EmuDevice);\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+\r
+      AddUnicodeString (\r
+        "eng",\r
+        gEmuBusDriverComponentName.SupportedLanguages,\r
+        &EmuDevice->ControllerNameTable,\r
+        ComponentName\r
+        );\r
+\r
+      EmuDevice->Signature = EMU_IO_DEVICE_SIGNATURE;\r
+\r
+      InstallStatus = gBS->InstallMultipleProtocolInterfaces (\r
+                            &EmuDevice->Handle,\r
+                            &gEfiDevicePathProtocolGuid,  EmuDevice->DevicePath,\r
+                            &gEmuIoThunkProtocolGuid,     &EmuDevice->EmuIoThunk,\r
+                            NULL\r
+                            );\r
+      if (EFI_ERROR (InstallStatus)) {\r
+        FreeUnicodeStringTable (EmuDevice->ControllerNameTable);\r
+        gBS->FreePool (EmuDevice);\r
+      } else {\r
+        //\r
+        // Open For Child Device\r
+        //\r
+        Status = gBS->OpenProtocol (\r
+                        ControllerHandle,\r
+                        &gEmuThunkProtocolGuid,\r
+                        (VOID **)&EmuThunk   ,\r
+                        This->DriverBindingHandle,\r
+                        EmuDevice->Handle,\r
+                        EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+                        );\r
+        if (!EFI_ERROR (Status)) {\r
+          InstallStatus = EFI_SUCCESS;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return InstallStatus;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBusDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  UINTN                     Index;\r
+  BOOLEAN                   AllChildrenStopped;\r
+  EMU_IO_THUNK_PROTOCOL     *EmuIoThunk;\r
+  EMU_BUS_DEVICE            *EmuBusDevice;\r
+  EMU_IO_DEVICE             *EmuDevice;\r
+  EMU_THUNK_PROTOCOL        *EmuThunk;\r
+\r
+  //\r
+  // Complete all outstanding transactions to Controller.\r
+  // Don't allow any new transaction to Controller to be started.\r
+  //\r
+\r
+  if (NumberOfChildren == 0) {\r
+    //\r
+    // Close the bus driver\r
+    //\r
+    Status = gBS->OpenProtocol (\r
+                    ControllerHandle,\r
+                    &gEfiCallerIdGuid,\r
+                    (VOID **)&EmuBusDevice,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    gBS->UninstallMultipleProtocolInterfaces (\r
+          ControllerHandle,\r
+          &gEfiCallerIdGuid,  EmuBusDevice,\r
+          NULL\r
+          );\r
+\r
+    FreeUnicodeStringTable (EmuBusDevice->ControllerNameTable);\r
+\r
+    gBS->FreePool (EmuBusDevice);\r
+\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEmuThunkProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEfiDevicePathProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  AllChildrenStopped = TRUE;\r
+\r
+  for (Index = 0; Index < NumberOfChildren; Index++) {\r
+\r
+    Status = gBS->OpenProtocol (\r
+                    ChildHandleBuffer[Index],\r
+                    &gEmuIoThunkProtocolGuid,\r
+                    (VOID **)&EmuIoThunk,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      EmuDevice = EMU_IO_DEVICE_FROM_THIS (EmuIoThunk);\r
+\r
+      Status = gBS->CloseProtocol (\r
+                      ControllerHandle,\r
+                      &gEmuThunkProtocolGuid,\r
+                      This->DriverBindingHandle,\r
+                      EmuDevice->Handle\r
+                      );\r
+\r
+      Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                      EmuDevice->Handle,\r
+                      &gEfiDevicePathProtocolGuid,  EmuDevice->DevicePath,\r
+                      &gEmuIoThunkProtocolGuid,     EmuDevice->EmuIoThunk,\r
+                      NULL\r
+                      );\r
+\r
+      if (EFI_ERROR (Status)) {\r
+        gBS->OpenProtocol (\r
+              ControllerHandle,\r
+              &gEmuThunkProtocolGuid,\r
+              (VOID **) &EmuThunk   ,\r
+              This->DriverBindingHandle,\r
+              EmuDevice->Handle,\r
+              EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+              );\r
+      } else {\r
+        //\r
+        // Close the child handle\r
+        //\r
+        FreeUnicodeStringTable (EmuDevice->ControllerNameTable);\r
+        FreePool (EmuDevice);\r
+      }\r
+    }\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      AllChildrenStopped = FALSE;\r
+    }\r
+  }\r
+\r
+  if (!AllChildrenStopped) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Create a device path node using Guid and InstanceNumber and append it to\r
+  the passed in RootDevicePath\r
+\r
+Arguments:\r
+  RootDevicePath - Root of the device path to return.\r
+\r
+  Guid           - GUID to use in vendor device path node.\r
+\r
+  InstanceNumber - Instance number to use in the vendor device path. This\r
+                    argument is needed to make sure each device path is unique.\r
+\r
+Returns:\r
+\r
+  EFI_DEVICE_PATH_PROTOCOL \r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EmuBusCreateDevicePath (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *RootDevicePath,\r
+  IN  EFI_GUID                  *Guid,\r
+  IN  UINT16                    InstanceNumber\r
+  )\r
+{\r
+  EMU_VENDOR_DEVICE_PATH_NODE  DevicePath;\r
+\r
+  DevicePath.VendorDevicePath.Header.Type     = HARDWARE_DEVICE_PATH;\r
+  DevicePath.VendorDevicePath.Header.SubType  = HW_VENDOR_DP;\r
+  SetDevicePathNodeLength (&DevicePath.VendorDevicePath.Header, sizeof (EMU_VENDOR_DEVICE_PATH_NODE));\r
+\r
+  //\r
+  // The GUID defines the Class\r
+  //\r
+  CopyMem (&DevicePath.VendorDevicePath.Guid, Guid, sizeof (EFI_GUID));\r
+\r
+  //\r
+  // Add an instance number so we can make sure there are no Device Path\r
+  // duplication.\r
+  //\r
+  DevicePath.Instance = InstanceNumber;\r
+\r
+  return AppendDevicePathNode (\r
+          RootDevicePath,\r
+          (EFI_DEVICE_PATH_PROTOCOL *) &DevicePath\r
+          );\r
+}\r
+\r
+\r
+\r
+/**\r
+  The user Entry Point for module EmuBusDriver. The user code starts with this function.\r
+\r
+  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
+  @param[in] SystemTable    A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
+  @retval other             Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeEmuBusDriver (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+\r
+  Status = EfiLibInstallAllDriverProtocols (\r
+             ImageHandle,\r
+             SystemTable,\r
+             &gEmuBusDriverBinding,\r
+             ImageHandle,\r
+             &gEmuBusDriverComponentName,\r
+             NULL,\r
+             NULL\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+\r
diff --git a/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.h b/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.h
new file mode 100644 (file)
index 0000000..e5eee56
--- /dev/null
@@ -0,0 +1,116 @@
+/*++ @file\r
+\r
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#ifndef __EMU_BUS_DRIVER_H__\r
+#define __EMU_BUS_DRIVER_H__\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/EmuThunk.h>\r
+#include <Protocol/EmuIoThunk.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+extern EFI_DRIVER_BINDING_PROTOCOL  gEmuBusDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL  gEmuBusDriverComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2;\r
+\r
+\r
+//\r
+// Unix Bus Controller Structure\r
+//\r
+#define EMU_BUS_DEVICE_SIGNATURE SIGNATURE_32 ('L', 'X', 'B', 'D')\r
+\r
+typedef struct {\r
+  UINT64                    Signature;\r
+  EFI_UNICODE_STRING_TABLE  *ControllerNameTable;\r
+} EMU_BUS_DEVICE;\r
+\r
+//\r
+// Unix Child Device Controller Structure\r
+//\r
+#define EMU_IO_DEVICE_SIGNATURE  SIGNATURE_32 ('L', 'X', 'V', 'D')\r
+\r
+typedef struct {\r
+  UINT64                    Signature;\r
+  EFI_HANDLE                Handle;\r
+  EMU_IO_THUNK_PROTOCOL     EmuIoThunk;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+\r
+  //\r
+  // Private data about the parent\r
+  //\r
+  EFI_HANDLE                ControllerHandle;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
+\r
+  EFI_UNICODE_STRING_TABLE  *ControllerNameTable;\r
+\r
+} EMU_IO_DEVICE;\r
+\r
+#define EMU_IO_DEVICE_FROM_THIS(a) \\r
+  CR(a, EMU_IO_DEVICE, EmuIoThunk, EMU_IO_DEVICE_SIGNATURE)\r
+\r
+\r
+\r
+//\r
+// Driver Binding Protocol function prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBusDriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     Handle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  );\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBusDriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     ParentHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
+  );\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuBusDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  );\r
+\r
+//\r
+// Unix Bus Driver private worker functions\r
+//\r
+EFI_DEVICE_PATH_PROTOCOL  *\r
+EmuBusCreateDevicePath (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *RootDevicePath,\r
+  IN  EFI_GUID                  *Guid,\r
+  IN  UINT16                    InstanceNumber\r
+  );\r
+\r
+\r
+#endif\r
diff --git a/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.inf b/EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.inf
new file mode 100644 (file)
index 0000000..44f2af0
--- /dev/null
@@ -0,0 +1,63 @@
+## @file\r
+# Emu Bus driver\r
+#\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuBusDriver\r
+  FILE_GUID                      = 9842073D-95D9-9F49-BD3F-2E29525125DF\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = InitializeEmuBusDriver\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+#  DRIVER_BINDING                =  gEmuBusDriverBinding                        \r
+#  COMPONENT_NAME                =  gEmuBusDriverComponentName                  \r
+#\r
+\r
+[Sources]\r
+  ComponentName.c\r
+  EmuBusDriverDxe.c\r
+  \r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+  DevicePathLib\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  BaseMemoryLib\r
+  PcdLib\r
+  UefiLib\r
+  UefiDriverEntryPoint\r
+  BaseLib\r
+  DebugLib\r
+\r
+\r
+[Protocols]\r
+  gEfiDevicePathProtocolGuid                    # PROTOCOL TO_START\r
+  gEmuThunkProtocolGuid                         # PROTOCOL TO_START\r
+  gEmuIoThunkProtocolGuid                       # PROTOCOL BY_START\r
+\r
+\r
+\r
diff --git a/EmulatorPkg/EmuGopDxe/ComponentName.c b/EmulatorPkg/EmuGopDxe/ComponentName.c
new file mode 100644 (file)
index 0000000..e10f607
--- /dev/null
@@ -0,0 +1,250 @@
+/** @file\r
+\r
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2010,Apple Inc. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  ComponentName.c\r
+\r
+Abstract:\r
+\r
+**/\r
+\r
+#include "Gop.h"\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+EmuGopComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuGopComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  );\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+EFI_COMPONENT_NAME_PROTOCOL     gEmuGopComponentName = {\r
+  EmuGopComponentNameGetDriverName,\r
+  EmuGopComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+//\r
+// EFI Component Name 2 Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2 = {\r
+  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuGopComponentNameGetDriverName,\r
+  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuGopComponentNameGetControllerName,\r
+  "en"\r
+};\r
+\r
+\r
+EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable[] = {\r
+  { "eng", L"Emulator GOP Driver" },\r
+  { NULL , NULL }\r
+};\r
+\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                driver specified by This in the language\r
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuGopComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+{\r
+  return LookupUnicodeString2 (\r
+           Language,\r
+           This->SupportedLanguages,\r
+           mEmuGopDriverNameTable,\r
+           DriverName,\r
+           (BOOLEAN)(This == &gEmuGopComponentName)\r
+           );\r
+}\r
+\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the controller\r
+  that is being managed by a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+\r
+  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified in\r
+                                RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuGopComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  )\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;\r
+  GOP_PRIVATE_DATA              *Private;\r
+\r
+  //\r
+  // This is a device driver, so ChildHandle must be NULL.\r
+  //\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Make sure this driver is currently managing ControllerHandle\r
+  //\r
+  Status = EfiTestManagedDevice (\r
+             ControllerHandle,\r
+             gEmuGopDriverBinding.DriverBindingHandle,\r
+             &gEmuIoThunkProtocolGuid\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Get our context back\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiGraphicsOutputProtocolGuid,\r
+                  (VOID **)&GraphicsOutput,\r
+                  gEmuGopDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);\r
+\r
+  return LookupUnicodeString2 (\r
+           Language,\r
+           This->SupportedLanguages,\r
+           Private->ControllerNameTable,\r
+           ControllerName,\r
+           (BOOLEAN)(This == &gEmuGopComponentName)\r
+           );\r
+}\r
diff --git a/EmulatorPkg/EmuGopDxe/EmuGopDxe.inf b/EmulatorPkg/EmuGopDxe/EmuGopDxe.inf
new file mode 100644 (file)
index 0000000..19c7b2e
--- /dev/null
@@ -0,0 +1,69 @@
+## @file\r
+# GOP driver\r
+#\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuGopDxe\r
+  FILE_GUID                      = BCC87E0D-86D6-4D4D-8040-2D983D368BD1\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = InitializeEmuGop\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+#  DRIVER_BINDING                =  gEmuGopDriverBinding                        \r
+#  COMPONENT_NAME                =  gEmuGopComponentName                        \r
+#\r
+\r
+[Sources]\r
+  ComponentName.c\r
+  GopScreen.c\r
+  GopDriver.c\r
+  GopInput.c\r
+  Gop.h\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  BaseMemoryLib\r
+  UefiLib\r
+  UefiDriverEntryPoint\r
+  BaseLib\r
+  DebugLib\r
+  KeyMapLib\r
+  \r
+\r
+[Guids]\r
+  gEfiEventExitBootServicesGuid                # SOMETIMES_CONSUMED  Create Event: EVENT_GROUP_GUID\r
+\r
+\r
+[Protocols]\r
+  gEfiGraphicsOutputProtocolGuid\r
+  gEfiSimpleTextInProtocolGuid                  # PROTOCOL BY_START\r
+  gEfiSimpleTextInputExProtocolGuid             # PROTOCOL BY_START\r
+  gEfiSimplePointerProtocolGuid                 # PROTOCOL BY_START\r
+  gEmuIoThunkProtocolGuid                       # PROTOCOL TO_START\r
+  gEmuGraphicsWindowProtocolGuid                # PROTOCOL TO_START\r
diff --git a/EmulatorPkg/EmuGopDxe/Gop.h b/EmulatorPkg/EmuGopDxe/Gop.h
new file mode 100644 (file)
index 0000000..03e33ea
--- /dev/null
@@ -0,0 +1,195 @@
+/*++ @file
+
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+Portions copyright (c) 2010,Apple Inc. All rights reserved.<BR>
+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 __UGA_H_
+#define __UGA_H_
+
+#include <PiDxe.h>
+
+#include <Protocol/GraphicsOutput.h>
+#include <Protocol/SimpleTextIn.h>
+#include <Protocol/SimpleTextInEx.h>
+#include <Protocol/SimplePointer.h>
+#include <Protocol/EmuIoThunk.h>
+#include <Protocol/EmuGraphicsWindow.h>
+
+#include <Guid/EventGroup.h>
+
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/KeyMapLib.h>
+
+
+#define MAX_Q 256
+
+typedef struct {
+  UINTN         Front;
+  UINTN         Rear;
+  UINTN         Count;
+  EFI_INPUT_KEY Q[MAX_Q];
+} GOP_QUEUE_FIXED;
+
+#define EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('U', 'g', 'S', 'n')
+typedef struct _EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY {
+  UINTN                                 Signature;
+  EFI_HANDLE                            NotifyHandle;
+  EFI_KEY_DATA                          KeyData;
+  EFI_KEY_NOTIFY_FUNCTION               KeyNotificationFn;
+  EFI_EVENT                             Event;
+  LIST_ENTRY                            NotifyEntry;
+} EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY;
+  
+#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
+
+typedef struct {
+  UINT32                     HorizontalResolution;
+  UINT32                     VerticalResolution;
+  UINT32                     ColorDepth;
+  UINT32                     RefreshRate;
+} GOP_MODE_DATA;
+
+
+
+extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName;
+
+#define EMU_UGA_CLASS_NAME       L"EmuGopWindow"
+
+#define GOP_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('G', 'o', 'p', 'N')
+typedef struct {
+  UINT64                            Signature;
+
+  EFI_HANDLE                        Handle;
+  EFI_GRAPHICS_OUTPUT_PROTOCOL      GraphicsOutput;
+  EFI_SIMPLE_TEXT_INPUT_PROTOCOL    SimpleTextIn;
+  EFI_SIMPLE_POINTER_PROTOCOL       SimplePointer;
+
+  EMU_IO_THUNK_PROTOCOL             *EmuIoThunk;
+  EMU_GRAPHICS_WINDOW_PROTOCOL      *EmuGraphicsWindow;
+
+  EFI_UNICODE_STRING_TABLE          *ControllerNameTable;
+
+  EFI_SIMPLE_POINTER_MODE           PointerMode;
+  //
+  // GOP Private Data for QueryMode ()
+  //
+  GOP_MODE_DATA                     *ModeData;
+
+
+  //
+  // UGA Private Data knowing when to start hardware
+  //
+  BOOLEAN                           HardwareNeedsStarting;
+
+  CHAR16                            *WindowName;
+
+  GOP_QUEUE_FIXED                   Queue;
+
+  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInEx;
+  EFI_KEY_STATE                     KeyState;
+  LIST_ENTRY                        NotifyList;  
+} GOP_PRIVATE_DATA;
+
+
+#define GOP_PRIVATE_DATA_FROM_THIS(a)  \
+         CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE)
+
+#define GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS(a)  \
+         CR(a, GOP_PRIVATE_DATA, SimpleTextIn, GOP_PRIVATE_DATA_SIGNATURE)
+
+#define GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS(a)  \
+         CR(a, GOP_PRIVATE_DATA, SimpleTextInEx, GOP_PRIVATE_DATA_SIGNATURE)
+
+#define GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS(a)  \
+         CR(a, GOP_PRIVATE_DATA, SimplePointer, GOP_PRIVATE_DATA_SIGNATURE)
+
+
+//
+// Global Protocol Variables
+//
+extern EFI_DRIVER_BINDING_PROTOCOL  gEmuGopDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL  gEmuGopComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2;
+
+//
+// Gop Hardware abstraction internal worker functions
+//
+EFI_STATUS
+EmuGopSupported (
+  IN  EMU_IO_THUNK_PROTOCOL  *EmuIoThunk
+  );
+
+EFI_STATUS
+EmuGopConstructor (
+  IN  GOP_PRIVATE_DATA    *Private
+  );
+
+EFI_STATUS
+EmuGopDestructor (
+  IN  GOP_PRIVATE_DATA    *Private
+  );
+
+
+EFI_STATUS
+GopPrivateAddQ (
+  IN  GOP_PRIVATE_DATA    *Private,
+  IN  EFI_INPUT_KEY       Key
+  );
+
+EFI_STATUS
+EmuGopInitializeSimpleTextInForWindow (
+  IN  GOP_PRIVATE_DATA    *Private
+  );
+
+EFI_STATUS
+EmuGopInitializeSimplePointerForWindow (
+  IN  GOP_PRIVATE_DATA    *Private
+  );
+
+EFI_STATUS
+EmuGopStartWindow (
+  IN  GOP_PRIVATE_DATA    *Private,
+  IN  UINT32              HorizontalResolution,
+  IN  UINT32              VerticalResolution,
+  IN  UINT32              ColorDepth,
+  IN  UINT32              RefreshRate
+  );
+
+VOID
+EFIAPI
+ShutdownGopEvent (
+  IN EFI_EVENT  Event,
+  IN VOID       *Context
+  );
+
+VOID
+EFIAPI
+GopPrivateMakeCallbackFunction (
+  IN VOID           *Context,
+  IN EFI_KEY_DATA   *KeyData
+  );
+
+VOID
+EFIAPI
+GopPrivateBreakCallbackFunction (
+  IN VOID           *Context,
+  IN EFI_KEY_DATA   *KeyData
+  );
+
+#endif
diff --git a/EmulatorPkg/EmuGopDxe/GopDriver.c b/EmulatorPkg/EmuGopDxe/GopDriver.c
new file mode 100644 (file)
index 0000000..8ddaa86
--- /dev/null
@@ -0,0 +1,443 @@
+/*++ @file\r
+\r
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2010,Apple Inc. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+**/\r
+\r
+#include "Gop.h"\r
+\r
+\r
+EFI_STATUS\r
+FreeNotifyList (\r
+  IN OUT LIST_ENTRY           *ListHead\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+  ListHead   - The list head\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Free the notify list successfully\r
+  EFI_INVALID_PARAMETER - ListHead is invalid.\r
+\r
+**/\r
+{\r
+  EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *NotifyNode;\r
+\r
+  if (ListHead == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  while (!IsListEmpty (ListHead)) {\r
+    NotifyNode = CR (\r
+                   ListHead->ForwardLink, \r
+                   EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, \r
+                   NotifyEntry, \r
+                   EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE\r
+                   );\r
+    RemoveEntryList (ListHead->ForwardLink);\r
+    gBS->FreePool (NotifyNode);\r
+  }\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Tests to see if this driver supports a given controller. If a child device is provided, \r
+  it further tests to see if this driver supports creating a handle for the specified child device.\r
+\r
+  This function checks to see if the driver specified by This supports the device specified by \r
+  ControllerHandle. Drivers will typically use the device path attached to \r
+  ControllerHandle and/or the services from the bus I/O abstraction attached to \r
+  ControllerHandle to determine if the driver supports ControllerHandle. This function \r
+  may be called many times during platform initialization. In order to reduce boot times, the tests \r
+  performed by this function must be very small, and take as little time as possible to execute. This \r
+  function must not change the state of any hardware devices, and this function must be aware that the \r
+  device specified by ControllerHandle may already be managed by the same driver or a \r
+  different driver. This function must match its calls to AllocatePages() with FreePages(), \r
+  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().  \r
+  Because ControllerHandle may have been previously started by the same driver, if a protocol is \r
+  already in the opened state, then it must not be closed with CloseProtocol(). This is required \r
+  to guarantee the state of ControllerHandle is not modified by this function.\r
+\r
+  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle     The handle of the controller to test. This handle \r
+                                   must support a protocol interface that supplies \r
+                                   an I/O abstraction to the driver.\r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
+                                   parameter is ignored by device drivers, and is optional for bus \r
+                                   drivers. For bus drivers, if this parameter is not NULL, then \r
+                                   the bus driver must determine if the bus controller specified \r
+                                   by ControllerHandle and the child controller specified \r
+                                   by RemainingDevicePath are both supported by this \r
+                                   bus driver.\r
+\r
+  @retval EFI_SUCCESS              The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is supported by the driver specified by This.\r
+  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is already being managed by the driver\r
+                                   specified by This.\r
+  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is already being managed by a different\r
+                                   driver or an application that requires exclusive access.\r
+                                   Currently not implemented.\r
+  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is not supported by the driver specified by This.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuGopDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_IO_THUNK_PROTOCOL   *EmuIoThunk;\r
+\r
+  //\r
+  // Open the IO Abstraction(s) needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&EmuIoThunk,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Status = EmuGopSupported (EmuIoThunk);\r
+\r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
+  gBS->CloseProtocol (\r
+        Handle,\r
+        &gEmuIoThunkProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        Handle\r
+        );\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Starts a device controller or a bus controller.\r
+\r
+  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
+  As a result, much of the error checking on the parameters to Start() has been moved into this \r
+  common boot service. It is legal to call Start() from other locations, \r
+  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE.\r
+  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
+     EFI_DEVICE_PATH_PROTOCOL.\r
+  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
+     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.  \r
+\r
+  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle     The handle of the controller to start. This handle \r
+                                   must support a protocol interface that supplies \r
+                                   an I/O abstraction to the driver.\r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
+                                   parameter is ignored by device drivers, and is optional for bus \r
+                                   drivers. For a bus driver, if this parameter is NULL, then handles \r
+                                   for all the children of Controller are created by this driver.  \r
+                                   If this parameter is not NULL and the first Device Path Node is \r
+                                   not the End of Device Path Node, then only the handle for the \r
+                                   child device specified by the first Device Path Node of \r
+                                   RemainingDevicePath is created by this driver.\r
+                                   If the first Device Path Node of RemainingDevicePath is \r
+                                   the End of Device Path Node, no child handle is created by this\r
+                                   driver.\r
+\r
+  @retval EFI_SUCCESS              The device was started.\r
+  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.Currently not implemented.\r
+  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
+  @retval Others                   The driver failded to start the device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuGopDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
+  IN  EFI_HANDLE                      Handle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
+  )\r
+{\r
+  EMU_IO_THUNK_PROTOCOL   *EmuIoThunk;\r
+  EFI_STATUS              Status;\r
+  GOP_PRIVATE_DATA        *Private;\r
+\r
+  //\r
+  // Grab the protocols we need\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&EmuIoThunk,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Allocate Private context data for SGO inteface.\r
+  //\r
+  Private = NULL;\r
+  Status = gBS->AllocatePool (\r
+                  EfiBootServicesData,\r
+                  sizeof (GOP_PRIVATE_DATA),\r
+                  (VOID **)&Private\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Set up context record\r
+  //\r
+  Private->Signature           = GOP_PRIVATE_DATA_SIGNATURE;\r
+  Private->Handle              = Handle;\r
+  Private->EmuIoThunk          = EmuIoThunk;\r
+  Private->WindowName          = EmuIoThunk->ConfigString;\r
+  Private->ControllerNameTable = NULL;\r
+\r
+  AddUnicodeString (\r
+    "eng",\r
+    gEmuGopComponentName.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    EmuIoThunk->ConfigString\r
+    );\r
+  AddUnicodeString2 (\r
+    "en",\r
+    gEmuGopComponentName2.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    EmuIoThunk->ConfigString,\r
+    FALSE\r
+    );\r
+\r
+  Status = EmuGopConstructor (Private);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Publish the Gop interface to the world\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Private->Handle,\r
+                  &gEfiGraphicsOutputProtocolGuid,    &Private->GraphicsOutput,\r
+                  &gEfiSimpleTextInProtocolGuid,      &Private->SimpleTextIn,\r
+                  &gEfiSimplePointerProtocolGuid,     &Private->SimplePointer,\r
+                  &gEfiSimpleTextInputExProtocolGuid, &Private->SimpleTextInEx,\r
+                  NULL\r
+                  );\r
+\r
+Done:\r
+  if (EFI_ERROR (Status)) {\r
+\r
+    gBS->CloseProtocol (\r
+          Handle,\r
+          &gEmuIoThunkProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          Handle\r
+          );\r
+\r
+    if (Private != NULL) {\r
+      //\r
+      // On Error Free back private data\r
+      //\r
+      if (Private->ControllerNameTable != NULL) {\r
+        FreeUnicodeStringTable (Private->ControllerNameTable);\r
+      }\r
+      if (Private->SimpleTextIn.WaitForKey != NULL) {\r
+        gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);\r
+      }\r
+      if (Private->SimpleTextInEx.WaitForKeyEx != NULL) {\r
+        gBS->CloseEvent (Private->SimpleTextInEx.WaitForKeyEx);\r
+      }\r
+      FreeNotifyList (&Private->NotifyList);\r
+\r
+      gBS->FreePool (Private);\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Stops a device controller or a bus controller.\r
+  \r
+  The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
+  As a result, much of the error checking on the parameters to Stop() has been moved \r
+  into this common boot service. It is legal to call Stop() from other locations, \r
+  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
+     same driver's Start() function.\r
+  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
+     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
+     Start() function, and the Start() function must have called OpenProtocol() on\r
+     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+  \r
+  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must \r
+                                support a bus specific I/O protocol for the driver \r
+                                to use to stop the device.\r
+  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
+  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL \r
+                                if NumberOfChildren is 0.\r
+\r
+  @retval EFI_SUCCESS           The device was stopped.\r
+  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuGopDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   Handle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+{\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+  EFI_STATUS                   Status;\r
+  GOP_PRIVATE_DATA             *Private;\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  Handle,\r
+                  &gEfiGraphicsOutputProtocolGuid,\r
+                  (VOID **)&GraphicsOutput,\r
+                  This->DriverBindingHandle,\r
+                  Handle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // If the GOP interface does not exist the driver is not started\r
+    //\r
+    return EFI_NOT_STARTED;\r
+  }\r
+\r
+  //\r
+  // Get our private context information\r
+  //\r
+  Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);\r
+\r
+  //\r
+  // Remove the SGO interface from the system\r
+  //\r
+  Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                  Private->Handle,\r
+                  &gEfiGraphicsOutputProtocolGuid,    &Private->GraphicsOutput,\r
+                  &gEfiSimpleTextInProtocolGuid,      &Private->SimpleTextIn,\r
+                  &gEfiSimplePointerProtocolGuid,     &Private->SimplePointer,\r
+                  &gEfiSimpleTextInputExProtocolGuid, &Private->SimpleTextInEx,\r
+                  NULL\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Shutdown the hardware\r
+    //\r
+    Status = EmuGopDestructor (Private);\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
+    gBS->CloseProtocol (\r
+          Handle,\r
+          &gEmuIoThunkProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          Handle\r
+          );\r
+\r
+    //\r
+    // Free our instance data\r
+    //\r
+    FreeUnicodeStringTable (Private->ControllerNameTable);\r
+    \r
+    Status = gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);\r
+    ASSERT_EFI_ERROR (Status);\r
+    \r
+    Status = gBS->CloseEvent (Private->SimpleTextInEx.WaitForKeyEx);\r
+    ASSERT_EFI_ERROR (Status);\r
+    \r
+    FreeNotifyList (&Private->NotifyList);\r
+\r
+    gBS->FreePool (Private);\r
+\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+///\r
+/// This protocol provides the services required to determine if a driver supports a given controller. \r
+/// If a controller is supported, then it also provides routines to start and stop the controller.\r
+///\r
+EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding = {\r
+  EmuGopDriverBindingSupported,\r
+  EmuGopDriverBindingStart,\r
+  EmuGopDriverBindingStop,\r
+  0xa,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+\r
+\r
+/**\r
+  The user Entry Point for module EmuGop. The user code starts with this function.\r
+\r
+  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
+  @param[in] SystemTable    A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
+  @retval other             Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeEmuGop (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+\r
+  Status = EfiLibInstallDriverBindingComponentName2 (\r
+             ImageHandle,\r
+             SystemTable,\r
+             &gEmuGopDriverBinding,\r
+             ImageHandle,\r
+             &gEmuGopComponentName,\r
+             &gEmuGopComponentName2\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+  return Status;\r
+}\r
+\r
diff --git a/EmulatorPkg/EmuGopDxe/GopInput.c b/EmulatorPkg/EmuGopDxe/GopInput.c
new file mode 100644 (file)
index 0000000..0bc2eb5
--- /dev/null
@@ -0,0 +1,897 @@
+/*++ @file
+
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Portions copyright (c) 2010 0 2011,Apple Inc. All rights reserved.<BR>
+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 "Gop.h"
+
+
+BOOLEAN
+GopPrivateIsKeyRegistered (
+  IN EFI_KEY_DATA  *RegsiteredData,
+  IN EFI_KEY_DATA  *InputData
+  )
+/*++
+
+Routine Description:
+
+Arguments:
+
+  RegsiteredData    - A pointer to a buffer that is filled in with the keystroke 
+                      state data for the key that was registered.
+  InputData         - A pointer to a buffer that is filled in with the keystroke 
+                      state data for the key that was pressed.
+
+Returns:
+  TRUE              - Key be pressed matches a registered key.
+  FLASE             - Match failed. 
+  
+**/
+{
+  ASSERT (RegsiteredData != NULL && InputData != NULL);
+  
+  if ((RegsiteredData->Key.ScanCode    != InputData->Key.ScanCode) ||
+      (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {
+    return FALSE;  
+  }      
+  
+  //
+  // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
+  //
+  if (RegsiteredData->KeyState.KeyShiftState != 0 &&
+      RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {
+    return FALSE;    
+  }   
+  if (RegsiteredData->KeyState.KeyToggleState != 0 &&
+      RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {
+    return FALSE;    
+  }     
+  
+  return TRUE;
+
+}
+
+
+VOID
+EFIAPI
+GopPrivateMakeCallbackFunction (
+  IN VOID           *Context,
+  IN EFI_KEY_DATA   *KeyData
+  )
+{ 
+  LIST_ENTRY                        *Link;
+  EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY  *CurrentNotify;
+  GOP_PRIVATE_DATA                  *Private = (GOP_PRIVATE_DATA *)Context;
+  
+  KeyMapMake (KeyData);
+
+  for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
+    CurrentNotify = CR (
+                      Link, 
+                      EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, 
+                      NotifyEntry, 
+                      EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
+                      );
+    if (GopPrivateIsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { 
+      // We could be called at a high TPL so signal an event to call the registered function 
+      // at a lower TPL.
+      gBS->SignalEvent (CurrentNotify->Event);
+    }
+  }    
+}
+
+
+VOID
+EFIAPI
+GopPrivateBreakCallbackFunction (
+  IN VOID           *Context,
+  IN EFI_KEY_DATA   *KeyData
+  )
+{ 
+  KeyMapBreak (KeyData);
+}
+
+
+
+//
+// Simple Text In implementation.
+//
+
+/**
+  Reset the input device and optionally run diagnostics
+
+  @param  This                 Protocol instance pointer.
+  @param  ExtendedVerification Driver may perform diagnostics on reset.
+
+  @retval EFI_SUCCESS          The device was reset.
+  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could not be reset.
+
+**/
+EFI_STATUS
+EFIAPI
+EmuGopSimpleTextInReset (
+  IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL       *This,
+  IN BOOLEAN                              ExtendedVerification
+  )
+{
+  GOP_PRIVATE_DATA  *Private;
+  EFI_KEY_DATA      KeyData;
+  EFI_TPL           OldTpl;
+
+  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
+  if (Private->EmuGraphicsWindow == NULL) {
+    return EFI_SUCCESS;
+  }
+
+  //
+  // Enter critical section
+  //
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+  //
+  // A reset is draining the Queue
+  //
+  while (Private->EmuGraphicsWindow->GetKey (Private->EmuGraphicsWindow, &KeyData) == EFI_SUCCESS)
+    ;
+
+  //
+  // Leave critical section and return
+  //
+  gBS->RestoreTPL (OldTpl);
+  return EFI_SUCCESS;
+}
+
+
+/**
+  Reads the next keystroke from the input device. The WaitForKey Event can
+  be used to test for existence of a keystroke via WaitForEvent () call.
+
+  @param  This  Protocol instance pointer.
+  @param  Key   A pointer to a buffer that is filled in with the keystroke
+                information for the key that was pressed.
+
+  @retval EFI_SUCCESS      The keystroke information was returned.
+  @retval EFI_NOT_READY    There was no keystroke data available.
+  @retval EFI_DEVICE_ERROR The keystroke information was not returned due to
+                           hardware errors.
+
+**/
+EFI_STATUS
+EFIAPI
+EmuGopSimpleTextInReadKeyStroke (
+  IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL       *This,
+  OUT EFI_INPUT_KEY                       *Key
+  )
+{
+  GOP_PRIVATE_DATA  *Private;
+  EFI_STATUS        Status;
+  EFI_TPL           OldTpl;
+  EFI_KEY_DATA      KeyData;
+
+  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
+  if (Private->EmuGraphicsWindow == NULL) {
+    return EFI_NOT_READY;
+  }
+
+  //
+  // Enter critical section
+  //
+  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);
+
+  Status  = Private->EmuGraphicsWindow->GetKey (Private->EmuGraphicsWindow, &KeyData);
+  CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY));
+
+  //
+  // Leave critical section and return
+  //
+  gBS->RestoreTPL (OldTpl);
+
+  return Status;
+}
+
+
+
+/**
+  SimpleTextIn and SimpleTextInEx Notify Wait Event 
+
+  @param  Event                 Event whose notification function is being invoked.
+  @param  Context               Pointer to GOP_PRIVATE_DATA.
+
+**/
+VOID
+EFIAPI
+EmuGopSimpleTextInWaitForKey (
+  IN EFI_EVENT          Event,
+  IN VOID               *Context
+  )
+{
+  GOP_PRIVATE_DATA  *Private;
+  EFI_STATUS        Status;
+  EFI_TPL           OldTpl;
+
+  Private = (GOP_PRIVATE_DATA *) Context;
+  if (Private->EmuGraphicsWindow == NULL) {
+    return;
+  }
+
+  //
+  // Enter critical section
+  //
+  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);
+
+  Status  = Private->EmuGraphicsWindow->CheckKey (Private->EmuGraphicsWindow);
+  if (!EFI_ERROR (Status)) {
+    //
+    // If a there is a key in the queue signal our event.
+    //
+    gBS->SignalEvent (Event);
+  }
+  //
+  // Leave critical section and return
+  //
+  gBS->RestoreTPL (OldTpl);
+}
+
+
+//
+// Simple Text Input Ex protocol functions
+//
+
+
+/**
+  The Reset() function resets the input device hardware. As part
+  of initialization process, the firmware/device will make a quick
+  but reasonable attempt to verify that the device is functioning.
+  If the ExtendedVerification flag is TRUE the firmware may take
+  an extended amount of time to verify the device is operating on
+  reset. Otherwise the reset operation is to occur as quickly as
+  possible. The hardware verification process is not defined by
+  this specification and is left up to the platform firmware or
+  driver to implement.
+
+  @param This                 A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
+
+  @param ExtendedVerification Indicates that the driver may
+                              perform a more exhaustive
+                              verification operation of the
+                              device during reset.
+
+
+  @retval EFI_SUCCESS       The device was reset.
+  
+  @retval EFI_DEVICE_ERROR  The device is not functioning
+                            correctly and could not be reset.
+
+**/
+EFI_STATUS
+EFIAPI
+EmuGopSimpleTextInExResetEx (
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,
+  IN BOOLEAN                            ExtendedVerification
+  )
+/*++
+
+  Routine Description:
+    Reset the input device and optionaly run diagnostics
+
+  Arguments:
+    This                 - Protocol instance pointer.
+    ExtendedVerification - Driver may perform diagnostics on reset.
+
+  Returns:
+    EFI_SUCCESS           - The device was reset.
+
+**/
+{
+  GOP_PRIVATE_DATA *Private;
+
+  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This);
+  
+  return EFI_SUCCESS;
+}
+
+
+
+/**
+  The function reads the next keystroke from the input device. If
+  there is no pending keystroke the function returns
+  EFI_NOT_READY. If there is a pending keystroke, then
+  KeyData.Key.ScanCode is the EFI scan code defined in Error!
+  Reference source not found. The KeyData.Key.UnicodeChar is the
+  actual printable character or is zero if the key does not
+  represent a printable character (control key, function key,
+  etc.). The KeyData.KeyState is shift state for the character
+  reflected in KeyData.Key.UnicodeChar or KeyData.Key.ScanCode .
+  When interpreting the data from this function, it should be
+  noted that if a class of printable characters that are
+  normally adjusted by shift modifiers (e.g. Shift Key + "f"
+  key) would be presented solely as a KeyData.Key.UnicodeChar
+  without the associated shift state. So in the previous example
+  of a Shift Key + "f" key being pressed, the only pertinent
+  data returned would be KeyData.Key.UnicodeChar with the value
+  of "F". This of course would not typically be the case for
+  non-printable characters such as the pressing of the Right
+  Shift Key + F10 key since the corresponding returned data
+  would be reflected both in the KeyData.KeyState.KeyShiftState
+  and KeyData.Key.ScanCode values. UEFI drivers which implement
+  the EFI_SIMPLE_TEXT_INPUT_EX protocol are required to return
+  KeyData.Key and KeyData.KeyState values. These drivers must
+  always return the most current state of
+  KeyData.KeyState.KeyShiftState and
+  KeyData.KeyState.KeyToggleState. It should also be noted that
+  certain input devices may not be able to produce shift or toggle
+  state information, and in those cases the high order bit in the
+  respective Toggle and Shift state fields should not be active.
+
+  
+  @param This     A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
+
+  @param KeyData  A pointer to a buffer that is filled in with
+                  the keystroke state data for the key that was
+                  pressed.
+
+  
+  @retval EFI_SUCCESS     The keystroke information was
+                          returned.
+  
+  @retval EFI_NOT_READY   There was no keystroke data available.
+                          EFI_DEVICE_ERROR The keystroke
+                          information was not returned due to
+                          hardware errors.
+
+
+**/
+EFI_STATUS
+EFIAPI
+EmuGopSimpleTextInExReadKeyStrokeEx (
+  IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+  OUT EFI_KEY_DATA                      *KeyData
+  )
+/*++
+
+  Routine Description:
+    Reads the next keystroke from the input device. The WaitForKey Event can 
+    be used to test for existance of a keystroke via WaitForEvent () call.
+
+  Arguments:
+    This       - Protocol instance pointer.
+    KeyData    - A pointer to a buffer that is filled in with the keystroke 
+                 state data for the key that was pressed.
+
+  Returns:
+    EFI_SUCCESS           - The keystroke information was returned.
+    EFI_NOT_READY         - There was no keystroke data availiable.
+    EFI_DEVICE_ERROR      - The keystroke information was not returned due to 
+                            hardware errors.
+    EFI_INVALID_PARAMETER - KeyData is NULL.                        
+
+**/
+{
+  EFI_STATUS        Status;
+  GOP_PRIVATE_DATA  *Private;
+  EFI_TPL           OldTpl;
+
+
+  if (KeyData == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
+  if (Private->EmuGraphicsWindow == NULL) {
+    return EFI_NOT_READY;
+  }
+
+  //
+  // Enter critical section
+  //
+  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);
+
+  Status  = Private->EmuGraphicsWindow->GetKey(Private->EmuGraphicsWindow, KeyData);
+
+  //
+  // Leave critical section and return
+  //
+  gBS->RestoreTPL (OldTpl);
+
+  return Status;
+}
+
+
+
+/**
+  The SetState() function allows the input device hardware to
+  have state settings adjusted.
+  
+  @param This           A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
+  
+  @param KeyToggleState Pointer to the EFI_KEY_TOGGLE_STATE to
+                        set the state for the input device.
+  
+  
+  @retval EFI_SUCCESS       The device state was set appropriately.
+
+  @retval EFI_DEVICE_ERROR  The device is not functioning
+                            correctly and could not have the
+                            setting adjusted.
+
+  @retval EFI_UNSUPPORTED   The device does not support the
+                            ability to have its state set.
+
+**/
+EFI_STATUS
+EFIAPI
+EmuGopSimpleTextInExSetState (
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,
+  IN EFI_KEY_TOGGLE_STATE               *KeyToggleState
+  )
+{
+  GOP_PRIVATE_DATA  *Private;
+  EFI_STATUS        Status;
+  EFI_TPL           OldTpl;
+
+  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
+  if (Private->EmuGraphicsWindow == NULL) {
+    return EFI_NOT_READY;
+  }
+
+  //
+  // Enter critical section
+  //
+  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);
+
+  Status  = Private->EmuGraphicsWindow->KeySetState (Private->EmuGraphicsWindow, KeyToggleState);
+  //
+  // Leave critical section and return
+  //
+  gBS->RestoreTPL (OldTpl);
+
+  return Status;
+}
+
+
+/**
+  SimpleTextIn and SimpleTextInEx Notify Wait Event 
+
+  @param  Event                 Event whose notification function is being invoked.
+  @param  Context               Pointer to GOP_PRIVATE_DATA.
+
+**/
+VOID
+EFIAPI
+EmuGopRegisterKeyCallback (
+  IN EFI_EVENT          Event,
+  IN VOID               *Context
+  )
+{
+  EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *ExNotify = (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *)Context;
+  
+  ExNotify->KeyNotificationFn (&ExNotify->KeyData);
+}
+
+
+
+/**
+  The RegisterKeystrokeNotify() function registers a function
+  which will be called when a specified keystroke will occur.
+  
+  @param This                     A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
+  
+  @param KeyData                  A pointer to a buffer that is filled in with
+                                  the keystroke information for the key that was
+                                  pressed.
+  
+  @param KeyNotificationFunction  Points to the function to be
+                                  called when the key sequence
+                                  is typed specified by KeyData.
+  
+  
+  @param NotifyHandle             Points to the unique handle assigned to
+                                  the registered notification.
+  
+  @retval EFI_SUCCESS           The device state was set
+                                appropriately.
+
+  @retval EFI_OUT_OF_RESOURCES  Unable to allocate necessary
+                                data structures.
+
+**/
+EFI_STATUS
+EFIAPI
+EmuGopSimpleTextInExRegisterKeyNotify (
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,
+  IN EFI_KEY_DATA                       *KeyData,
+  IN EFI_KEY_NOTIFY_FUNCTION            KeyNotificationFunction,
+  OUT EFI_HANDLE                        *NotifyHandle
+  )
+{
+  EFI_STATUS                          Status;
+  GOP_PRIVATE_DATA                    *Private;
+  EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY     *CurrentNotify;
+  LIST_ENTRY                          *Link;
+  EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY     *NewNotify;
+
+  if (KeyData == NULL || KeyNotificationFunction == NULL || NotifyHandle == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This);
+
+  //
+  // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
+  //
+  for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
+    CurrentNotify = CR (
+                      Link, 
+                      EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, 
+                      NotifyEntry, 
+                      EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
+                      );
+    if (GopPrivateIsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { 
+      if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {
+        *NotifyHandle = CurrentNotify->NotifyHandle;
+        return EFI_SUCCESS;
+      }
+    }
+  }    
+  
+  //
+  // Allocate resource to save the notification function
+  //  
+  NewNotify = (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *) AllocateZeroPool (sizeof (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY));
+  if (NewNotify == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  NewNotify->Signature         = EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE;     
+  NewNotify->KeyNotificationFn = KeyNotificationFunction;
+  NewNotify->NotifyHandle      = (EFI_HANDLE) NewNotify;
+  CopyMem (&NewNotify->KeyData, KeyData, sizeof (KeyData));
+  InsertTailList (&Private->NotifyList, &NewNotify->NotifyEntry);
+  
+  Status = gBS->CreateEvent (
+                  EVT_NOTIFY_SIGNAL,
+                  TPL_NOTIFY,
+                  EmuGopRegisterKeyCallback,
+                  NewNotify,
+                  &NewNotify->Event
+                  );
+  ASSERT_EFI_ERROR (Status);
+
+
+  *NotifyHandle = NewNotify->NotifyHandle;  
+  
+  return EFI_SUCCESS;
+  
+}
+
+
+/**
+  The UnregisterKeystrokeNotify() function removes the
+  notification which was previously registered.
+  
+  @param This               A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
+  
+  @param NotificationHandle The handle of the notification
+                            function being unregistered.
+  
+  @retval EFI_SUCCESS The device state was set appropriately.
+  
+  @retval EFI_INVALID_PARAMETER The NotificationHandle is
+                                invalid.
+
+**/
+EFI_STATUS
+EFIAPI
+EmuGopSimpleTextInExUnregisterKeyNotify (
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,
+  IN EFI_HANDLE                         NotificationHandle
+  )
+/*++
+
+  Routine Description:
+    Remove a registered notification function from a particular keystroke.
+
+  Arguments:
+    This                    - Protocol instance pointer.    
+    NotificationHandle      - The handle of the notification function being unregistered.
+
+  Returns:
+    EFI_SUCCESS             - The notification function was unregistered successfully.
+    EFI_INVALID_PARAMETER   - The NotificationHandle is invalid.
+                              
+**/   
+{
+  GOP_PRIVATE_DATA                   *Private;
+  LIST_ENTRY                         *Link;
+  EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify;
+
+  if (NotificationHandle == NULL) {
+    return EFI_INVALID_PARAMETER;
+  } 
+
+  if (((EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *) NotificationHandle)->Signature != EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE) {
+    return EFI_INVALID_PARAMETER;
+  } 
+
+  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This);
+
+  for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
+    CurrentNotify = CR (
+                      Link, 
+                      EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, 
+                      NotifyEntry, 
+                      EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
+                      );       
+    if (CurrentNotify->NotifyHandle == NotificationHandle) {
+      //
+      // Remove the notification function from NotifyList and free resources
+      //
+      RemoveEntryList (&CurrentNotify->NotifyEntry);    
+      
+      gBS->CloseEvent (CurrentNotify->Event);
+
+      gBS->FreePool (CurrentNotify);            
+      return EFI_SUCCESS;
+    }
+  }
+
+  //
+  // Can not find the specified Notification Handle
+  //
+  return EFI_INVALID_PARAMETER;
+}
+
+
+
+/**
+  Initialize SimplelTextIn and SimpleTextInEx protocols in the Private
+  context structure.
+
+  @param  Private               Context structure to fill in. 
+
+  @return EFI_SUCCESS           Initialization was a success
+
+**/
+EFI_STATUS
+EmuGopInitializeSimpleTextInForWindow (
+  IN  GOP_PRIVATE_DATA    *Private
+  )
+{
+  EFI_STATUS  Status;
+
+  //
+  // Initialize Simple Text In protoocol
+  //
+  Private->SimpleTextIn.Reset         = EmuGopSimpleTextInReset;
+  Private->SimpleTextIn.ReadKeyStroke = EmuGopSimpleTextInReadKeyStroke;
+
+  Status = gBS->CreateEvent (
+                  EVT_NOTIFY_WAIT,
+                  TPL_NOTIFY,
+                  EmuGopSimpleTextInWaitForKey,
+                  Private,
+                  &Private->SimpleTextIn.WaitForKey
+                  );
+  ASSERT_EFI_ERROR (Status);
+  
+  
+  //
+  // Initialize Simple Text In Ex
+  //
+  
+  Private->SimpleTextInEx.Reset               = EmuGopSimpleTextInExResetEx;
+  Private->SimpleTextInEx.ReadKeyStrokeEx     = EmuGopSimpleTextInExReadKeyStrokeEx;
+  Private->SimpleTextInEx.SetState            = EmuGopSimpleTextInExSetState;
+  Private->SimpleTextInEx.RegisterKeyNotify   = EmuGopSimpleTextInExRegisterKeyNotify;
+  Private->SimpleTextInEx.UnregisterKeyNotify = EmuGopSimpleTextInExUnregisterKeyNotify;
+
+  Private->SimpleTextInEx.Reset (&Private->SimpleTextInEx, FALSE);
+  
+  InitializeListHead (&Private->NotifyList);
+
+  Status = gBS->CreateEvent (
+                  EVT_NOTIFY_WAIT,
+                  TPL_NOTIFY,
+                  EmuGopSimpleTextInWaitForKey,
+                  Private,
+                  &Private->SimpleTextInEx.WaitForKeyEx
+                  );
+  ASSERT_EFI_ERROR (Status);
+
+
+  return Status;
+}
+
+
+
+
+
+
+
+//
+// Simple Pointer implementation.
+//
+
+
+/**                                                                 
+  Resets the pointer device hardware.
+    
+  @param  This                  A pointer to the EFI_SIMPLE_POINTER_PROTOCOL
+                                instance.                                   
+  @param  ExtendedVerification  Indicates that the driver may perform a more exhaustive
+                                verification operation of the device during reset.                                       
+                                
+  @retval EFI_SUCCESS           The device was reset.
+  @retval EFI_DEVICE_ERROR      The device is not functioning correctly and could not be reset.  
+                                   
+**/
+EFI_STATUS
+EFIAPI
+EmuGopSimplePointerReset (
+  IN EFI_SIMPLE_POINTER_PROTOCOL          *This,
+  IN BOOLEAN                              ExtendedVerification
+  )
+{
+  GOP_PRIVATE_DATA             *Private;
+  EFI_SIMPLE_POINTER_STATE     State;
+  EFI_TPL                      OldTpl;
+
+  Private = GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS (This);
+  if (Private->EmuGraphicsWindow == NULL) {
+    return EFI_SUCCESS;
+  }
+
+  //
+  // Enter critical section
+  //
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+  //
+  // A reset is draining the Queue
+  //
+  while (Private->EmuGraphicsWindow->GetPointerState (Private->EmuGraphicsWindow, &State) == EFI_SUCCESS)
+    ;
+
+  //
+  // Leave critical section and return
+  //
+  gBS->RestoreTPL (OldTpl);
+  return EFI_SUCCESS;
+}
+
+
+/**                                                                 
+  Retrieves the current state of a pointer device.
+    
+  @param  This                  A pointer to the EFI_SIMPLE_POINTER_PROTOCOL
+                                instance.                                   
+  @param  State                 A pointer to the state information on the pointer device.
+                                
+  @retval EFI_SUCCESS           The state of the pointer device was returned in State.
+  @retval EFI_NOT_READY         The state of the pointer device has not changed since the last call to
+                                GetState().                                                           
+  @retval EFI_DEVICE_ERROR      A device error occurred while attempting to retrieve the pointer device's
+                                current state.                                                           
+                                   
+**/
+EFI_STATUS
+EFIAPI
+EmuGopSimplePointerGetState (
+  IN EFI_SIMPLE_POINTER_PROTOCOL          *This,
+  IN OUT EFI_SIMPLE_POINTER_STATE         *State
+  )
+{
+  GOP_PRIVATE_DATA  *Private;
+  EFI_STATUS        Status;
+  EFI_TPL           OldTpl;
+
+  Private = GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS (This);
+  if (Private->EmuGraphicsWindow == NULL) {
+    return EFI_NOT_READY;
+  }
+
+  //
+  // Enter critical section
+  //
+  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);
+
+  Status  = Private->EmuGraphicsWindow->GetPointerState (Private->EmuGraphicsWindow, State);
+  //
+  // Leave critical section and return
+  //
+  gBS->RestoreTPL (OldTpl);
+
+  return Status;
+}
+
+
+/**
+  SimplePointer Notify Wait Event 
+
+  @param  Event                 Event whose notification function is being invoked.
+  @param  Context               Pointer to GOP_PRIVATE_DATA.
+
+**/
+VOID
+EFIAPI
+EmuGopSimplePointerWaitForInput (
+  IN EFI_EVENT          Event,
+  IN VOID               *Context
+  )
+{
+  GOP_PRIVATE_DATA  *Private;
+  EFI_STATUS        Status;
+  EFI_TPL           OldTpl;
+
+  Private = (GOP_PRIVATE_DATA *) Context;
+  if (Private->EmuGraphicsWindow == NULL) {
+    return;
+  }
+
+  //
+  // Enter critical section
+  //
+  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);
+
+  Status  = Private->EmuGraphicsWindow->CheckPointer (Private->EmuGraphicsWindow);
+  if (!EFI_ERROR (Status)) {
+    //
+    // If the pointer state has changed, signal our event.
+    //
+    gBS->SignalEvent (Event);
+  }
+  //
+  // Leave critical section and return
+  //
+  gBS->RestoreTPL (OldTpl);
+}
+
+
+/**
+  SimplePointer constructor 
+
+  @param  Private Context structure to fill in.      
+
+  @retval EFI_SUCCESS Constructor had success        
+
+**/
+EFI_STATUS
+EmuGopInitializeSimplePointerForWindow (
+  IN  GOP_PRIVATE_DATA    *Private
+  )
+{
+  EFI_STATUS  Status;
+
+  //
+  // Initialize Simple Pointer protoocol
+  //
+  Private->PointerMode.ResolutionX = 1;
+  Private->PointerMode.ResolutionY = 1;
+  Private->PointerMode.ResolutionZ = 1;
+  Private->PointerMode.LeftButton  = TRUE;
+  Private->PointerMode.RightButton = TRUE;
+
+  Private->SimplePointer.Reset     = EmuGopSimplePointerReset;
+  Private->SimplePointer.GetState  = EmuGopSimplePointerGetState;
+  Private->SimplePointer.Mode      = &Private->PointerMode;
+
+  Status = gBS->CreateEvent (
+                  EVT_NOTIFY_WAIT,
+                  TPL_NOTIFY,
+                  EmuGopSimplePointerWaitForInput,
+                  Private,
+                  &Private->SimplePointer.WaitForInput
+                  );
+
+  return Status;
+}
diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c b/EmulatorPkg/EmuGopDxe/GopScreen.c
new file mode 100644 (file)
index 0000000..7f4333d
--- /dev/null
@@ -0,0 +1,420 @@
+/*++ @file
+
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Portions 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.
+
+Module Name:
+
+    EmuGopScreen.c
+
+Abstract:
+
+  This file produces the graphics abstration of UGA. It is called by
+  EmuGopDriver.c file which deals with the EFI 1.1 driver model.
+  This file just does graphics.
+
+**/
+
+#include "Gop.h"
+
+
+EFI_EVENT               mGopScreenExitBootServicesEvent;
+
+GOP_MODE_DATA mGopModeData[] = {
+    { 800,  600, 0, 0 },
+    { 640,  480, 0, 0 },
+    { 720,  400, 0, 0 },
+    {1024,  768, 0, 0 },
+    {1280, 1024, 0, 0 }
+    };
+
+
+/**
+  Returns information for an available graphics mode that the graphics device
+  and the set of active video output devices supports.
+
+  @param  This                  The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
+  @param  ModeNumber            The mode number to return information on.
+  @param  SizeOfInfo            A pointer to the size, in bytes, of the Info buffer.
+  @param  Info                  A pointer to callee allocated buffer that returns information about ModeNumber.
+
+  @retval EFI_SUCCESS           Mode information returned.
+  @retval EFI_BUFFER_TOO_SMALL  The Info buffer was too small.
+  @retval EFI_DEVICE_ERROR      A hardware error occurred trying to retrieve the video mode.
+  @retval EFI_NOT_STARTED       Video display is not initialized. Call SetMode ()
+  @retval EFI_INVALID_PARAMETER One of the input args was NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+EmuGopQuerytMode (
+  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL          *This,
+  IN  UINT32                                ModeNumber,
+  OUT UINTN                                 *SizeOfInfo,
+  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  **Info
+  )
+{
+  GOP_PRIVATE_DATA  *Private;
+
+  Private = GOP_PRIVATE_DATA_FROM_THIS (This);
+
+  if (Info == NULL || SizeOfInfo == NULL || (UINTN) ModeNumber >= This->Mode->MaxMode) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  *Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
+  if (*Info == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
+
+  (*Info)->Version = 0;
+  (*Info)->HorizontalResolution = Private->ModeData[ModeNumber].HorizontalResolution;
+  (*Info)->VerticalResolution   = Private->ModeData[ModeNumber].VerticalResolution;
+  (*Info)->PixelFormat = PixelBltOnly;
+  (*Info)->PixelsPerScanLine = (*Info)->HorizontalResolution;
+
+  return EFI_SUCCESS;
+}
+
+
+
+/**
+  Set the video device into the specified mode and clears the visible portions of 
+  the output display to black.
+
+  @param  This              The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
+  @param  ModeNumber        Abstraction that defines the current video mode.
+
+  @retval EFI_SUCCESS       The graphics mode specified by ModeNumber was selected.
+  @retval EFI_DEVICE_ERROR  The device had an error and could not complete the request.
+  @retval EFI_UNSUPPORTED   ModeNumber is not supported by this device.
+
+**/
+EFI_STATUS
+EFIAPI
+EmuGopSetMode (
+  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL  *This,
+  IN  UINT32                        ModeNumber
+  )
+{
+  EFI_STATUS                      Status;
+  GOP_PRIVATE_DATA                *Private;
+  GOP_MODE_DATA                   *ModeData;
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL   Fill;
+
+  Private = GOP_PRIVATE_DATA_FROM_THIS (This);
+
+  if (ModeNumber >= This->Mode->MaxMode) {
+    return EFI_UNSUPPORTED;
+  }
+
+  ModeData = &Private->ModeData[ModeNumber];
+  This->Mode->Mode = ModeNumber;
+  Private->GraphicsOutput.Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;
+  Private->GraphicsOutput.Mode->Info->VerticalResolution = ModeData->VerticalResolution;
+  Private->GraphicsOutput.Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution;
+
+  if (Private->HardwareNeedsStarting) {
+    Status = EmuGopStartWindow (
+              Private,
+              ModeData->HorizontalResolution,
+              ModeData->VerticalResolution,
+              ModeData->ColorDepth,
+              ModeData->RefreshRate
+              );
+    if (EFI_ERROR (Status)) {
+      return EFI_DEVICE_ERROR;
+    }
+
+    Private->HardwareNeedsStarting = FALSE;
+  }
+  
+  
+  Status = Private->EmuGraphicsWindow->Size(
+                            Private->EmuGraphicsWindow,
+                            ModeData->HorizontalResolution,
+                            ModeData->VerticalResolution
+                            );
+
+
+  Fill.Red                      = 0x7f;
+  Fill.Green                    = 0x7F;
+  Fill.Blue                     = 0x7f;
+  This->Blt (
+          This,
+          &Fill,
+          EfiBltVideoFill,
+          0,
+          0,
+          0,
+          0,
+          ModeData->HorizontalResolution,
+          ModeData->VerticalResolution,
+          ModeData->HorizontalResolution * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+          );
+  return EFI_SUCCESS;
+}
+
+
+
+/**
+  Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
+  
+  @param  This         Protocol instance pointer.
+  @param  BltBuffer    Buffer containing data to blit into video buffer. This
+                       buffer has a size of Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+  @param  BltOperation Operation to perform on BlitBuffer and video memory
+  @param  SourceX      X coordinate of source for the BltBuffer.
+  @param  SourceY      Y coordinate of source for the BltBuffer.
+  @param  DestinationX X coordinate of destination for the BltBuffer.
+  @param  DestinationY Y coordinate of destination for the BltBuffer.
+  @param  Width        Width of rectangle in BltBuffer in pixels.
+  @param  Height       Hight of rectangle in BltBuffer in pixels.
+  @param  Delta        OPTIONAL
+
+  @retval EFI_SUCCESS           The Blt operation completed.
+  @retval EFI_INVALID_PARAMETER BltOperation is not valid.
+  @retval EFI_DEVICE_ERROR      A hardware error occured writting to the video buffer.
+
+**/
+EFI_STATUS
+EFIAPI
+EmuGopBlt (
+  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL            *This,
+  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL           *BltBuffer,   OPTIONAL
+  IN  EFI_GRAPHICS_OUTPUT_BLT_OPERATION       BltOperation,
+  IN  UINTN                                   SourceX,
+  IN  UINTN                                   SourceY,
+  IN  UINTN                                   DestinationX,
+  IN  UINTN                                   DestinationY,
+  IN  UINTN                                   Width,
+  IN  UINTN                                   Height,
+  IN  UINTN                                   Delta         OPTIONAL
+  )
+{
+  GOP_PRIVATE_DATA  *Private;
+  EFI_TPL           OriginalTPL;
+  EFI_STATUS        Status;
+  EMU_GRAPHICS_WINDOWS__BLT_ARGS      GopBltArgs;
+
+  Private = GOP_PRIVATE_DATA_FROM_THIS (This);
+
+  if ((BltOperation < 0) || (BltOperation >= EfiGraphicsOutputBltOperationMax)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if (Width == 0 || Height == 0) {
+    return EFI_INVALID_PARAMETER;
+  }
+  //
+  // If Delta is zero, then the entire BltBuffer is being used, so Delta
+  // is the number of bytes in each row of BltBuffer.  Since BltBuffer is Width pixels size,
+  // the number of bytes in each row can be computed.
+  //
+  if (Delta == 0) {
+    Delta = Width * sizeof (EFI_UGA_PIXEL);
+  }
+
+  //
+  // We have to raise to TPL Notify, so we make an atomic write the frame buffer.
+  // We would not want a timer based event (Cursor, ...) to come in while we are
+  // doing this operation.
+  //
+  OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY);
+
+  //
+  // Pack UGA Draw protocol parameters to EMU_GRAPHICS_WINDOWS__BLT_ARGS structure to adapt to
+  // GopBlt() API of Unix UGA IO protocol.
+  //
+  GopBltArgs.DestinationX = DestinationX;
+  GopBltArgs.DestinationY = DestinationY;
+  GopBltArgs.Height       = Height;
+  GopBltArgs.Width        = Width;
+  GopBltArgs.SourceX      = SourceX;
+  GopBltArgs.SourceY      = SourceY;
+  GopBltArgs.Delta        = Delta;
+  Status = Private->EmuGraphicsWindow->Blt (
+                            Private->EmuGraphicsWindow,
+                            (EFI_UGA_PIXEL *)BltBuffer,
+                            (EFI_UGA_BLT_OPERATION)BltOperation,
+                            &GopBltArgs
+                            );
+
+  gBS->RestoreTPL (OriginalTPL);
+
+  return Status;
+}
+
+
+//
+// Construction and Destruction functions
+//
+
+EFI_STATUS
+EmuGopSupported (
+  IN  EMU_IO_THUNK_PROTOCOL  *EmuIoThunk
+  )
+{
+  //
+  // Check to see if the IO abstraction represents a device type we support.
+  //
+  // This would be replaced a check of PCI subsystem ID, etc.
+  //
+  if (!CompareGuid (EmuIoThunk->Protocol, &gEmuGraphicsWindowProtocolGuid)) {
+    return EFI_UNSUPPORTED;
+  }
+
+  return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EmuGopStartWindow (
+  IN  GOP_PRIVATE_DATA    *Private,
+  IN  UINT32              HorizontalResolution,
+  IN  UINT32              VerticalResolution,
+  IN  UINT32              ColorDepth,
+  IN  UINT32              RefreshRate
+  )
+{
+  EFI_STATUS          Status;
+
+  //
+  // Register to be notified on exit boot services so we can destroy the window.
+  //
+  Status = gBS->CreateEvent (
+                  EVT_SIGNAL_EXIT_BOOT_SERVICES,
+                  TPL_CALLBACK,
+                  ShutdownGopEvent,
+                  Private,
+                  &mGopScreenExitBootServicesEvent
+                  );
+
+  Status = Private->EmuIoThunk->Open (Private->EmuIoThunk);
+  if (!EFI_ERROR (Status)) {
+    Private->EmuGraphicsWindow = Private->EmuIoThunk->Interface;
+    
+    // Register callback to support RegisterKeyNotify()
+    Status  = Private->EmuGraphicsWindow->RegisterKeyNotify (
+                                            Private->EmuGraphicsWindow, 
+                                            GopPrivateMakeCallbackFunction, 
+                                            GopPrivateBreakCallbackFunction, 
+                                            Private
+                                            );
+    ASSERT_EFI_ERROR (Status);
+  }
+  return Status;
+}
+
+EFI_STATUS
+EmuGopConstructor (
+  GOP_PRIVATE_DATA    *Private
+  )
+{
+  Private->ModeData = mGopModeData;
+
+  Private->GraphicsOutput.QueryMode      = EmuGopQuerytMode;
+  Private->GraphicsOutput.SetMode        = EmuGopSetMode;
+  Private->GraphicsOutput.Blt            = EmuGopBlt;
+
+  //
+  // Allocate buffer for Graphics Output Protocol mode information
+  //
+  Private->GraphicsOutput.Mode = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE));
+  if (Private->GraphicsOutput.Mode == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+  Private->GraphicsOutput.Mode->Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
+  if (Private->GraphicsOutput.Mode->Info == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  Private->GraphicsOutput.Mode->MaxMode = sizeof(mGopModeData) / sizeof(GOP_MODE_DATA);
+  //
+  // Till now, we have no idea about the window size.
+  //
+  Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;
+  Private->GraphicsOutput.Mode->Info->Version = 0;
+  Private->GraphicsOutput.Mode->Info->HorizontalResolution = 0;
+  Private->GraphicsOutput.Mode->Info->VerticalResolution = 0;
+  Private->GraphicsOutput.Mode->Info->PixelFormat = PixelBltOnly;
+  Private->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
+  Private->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL;
+  Private->GraphicsOutput.Mode->FrameBufferSize = 0;
+
+  Private->HardwareNeedsStarting  = TRUE;
+  Private->EmuGraphicsWindow                  = NULL;
+
+  EmuGopInitializeSimpleTextInForWindow (Private);
+
+  EmuGopInitializeSimplePointerForWindow (Private);
+
+  return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+EmuGopDestructor (
+  GOP_PRIVATE_DATA     *Private
+  )
+{
+  EFI_STATUS  Status;
+  
+  Status = EFI_SUCCESS;
+  if (!Private->HardwareNeedsStarting) {
+    Status = Private->EmuIoThunk->Close (Private->EmuIoThunk);
+    Private->EmuGraphicsWindow = NULL;
+  }
+
+  //
+  // Free graphics output protocol occupied resource
+  //
+  if (Private->GraphicsOutput.Mode != NULL) {
+    if (Private->GraphicsOutput.Mode->Info != NULL) {
+      FreePool (Private->GraphicsOutput.Mode->Info);
+    }
+    FreePool (Private->GraphicsOutput.Mode);
+  }
+
+  return EFI_SUCCESS;
+}
+
+
+VOID
+EFIAPI
+ShutdownGopEvent (
+  IN EFI_EVENT  Event,
+  IN VOID       *Context
+  )
+/*++
+
+Routine Description:
+
+  This is the UGA screen's callback notification function for exit-boot-services.
+  All we do here is call EmuGopDestructor().
+
+Arguments:
+
+  Event   - not used
+  Context - pointer to the Private structure.
+
+Returns:
+
+  None.
+
+**/
+{
+  EFI_STATUS  Status;
+  Status = EmuGopDestructor (Context);
+}
+
diff --git a/EmulatorPkg/EmuSimpleFileSystemDxe/ComponentName.c b/EmulatorPkg/EmuSimpleFileSystemDxe/ComponentName.c
new file mode 100644 (file)
index 0000000..fa6404a
--- /dev/null
@@ -0,0 +1,244 @@
+/** @file\r
+\r
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#include "EmuSimpleFileSystem.h"\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                                        *This,\r
+  IN  EFI_HANDLE                                                         ControllerHandle,\r
+  IN  EFI_HANDLE                                                         ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                                              *Language,\r
+  OUT CHAR16                                                             **ControllerName\r
+  );\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gEmuSimpleFileSystemComponentName = {\r
+  EmuSimpleFileSystemComponentNameGetDriverName,\r
+  EmuSimpleFileSystemComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL  gEmuSimpleFileSystemComponentName2 = {\r
+  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuSimpleFileSystemComponentNameGetDriverName,\r
+  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuSimpleFileSystemComponentNameGetControllerName,\r
+  "en"\r
+};\r
+\r
+EFI_UNICODE_STRING_TABLE mEmuSimpleFileSystemDriverNameTable[] = {\r
+  {\r
+    "eng;en",\r
+    L"Emu Simple File System Driver"\r
+  },\r
+  {\r
+    NULL,\r
+    NULL\r
+  }\r
+};\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                driver specified by This in the language\r
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+{\r
+  return LookupUnicodeString2 (\r
+          Language,\r
+          This->SupportedLanguages,\r
+          mEmuSimpleFileSystemDriverNameTable,\r
+          DriverName,\r
+          (BOOLEAN)(This == &gEmuSimpleFileSystemComponentName)\r
+          );\r
+}\r
+\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the controller\r
+  that is being managed by a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+\r
+  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified in\r
+                                RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                                        *This,\r
+  IN  EFI_HANDLE                                                         ControllerHandle,\r
+  IN  EFI_HANDLE                                                         ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                                              *Language,\r
+  OUT CHAR16                                                             **ControllerName\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL   *SimpleFileSystem;\r
+  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *Private;\r
+\r
+  //\r
+  // This is a device driver, so ChildHandle must be NULL.\r
+  //\r
+  if (ChildHandle != NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Make sure this driver is currently managing ControllerHandle\r
+  //\r
+  Status = EfiTestManagedDevice (\r
+             ControllerHandle,\r
+             gEmuSimpleFileSystemDriverBinding.DriverBindingHandle,\r
+             &gEmuIoThunkProtocolGuid\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Get our context back\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiSimpleFileSystemProtocolGuid,\r
+                  (VOID**)&SimpleFileSystem,\r
+                  gEmuSimpleFileSystemDriverBinding.DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem);\r
+\r
+  return LookupUnicodeString2 (\r
+          Language,\r
+          This->SupportedLanguages,\r
+          Private->ControllerNameTable,\r
+          ControllerName,\r
+          (BOOLEAN)(This == &gEmuSimpleFileSystemComponentName)\r
+          );\r
+}\r
diff --git a/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c b/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
new file mode 100644 (file)
index 0000000..551b543
--- /dev/null
@@ -0,0 +1,915 @@
+/*++ @file\r
+  Produce Simple File System abstractions for directories on your PC using Posix APIs.\r
+  The configuration of what devices to mount or emulate comes from UNIX \r
+  environment variables. The variables must be visible to the Microsoft* \r
+  Developer Studio for them to work.\r
+\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "EmuSimpleFileSystem.h"\r
+\r
+\r
+\r
+\r
+/**\r
+  Opens a new file relative to the source file's location.\r
+\r
+  @param  This       The protocol instance pointer.\r
+  @param  NewHandle  Returns File Handle for FileName.\r
+  @param  FileName   Null terminated string. "\", ".", and ".." are supported.\r
+  @param  OpenMode   Open mode for file.\r
+  @param  Attributes Only used for EFI_FILE_MODE_CREATE.\r
+\r
+  @retval EFI_SUCCESS          The device was opened.\r
+  @retval EFI_NOT_FOUND        The specified file could not be found on the device.\r
+  @retval EFI_NO_MEDIA         The device has no media.\r
+  @retval EFI_MEDIA_CHANGED    The media has changed.\r
+  @retval EFI_DEVICE_ERROR     The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+  @retval EFI_ACCESS_DENIED    The service denied access to the file.\r
+  @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.\r
+  @retval EFI_VOLUME_FULL      The volume is full.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemOpen (\r
+  IN  EFI_FILE_PROTOCOL   *This,\r
+  OUT EFI_FILE_PROTOCOL   **NewHandle,\r
+  IN  CHAR16              *FileName,\r
+  IN  UINT64              OpenMode,\r
+  IN  UINT64              Attributes\r
+  )\r
+{\r
+  EMU_EFI_FILE_PRIVATE              *PrivateFile;\r
+\r
+  //\r
+  // Check for obvious invalid parameters.\r
+  //\r
+  if (This == NULL || NewHandle == NULL || FileName == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  switch (OpenMode) {\r
+  case EFI_FILE_MODE_CREATE | EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:\r
+    if (Attributes &~EFI_FILE_VALID_ATTR) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    if (Attributes & EFI_FILE_READ_ONLY) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+  //\r
+  // fall through\r
+  //\r
+  case EFI_FILE_MODE_READ:\r
+  case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:\r
+    break;\r
+\r
+  default:\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  PrivateFile     = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return PrivateFile->Io->Open (PrivateFile->Io, NewHandle, FileName, OpenMode, Attributes);\r
+}\r
+\r
+\r
+\r
+/**\r
+  Close the file handle\r
+\r
+  @param  This          Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS   The file was closed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemClose (\r
+  IN EFI_FILE_PROTOCOL  *This\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_EFI_FILE_PRIVATE    *PrivateFile;\r
+  EFI_TPL                 OldTpl;\r
+\r
+  if (This == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+  Status = PrivateFile->Io->Close (PrivateFile->Io);\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->FreePool (PrivateFile);\r
+  }\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  \r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Close and delete the file handle.\r
+\r
+  @param  This                     Protocol instance pointer.\r
+                                   \r
+  @retval EFI_SUCCESS              The file was closed and deleted.\r
+  @retval EFI_WARN_DELETE_FAILURE  The handle was closed but the file was not deleted.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemDelete (\r
+  IN EFI_FILE_PROTOCOL  *This\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_EFI_FILE_PRIVATE    *PrivateFile;\r
+  EFI_TPL                 OldTpl;\r
+\r
+  if (This == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+  \r
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status = PrivateFile->Io->Delete (PrivateFile->Io);\r
+  if (!EFI_ERROR (Status)) {\r
+    gBS->FreePool (PrivateFile);\r
+  }\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Read data from the file.\r
+\r
+  @param  This       Protocol instance pointer.\r
+  @param  BufferSize On input size of buffer, on output amount of data in buffer.\r
+  @param  Buffer     The buffer in which data is read.\r
+\r
+  @retval EFI_SUCCESS          Data was read.\r
+  @retval EFI_NO_MEDIA         The device has no media.\r
+  @retval EFI_DEVICE_ERROR     The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+  @retval EFI_BUFFER_TO_SMALL  BufferSize is too small. BufferSize contains required size.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemRead (\r
+  IN     EFI_FILE_PROTOCOL  *This,\r
+  IN OUT UINTN              *BufferSize,\r
+  OUT    VOID               *Buffer\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_EFI_FILE_PRIVATE    *PrivateFile;\r
+  EFI_TPL                 OldTpl;\r
+\r
+  if (This == NULL || BufferSize == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  if ((*BufferSize != 0) && (Buffer == NULL)) {\r
+    // Buffer can be NULL  if *BufferSize is zero\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+  \r
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status = PrivateFile->Io->Read (PrivateFile->Io, BufferSize, Buffer);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Write data to a file.\r
+\r
+  @param  This       Protocol instance pointer.\r
+  @param  BufferSize On input size of buffer, on output amount of data in buffer.\r
+  @param  Buffer     The buffer in which data to write.\r
+\r
+  @retval EFI_SUCCESS          Data was written.\r
+  @retval EFI_UNSUPPORTED      Writes to Open directory are not supported.\r
+  @retval EFI_NO_MEDIA         The device has no media.\r
+  @retval EFI_DEVICE_ERROR     The device reported an error.\r
+  @retval EFI_DEVICE_ERROR     An attempt was made to write to a deleted file.\r
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+  @retval EFI_WRITE_PROTECTED  The device is write protected.\r
+  @retval EFI_ACCESS_DENIED    The file was open for read only.\r
+  @retval EFI_VOLUME_FULL      The volume is full.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemWrite (\r
+  IN     EFI_FILE_PROTOCOL  *This,\r
+  IN OUT UINTN              *BufferSize,\r
+  IN     VOID               *Buffer\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EMU_EFI_FILE_PRIVATE *PrivateFile;\r
+  EFI_TPL               OldTpl;\r
+\r
+  if (This == NULL || BufferSize == NULL || Buffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status = PrivateFile->Io->Write (PrivateFile->Io, BufferSize, Buffer);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Set a files current position\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  Position        Byte position from the start of the file.\r
+                          \r
+  @retval EFI_SUCCESS     Position was updated.\r
+  @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemGetPosition (\r
+  IN  EFI_FILE_PROTOCOL   *This,\r
+  OUT UINT64              *Position\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EMU_EFI_FILE_PRIVATE *PrivateFile;\r
+  EFI_TPL               OldTpl;\r
+\r
+  if (This == NULL || Position == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+  \r
+  PrivateFile   = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status = PrivateFile->Io->GetPosition (PrivateFile->Io, Position);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Get a file's current position\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  Position        Byte position from the start of the file.\r
+                          \r
+  @retval EFI_SUCCESS     Position was updated.\r
+  @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open..\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemSetPosition (\r
+  IN EFI_FILE_PROTOCOL  *This,\r
+  IN UINT64             Position\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_EFI_FILE_PRIVATE    *PrivateFile;\r
+  EFI_TPL                 OldTpl;\r
+\r
+  if (This == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+  \r
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status = PrivateFile->Io->SetPosition (PrivateFile->Io, Position);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Get information about a file.\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  InformationType Type of information to return in Buffer.\r
+  @param  BufferSize      On input size of buffer, on output amount of data in buffer.\r
+  @param  Buffer          The buffer to return data.\r
+\r
+  @retval EFI_SUCCESS          Data was returned.\r
+  @retval EFI_UNSUPPORTED      InformationType is not supported.\r
+  @retval EFI_NO_MEDIA         The device has no media.\r
+  @retval EFI_DEVICE_ERROR     The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+  @retval EFI_WRITE_PROTECTED  The device is write protected.\r
+  @retval EFI_ACCESS_DENIED    The file was open for read only.\r
+  @retval EFI_BUFFER_TOO_SMALL Buffer was too small; required size returned in BufferSize.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemGetInfo (\r
+  IN     EFI_FILE_PROTOCOL  *This,\r
+  IN     EFI_GUID           *InformationType,\r
+  IN OUT UINTN              *BufferSize,\r
+  OUT    VOID               *Buffer\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  EMU_EFI_FILE_PRIVATE              *PrivateFile;\r
+  EFI_TPL                           OldTpl;\r
+\r
+  if (This == NULL || InformationType == NULL || BufferSize == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+    \r
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status = PrivateFile->Io->GetInfo (PrivateFile->Io, InformationType, BufferSize, Buffer);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Set information about a file\r
+\r
+  @param  File            Protocol instance pointer.\r
+  @param  InformationType Type of information in Buffer.\r
+  @param  BufferSize      Size of buffer.\r
+  @param  Buffer          The data to write.\r
+\r
+  @retval EFI_SUCCESS          Data was set.\r
+  @retval EFI_UNSUPPORTED      InformationType is not supported.\r
+  @retval EFI_NO_MEDIA         The device has no media.\r
+  @retval EFI_DEVICE_ERROR     The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+  @retval EFI_WRITE_PROTECTED  The device is write protected.\r
+  @retval EFI_ACCESS_DENIED    The file was open for read only.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemSetInfo (\r
+  IN EFI_FILE_PROTOCOL*This,\r
+  IN EFI_GUID         *InformationType,\r
+  IN UINTN            BufferSize,\r
+  IN VOID             *Buffer\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  EMU_EFI_FILE_PRIVATE              *PrivateFile;\r
+  EFI_TPL                           OldTpl;\r
+\r
+  //\r
+  // Check for invalid parameters.\r
+  //\r
+  if (This == NULL || InformationType == NULL || BufferSize == 0 || Buffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+  \r
+  PrivateFile               = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status = PrivateFile->Io->SetInfo (PrivateFile->Io, InformationType, BufferSize, Buffer);\r
+\r
+  gBS->RestoreTPL (OldTpl);  \r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Flush data back for the file handle.\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS          Data was flushed.\r
+  @retval EFI_UNSUPPORTED      Writes to Open directory are not supported.\r
+  @retval EFI_NO_MEDIA         The device has no media.\r
+  @retval EFI_DEVICE_ERROR     The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+  @retval EFI_WRITE_PROTECTED  The device is write protected.\r
+  @retval EFI_ACCESS_DENIED    The file was open for read only.\r
+  @retval EFI_VOLUME_FULL      The volume is full.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemFlush (\r
+  IN EFI_FILE_PROTOCOL  *This\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EMU_EFI_FILE_PRIVATE      *PrivateFile;\r
+  EFI_TPL                   OldTpl;\r
+\r
+  if (This == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+  \r
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status = PrivateFile->Io->Flush (PrivateFile->Io);\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Open the root directory on a volume.\r
+\r
+  @param  This Protocol instance pointer.\r
+  @param  Root Returns an Open file handle for the root directory\r
+\r
+  @retval EFI_SUCCESS          The device was opened.\r
+  @retval EFI_UNSUPPORTED      This volume does not support the file system.\r
+  @retval EFI_NO_MEDIA         The device has no media.\r
+  @retval EFI_DEVICE_ERROR     The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+  @retval EFI_ACCESS_DENIED    The service denied access to the file.\r
+  @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemOpenVolume (\r
+  IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL  *This,\r
+  OUT EFI_FILE_PROTOCOL               **Root\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *Private;\r
+  EMU_EFI_FILE_PRIVATE              *PrivateFile;\r
+  EFI_TPL                           OldTpl;\r
+\r
+  Status = EFI_UNSUPPORTED;\r
+\r
+  if (This == NULL || Root == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
+  Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  PrivateFile = AllocatePool (sizeof (EMU_EFI_FILE_PRIVATE));\r
+  if (PrivateFile == NULL) {\r
+    goto Done;\r
+  }\r
+  \r
+  PrivateFile->Signature            = EMU_EFI_FILE_PRIVATE_SIGNATURE;\r
+  PrivateFile->IoThunk              = Private->IoThunk;\r
+  PrivateFile->SimpleFileSystem     = This;\r
+  PrivateFile->EfiFile.Revision     = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION;\r
+  PrivateFile->EfiFile.Open         = EmuSimpleFileSystemOpen;\r
+  PrivateFile->EfiFile.Close        = EmuSimpleFileSystemClose;\r
+  PrivateFile->EfiFile.Delete       = EmuSimpleFileSystemDelete;\r
+  PrivateFile->EfiFile.Read         = EmuSimpleFileSystemRead;\r
+  PrivateFile->EfiFile.Write        = EmuSimpleFileSystemWrite;\r
+  PrivateFile->EfiFile.GetPosition  = EmuSimpleFileSystemGetPosition;\r
+  PrivateFile->EfiFile.SetPosition  = EmuSimpleFileSystemSetPosition;\r
+  PrivateFile->EfiFile.GetInfo      = EmuSimpleFileSystemGetInfo;\r
+  PrivateFile->EfiFile.SetInfo      = EmuSimpleFileSystemSetInfo;\r
+  PrivateFile->EfiFile.Flush        = EmuSimpleFileSystemFlush;\r
+\r
+  *Root = &PrivateFile->EfiFile;\r
+\r
+  Status = Private->Io->OpenVolume (Private->Io, &PrivateFile->Io);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+  \r
+  AddUnicodeString2 (\r
+    "eng",\r
+    gEmuSimpleFileSystemComponentName.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    Private->IoThunk->ConfigString,\r
+    TRUE\r
+    );\r
+\r
+  AddUnicodeString2 (\r
+    "en",\r
+    gEmuSimpleFileSystemComponentName.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    Private->IoThunk->ConfigString,\r
+    FALSE\r
+    );\r
+\r
+\r
+Done:\r
+  if (EFI_ERROR (Status)) {\r
+    if (PrivateFile) {\r
+      gBS->FreePool (PrivateFile);\r
+    }\r
+    \r
+    *Root = NULL;\r
+  }\r
+\r
+  gBS->RestoreTPL (OldTpl);\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Tests to see if this driver supports a given controller. If a child device is provided, \r
+  it further tests to see if this driver supports creating a handle for the specified child device.\r
+\r
+  This function checks to see if the driver specified by This supports the device specified by \r
+  ControllerHandle. Drivers will typically use the device path attached to \r
+  ControllerHandle and/or the services from the bus I/O abstraction attached to \r
+  ControllerHandle to determine if the driver supports ControllerHandle. This function \r
+  may be called many times during platform initialization. In order to reduce boot times, the tests \r
+  performed by this function must be very small, and take as little time as possible to execute. This \r
+  function must not change the state of any hardware devices, and this function must be aware that the \r
+  device specified by ControllerHandle may already be managed by the same driver or a \r
+  different driver. This function must match its calls to AllocatePages() with FreePages(), \r
+  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().  \r
+  Because ControllerHandle may have been previously started by the same driver, if a protocol is \r
+  already in the opened state, then it must not be closed with CloseProtocol(). This is required \r
+  to guarantee the state of ControllerHandle is not modified by this function.\r
+\r
+  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle     The handle of the controller to test. This handle \r
+                                   must support a protocol interface that supplies \r
+                                   an I/O abstraction to the driver.\r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
+                                   parameter is ignored by device drivers, and is optional for bus \r
+                                   drivers. For bus drivers, if this parameter is not NULL, then \r
+                                   the bus driver must determine if the bus controller specified \r
+                                   by ControllerHandle and the child controller specified \r
+                                   by RemainingDevicePath are both supported by this \r
+                                   bus driver.\r
+\r
+  @retval EFI_SUCCESS              The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is supported by the driver specified by This.\r
+  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is already being managed by the driver\r
+                                   specified by This.\r
+  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is already being managed by a different\r
+                                   driver or an application that requires exclusive access.\r
+                                   Currently not implemented.\r
+  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and\r
+                                   RemainingDevicePath is not supported by the driver specified by This.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemDriverBindingSupported (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_IO_THUNK_PROTOCOL  *EmuIoThunk;\r
+\r
+  //\r
+  // Open the IO Abstraction(s) needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&EmuIoThunk,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Make sure GUID is for a File System handle.\r
+  //\r
+  Status = EFI_UNSUPPORTED;\r
+  if (CompareGuid (EmuIoThunk->Protocol, &gEfiSimpleFileSystemProtocolGuid)) {\r
+    Status = EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
+  gBS->CloseProtocol (\r
+        ControllerHandle,\r
+        &gEmuIoThunkProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        ControllerHandle\r
+        );\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Starts a device controller or a bus controller.\r
+\r
+  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
+  As a result, much of the error checking on the parameters to Start() has been moved into this \r
+  common boot service. It is legal to call Start() from other locations, \r
+  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE.\r
+  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
+     EFI_DEVICE_PATH_PROTOCOL.\r
+  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
+     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.  \r
+\r
+  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle     The handle of the controller to start. This handle \r
+                                   must support a protocol interface that supplies \r
+                                   an I/O abstraction to the driver.\r
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
+                                   parameter is ignored by device drivers, and is optional for bus \r
+                                   drivers. For a bus driver, if this parameter is NULL, then handles \r
+                                   for all the children of Controller are created by this driver.  \r
+                                   If this parameter is not NULL and the first Device Path Node is \r
+                                   not the End of Device Path Node, then only the handle for the \r
+                                   child device specified by the first Device Path Node of \r
+                                   RemainingDevicePath is created by this driver.\r
+                                   If the first Device Path Node of RemainingDevicePath is \r
+                                   the End of Device Path Node, no child handle is created by this\r
+                                   driver.\r
+\r
+  @retval EFI_SUCCESS              The device was started.\r
+  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.Currently not implemented.\r
+  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
+  @retval Others                   The driver failded to start the device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemDriverBindingStart (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
+  IN  EFI_HANDLE                    ControllerHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  EMU_IO_THUNK_PROTOCOL             *EmuIoThunk;\r
+  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *Private;\r
+\r
+  Private = NULL;\r
+\r
+  //\r
+  // Open the IO Abstraction(s) needed\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&EmuIoThunk,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Validate GUID\r
+  //\r
+  if (!CompareGuid (EmuIoThunk->Protocol, &gEfiSimpleFileSystemProtocolGuid)) {\r
+    Status = EFI_UNSUPPORTED;\r
+    goto Done;\r
+  }\r
+\r
+  Private = AllocateZeroPool (sizeof (EMU_SIMPLE_FILE_SYSTEM_PRIVATE));\r
+  if (Private == NULL) {\r
+    goto Done;\r
+  }\r
+\r
+  Status = EmuIoThunk->Open (EmuIoThunk);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  Private->Signature = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE;\r
+  Private->IoThunk   = EmuIoThunk;\r
+  Private->Io        = EmuIoThunk->Interface;\r
+  \r
+  Private->SimpleFileSystem.Revision    = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION;\r
+  Private->SimpleFileSystem.OpenVolume  = EmuSimpleFileSystemOpenVolume;\r
+\r
+  Private->ControllerNameTable = NULL;\r
+\r
+  AddUnicodeString2 (\r
+    "eng",\r
+    gEmuSimpleFileSystemComponentName.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    EmuIoThunk->ConfigString,\r
+    TRUE\r
+    );\r
+    \r
+  AddUnicodeString2 (\r
+    "en",\r
+    gEmuSimpleFileSystemComponentName2.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    EmuIoThunk->ConfigString,\r
+    FALSE\r
+    );\r
+\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &ControllerHandle,\r
+                  &gEfiSimpleFileSystemProtocolGuid,  &Private->SimpleFileSystem,\r
+                  NULL\r
+                  );\r
+\r
+Done:\r
+  if (EFI_ERROR (Status)) {\r
+    if (Private != NULL) {\r
+      if (Private->ControllerNameTable != NULL) {\r
+        FreeUnicodeStringTable (Private->ControllerNameTable);\r
+      }\r
+      \r
+      gBS->FreePool (Private);\r
+    \r
+    }\r
+\r
+    gBS->CloseProtocol (\r
+          ControllerHandle,\r
+          &gEmuIoThunkProtocolGuid,\r
+          This->DriverBindingHandle,\r
+          ControllerHandle\r
+          );\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Stops a device controller or a bus controller.\r
+  \r
+  The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
+  As a result, much of the error checking on the parameters to Stop() has been moved \r
+  into this common boot service. It is legal to call Stop() from other locations, \r
+  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
+  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
+     same driver's Start() function.\r
+  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
+     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
+     Start() function, and the Start() function must have called OpenProtocol() on\r
+     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+  \r
+  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must \r
+                                support a bus specific I/O protocol for the driver \r
+                                to use to stop the device.\r
+  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
+  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL \r
+                                if NumberOfChildren is 0.\r
+\r
+  @retval EFI_SUCCESS           The device was stopped.\r
+  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSimpleFileSystemDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL   *SimpleFileSystem;\r
+  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *Private;\r
+\r
+  //\r
+  // Get our context back\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiSimpleFileSystemProtocolGuid,\r
+                  (VOID **)&SimpleFileSystem,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem);\r
+  Status = Private->IoThunk->Close (Private->IoThunk);\r
+\r
+  //\r
+  // Uninstall the Simple File System Protocol from ControllerHandle\r
+  //\r
+  Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                  ControllerHandle,\r
+                  &gEfiSimpleFileSystemProtocolGuid,  &Private->SimpleFileSystem,\r
+                  NULL\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    Status = gBS->CloseProtocol (\r
+                    ControllerHandle,\r
+                    &gEmuIoThunkProtocolGuid,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle\r
+                    );\r
+  }\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Free our instance data\r
+    //\r
+    FreeUnicodeStringTable (Private->ControllerNameTable);\r
+    gBS->FreePool (Private);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding = {\r
+  EmuSimpleFileSystemDriverBindingSupported,\r
+  EmuSimpleFileSystemDriverBindingStart,\r
+  EmuSimpleFileSystemDriverBindingStop,\r
+  0xa,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+\r
+\r
+\r
+/**\r
+  The user Entry Point for module EmuSimpleFileSystem. The user code starts with this function.\r
+\r
+  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
+  @param[in] SystemTable    A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
+  @retval other             Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeEmuSimpleFileSystem(\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+\r
+  Status = EfiLibInstallDriverBindingComponentName2 (\r
+             ImageHandle,\r
+             SystemTable,\r
+             &gEmuSimpleFileSystemDriverBinding,\r
+             ImageHandle,\r
+             &gEmuSimpleFileSystemComponentName,\r
+             &gEmuSimpleFileSystemComponentName2\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.h b/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.h
new file mode 100644 (file)
index 0000000..5a1182c
--- /dev/null
@@ -0,0 +1,80 @@
+/*++ @file\r
+  Produce Simple File System abstractions for a directory on your PC using Unix APIs.\r
+  The configuration of what devices to mount or emulate comes from  \r
+  environment variables.\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+**/\r
+\r
+#ifndef _EMU_SIMPLE_FILE_SYSTEM_H_\r
+#define _EMU_SIMPLE_FILE_SYSTEM_H_\r
+\r
+#include "PiDxe.h"\r
+\r
+#include <Guid/FileSystemInfo.h>\r
+#include <Guid/FileInfo.h>\r
+#include <Guid/FileSystemVolumeLabelInfo.h>\r
+\r
+#include <Protocol/EmuIoThunk.h>\r
+#include <Protocol/SimpleFileSystem.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+\r
+extern EFI_DRIVER_BINDING_PROTOCOL  gEmuSimpleFileSystemDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL  gEmuSimpleFileSystemComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL gEmuSimpleFileSystemComponentName2;\r
+\r
+#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'M', 'f', 's')\r
+\r
+typedef struct {\r
+  UINTN                           Signature;\r
+  EMU_IO_THUNK_PROTOCOL           *IoThunk;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Io;\r
+  EFI_UNICODE_STRING_TABLE        *ControllerNameTable;\r
+} EMU_SIMPLE_FILE_SYSTEM_PRIVATE;\r
+\r
+#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \\r
+  CR (a, \\r
+      EMU_SIMPLE_FILE_SYSTEM_PRIVATE, \\r
+      SimpleFileSystem, \\r
+      EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \\r
+      )\r
+\r
+#define EMU_EFI_FILE_PRIVATE_SIGNATURE SIGNATURE_32 ('e', 'm', 'f', 's')\r
+\r
+typedef struct {\r
+  UINTN                           Signature;\r
+  EMU_IO_THUNK_PROTOCOL           *IoThunk;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;\r
+  EFI_FILE_PROTOCOL               EfiFile;\r
+  EFI_FILE_PROTOCOL               *Io;\r
+} EMU_EFI_FILE_PRIVATE;\r
+\r
+#define EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \\r
+  CR (a, \\r
+      EMU_EFI_FILE_PRIVATE, \\r
+      EfiFile, \\r
+      EMU_EFI_FILE_PRIVATE_SIGNATURE \\r
+      )\r
+\r
+\r
+\r
+#endif \r
diff --git a/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf b/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf
new file mode 100644 (file)
index 0000000..63bafa8
--- /dev/null
@@ -0,0 +1,55 @@
+## @file\r
+# Simple filesystem driver\r
+#\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuSimpleFileSystem\r
+  FILE_GUID                      = 35B72237-3926-CF4A-A7F3-1449F9E0E4BD\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = InitializeEmuSimpleFileSystem\r
+\r
+\r
+[Sources]\r
+  ComponentName.c\r
+  EmuSimpleFileSystem.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  BaseMemoryLib\r
+  UefiLib\r
+  UefiDriverEntryPoint\r
+  BaseLib\r
+  DebugLib\r
+\r
+\r
+[Guids]\r
+  gEfiFileSystemVolumeLabelInfoIdGuid           # SOMETIMES_CONSUMED\r
+  gEfiFileInfoGuid                              # SOMETIMES_CONSUMED\r
+  gEfiFileSystemInfoGuid                        # SOMETIMES_CONSUMED\r
+\r
+\r
+[Protocols]\r
+  gEfiSimpleFileSystemProtocolGuid               # PROTOCOL BY_START\r
+  gEmuIoThunkProtocolGuid                        # PROTOCOL TO_START\r
+\r
diff --git a/EmulatorPkg/EmuSnpDxe/ComponentName.c b/EmulatorPkg/EmuSnpDxe/ComponentName.c
new file mode 100644 (file)
index 0000000..a7c5124
--- /dev/null
@@ -0,0 +1,318 @@
+/** @file\r
+\r
+ Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
+\r
+    This program and the accompanying materials\r
+    are licensed and made available under the terms and conditions of the BSD License\r
+    which accompanies this distribution. The full text of the license may be found at\r
+    http://opensource.org/licenses/bsd-license.php\r
+\r
+    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  ComponentName.c\r
+\r
+Abstract:\r
+\r
+-**/\r
+\r
+#include "EmuSnpDxe.h"\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                driver specified by This in the language\r
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  );\r
+\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the controller\r
+  that is being managed by a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+\r
+  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified in\r
+                                RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  );\r
+\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gEmuSnpDriverComponentName = {\r
+  EmuSnpDriverComponentNameGetDriverName,\r
+  EmuSnpDriverComponentNameGetControllerName,\r
+  "eng"\r
+};\r
+\r
+//\r
+// EFI Component Name 2 Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2 = {\r
+  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuSnpDriverComponentNameGetDriverName,\r
+  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuSnpDriverComponentNameGetControllerName,\r
+  "en"\r
+};\r
+\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuSnpDriverNameTable[] = {\r
+  {\r
+    "eng;en",\r
+    L"Emu SNP Driver"\r
+  },\r
+  {\r
+    NULL,\r
+    NULL\r
+  }\r
+};\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+  This function retrieves the user readable name of a driver in the form of a\r
+  Unicode string. If the driver specified by This has a user readable name in\r
+  the language specified by Language, then a pointer to the driver name is\r
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+  by This does not support the language specified by Language,\r
+  then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language. This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                driver specified by This in the language\r
+                                specified by Language.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
+                                This and the language specified by Language was\r
+                                returned in DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverComponentNameGetDriverName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
+  IN  CHAR8                        *Language,\r
+  OUT CHAR16                       **DriverName\r
+  )\r
+{\r
+  return LookupUnicodeString2 (\r
+           Language,\r
+           This->SupportedLanguages,\r
+           mEmuSnpDriverNameTable,\r
+           DriverName,\r
+           (BOOLEAN)(This == &gEmuSnpDriverComponentName)\r
+           );\r
+}\r
+\r
+/**\r
+  Retrieves a Unicode string that is the user readable name of the controller\r
+  that is being managed by a driver.\r
+\r
+  This function retrieves the user readable name of the controller specified by\r
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+  driver specified by This has a user readable name in the language specified by\r
+  Language, then a pointer to the controller name is returned in ControllerName,\r
+  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
+  managing the controller specified by ControllerHandle and ChildHandle,\r
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+                                specified by This is managing.  This handle\r
+                                specifies the controller whose name is to be\r
+                                returned.\r
+\r
+  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+                                the name of.  This is an optional parameter that\r
+                                may be NULL.  It will be NULL for device\r
+                                drivers.  It will also be NULL for a bus drivers\r
+                                that wish to retrieve the name of the bus\r
+                                controller.  It will not be NULL for a bus\r
+                                driver that wishes to retrieve the name of a\r
+                                child controller.\r
+\r
+  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+                                array indicating the language.  This is the\r
+                                language of the driver name that the caller is\r
+                                requesting, and it must match one of the\r
+                                languages specified in SupportedLanguages. The\r
+                                number of languages supported by a driver is up\r
+                                to the driver writer. Language is specified in\r
+                                RFC 4646 or ISO 639-2 language code format.\r
+\r
+  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+                                This Unicode string is the name of the\r
+                                controller specified by ControllerHandle and\r
+                                ChildHandle in the language specified by\r
+                                Language from the point of view of the driver\r
+                                specified by This.\r
+\r
+  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
+                                the language specified by Language for the\r
+                                driver specified by This was returned in\r
+                                DriverName.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+                                EFI_HANDLE.\r
+\r
+  @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
+                                managing the controller specified by\r
+                                ControllerHandle and ChildHandle.\r
+\r
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
+                                the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverComponentNameGetControllerName (\r
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
+  IN  EFI_HANDLE                                      ControllerHandle,\r
+  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
+  IN  CHAR8                                           *Language,\r
+  OUT CHAR16                                          **ControllerName\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c b/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c
new file mode 100644 (file)
index 0000000..4432218
--- /dev/null
@@ -0,0 +1,958 @@
+/** @file\r
+\r
+ Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
+ Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+\r
+    This program and the accompanying materials\r
+    are licensed and made available under the terms and conditions of the BSD License\r
+    which accompanies this distribution. The full text of the license may be found at\r
+    http://opensource.org/licenses/bsd-license.php\r
+\r
+    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  EmuSnp.c\r
+\r
+Abstract:\r
+\r
+-**/\r
+\r
+#include "EmuSnpDxe.h"\r
+\r
+\r
+\r
+EFI_SIMPLE_NETWORK_PROTOCOL gEmuSnpTemplate = {\r
+  EFI_SIMPLE_NETWORK_PROTOCOL_REVISION,  \r
+  EmuSnpStart,             \r
+  EmuSnpStop,              \r
+  EmuSnpInitialize,       \r
+  EmuSnpReset,              \r
+  EmuSnpShutdown,            \r
+  EmuSnpReceiveFilters,          \r
+  EmuSnpStationAddress,          \r
+  EmuSnpStatistics,            \r
+  EmuSnpMcastIptoMac,          \r
+  EmuSnpNvdata,              \r
+  EmuSnpGetStatus,            \r
+  EmuSnpTransmit,            \r
+  EmuSnpReceive,              \r
+  NULL,                     // WaitForPacket\r
+  NULL                      // Mode\r
+ };\r
+\r
+\r
+\r
+\r
+/**\r
+  Changes the state of a network interface from "stopped" to "started".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStart(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Start (Private->Io);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Changes the state of a network interface from "started" to "stopped".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStop (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Stop (Private->Io);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Resets a network adapter and allocates the transmit and receive buffers \r
+  required by the network interface; optionally, also requests allocation \r
+  of additional transmit and receive buffers.\r
+\r
+  @param  This              Protocol instance pointer.\r
+  @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+  @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpInitialize (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN UINTN                          ExtraRxBufferSize OPTIONAL,\r
+  IN UINTN                          ExtraTxBufferSize OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Initialize (Private->Io, ExtraRxBufferSize, ExtraTxBufferSize);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Resets a network adapter and re-initializes it with the parameters that were \r
+  provided in the previous call to Initialize().  \r
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  ExtendedVerification Indicates that the driver may perform a more\r
+                               exhaustive verification operation of the device\r
+                               during reset.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReset (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN BOOLEAN                        ExtendedVerification\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Reset (Private->Io, ExtendedVerification);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Resets a network adapter and leaves it in a state that is safe for \r
+  another driver to initialize.\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpShutdown (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Shutdown (Private->Io);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Manages the multicast receive filters of a network interface.\r
+\r
+  @param  This               Protocol instance pointer.\r
+  @param  EnableBits         A bit mask of receive filters to enable on the network interface.\r
+  @param  DisableBits        A bit mask of receive filters to disable on the network interface.\r
+  @param  ResetMcastFilter   Set to TRUE to reset the contents of the multicast receive\r
+                             filters on the network interface to their default values.\r
+  @param  McastFilterCount   Number of multicast HW MAC addresses in the new\r
+                             MCastFilter list. This value must be less than or equal to\r
+                             the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This\r
+                             field is optional if ResetMCastFilter is TRUE.\r
+  @param  McastFilter        A pointer to a list of new multicast receive filter HW MAC\r
+                             addresses. This list will replace any existing multicast\r
+                             HW MAC address list. This field is optional if\r
+                             ResetMCastFilter is TRUE.\r
+\r
+  @retval EFI_SUCCESS           The multicast receive filter list was updated.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReceiveFilters (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN UINT32                         EnableBits,\r
+  IN UINT32                         DisableBits,\r
+  IN BOOLEAN                        ResetMcastFilter,\r
+  IN UINTN                          McastFilterCount OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                *McastFilter OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->ReceiveFilters (\r
+                          Private->Io,\r
+                          EnableBits,\r
+                          DisableBits,\r
+                          ResetMcastFilter,\r
+                          McastFilterCount,\r
+                          McastFilter\r
+                          );\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Modifies or resets the current station address, if supported.\r
+\r
+  @param  This         Protocol instance pointer.\r
+  @param  Reset        Flag used to reset the station address to the network interfaces\r
+                       permanent address.\r
+  @param  NewMacAddr   New station address to be used for the network interface.\r
+\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStationAddress (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN BOOLEAN                        Reset,\r
+  IN EFI_MAC_ADDRESS                *NewMacAddr OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->StationAddress (Private->Io, Reset, NewMacAddr);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Resets or collects the statistics on a network interface.\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
+  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
+                          output the size, in bytes, of the resulting table of\r
+                          statistics.\r
+  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
+                          contains the statistics.\r
+\r
+  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStatistics (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN BOOLEAN                        Reset,\r
+  IN OUT UINTN                      *StatisticsSize OPTIONAL,\r
+  OUT EFI_NETWORK_STATISTICS        *StatisticsTable OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Statistics (Private->Io, Reset, StatisticsSize, StatisticsTable);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Converts a multicast IP address to a multicast HW MAC address.\r
+\r
+  @param  This Protocol instance pointer.\r
+  @param  Ipv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
+               to FALSE if the multicast IP address is IPv4 [RFC 791].\r
+  @param  Ip   The multicast IP address that is to be converted to a multicast\r
+               HW MAC address.\r
+  @param  Mac  The multicast HW MAC address that is to be generated from IP.\r
+\r
+  @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast\r
+                                HW MAC address.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpMcastIptoMac (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN BOOLEAN                        Ipv6,\r
+  IN EFI_IP_ADDRESS                 *Ip,\r
+  OUT EFI_MAC_ADDRESS               *Mac\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->MCastIpToMac (Private->Io, Ipv6, Ip, Mac);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Performs read and write operations on the NVRAM device attached to a \r
+  network interface.\r
+\r
+  @param  This         Protocol instance pointer.\r
+  @param  ReadOrWrite  TRUE for read operations, FALSE for write operations.\r
+  @param  Offset       Byte offset in the NVRAM device at which to start the read or\r
+                       write operation. This must be a multiple of NvRamAccessSize and\r
+                       less than NvRamSize.\r
+  @param  BufferSize   The number of bytes to read or write from the NVRAM device.\r
+                       This must also be a multiple of NvramAccessSize.\r
+  @param  Buffer       A pointer to the data buffer.\r
+\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpNvdata (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN BOOLEAN                        ReadOrWrite,\r
+  IN UINTN                          Offset,\r
+  IN UINTN                          BufferSize,\r
+  IN OUT VOID                       *Buffer\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->NvData (Private->Io, ReadOrWrite, Offset, BufferSize, Buffer);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Reads the current interrupt status and recycled transmit buffer status from \r
+  a network interface.\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
+                          If this is NULL, the interrupt status will not be read from\r
+                          the device. If this is not NULL, the interrupt status will\r
+                          be read from the device. When the  interrupt status is read,\r
+                          it will also be cleared. Clearing the transmit  interrupt\r
+                          does not empty the recycled transmit buffer array.\r
+  @param  TxBuffer        Recycled transmit buffer address. The network interface will\r
+                          not transmit if its internal recycled transmit buffer array\r
+                          is full. Reading the transmit buffer does not clear the\r
+                          transmit interrupt. If this is NULL, then the transmit buffer\r
+                          status will not be read. If there are no transmit buffers to\r
+                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpGetStatus (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  OUT UINT32                        *InterruptStatus,\r
+  OUT VOID                          **TxBuffer\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->GetStatus (Private->Io, InterruptStatus, TxBuffer);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Places a packet in the transmit queue of a network interface.\r
+\r
+  @param  This       Protocol instance pointer.\r
+  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
+                     the Transmit() function. If HeaderSize is non-zero, then it\r
+                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
+                     and Protocol parameters must not be NULL.\r
+  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
+                     data) to be transmitted through the network interface.\r
+  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
+                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
+                     then the media header in Buffer must already be filled in by the\r
+                     caller. If HeaderSize is non-zero, then the media header will be\r
+                     filled in by the Transmit() function.\r
+  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
+                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
+                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
+  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
+                     parameter is ignored.\r
+  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
+                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
+                     examples.\r
+\r
+  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpTransmit (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  IN UINTN                          HeaderSize,\r
+  IN UINTN                          BufferSize,\r
+  IN VOID*                          Buffer,\r
+  IN EFI_MAC_ADDRESS                *SrcAddr OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                *DestAddr OPTIONAL,\r
+  IN UINT16                         *Protocol OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Transmit (\r
+                          Private->Io,\r
+                          HeaderSize,\r
+                          BufferSize,\r
+                          Buffer,\r
+                          SrcAddr,\r
+                          DestAddr,\r
+                          Protocol\r
+                          );\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Receives a packet from a network interface.\r
+\r
+  @param  This             Protocol instance pointer.\r
+  @param  HeaderSize       The size, in bytes, of the media header received on the network\r
+                           interface. If this parameter is NULL, then the media header size\r
+                           will not be returned.\r
+  @param  BuffSize         On entry, the size, in bytes, of Buffer. On exit, the size, in\r
+                           bytes, of the packet that was received on the network interface.\r
+  @param  Buffer           A pointer to the data buffer to receive both the media header and\r
+                           the data.\r
+  @param  SourceAddr       The source HW MAC address. If this parameter is NULL, the\r
+                           HW MAC source address will not be extracted from the media\r
+                           header.\r
+  @param  DestinationAddr  The destination HW MAC address. If this parameter is NULL,\r
+                           the HW MAC destination address will not be extracted from the\r
+                           media header.\r
+  @param  Protocol         The media header type. If this parameter is NULL, then the\r
+                           protocol will not be extracted from the media header. See\r
+                           RFC 1700 section "Ether Types" for examples.\r
+\r
+  @retval EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
+                                been updated to the number of bytes received.\r
+  @retval EFI_NOT_READY         The network interface is too busy to accept this transmit\r
+                                request.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReceive (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
+  OUT UINTN                         *HeaderSize OPTIONAL,\r
+  IN OUT UINTN                      *BuffSize,\r
+  OUT VOID                          *Buffer,\r
+  OUT EFI_MAC_ADDRESS               *SourceAddr OPTIONAL,\r
+  OUT EFI_MAC_ADDRESS               *DestinationAddr OPTIONAL,\r
+  OUT UINT16                        *Protocol OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_SNP_PRIVATE_DATA    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
+\r
+  Status = Private->Io->Receive (\r
+                          Private->Io,\r
+                          HeaderSize,\r
+                          BuffSize,\r
+                          Buffer,\r
+                          SourceAddr,\r
+                          DestinationAddr,\r
+                          Protocol\r
+                          );\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Test to see if this driver supports ControllerHandle. This service\r
+  is called by the EFI boot service ConnectController(). In\r
+  order to make drivers as small as possible, there are a few calling\r
+  restrictions for this service. ConnectController() must\r
+  follow these calling restrictions. If any other agent wishes to call\r
+  Supported() it must also follow these calling restrictions.\r
+\r
+  @param  This                Protocol instance pointer.\r
+  @param  ControllerHandle    Handle of device to test\r
+  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
+                              device to start.\r
+\r
+  @retval EFI_SUCCESS         This driver supports this device\r
+  @retval EFI_UNSUPPORTED     This driver does not support this device\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EMU_IO_THUNK_PROTOCOL     *EmuIoThunk;\r
+  MAC_ADDR_DEVICE_PATH      *Node;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
+\r
+  if (RemainingDevicePath != NULL) {\r
+    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+      Node = (MAC_ADDR_DEVICE_PATH *)RemainingDevicePath;\r
+      if (Node->Header.Type != MESSAGING_DEVICE_PATH ||\r
+          Node->Header.SubType != MSG_MAC_ADDR_DP) {\r
+        // If the remaining device path does not match we don't support the request\r
+        return EFI_UNSUPPORTED;\r
+      }\r
+    }\r
+  }\r
+  \r
+  \r
+  //\r
+  // Open the IO Abstraction(s) needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&EmuIoThunk,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Make sure GUID is for a File System handle.\r
+  //\r
+  Status = EFI_UNSUPPORTED;\r
+  if (CompareGuid (EmuIoThunk->Protocol, &gEmuSnpProtocolGuid)) {\r
+    Status = EFI_SUCCESS;\r
+  }\r
+\r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
+  gBS->CloseProtocol (\r
+        ControllerHandle,\r
+        &gEmuIoThunkProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        ControllerHandle\r
+        );\r
+        \r
+        \r
+  //\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (Status == EFI_ALREADY_STARTED) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Close protocol, don't use device path protocol in the Support() function\r
+  //\r
+  gBS->CloseProtocol (\r
+        ControllerHandle,\r
+        &gEfiDevicePathProtocolGuid,\r
+        This->DriverBindingHandle,\r
+        ControllerHandle\r
+        );\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Start this driver on ControllerHandle. This service is called by the\r
+  EFI boot service ConnectController(). In order to make\r
+  drivers as small as possible, there are a few calling restrictions for\r
+  this service. ConnectController() must follow these\r
+  calling restrictions. If any other agent wishes to call Start() it\r
+  must also follow these calling restrictions.\r
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  ControllerHandle     Handle of device to bind driver to\r
+  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
+                               device to start.\r
+\r
+  @retval EFI_SUCCESS          Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EMU_IO_THUNK_PROTOCOL       *EmuIoThunk;\r
+  EMU_SNP_PRIVATE_DATA        *Private;\r
+  MAC_ADDR_DEVICE_PATH        Node;\r
+  EFI_DEVICE_PATH_PROTOCOL    *ParentDevicePath;\r
+\r
+  Private = NULL;\r
+\r
+  //\r
+  // Grab the protocols we need\r
+  //\r
+  Status = gBS->OpenProtocol(\r
+                  ControllerHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  ( VOID ** ) &ParentDevicePath,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status) && Status) {\r
+    return Status;\r
+  }\r
+\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&EmuIoThunk,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if (!CompareGuid (EmuIoThunk->Protocol, &gEmuSnpProtocolGuid)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Status = EmuIoThunk->Open (EmuIoThunk);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  //\r
+  //  Allocate the private data.\r
+  //\r
+  Private = AllocateZeroPool (sizeof (EMU_SNP_PRIVATE_DATA));\r
+  if (Private == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Done;\r
+  }\r
+\r
+  CopyMem (&Private->Snp, &gEmuSnpTemplate, sizeof (EFI_SIMPLE_NETWORK_PROTOCOL));\r
+\r
+  Private->Signature    = EMU_SNP_PRIVATE_DATA_SIGNATURE;\r
+  Private->IoThunk      = EmuIoThunk;\r
+  Private->Io           = EmuIoThunk->Interface;\r
+  Private->EfiHandle    = ControllerHandle;\r
+  Private->DeviceHandle = NULL;\r
+  Private->Snp.Mode     = &Private->Mode;\r
+  Private->ControllerNameTable = NULL;\r
+\r
+  \r
+  Status = Private->Io->CreateMapping (Private->Io, &Private->Mode);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  //\r
+  // Build the device path by appending the MAC node to the ParentDevicePath\r
+  // from the EmuIo handle.\r
+  //\r
+  ZeroMem (&Node, sizeof (MAC_ADDR_DEVICE_PATH));\r
+\r
+  Node.Header.Type     = MESSAGING_DEVICE_PATH;\r
+  Node.Header.SubType  = MSG_MAC_ADDR_DP;\r
+  Node.IfType          = Private->Mode.IfType;\r
+\r
+  SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL * )&Node, sizeof (MAC_ADDR_DEVICE_PATH));\r
+\r
+  CopyMem (&Node.MacAddress, &Private->Mode.CurrentAddress, sizeof (EFI_MAC_ADDRESS));\r
+\r
+  //\r
+  // Build the device path by appending the MAC node to the ParentDevicePath from the EmuIo handle.\r
+  //\r
+  Private->DevicePath = AppendDevicePathNode (ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&Node);\r
+  if ( Private->DevicePath == NULL ) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Done;\r
+  }\r
+\r
+  AddUnicodeString2 (\r
+    "eng",\r
+    gEmuSnpDriverComponentName.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    EmuIoThunk->ConfigString,\r
+    TRUE\r
+    );\r
+    \r
+  AddUnicodeString2 (\r
+    "en",\r
+    gEmuSnpDriverComponentName2.SupportedLanguages,\r
+    &Private->ControllerNameTable,\r
+    EmuIoThunk->ConfigString,\r
+    FALSE\r
+    );\r
+\r
+  //\r
+  // Create Child Handle\r
+  //\r
+  Status = gBS->InstallMultipleProtocolInterfaces(\r
+                  &Private->DeviceHandle,\r
+                  &gEfiSimpleNetworkProtocolGuid, &Private->Snp,\r
+                  &gEfiDevicePathProtocolGuid,    Private->DevicePath,\r
+                  NULL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  //\r
+  // Open For Child Device\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  (VOID **)&EmuIoThunk,\r
+                  This->DriverBindingHandle,\r
+                  Private->DeviceHandle,\r
+                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+                  );\r
+\r
+Done:\r
+  if (EFI_ERROR (Status)) {\r
+    if (Private != NULL) {\r
+      FreePool (Private);\r
+    }\r
+    if (ParentDevicePath != NULL) {\r
+      gBS->CloseProtocol(\r
+            ControllerHandle,\r
+            &gEfiDevicePathProtocolGuid,\r
+            This->DriverBindingHandle,\r
+            ControllerHandle\r
+            );\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Stop this driver on ControllerHandle. This service is called by the\r
+  EFI boot service DisconnectController(). In order to\r
+  make drivers as small as possible, there are a few calling\r
+  restrictions for this service. DisconnectController()\r
+  must follow these calling restrictions. If any other agent wishes\r
+  to call Stop() it must also follow these calling restrictions.\r
+  \r
+  @param  This              Protocol instance pointer.\r
+  @param  ControllerHandle  Handle of device to stop driver on\r
+  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
+                            children is zero stop the entire bus driver.\r
+  @param  ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+  @retval EFI_SUCCESS       Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingStop (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
+  IN EFI_HANDLE                     ControllerHandle,\r
+  IN UINTN                          NumberOfChildren,\r
+  IN EFI_HANDLE                     *ChildHandleBuffer\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EMU_SNP_PRIVATE_DATA        *Private = NULL;\r
+  EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
+\r
+  //\r
+  // Complete all outstanding transactions to Controller.\r
+  // Don't allow any new transaction to Controller to be started.\r
+  //\r
+  if (NumberOfChildren == 0) {\r
+    //\r
+    // Close the bus driver\r
+    //\r
+    Status = gBS->CloseProtocol (\r
+                    ControllerHandle,\r
+                    &gEmuIoThunkProtocolGuid,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle\r
+                    );\r
+\r
+    Status = gBS->CloseProtocol (\r
+                    ControllerHandle,\r
+                    &gEfiDevicePathProtocolGuid,\r
+                    This->DriverBindingHandle,\r
+                    ControllerHandle\r
+                    );\r
+    return Status;\r
+  }\r
+\r
+  ASSERT (NumberOfChildren == 1);\r
+  \r
+  \r
+  //\r
+  // Get our context back.\r
+  //\r
+  Status = gBS->OpenProtocol(\r
+                  ChildHandleBuffer[0],\r
+                  &gEfiSimpleNetworkProtocolGuid,\r
+                  ( VOID ** ) &Snp,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (Snp);\r
+  Status = Private->IoThunk->Close (Private->IoThunk);\r
+\r
+  Status = gBS->CloseProtocol(\r
+                  ChildHandleBuffer[0],\r
+                  &gEmuIoThunkProtocolGuid,\r
+                  This->DriverBindingHandle,\r
+                  Private->DeviceHandle\r
+                  );\r
+\r
+  Status = gBS->UninstallMultipleProtocolInterfaces(\r
+                  ChildHandleBuffer[0],\r
+                  &gEfiSimpleNetworkProtocolGuid,   &Private->Snp,\r
+                  &gEfiDevicePathProtocolGuid,      Private->DevicePath,\r
+                  NULL\r
+                  );\r
+\r
+  FreePool (Private->DevicePath);\r
+  FreeUnicodeStringTable (Private->ControllerNameTable);\r
+  FreePool (Private);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding = {\r
+  EmuSnpDriverBindingSupported,\r
+  EmuSnpDriverBindingStart,\r
+  EmuSnpDriverBindingStop,\r
+  0xA,\r
+  NULL,\r
+  NULL\r
+};\r
+\r
+\r
+\r
+/**\r
+  This is the declaration of an EFI image entry point. This entry point is\r
+  the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including\r
+  both device drivers and bus drivers.\r
+\r
+  @param  ImageHandle           The firmware allocated handle for the UEFI image.\r
+  @param  SystemTable           A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeEmuSnpDriver (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+\r
+  //\r
+  // Install the Driver Protocols\r
+  //\r
+\r
+  Status = EfiLibInstallDriverBindingComponentName2(\r
+              ImageHandle,\r
+              SystemTable,\r
+              &gEmuSnpDriverBinding,\r
+              ImageHandle,\r
+              &gEmuSnpDriverComponentName,\r
+              &gEmuSnpDriverComponentName2\r
+              );\r
+\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.h b/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.h
new file mode 100644 (file)
index 0000000..21bfc42
--- /dev/null
@@ -0,0 +1,488 @@
+/** @file\r
+\r
+ Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
+\r
+    This program and the accompanying materials\r
+    are licensed and made available under the terms and conditions of the BSD License\r
+    which accompanies this distribution. The full text of the license may be found at\r
+    http://opensource.org/licenses/bsd-license.php\r
+\r
+    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  EmuSnp.h\r
+\r
+Abstract:\r
+\r
+-**/\r
+\r
+#ifndef _EMU_SNP_H_\r
+#define _EMU_SNP_H_\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/SimpleNetwork.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/EmuIoThunk.h>\r
+#include <Protocol/EmuSnp.h>\r
+\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/NetLib.h>\r
+\r
+#define NET_ETHER_HEADER_SIZE     14\r
+\r
+//\r
+//  Private data for driver.\r
+//\r
+#define EMU_SNP_PRIVATE_DATA_SIGNATURE SIGNATURE_32( 'U', 'S', 'N', 'P' )\r
+\r
+typedef struct {\r
+  UINTN                       Signature;\r
+  EMU_IO_THUNK_PROTOCOL       *IoThunk;\r
+  EMU_SNP_PROTOCOL            *Io;\r
+  EFI_DEVICE_PATH_PROTOCOL    *DevicePath;\r
+\r
+  EFI_HANDLE                  EfiHandle;\r
+  EFI_HANDLE                  DeviceHandle;\r
+\r
+  EFI_SIMPLE_NETWORK_PROTOCOL Snp;\r
+  EFI_SIMPLE_NETWORK_MODE     Mode;\r
+  \r
+  EFI_UNICODE_STRING_TABLE    *ControllerNameTable;\r
+\r
+} EMU_SNP_PRIVATE_DATA;\r
+\r
+#define EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS(a) \\r
+      CR( a, EMU_SNP_PRIVATE_DATA, Snp, EMU_SNP_PRIVATE_DATA_SIGNATURE )\r
+\r
+extern EFI_DRIVER_BINDING_PROTOCOL    gEmuSnpDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL    gEmuSnpDriverComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL   gEmuSnpDriverComponentName2;\r
+\r
+/**\r
+  Test to see if this driver supports ControllerHandle. This service\r
+  is called by the EFI boot service ConnectController(). In\r
+  order to make drivers as small as possible, there are a few calling\r
+  restrictions for this service. ConnectController() must\r
+  follow these calling restrictions. If any other agent wishes to call\r
+  Supported() it must also follow these calling restrictions.\r
+\r
+  @param  This                Protocol instance pointer.\r
+  @param  ControllerHandle    Handle of device to test\r
+  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
+                              device to start.\r
+\r
+  @retval EFI_SUCCESS         This driver supports this device\r
+  @retval EFI_UNSUPPORTED     This driver does not support this device\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingSupported (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  * This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     * RemainingDevicePath OPTIONAL\r
+  );\r
+\r
+/**\r
+  Start this driver on ControllerHandle. This service is called by the\r
+  EFI boot service ConnectController(). In order to make\r
+  drivers as small as possible, there are a few calling restrictions for\r
+  this service. ConnectController() must follow these\r
+  calling restrictions. If any other agent wishes to call Start() it\r
+  must also follow these calling restrictions.\r
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  ControllerHandle     Handle of device to bind driver to\r
+  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
+                               device to start.\r
+\r
+  @retval EFI_SUCCESS          Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingStart (\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  * This,\r
+  IN EFI_HANDLE                   ControllerHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL     * RemainingDevicePath OPTIONAL\r
+  );\r
+\r
+/**\r
+  Stop this driver on ControllerHandle. This service is called by the\r
+  EFI boot service DisconnectController(). In order to\r
+  make drivers as small as possible, there are a few calling\r
+  restrictions for this service. DisconnectController()\r
+  must follow these calling restrictions. If any other agent wishes\r
+  to call Stop() it must also follow these calling restrictions.\r
+  \r
+  @param  This              Protocol instance pointer.\r
+  @param  ControllerHandle  Handle of device to stop driver on\r
+  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
+                            children is zero stop the entire bus driver.\r
+  @param  ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+  @retval EFI_SUCCESS       Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpDriverBindingStop (\r
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
+  IN  EFI_HANDLE                   ControllerHandle,\r
+  IN  UINTN                        NumberOfChildren,\r
+  IN  EFI_HANDLE                   *ChildHandleBuffer\r
+  );\r
+\r
+/**\r
+  Changes the state of a network interface from "stopped" to "started".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStart(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This\r
+  );\r
+  \r
+/**\r
+  Changes the state of a network interface from "started" to "stopped".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStop(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This\r
+  );\r
+  \r
+/**\r
+  Resets a network adapter and allocates the transmit and receive buffers \r
+  required by the network interface; optionally, also requests allocation \r
+  of additional transmit and receive buffers.\r
+\r
+  @param  This              Protocol instance pointer.\r
+  @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+  @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpInitialize(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN UINTN              ExtraRxBufferSize OPTIONAL,\r
+  IN UINTN              ExtraTxBufferSize OPTIONAL\r
+  );\r
+  \r
+/**\r
+  Resets a network adapter and re-initializes it with the parameters that were \r
+  provided in the previous call to Initialize().  \r
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  ExtendedVerification Indicates that the driver may perform a more\r
+                               exhaustive verification operation of the device\r
+                               during reset.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReset(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN BOOLEAN              ExtendedVerification\r
+  );\r
+\r
+/**\r
+  Resets a network adapter and leaves it in a state that is safe for \r
+  another driver to initialize.\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpShutdown(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This\r
+  );\r
+\r
+/**\r
+  Manages the multicast receive filters of a network interface.\r
+\r
+  @param  This               Protocol instance pointer.\r
+  @param  EnableBits         A bit mask of receive filters to enable on the network interface.\r
+  @param  DisableBits        A bit mask of receive filters to disable on the network interface.\r
+  @param  ResetMcastFilter   Set to TRUE to reset the contents of the multicast receive\r
+                             filters on the network interface to their default values.\r
+  @param  McastFilterCount   Number of multicast HW MAC addresses in the new\r
+                             MCastFilter list. This value must be less than or equal to\r
+                             the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This\r
+                             field is optional if ResetMCastFilter is TRUE.\r
+  @param  McastFilter        A pointer to a list of new multicast receive filter HW MAC\r
+                             addresses. This list will replace any existing multicast\r
+                             HW MAC address list. This field is optional if\r
+                             ResetMCastFilter is TRUE.\r
+\r
+  @retval EFI_SUCCESS           The multicast receive filter list was updated.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReceiveFilters(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN UINT32              EnableBits,\r
+  IN UINT32              DisableBits,\r
+  IN BOOLEAN              ResetMcastFilter,\r
+  IN UINTN              McastFilterCount OPTIONAL,\r
+  IN EFI_MAC_ADDRESS*          McastFilter OPTIONAL\r
+  );\r
+\r
+/**\r
+  Modifies or resets the current station address, if supported.\r
+\r
+  @param  This         Protocol instance pointer.\r
+  @param  Reset        Flag used to reset the station address to the network interfaces\r
+                       permanent address.\r
+  @param  NewMacAddr   New station address to be used for the network interface.\r
+\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStationAddress(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN BOOLEAN              Reset,\r
+  IN EFI_MAC_ADDRESS*          NewMacAddr OPTIONAL\r
+  );\r
+\r
+/**\r
+  Resets or collects the statistics on a network interface.\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
+  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
+                          output the size, in bytes, of the resulting table of\r
+                          statistics.\r
+  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
+                          contains the statistics.\r
+\r
+  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpStatistics(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN BOOLEAN              Reset,\r
+  IN OUT UINTN*            StatisticsSize OPTIONAL,\r
+  OUT EFI_NETWORK_STATISTICS*      StatisticsTable OPTIONAL\r
+  );\r
+  \r
+/**\r
+  Converts a multicast IP address to a multicast HW MAC address.\r
+  \r
+  @param  This  Protocol instance pointer.\r
+  @param  Ipv6  Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
+                to FALSE if the multicast IP address is IPv4 [RFC 791].\r
+  @param  Ip    The multicast IP address that is to be converted to a multicast\r
+                HW MAC address.\r
+  @param  Mac   The multicast HW MAC address that is to be generated from IP.\r
+\r
+  @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast\r
+                                HW MAC address.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpMcastIptoMac(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN BOOLEAN              Ipv6,\r
+  IN EFI_IP_ADDRESS*          Ip,\r
+  OUT EFI_MAC_ADDRESS*        Mac\r
+  );\r
+\r
+/**\r
+  Performs read and write operations on the NVRAM device attached to a \r
+  network interface.\r
+\r
+  @param  This         Protocol instance pointer.\r
+  @param  ReadOrWrite  TRUE for read operations, FALSE for write operations.\r
+  @param  Offset       Byte offset in the NVRAM device at which to start the read or\r
+                       write operation. This must be a multiple of NvRamAccessSize and\r
+                       less than NvRamSize.\r
+  @param  BufferSize   The number of bytes to read or write from the NVRAM device.\r
+                       This must also be a multiple of NvramAccessSize.\r
+  @param  Buffer       A pointer to the data buffer.\r
+\r
+  @retval EFI_UNSUPPORTED       Not supported yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpNvdata(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN BOOLEAN              ReadOrWrite,\r
+  IN UINTN              Offset,\r
+  IN UINTN              BufferSize,\r
+  IN OUT VOID*            Buffer\r
+  );\r
+\r
+/**\r
+  Reads the current interrupt status and recycled transmit buffer status from \r
+  a network interface.\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
+                          If this is NULL, the interrupt status will not be read from\r
+                          the device. If this is not NULL, the interrupt status will\r
+                          be read from the device. When the  interrupt status is read,\r
+                          it will also be cleared. Clearing the transmit  interrupt\r
+                          does not empty the recycled transmit buffer array.\r
+  @param  TxBuffer        Recycled transmit buffer address. The network interface will\r
+                          not transmit if its internal recycled transmit buffer array\r
+                          is full. Reading the transmit buffer does not clear the\r
+                          transmit interrupt. If this is NULL, then the transmit buffer\r
+                          status will not be read. If there are no transmit buffers to\r
+                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
+\r
+  @retval EFI_SUCCESS           Always succeeds.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpGetStatus(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  OUT UINT32*              InterruptStatus,\r
+  OUT VOID**              TxBuffer\r
+  );\r
+\r
+/**\r
+  Places a packet in the transmit queue of a network interface.\r
+\r
+  @param  This       Protocol instance pointer.\r
+  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
+                     the Transmit() function. If HeaderSize is non-zero, then it\r
+                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
+                     and Protocol parameters must not be NULL.\r
+  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
+                     data) to be transmitted through the network interface.\r
+  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
+                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
+                     then the media header in Buffer must already be filled in by the\r
+                     caller. If HeaderSize is non-zero, then the media header will be\r
+                     filled in by the Transmit() function.\r
+  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
+                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
+                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
+  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
+                     parameter is ignored.\r
+  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
+                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
+                     examples.\r
+\r
+  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_ACCESS_DENIED     Error acquire global lock for operation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpTransmit(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  IN UINTN              HeaderSize,\r
+  IN UINTN              BufferSize,\r
+  IN VOID*              Buffer,\r
+  IN EFI_MAC_ADDRESS*          SrcAddr OPTIONAL,\r
+  IN EFI_MAC_ADDRESS*          DestAddr OPTIONAL,\r
+  IN UINT16*              Protocol OPTIONAL\r
+  );\r
+\r
+/**\r
+  Receives a packet from a network interface.\r
+\r
+  @param  This             Protocol instance pointer.\r
+  @param  HeaderSize       The size, in bytes, of the media header received on the network\r
+                           interface. If this parameter is NULL, then the media header size\r
+                           will not be returned.\r
+  @param  BuffSize         On entry, the size, in bytes, of Buffer. On exit, the size, in\r
+                           bytes, of the packet that was received on the network interface.\r
+  @param  Buffer           A pointer to the data buffer to receive both the media header and\r
+                           the data.\r
+  @param  SourceAddr       The source HW MAC address. If this parameter is NULL, the\r
+                           HW MAC source address will not be extracted from the media\r
+                           header.\r
+  @param  DestinationAddr  The destination HW MAC address. If this parameter is NULL,\r
+                           the HW MAC destination address will not be extracted from the\r
+                           media header.\r
+  @param  Protocol         The media header type. If this parameter is NULL, then the\r
+                           protocol will not be extracted from the media header. See\r
+                           RFC 1700 section "Ether Types" for examples.\r
+\r
+  @retval  EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
+                                 been updated to the number of bytes received.\r
+  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
+                                 request.\r
+  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
+  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval  EFI_ACCESS_DENIED     Error acquire global lock for operation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSnpReceive(\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
+  OUT UINTN*              HeaderSize OPTIONAL,\r
+  IN OUT UINTN*            BuffSize,\r
+  OUT VOID*              Buffer,\r
+  OUT EFI_MAC_ADDRESS*        SourceAddr OPTIONAL,\r
+  OUT EFI_MAC_ADDRESS*        DestinationAddr OPTIONAL,\r
+  OUT UINT16*              Protocol OPTIONAL\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+EmuSnpWaitForPacketNotify(\r
+  IN EFI_EVENT            Event,\r
+  IN VOID*              Private\r
+  );\r
+\r
+#endif  // _EMU_SNP_H_\r
diff --git a/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.inf b/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.inf
new file mode 100644 (file)
index 0000000..5360e24
--- /dev/null
@@ -0,0 +1,57 @@
+#/** @file\r
+# Component name for module EmuSnpDxe\r
+#\r
+# Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
+#\r
+#    This program and the accompanying materials\r
+#    are licensed and made available under the terms and conditions of the BSD License\r
+#    which accompanies this distribution. The full text of the license may be found at\r
+#    http://opensource.org/licenses/bsd-license.php\r
+#\r
+#    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuSnpDxe\r
+  FILE_GUID                      = 22597239-6107-DF44-AD3F-5F053E92222E\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = InitializeEmuSnpDriver\r
+#  UNLOAD_IMAGE                   = EmuSnpUnload\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  ComponentName.c\r
+  EmuSnpDxe.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  DevicePathLib\r
+  UefiLib\r
+  UefiBootServicesTableLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+  UefiDriverEntryPoint\r
+  NetLib\r
+\r
+[Protocols]\r
+  gEfiSimpleNetworkProtocolGuid                 # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiDevicePathProtocolGuid                    # PROTOCOL ALWAYS_CONSUMED\r
+  gEmuSnpProtocolGuid\r
+  gEmuIoThunkProtocolGuid\r
+\r
+\r
diff --git a/EmulatorPkg/EmuThunkDxe/EmuThunk.c b/EmulatorPkg/EmuThunkDxe/EmuThunk.c
new file mode 100644 (file)
index 0000000..a0661c8
--- /dev/null
@@ -0,0 +1,89 @@
+/*++ @file\r
+\r
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+**/\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/EmuThunk.h> \r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/EmuThunkLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+//\r
+// EmuThunk Device Path Protocol Instance\r
+//\r
+EMU_THUNK_DEVICE_PATH mEmuThunkDevicePath = {\r
+  {\r
+    {\r
+      {\r
+        HARDWARE_DEVICE_PATH,\r
+        HW_VENDOR_DP,\r
+        {\r
+          (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),\r
+          (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
+        }\r
+      },\r
+      EMU_THUNK_PROTOCOL_GUID\r
+    },\r
+    0\r
+  },\r
+  {\r
+    END_DEVICE_PATH_TYPE,\r
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
+    {\r
+      END_DEVICE_PATH_LENGTH,\r
+      0\r
+    }\r
+  }\r
+};\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeEmuThunk (\r
+  IN EFI_HANDLE                            ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                      *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Install UnixThunk Protocol and it's associated Device Path protocol\r
+\r
+Arguments:\r
+  (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
+\r
+Returns:\r
+  EFI_SUCEESS - UnixThunk protocol is added or error status from \r
+                gBS->InstallMultiProtocolInterfaces().\r
+\r
+**/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  Handle;\r
+\r
+  Handle = NULL;\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Handle,\r
+                  &gEmuThunkProtocolGuid,       gEmuThunk,\r
+                  &gEfiDevicePathProtocolGuid,  &mEmuThunkDevicePath,\r
+                  NULL\r
+                  );\r
+\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/EmuThunkDxe/EmuThunk.inf b/EmulatorPkg/EmuThunkDxe/EmuThunk.inf
new file mode 100644 (file)
index 0000000..394d280
--- /dev/null
@@ -0,0 +1,59 @@
+## @file\r
+#   A DXE driver to produce EMU_THUNK_PROTOCOL\r
+#\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuThunk\r
+  FILE_GUID                      = 2F62A818-4A72-CD40-90B9-FF00DAABEE7B\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = InitializeEmuThunk\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  EmuThunk.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  EmuThunkLib\r
+  UefiDriverEntryPoint\r
+  UefiLib\r
+  DebugLib\r
+  DevicePathLib\r
+\r
+\r
+\r
+[Protocols]\r
+  gEfiDevicePathProtocolGuid                # PROTOCOL ALWAYS_PRODUCED\r
+  gEmuThunkProtocolGuid                     # PROTOCOL ALWAYS_PRODUCED\r
+\r
+\r
+[Depex]\r
+  TRUE\r
+\r
diff --git a/EmulatorPkg/EmulatorPkg.dec b/EmulatorPkg/EmulatorPkg.dec
new file mode 100644 (file)
index 0000000..b5f7192
--- /dev/null
@@ -0,0 +1,101 @@
+## @file\r
+#\r
+# This is the Emu Emulation Environment Platform\r
+#\r
+# Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#    This program and the accompanying materials are licensed and made available \r
+#    under the terms and conditions of the BSD License which accompanies this distribution.\r
+#    The full text of the license may be found at http://opensource.org/licenses/bsd-license.php\r
+#    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES\r
+#    OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+  DEC_VERSION                    = 0x00010005\r
+  PACKAGE_NAME                   = EmulatorPkg\r
+  PACKAGE_GUID                   = 36E48BD7-7D92-5A47-A2CD-513F072E3300\r
+  PACKAGE_VERSION                = 0.1\r
+\r
+\r
+[Includes]\r
+  Include\r
+\r
+\r
+[LibraryClasses]\r
+  ThunkPpiList|Include/Library/ThunkPpiList.h\r
+  ThunkProtocolList|Include/Library/ThunkProtocolList.h\r
+  EmuThunkLib|Include/Library/EmuThunkLib.h\r
+  KeyMap|Include/Library/KeyMapLib.h\r
+  PpiListLib|Include/Library/PpiListLib.h\r
+\r
+[Protocols]\r
+  gEmuThunkProtocolGuid          = { 0x5CF32E0B, 0x8EDF, 0x2E44, { 0x9C, 0xDA, 0x93, 0x20, 0x5E, 0x99, 0xEC, 0x1C } }\r
+  gEmuIoThunkProtocolGuid        = { 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } }\r
+  gEmuGraphicsWindowProtocolGuid = { 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 0xC1 } }\r
+  gEmuThreadThunkProtocolGuid    = { 0x3B1E4B7C, 0x09D8, 0x944F, { 0xA4, 0x08, 0x13, 0x09, 0xEB, 0x8B, 0x44, 0x27 } }\r
+  gEmuBlockIoProtocolGuid        = { 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }\r
+  gEmuSnpProtocolGuid            = { 0xFD5FBE54, 0x8C35, 0xB345, { 0x8A, 0x0F, 0x7A, 0xC8, 0xA5, 0xFD, 0x05, 0x21 } }\r
+\r
+[Ppis]\r
+  gEmuThunkPpiGuid               = { 0xE113F896, 0x75CF, 0xF640, { 0x81, 0x7F, 0xC8, 0x5A, 0x79, 0xE8, 0xAE, 0x67 } }\r
+\r
+[Guids]\r
+  gEmulatorPkgTokenSpaceGuid  = { 0x4F792E68, 0xE8C8, 0x794E, { 0xB1, 0xD8, 0x37, 0x03, 0xF3, 0xF2, 0xD5, 0xA5 } }\r
+  gEmuSystemConfigGuid       = { 0xF8626165, 0x6CEB, 0x924A, { 0xBA, 0xFC, 0xF1, 0x3A, 0xB9, 0xD6, 0x57, 0x28 } }\r
+  gEmuVirtualDisksGuid       = { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }\r
+  gEmuPhysicalDisksGuid      = { 0xf2bdcc96, 0x8985, 0x11db, { 0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }\r
+\r
+[PcdsFixedAtBuild]\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase|0x0|UINT64|0x00001014\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase|0x0|UINT64|0x00001015\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwWorkingBase|0x0|UINT64|0x00001016\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFdBaseAddress|0x0|UINT64|0x00001017\r
+\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogBase|0x0|UINT64|0x0000100e\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogSize|0x0|UINT32|0x0000100f\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashFvRecoveryBase|0x0|UINT64|0x00001010\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashFvRecoverySize|0x0|UINT32|0x00001011\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFirmwareFdSize|0x0|UINT32|0x00001012\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFirmwareBlockSize|0|UINT32|0x00001013\r
\r
+  ## Number of Application Processors (APs) in the system 0 means Uniprocessor mode\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuApCount|L"0"|VOID*|0x00001019\r
+\r
+  ## Magic page to implement PEI Services Table Pointer Lib\r
+  gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage|0x1003000000|UINT64|0x0000101b\r
+\r
+  ## Size of the packet filter\r
+  gEmulatorPkgTokenSpaceGuid.PcdNetworkPacketFilterSize|524288|UINT32|0x0000101c\r
+\r
+  \r
+\r
+[PcdsFixedAtBuild, PcdsPatchableInModule] \r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuBootMode|1|UINT32|0x00001006\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFirmwareVolume|L"..\\Fv\\Fv_Recovery.fd"|VOID*|0x00001009\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuMemorySize|L"64!64"|VOID*|0x0000100c\r
+  \r
+  #\r
+  # filename[:[R|F][O|W]][:BlockSize]\r
+  # filename can be a device node, like /dev/disk1\r
+  # R - Removable Media F - Fixed Media\r
+  # O - Write protected W - Writable\r
+  #   Default is Fixed Media, Writable\r
+  # For a file the default BlockSize is 512, and can be overridden via BlockSize,\r
+  #  for example 2048 for an ISO CD image. The block size for a device comes from\r
+  #  the device and is not configurable. \r
+  # Device Size comes from file or device. \r
+  # On Mac OS X you can use Disk Utility to create .dmg files and mount them like disks\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"disk.dmg:FW"|VOID*|0x00001001\r
+  \r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuGop|L"GOP Window"|VOID*|0x00001018\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFileSystem|L".!../../../../../EdkShellBinPkg/bin/ia32/Apps"|VOID*|0x00001004\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuSerialPort|L"/dev/ttyS0"|VOID*|0x00001002\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuNetworkInterface|L"en0"|VOID*|0x0000100d\r
+\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuCpuModel|L"Intel(R) Processor Model"|VOID*|0x00001007\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuCpuSpeed|L"3000"|VOID*|0x00001008\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuMpServicesPollingInterval|0x100|UINT64|0x0000101a\r
+\r
diff --git a/EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.c b/EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.c
new file mode 100644 (file)
index 0000000..ec9fe5c
--- /dev/null
@@ -0,0 +1,130 @@
+/*++ @file\r
+\r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#include "PiPei.h"\r
+#include <Ppi/EmuThunk.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializeFirmwareVolumePei (\r
+  IN       EFI_PEI_FILE_HANDLE       FileHandle,\r
+  IN CONST EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Perform a call-back into the SEC simulator to get address of the Firmware Hub\r
+\r
+Arguments:\r
+  FfsHeader   - Ffs Header availible to every PEIM\r
+  PeiServices - General purpose services available to every PEIM.\r
+    \r
+Returns:\r
+  None\r
+\r
+**/\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_PEI_PPI_DESCRIPTOR      *PpiDescriptor;\r
+  EMU_THUNK_PPI               *Thunk;\r
+  EFI_PHYSICAL_ADDRESS        FdBase;\r
+  EFI_PHYSICAL_ADDRESS        FdFixUp;\r
+  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
+  UINT64                      FdSize;\r
+  UINTN                       Index;\r
+\r
+  DEBUG ((EFI_D_ERROR, "Unix Firmware Volume PEIM Loaded\n"));\r
+\r
+  //\r
+  // Get the Fwh Information PPI\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+              &gEmuThunkPpiGuid,  // GUID\r
+              0,                  // INSTANCE\r
+              &PpiDescriptor,     // EFI_PEI_PPI_DESCRIPTOR\r
+              (VOID **)&Thunk     // PPI\r
+              );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Index = 0;\r
+  do {\r
+    //\r
+    // Get information about all the FD's in the system\r
+    //\r
+    Status = Thunk->FirmwareDevices (Index, &FdBase, &FdSize, &FdFixUp);\r
+    if (!EFI_ERROR (Status)) {\r
+      //\r
+      // Assume the FD starts with an FV header\r
+      //\r
+      FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase;\r
+\r
+      //\r
+      // Make an FV Hob for the first FV in the FD\r
+      //\r
+      BuildFvHob (FdBase, FvHeader->FvLength);\r
+\r
+      if (Index == 0) {\r
+        //\r
+        // Assume the first FD was produced by the NT32.DSC\r
+        //  All these strange offests are needed to keep in\r
+        //  sync with the FlashMap and NT32.dsc file\r
+        //\r
+        BuildResourceDescriptorHob (\r
+          EFI_RESOURCE_FIRMWARE_DEVICE,\r
+          (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
+          FdBase,\r
+          ( \r
+            FvHeader->FvLength + \r
+            PcdGet32 (PcdFlashNvStorageVariableSize) +\r
+            PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
+            PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
+            PcdGet32 (PcdEmuFlashNvStorageEventLogSize)\r
+          )\r
+        );\r
+\r
+        //\r
+        // Hard code the address of the spare block and variable services.\r
+        //  Assume it's a hard coded offset from FV0 in FD0.\r
+        //\r
+        FdSize  = \r
+          PcdGet32 (PcdFlashNvStorageVariableSize) +\r
+          PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
+          PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
+          PcdGet32 (PcdEmuFlashNvStorageEventLogSize);\r
+\r
+        BuildFvHob (FdFixUp + PcdGet64 (PcdEmuFlashNvStorageVariableBase), FdSize);\r
+      } else {\r
+        //\r
+        // For other FD's just map them in.\r
+        //\r
+        BuildResourceDescriptorHob (\r
+          EFI_RESOURCE_FIRMWARE_DEVICE,\r
+          (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
+          FdBase,\r
+          FdSize\r
+          );\r
+      }\r
+    }\r
+\r
+    Index++;\r
+  } while (!EFI_ERROR (Status));\r
+\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.inf b/EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.inf
new file mode 100644 (file)
index 0000000..368f947
--- /dev/null
@@ -0,0 +1,60 @@
+## @file\r
+# Component description file for EmuFwh module\r
+#\r
+# This PEIM will produce the HOB to describe Firmware Volume, Firmware Devices\r
+#  on the Emu emulator.\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = FirmwareVolumePei\r
+  FILE_GUID                      = 6DB075DE-449E-2644-96D0-CC5A1B4C3B2A\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  ENTRY_POINT                    = PeimInitializeFirmwareVolumePei\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  FirmwareVolumePei.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  PeiServicesTablePointerLib\r
+  PeiServicesLib\r
+  HobLib\r
+  PeimEntryPoint\r
+  DebugLib\r
+\r
+[Pcd]\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogSize\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
+\r
+[Ppis]\r
+  gEmuThunkPpiGuid                               # PPI ALWAYS_CONSUMED\r
+\r
+[Depex]\r
+  gEmuThunkPpiGuid AND gEfiPeiMemoryDiscoveredPpiGuid\r
+\r
diff --git a/EmulatorPkg/FlashMapPei/FlashMapPei.c b/EmulatorPkg/FlashMapPei/FlashMapPei.c
new file mode 100644 (file)
index 0000000..94c1874
--- /dev/null
@@ -0,0 +1,83 @@
+/*++ @file\r
+  PEIM to build GUIDed HOBs for platform specific flash map\r
+\r
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+\r
+#include "PiPei.h"\r
+\r
+#include <Guid/SystemNvDataGuid.h>\r
+#include <Ppi/EmuThunk.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializeFlashMap (\r
+  IN       EFI_PEI_FILE_HANDLE       FileHandle,\r
+  IN CONST EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Build GUIDed HOBs for platform specific flash map\r
+  \r
+Arguments:\r
+  FfsHeader   - A pointer to the EFI_FFS_FILE_HEADER structure.\r
+  PeiServices - General purpose services available to every PEIM.\r
+    \r
+Returns:\r
+  EFI_STATUS\r
+\r
+**/\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_THUNK_PPI           *Thunk;\r
+  EFI_PEI_PPI_DESCRIPTOR  *PpiDescriptor;\r
+  EFI_PHYSICAL_ADDRESS    FdBase;\r
+  EFI_PHYSICAL_ADDRESS    FdFixUp;\r
+  UINT64                  FdSize;\r
+\r
+  DEBUG ((EFI_D_ERROR, "EmulatorPkg Flash Map PEIM Loaded\n"));\r
+\r
+  //\r
+  // Get the Fwh Information PPI\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+            &gEmuThunkPpiGuid, // GUID\r
+            0,                 // INSTANCE\r
+            &PpiDescriptor,     // EFI_PEI_PPI_DESCRIPTOR\r
+            (VOID **)&Thunk       // PPI\r
+            );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Assume that FD0 contains the Flash map.\r
+  //\r
+  Status = Thunk->FirmwareDevices (0, &FdBase, &FdSize, &FdFixUp);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  \r
+  PcdSet64 (PcdFlashNvStorageVariableBase64, PcdGet64 (PcdEmuFlashNvStorageVariableBase) + FdFixUp);\r
+  PcdSet64 (PcdFlashNvStorageFtwWorkingBase64, PcdGet64 (PcdEmuFlashNvStorageFtwWorkingBase) + FdFixUp);\r
+  PcdSet64 (PcdFlashNvStorageFtwSpareBase64, PcdGet64 (PcdEmuFlashNvStorageFtwSpareBase) + FdFixUp);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EmulatorPkg/FlashMapPei/FlashMapPei.inf b/EmulatorPkg/FlashMapPei/FlashMapPei.inf
new file mode 100644 (file)
index 0000000..15a872a
--- /dev/null
@@ -0,0 +1,68 @@
+## @file\r
+# Component description file for FlashMap PEI module\r
+#\r
+# This module installs FlashMap PPI which is used to get flash layout information.\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = FlashMapPei\r
+  FILE_GUID                      = C9FAF091-57F8-A64C-A07A-445B124F0D93\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = PeimInitializeFlashMap\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  FlashMapPei.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  PcdLib\r
+  BaseMemoryLib\r
+  PeiServicesTablePointerLib\r
+  PeiServicesLib\r
+  HobLib\r
+  PeimEntryPoint\r
+  DebugLib\r
+\r
+\r
+[Ppis]\r
+  gEmuThunkPpiGuid                               # PPI ALWAYS_CONSUMED\r
+\r
+[Pcd]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64\r
+\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwWorkingBase\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase\r
+\r
+[Depex]\r
+  gEmuThunkPpiGuid\r
+\r
diff --git a/EmulatorPkg/FvbServicesRuntimeDxe/FWBlockService.c b/EmulatorPkg/FvbServicesRuntimeDxe/FWBlockService.c
new file mode 100644 (file)
index 0000000..a95b180
--- /dev/null
@@ -0,0 +1,1360 @@
+/*++ @file\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#include "PiDxe.h"\r
+#include <Guid/EventGroup.h>\r
+#include <Protocol/FirmwareVolumeBlock.h>\r
+#include <Protocol/DevicePath.h>\r
+\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DxeServicesTableLib.h>\r
+#include <Library/UefiRuntimeLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+#include "FwBlockService.h"\r
+\r
+ESAL_FWB_GLOBAL         *mFvbModuleGlobal;\r
+\r
+#define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)\r
+\r
+EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {\r
+  FVB_DEVICE_SIGNATURE,\r
+  {\r
+    {\r
+      {\r
+        HARDWARE_DEVICE_PATH,\r
+        HW_MEMMAP_DP,\r
+        {\r
+          sizeof (MEMMAP_DEVICE_PATH),\r
+          0\r
+        }\r
+      },\r
+      EfiMemoryMappedIO,\r
+      0,\r
+      0,\r
+    },\r
+    {\r
+      END_DEVICE_PATH_TYPE,\r
+      END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
+      {\r
+        sizeof (EFI_DEVICE_PATH_PROTOCOL),\r
+        0\r
+      }\r
+    }\r
+  },\r
+  0,\r
+  {\r
+    FvbProtocolGetAttributes,\r
+    FvbProtocolSetAttributes,\r
+    FvbProtocolGetPhysicalAddress,\r
+    FvbProtocolGetBlockSize,\r
+    FvbProtocolRead,\r
+    FvbProtocolWrite,\r
+    FvbProtocolEraseBlocks,\r
+    NULL\r
+  }\r
+};\r
+\r
+\r
+\r
+VOID\r
+EFIAPI\r
+FvbVirtualddressChangeEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Fixup internal data so that EFI and SAL can be call in virtual mode.\r
+  Call the passed in Child Notify event and convert the mFvbModuleGlobal\r
+  date items to there virtual address.\r
+\r
+  mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]  - Physical copy of instance data\r
+  mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]   - Virtual pointer to common \r
+                                                instance data.\r
+\r
+Arguments:\r
+\r
+  (Standard EFI notify event - EFI_EVENT_NOTIFY)\r
+\r
+Returns: \r
+\r
+  None\r
+\r
+**/\r
+{\r
+  EFI_FW_VOL_INSTANCE *FwhInstance;\r
+  UINTN               Index;\r
+\r
+  EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]);\r
+\r
+  //\r
+  // Convert the base address of all the instances\r
+  //\r
+  Index       = 0;\r
+  FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL];\r
+  while (Index < mFvbModuleGlobal->NumFv) {\r
+    EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase[FVB_VIRTUAL]);\r
+    FwhInstance = (EFI_FW_VOL_INSTANCE *)\r
+      (\r
+        (UINTN) ((UINT8 *) FwhInstance) + FwhInstance->VolumeHeader.HeaderLength +\r
+          (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
+      );\r
+    Index++;\r
+  }\r
+\r
+  EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal);\r
+}\r
+\r
+EFI_STATUS\r
+GetFvbInstance (\r
+  IN  UINTN                               Instance,\r
+  IN  ESAL_FWB_GLOBAL                     *Global,\r
+  OUT EFI_FW_VOL_INSTANCE                 **FwhInstance,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves the physical address of a memory mapped FV\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose base address is going to be\r
+                          returned\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  FwhInstance           - The EFI_FW_VOL_INSTANCE fimrware instance structure\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+  EFI_INVALID_PARAMETER - Instance not found\r
+\r
+**/\r
+{\r
+  EFI_FW_VOL_INSTANCE *FwhRecord;\r
+\r
+  if (Instance >= Global->NumFv) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Find the right instance of the FVB private data\r
+  //\r
+  FwhRecord = Global->FvInstance[Virtual];\r
+  while (Instance > 0) {\r
+    FwhRecord = (EFI_FW_VOL_INSTANCE *)\r
+      (\r
+        (UINTN) ((UINT8 *) FwhRecord) + FwhRecord->VolumeHeader.HeaderLength +\r
+          (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
+      );\r
+    Instance--;\r
+  }\r
+\r
+  *FwhInstance = FwhRecord;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FvbGetPhysicalAddress (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_PHYSICAL_ADDRESS                *Address,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves the physical address of a memory mapped FV\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose base address is going to be\r
+                          returned\r
+  Address               - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS \r
+                          that on successful return, contains the base address\r
+                          of the firmware volume. \r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+  EFI_INVALID_PARAMETER - Instance not found\r
+\r
+**/\r
+{\r
+  EFI_FW_VOL_INSTANCE *FwhInstance = NULL;\r
+  EFI_STATUS          Status;\r
+\r
+  //\r
+  // Find the right instance of the FVB private data\r
+  //\r
+  Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);\r
+  ASSERT_EFI_ERROR (Status);\r
+  *Address = FwhInstance->FvBase[Virtual];\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FvbGetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_FVB_ATTRIBUTES_2                *Attributes,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves attributes, insures positive polarity of attribute bits, returns\r
+  resulting attributes in output parameter\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose attributes is going to be \r
+                          returned\r
+  Attributes            - Output buffer which contains attributes\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+  EFI_INVALID_PARAMETER - Instance not found\r
+\r
+**/\r
+{\r
+  EFI_FW_VOL_INSTANCE *FwhInstance = NULL;\r
+  EFI_STATUS          Status;\r
+\r
+  //\r
+  // Find the right instance of the FVB private data\r
+  //\r
+  Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);\r
+  ASSERT_EFI_ERROR (Status);\r
+  *Attributes = FwhInstance->VolumeHeader.Attributes;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FvbGetLbaAddress (\r
+  IN  UINTN                               Instance,\r
+  IN  EFI_LBA                             Lba,\r
+  OUT UINTN                               *LbaAddress,\r
+  OUT UINTN                               *LbaLength,\r
+  OUT UINTN                               *NumOfBlocks,\r
+  IN  ESAL_FWB_GLOBAL                     *Global,\r
+  IN  BOOLEAN                             Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieves the starting address of an LBA in an FV\r
+\r
+Arguments:\r
+  Instance              - The FV instance which the Lba belongs to\r
+  Lba                   - The logical block address\r
+  LbaAddress            - On output, contains the physical starting address \r
+                          of the Lba\r
+  LbaLength             - On output, contains the length of the block\r
+  NumOfBlocks           - A pointer to a caller allocated UINTN in which the\r
+                          number of consecutive blocks starting with Lba is\r
+                          returned. All blocks in this range have a size of\r
+                          BlockSize\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+  EFI_INVALID_PARAMETER - Instance not found\r
+\r
+**/\r
+{\r
+  UINT32                  NumBlocks;\r
+  UINT32                  BlockLength;\r
+  UINTN                   Offset;\r
+  EFI_LBA                 StartLba;\r
+  EFI_LBA                 NextLba;\r
+  EFI_FW_VOL_INSTANCE     *FwhInstance = NULL;\r
+  EFI_FV_BLOCK_MAP_ENTRY  *BlockMap;\r
+  EFI_STATUS              Status;\r
+\r
+  //\r
+  // Find the right instance of the FVB private data\r
+  //\r
+  Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  StartLba  = 0;\r
+  Offset    = 0;\r
+  BlockMap  = &(FwhInstance->VolumeHeader.BlockMap[0]);\r
+\r
+  //\r
+  // Parse the blockmap of the FV to find which map entry the Lba belongs to\r
+  //\r
+  while (TRUE) {\r
+    NumBlocks   = BlockMap->NumBlocks;\r
+    BlockLength = BlockMap->Length;\r
+\r
+    if (NumBlocks == 0 || BlockLength == 0) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    NextLba = StartLba + NumBlocks;\r
+\r
+    //\r
+    // The map entry found\r
+    //\r
+    if (Lba >= StartLba && Lba < NextLba) {\r
+      Offset = Offset + (UINTN) MultU64x32 ((Lba - StartLba), BlockLength);\r
+      if (LbaAddress != NULL) {\r
+        *LbaAddress = FwhInstance->FvBase[Virtual] + Offset;\r
+      }\r
+\r
+      if (LbaLength != NULL) {\r
+        *LbaLength = BlockLength;\r
+      }\r
+\r
+      if (NumOfBlocks != NULL) {\r
+        *NumOfBlocks = (UINTN) (NextLba - Lba);\r
+      }\r
+\r
+      return EFI_SUCCESS;\r
+    }\r
+\r
+    StartLba  = NextLba;\r
+    Offset    = Offset + NumBlocks * BlockLength;\r
+    BlockMap++;\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+FvbReadBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  IN UINTN                                BlockOffset,\r
+  IN OUT UINTN                            *NumBytes,\r
+  IN UINT8                                *Buffer,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Reads specified number of bytes into a buffer from the specified block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be read from\r
+  Lba                   - The logical block address to be read from\r
+  BlockOffset           - Offset into the block at which to begin reading\r
+  NumBytes              - Pointer that on input contains the total size of\r
+                          the buffer. On output, it contains the total number\r
+                          of bytes read\r
+  Buffer                - Pointer to a caller allocated buffer that will be\r
+                          used to hold the data read\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was read successfully and \r
+                          contents are in Buffer\r
+  EFI_BAD_BUFFER_SIZE   - Read attempted across a LBA boundary. On output,\r
+                          NumBytes contains the total number of bytes returned\r
+                          in Buffer\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the ReadDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be read\r
+  EFI_INVALID_PARAMETER - Instance not found, or NumBytes, Buffer are NULL\r
+\r
+**/\r
+{\r
+  EFI_FVB_ATTRIBUTES_2  Attributes;\r
+  UINTN               LbaAddress;\r
+  UINTN               LbaLength;\r
+  EFI_STATUS          Status;\r
+\r
+  //\r
+  // Check for invalid conditions\r
+  //\r
+  if ((NumBytes == NULL) || (Buffer == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (*NumBytes == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL, Global, Virtual);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Check if the FV is read enabled\r
+  //\r
+  FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual);\r
+\r
+  if ((Attributes & EFI_FVB2_READ_STATUS) == 0) {\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+  //\r
+  // Perform boundary checks and adjust NumBytes\r
+  //\r
+  if (BlockOffset > LbaLength) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (LbaLength < (*NumBytes + BlockOffset)) {\r
+    *NumBytes = (UINT32) (LbaLength - BlockOffset);\r
+    Status    = EFI_BAD_BUFFER_SIZE;\r
+  }\r
+\r
+  CopyMem (Buffer, (UINT8 *) (LbaAddress + BlockOffset), (UINTN) (*NumBytes));\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+FvbWriteBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  IN UINTN                                BlockOffset,\r
+  IN OUT UINTN                            *NumBytes,\r
+  IN UINT8                                *Buffer,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Writes specified number of bytes from the input buffer to the block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be written to\r
+  Lba                   - The starting logical block index to write to\r
+  BlockOffset           - Offset into the block at which to begin writing\r
+  NumBytes              - Pointer that on input contains the total size of\r
+                          the buffer. On output, it contains the total number\r
+                          of bytes actually written\r
+  Buffer                - Pointer to a caller allocated buffer that contains\r
+                          the source for the write\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was written successfully\r
+  EFI_BAD_BUFFER_SIZE   - Write attempted across a LBA boundary. On output,\r
+                          NumBytes contains the total number of bytes\r
+                          actually written\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be written\r
+  EFI_INVALID_PARAMETER - Instance not found, or NumBytes, Buffer are NULL\r
+\r
+**/\r
+{\r
+  EFI_FVB_ATTRIBUTES_2  Attributes;\r
+  UINTN               LbaAddress;\r
+  UINTN               LbaLength;\r
+  EFI_STATUS          Status;\r
+\r
+  //\r
+  // Check for invalid conditions\r
+  //\r
+  if ((NumBytes == NULL) || (Buffer == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (*NumBytes == 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL, Global, Virtual);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Check if the FV is write enabled\r
+  //\r
+  FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual);\r
+\r
+  if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) {\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+  //\r
+  // Perform boundary checks and adjust NumBytes\r
+  //\r
+  if (BlockOffset > LbaLength) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (LbaLength < (*NumBytes + BlockOffset)) {\r
+    *NumBytes = (UINT32) (LbaLength - BlockOffset);\r
+    Status    = EFI_BAD_BUFFER_SIZE;\r
+  }\r
+  //\r
+  // Write data\r
+  //\r
+  CopyMem ((UINT8 *) (LbaAddress + BlockOffset), Buffer, (UINTN) (*NumBytes));\r
+\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+FvbEraseBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Erases and initializes a firmware volume block\r
+\r
+Arguments:\r
+  Instance              - The FV instance to be erased\r
+  Lba                   - The logical block index to be erased\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The erase request was successfully completed\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be written. Firmware device may have been\r
+                          partially erased\r
+  EFI_INVALID_PARAMETER - Instance not found\r
+\r
+**/\r
+{\r
+\r
+  EFI_FVB_ATTRIBUTES_2  Attributes;\r
+  UINTN                 LbaAddress;\r
+  UINTN                 LbaLength;\r
+  EFI_STATUS            Status;\r
+  UINT8                 Data;\r
+\r
+  //\r
+  // Check if the FV is write enabled\r
+  //\r
+  FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual);\r
+\r
+  if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) {\r
+    return EFI_ACCESS_DENIED;\r
+  }\r
+  //\r
+  // Get the starting address of the block for erase.\r
+  //\r
+  Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL, Global, Virtual);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if ((Attributes & EFI_FVB2_ERASE_POLARITY) != 0) {\r
+    Data = 0xFF;\r
+  } else {\r
+    Data = 0x0;\r
+  }\r
+\r
+  SetMem ((UINT8 *) LbaAddress, LbaLength, Data);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+FvbSetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  IN OUT EFI_FVB_ATTRIBUTES_2             *Attributes,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Modifies the current settings of the firmware volume according to the \r
+  input parameter, and returns the new setting of the volume\r
+\r
+Arguments:\r
+  Instance              - The FV instance whose attributes is going to be \r
+                          modified\r
+  Attributes            - On input, it is a pointer to EFI_FVB_ATTRIBUTES_2 \r
+                          containing the desired firmware volume settings.\r
+                          On successful return, it contains the new settings\r
+                          of the firmware volume\r
+  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
+                          instance data\r
+  Virtual               - Whether CPU is in virtual or physical mode\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+  EFI_ACCESS_DENIED     - The volume setting is locked and cannot be modified\r
+  EFI_INVALID_PARAMETER - Instance not found, or The attributes requested are\r
+                          in conflict with the capabilities as declared in the\r
+                          firmware volume header\r
+\r
+**/\r
+{\r
+  EFI_FW_VOL_INSTANCE   *FwhInstance = NULL;\r
+  EFI_FVB_ATTRIBUTES_2  OldAttributes;\r
+  EFI_FVB_ATTRIBUTES_2  *AttribPtr;\r
+  UINT32                Capabilities;\r
+  UINT32                OldStatus;\r
+  UINT32                NewStatus;\r
+  EFI_STATUS            Status;\r
+  EFI_FVB_ATTRIBUTES_2  UnchangedAttributes;\r
+\r
+\r
+  //\r
+  // Find the right instance of the FVB private data\r
+  //\r
+  Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  AttribPtr     = (EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes);\r
+  OldAttributes = *AttribPtr;\r
+  Capabilities  = OldAttributes & (EFI_FVB2_READ_DISABLED_CAP | \\r
+                                   EFI_FVB2_READ_ENABLED_CAP | \\r
+                                   EFI_FVB2_WRITE_DISABLED_CAP | \\r
+                                   EFI_FVB2_WRITE_ENABLED_CAP | \\r
+                                   EFI_FVB2_LOCK_CAP \\r
+                                   );\r
+\r
+  OldStatus     = OldAttributes & EFI_FVB2_STATUS;\r
+  NewStatus     = *Attributes & EFI_FVB2_STATUS;\r
+  UnchangedAttributes = EFI_FVB2_READ_DISABLED_CAP  | \\r
+                        EFI_FVB2_READ_ENABLED_CAP   | \\r
+                        EFI_FVB2_WRITE_DISABLED_CAP | \\r
+                        EFI_FVB2_WRITE_ENABLED_CAP  | \\r
+                        EFI_FVB2_LOCK_CAP           | \\r
+                        EFI_FVB2_STICKY_WRITE       | \\r
+                        EFI_FVB2_MEMORY_MAPPED      | \\r
+                        EFI_FVB2_ERASE_POLARITY     | \\r
+                        EFI_FVB2_READ_LOCK_CAP      | \\r
+                        EFI_FVB2_WRITE_LOCK_CAP     | \\r
+                        EFI_FVB2_ALIGNMENT;\r
+\r
+  //\r
+  // Some attributes of FV is read only can *not* be set\r
+  //\r
+  if ((OldAttributes & UnchangedAttributes) ^ (*Attributes & UnchangedAttributes)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // If firmware volume is locked, no status bit can be updated\r
+  //\r
+  if (OldAttributes & EFI_FVB2_LOCK_STATUS) {\r
+    if (OldStatus ^ NewStatus) {\r
+      return EFI_ACCESS_DENIED;\r
+    }\r
+  }\r
+  //\r
+  // Test read disable\r
+  //\r
+  if ((Capabilities & EFI_FVB2_READ_DISABLED_CAP) == 0) {\r
+    if ((NewStatus & EFI_FVB2_READ_STATUS) == 0) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Test read enable\r
+  //\r
+  if ((Capabilities & EFI_FVB2_READ_ENABLED_CAP) == 0) {\r
+    if (NewStatus & EFI_FVB2_READ_STATUS) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Test write disable\r
+  //\r
+  if ((Capabilities & EFI_FVB2_WRITE_DISABLED_CAP) == 0) {\r
+    if ((NewStatus & EFI_FVB2_WRITE_STATUS) == 0) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Test write enable\r
+  //\r
+  if ((Capabilities & EFI_FVB2_WRITE_ENABLED_CAP) == 0) {\r
+    if (NewStatus & EFI_FVB2_WRITE_STATUS) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+  //\r
+  // Test lock\r
+  //\r
+  if ((Capabilities & EFI_FVB2_LOCK_CAP) == 0) {\r
+    if (NewStatus & EFI_FVB2_LOCK_STATUS) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  }\r
+\r
+  *AttribPtr  = (*AttribPtr) & (0xFFFFFFFF & (~EFI_FVB2_STATUS));\r
+  *AttribPtr  = (*AttribPtr) | NewStatus;\r
+  *Attributes = *AttribPtr;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+//\r
+// FVB protocol APIs\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolGetPhysicalAddress (\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
+  OUT EFI_PHYSICAL_ADDRESS                        *Address\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Retrieves the physical address of the device.\r
+\r
+Arguments:\r
+\r
+  This                  - Calling context\r
+  Address               - Output buffer containing the address.\r
+\r
+Returns:\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+\r
+**/\r
+{\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  return FvbGetPhysicalAddress (FvbDevice->Instance, Address, mFvbModuleGlobal, EfiGoneVirtual ());\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolGetBlockSize (\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
+  IN  EFI_LBA                                     Lba,\r
+  OUT UINTN                                       *BlockSize,\r
+  OUT UINTN                                       *NumOfBlocks\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Retrieve the size of a logical block\r
+\r
+Arguments:\r
+  This                  - Calling context\r
+  Lba                   - Indicates which block to return the size for.\r
+  BlockSize             - A pointer to a caller allocated UINTN in which\r
+                          the size of the block is returned\r
+  NumOfBlocks           - a pointer to a caller allocated UINTN in which the\r
+                          number of consecutive blocks starting with Lba is\r
+                          returned. All blocks in this range have a size of\r
+                          BlockSize\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was read successfully and \r
+                          contents are in Buffer\r
+\r
+**/\r
+{\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  return FvbGetLbaAddress (\r
+          FvbDevice->Instance,\r
+          Lba,\r
+          NULL,\r
+          BlockSize,\r
+          NumOfBlocks,\r
+          mFvbModuleGlobal,\r
+          EfiGoneVirtual ()\r
+          );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolGetAttributes (\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
+  OUT EFI_FVB_ATTRIBUTES_2                        *Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+    Retrieves Volume attributes.  No polarity translations are done.\r
+\r
+Arguments:\r
+    This                - Calling context\r
+    Attributes          - output buffer which contains attributes\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+\r
+**/\r
+{\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  return FvbGetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ());\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolSetAttributes (\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
+  IN OUT EFI_FVB_ATTRIBUTES_2                     *Attributes\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Sets Volume attributes. No polarity translations are done.\r
+\r
+Arguments:\r
+  This                  - Calling context\r
+  Attributes            - output buffer which contains attributes\r
+\r
+Returns: \r
+  EFI_SUCCESS           - Successfully returns\r
+\r
+**/\r
+{\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  return FvbSetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ());\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolEraseBlocks (\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *This,\r
+  ...  \r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The EraseBlock() function erases one or more blocks as denoted by the \r
+  variable argument list. The entire parameter list of blocks must be verified\r
+  prior to erasing any blocks.  If a block is requested that does not exist \r
+  within the associated firmware volume (it has a larger index than the last \r
+  block of the firmware volume), the EraseBlock() function must return\r
+  EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.\r
+\r
+Arguments:\r
+  This                  - Calling context\r
+  ...                   - Starting LBA followed by Number of Lba to erase. \r
+                          a -1 to terminate the list.\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The erase request was successfully completed\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be written. Firmware device may have been\r
+                          partially erased\r
+\r
+**/\r
+{\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+  EFI_FW_VOL_INSTANCE     *FwhInstance = NULL;\r
+  UINTN                   NumOfBlocks;\r
+  VA_LIST                 args;\r
+  EFI_LBA                 StartingLba;\r
+  UINTN                   NumOfLba;\r
+  EFI_STATUS              Status;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  Status    = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal, &FwhInstance, EfiGoneVirtual ());\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  NumOfBlocks = FwhInstance->NumOfBlocks;\r
+\r
+  VA_START (args, This);\r
+\r
+  do {\r
+    StartingLba = VA_ARG (args, EFI_LBA);\r
+    if (StartingLba == EFI_LBA_LIST_TERMINATOR) {\r
+      break;\r
+    }\r
+\r
+    NumOfLba = VA_ARG (args, UINT32);\r
+\r
+    //\r
+    // Check input parameters\r
+    //\r
+    if (NumOfLba == 0) {\r
+      VA_END (args);\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    if ((StartingLba + NumOfLba) > NumOfBlocks) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+  } while (1);\r
+\r
+  VA_END (args);\r
+\r
+  VA_START (args, This);\r
+  do {\r
+    StartingLba = VA_ARG (args, EFI_LBA);\r
+    if (StartingLba == EFI_LBA_LIST_TERMINATOR) {\r
+      break;\r
+    }\r
+\r
+    NumOfLba = VA_ARG (args, UINT32);\r
+\r
+    while (NumOfLba > 0) {\r
+      Status = FvbEraseBlock (FvbDevice->Instance, StartingLba, mFvbModuleGlobal, EfiGoneVirtual ());\r
+      if (EFI_ERROR (Status)) {\r
+        VA_END (args);\r
+        return Status;\r
+      }\r
+\r
+      StartingLba++;\r
+      NumOfLba--;\r
+    }\r
+\r
+  } while (1);\r
+\r
+  VA_END (args);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolWrite (\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Writes data beginning at Lba:Offset from FV. The write terminates either\r
+  when *NumBytes of data have been written, or when a block boundary is\r
+  reached.  *NumBytes is updated to reflect the actual number of bytes\r
+  written. The write opertion does not include erase. This routine will\r
+  attempt to write only the specified bytes. If the writes do not stick,\r
+  it will return an error.\r
+\r
+Arguments:\r
+  This                  - Calling context\r
+  Lba                   - Block in which to begin write\r
+  Offset                - Offset in the block at which to begin write\r
+  NumBytes              - On input, indicates the requested write size. On\r
+                          output, indicates the actual number of bytes written\r
+  Buffer                - Buffer containing source data for the write.\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was written successfully\r
+  EFI_BAD_BUFFER_SIZE   - Write attempted across a LBA boundary. On output,\r
+                          NumBytes contains the total number of bytes\r
+                          actually written\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be written\r
+  EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL\r
+\r
+**/\r
+{\r
+\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  return FvbWriteBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer, mFvbModuleGlobal, EfiGoneVirtual ());\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolRead (\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Reads data beginning at Lba:Offset from FV. The Read terminates either\r
+  when *NumBytes of data have been read, or when a block boundary is\r
+  reached.  *NumBytes is updated to reflect the actual number of bytes\r
+  written. The write opertion does not include erase. This routine will\r
+  attempt to write only the specified bytes. If the writes do not stick,\r
+  it will return an error.\r
+\r
+Arguments:\r
+  This                  - Calling context\r
+  Lba                   - Block in which to begin Read\r
+  Offset                - Offset in the block at which to begin Read\r
+  NumBytes              - On input, indicates the requested write size. On\r
+                          output, indicates the actual number of bytes Read\r
+  Buffer                - Buffer containing source data for the Read.\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume was read successfully and \r
+                          contents are in Buffer\r
+  EFI_BAD_BUFFER_SIZE   - Read attempted across a LBA boundary. On output,\r
+                          NumBytes contains the total number of bytes returned\r
+                          in Buffer\r
+  EFI_ACCESS_DENIED     - The firmware volume is in the ReadDisabled state\r
+  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
+                          could not be read\r
+  EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL\r
+\r
+**/\r
+{\r
+\r
+  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
+\r
+  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
+\r
+  return FvbReadBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer, mFvbModuleGlobal, EfiGoneVirtual ());\r
+}\r
+EFI_STATUS\r
+ValidateFvHeader (\r
+  EFI_FIRMWARE_VOLUME_HEADER            *FwVolHeader\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Check the integrity of firmware volume header\r
+\r
+Arguments:\r
+  FwVolHeader           - A pointer to a firmware volume header\r
+\r
+Returns: \r
+  EFI_SUCCESS           - The firmware volume is consistent\r
+  EFI_NOT_FOUND         - The firmware volume has corrupted. So it is not an FV\r
+\r
+**/\r
+{\r
+  UINT16  *Ptr;\r
+  UINT16  HeaderLength;\r
+  UINT16  Checksum;\r
+\r
+  //\r
+  // Verify the header revision, header signature, length\r
+  // Length of FvBlock cannot be 2**64-1\r
+  // HeaderLength cannot be an odd number\r
+  //\r
+  if ((FwVolHeader->Revision != EFI_FVH_REVISION) ||\r
+      (FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||\r
+      (FwVolHeader->FvLength == ((UINTN) -1)) ||\r
+      ((FwVolHeader->HeaderLength & 0x01) != 0)\r
+      ) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  //\r
+  // Verify the header checksum\r
+  //\r
+  HeaderLength  = (UINT16) (FwVolHeader->HeaderLength / 2);\r
+  Ptr           = (UINT16 *) FwVolHeader;\r
+  Checksum      = 0;\r
+  while (HeaderLength > 0) {\r
+    Checksum = Checksum + (*Ptr);\r
+    HeaderLength--;\r
+    Ptr++;\r
+  }\r
+\r
+  if (Checksum != 0) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbInitialize (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function does common initialization for FVB services\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+**/\r
+{\r
+  EFI_STATUS                          Status;\r
+  EFI_FW_VOL_INSTANCE                 *FwhInstance = NULL;\r
+  EFI_FIRMWARE_VOLUME_HEADER          *FwVolHeader;\r
+  EFI_DXE_SERVICES                    *DxeServices;\r
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR     Descriptor;\r
+  UINT32                              BufferSize;\r
+  EFI_FV_BLOCK_MAP_ENTRY              *PtrBlockMapEntry;\r
+  EFI_HANDLE                          FwbHandle;\r
+  EFI_FW_VOL_BLOCK_DEVICE             *FvbDevice;\r
+  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *OldFwbInterface;\r
+  EFI_DEVICE_PATH_PROTOCOL            *TempFwbDevicePath;\r
+  FV_DEVICE_PATH                      TempFvbDevicePathData;\r
+  UINT32                              MaxLbaSize;\r
+  EFI_PHYSICAL_ADDRESS                BaseAddress;\r
+  UINT64                              Length;\r
+  UINTN                               NumOfBlocks;\r
+  EFI_PEI_HOB_POINTERS                FvHob;\r
+\r
+   //\r
+  // Get the DXE services table\r
+  //\r
+  DxeServices = gDS;\r
+\r
+  //\r
+  // Allocate runtime services data for global variable, which contains\r
+  // the private data of all firmware volume block instances\r
+  //\r
+  Status = gBS->AllocatePool (\r
+                  EfiRuntimeServicesData,\r
+                  sizeof (ESAL_FWB_GLOBAL),\r
+                  (VOID**) &mFvbModuleGlobal\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Calculate the total size for all firmware volume block instances\r
+  //\r
+  BufferSize            = 0;\r
+\r
+  FvHob.Raw = GetHobList ();\r
+  while ((FvHob.Raw = GetNextHob (EFI_HOB_TYPE_FV, FvHob.Raw)) != NULL) {\r
+    BaseAddress = FvHob.FirmwareVolume->BaseAddress;\r
+    Length      = FvHob.FirmwareVolume->Length;\r
+    //\r
+    // Check if it is a "real" flash\r
+    //\r
+    Status = DxeServices->GetMemorySpaceDescriptor (\r
+                            BaseAddress,\r
+                            &Descriptor\r
+                            );\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+\r
+    if (Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) {\r
+      FvHob.Raw = GET_NEXT_HOB (FvHob);\r
+      continue;\r
+    }\r
+\r
+    FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;\r
+    Status      = ValidateFvHeader (FwVolHeader);\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Get FvbInfo\r
+      //\r
+      Status = GetFvbInfo (Length, &FwVolHeader);\r
+      if (EFI_ERROR (Status)) {\r
+        FvHob.Raw = GET_NEXT_HOB (FvHob);\r
+        continue;\r
+      }\r
+    }\r
+\r
+    BufferSize += (sizeof (EFI_FW_VOL_INSTANCE) + FwVolHeader->HeaderLength - sizeof (EFI_FIRMWARE_VOLUME_HEADER));\r
+    FvHob.Raw = GET_NEXT_HOB (FvHob);\r
+  }\r
+\r
+  //\r
+  // Only need to allocate once. There is only one copy of physical memory for\r
+  // the private data of each FV instance. But in virtual mode or in physical\r
+  // mode, the address of the the physical memory may be different.\r
+  //\r
+  Status = gBS->AllocatePool (\r
+                  EfiRuntimeServicesData,\r
+                  BufferSize,\r
+                  (VOID**) &mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Make a virtual copy of the FvInstance pointer.\r
+  //\r
+  FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL];\r
+  mFvbModuleGlobal->FvInstance[FVB_VIRTUAL] = FwhInstance;\r
+\r
+  mFvbModuleGlobal->NumFv                   = 0;\r
+  MaxLbaSize = 0;\r
+\r
+  FvHob.Raw = GetHobList ();\r
+  while (NULL != (FvHob.Raw = GetNextHob (EFI_HOB_TYPE_FV, FvHob.Raw))) {\r
+    BaseAddress = FvHob.FirmwareVolume->BaseAddress;\r
+    Length      = FvHob.FirmwareVolume->Length;\r
+    //\r
+    // Check if it is a "real" flash\r
+    //\r
+    Status = DxeServices->GetMemorySpaceDescriptor (\r
+                            BaseAddress,\r
+                            &Descriptor\r
+                            );\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+\r
+    if (Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) {\r
+      FvHob.Raw = GET_NEXT_HOB (FvHob);\r
+      continue;\r
+    }\r
+\r
+    FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;\r
+    Status      = ValidateFvHeader (FwVolHeader);\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Get FvbInfo to provide in FwhInstance.\r
+      //\r
+      Status = GetFvbInfo (Length, &FwVolHeader);\r
+      if (EFI_ERROR (Status)) {\r
+        FvHob.Raw = GET_NEXT_HOB (FvHob);\r
+        continue;\r
+      }\r
+      //\r
+      //  Write healthy FV header back.\r
+      //\r
+      CopyMem (\r
+        (VOID *) (UINTN) BaseAddress,\r
+        (VOID *) FwVolHeader,\r
+        FwVolHeader->HeaderLength\r
+        );\r
+    }\r
+\r
+    FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN) BaseAddress;\r
+    FwhInstance->FvBase[FVB_VIRTUAL]  = (UINTN) BaseAddress;\r
+\r
+    CopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader, FwVolHeader->HeaderLength);\r
+    FwVolHeader = &(FwhInstance->VolumeHeader);\r
+    EfiInitializeLock (&(FwhInstance->FvbDevLock), TPL_HIGH_LEVEL);\r
+\r
+    NumOfBlocks = 0;\r
+\r
+    for (PtrBlockMapEntry = FwVolHeader->BlockMap; PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) {\r
+      //\r
+      // Get the maximum size of a block. The size will be used to allocate\r
+      // buffer for Scratch space, the intermediate buffer for FVB extension\r
+      // protocol\r
+      //\r
+      if (MaxLbaSize < PtrBlockMapEntry->Length) {\r
+        MaxLbaSize = PtrBlockMapEntry->Length;\r
+      }\r
+\r
+      NumOfBlocks = NumOfBlocks + PtrBlockMapEntry->NumBlocks;\r
+    }\r
+    //\r
+    // The total number of blocks in the FV.\r
+    //\r
+    FwhInstance->NumOfBlocks = NumOfBlocks;\r
+\r
+    //\r
+    // Add a FVB Protocol Instance\r
+    //\r
+    Status = gBS->AllocatePool (\r
+                    EfiRuntimeServicesData,\r
+                    sizeof (EFI_FW_VOL_BLOCK_DEVICE),\r
+                    (VOID**) &FvbDevice\r
+                    );\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    CopyMem (FvbDevice, &mFvbDeviceTemplate, sizeof (EFI_FW_VOL_BLOCK_DEVICE));\r
+\r
+    FvbDevice->Instance = mFvbModuleGlobal->NumFv;\r
+    mFvbModuleGlobal->NumFv++;\r
+\r
+    //\r
+    // Set up the devicepath\r
+    //\r
+    FvbDevice->DevicePath.MemMapDevPath.StartingAddress = BaseAddress;\r
+    FvbDevice->DevicePath.MemMapDevPath.EndingAddress   = BaseAddress + (FwVolHeader->FvLength - 1);\r
+\r
+    //\r
+    // Find a handle with a matching device path that has supports FW Block protocol\r
+    //\r
+    TempFwbDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) &TempFvbDevicePathData;\r
+    CopyMem (TempFwbDevicePath, &FvbDevice->DevicePath, sizeof (FV_DEVICE_PATH));\r
+    Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, &TempFwbDevicePath, &FwbHandle);\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // LocateDevicePath fails so install a new interface and device path\r
+      //\r
+      FwbHandle = NULL;\r
+      Status = gBS->InstallMultipleProtocolInterfaces (\r
+                      &FwbHandle,\r
+                      &gEfiFirmwareVolumeBlockProtocolGuid,\r
+                      &FvbDevice->FwVolBlockInstance,\r
+                      &gEfiDevicePathProtocolGuid,\r
+                      &FvbDevice->DevicePath,\r
+                      NULL\r
+                      );\r
+      ASSERT_EFI_ERROR (Status);\r
+    } else if (IsDevicePathEnd (TempFwbDevicePath)) {\r
+      //\r
+      // Device allready exists, so reinstall the FVB protocol\r
+      //\r
+      Status = gBS->HandleProtocol (\r
+                      FwbHandle,\r
+                      &gEfiFirmwareVolumeBlockProtocolGuid,\r
+                      (VOID**)&OldFwbInterface\r
+                      );\r
+      ASSERT_EFI_ERROR (Status);\r
+\r
+      Status = gBS->ReinstallProtocolInterface (\r
+                      FwbHandle,\r
+                      &gEfiFirmwareVolumeBlockProtocolGuid,\r
+                      OldFwbInterface,\r
+                      &FvbDevice->FwVolBlockInstance\r
+                      );\r
+      ASSERT_EFI_ERROR (Status);\r
+\r
+    } else {\r
+      //\r
+      // There was a FVB protocol on an End Device Path node\r
+      //\r
+      ASSERT (FALSE);\r
+    }\r
+\r
+    FwhInstance = (EFI_FW_VOL_INSTANCE *)\r
+      (\r
+        (UINTN) ((UINT8 *) FwhInstance) + FwVolHeader->HeaderLength +\r
+          (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
+      );\r
+\r
+    FvHob.Raw = GET_NEXT_HOB (FvHob);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EmulatorPkg/FvbServicesRuntimeDxe/FvbInfo.c b/EmulatorPkg/FvbServicesRuntimeDxe/FvbInfo.c
new file mode 100644 (file)
index 0000000..34f2910
--- /dev/null
@@ -0,0 +1,154 @@
+/*++ @file\r
+  Defines data structure that is the volume header found.These data is intent\r
+  to decouple FVB driver with FV header.\r
+\r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Guid/EventGroup.h>\r
+#include <Guid/FirmwareFileSystem2.h>\r
+#include <Guid/SystemNvDataGuid.h>\r
+\r
+#include <Protocol/FirmwareVolumeBlock.h>\r
+#include <Protocol/DevicePath.h>\r
+\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DxeServicesTableLib.h>\r
+#include <Library/UefiRuntimeLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+\r
+typedef struct {\r
+  UINT64                      FvLength;\r
+  EFI_FIRMWARE_VOLUME_HEADER  FvbInfo;\r
+  //\r
+  // EFI_FV_BLOCK_MAP_ENTRY    ExtraBlockMap[n];//n=0\r
+  //\r
+  EFI_FV_BLOCK_MAP_ENTRY      End[1];\r
+} EFI_FVB_MEDIA_INFO;\r
+\r
+EFI_FVB_MEDIA_INFO  mPlatformFvbMediaInfo[] = {\r
+  //\r
+  // Recovery BOIS FVB\r
+  //\r
+  {\r
+    FixedPcdGet32 (PcdEmuFlashFvRecoverySize),\r
+    {\r
+      {\r
+        0,\r
+      },  // ZeroVector[16]\r
+      EFI_FIRMWARE_FILE_SYSTEM2_GUID,\r
+      FixedPcdGet32 (PcdEmuFlashFvRecoverySize),\r
+      EFI_FVH_SIGNATURE,\r
+      EFI_FVB2_READ_ENABLED_CAP |\r
+        EFI_FVB2_READ_STATUS |\r
+        EFI_FVB2_WRITE_ENABLED_CAP |\r
+        EFI_FVB2_WRITE_STATUS |\r
+        EFI_FVB2_ERASE_POLARITY,\r
+      sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
+      0,  // CheckSum\r
+      0,  // ExtHeaderOffset\r
+      {\r
+        0,\r
+      },  // Reserved[1]\r
+      2,  // Revision\r
+      {\r
+        {\r
+          FixedPcdGet32 (PcdEmuFlashFvRecoverySize)/FixedPcdGet32 (PcdEmuFirmwareBlockSize),\r
+          FixedPcdGet32 (PcdEmuFirmwareBlockSize),\r
+        }\r
+      }\r
+    },\r
+    {\r
+      {\r
+        0,\r
+        0\r
+      }\r
+    }\r
+  },\r
+  //\r
+  // Systen NvStorage FVB\r
+  //\r
+  {\r
+    FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \\r
+    FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \\r
+    FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \\r
+    FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize),\r
+    {\r
+      {\r
+        0,\r
+      },  // ZeroVector[16]\r
+      EFI_SYSTEM_NV_DATA_FV_GUID,\r
+      FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \\r
+      FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \\r
+      FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \\r
+      FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize),\r
+      EFI_FVH_SIGNATURE,\r
+      EFI_FVB2_READ_ENABLED_CAP |\r
+        EFI_FVB2_READ_STATUS |\r
+        EFI_FVB2_WRITE_ENABLED_CAP |\r
+        EFI_FVB2_WRITE_STATUS |\r
+        EFI_FVB2_ERASE_POLARITY,\r
+      sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
+      0,  // CheckSum\r
+      0,  // ExtHeaderOffset\r
+      {\r
+        0,\r
+      },  // Reserved[1]\r
+      2,  // Revision\r
+      {\r
+        {\r
+          (FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \\r
+          FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \\r
+          FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \\r
+          FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdEmuFirmwareBlockSize),\r
+          FixedPcdGet32 (PcdEmuFirmwareBlockSize),\r
+        }\r
+      }\r
+    },\r
+    {\r
+      {\r
+        0,\r
+        0\r
+      }\r
+    }\r
+  }\r
+};\r
+\r
+EFI_STATUS\r
+GetFvbInfo (\r
+  IN  UINT64                        FvLength,\r
+  OUT EFI_FIRMWARE_VOLUME_HEADER    **FvbInfo\r
+  )\r
+{\r
+  UINTN Index;\r
+\r
+  for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {\r
+    if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {\r
+      *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
diff --git a/EmulatorPkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf b/EmulatorPkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
new file mode 100644 (file)
index 0000000..c7c21ab
--- /dev/null
@@ -0,0 +1,80 @@
+## @file\r
+# Component description file for Emu Fimware Volume Block DXE driver module.\r
+#\r
+# This DXE runtime driver implements and produces the Fimware Volue Block Protocol on \r
+#  Emu emulator.\r
+# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = FwBlockService\r
+  FILE_GUID                      = A01E498C-96E8-2A4C-95F4-85248F989753\r
+  MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  ENTRY_POINT                    = FvbInitialize\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  FvbInfo.c\r
+  FWBlockService.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  BaseMemoryLib\r
+  HobLib\r
+  DebugLib\r
+  UefiRuntimeLib\r
+  DxeServicesTableLib\r
+  BaseLib\r
+  UefiDriverEntryPoint\r
+  UefiLib\r
+  DevicePathLib\r
+\r
+[Guids]\r
+  gEfiEventVirtualAddressChangeGuid             # ALWAYS_CONSUMED  Create Event: EVENT_GROUP_GUID\r
+\r
+[Protocols]\r
+  gEfiFirmwareVolumeBlockProtocolGuid           # PROTOCOL ALWAYS_PRODUCED\r
+  gEfiDevicePathProtocolGuid                    # PROTOCOL SOMETIMES_PRODUCED\r
+\r
+[FixedPcd]\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFirmwareFdSize\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFirmwareBlockSize\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashFvRecoveryBase\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashFvRecoverySize\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogBase\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogSize\r
+\r
+[Pcd]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase\r
+\r
+[Depex]\r
+  TRUE\r
+\r
diff --git a/EmulatorPkg/FvbServicesRuntimeDxe/FwBlockService.h b/EmulatorPkg/FvbServicesRuntimeDxe/FwBlockService.h
new file mode 100644 (file)
index 0000000..e498451
--- /dev/null
@@ -0,0 +1,219 @@
+/*++ @file\r
+  Firmware volume block driver for Intel Firmware Hub (FWH) device\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#ifndef _FW_BLOCK_SERVICE_H\r
+#define _FW_BLOCK_SERVICE_H\r
+\r
+//\r
+// BugBug: Add documentation here for data structure!!!!\r
+//\r
+#define FVB_PHYSICAL  0\r
+#define FVB_VIRTUAL   1\r
+\r
+typedef struct {\r
+  EFI_LOCK                    FvbDevLock;\r
+  UINTN                       FvBase[2];\r
+  UINTN                       NumOfBlocks;\r
+  EFI_FIRMWARE_VOLUME_HEADER  VolumeHeader;\r
+} EFI_FW_VOL_INSTANCE;\r
+\r
+typedef struct {\r
+  UINT32              NumFv;\r
+  EFI_FW_VOL_INSTANCE *FvInstance[2];\r
+} ESAL_FWB_GLOBAL;\r
+\r
+//\r
+// Fvb Protocol instance data\r
+//\r
+#define FVB_DEVICE_FROM_THIS(a)         CR (a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE)\r
+#define FVB_EXTEND_DEVICE_FROM_THIS(a)  CR (a, EFI_FW_VOL_BLOCK_DEVICE, FvbExtension, FVB_DEVICE_SIGNATURE)\r
+#define FVB_DEVICE_SIGNATURE            SIGNATURE_32 ('F', 'V', 'B', 'N')\r
+\r
+typedef struct {\r
+  MEMMAP_DEVICE_PATH        MemMapDevPath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevPath;\r
+} FV_DEVICE_PATH;\r
+\r
+typedef struct {\r
+  UINTN                               Signature;\r
+  FV_DEVICE_PATH                      DevicePath;\r
+  UINTN                               Instance;\r
+  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  FwVolBlockInstance;\r
+} EFI_FW_VOL_BLOCK_DEVICE;\r
+\r
+EFI_STATUS\r
+GetFvbInfo (\r
+  IN  UINT64                            FvLength,\r
+  OUT EFI_FIRMWARE_VOLUME_HEADER        **FvbInfo\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbReadBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  IN UINTN                                BlockOffset,\r
+  IN OUT UINTN                            *NumBytes,\r
+  IN UINT8                                *Buffer,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbWriteBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  IN UINTN                                BlockOffset,\r
+  IN OUT UINTN                            *NumBytes,\r
+  IN UINT8                                *Buffer,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbEraseBlock (\r
+  IN UINTN                                Instance,\r
+  IN EFI_LBA                              Lba,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbSetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  IN OUT EFI_FVB_ATTRIBUTES_2             *Attributes,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbGetVolumeAttributes (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_FVB_ATTRIBUTES_2                *Attributes,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbGetPhysicalAddress (\r
+  IN UINTN                                Instance,\r
+  OUT EFI_PHYSICAL_ADDRESS                *Address,\r
+  IN ESAL_FWB_GLOBAL                      *Global,\r
+  IN BOOLEAN                              Virtual\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbInitialize (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+;\r
+\r
+\r
+VOID\r
+EFIAPI\r
+FvbClassAddressChangeEvent (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+FvbGetLbaAddress (\r
+  IN  UINTN                               Instance,\r
+  IN  EFI_LBA                             Lba,\r
+  OUT UINTN                               *LbaAddress,\r
+  OUT UINTN                               *LbaLength,\r
+  OUT UINTN                               *NumOfBlocks,\r
+  IN  ESAL_FWB_GLOBAL                     *Global,\r
+  IN  BOOLEAN                             Virtual\r
+  )\r
+;\r
+\r
+//\r
+// Protocol APIs\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolGetAttributes (\r
+  IN  CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  OUT       EFI_FVB_ATTRIBUTES_2                         *Attributes\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolSetAttributes (\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN OUT   EFI_FVB_ATTRIBUTES_2                         *Attributes\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolGetPhysicalAddress (\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  OUT      EFI_PHYSICAL_ADDRESS                         *Address\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolGetBlockSize (\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
+  IN  EFI_LBA                                     Lba,\r
+  OUT UINTN                                       *BlockSize,\r
+  OUT UINTN                                       *NumOfBlocks\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolRead (\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolWrite (\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
+  IN EFI_LBA                                      Lba,\r
+  IN UINTN                                        Offset,\r
+  IN OUT UINTN                                    *NumBytes,\r
+  IN UINT8                                        *Buffer\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+FvbProtocolEraseBlocks (\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *This,\r
+  ...\r
+  )\r
+;\r
+\r
+#endif\r
diff --git a/EmulatorPkg/Include/Guid/EmuPhysicalDisk.h b/EmulatorPkg/Include/Guid/EmuPhysicalDisk.h
new file mode 100644 (file)
index 0000000..324dc04
--- /dev/null
@@ -0,0 +1,24 @@
+/** @file\r
+  Setup Variable data structure for Emu platform.\r
+\r
+Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+**/\r
+\r
+#ifndef __EMU_PHYSICAL_DISK_H__\r
+#define __EMU_PHYSICAL_DISK_H__\r
+\r
+#define EFI_EMU_PHYSICAL_DISK_GUID  \\r
+ { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }\r
+\r
+extern EFI_GUID   gEmuPhysicalDisksGuid;\r
+\r
+#endif\r
diff --git a/EmulatorPkg/Include/Guid/EmuSystemConfig.h b/EmulatorPkg/Include/Guid/EmuSystemConfig.h
new file mode 100644 (file)
index 0000000..b3a7d9b
--- /dev/null
@@ -0,0 +1,36 @@
+/** @file\r
+  Setup Variable data structure for Emu platform.\r
+\r
+Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+**/\r
+\r
+#ifndef __EMU_SYSTEM_CONFIG_H__\r
+#define __EMU_SYSTEM_CONFIG_H__\r
+\r
+#define EFI_EMU_SYSTEM_CONFIG_GUID  \\r
+ { 0x9C4FB516, 0x3A1E, 0xD847, { 0xA1, 0xA1, 0x70, 0x58, 0xB6, 0x98, 0x67, 0x32 } }\r
+\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+  //\r
+  // Console output mode\r
+  //\r
+  UINT32        ConOutColumn;\r
+  UINT32        ConOutRow;\r
+} EMU_SYSTEM_CONFIGURATION;\r
+#pragma pack()\r
+\r
+\r
+extern EFI_GUID   gEmuSystemConfigGuid;\r
+\r
+#endif\r
diff --git a/EmulatorPkg/Include/Guid/EmuVirtualDisk.h b/EmulatorPkg/Include/Guid/EmuVirtualDisk.h
new file mode 100644 (file)
index 0000000..17b97dc
--- /dev/null
@@ -0,0 +1,24 @@
+/** @file\r
+  Setup Variable data structure for Emu platform.\r
+\r
+Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+**/\r
+\r
+#ifndef __EMU_VIRTUAL_DISK_H__\r
+#define __EMU_VIRTUAL_DISK_H__\r
+\r
+#define EFI_EMU_VIRTUAL_DISK_GUID  \\r
+ { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }\r
+\r
+extern EFI_GUID   gEmuVirtualDisksGuid;\r
+\r
+#endif\r
diff --git a/EmulatorPkg/Include/Library/EmuMagicPageLib.h b/EmulatorPkg/Include/Library/EmuMagicPageLib.h
new file mode 100644 (file)
index 0000000..a701b76
--- /dev/null
@@ -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.<BR>
+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 <PiPei.h>
+#include <Library/PcdLib.h>
+#include <Protocol/EmuThunk.h>
+
+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 (file)
index 0000000..9d69d4f
--- /dev/null
@@ -0,0 +1,42 @@
+/*++ @file
+
+Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
+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 <Protocol/EmuThunk.h>
+
+
+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 (file)
index 0000000..7bd29a7
--- /dev/null
@@ -0,0 +1,43 @@
+/*++ @file\r
+\r
+Copyright (c) 2011, Apple Inc. All rights reserved. \r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Protocol/SimpleTextInEx.h>\r
+\r
+\r
+/**\r
+  KeyMapMake gets called on key presses.\r
+\r
+  @param  KeyData       Key that was pressed.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+KeyMapMake (\r
+  IN EFI_KEY_DATA   *KeyData\r
+  );\r
+\r
+/**\r
+  KeyMapBreak gets called on key releases.\r
+\r
+  @param  KeyData       Key that was pressed.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+KeyMapBreak (\r
+  IN EFI_KEY_DATA   *KeyData\r
+  );\r
diff --git a/EmulatorPkg/Include/Library/PpiListLib.h b/EmulatorPkg/Include/Library/PpiListLib.h
new file mode 100644 (file)
index 0000000..061cfca
--- /dev/null
@@ -0,0 +1,21 @@
+/*++ @file
+
+Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
+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 (file)
index 0000000..febc972
--- /dev/null
@@ -0,0 +1,33 @@
+/** @file\r
+  All 3rd parties to register the PPIs passed into PEI Core\r
+\r
+  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
+  \r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+\r
+\r
+EFI_PEI_PPI_DESCRIPTOR *\r
+GetThunkPpiList (\r
+  VOID\r
+  );\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+AddThunkPpi (\r
+  IN  UINTN     Flags,\r
+  IN  EFI_GUID  *Guid,\r
+  IN  VOID      *Ppi\r
+  );\r
+\r
+\r
diff --git a/EmulatorPkg/Include/Library/ThunkProtocolList.h b/EmulatorPkg/Include/Library/ThunkProtocolList.h
new file mode 100644 (file)
index 0000000..5b25f9c
--- /dev/null
@@ -0,0 +1,35 @@
+/** @file\r
+  Emulator Thunk to abstract OS services from pure EFI code\r
+\r
+  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
+  \r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Uefi.h>\r
+#include <Protocol/EmuIoThunk.h>\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+AddThunkProtocol (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *ThunkIo,  \r
+  IN  CHAR16                  *ConfigString,\r
+  IN  BOOLEAN                 EmuBusDriver\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GetNextThunkProtocol (\r
+  IN  BOOLEAN                 EmuBusDriver,\r
+  OUT EMU_IO_THUNK_PROTOCOL   **Instance  \r
+  );\r
+  \r
+\r
diff --git a/EmulatorPkg/Include/Ppi/EmuThunk.h b/EmulatorPkg/Include/Ppi/EmuThunk.h
new file mode 100644 (file)
index 0000000..20cdc46
--- /dev/null
@@ -0,0 +1,127 @@
+/** @file\r
+  Emulator Thunk to abstract OS services from pure EFI code\r
+\r
+  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
+  \r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __EMU_THUNK_PPI_H__\r
+#define __EMU_THUNK_PPI_H__\r
+\r
+#define EMU_THUNK_PPI_GUID  \\r
+ { 0xB958B78C, 0x1D3E, 0xEE40, { 0x8B, 0xF4, 0xF0, 0x63, 0x2D, 0x06, 0x39, 0x16 } }\r
+\r
+\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  This service is called from Index == 0 until it returns EFI_UNSUPPORTED.\r
+  It allows discontiguous memory regions to be supported by the emulator.\r
+\r
+Arguments:\r
+  Index      - Which memory region to use\r
+  MemoryBase - Return Base address of memory region\r
+  MemorySize - Return size in bytes of the memory region\r
+\r
+Returns:\r
+  EFI_SUCCESS - If memory region was mapped\r
+  EFI_UNSUPPORTED - If Index is not supported\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_PEI_AUTOSCAN) (\r
+  IN  UINTN                 Index,\r
+  OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,\r
+  OUT UINT64                *MemorySize\r
+  );\r
+\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Return the FD Size and base address. Since the FD is loaded from a \r
+  file into host memory only the SEC will know it's address.\r
+\r
+Arguments:\r
+  Index  - Which FD, starts at zero.\r
+  FdSize - Size of the FD in bytes\r
+  FdBase - Start address of the FD. Assume it points to an FV Header\r
+  FixUp  - Difference between actual FD address and build address\r
+\r
+Returns:\r
+  EFI_SUCCESS     - Return the Base address and size of the FV\r
+  EFI_UNSUPPORTED - Index does nto map to an FD in the system\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_PEI_FD_INFORMATION) (\r
+  IN     UINTN                  Index,\r
+  IN OUT EFI_PHYSICAL_ADDRESS   *FdBase,\r
+  IN OUT UINT64                 *FdSize,\r
+  IN OUT EFI_PHYSICAL_ADDRESS   *FixUp\r
+  );\r
+\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Export of EMU_THUNK_PROTOCOL from the SEC.\r
+\r
+Returns:\r
+  EFI_SUCCESS - Data returned\r
+\r
+**/\r
+typedef\r
+VOID *\r
+(EFIAPI *EMU_PEI_THUNK_INTERFACE) (\r
+  VOID\r
+  );\r
+\r
+\r
+\r
+/*++\r
+\r
+Routine Description:\r
+  Loads and relocates a PE/COFF image into memory.\r
+\r
+Arguments:\r
+  Pe32Data         - The base address of the PE/COFF file that is to be loaded and relocated\r
+  ImageAddress     - The base address of the relocated PE/COFF image\r
+  ImageSize        - The size of the relocated PE/COFF image\r
+  EntryPoint       - The entry point of the relocated PE/COFF image\r
+\r
+Returns:\r
+  EFI_SUCCESS   - The file was loaded and relocated\r
+  EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_PEI_LOAD_FILE) (\r
+  VOID                  *Pe32Data,\r
+  EFI_PHYSICAL_ADDRESS  *ImageAddress,\r
+  UINT64                *ImageSize,\r
+  EFI_PHYSICAL_ADDRESS  *EntryPoint\r
+  );\r
+\r
+\r
+typedef struct {\r
+  EMU_PEI_AUTOSCAN                  MemoryAutoScan;\r
+  EMU_PEI_FD_INFORMATION            FirmwareDevices;\r
+  EMU_PEI_THUNK_INTERFACE           Thunk;\r
+} EMU_THUNK_PPI;\r
+\r
+extern EFI_GUID gEmuThunkPpiGuid;\r
+\r
+#endif\r
diff --git a/EmulatorPkg/Include/Protocol/EmuBlockIo.h b/EmulatorPkg/Include/Protocol/EmuBlockIo.h
new file mode 100644 (file)
index 0000000..26d6bb8
--- /dev/null
@@ -0,0 +1,192 @@
+/** @file\r
+  Emu Block IO2 protocol as defined in the UEFI 2.3.1 specification.\r
+\r
+  The Block IO2 protocol defines an extension to the Block IO protocol which\r
+  enables the ability to read and write data at a block level in a non-blocking\r
+  manner.\r
+\r
+  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#ifndef __EMU_BLOCK_IO_H__\r
+#define __EMU_BLOCK_IO_H__\r
+\r
+#include <Protocol/BlockIo.h>\r
+#include <Protocol/BlockIo2.h>\r
+\r
+#define EMU_BLOCK_IO_PROTOCOL_GUID \\r
+{ 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }\r
+\r
+typedef struct _EMU_BLOCK_IO_PROTOCOL   EMU_BLOCK_IO_PROTOCOL;\r
+\r
+\r
+\r
+/**\r
+  Reset the block device hardware.\r
+\r
+  @param[in]  This                 Indicates a pointer to the calling context.\r
+  @param[in]  ExtendedVerification Indicates that the driver may perform a more\r
+                                   exhausive verfication operation of the device\r
+                                   during reset.\r
+\r
+  @retval EFI_SUCCESS          The device was reset.\r
+  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
+                               not be reset.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_BLOCK_RESET) (\r
+  IN EMU_BLOCK_IO_PROTOCOL   *This,\r
+  IN BOOLEAN                 ExtendedVerification\r
+  );\r
+\r
+/**\r
+  Read BufferSize bytes from Lba into Buffer.\r
+  \r
+  This function reads the requested number of blocks from the device. All the\r
+  blocks are read, or an error is returned.\r
+  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and\r
+  non-blocking I/O is being used, the Event associated with this request will\r
+  not be signaled.\r
+\r
+  @param[in]       This       Indicates a pointer to the calling context.\r
+  @param[in]       MediaId    Id of the media, changes every time the media is \r
+                              replaced.\r
+  @param[in]       Lba        The starting Logical Block Address to read from.\r
+  @param[in, out]  Token           A pointer to the token associated with the transaction.\r
+  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.  \r
+  @param[out]      Buffer     A pointer to the destination buffer for the data. The \r
+                              caller is responsible for either having implicit or \r
+                              explicit ownership of the buffer.\r
+\r
+  @retval EFI_SUCCESS           The read request was queued if Token->Event is\r
+                                not NULL.The data was read correctly from the\r
+                                device if the Token->Event is NULL.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error while performing\r
+                                the read.\r
+  @retval EFI_NO_MEDIA          There is no media in the device.\r
+  @retval EFI_MEDIA_CHANGED     The MediaId is not for the current media.\r
+  @retval EFI_BAD_BUFFER_SIZE   The BufferSize parameter is not a multiple of the\r
+                                intrinsic block size of the device.\r
+  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
+                                or the buffer is not on proper alignment.\r
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack\r
+                                of resources.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_BLOCK_READ) (\r
+  IN     EMU_BLOCK_IO_PROTOCOL  *This,\r
+  IN     UINT32                 MediaId,\r
+  IN     EFI_LBA                LBA,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
+  IN     UINTN                  BufferSize,\r
+     OUT VOID                   *Buffer\r
+  );\r
+\r
+/**\r
+  Write BufferSize bytes from Lba into Buffer.\r
+\r
+  This function writes the requested number of blocks to the device. All blocks\r
+  are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,\r
+  EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is\r
+  being used, the Event associated with this request will not be signaled.\r
+\r
+  @param[in]       This       Indicates a pointer to the calling context.\r
+  @param[in]       MediaId    The media ID that the write request is for.\r
+  @param[in]       Lba        The starting logical block address to be written. The\r
+                              caller is responsible for writing to only legitimate\r
+                              locations.\r
+  @param[in, out]  Token      A pointer to the token associated with the transaction.\r
+  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.\r
+  @param[in]       Buffer     A pointer to the source buffer for the data.\r
+\r
+  @retval EFI_SUCCESS           The write request was queued if Event is not NULL.\r
+                                The data was written correctly to the device if\r
+                                the Event is NULL.\r
+  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
+  @retval EFI_NO_MEDIA          There is no media in the device.\r
+  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
+  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
+  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
+                                or the buffer is not on proper alignment.\r
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack\r
+                                of resources.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_BLOCK_WRITE) (\r
+  IN     EMU_BLOCK_IO_PROTOCOL  *This,\r
+  IN     UINT32                 MediaId,\r
+  IN     EFI_LBA                LBA,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
+  IN     UINTN                  BufferSize,\r
+  IN     VOID                   *Buffer\r
+  );\r
+\r
+/**\r
+  Flush the Block Device.\r
\r
+  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED\r
+  is returned and non-blocking I/O is being used, the Event associated with\r
+  this request will not be signaled.  \r
+\r
+  @param[in]      This     Indicates a pointer to the calling context.\r
+  @param[in,out]  Token    A pointer to the token associated with the transaction\r
+\r
+  @retval EFI_SUCCESS          The flush request was queued if Event is not NULL.\r
+                               All outstanding data was written correctly to the\r
+                               device if the Event is NULL.\r
+  @retval EFI_DEVICE_ERROR     The device reported an error while writting back\r
+                               the data.\r
+  @retval EFI_WRITE_PROTECTED  The device cannot be written to.\r
+  @retval EFI_NO_MEDIA         There is no media in the device.\r
+  @retval EFI_MEDIA_CHANGED    The MediaId is not for the current media.\r
+  @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
+                               of resources.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_BLOCK_FLUSH) (\r
+  IN     EMU_BLOCK_IO_PROTOCOL    *This,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN      *Token\r
+  );\r
+\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_BLOCK_CREATE_MAPPING) (\r
+  IN     EMU_BLOCK_IO_PROTOCOL    *This,\r
+  IN     EFI_BLOCK_IO_MEDIA       *Media\r
+  );\r
+\r
+\r
+///\r
+///  The Block I/O2 protocol defines an extension to the Block I/O protocol which\r
+///  enables the ability to read and write data at a block level in a non-blocking\r
+//   manner.\r
+///\r
+struct _EMU_BLOCK_IO_PROTOCOL  {\r
+  EMU_BLOCK_RESET           Reset;\r
+  EMU_BLOCK_READ            ReadBlocks;\r
+  EMU_BLOCK_WRITE           WriteBlocks;\r
+  EMU_BLOCK_FLUSH           FlushBlocks;\r
+  EMU_BLOCK_CREATE_MAPPING  CreateMapping;\r
+};\r
+\r
+extern EFI_GUID gEmuBlockIoProtocolGuid;\r
+\r
+#endif\r
+\r
diff --git a/EmulatorPkg/Include/Protocol/EmuFileSystem.h b/EmulatorPkg/Include/Protocol/EmuFileSystem.h
new file mode 100644 (file)
index 0000000..3713acf
--- /dev/null
@@ -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.<BR>
+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 <Protocol/SimplePointer.h>
+#include <Protocol/SimpleTextIn.h>
+#include <Protocol/SimpleTextInEx.h>
+#include <Protocol/UgaDraw.h>
+
+#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 (file)
index 0000000..e1afa0e
--- /dev/null
@@ -0,0 +1,134 @@
+/*++ @file
+
+Copyright (c) 2006, Tristan Gingold. All rights reserved.<BR>
+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 <Protocol/SimplePointer.h>
+#include <Protocol/SimpleTextIn.h>
+#include <Protocol/SimpleTextInEx.h>
+#include <Protocol/UgaDraw.h>
+
+#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 (file)
index 0000000..af132be
--- /dev/null
@@ -0,0 +1,51 @@
+/** @file\r
+  Emulator Thunk to abstract OS services from pure EFI code\r
+\r
+  Copyright (c) 2010 - 2011, Apple Inc. All rights reserved.<BR>\r
+  \r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __EMU_IO_THUNK__ \r
+#define __EMU_IO_THUNK__\r
+\r
+\r
+#define EMU_IO_THUNK_PROTOCO_GUID  \\r
+ { 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } }\r
+\r
+\r
+typedef struct _EMU_IO_THUNK_PROTOCOL  EMU_IO_THUNK_PROTOCOL;\r
+\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN) (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  );\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE) (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  );\r
+\r
+struct _EMU_IO_THUNK_PROTOCOL {\r
+  EFI_GUID                            *Protocol;\r
+  VOID                                *Interface;  /// Only be valid after Open() is called\r
+  CHAR16                              *ConfigString;\r
+  UINT16                              Instance;\r
+  EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN    Open;\r
+  EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE   Close;\r
+  VOID                                *Private;    /// Used by implementation \r
+};\r
+\r
+extern EFI_GUID gEmuIoThunkProtocolGuid;\r
+\r
+#endif\r
diff --git a/EmulatorPkg/Include/Protocol/EmuSnp.h b/EmulatorPkg/Include/Protocol/EmuSnp.h
new file mode 100644 (file)
index 0000000..fc8e24c
--- /dev/null
@@ -0,0 +1,459 @@
+/** @file\r
+  The EMU_SNP_PROTOCOL provides services to initialize a network interface, \r
+  transmit packets, receive packets, and close a network interface.\r
+\r
+\r
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Portitions copyright (c) 2011, Apple Inc. All rights reserved. \r
+This program and the accompanying materials are licensed and made available under \r
+the terms and conditions of the BSD License that accompanies this distribution.  \r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php.                                          \r
+    \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.   \r
+\r
+**/\r
+\r
+#ifndef __EMU_SNP_H__\r
+#define __EMU_SNP_H__\r
+\r
+#include <Protocol/SimpleNetwork.h>\r
+\r
+#define EMU_SNP_PROTOCOL_GUID \\r
+ { 0xFD5FBE54, 0x8C35, 0xB345, { 0x8A, 0x0F, 0x7A, 0xC8, 0xA5, 0xFD, 0x05, 0x21 } }\r
+\r
+typedef struct _EMU_SNP_PROTOCOL  EMU_SNP_PROTOCOL;\r
+\r
+\r
+/**\r
+  Register storage for SNP Mode.\r
+\r
+  @param  This Protocol instance pointer.\r
+  @param  Mode SimpleNetworkProtocol Mode structure passed into driver.\r
+\r
+  @retval EFI_SUCCESS           The network interface was started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_CREATE_MAPPING)(\r
+  IN EMU_SNP_PROTOCOL         *This,\r
+  IN EFI_SIMPLE_NETWORK_MODE  *Mode\r
+  );\r
+\r
+\r
+/**\r
+  Changes the state of a network interface from "stopped" to "started".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           The network interface was started.\r
+  @retval EFI_ALREADY_STARTED   The network interface is already in the started state.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_START)(\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  );\r
+\r
+/**\r
+  Changes the state of a network interface from "started" to "stopped".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           The network interface was stopped.\r
+  @retval EFI_ALREADY_STARTED   The network interface is already in the stopped state.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_STOP)(\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  );\r
+\r
+/**\r
+  Resets a network adapter and allocates the transmit and receive buffers \r
+  required by the network interface; optionally, also requests allocation \r
+  of additional transmit and receive buffers.\r
+\r
+  @param  This              The protocol instance pointer.\r
+  @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+  @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+\r
+  @retval EFI_SUCCESS           The network interface was initialized.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_OUT_OF_RESOURCES  There was not enough memory for the transmit and\r
+                                receive buffers.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_INITIALIZE)(\r
+  IN EMU_SNP_PROTOCOL                    *This,\r
+  IN UINTN                               ExtraRxBufferSize  OPTIONAL,\r
+  IN UINTN                               ExtraTxBufferSize  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Resets a network adapter and re-initializes it with the parameters that were \r
+  provided in the previous call to Initialize().  \r
+\r
+  @param  This                 The protocol instance pointer.\r
+  @param  ExtendedVerification Indicates that the driver may perform a more\r
+                               exhaustive verification operation of the device\r
+                               during reset.\r
+\r
+  @retval EFI_SUCCESS           The network interface was reset.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_RESET)(\r
+  IN EMU_SNP_PROTOCOL   *This,\r
+  IN BOOLEAN            ExtendedVerification\r
+  );\r
+\r
+/**\r
+  Resets a network adapter and leaves it in a state that is safe for \r
+  another driver to initialize.\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           The network interface was shutdown.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_SHUTDOWN)(\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  );\r
+\r
+/**\r
+  Manages the multicast receive filters of a network interface.\r
+\r
+  @param  This             The protocol instance pointer.\r
+  @param  Enable           A bit mask of receive filters to enable on the network interface.\r
+  @param  Disable          A bit mask of receive filters to disable on the network interface.\r
+  @param  ResetMCastFilter Set to TRUE to reset the contents of the multicast receive\r
+                           filters on the network interface to their default values.\r
+  @param  McastFilterCnt   Number of multicast HW MAC addresses in the new\r
+                           MCastFilter list. This value must be less than or equal to\r
+                           the MCastFilterCnt field of EMU_SNP_MODE. This\r
+                           field is optional if ResetMCastFilter is TRUE.\r
+  @param  MCastFilter      A pointer to a list of new multicast receive filter HW MAC\r
+                           addresses. This list will replace any existing multicast\r
+                           HW MAC address list. This field is optional if\r
+                           ResetMCastFilter is TRUE.\r
+\r
+  @retval EFI_SUCCESS           The multicast receive filter list was updated.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_RECEIVE_FILTERS)(\r
+  IN EMU_SNP_PROTOCOL                             *This,\r
+  IN UINT32                                       Enable,\r
+  IN UINT32                                       Disable,\r
+  IN BOOLEAN                                      ResetMCastFilter,\r
+  IN UINTN                                        MCastFilterCnt     OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                              *MCastFilter OPTIONAL\r
+  );\r
+\r
+/**\r
+  Modifies or resets the current station address, if supported.\r
+\r
+  @param  This  The protocol instance pointer.\r
+  @param  Reset Flag used to reset the station address to the network interfaces\r
+                permanent address.\r
+  @param  New   The new station address to be used for the network interface.\r
+\r
+  @retval EFI_SUCCESS           The network interfaces station address was updated.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_STATION_ADDRESS)(\r
+  IN EMU_SNP_PROTOCOL            *This,\r
+  IN BOOLEAN                     Reset,\r
+  IN EFI_MAC_ADDRESS             *New OPTIONAL\r
+  );\r
+\r
+/**\r
+  Resets or collects the statistics on a network interface.\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
+  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
+                          output the size, in bytes, of the resulting table of\r
+                          statistics.\r
+  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
+                          contains the statistics.\r
+\r
+  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_STATISTICS)(\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              Reset,\r
+  IN OUT UINTN                            *StatisticsSize   OPTIONAL,\r
+  OUT EFI_NETWORK_STATISTICS              *StatisticsTable  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Converts a multicast IP address to a multicast HW MAC address.\r
+\r
+  @param  This The protocol instance pointer.\r
+  @param  IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
+               to FALSE if the multicast IP address is IPv4 [RFC 791].\r
+  @param  IP   The multicast IP address that is to be converted to a multicast\r
+               HW MAC address.\r
+  @param  MAC  The multicast HW MAC address that is to be generated from IP.\r
+\r
+  @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast\r
+                                HW MAC address.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_MCAST_IP_TO_MAC)(\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              IPv6,\r
+  IN EFI_IP_ADDRESS                       *IP,\r
+  OUT EFI_MAC_ADDRESS                     *MAC\r
+  );\r
+\r
+/**\r
+  Performs read and write operations on the NVRAM device attached to a \r
+  network interface.\r
+\r
+  @param  This       The protocol instance pointer.\r
+  @param  ReadWrite  TRUE for read operations, FALSE for write operations.\r
+  @param  Offset     Byte offset in the NVRAM device at which to start the read or\r
+                     write operation. This must be a multiple of NvRamAccessSize and\r
+                     less than NvRamSize.\r
+  @param  BufferSize The number of bytes to read or write from the NVRAM device.\r
+                     This must also be a multiple of NvramAccessSize.\r
+  @param  Buffer     A pointer to the data buffer.\r
+\r
+  @retval EFI_SUCCESS           The NVRAM access was performed.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_NVDATA)(\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              ReadWrite,\r
+  IN UINTN                                Offset,\r
+  IN UINTN                                BufferSize,\r
+  IN OUT VOID                             *Buffer\r
+  );\r
+\r
+/**\r
+  Reads the current interrupt status and recycled transmit buffer status from \r
+  a network interface.\r
+\r
+  @param  This            The protocol instance pointer.\r
+  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
+                          If this is NULL, the interrupt status will not be read from\r
+                          the device. If this is not NULL, the interrupt status will\r
+                          be read from the device. When the  interrupt status is read,\r
+                          it will also be cleared. Clearing the transmit  interrupt\r
+                          does not empty the recycled transmit buffer array.\r
+  @param  TxBuf           Recycled transmit buffer address. The network interface will\r
+                          not transmit if its internal recycled transmit buffer array\r
+                          is full. Reading the transmit buffer does not clear the\r
+                          transmit interrupt. If this is NULL, then the transmit buffer\r
+                          status will not be read. If there are no transmit buffers to\r
+                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
+\r
+  @retval EFI_SUCCESS           The status of the network interface was retrieved.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_GET_STATUS)(\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  OUT UINT32                              *InterruptStatus OPTIONAL,\r
+  OUT VOID                                **TxBuf OPTIONAL\r
+  );\r
+\r
+/**\r
+  Places a packet in the transmit queue of a network interface.\r
+\r
+  @param  This       The protocol instance pointer.\r
+  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
+                     the Transmit() function. If HeaderSize is non-zero, then it\r
+                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
+                     and Protocol parameters must not be NULL.\r
+  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
+                     data) to be transmitted through the network interface.\r
+  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
+                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
+                     then the media header in Buffer must already be filled in by the\r
+                     caller. If HeaderSize is non-zero, then the media header will be\r
+                     filled in by the Transmit() function.\r
+  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
+                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
+                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
+  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
+                     parameter is ignored.\r
+  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
+                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
+                     examples.\r
+\r
+  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_NOT_READY         The network interface is too busy to accept this transmit request.                      \r
+  @retval EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_TRANSMIT)(\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN UINTN                                HeaderSize,\r
+  IN UINTN                                BufferSize,\r
+  IN VOID                                 *Buffer,\r
+  IN EFI_MAC_ADDRESS                      *SrcAddr  OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                      *DestAddr OPTIONAL,\r
+  IN UINT16                               *Protocol OPTIONAL\r
+  );\r
+\r
+/**\r
+  Receives a packet from a network interface.\r
+\r
+  @param  This       The protocol instance pointer.\r
+  @param  HeaderSize The size, in bytes, of the media header received on the network\r
+                     interface. If this parameter is NULL, then the media header size\r
+                     will not be returned.\r
+  @param  BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
+                     bytes, of the packet that was received on the network interface.\r
+  @param  Buffer     A pointer to the data buffer to receive both the media header and\r
+                     the data.\r
+  @param  SrcAddr    The source HW MAC address. If this parameter is NULL, the\r
+                     HW MAC source address will not be extracted from the media\r
+                     header.\r
+  @param  DestAddr   The destination HW MAC address. If this parameter is NULL,\r
+                     the HW MAC destination address will not be extracted from the\r
+                     media header.\r
+  @param  Protocol   The media header type. If this parameter is NULL, then the\r
+                     protocol will not be extracted from the media header. See\r
+                     RFC 1700 section "Ether Types" for examples.\r
+\r
+  @retval  EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
+                                 been updated to the number of bytes received.\r
+  @retval  EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
+                                 request.\r
+  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
+  @retval  EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval  EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_SNP_RECEIVE)(\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  OUT UINTN                               *HeaderSize OPTIONAL,\r
+  IN OUT UINTN                            *BufferSize,\r
+  OUT VOID                                *Buffer,\r
+  OUT EFI_MAC_ADDRESS                     *SrcAddr    OPTIONAL,\r
+  OUT EFI_MAC_ADDRESS                     *DestAddr   OPTIONAL,\r
+  OUT UINT16                              *Protocol   OPTIONAL\r
+  );\r
+\r
+#define EMU_SNP_PROTOCOL_REVISION  0x00010000\r
+\r
+//\r
+// Revision defined in EFI1.1\r
+// \r
+#define EMU_SNP_INTERFACE_REVISION   EMU_SNP_PROTOCOL_REVISION\r
+\r
+///\r
+/// The EMU_SNP_PROTOCOL protocol abstracts OS network sercices \r
+/// from the EFI driver that produces EFI Simple Network Protocol.\r
+///\r
+struct _EMU_SNP_PROTOCOL {\r
+  EMU_SNP_CREATE_MAPPING   CreateMapping;\r
+  EMU_SNP_START            Start;\r
+  EMU_SNP_STOP             Stop;\r
+  EMU_SNP_INITIALIZE       Initialize;\r
+  EMU_SNP_RESET            Reset;\r
+  EMU_SNP_SHUTDOWN         Shutdown;\r
+  EMU_SNP_RECEIVE_FILTERS  ReceiveFilters;\r
+  EMU_SNP_STATION_ADDRESS  StationAddress;\r
+  EMU_SNP_STATISTICS       Statistics;\r
+  EMU_SNP_MCAST_IP_TO_MAC  MCastIpToMac;\r
+  EMU_SNP_NVDATA           NvData;\r
+  EMU_SNP_GET_STATUS       GetStatus;\r
+  EMU_SNP_TRANSMIT         Transmit;\r
+  EMU_SNP_RECEIVE          Receive;\r
+};\r
+\r
+extern EFI_GUID gEmuSnpProtocolGuid;\r
+\r
+#endif\r
diff --git a/EmulatorPkg/Include/Protocol/EmuThread.h b/EmulatorPkg/Include/Protocol/EmuThread.h
new file mode 100644 (file)
index 0000000..e518bb1
--- /dev/null
@@ -0,0 +1,103 @@
+/** @file\r
+  Emulator Thunk to abstract OS services from pure EFI code\r
+\r
+  Copyright (c) 2010 - 2011, Apple Inc. All rights reserved.<BR>\r
+  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __EMU_THREAD_THUNK__\r
+#define __EMU_THREAD_THUNK__\r
+\r
+\r
+typedef struct _EMU_THREAD_THUNK_PROTOCOL  EMU_THREAD_THUNK_PROTOCOL;\r
+\r
+\r
+typedef\r
+UINTN\r
+(EFIAPI *THREAD_THUNK_MUTEX_LOCK) (\r
+  IN VOID *Mutex\r
+  );\r
+\r
+\r
+typedef\r
+UINTN\r
+(EFIAPI *THREAD_THUNK_MUTEX_UNLOCK) (\r
+  IN VOID *Mutex\r
+  );\r
+\r
+\r
+typedef\r
+UINTN\r
+(EFIAPI *THREAD_THUNK_MUTEX_TRY_LOCK) (\r
+  IN VOID *Mutex\r
+  );\r
+\r
+\r
+typedef\r
+VOID *\r
+(EFIAPI *THREAD_THUNK_MUTEX_INIT) (\r
+  IN VOID\r
+  );\r
+\r
+\r
+typedef\r
+UINTN\r
+(EFIAPI *THREAD_THUNK_MUTEX_DISTROY) (\r
+  IN VOID *Mutex\r
+  );\r
+\r
+\r
+\r
+typedef\r
+VOID *\r
+(EFIAPI *THREAD_THUNK_THREAD_ENTRY) (\r
+  IN  VOID *Context\r
+  );\r
+\r
+typedef\r
+UINTN\r
+(EFIAPI *THREAD_THUNK_CREATE_THREAD) (\r
+  IN  VOID                      *Thread,\r
+  IN  VOID                      *Attribute,\r
+  IN  THREAD_THUNK_THREAD_ENTRY Start,\r
+  IN  VOID                      *Context\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *THREAD_THUNK_EXIT_THREAD) (\r
+  IN VOID *ValuePtr\r
+  );\r
+\r
+\r
+typedef\r
+UINTN\r
+(EFIAPI *THREAD_THUNK_SELF) (\r
+  VOID\r
+  );\r
+\r
+\r
+struct _EMU_THREAD_THUNK_PROTOCOL {\r
+  THREAD_THUNK_MUTEX_LOCK       MutexLock;\r
+  THREAD_THUNK_MUTEX_UNLOCK     MutexUnlock;\r
+  THREAD_THUNK_MUTEX_TRY_LOCK   MutexTryLock;\r
+  THREAD_THUNK_MUTEX_INIT       MutexInit;\r
+  THREAD_THUNK_MUTEX_DISTROY    MutexDistroy;\r
+  THREAD_THUNK_CREATE_THREAD    CreateThread;\r
+  THREAD_THUNK_EXIT_THREAD      ExitThread;\r
+  THREAD_THUNK_SELF             Self;\r
+};\r
+\r
+extern EFI_GUID gEmuThreadThunkProtocolGuid;\r
+\r
+#endif\r
+\r
diff --git a/EmulatorPkg/Include/Protocol/EmuThunk.h b/EmulatorPkg/Include/Protocol/EmuThunk.h
new file mode 100644 (file)
index 0000000..27921b1
--- /dev/null
@@ -0,0 +1,264 @@
+/** @file\r
+  Emulator Thunk to abstract OS services from pure EFI code\r
+\r
+  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
+  \r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __EMU_THUNK_PROTOCOL_H__\r
+#define __EMU_THUNK_PROTOCOL_H__\r
+\r
+#define EMU_THUNK_PROTOCOL_GUID  \\r
+ { 0x5CF32E0B, 0x8EDF, 0x2E44, { 0x9C, 0xDA, 0x93, 0x20, 0x5E, 0x99, 0xEC, 0x1C } }\r
+\r
+// neded for things like EFI_TIME_CAPABILITIES\r
+#include <Uefi.h>\r
+\r
+#include <Library/PeCoffExtraActionLib.h>\r
+\r
+#include <Protocol/EmuIoThunk.h>\r
+#include <Protocol/DevicePath.h>\r
+\r
+\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH  VendorDevicePath;\r
+  UINT32              Instance;\r
+} EMU_VENDOR_DEVICE_PATH_NODE;\r
+\r
+typedef struct {\r
+  EMU_VENDOR_DEVICE_PATH_NODE Vendor;\r
+  EFI_DEVICE_PATH_PROTOCOL    EndDevicePath;\r
+} EMU_THUNK_DEVICE_PATH;\r
+\r
+\r
+\r
+typedef struct _EMU_THUNK_PROTOCOL  EMU_THUNK_PROTOCOL;\r
+\r
+\r
+\r
+typedef \r
+UINTN\r
+(EFIAPI *EMU_WRITE_STD_ERROR) (\r
+  IN UINT8     *Buffer,\r
+  IN UINTN     NumberOfBytes\r
+  );  \r
+  \r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EMU_CONFIG_STD_IN) (\r
+  VOID\r
+  );\r
+  \r
+typedef \r
+UINTN\r
+(EFIAPI *EMU_WRITE_STD_OUT) (\r
+  IN UINT8     *Buffer,\r
+  IN UINTN     NumberOfBytes\r
+  );\r
+  \r
+typedef \r
+UINTN\r
+(EFIAPI *EMU_READ_STD_IN) (\r
+  OUT UINT8     *Buffer,\r
+  IN  UINTN     NumberOfBytes\r
+  );\r
+\r
+typedef \r
+BOOLEAN\r
+(EFIAPI *EMU_POLL_STD_IN) (\r
+  VOID\r
+  );\r
+\r
+\r
+typedef\r
+VOID *\r
+(EFIAPI *EMU_OS_MALLOC) (\r
+  IN  UINTN Size\r
+  );\r
+\r
+typedef\r
+VOID *\r
+(EFIAPI *EMU_OS_VMALLOC) (\r
+  IN  UINTN Size\r
+  );\r
+  \r
+typedef \r
+BOOLEAN\r
+(EFIAPI *EMU_OS_FREE) (\r
+  IN  VOID *Ptr\r
+  );\r
+\r
+\r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EMU_PE_COFF_GET_ENTRY_POINT) (\r
+  IN     VOID  *Pe32Data,\r
+  IN OUT VOID  **EntryPoint\r
+  );\r
+\r
+typedef \r
+VOID\r
+(EFIAPI *EMU_PE_COFF_RELOCATE_EXTRA_ACTION) (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  );\r
+\r
+typedef \r
+VOID\r
+(EFIAPI *EMU_PE_COFF_UNLOAD_EXTRA_ACTION) (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EMU_ENABLE_INERRUPTS) (\r
+  VOID\r
+  );\r
+  \r
+typedef\r
+VOID\r
+(EFIAPI *EMU_DISABLE_INERRUPTS) (\r
+  VOID\r
+  );\r
+\r
+typedef\r
+UINT64\r
+(EFIAPI *EMU_QUERY_PERFORMANCE_FREQENCY) (\r
+  VOID\r
+  );\r
+\r
+typedef\r
+UINT64\r
+(EFIAPI *EMU_QUERY_PERFORMANCE_COUNTER) (\r
+  VOID\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EMU_SLEEP) (\r
+  IN  UINT64    Milliseconds\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EMU_CPU_SLEEP) (\r
+  VOID\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EMU_EXIT) (\r
+  IN  UINTN    Status\r
+  );\r
+  \r
+typedef\r
+VOID\r
+(EFIAPI *EMU_GET_TIME) (\r
+  OUT  EFI_TIME               *Time,\r
+  OUT EFI_TIME_CAPABILITIES   *Capabilities OPTIONAL\r
+  );\r
+  \r
+typedef\r
+VOID\r
+(EFIAPI *EMU_SET_TIME) (\r
+  IN   EFI_TIME               *Time\r
+  );\r
+\r
+\r
+typedef\r
+VOID\r
+(EFIAPI EMU_SET_TIMER_CALLBACK) (\r
+  IN  UINT64  DeltaMs\r
+  );\r
+\r
+typedef\r
+VOID\r
+(EFIAPI *EMU_SET_TIMER) (\r
+  IN  UINT64                  PeriodMs,\r
+  IN  EMU_SET_TIMER_CALLBACK  CallBack\r
+  );\r
+  \r
+\r
+\r
+/**\r
+  Enumerates the current set of protocol instances that abstract OS services from EFI.\r
+  \r
+  A given protocol can have multiple instances. Usually a protocol is configured via a\r
+  single PCD string. The data associated for each instance is seperated via a ! in the string. \r
+  EMU_IO_THUNK_PROTOCOL_CLOSE.ConfigString will contain the information in the PCD string up to the next !.\r
+  Thus each instance has a unique ConfigString. \r
+\r
+  @param  EmuBusDriver          TRUE means only return protocol instances that need to be produced\r
+                                by the EmuBusDriver. FALSE means return all possible protocols\r
+  @param  Instance              On input the protocol to search for, or NULL to start a search \r
+                                of all the supported protocol instances. \r
+  @param  NextProtocol          On output it represents the next value to be passed into Protocol. \r
+  @param  Interface             A pointer to the EMU_IO_THUNK_PROTOCOL_CLOSE interface. \r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_NOT_FOUND         The next protocol instance was not found.\r
+  @retval EFI_INVALID_PARAMETER Instance is NULL.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EMU_GET_NEXT_PROTOCOL) (\r
+  IN  BOOLEAN                 EmuBusDriver,\r
+  OUT EMU_IO_THUNK_PROTOCOL   **Instance  OPTIONAL\r
+  );\r
+  \r
+\r
+struct _EMU_THUNK_PROTOCOL {\r
+  // Used for early debug printing\r
+  EMU_WRITE_STD_ERROR               WriteStdErr;\r
+  EMU_CONFIG_STD_IN                 ConfigStdIn;\r
+  EMU_WRITE_STD_OUT                 WriteStdOut;\r
+  EMU_READ_STD_IN                   ReadStdIn;\r
+  EMU_POLL_STD_IN                   PollStdIn;\r
+  \r
+  //\r
+  // Map OS malloc/free so we can use OS based guard malloc\r
+  //\r
+  EMU_OS_MALLOC                     Malloc;\r
+  EMU_OS_VMALLOC                    Valloc;\r
+  EMU_OS_FREE                       Free;\r
+  \r
+  \r
+  ///\r
+  /// PE/COFF loader hooks to get symbols loaded\r
+  ///\r
+  EMU_PE_COFF_GET_ENTRY_POINT       PeCoffGetEntryPoint;\r
+  EMU_PE_COFF_RELOCATE_EXTRA_ACTION PeCoffRelocateImageExtraAction;\r
+  EMU_PE_COFF_UNLOAD_EXTRA_ACTION   PeCoffUnloadImageExtraAction;\r
+  \r
+  ///\r
+  /// DXE Architecture Protocol Services\r
+  ///\r
+  EMU_ENABLE_INERRUPTS              EnableInterrupt;\r
+  EMU_DISABLE_INERRUPTS             DisableInterrupt;\r
+  EMU_QUERY_PERFORMANCE_FREQENCY    QueryPerformanceFrequency;\r
+  EMU_QUERY_PERFORMANCE_COUNTER     QueryPerformanceCounter;\r
+\r
+  EMU_SLEEP                         Sleep;\r
+  EMU_CPU_SLEEP                     CpuSleep;\r
+  EMU_EXIT                          Exit;\r
+  EMU_GET_TIME                      GetTime;                \r
+  EMU_SET_TIME                      SetTime;\r
+  EMU_SET_TIMER                     SetTimer;  \r
+  \r
+  ///\r
+  /// Generic System Services\r
+  ///\r
+  EMU_GET_NEXT_PROTOCOL             GetNextProtocol;\r
+};\r
+\r
+extern EFI_GUID gEmuThunkProtocolGuid;\r
+\r
+#endif\r
diff --git a/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c b/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c
new file mode 100644 (file)
index 0000000..ba625ae
--- /dev/null
@@ -0,0 +1,183 @@
+/** @file\r
+  Null Platform Hook Library instance.\r
+\r
+  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Base.h>\r
+\r
+#include <Protocol/EmuThunk.h>\r
+#include <Protocol/EmuGraphicsWindow.h>\r
+#include <Protocol/EmuBlockIo.h>\r
+#include <Protocol/SimpleFileSystem.h>\r
+#include <Protocol/EmuThread.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DevicePathToTextLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+\r
+/**\r
+  Converts a Vendor device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+  @return EFI_NOT_FOUND if no string representation exists.\r
+  @return EFI_SUCCESS   a string representation was created.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DevPathToTextVendorLib (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  EMU_VENDOR_DEVICE_PATH_NODE  *Vendor;\r
+  CHAR16                       *Type;\r
+\r
+  Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *)DevPath;\r
+  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThunkProtocolGuid)) {\r
+    CatPrint (Str, L"EmuThunk()");\r
+    return EFI_SUCCESS;\r
+  }\r
+  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuGraphicsWindowProtocolGuid)) {\r
+    CatPrint (Str, L"EmuGraphics(%d)", Vendor->Instance);\r
+    return EFI_SUCCESS;\r
+  }\r
+  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid)) {\r
+    CatPrint (Str, L"EmuFs(%d)", Vendor->Instance);\r
+    return EFI_SUCCESS;\r
+  }\r
+  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuBlockIoProtocolGuid)) {\r
+    CatPrint (Str, L"EmuBlk(%d)", Vendor->Instance);\r
+    return EFI_SUCCESS;\r
+  }\r
+  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThreadThunkProtocolGuid)) {\r
+    CatPrint (Str, L"EmuThread()");\r
+    return EFI_SUCCESS;\r
+  }\r
+  \r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Hardware Vendor device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Hardware Vendor device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextEmuThunk (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16              *Str;\r
+  VENDOR_DEVICE_PATH  *Vendor;\r
+\r
+  Str    = GetNextParamStr (&TextDeviceNode);\r
+  Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
+                                     HARDWARE_DEVICE_PATH,\r
+                                     HW_VENDOR_DP,\r
+                                     (UINT16) sizeof (VENDOR_DEVICE_PATH)\r
+                                     );\r
+  CopyGuid (&Vendor->Guid, &gEmuThunkProtocolGuid);\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Hardware Vendor device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Hardware Vendor device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextEmuThread (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16              *Str;\r
+  VENDOR_DEVICE_PATH  *Vendor;\r
+\r
+  Str    = GetNextParamStr (&TextDeviceNode);\r
+  Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
+                                     HARDWARE_DEVICE_PATH,\r
+                                     HW_VENDOR_DP,\r
+                                     (UINT16) sizeof (VENDOR_DEVICE_PATH)\r
+                                     );\r
+  CopyGuid (&Vendor->Guid, &gEmuThreadThunkProtocolGuid);\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Hardware Vendor device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Hardware Vendor device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextEmuFs (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                       *Str;\r
+  EMU_VENDOR_DEVICE_PATH_NODE  *Vendor;\r
+\r
+  Str = GetNextParamStr (&TextDeviceNode);\r
+  Vendor    = (EMU_VENDOR_DEVICE_PATH_NODE *) CreateDeviceNode (\r
+                                                   HARDWARE_DEVICE_PATH,\r
+                                                   HW_VENDOR_DP,\r
+                                                   (UINT16) sizeof (EMU_VENDOR_DEVICE_PATH_NODE)\r
+                                                   );\r
+  CopyGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid);\r
+  Vendor->Instance = (UINT32) StrDecimalToUintn (Str);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
+}\r
+\r
+/**\r
+  Register the Filter function\r
+  \r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS   The constructor executed correctly.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DevicePathToTextLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+\r
+{\r
+  DevPathToTextSetVendorDevicePathFilter (DevPathToTextVendorLib);\r
+  DevicePathFromTextAddFilter (L"EmuThunk", DevPathFromTextEmuThunk);\r
+  DevicePathFromTextAddFilter (L"EmuThread", DevPathFromTextEmuThread);\r
+  DevicePathFromTextAddFilter (L"EmuFs", DevPathFromTextEmuFs);\r
+  return EFI_SUCCESS;\r
+}
\ No newline at end of file
diff --git a/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.inf b/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
new file mode 100644 (file)
index 0000000..f572678
--- /dev/null
@@ -0,0 +1,48 @@
+## @file\r
+#  Null DevicePathToText library.\r
+#\r
+#  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DevicePathTextLib\r
+  FILE_GUID                      = DCD1F939-1732-CA4D-81B7-C757AEC84DBC\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = NULL|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE\r
+  CONSTRUCTOR                    = DevicePathToTextLibConstructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  DevicePathTextLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  DebugLib\r
+  DevicePathLib\r
+\r
+[Protocols]\r
+  gEmuThunkProtocolGuid\r
+  gEmuGraphicsWindowProtocolGuid\r
+  gEfiSimpleFileSystemProtocolGuid\r
+  gEmuBlockIoProtocolGuid\r
+  gEmuThreadThunkProtocolGuid
\ No newline at end of file
diff --git a/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c b/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c
new file mode 100644 (file)
index 0000000..db3b313
--- /dev/null
@@ -0,0 +1,128 @@
+/** @file\r
+  A non-functional instance of the Timer Library.\r
+\r
+  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+#include <Library/TimerLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/EmuThunkLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+\r
+#include <Protocol/Timer.h>\r
+\r
+\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of microseconds.\r
+\r
+  Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
+\r
+  @param  MicroSeconds  The minimum number of microseconds to delay.\r
+\r
+  @return The value of MicroSeconds inputted.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+MicroSecondDelay (\r
+  IN      UINTN                     MicroSeconds\r
+  )\r
+{\r
+  return NanoSecondDelay (MicroSeconds * 1000);\r
+}\r
+\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of nanoseconds.\r
+\r
+  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
+\r
+  @param  NanoSeconds The minimum number of nanoseconds to delay.\r
+\r
+  @return The value of NanoSeconds inputted.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+NanoSecondDelay (\r
+  IN      UINTN                     NanoSeconds\r
+  )\r
+{\r
+  gEmuThunk->Sleep (NanoSeconds);\r
+  return NanoSeconds;\r
+}\r
+\r
+\r
+/**\r
+  Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+  The counter can either count up by 1 or count down by 1. If the physical\r
+  performance counter counts by a larger increment, then the counter values\r
+  must be translated. The properties of the counter can be retrieved from\r
+  GetPerformanceCounterProperties().\r
+\r
+  @return The current value of the free running performance counter.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounter (\r
+  VOID\r
+  )\r
+{\r
+  return gEmuThunk->QueryPerformanceCounter ();\r
+}\r
+\r
+/**\r
+  Retrieves the 64-bit frequency in Hz and the range of performance counter\r
+  values.\r
+\r
+  If StartValue is not NULL, then the value that the performance counter starts\r
+  with immediately after is it rolls over is returned in StartValue. If\r
+  EndValue is not NULL, then the value that the performance counter end with\r
+  immediately before it rolls over is returned in EndValue. The 64-bit\r
+  frequency of the performance counter in Hz is always returned. If StartValue\r
+  is less than EndValue, then the performance counter counts up. If StartValue\r
+  is greater than EndValue, then the performance counter counts down. For\r
+  example, a 64-bit free running counter that counts up would have a StartValue\r
+  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
+  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
+\r
+  @param  StartValue  The value the performance counter starts with when it\r
+                      rolls over.\r
+  @param  EndValue    The value that the performance counter ends with before\r
+                      it rolls over.\r
+\r
+  @return The frequency in Hz.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounterProperties (\r
+  OUT      UINT64                    *StartValue,  OPTIONAL\r
+  OUT      UINT64                    *EndValue     OPTIONAL\r
+  )\r
+{\r
+\r
+  if (StartValue != NULL) {\r
+    *StartValue = 0ULL;\r
+  }\r
+  if (EndValue != NULL) {\r
+    *EndValue = (UINT64)-1LL;\r
+  }\r
+  \r
+  return gEmuThunk->QueryPerformanceFrequency ();\r
+}\r
+\r
+\r
diff --git a/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.inf b/EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.inf
new file mode 100644 (file)
index 0000000..12826ed
--- /dev/null
@@ -0,0 +1,44 @@
+## @file\r
+#  NULL instance of Timer Library as a template.\r
+#\r
+#  A non-functional instance of the Timer Library that can be used as a template\r
+#  for the implementation of a functional timer library instance. This library instance can\r
+#  also be used to test build DXE, Runtime, DXE SAL, and DXE SMM modules that require timer\r
+#  services as well as EBC modules that require timer services.\r
+#\r
+#  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuDxeCodeTimerLib\r
+  FILE_GUID                      = FB184AF4-A2F2-EE4E-8885-E81E5D8B0135\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = TimerLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  DxeCoreTimerLib.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+  EmuThunkLib\r
+  \r
diff --git a/EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c b/EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c
new file mode 100644 (file)
index 0000000..2e42ea6
--- /dev/null
@@ -0,0 +1,88 @@
+/*++ @file\r
+\r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/EmuThunkLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+EMU_THUNK_PROTOCOL   *gEmuThunk = NULL;\r
+\r
+\r
+/**\r
+  The constructor function caches the pointer of EMU Thunk protocol.\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DxeEmuLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_HOB_GUID_TYPE        *GuidHob;\r
+\r
+  GuidHob = GetFirstGuidHob (&gEmuThunkProtocolGuid);\r
+  ASSERT (GuidHob != NULL);\r
+  \r
+  gEmuThunk = (EMU_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r
+  ASSERT (gEmuThunk != NULL);\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Serach the EMU IO Thunk database for a matching EMU IO Thunk \r
+  Protocol instance.\r
+\r
+  @param  Protocol   Protocol to search for.\r
+  @param  Instance   Instance of protocol to search for.\r
+\r
+  @retval NULL       Protocol and Instance not found.\r
+  @retval other      EMU IO Thunk protocol that matched.\r
+\r
+**/\r
+EMU_IO_THUNK_PROTOCOL *\r
+EFIAPI\r
+GetIoThunkInstance (\r
+  IN  EFI_GUID  *Protocol,\r
+  IN  UINTN     Instance\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_IO_THUNK_PROTOCOL   *EmuIoThunk;\r
+  \r
+  for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) {\r
+    Status = gEmuThunk->GetNextProtocol (FALSE, &EmuIoThunk);\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
+  \r
+    if (EmuIoThunk->Instance == Instance) {\r
+      if (CompareGuid (EmuIoThunk->Protocol, Protocol)) {\r
+        return EmuIoThunk;\r
+      }\r
+    }\r
+  }\r
+  \r
+  return NULL;\r
+}
\ No newline at end of file
diff --git a/EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.inf b/EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.inf
new file mode 100644 (file)
index 0000000..731bdda
--- /dev/null
@@ -0,0 +1,46 @@
+## @file\r
+# A library to produce the global variable 'gEmuThunk'\r
+#\r
+# This library contains a single global variable 'gEmuThunk' along with a constructor to \r
+# initialize that global.\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DxeEmuLib\r
+  FILE_GUID                      = 31479AFD-B06F-4E4A-863B-A8F7E7710778\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = EmuThunkLib \r
+\r
+  CONSTRUCTOR                    = DxeEmuLibConstructor\r
+\r
+\r
+[Sources]\r
+  DxeEmuLib.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  HobLib\r
+  DebugLib\r
+  BaseMemoryLib\r
+\r
+\r
+[Protocols]\r
+  gEmuThunkProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED\r
+\r
diff --git a/EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.c b/EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.c
new file mode 100644 (file)
index 0000000..fdb8d53
--- /dev/null
@@ -0,0 +1,103 @@
+/** @file\r
+  Provides services to perform additional actions to relocate and unload\r
+  PE/Coff image for Emu environment specific purpose such as souce level debug.\r
+  This version only works for DXE phase  \r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/EmuThunk.h>\r
+\r
+#include <Library/PeCoffLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/PeCoffExtraActionLib.h>\r
+\r
+//\r
+// Cache of UnixThunk protocol \r
+//\r
+EMU_THUNK_PROTOCOL   *mThunk = NULL;\r
+\r
+\r
+/**\r
+  The constructor function gets  the pointer of the WinNT thunk functions\r
+  It will ASSERT() if Unix thunk protocol is not installed.\r
+\r
+  @retval EFI_SUCCESS   Unix thunk protocol is found and cached.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DxeEmuPeCoffLibExtraActionConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+   EFI_HOB_GUID_TYPE        *GuidHob;\r
+\r
+  //\r
+  // Retrieve EmuThunkProtocol from GUID'ed HOB\r
+  //\r
+  GuidHob = GetFirstGuidHob (&gEmuThunkProtocolGuid);\r
+  ASSERT (GuidHob != NULL);\r
+  mThunk = (EMU_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r
+  ASSERT (mThunk != NULL);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Performs additional actions after a PE/COFF image has been loaded and relocated.\r
+\r
+  If ImageContext is NULL, then ASSERT().\r
+\r
+  @param  ImageContext  Pointer to the image context structure that describes the\r
+                        PE/COFF image that has already been loaded and relocated.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeCoffLoaderRelocateImageExtraAction (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+{\r
+  if (mThunk != NULL) {\r
+    mThunk->PeCoffRelocateImageExtraAction (ImageContext);\r
+  }\r
+}\r
+\r
+\r
+\r
+/**\r
+  Performs additional actions just before a PE/COFF image is unloaded.  Any resources\r
+  that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.\r
+  \r
+  If ImageContext is NULL, then ASSERT().\r
+  \r
+  @param  ImageContext  Pointer to the image context structure that describes the\r
+                        PE/COFF image that is being unloaded.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeCoffLoaderUnloadImageExtraAction (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+{\r
+  if (mThunk != NULL) {\r
+    mThunk->PeCoffUnloadImageExtraAction (ImageContext);\r
+  }\r
+}\r
diff --git a/EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf b/EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf
new file mode 100644 (file)
index 0000000..b5961c5
--- /dev/null
@@ -0,0 +1,48 @@
+## @file
+# PeCoff extra action libary for DXE phase that run Emu emulator.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# 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
+# 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.
+
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = DxeEmuPeCoffExtraActionLib
+  FILE_GUID                      = 68FCD487-D230-6846-95B1-5E1F2EF942C4
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = PeCoffExtraActionLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER
+
+  CONSTRUCTOR                    = DxeEmuPeCoffLibExtraActionConstructor
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32
+#
+
+[Sources]
+  DxeEmuPeCoffExtraActionLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  EmulatorPkg/EmulatorPkg.dec
+
+[LibraryClasses]
+  DebugLib
+  HobLib
+  BaseMemoryLib
+
+[Protocols]
+  gEmuThunkProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED
+
diff --git a/EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c b/EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
new file mode 100644 (file)
index 0000000..ccf4fa0
--- /dev/null
@@ -0,0 +1,119 @@
+/** @file\r
+  Serial Port Lib that thunks back to Emulator services to write to StdErr. \r
+  All read functions are stubed out. \r
+\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#include <PiDxe.h>\r
+#include <Library/SerialPortLib.h>\r
+#include <Library/EmuThunkLib.h>\r
+\r
+\r
+\r
+\r
+/**\r
+  Initialize the serial device hardware.\r
+  \r
+  If no initialization is required, then return RETURN_SUCCESS.\r
+  If the serial device was successfully initialized, then return RETURN_SUCCESS.\r
+  If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.\r
+  \r
+  @retval RETURN_SUCCESS        The serial device was initialized.\r
+  @retval RETURN_DEVICE_ERROR   The serial device could not be initialized.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SerialPortInitialize (\r
+  VOID\r
+  )\r
+{\r
+  return gEmuThunk->ConfigStdIn ();\r
+}\r
+\r
+/**\r
+  Write data from buffer to serial device. \r
\r
+  Writes NumberOfBytes data bytes from Buffer to the serial device.  \r
+  The number of bytes actually written to the serial device is returned.\r
+  If the return value is less than NumberOfBytes, then the write operation failed.\r
+  If Buffer is NULL, then ASSERT(). \r
+  If NumberOfBytes is zero, then return 0.\r
+\r
+  @param  Buffer           The pointer to the data buffer to be written.\r
+  @param  NumberOfBytes    The number of bytes to written to the serial device.\r
+\r
+  @retval 0                NumberOfBytes is 0.\r
+  @retval >0               The number of bytes written to the serial device.  \r
+                           If this value is less than NumberOfBytes, then the read operation failed.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SerialPortWrite (\r
+  IN UINT8     *Buffer,\r
+  IN UINTN     NumberOfBytes\r
+  )\r
+{\r
+  return gEmuThunk->WriteStdOut (Buffer, NumberOfBytes);\r
+}\r
+\r
+\r
+/**\r
+  Read data from serial device and save the datas in buffer.\r
\r
+  Reads NumberOfBytes data bytes from a serial device into the buffer\r
+  specified by Buffer. The number of bytes actually read is returned. \r
+  If the return value is less than NumberOfBytes, then the rest operation failed.\r
+  If Buffer is NULL, then ASSERT(). \r
+  If NumberOfBytes is zero, then return 0.\r
+\r
+  @param  Buffer           The pointer to the data buffer to store the data read from the serial device.\r
+  @param  NumberOfBytes    The number of bytes which will be read.\r
+\r
+  @retval 0                Read data failed; No data is to be read.\r
+  @retval >0               The actual number of bytes read from serial device.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SerialPortRead (\r
+  OUT UINT8     *Buffer,\r
+  IN  UINTN     NumberOfBytes\r
+  )\r
+{\r
+  return gEmuThunk->ReadStdIn (Buffer, NumberOfBytes);\r
+}\r
+\r
+/**\r
+  Polls a serial device to see if there is any data waiting to be read.\r
+\r
+  Polls a serial device to see if there is any data waiting to be read.\r
+  If there is data waiting to be read from the serial device, then TRUE is returned.\r
+  If there is no data waiting to be read from the serial device, then FALSE is returned.\r
+\r
+  @retval TRUE             Data is waiting to be read from the serial device.\r
+  @retval FALSE            There is no data waiting to be read from the serial device.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+SerialPortPoll (\r
+  VOID\r
+  )\r
+{\r
+  return gEmuThunk->PollStdIn ();\r
+}\r
+\r
+\r
diff --git a/EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf b/EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf
new file mode 100644 (file)
index 0000000..a4734c5
--- /dev/null
@@ -0,0 +1,40 @@
+## @file\r
+#  Write only instance of Serial Port Library with empty functions.\r
+#\r
+#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DxeEmuSerialPortLib\r
+  FILE_GUID                      = DF08A29A-F60B-E649-AA79-A1490E863A5D\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = SerialPortLib| DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVE\r
+\r
+\r
+[Sources]\r
+  DxeEmuSerialPortLib.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+  \r
+[LibraryClasses]\r
+  EmuThunkLib\r
+\r
+\r
+\r
+  \r
+\r
diff --git a/EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c b/EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c
new file mode 100644 (file)
index 0000000..b4ef86e
--- /dev/null
@@ -0,0 +1,119 @@
+/** @file\r
+  Serial Port Lib that thunks back to Emulator services to write to StdErr. \r
+  All read functions are stubed out. \r
+\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#include <PiDxe.h>\r
+#include <Library/SerialPortLib.h>\r
+#include <Library/EmuThunkLib.h>\r
+\r
+\r
+\r
+\r
+/**\r
+  Initialize the serial device hardware.\r
+  \r
+  If no initialization is required, then return RETURN_SUCCESS.\r
+  If the serial device was successfully initialized, then return RETURN_SUCCESS.\r
+  If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.\r
+  \r
+  @retval RETURN_SUCCESS        The serial device was initialized.\r
+  @retval RETURN_DEVICE_ERROR   The serial device could not be initialized.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SerialPortInitialize (\r
+  VOID\r
+  )\r
+{\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Write data from buffer to serial device. \r
\r
+  Writes NumberOfBytes data bytes from Buffer to the serial device.  \r
+  The number of bytes actually written to the serial device is returned.\r
+  If the return value is less than NumberOfBytes, then the write operation failed.\r
+  If Buffer is NULL, then ASSERT(). \r
+  If NumberOfBytes is zero, then return 0.\r
+\r
+  @param  Buffer           The pointer to the data buffer to be written.\r
+  @param  NumberOfBytes    The number of bytes to written to the serial device.\r
+\r
+  @retval 0                NumberOfBytes is 0.\r
+  @retval >0               The number of bytes written to the serial device.  \r
+                           If this value is less than NumberOfBytes, then the read operation failed.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SerialPortWrite (\r
+  IN UINT8     *Buffer,\r
+  IN UINTN     NumberOfBytes\r
+  )\r
+{\r
+  return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);\r
+}\r
+\r
+\r
+/**\r
+  Read data from serial device and save the datas in buffer.\r
\r
+  Reads NumberOfBytes data bytes from a serial device into the buffer\r
+  specified by Buffer. The number of bytes actually read is returned. \r
+  If the return value is less than NumberOfBytes, then the rest operation failed.\r
+  If Buffer is NULL, then ASSERT(). \r
+  If NumberOfBytes is zero, then return 0.\r
+\r
+  @param  Buffer           The pointer to the data buffer to store the data read from the serial device.\r
+  @param  NumberOfBytes    The number of bytes which will be read.\r
+\r
+  @retval 0                Read data failed; No data is to be read.\r
+  @retval >0               The actual number of bytes read from serial device.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SerialPortRead (\r
+  OUT UINT8     *Buffer,\r
+  IN  UINTN     NumberOfBytes\r
+  )\r
+{\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Polls a serial device to see if there is any data waiting to be read.\r
+\r
+  Polls a serial device to see if there is any data waiting to be read.\r
+  If there is data waiting to be read from the serial device, then TRUE is returned.\r
+  If there is no data waiting to be read from the serial device, then FALSE is returned.\r
+\r
+  @retval TRUE             Data is waiting to be read from the serial device.\r
+  @retval FALSE            There is no data waiting to be read from the serial device.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+SerialPortPoll (\r
+  VOID\r
+  )\r
+{\r
+  return FALSE;\r
+}\r
+\r
+\r
diff --git a/EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf b/EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf
new file mode 100644 (file)
index 0000000..5d791bc
--- /dev/null
@@ -0,0 +1,40 @@
+## @file\r
+#  Write only instance of Serial Port Library with empty functions.\r
+#\r
+#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DxeEmuStdErrSerialPortLib\r
+  FILE_GUID                      = 4EED5138-C512-9E4F-AB13-149B87D40453\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = SerialPortLib| DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVE\r
+\r
+\r
+[Sources]\r
+  DxeEmuStdErrSerialPortLib.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+  \r
+[LibraryClasses]\r
+  EmuThunkLib\r
+\r
+\r
+\r
+  \r
+\r
diff --git a/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c b/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c
new file mode 100644 (file)
index 0000000..14bb17f
--- /dev/null
@@ -0,0 +1,206 @@
+/** @file\r
+  A non-functional instance of the Timer Library.\r
+\r
+  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/TimerLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/EmuThunkLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+\r
+#include <Protocol/Timer.h>\r
+\r
+\r
+STATIC UINT64                  gTimerPeriod = 0;\r
+STATIC EFI_TIMER_ARCH_PROTOCOL *gTimerAp = NULL;\r
+STATIC EFI_EVENT               gTimerEvent = NULL;\r
+STATIC VOID                    *gRegistration = NULL;\r
+\r
+VOID\r
+EFIAPI\r
+RegisterTimerArchProtocol (\r
+  IN EFI_EVENT     Event,\r
+  IN VOID          *Context\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  \r
+  Status = gBS->LocateProtocol (&gEfiTimerArchProtocolGuid, NULL, (VOID **)&gTimerAp);\r
+  if (!EFI_ERROR (Status)) {    \r
+    Status = gTimerAp->GetTimerPeriod (gTimerAp, &gTimerPeriod);\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    // Convert to Nanoseconds.\r
+    gTimerPeriod = MultU64x32 (gTimerPeriod, 100);\r
+    \r
+    if (gTimerEvent == NULL) {\r
+      Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, (VOID **)&gTimerEvent);\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
+  }\r
+}\r
+\r
+\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of microseconds.\r
+\r
+  Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
+\r
+  @param  MicroSeconds  The minimum number of microseconds to delay.\r
+\r
+  @return The value of MicroSeconds inputted.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+MicroSecondDelay (\r
+  IN      UINTN                     MicroSeconds\r
+  )\r
+{\r
+  return NanoSecondDelay (MicroSeconds * 1000);\r
+}\r
+\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of nanoseconds.\r
+\r
+  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
+\r
+  @param  NanoSeconds The minimum number of nanoseconds to delay.\r
+\r
+  @return The value of NanoSeconds inputted.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+NanoSecondDelay (\r
+  IN      UINTN                     NanoSeconds\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  UINT64      HundredNanoseconds;\r
+  UINTN       Index;\r
+  \r
+  if ((gTimerPeriod != 0) && \r
+      ((UINT64)NanoSeconds > gTimerPeriod) && \r
+      (EfiGetCurrentTpl () == TPL_APPLICATION)) {\r
+    //\r
+    // This stall is long, so use gBS->WaitForEvent () to yield CPU to DXE Core\r
+    //\r
+    \r
+    HundredNanoseconds = DivU64x32 (NanoSeconds, 100);\r
+    Status = gBS->SetTimer (gTimerEvent, TimerRelative, HundredNanoseconds);\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    Status = gBS->WaitForEvent (sizeof (gTimerEvent)/sizeof (EFI_EVENT), &gTimerEvent, &Index);\r
+    ASSERT_EFI_ERROR (Status);\r
+  \r
+  } else {\r
+    gEmuThunk->Sleep (NanoSeconds);\r
+  }\r
+  return NanoSeconds;\r
+}\r
+\r
+\r
+/**\r
+  Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+  The counter can either count up by 1 or count down by 1. If the physical\r
+  performance counter counts by a larger increment, then the counter values\r
+  must be translated. The properties of the counter can be retrieved from\r
+  GetPerformanceCounterProperties().\r
+\r
+  @return The current value of the free running performance counter.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounter (\r
+  VOID\r
+  )\r
+{\r
+  return gEmuThunk->QueryPerformanceCounter ();\r
+}\r
+\r
+/**\r
+  Retrieves the 64-bit frequency in Hz and the range of performance counter\r
+  values.\r
+\r
+  If StartValue is not NULL, then the value that the performance counter starts\r
+  with immediately after is it rolls over is returned in StartValue. If\r
+  EndValue is not NULL, then the value that the performance counter end with\r
+  immediately before it rolls over is returned in EndValue. The 64-bit\r
+  frequency of the performance counter in Hz is always returned. If StartValue\r
+  is less than EndValue, then the performance counter counts up. If StartValue\r
+  is greater than EndValue, then the performance counter counts down. For\r
+  example, a 64-bit free running counter that counts up would have a StartValue\r
+  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
+  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
+\r
+  @param  StartValue  The value the performance counter starts with when it\r
+                      rolls over.\r
+  @param  EndValue    The value that the performance counter ends with before\r
+                      it rolls over.\r
+\r
+  @return The frequency in Hz.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounterProperties (\r
+  OUT      UINT64                    *StartValue,  OPTIONAL\r
+  OUT      UINT64                    *EndValue     OPTIONAL\r
+  )\r
+{\r
+\r
+  if (StartValue != NULL) {\r
+    *StartValue = 0ULL;\r
+  }\r
+  if (EndValue != NULL) {\r
+    *EndValue = (UINT64)-1LL;\r
+  }\r
+  \r
+  return gEmuThunk->QueryPerformanceFrequency ();\r
+}\r
+\r
+\r
+/**\r
+  Register for the Timer AP protocol.\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DxeTimerLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EfiCreateProtocolNotifyEvent (\r
+    &gEfiTimerArchProtocolGuid,\r
+    TPL_CALLBACK,\r
+    RegisterTimerArchProtocol,\r
+    NULL,\r
+    &gRegistration\r
+    );\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
diff --git a/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.inf b/EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.inf
new file mode 100644 (file)
index 0000000..5147937
--- /dev/null
@@ -0,0 +1,51 @@
+## @file\r
+#  NULL instance of Timer Library as a template.\r
+#\r
+#  A non-functional instance of the Timer Library that can be used as a template\r
+#  for the implementation of a functional timer library instance. This library instance can\r
+#  also be used to test build DXE, Runtime, DXE SAL, and DXE SMM modules that require timer\r
+#  services as well as EBC modules that require timer services.\r
+#\r
+#  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuDxeTimerLib\r
+  FILE_GUID                      = 74B62391-AD0D-1B4D-8784-151404F9D538\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = TimerLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION\r
+\r
+  CONSTRUCTOR                    = DxeTimerLibConstructor\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  DxeTimerLib.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  DebugLib\r
+  EmuThunkLib\r
+  UefiLib\r
+  UefiBootServicesTableLib\r
+  \r
+[Protocols]\r
+  gEfiTimerArchProtocolGuid\r
diff --git a/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c b/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c
new file mode 100644 (file)
index 0000000..8f47ef9
--- /dev/null
@@ -0,0 +1,557 @@
+/*++ @file\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#include "BdsPlatform.h"\r
+\r
+EMU_SYSTEM_CONFIGURATION mSystemConfigData;\r
+\r
+VOID\r
+SetupVariableInit (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                      Status;\r
+  UINTN                           Size;\r
+\r
+  Size = sizeof (mSystemConfigData);\r
+  Status = gRT->GetVariable (\r
+                  L"Setup",\r
+                  &gEmuSystemConfigGuid,\r
+                  NULL,\r
+                  &Size,\r
+                  (VOID *) &mSystemConfigData\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // SetupVariable is corrupt\r
+    //\r
+    mSystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);\r
+    mSystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);\r
+\r
+    Status = gRT->SetVariable (\r
+                    L"Setup",\r
+                    &gEmuSystemConfigGuid,\r
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                    sizeof (mSystemConfigData),\r
+                    (VOID *) &mSystemConfigData\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));\r
+    }\r
+  }\r
+}\r
+\r
+//\r
+// BDS Platform Functions\r
+//\r
+VOID\r
+EFIAPI\r
+PlatformBdsInit (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Platform Bds init. Include the platform firmware vendor, revision\r
+  and so crc check.\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+  None.\r
+\r
+**/\r
+{\r
+  SetupVariableInit ();\r
+}\r
+\r
+EFI_STATUS\r
+PlatformBdsConnectConsole (\r
+  IN BDS_CONSOLE_CONNECT_ENTRY   *PlatformConsole\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Connect the predefined platform default console device. Always try to find\r
+  and enable the vga device if have.\r
+\r
+Arguments:\r
+\r
+  PlatformConsole         - Predfined platform default console device array.\r
\r
+Returns:\r
+\r
+  EFI_SUCCESS             - Success connect at least one ConIn and ConOut \r
+                            device, there must have one ConOut device is \r
+                            active vga device.\r
+  \r
+  EFI_STATUS              - Return the status of \r
+                            BdsLibConnectAllDefaultConsoles ()\r
+\r
+**/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       Index;\r
+\r
+  Index   = 0;\r
+  Status  = EFI_SUCCESS;\r
+\r
+  //\r
+  // Have chance to connect the platform default console,\r
+  // the platform default console is the minimue device group\r
+  // the platform should support\r
+  //\r
+  while (PlatformConsole[Index].DevicePath != NULL) {\r
+    //\r
+    // Update the console variable with the connect type\r
+    //\r
+    if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
+      BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);\r
+    }\r
+\r
+    if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
+      BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);\r
+    }\r
+\r
+    if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
+      BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);\r
+    }\r
+\r
+    Index++;\r
+  }\r
+  //\r
+  // Connect the all the default console with current cosole variable\r
+  //\r
+  Status = BdsLibConnectAllDefaultConsoles ();\r
+  return Status;\r
+}\r
+\r
+VOID\r
+PlatformBdsConnectSequence (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Connect with predeined platform connect sequence, \r
+  the OEM/IBV can customize with their own connect sequence.\r
+  \r
+Arguments:\r
+\r
+  None.\r
\r
+Returns:\r
+\r
+  None.\r
+  \r
+**/\r
+{\r
+  UINTN Index;\r
+\r
+  Index = 0;\r
+\r
+  //\r
+  // Here we can get the customized platform connect sequence\r
+  // Notes: we can connect with new variable which record the\r
+  // last time boots connect device path sequence\r
+  //\r
+  while (gPlatformConnectSequence[Index] != NULL) {\r
+    //\r
+    // Build the platform boot option\r
+    //\r
+    BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
+    Index++;\r
+  }\r
+\r
+  //\r
+  // Just use the simple policy to connect all devices\r
+  //\r
+  BdsLibConnectAll ();\r
+}\r
+\r
+VOID\r
+PlatformBdsGetDriverOption (\r
+  IN OUT LIST_ENTRY              *BdsDriverLists\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Load the predefined driver option, OEM/IBV can customize this\r
+  to load their own drivers\r
+  \r
+Arguments:\r
+\r
+  BdsDriverLists  - The header of the driver option link list.\r
\r
+Returns:\r
+\r
+  None.\r
+  \r
+**/\r
+{\r
+  UINTN Index;\r
+\r
+  Index = 0;\r
+\r
+  //\r
+  // Here we can get the customized platform driver option\r
+  //\r
+  while (gPlatformDriverOption[Index] != NULL) {\r
+    //\r
+    // Build the platform boot option\r
+    //\r
+    BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");\r
+    Index++;\r
+  }\r
+\r
+}\r
+\r
+VOID\r
+PlatformBdsDiagnostics (\r
+  IN EXTENDMEM_COVERAGE_LEVEL    MemoryTestLevel,\r
+  IN BOOLEAN                     QuietBoot,\r
+  IN BASEM_MEMORY_TEST           BaseMemoryTest\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Perform the platform diagnostic, such like test memory. OEM/IBV also\r
+  can customize this fuction to support specific platform diagnostic.\r
+  \r
+Arguments:\r
+\r
+  MemoryTestLevel  - The memory test intensive level\r
+  \r
+  QuietBoot        - Indicate if need to enable the quiet boot\r
+\r
+  BaseMemoryTest   - A pointer to BdsMemoryTest()\r
\r
+Returns:\r
+\r
+  None.\r
+  \r
+**/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Here we can decide if we need to show\r
+  // the diagnostics screen\r
+  // Notes: this quiet boot code should be remove\r
+  // from the graphic lib\r
+  //\r
+  if (QuietBoot) {\r
+    EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
+    //\r
+    // Perform system diagnostic\r
+    //\r
+    Status = BaseMemoryTest (MemoryTestLevel);\r
+    if (EFI_ERROR (Status)) {\r
+      DisableQuietBoot ();\r
+    }\r
+\r
+    return ;\r
+  }\r
+  //\r
+  // Perform system diagnostic\r
+  //\r
+  Status = BaseMemoryTest (MemoryTestLevel);\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+PlatformBdsPolicyBehavior (\r
+  IN OUT LIST_ENTRY                  *DriverOptionList,\r
+  IN OUT LIST_ENTRY                  *BootOptionList,\r
+  IN PROCESS_CAPSULES                ProcessCapsules,\r
+  IN BASEM_MEMORY_TEST               BaseMemoryTest\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The function will excute with as the platform policy, current policy\r
+  is driven by boot mode. IBV/OEM can customize this code for their specific\r
+  policy action.\r
+  \r
+Arguments:\r
+\r
+  DriverOptionList - The header of the driver option link list\r
+  \r
+  BootOptionList   - The header of the boot option link list\r
+\r
+  ProcessCapsules  - A pointer to ProcessCapsules()\r
+\r
+  BaseMemoryTest   - A pointer to BaseMemoryTest()\r
+\r
+Returns:\r
+\r
+  None.\r
+  \r
+**/\r
+{\r
+  EFI_STATUS     Status;\r
+  UINT16         Timeout;\r
+  EFI_BOOT_MODE  BootMode;\r
+\r
+  //\r
+  // Init the time out value\r
+  //\r
+  Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
+\r
+  //\r
+  // Load the driver option as the driver option list\r
+  //\r
+  PlatformBdsGetDriverOption (DriverOptionList);\r
+\r
+  //\r
+  // Get current Boot Mode\r
+  //\r
+  Status = BdsLibGetBootMode (&BootMode);\r
+\r
+  //\r
+  // Go the different platform policy with different boot mode\r
+  // Notes: this part code can be change with the table policy\r
+  //\r
+  switch (BootMode) {\r
+\r
+  case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r
+  case BOOT_WITH_MINIMAL_CONFIGURATION:\r
+    //\r
+    // In no-configuration boot mode, we can connect the\r
+    // console directly.\r
+    //\r
+    BdsLibConnectAllDefaultConsoles ();\r
+    PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r
+\r
+    //\r
+    // Perform some platform specific connect sequence\r
+    //\r
+    PlatformBdsConnectSequence ();\r
+\r
+    //\r
+    // Notes: current time out = 0 can not enter the\r
+    // front page\r
+    //\r
+    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
+\r
+    //\r
+    // Check the boot option with the boot option list\r
+    //\r
+    BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
+    break;\r
+\r
+  case BOOT_ON_FLASH_UPDATE:\r
+    //\r
+    // Boot with the specific configuration\r
+    //\r
+    PlatformBdsConnectConsole (gPlatformConsole);\r
+    PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
+    BdsLibConnectAll ();\r
+    ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r
+    break;\r
+\r
+  case BOOT_IN_RECOVERY_MODE:\r
+    //\r
+    // In recovery mode, just connect platform console\r
+    // and show up the front page\r
+    //\r
+    PlatformBdsConnectConsole (gPlatformConsole);\r
+    PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
+\r
+    //\r
+    // In recovery boot mode, we still enter to the\r
+    // frong page now\r
+    //\r
+    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
+    break;\r
+\r
+  case BOOT_WITH_FULL_CONFIGURATION:\r
+  case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r
+  case BOOT_WITH_DEFAULT_SETTINGS:\r
+  default:\r
+    //\r
+    // Connect platform console\r
+    //\r
+    Status = PlatformBdsConnectConsole (gPlatformConsole);\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Here OEM/IBV can customize with defined action\r
+      //\r
+      PlatformBdsNoConsoleAction ();\r
+    }\r
+\r
+    PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r
+\r
+    //\r
+    // Perform some platform specific connect sequence\r
+    //\r
+    PlatformBdsConnectSequence ();\r
+\r
+    //\r
+    // Give one chance to enter the setup if we\r
+    // have the time out\r
+    //\r
+    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
+\r
+    //\r
+    // Here we have enough time to do the enumeration of boot device\r
+    //\r
+    BdsLibEnumerateAllBootOption (BootOptionList);\r
+    break;\r
+  }\r
+\r
+  return ;\r
+\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+PlatformBdsBootSuccess (\r
+  IN  BDS_COMMON_OPTION   *Option\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Hook point after a boot attempt succeeds. We don't expect a boot option to\r
+  return, so the EFI 1.0 specification defines that you will default to an\r
+  interactive mode and stop processing the BootOrder list in this case. This\r
+  is alos a platform implementation and can be customized by IBV/OEM.\r
+\r
+Arguments:\r
+\r
+  Option - Pointer to Boot Option that succeeded to boot.\r
+\r
+Returns:\r
+  \r
+  None.\r
+\r
+**/\r
+{\r
+  CHAR16  *TmpStr;\r
+\r
+  //\r
+  // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
+  // select loop then we need to pop up a UI and wait for user input.\r
+  //\r
+  TmpStr = Option->StatusString;\r
+  if (TmpStr != NULL) {\r
+    BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
+    FreePool (TmpStr);\r
+  }\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+PlatformBdsBootFail (\r
+  IN  BDS_COMMON_OPTION  *Option,\r
+  IN  EFI_STATUS         Status,\r
+  IN  CHAR16             *ExitData,\r
+  IN  UINTN              ExitDataSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Hook point after a boot attempt fails.\r
+\r
+Arguments:\r
+  \r
+  Option - Pointer to Boot Option that failed to boot.\r
+\r
+  Status - Status returned from failed boot.\r
+\r
+  ExitData - Exit data returned from failed boot.\r
+\r
+  ExitDataSize - Exit data size returned from failed boot.\r
+\r
+Returns:\r
+  \r
+  None.\r
+\r
+**/\r
+{\r
+  CHAR16  *TmpStr;\r
+\r
+  //\r
+  // If Boot returned with failed status then we need to pop up a UI and wait\r
+  // for user input.\r
+  //\r
+  TmpStr = Option->StatusString;\r
+  if (TmpStr != NULL) {\r
+    BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
+    FreePool (TmpStr);\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+PlatformBdsNoConsoleAction (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  This function is remained for IBV/OEM to do some platform action,\r
+  if there no console device can be connected.\r
+\r
+Arguments:\r
+  \r
+  None.\r
+  \r
+Returns:\r
+  \r
+  EFI_SUCCESS      - Direct return success now.\r
+\r
+**/\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+PlatformBdsLockNonUpdatableFlash (\r
+  VOID\r
+  )\r
+{\r
+  return;\r
+}\r
+\r
+/**\r
+  Lock the ConsoleIn device in system table. All key\r
+  presses will be ignored until the Password is typed in. The only way to\r
+  disable the password is to type it in to a ConIn device.\r
+\r
+  @param  Password        Password used to lock ConIn device.\r
+\r
+  @retval EFI_SUCCESS     lock the Console In Spliter virtual handle successfully.\r
+  @retval EFI_UNSUPPORTED Password not found\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LockKeyboards (\r
+  IN  CHAR16    *Password\r
+  )\r
+{\r
+    return EFI_UNSUPPORTED;\r
+}\r
diff --git a/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.h b/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.h
new file mode 100644 (file)
index 0000000..a76ec2e
--- /dev/null
@@ -0,0 +1,97 @@
+/*++ @file\r
+\r
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#ifndef _BDS_PLATFORM_H\r
+#define _BDS_PLATFORM_H\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Guid/EmuSystemConfig.h>\r
+#include <Protocol/EmuThunk.h>\r
+#include <Protocol/EmuIoThunk.h>\r
+#include <Protocol/EmuGraphicsWindow.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/GenericBdsLib.h>\r
+#include <Library/PlatformBdsLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+\r
+extern BDS_CONSOLE_CONNECT_ENTRY  gPlatformConsole[];\r
+extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformConnectSequence[];\r
+extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformDriverOption[];\r
+\r
+#define gEndEntire \\r
+  { \\r
+    END_DEVICE_PATH_TYPE,\\r
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,\\r
+    END_DEVICE_PATH_LENGTH,\\r
+    0\\r
+  }\r
+\r
+\r
+typedef struct {\r
+  EMU_VENDOR_DEVICE_PATH_NODE     EmuBus;\r
+  EMU_VENDOR_DEVICE_PATH_NODE     EmuGraphicsWindow;\r
+  EFI_DEVICE_PATH_PROTOCOL        End;\r
+} EMU_PLATFORM_UGA_DEVICE_PATH;\r
+\r
+\r
+//\r
+// Platform BDS Functions\r
+//\r
+VOID\r
+PlatformBdsGetDriverOption (\r
+  IN LIST_ENTRY               *BdsDriverLists\r
+  );\r
+\r
+EFI_STATUS\r
+BdsMemoryTest (\r
+  EXTENDMEM_COVERAGE_LEVEL Level\r
+  );\r
+\r
+\r
+VOID\r
+PlatformBdsConnectSequence (\r
+  VOID\r
+  );\r
+\r
+EFI_STATUS\r
+ProcessCapsules (\r
+  EFI_BOOT_MODE BootMode\r
+  );\r
+\r
+EFI_STATUS\r
+PlatformBdsConnectConsole (\r
+  IN BDS_CONSOLE_CONNECT_ENTRY   *PlatformConsole\r
+  );\r
+\r
+EFI_STATUS\r
+PlatformBdsNoConsoleAction (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+PlatformBdsEnterFrontPage (\r
+  IN UINT16                 TimeoutDefault,\r
+  IN BOOLEAN                ConnectAllHappened\r
+  );\r
+\r
+#endif // _BDS_PLATFORM_H\r
diff --git a/EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf b/EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf
new file mode 100644 (file)
index 0000000..fecdbec
--- /dev/null
@@ -0,0 +1,66 @@
+## @file\r
+# Platfrom BDS driver\r
+#\r
+# Do platform action customized by IBV/OEM.\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuBdsLib\r
+  FILE_GUID                      =  59569181-CBF8-2E44-9C3E-C2AB2F5608E1\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PlatformBdsLib|DXE_DRIVER   \r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  BdsPlatform.c\r
+  PlatformData.c\r
+  BdsPlatform.h\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  MemoryAllocationLib\r
+  UefiBootServicesTableLib\r
+  UefiRuntimeServicesTableLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+  PcdLib\r
+  GenericBdsLib\r
+  DevicePathLib\r
+\r
+\r
+[Guids]\r
+  gEmuSystemConfigGuid\r
+\r
+[Pcd]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile\r
+  \r
+[Depex]\r
+  gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid\r
diff --git a/EmulatorPkg/Library/EmuBdsLib/PlatformData.c b/EmulatorPkg/Library/EmuBdsLib/PlatformData.c
new file mode 100644 (file)
index 0000000..e20099b
--- /dev/null
@@ -0,0 +1,69 @@
+/*++ @file\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#include "BdsPlatform.h"\r
+\r
+\r
+\r
+EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {\r
+  {\r
+    {\r
+      {\r
+        HARDWARE_DEVICE_PATH,\r
+        HW_VENDOR_DP,\r
+        {\r
+          (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),\r
+          (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
+        }\r
+      },\r
+      EMU_THUNK_PROTOCOL_GUID\r
+    },\r
+    0\r
+  },\r
+  {\r
+      HARDWARE_DEVICE_PATH,\r
+      HW_VENDOR_DP,\r
+      {\r
+        (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),\r
+        (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
+      },\r
+      EMU_GRAPHICS_WINDOW_PROTOCOL_GUID,\r
+      0\r
+  },\r
+  gEndEntire\r
+};\r
+\r
+//\r
+// Predefined platform default console device path\r
+//\r
+BDS_CONSOLE_CONNECT_ENTRY   gPlatformConsole[] = {\r
+  {\r
+    (EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath,\r
+    (CONSOLE_OUT | CONSOLE_IN)\r
+  },\r
+  {\r
+    NULL,\r
+    0\r
+  }\r
+};\r
+\r
+//\r
+// Predefined platform specific driver option\r
+//\r
+EFI_DEVICE_PATH_PROTOCOL    *gPlatformDriverOption[] = { NULL };\r
+\r
+//\r
+// Predefined platform connect sequence\r
+//\r
+EFI_DEVICE_PATH_PROTOCOL    *gPlatformConnectSequence[] = { NULL };\r
diff --git a/EmulatorPkg/Library/GuardUefiMemoryAllocationLib/GuardUefiMemoryAllocationLib.inf b/EmulatorPkg/Library/GuardUefiMemoryAllocationLib/GuardUefiMemoryAllocationLib.inf
new file mode 100644 (file)
index 0000000..3b008cc
--- /dev/null
@@ -0,0 +1,42 @@
+## @file\r
+# Instance of Memory Allocation Library using EFI Boot Services.\r
+#\r
+# Memory Allocation Library that uses EFI Boot Services to allocate\r
+#  and free memory. Calls OS malloc to enable OS based debug tools\r
+#\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = GuardUefiMemoryAllocationLib\r
+  FILE_GUID                      = DB290230-3EFA-064F-A317-E146925684FE\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = MemoryAllocationLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER DXE_CORE\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  MemoryAllocationLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+  BaseMemoryLib\r
+  UefiBootServicesTableLib\r
+  EmuThunkLib\r
diff --git a/EmulatorPkg/Library/GuardUefiMemoryAllocationLib/MemoryAllocationLib.c b/EmulatorPkg/Library/GuardUefiMemoryAllocationLib/MemoryAllocationLib.c
new file mode 100644 (file)
index 0000000..c457e7c
--- /dev/null
@@ -0,0 +1,819 @@
+/** @file\r
+  Support routines for memory allocation routines based \r
+  on boot services for Dxe phase drivers using OS malloc.\r
+  \r
+  OS malloc is used so OS based malloc debugging tools can be used. \r
+  If a single driver links against this lib protocols from other \r
+  drivers, or EFI boot services can return a buffer that needs to \r
+  freed using the EFI scheme. This is why the gEmuThunk->Free () \r
+  can detect if the memory rang is for EFI so the right free can be\r
+  called.\r
+\r
+  Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+  Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+  This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php.                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+\r
+#include <Uefi.h>\r
+\r
+\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/EmuThunkLib.h>\r
+\r
+/**\r
+  Allocates one or more 4KB pages of a certain memory type.\r
+\r
+  Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated\r
+  buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL is returned.\r
+  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  MemoryType            The type of memory to allocate.\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePages (\r
+  IN EFI_MEMORY_TYPE  MemoryType,  \r
+  IN UINTN            Pages\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PHYSICAL_ADDRESS  Memory; \r
+\r
+  if (Pages == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  return gEmuThunk->Valloc (Pages * EFI_PAGE_SIZE);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiBootServicesData.\r
+\r
+  Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocatePages (\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  return InternalAllocatePages (EfiBootServicesData, Pages);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimePages (\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  return InternalAllocatePages (EfiRuntimeServicesData, Pages);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiReservedMemoryType.\r
+\r
+  Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedPages (\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  return InternalAllocatePages (EfiReservedMemoryType, Pages);\r
+}\r
+\r
+/**\r
+  Frees one or more 4KB pages that were previously allocated with one of the page allocation\r
+  functions in the Memory Allocation Library.\r
+\r
+  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer\r
+  must have been allocated on a previous call to the page allocation services of the Memory\r
+  Allocation Library.  If it is not possible to free allocated pages, then this function will\r
+  perform no actions.\r
+  \r
+  If Buffer was not allocated with a page allocation function in the Memory Allocation Library,\r
+  then ASSERT().\r
+  If Pages is zero, then ASSERT().\r
\r
+  @param  Buffer                The pointer to the buffer of pages to free.\r
+  @param  Pages                 The number of 4 KB pages to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreePages (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+\r
+  ASSERT (Pages != 0);\r
+  if (!gEmuThunk->Free (Buffer)) {\r
+    // The Free thunk will not free memory allocated in emulated EFI memory.\r
+    // The assmuption is this was allocated directly by EFI. We need this as some \r
+    // times protocols or EFI BootServices can return dynamically allocated buffers.\r
+    Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of a certain memory type at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment\r
+  specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is returned.\r
+  If there is not enough memory at the specified alignment remaining to satisfy the request, then\r
+  NULL is returned.\r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  MemoryType            The type of memory to allocate.\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateAlignedPages (\r
+  IN EFI_MEMORY_TYPE  MemoryType,  \r
+  IN UINTN            Pages,\r
+  IN UINTN            Alignment\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  VOID                  *Memory;\r
+  UINTN                 AlignedMemory;\r
+  UINTN                 AlignmentMask;\r
+  UINTN                 UnalignedPages;\r
+  UINTN                 RealPages;\r
+\r
+  //\r
+  // Alignment must be a power of two or zero.\r
+  //\r
+  ASSERT ((Alignment & (Alignment - 1)) == 0);\r
\r
+  if (Pages == 0) {\r
+    return NULL;\r
+  }\r
+  if (Alignment > EFI_PAGE_SIZE) {\r
+    //\r
+    // Caculate the total number of pages since alignment is larger than page size.\r
+    //\r
+    AlignmentMask  = Alignment - 1;\r
+    RealPages      = Pages + EFI_SIZE_TO_PAGES (Alignment);\r
+    //\r
+    // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.\r
+    //\r
+    ASSERT (RealPages > Pages);\r
\r
+    Memory = gEmuThunk->Valloc (Pages * EFI_PAGE_SIZE);\r
+    if (Memory != NULL) {\r
+      return NULL;\r
+    }\r
+    AlignedMemory  = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;\r
+    UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);\r
+    if (UnalignedPages > 0) {\r
+      //\r
+      // Free first unaligned page(s).\r
+      //\r
+      FreePages (Memory, UnalignedPages);\r
+    }\r
+    Memory         = (VOID *) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));\r
+    UnalignedPages = RealPages - Pages - UnalignedPages;\r
+    if (UnalignedPages > 0) {\r
+      //\r
+      // Free last unaligned page(s).\r
+      //\r
+      FreePages (Memory, UnalignedPages);\r
+    }\r
+  } else {\r
+    //\r
+    // Do not over-allocate pages in this case.\r
+    //\r
+    Memory = gEmuThunk->Valloc (Pages * EFI_PAGE_SIZE);\r
+    if (Memory != NULL) {\r
+      return NULL;\r
+    }\r
+    AlignedMemory  = (UINTN) Memory;\r
+  }\r
+  return (VOID *) AlignedMemory;\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
+  request, then NULL is returned.\r
+  \r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedPages (\r
+  IN UINTN  Pages,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
+  request, then NULL is returned.\r
+  \r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedRuntimePages (\r
+  IN UINTN  Pages,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.\r
+\r
+  Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an\r
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
+  request, then NULL is returned.\r
+  \r
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
+                                If Alignment is zero, then byte alignment is used.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateAlignedReservedPages (\r
+  IN UINTN  Pages,\r
+  IN UINTN  Alignment\r
+  )\r
+{\r
+  return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);\r
+}\r
+\r
+/**\r
+  Frees one or more 4KB pages that were previously allocated with one of the aligned page\r
+  allocation functions in the Memory Allocation Library.\r
+\r
+  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer\r
+  must have been allocated on a previous call to the aligned page allocation services of the Memory\r
+  Allocation Library.  If it is not possible to free allocated pages, then this function will \r
+  perform no actions.\r
+  \r
+  If Buffer was not allocated with an aligned page allocation function in the Memory Allocation\r
+  Library, then ASSERT().\r
+  If Pages is zero, then ASSERT().\r
+  \r
+  @param  Buffer                The pointer to the buffer of pages to free.\r
+  @param  Pages                 The number of 4 KB pages to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreeAlignedPages (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  FreePages (Buffer, Pages);\r
+}\r
+\r
+/**\r
+  Allocates a buffer of a certain pool type.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certain pool type and returns a\r
+  pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  MemoryType            The type of memory to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocatePool (\r
+  IN EFI_MEMORY_TYPE  MemoryType,  \r
+  IN UINTN            AllocationSize\r
+  )\r
+{\r
+  return gEmuThunk->Malloc (AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfiBootServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a\r
+  pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocatePool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocatePool (EfiBootServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns\r
+  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimePool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates a buffer of type EfiReservedMemoryType.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns\r
+  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedPool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocatePool (EfiReservedMemoryType, AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of a certain pool type.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certain pool type, clears the buffer\r
+  with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a valid\r
+  buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the request,\r
+  then NULL is returned.\r
+\r
+  @param  PoolType              The type of memory to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateZeroPool (\r
+  IN EFI_MEMORY_TYPE  PoolType,  \r
+  IN UINTN            AllocationSize\r
+  ) \r
+{\r
+  VOID  *Memory;\r
+\r
+  Memory = InternalAllocatePool (PoolType, AllocationSize);\r
+  if (Memory != NULL) {\r
+    Memory = ZeroMem (Memory, AllocationSize);\r
+  }\r
+  return Memory;\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiBootServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the\r
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
+  request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateZeroPool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocateZeroPool (EfiBootServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the\r
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
+  request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimeZeroPool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);\r
+}\r
+\r
+/**\r
+  Allocates and zeros a buffer of type EfiReservedMemoryType.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the\r
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
+  request, then NULL is returned.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedZeroPool (\r
+  IN UINTN  AllocationSize\r
+  )\r
+{\r
+  return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of a certain pool type.\r
+\r
+  Allocates the number bytes specified by AllocationSize of a certain pool type, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+\r
+  @param  PoolType              The type of pool to allocate.\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalAllocateCopyPool (\r
+  IN EFI_MEMORY_TYPE  PoolType,  \r
+  IN UINTN            AllocationSize,\r
+  IN CONST VOID       *Buffer\r
+  ) \r
+{\r
+  VOID  *Memory;\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+\r
+  Memory = InternalAllocatePool (PoolType, AllocationSize);\r
+  if (Memory != NULL) {\r
+     Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+  }\r
+  return Memory;\r
+} \r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiBootServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  \r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer\r
+  )\r
+{\r
+  return InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer);\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  \r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimeCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer\r
+  )\r
+{\r
+  return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);\r
+}\r
+\r
+/**\r
+  Copies a buffer to an allocated buffer of type EfiReservedMemoryType.\r
+\r
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies\r
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
+  is not enough memory remaining to satisfy the request, then NULL is returned.\r
+  \r
+  If Buffer is NULL, then ASSERT().\r
+  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+\r
+  @param  AllocationSize        The number of bytes to allocate and zero.\r
+  @param  Buffer                The buffer to copy to the allocated buffer.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateReservedCopyPool (\r
+  IN UINTN       AllocationSize,\r
+  IN CONST VOID  *Buffer\r
+  )\r
+{\r
+  return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);\r
+}\r
+\r
+/**\r
+  Reallocates a buffer of a specified memory type.\r
+\r
+  Allocates and zeros the number bytes specified by NewSize from memory of the type\r
+  specified by PoolType.  If OldBuffer is not NULL, then the smaller of OldSize and \r
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  \r
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not \r
+  enough memory remaining to satisfy the request, then NULL is returned.\r
+  \r
+  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize\r
+  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().\r
+\r
+  @param  PoolType       The type of pool to allocate.\r
+  @param  OldSize        The size, in bytes, of OldBuffer.\r
+  @param  NewSize        The size, in bytes, of the buffer to reallocate.\r
+  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional \r
+                         parameter that may be NULL.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+InternalReallocatePool (\r
+  IN EFI_MEMORY_TYPE  PoolType,  \r
+  IN UINTN            OldSize,\r
+  IN UINTN            NewSize,\r
+  IN VOID             *OldBuffer  OPTIONAL\r
+  )\r
+{\r
+  VOID  *NewBuffer;\r
+\r
+  NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);\r
+  if (NewBuffer != NULL && OldBuffer != NULL) {\r
+    CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));\r
+    FreePool (OldBuffer);\r
+  }\r
+  return NewBuffer;\r
+}\r
+\r
+/**\r
+  Reallocates a buffer of type EfiBootServicesData.\r
+\r
+  Allocates and zeros the number bytes specified by NewSize from memory of type\r
+  EfiBootServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and \r
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  \r
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not \r
+  enough memory remaining to satisfy the request, then NULL is returned.\r
+  \r
+  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize\r
+  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().\r
+\r
+  @param  OldSize        The size, in bytes, of OldBuffer.\r
+  @param  NewSize        The size, in bytes, of the buffer to reallocate.\r
+  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional \r
+                         parameter that may be NULL.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ReallocatePool (\r
+  IN UINTN  OldSize,\r
+  IN UINTN  NewSize,\r
+  IN VOID   *OldBuffer  OPTIONAL\r
+  )\r
+{\r
+  return InternalReallocatePool (EfiBootServicesData, OldSize, NewSize, OldBuffer);\r
+}\r
+\r
+/**\r
+  Reallocates a buffer of type EfiRuntimeServicesData.\r
+\r
+  Allocates and zeros the number bytes specified by NewSize from memory of type\r
+  EfiRuntimeServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and \r
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  \r
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not \r
+  enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize\r
+  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().\r
+\r
+  @param  OldSize        The size, in bytes, of OldBuffer.\r
+  @param  NewSize        The size, in bytes, of the buffer to reallocate.\r
+  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional \r
+                         parameter that may be NULL.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ReallocateRuntimePool (\r
+  IN UINTN  OldSize,\r
+  IN UINTN  NewSize,\r
+  IN VOID   *OldBuffer  OPTIONAL\r
+  )\r
+{\r
+  return InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);\r
+}\r
+\r
+/**\r
+  Reallocates a buffer of type EfiReservedMemoryType.\r
+\r
+  Allocates and zeros the number bytes specified by NewSize from memory of type\r
+  EfiReservedMemoryType.  If OldBuffer is not NULL, then the smaller of OldSize and \r
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  \r
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not \r
+  enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize\r
+  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().\r
+\r
+  @param  OldSize        The size, in bytes, of OldBuffer.\r
+  @param  NewSize        The size, in bytes, of the buffer to reallocate.\r
+  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional \r
+                         parameter that may be NULL.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ReallocateReservedPool (\r
+  IN UINTN  OldSize,\r
+  IN UINTN  NewSize,\r
+  IN VOID   *OldBuffer  OPTIONAL\r
+  )\r
+{\r
+  return InternalReallocatePool (EfiReservedMemoryType, OldSize, NewSize, OldBuffer);\r
+}\r
+\r
+/**\r
+  Frees a buffer that was previously allocated with one of the pool allocation functions in the\r
+  Memory Allocation Library.\r
+\r
+  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the\r
+  pool allocation services of the Memory Allocation Library.  If it is not possible to free pool\r
+  resources, then this function will perform no actions.\r
+  \r
+  If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,\r
+  then ASSERT().\r
+\r
+  @param  Buffer                The pointer to the buffer to free.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+FreePool (\r
+  IN VOID   *Buffer\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+\r
+  if (!gEmuThunk->Free (Buffer)) {\r
+    // The Free thunk will not free memory allocated in emulated EFI memory.\r
+    // The assmuption is this was allocated directly by EFI. We need this as some \r
+    // times protocols or EFI BootServices can return dynamically allocated buffers.\r
+    Status = gBS->FreePool (Buffer);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+}\r
+\r
diff --git a/EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c b/EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c
new file mode 100644 (file)
index 0000000..5a80870
--- /dev/null
@@ -0,0 +1,50 @@
+/*++ @file\r
+\r
+Copyright (c) 2011, Apple Inc. All rights reserved. \r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Uefi.h>\r
+#include <Protocol/SimpleTextInEx.h>\r
+\r
+\r
+/**\r
+  KeyMapMake gets called on key presses.\r
+\r
+  @param  KeyData       Key that was pressed.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+KeyMapMake (\r
+  IN EFI_KEY_DATA   *KeyData\r
+  )\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  KeyMapBreak gets called on key releases.\r
+\r
+  @param  KeyData       Key that was pressed.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+KeyMapBreak (\r
+  IN EFI_KEY_DATA   *KeyData\r
+  )\r
+{\r
+  return EFI_SUCCESS;\r
+}
\ No newline at end of file
diff --git a/EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.inf b/EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.inf
new file mode 100644 (file)
index 0000000..f009d85
--- /dev/null
@@ -0,0 +1,39 @@
+## @file\r
+# A library to produce the global variable 'gEmuThunk'\r
+#\r
+# This library contains a single global variable 'gEmuThunk' along with a constructor to \r
+# initialize that global.\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = KeyMapLibNull\r
+  FILE_GUID                      = 6B7067C7-A843-A34C-9530-48446963B740\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = KeyMapLib \r
+\r
+[Sources]\r
+  KeyMapLibNull.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  HobLib\r
+  DebugLib\r
+\r
+\r
diff --git a/EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiCoreServicesTablePointerLib.inf b/EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiCoreServicesTablePointerLib.inf
new file mode 100644 (file)
index 0000000..04be649
--- /dev/null
@@ -0,0 +1,41 @@
+## @file\r
+# Instance of PEI Services Table Pointer Library using global variable for the table pointer.\r
+#\r
+# PEI Services Table Pointer Library implementation that retrieves a pointer to the\r
+#  PEI Services Table from a global variable. Not available to modules that execute from\r
+#  read-only memory.\r
+#\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmulatorPkgPeiCoreServicesTablePointerLib\r
+  FILE_GUID                      = E9A22529-44FA-3E4A-A66B-1E918E7AB26A\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PeiServicesTablePointerLib|PEI_CORE\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC (EBC is for build only)\r
+#\r
+\r
+[Sources]\r
+  PeiServicesTablePointer.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+\r
diff --git a/EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c b/EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c
new file mode 100644 (file)
index 0000000..9b02316
--- /dev/null
@@ -0,0 +1,91 @@
+/** @file\r
+  PEI Services Table Pointer Library.\r
+  \r
+  This library is used for PEIM which does executed from flash device directly but\r
+  executed in memory.\r
+\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+CONST EFI_PEI_SERVICES  **gPeiServices;\r
+\r
+/**\r
+  Caches a pointer PEI Services Table. \r
\r
+  Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer \r
+  in a CPU specific manner as specified in the CPU binding section of the Platform Initialization \r
+  Pre-EFI Initialization Core Interface Specification. \r
+  \r
+  If PeiServicesTablePointer is NULL, then ASSERT().\r
+  \r
+  @param    PeiServicesTablePointer   The address of PeiServices pointer.\r
+**/\r
+VOID\r
+EFIAPI\r
+SetPeiServicesTablePointer (\r
+  IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r
+  )\r
+{\r
+  ASSERT (PeiServicesTablePointer != NULL);\r
+  gPeiServices = PeiServicesTablePointer;\r
+}\r
+\r
+/**\r
+  Retrieves the cached value of the PEI Services Table pointer.\r
+\r
+  Returns the cached value of the PEI Services Table pointer in a CPU specific manner \r
+  as specified in the CPU binding section of the Platform Initialization Pre-EFI \r
+  Initialization Core Interface Specification.\r
+  \r
+  If the cached PEI Services Table pointer is NULL, then ASSERT().\r
+\r
+  @return  The pointer to PeiServices.\r
+\r
+**/\r
+CONST EFI_PEI_SERVICES **\r
+EFIAPI\r
+GetPeiServicesTablePointer (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (gPeiServices != NULL);\r
+  return gPeiServices;\r
+}\r
+\r
+\r
+/**\r
+  The constructor function caches the pointer to PEI services.\r
+  \r
+  The constructor function caches the pointer to PEI services.\r
+  It will always return EFI_SUCCESS.\r
+\r
+  @param  FileHandle   The handle of FFS header the loaded driver.\r
+  @param  PeiServices  The pointer to the PEI services.\r
+\r
+  @retval EFI_SUCCESS  The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesTablePointerLibConstructor (\r
+  IN EFI_PEI_FILE_HANDLE        FileHandle,\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices\r
+  )\r
+{\r
+  gPeiServices = PeiServices;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
diff --git a/EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c b/EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c
new file mode 100644 (file)
index 0000000..b398b53
--- /dev/null
@@ -0,0 +1,107 @@
+/** @file\r
+  Provides services to perform additional actions to relocate and unload\r
+  PE/Coff image for Emu environment specific purpose such as souce level debug.\r
+  This version only works for PEI phase\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#include <PiPei.h>\r
+#include <Ppi/EmuThunk.h>\r
+#include <Protocol/EmuThunk.h>\r
+\r
+#include <Library/PeCoffLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/PeCoffExtraActionLib.h>\r
+#include <Library/EmuMagicPageLib.h>\r
+\r
+//\r
+// Cache of UnixThunk protocol \r
+//\r
+EMU_THUNK_PROTOCOL   *mThunk = NULL;\r
+\r
+/**\r
+  The function caches the pointer of the Unix thunk functions\r
+  It will ASSERT() if Unix thunk ppi is not installed.\r
+\r
+  @retval EFI_SUCCESS   WinNT thunk protocol is found and cached.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmuPeCoffGetThunkStucture (\r
+  )\r
+{\r
+  EMU_THUNK_PPI     *ThunkPpi;\r
+  EFI_STATUS        Status;\r
+\r
+  \r
+  //\r
+  // Locate Unix ThunkPpi for retrieving standard output handle\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+              &gEmuThunkPpiGuid,\r
+              0,\r
+              NULL,\r
+              (VOID **) &ThunkPpi\r
+              );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  EMU_MAGIC_PAGE()->Thunk = (EMU_THUNK_PROTOCOL *) ThunkPpi->Thunk ();\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Performs additional actions after a PE/COFF image has been loaded and relocated.\r
+\r
+  If ImageContext is NULL, then ASSERT().\r
+\r
+  @param  ImageContext  Pointer to the image context structure that describes the\r
+                        PE/COFF image that has already been loaded and relocated.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeCoffLoaderRelocateImageExtraAction (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+{\r
+  if (EMU_MAGIC_PAGE()->Thunk == NULL) {\r
+    EmuPeCoffGetThunkStucture ();\r
+  }\r
+    EMU_MAGIC_PAGE()->Thunk->PeCoffRelocateImageExtraAction (ImageContext);\r
+  }\r
+\r
+\r
+/**\r
+  Performs additional actions just before a PE/COFF image is unloaded.  Any resources\r
+  that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.\r
+  \r
+  If ImageContext is NULL, then ASSERT().\r
+  \r
+  @param  ImageContext  Pointer to the image context structure that describes the\r
+                        PE/COFF image that is being unloaded.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeCoffLoaderUnloadImageExtraAction (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+{\r
+  if (EMU_MAGIC_PAGE()->Thunk == NULL) {\r
+    EmuPeCoffGetThunkStucture ();\r
+  }\r
+  EMU_MAGIC_PAGE()->Thunk->PeCoffUnloadImageExtraAction (ImageContext);\r
+}\r
diff --git a/EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf b/EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf
new file mode 100644 (file)
index 0000000..f05dfc1
--- /dev/null
@@ -0,0 +1,49 @@
+## @file
+# PeCoff extra action libary for Pei phase that run Emu emulator.
+#
+# Lib to provide memory journal status code reporting Routines
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# 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
+# 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.
+
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = PeiEmuPeCoffExtraActionLib
+  FILE_GUID                      = 79C4E72A-730B-F040-8129-95877B3A97A8
+  MODULE_TYPE                    = PEIM
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = PeCoffExtraActionLib|PEI_CORE PEIM
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32
+#
+
+[Sources]
+  PeiEmuPeCoffExtraActionLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  EmulatorPkg/EmulatorPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  PeiServicesLib
+  DebugLib
+
+[Ppis]
+  gEmuThunkPpiGuid                          # PPI ALWAYS_CONSUMED
+
+[Pcd]
+  gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage
diff --git a/EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.c b/EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.c
new file mode 100644 (file)
index 0000000..e229805
--- /dev/null
@@ -0,0 +1,297 @@
+/*++ @file\r
+\r
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "PiPei.h"\r
+#include <Library/PeCoffGetEntryPointLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <IndustryStandard/PeImage.h>\r
+#include <Library/DebugLib.h>\r
+\r
+#include <Ppi/EmuThunk.h>\r
+#include <Protocol/EmuThunk.h>\r
+\r
+\r
+\r
+/**\r
+  Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded\r
+  into system memory with the PE/COFF Loader Library functions.\r
+\r
+  Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry\r
+  point in EntryPoint.  If the entry point could not be retrieved from the PE/COFF image, then\r
+  return RETURN_INVALID_PARAMETER.  Otherwise return RETURN_SUCCESS.\r
+  If Pe32Data is NULL, then ASSERT().\r
+  If EntryPoint is NULL, then ASSERT().\r
+\r
+  @param  Pe32Data                  The pointer to the PE/COFF image that is loaded in system memory.\r
+  @param  EntryPoint                The pointer to entry point to the PE/COFF image to return.\r
+\r
+  @retval RETURN_SUCCESS            EntryPoint was returned.\r
+  @retval RETURN_INVALID_PARAMETER  The entry point could not be found in the PE/COFF image.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderGetEntryPoint (\r
+  IN     VOID  *Pe32Data,\r
+  IN OUT VOID  **EntryPoint\r
+  )\r
+{\r
+  EMU_THUNK_PPI           *ThunkPpi;\r
+  EFI_STATUS              Status;\r
+  EMU_THUNK_PROTOCOL      *Thunk;\r
+\r
+  //\r
+  // Locate EmuThunkPpi for retrieving standard output handle\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+              &gEmuThunkPpiGuid,\r
+              0,\r
+              NULL,\r
+              (VOID **) &ThunkPpi\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Thunk  = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();\r
+\r
+  return Thunk->PeCoffGetEntryPoint (Pe32Data, EntryPoint);\r
+}\r
+\r
+/**\r
+  Returns the machine type of PE/COFF image. \r
+  This is copied from MDE BasePeCoffGetEntryPointLib, the code should be sync with it.\r
+  The reason is Emu package needs to load the image to memory to support source\r
+  level debug.\r
+   \r
+\r
+  @param  Pe32Data   Pointer to a PE/COFF header\r
+\r
+  @return            Machine type or zero if not a valid iamge\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PeCoffLoaderGetMachineType (\r
+  IN  VOID  *Pe32Data\r
+  )\r
+{  \r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION  Hdr;\r
+  EFI_IMAGE_DOS_HEADER                 *DosHdr;\r
+\r
+  ASSERT (Pe32Data   != NULL);\r
+\r
+  DosHdr = (EFI_IMAGE_DOS_HEADER  *)Pe32Data;\r
+  if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));\r
+\r
+  } else {\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(Pe32Data);\r
+  }\r
+\r
+  if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+    return Hdr.Te->Machine;\r
+  } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE)  {\r
+    return Hdr.Pe32->FileHeader.Machine;\r
+  }\r
+\r
+  return 0x0000;\r
+}\r
+\r
+/**\r
+  Returns a pointer to the PDB file name for a PE/COFF image that has been\r
+  loaded into system memory with the PE/COFF Loader Library functions.\r
+\r
+  Returns the PDB file name for the PE/COFF image specified by Pe32Data.  If\r
+  the PE/COFF image specified by Pe32Data is not a valid, then NULL is\r
+  returned.  If the PE/COFF image specified by Pe32Data does not contain a\r
+  debug directory entry, then NULL is returned.  If the debug directory entry\r
+  in the PE/COFF image specified by Pe32Data does not contain a PDB file name,\r
+  then NULL is returned.\r
+  If Pe32Data is NULL, then ASSERT().\r
+\r
+  @param  Pe32Data   Pointer to the PE/COFF image that is loaded in system\r
+                     memory.\r
+\r
+  @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL\r
+          if it cannot be retrieved.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+PeCoffLoaderGetPdbPointer (\r
+  IN VOID  *Pe32Data\r
+  )\r
+{\r
+  EFI_IMAGE_DOS_HEADER                  *DosHdr;\r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
+  EFI_IMAGE_DATA_DIRECTORY              *DirectoryEntry;\r
+  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY       *DebugEntry;\r
+  UINTN                                 DirCount;\r
+  VOID                                  *CodeViewEntryPointer;\r
+  INTN                                  TEImageAdjust;\r
+  UINT32                                NumberOfRvaAndSizes;\r
+  UINT16                                Magic;\r
+\r
+  ASSERT (Pe32Data   != NULL);\r
+\r
+  TEImageAdjust       = 0;\r
+  DirectoryEntry      = NULL;\r
+  DebugEntry          = NULL;\r
+  NumberOfRvaAndSizes = 0;\r
+\r
+  DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;\r
+  if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+    //\r
+    // DOS image header is present, so read the PE header after the DOS image header.\r
+    //\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));\r
+  } else {\r
+    //\r
+    // DOS image header is not present, so PE header is at the image base.\r
+    //\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;\r
+  }\r
+\r
+  if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+    if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {\r
+      DirectoryEntry  = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];\r
+      TEImageAdjust   = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;\r
+      DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te +\r
+                    Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +\r
+                    TEImageAdjust);\r
+    }\r
+  } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {\r
+    //\r
+    // NOTE: We use Machine field to identify PE32/PE32+, instead of Magic.\r
+    //       It is due to backward-compatibility, for some system might\r
+    //       generate PE32+ image with PE32 Magic.\r
+    //\r
+    switch (Hdr.Pe32->FileHeader.Machine) {\r
+    case EFI_IMAGE_MACHINE_IA32:\r
+      //\r
+      // Assume PE32 image with IA32 Machine field.\r
+      //\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
+      break;\r
+    case EFI_IMAGE_MACHINE_X64:\r
+    case EFI_IMAGE_MACHINE_IA64:\r
+      //\r
+      // Assume PE32+ image with X64 or IA64 Machine field\r
+      //\r
+      Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
+      break;\r
+    default:\r
+      //\r
+      // For unknow Machine field, use Magic in optional Header\r
+      //\r
+      Magic = Hdr.Pe32->OptionalHeader.Magic;\r
+    }\r
+\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      //\r
+      // Use PE32 offset get Debug Directory Entry\r
+      //\r
+      NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;\r
+      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+      DebugEntry     = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);\r
+    } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
+      //\r
+      // Use PE32+ offset get Debug Directory Entry\r
+      //\r
+      NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;\r
+      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
+      DebugEntry     = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);\r
+    }\r
+\r
+    if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
+      DirectoryEntry = NULL;\r
+      DebugEntry = NULL;\r
+    }\r
+  } else {\r
+    return NULL;\r
+  }\r
+\r
+  if (DebugEntry == NULL || DirectoryEntry == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY), DebugEntry++) {\r
+    if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
+      if (DebugEntry->SizeOfData > 0) {\r
+        CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust);\r
+        switch (* (UINT32 *) CodeViewEntryPointer) {\r
+        case CODEVIEW_SIGNATURE_NB10:\r
+          return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));\r
+        case CODEVIEW_SIGNATURE_RSDS:\r
+          return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));\r
+        case CODEVIEW_SIGNATURE_MTOC:\r
+          return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));\r
+        default:\r
+          break;\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
+\r
+/**\r
+  Returns the size of the PE/COFF headers\r
+\r
+  Returns the size of the PE/COFF header specified by Pe32Data.\r
+  If Pe32Data is NULL, then ASSERT().\r
+\r
+  @param  Pe32Data   Pointer to the PE/COFF image that is loaded in system\r
+                     memory.\r
+\r
+  @return Size of PE/COFF header in bytes or zero if not a valid image.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PeCoffGetSizeOfHeaders (\r
+  IN VOID     *Pe32Data\r
+  )\r
+{\r
+  EFI_IMAGE_DOS_HEADER                  *DosHdr;\r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
+  UINTN                                 SizeOfHeaders;\r
+\r
+  ASSERT (Pe32Data   != NULL);\r
\r
+  DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;\r
+  if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+    //\r
+    // DOS image header is present, so read the PE header after the DOS image header.\r
+    //\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));\r
+  } else {\r
+    //\r
+    // DOS image header is not present, so PE header is at the image base.\r
+    //\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;\r
+  }\r
+\r
+  if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+    SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;\r
+  } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {\r
+    SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders;\r
+  } else {\r
+    SizeOfHeaders = 0;\r
+  }\r
+\r
+  return SizeOfHeaders;\r
+}\r
+\r
diff --git a/EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.inf b/EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.inf
new file mode 100644 (file)
index 0000000..9cd1fbb
--- /dev/null
@@ -0,0 +1,49 @@
+## @file\r
+# Component description file for the EdkNt32PeiPeCoffGetEntryPointLib library.\r
+#\r
+# PeCoffGetEntryPointLib library class for NT32 instance implemented by use NTPeiLoadFile PPI.\r
+# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PeiEmuPeCoffGetEntryPointLib\r
+  FILE_GUID                      = 1CBED347-7DE6-BC48-AC68-3758598124D2\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PeCoffGetEntryPointLib \r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  PeiEmuPeCoffGetEntryPointLib.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+  PeiServicesLib\r
+  DebugLib\r
+\r
+\r
+[Ppis]\r
+  gEmuThunkPpiGuid                       # PPI ALWAYS_CONSUMED\r
+\r
diff --git a/EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c b/EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c
new file mode 100644 (file)
index 0000000..aa4e80c
--- /dev/null
@@ -0,0 +1,140 @@
+/** @file\r
+  Serial Port Lib that thunks back to Emulator services to write to StdErr. \r
+  All read functions are stubed out. There is no constructor so this lib can \r
+  be linked with PEI Core.\r
+\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#include <PiPei.h>\r
+#include <Library/SerialPortLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+\r
+#include <Ppi/EmuThunk.h>\r
+#include <Protocol/EmuThunk.h>\r
+\r
+\r
+\r
+/**\r
+  Initialize the serial device hardware.\r
+  \r
+  If no initialization is required, then return RETURN_SUCCESS.\r
+  If the serial device was successfully initialized, then return RETURN_SUCCESS.\r
+  If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.\r
+  \r
+  @retval RETURN_SUCCESS        The serial device was initialized.\r
+  @retval RETURN_DEVICE_ERROR   The serial device could not be initialized.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SerialPortInitialize (\r
+  VOID\r
+  )\r
+{\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Write data from buffer to serial device. \r
\r
+  Writes NumberOfBytes data bytes from Buffer to the serial device.  \r
+  The number of bytes actually written to the serial device is returned.\r
+  If the return value is less than NumberOfBytes, then the write operation failed.\r
+  If Buffer is NULL, then ASSERT(). \r
+  If NumberOfBytes is zero, then return 0.\r
+\r
+  @param  Buffer           The pointer to the data buffer to be written.\r
+  @param  NumberOfBytes    The number of bytes to written to the serial device.\r
+\r
+  @retval 0                NumberOfBytes is 0.\r
+  @retval >0               The number of bytes written to the serial device.  \r
+                           If this value is less than NumberOfBytes, then the read operation failed.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SerialPortWrite (\r
+  IN UINT8     *Buffer,\r
+  IN UINTN     NumberOfBytes\r
+  )\r
+{\r
+  EMU_THUNK_PPI           *ThunkPpi;\r
+  EFI_STATUS              Status;\r
+  EMU_THUNK_PROTOCOL      *Thunk;\r
+\r
+  //\r
+  // Locate EmuThunkPpi for retrieving standard output handle\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+              &gEmuThunkPpiGuid,\r
+              0,\r
+              NULL,\r
+              (VOID **) &ThunkPpi\r
+             );\r
+  if (!EFI_ERROR (Status)) {\r
+    Thunk  = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();\r
+    return Thunk->WriteStdErr (Buffer, NumberOfBytes);\r
+  }\r
+  \r
+  return 0;\r
+}\r
+\r
+\r
+/**\r
+  Read data from serial device and save the datas in buffer.\r
\r
+  Reads NumberOfBytes data bytes from a serial device into the buffer\r
+  specified by Buffer. The number of bytes actually read is returned. \r
+  If the return value is less than NumberOfBytes, then the rest operation failed.\r
+  If Buffer is NULL, then ASSERT(). \r
+  If NumberOfBytes is zero, then return 0.\r
+\r
+  @param  Buffer           The pointer to the data buffer to store the data read from the serial device.\r
+  @param  NumberOfBytes    The number of bytes which will be read.\r
+\r
+  @retval 0                Read data failed; No data is to be read.\r
+  @retval >0               The actual number of bytes read from serial device.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SerialPortRead (\r
+  OUT UINT8     *Buffer,\r
+  IN  UINTN     NumberOfBytes\r
+  )\r
+{\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Polls a serial device to see if there is any data waiting to be read.\r
+\r
+  Polls a serial device to see if there is any data waiting to be read.\r
+  If there is data waiting to be read from the serial device, then TRUE is returned.\r
+  If there is no data waiting to be read from the serial device, then FALSE is returned.\r
+\r
+  @retval TRUE             Data is waiting to be read from the serial device.\r
+  @retval FALSE            There is no data waiting to be read from the serial device.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+SerialPortPoll (\r
+  VOID\r
+  )\r
+{\r
+  return FALSE;\r
+}\r
+\r
+\r
diff --git a/EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf b/EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf
new file mode 100644 (file)
index 0000000..f45ce49
--- /dev/null
@@ -0,0 +1,45 @@
+## @file\r
+#  Write only instance of Serial Port Library with empty functions.\r
+#\r
+#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PeiEmuSerialPortLibNull\r
+  FILE_GUID                      = E4541241-8897-411a-91F8-7D7E45837146\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = SerialPortLib| PEI_CORE PEIM SEC\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  PeiEmuSerialPortLib.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+  \r
+[LibraryClasses]\r
+  PeiServicesLib\r
+\r
+[Ppis]\r
+  gEmuThunkPpiGuid                       # PPI ALWAYS_CONSUMED\r
+\r
+\r
+  \r
+\r
diff --git a/EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c b/EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
new file mode 100644 (file)
index 0000000..3454660
--- /dev/null
@@ -0,0 +1,136 @@
+/** @file\r
+  PEI Services Table Pointer Library.\r
+  \r
+  This library is used for PEIM which does executed from flash device directly but\r
+  executed in memory.\r
+\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Portiions copyrigth (c) 2011, Apple Inc. All rights reserved. \r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+#include <Ppi/MemoryDiscovered.h>\r
+\r
+\r
+CONST EFI_PEI_SERVICES  **gPeiServices = NULL;\r
+\r
+/**\r
+  Caches a pointer PEI Services Table. \r
\r
+  Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer \r
+  in a CPU specific manner as specified in the CPU binding section of the Platform Initialization \r
+  Pre-EFI Initialization Core Interface Specification. \r
+  \r
+  If PeiServicesTablePointer is NULL, then ASSERT().\r
+  \r
+  @param    PeiServicesTablePointer   The address of PeiServices pointer.\r
+**/\r
+VOID\r
+EFIAPI\r
+SetPeiServicesTablePointer (\r
+  IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r
+  )\r
+{\r
+  ASSERT (PeiServicesTablePointer != NULL);\r
+  ASSERT (*PeiServicesTablePointer != NULL);\r
+  gPeiServices = PeiServicesTablePointer;\r
+}\r
+\r
+/**\r
+  Retrieves the cached value of the PEI Services Table pointer.\r
+\r
+  Returns the cached value of the PEI Services Table pointer in a CPU specific manner \r
+  as specified in the CPU binding section of the Platform Initialization Pre-EFI \r
+  Initialization Core Interface Specification.\r
+  \r
+  If the cached PEI Services Table pointer is NULL, then ASSERT().\r
+\r
+  @return  The pointer to PeiServices.\r
+\r
+**/\r
+CONST EFI_PEI_SERVICES **\r
+EFIAPI\r
+GetPeiServicesTablePointer (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (gPeiServices != NULL);\r
+  ASSERT (*gPeiServices != NULL);\r
+  return gPeiServices;\r
+}\r
+\r
+\r
+\r
+/**\r
+  Notification service to be called when gEmuThunkPpiGuid is installed.\r
+\r
+  @param  PeiServices                 Indirect reference to the PEI Services Table.\r
+  @param  NotifyDescriptor          Address of the notification descriptor data structure. Type\r
+          EFI_PEI_NOTIFY_DESCRIPTOR is defined above.\r
+  @param  Ppi                             Address of the PPI that was installed.\r
+\r
+  @retval   EFI_STATUS                This function will install a PPI to PPI database. The status\r
+                                                  code will be the code for (*PeiServices)->InstallPpi.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesTablePointerNotifyCallback (\r
+  IN EFI_PEI_SERVICES              **PeiServices,\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR     *NotifyDescriptor,\r
+  IN VOID                          *Ppi\r
+  )\r
+{\r
+  gPeiServices = (CONST EFI_PEI_SERVICES  **)PeiServices;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnThunkList = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiPeiMemoryDiscoveredPpiGuid,\r
+  PeiServicesTablePointerNotifyCallback \r
+};\r
+\r
+\r
+/**\r
+  Constructor register notification on when PPI updates. If PPI is \r
+  alreay installed registering the notify will cause the handle to \r
+  run.\r
+\r
+  @param  FileHandle   The handle of FFS header the loaded driver.\r
+  @param  PeiServices  The pointer to the PEI services.\r
+\r
+  @retval EFI_SUCCESS  The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesTablePointerLibConstructor (\r
+  IN EFI_PEI_FILE_HANDLE        FileHandle,\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+\r
+  gPeiServices = (CONST EFI_PEI_SERVICES  **)PeiServices;\r
+\r
+  // register to be told when PeiServices pointer is updated\r
+  Status = (*PeiServices)->NotifyPpi (PeiServices, &mNotifyOnThunkList);\r
+  ASSERT_EFI_ERROR (Status);\r
+  return Status;\r
+}\r
+\r
+\r
diff --git a/EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf b/EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
new file mode 100644 (file)
index 0000000..07f323a
--- /dev/null
@@ -0,0 +1,46 @@
+## @file\r
+# Instance of PEI Services Table Pointer Library using global variable for the table pointer.\r
+#\r
+# PEI Services Table Pointer Library implementation that retrieves a pointer to the\r
+#  PEI Services Table from a global variable. Not available to modules that execute from\r
+#  read-only memory.\r
+#\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmulatorPkgPeiServicesTablePointerLib\r
+  FILE_GUID                      =  5FD8B4ED-D66F-C144-9953-AC557C649925\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PeiServicesTablePointerLib|PEIM\r
+\r
+  CONSTRUCTOR                    = PeiServicesTablePointerLibConstructor\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC (EBC is for build only)\r
+#\r
+\r
+[Sources]\r
+  PeiServicesTablePointer.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+\r
+[Ppis]\r
+  gEfiPeiMemoryDiscoveredPpiGuid\r
+\r
diff --git a/EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c b/EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c
new file mode 100644 (file)
index 0000000..4b4db5c
--- /dev/null
@@ -0,0 +1,75 @@
+/** @file\r
+  PEI Services Table Pointer Library.\r
+  \r
+  Store PEI Services Table pointer via gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage.\r
+  This emulates a platform SRAM. The PI mechaism does not work in the emulator due to\r
+  lack of privledge.\r
+\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Portiions copyrigth (c) 2011, Apple Inc. All rights reserved. \r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/EmuMagicPageLib.h>\r
+\r
+\r
+/**\r
+  Caches a pointer PEI Services Table. \r
\r
+  Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer \r
+  in a CPU specific manner as specified in the CPU binding section of the Platform Initialization \r
+  Pre-EFI Initialization Core Interface Specification. \r
+  \r
+  If PeiServicesTablePointer is NULL, then ASSERT().\r
+  \r
+  @param    PeiServicesTablePointer   The address of PeiServices pointer.\r
+**/\r
+VOID\r
+EFIAPI\r
+SetPeiServicesTablePointer (\r
+  IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r
+  )\r
+{\r
+  ASSERT (PeiServicesTablePointer != NULL);\r
+  ASSERT (*PeiServicesTablePointer != NULL);\r
+  EMU_MAGIC_PAGE()->PeiServicesTablePointer = PeiServicesTablePointer;\r
+}\r
+\r
+/**\r
+  Retrieves the cached value of the PEI Services Table pointer.\r
+\r
+  Returns the cached value of the PEI Services Table pointer in a CPU specific manner \r
+  as specified in the CPU binding section of the Platform Initialization Pre-EFI \r
+  Initialization Core Interface Specification.\r
+  \r
+  If the cached PEI Services Table pointer is NULL, then ASSERT().\r
+\r
+  @return  The pointer to PeiServices.\r
+\r
+**/\r
+CONST EFI_PEI_SERVICES **\r
+EFIAPI\r
+GetPeiServicesTablePointer (\r
+  VOID\r
+  )\r
+{\r
+  CONST EFI_PEI_SERVICES **PeiServicesTablePointer;\r
+  \r
+  PeiServicesTablePointer = EMU_MAGIC_PAGE()->PeiServicesTablePointer;\r
+  ASSERT (PeiServicesTablePointer != NULL);\r
+  ASSERT (*PeiServicesTablePointer != NULL);\r
+  return PeiServicesTablePointer;\r
+}\r
+\r
+\r
+\r
diff --git a/EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointerLibMagicPage.inf b/EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointerLibMagicPage.inf
new file mode 100644 (file)
index 0000000..60c584e
--- /dev/null
@@ -0,0 +1,44 @@
+## @file\r
+#  PEI Services Table Pointer Library.\r
+#  \r
+#  Store PEI Services Table pointer via gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage.\r
+#  This emulates a platform SRAM. The PI mechaism does not work in the emulator due to\r
+#  lack of privledge.\r
+#\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmulatorPkgPeiServicesTablePointerLib\r
+  FILE_GUID                      = 7488FC06-370A-1C41-B05C-7395559A535A\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PeiServicesTablePointerLib|PEIM PEI_CORE SEC\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC (EBC is for build only)\r
+#\r
+\r
+[Sources]\r
+  PeiServicesTablePointer.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+\r
+[Pcd]\r
+  gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage\r
diff --git a/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c b/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c
new file mode 100644 (file)
index 0000000..caf8a7c
--- /dev/null
@@ -0,0 +1,174 @@
+/** @file\r
+  A non-functional instance of the Timer Library.\r
+\r
+  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+#include <Library/TimerLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+\r
+#include <Ppi/EmuThunk.h>\r
+#include <Protocol/EmuThunk.h>\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of microseconds.\r
+\r
+  Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
+\r
+  @param  MicroSeconds  The minimum number of microseconds to delay.\r
+\r
+  @return The value of MicroSeconds inputted.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+MicroSecondDelay (\r
+  IN      UINTN                     MicroSeconds\r
+  )\r
+{\r
+  return NanoSecondDelay (MicroSeconds * 1000);\r
+}\r
+\r
+/**\r
+  Stalls the CPU for at least the given number of nanoseconds.\r
+\r
+  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
+\r
+  @param  NanoSeconds The minimum number of nanoseconds to delay.\r
+\r
+  @return The value of NanoSeconds inputted.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+NanoSecondDelay (\r
+  IN      UINTN                     NanoSeconds\r
+  )\r
+{\r
+  EMU_THUNK_PPI           *ThunkPpi;\r
+  EFI_STATUS              Status;\r
+  EMU_THUNK_PROTOCOL      *Thunk;\r
+\r
+  //\r
+  // Locate EmuThunkPpi for \r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+              &gEmuThunkPpiGuid,\r
+              0,\r
+              NULL,\r
+              (VOID **) &ThunkPpi\r
+             );\r
+  if (!EFI_ERROR (Status)) {   \r
+    Thunk  = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();\r
+    Thunk->Sleep (NanoSeconds * 100);\r
+    return NanoSeconds;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+  The counter can either count up by 1 or count down by 1. If the physical\r
+  performance counter counts by a larger increment, then the counter values\r
+  must be translated. The properties of the counter can be retrieved from\r
+  GetPerformanceCounterProperties().\r
+\r
+  @return The current value of the free running performance counter.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounter (\r
+  VOID\r
+  )\r
+{\r
+  EMU_THUNK_PPI           *ThunkPpi;\r
+  EFI_STATUS              Status;\r
+  EMU_THUNK_PROTOCOL      *Thunk;\r
+\r
+  //\r
+  // Locate EmuThunkPpi for \r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+              &gEmuThunkPpiGuid,\r
+              0,\r
+              NULL,\r
+              (VOID **) &ThunkPpi\r
+             );\r
+  if (!EFI_ERROR (Status)) {   \r
+    Thunk  = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();\r
+    return  Thunk->QueryPerformanceCounter ();\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Retrieves the 64-bit frequency in Hz and the range of performance counter\r
+  values.\r
+\r
+  If StartValue is not NULL, then the value that the performance counter starts\r
+  with immediately after is it rolls over is returned in StartValue. If\r
+  EndValue is not NULL, then the value that the performance counter end with\r
+  immediately before it rolls over is returned in EndValue. The 64-bit\r
+  frequency of the performance counter in Hz is always returned. If StartValue\r
+  is less than EndValue, then the performance counter counts up. If StartValue\r
+  is greater than EndValue, then the performance counter counts down. For\r
+  example, a 64-bit free running counter that counts up would have a StartValue\r
+  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
+  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
+\r
+  @param  StartValue  The value the performance counter starts with when it\r
+                      rolls over.\r
+  @param  EndValue    The value that the performance counter ends with before\r
+                      it rolls over.\r
+\r
+  @return The frequency in Hz.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounterProperties (\r
+  OUT      UINT64                    *StartValue,  OPTIONAL\r
+  OUT      UINT64                    *EndValue     OPTIONAL\r
+  )\r
+{\r
+  EMU_THUNK_PPI           *ThunkPpi;\r
+  EFI_STATUS              Status;\r
+  EMU_THUNK_PROTOCOL      *Thunk;\r
+\r
+  //\r
+  // Locate EmuThunkPpi for \r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+              &gEmuThunkPpiGuid,\r
+              0,\r
+              NULL,\r
+              (VOID **) &ThunkPpi\r
+             );\r
+  if (!EFI_ERROR (Status)) {\r
+    if (StartValue != NULL) {\r
+      *StartValue = 0ULL;\r
+    }\r
+    if (EndValue != NULL) {\r
+      *EndValue = (UINT64)-1LL;\r
+    }\r
+    \r
+    Thunk  = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();\r
+    return  Thunk->QueryPerformanceFrequency ();\r
+  }\r
+\r
+  return 0;\r
+}\r
diff --git a/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.inf b/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.inf
new file mode 100644 (file)
index 0000000..e473b52
--- /dev/null
@@ -0,0 +1,47 @@
+## @file\r
+#  NULL instance of Timer Library as a template.\r
+#\r
+#  A non-functional instance of the Timer Library that can be used as a template\r
+#  for the implementation of a functional timer library instance. This library instance can\r
+#  also be used to test build DXE, Runtime, DXE SAL, and DXE SMM modules that require timer\r
+#  services as well as EBC modules that require timer services.\r
+#\r
+#  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuPeiTimerLib\r
+  FILE_GUID                      = 6ABE5FDC-AE4B-474E-8E52-9546C96AE536\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = TimerLib|PEIM PEI_CORE SEC\r
+\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  PeiTimerLib.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+  PeiServicesLib\r
+\r
+[Ppis]\r
+  gEmuThunkPpiGuid
\ No newline at end of file
diff --git a/EmulatorPkg/Library/SecPeiServicesLib/FwVol.c b/EmulatorPkg/Library/SecPeiServicesLib/FwVol.c
new file mode 100644 (file)
index 0000000..ae4ebfb
--- /dev/null
@@ -0,0 +1,281 @@
+/*++ @file
+  A simple FV stack so the SEC can extract the SEC Core from an
+  FV.
+
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+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 <PiPei.h>
+
+
+#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
+  (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
+
+EFI_FFS_FILE_STATE
+GetFileState (
+  IN UINT8                ErasePolarity,
+  IN EFI_FFS_FILE_HEADER  *FfsHeader
+  )
+/*++
+
+Routine Description:
+  Returns the highest bit set of the State field
+
+Arguments:
+  ErasePolarity   - Erase Polarity  as defined by EFI_FVB2_ERASE_POLARITY
+                    in the Attributes field.
+  FfsHeader       - Pointer to FFS File Header.
+
+Returns:
+  Returns the highest bit in the State field
+
+**/
+{
+  EFI_FFS_FILE_STATE  FileState;
+  EFI_FFS_FILE_STATE  HighestBit;
+
+  FileState = FfsHeader->State;
+
+  if (ErasePolarity != 0) {
+    FileState = (EFI_FFS_FILE_STATE)~FileState;
+  }
+
+  HighestBit = 0x80;
+  while (HighestBit != 0 && (HighestBit & FileState) == 0) {
+    HighestBit >>= 1;
+  }
+
+  return HighestBit;
+}
+
+UINT8
+CalculateHeaderChecksum (
+  IN EFI_FFS_FILE_HEADER  *FileHeader
+  )
+/*++
+
+Routine Description:
+  Calculates the checksum of the header of a file.
+
+Arguments:
+  FileHeader       - Pointer to FFS File Header.
+
+Returns:
+  Checksum of the header.
+  
+**/
+{
+  UINT8 *ptr;
+  UINTN Index;
+  UINT8 Sum;
+
+  Sum = 0;
+  ptr = (UINT8 *) FileHeader;
+
+  for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) {
+    Sum = (UINT8) (Sum + ptr[Index]);
+    Sum = (UINT8) (Sum + ptr[Index + 1]);
+    Sum = (UINT8) (Sum + ptr[Index + 2]);
+    Sum = (UINT8) (Sum + ptr[Index + 3]);
+  }
+
+  for (; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
+    Sum = (UINT8) (Sum + ptr[Index]);
+  }
+  //
+  // State field (since this indicates the different state of file).
+  //
+  Sum = (UINT8) (Sum - FileHeader->State);
+  //
+  // Checksum field of the file is not part of the header checksum.
+  //
+  Sum = (UINT8) (Sum - FileHeader->IntegrityCheck.Checksum.File);
+
+  return Sum;
+}
+
+EFI_STATUS
+SecFfsFindNextFile (
+  IN EFI_FV_FILETYPE             SearchType,
+  IN EFI_PEI_FV_HANDLE           FvHandle,
+  IN OUT EFI_PEI_FILE_HANDLE     *FileHandle
+  )
+/*++
+
+Routine Description:
+    Given the input file pointer, search for the next matching file in the
+    FFS volume as defined by SearchType. The search starts from FileHeader inside
+    the Firmware Volume defined by FwVolHeader.
+
+Arguments:
+    SearchType - Filter to find only files of this type.
+                 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
+    FwVolHeader - Pointer to the FV header of the volume to search.
+                  This parameter must point to a valid FFS volume.
+    FileHeader  - Pointer to the current file from which to begin searching.
+                  This pointer will be updated upon return to reflect the file
+                  found.
+
+Returns:
+    EFI_NOT_FOUND - No files matching the search criteria were found
+    EFI_SUCCESS
+
+**/
+{
+  EFI_FFS_FILE_HEADER *FfsFileHeader;
+  UINT32              FileLength;
+  UINT32              FileOccupiedSize;
+  UINT32              FileOffset;
+  UINT64              FvLength;
+  UINT8               ErasePolarity;
+  UINT8               FileState;
+  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;
+  EFI_FFS_FILE_HEADER         **FileHeader;
+
+  //
+  // Convert the handle of FV to FV header for memory-mapped firmware volume
+  //
+  FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FvHandle;
+  FileHeader  = (EFI_FFS_FILE_HEADER **)FileHandle;
+
+  FvLength = FwVolHeader->FvLength;
+  if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {
+    ErasePolarity = 1;
+  } else {
+    ErasePolarity = 0;
+  }
+  //
+  // If FileHeader is not specified (NULL) start with the first file in the
+  // firmware volume.  Otherwise, start from the FileHeader.
+  //
+  if (*FileHeader == NULL) {
+    FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength);
+  } else {
+    //
+    // Length is 24 bits wide so mask upper 8 bits
+    // FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.
+    //
+    FileLength        = *(UINT32 *) (*FileHeader)->Size & 0x00FFFFFF;
+    FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);
+    FfsFileHeader     = (EFI_FFS_FILE_HEADER *) ((UINT8 *) *FileHeader + FileOccupiedSize);
+  }
+
+  FileOffset = (UINT32) ((UINT8 *) FfsFileHeader - (UINT8 *) FwVolHeader);
+
+  while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
+    //
+    // Get FileState which is the highest bit of the State
+    //
+    FileState = GetFileState (ErasePolarity, FfsFileHeader);
+
+    switch (FileState) {
+
+    case EFI_FILE_HEADER_INVALID:
+      FileOffset += sizeof (EFI_FFS_FILE_HEADER);
+      FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
+      break;
+
+    case EFI_FILE_DATA_VALID:
+    case EFI_FILE_MARKED_FOR_UPDATE:
+      if (CalculateHeaderChecksum (FfsFileHeader) == 0) {
+        FileLength        = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
+        FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);
+
+        if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
+
+          *FileHeader = FfsFileHeader;
+
+          return EFI_SUCCESS;
+        }
+
+        FileOffset += FileOccupiedSize;
+        FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
+      } else {
+        return EFI_NOT_FOUND;
+      }
+      break;
+
+    case EFI_FILE_DELETED:
+      FileLength        = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
+      FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);
+      FileOffset += FileOccupiedSize;
+      FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
+      break;
+
+    default:
+      return EFI_NOT_FOUND;
+
+    }
+  }
+
+  return EFI_NOT_FOUND;
+}
+
+EFI_STATUS
+SecFfsFindSectionData (
+  IN EFI_SECTION_TYPE      SectionType,
+  IN EFI_FFS_FILE_HEADER   *FfsFileHeader,
+  IN OUT VOID              **SectionData
+  )
+/*++
+
+Routine Description:
+    Given the input file pointer, search for the next matching section in the
+    FFS volume.
+
+Arguments:
+    SearchType    - Filter to find only sections of this type.
+    FfsFileHeader - Pointer to the current file to search.
+    SectionData   - Pointer to the Section matching SectionType in FfsFileHeader.
+                     NULL if section not found
+
+Returns:
+    EFI_NOT_FOUND - No files matching the search criteria were found
+    EFI_SUCCESS
+
+**/
+{
+  UINT32                    FileSize;
+  EFI_COMMON_SECTION_HEADER *Section;
+  UINT32                    SectionLength;
+  UINT32                    ParsedLength;
+
+  //
+  // Size is 24 bits wide so mask upper 8 bits.
+  //    Does not include FfsFileHeader header size
+  // FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
+  //
+  Section   = (EFI_COMMON_SECTION_HEADER *) (FfsFileHeader + 1);
+  FileSize  = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
+  FileSize -= sizeof (EFI_FFS_FILE_HEADER);
+
+  *SectionData  = NULL;
+  ParsedLength  = 0;
+  while (ParsedLength < FileSize) {
+    if (Section->Type == SectionType) {
+      *SectionData = (VOID *) (Section + 1);
+      return EFI_SUCCESS;
+    }
+    //
+    // Size is 24 bits wide so mask upper 8 bits.
+    // SectionLength is adjusted it is 4 byte aligned.
+    // Go to the next section
+    //
+    SectionLength = *(UINT32 *) Section->Size & 0x00FFFFFF;
+    SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
+
+    ParsedLength += SectionLength;
+    Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + SectionLength);
+  }
+
+  return EFI_NOT_FOUND;
+}
+
diff --git a/EmulatorPkg/Library/SecPeiServicesLib/PeiServicesLib.c b/EmulatorPkg/Library/SecPeiServicesLib/PeiServicesLib.c
new file mode 100644 (file)
index 0000000..bdbf687
--- /dev/null
@@ -0,0 +1,567 @@
+/** @file\r
+  Implementation for PEI Services Library.\r
+\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#include <PiPei.h>\r
+#include <Library/EmuMagicPageLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+\r
+\r
+EFI_STATUS\r
+SecFfsFindNextFile (\r
+  IN EFI_FV_FILETYPE            SearchType,\r
+  IN EFI_PEI_FV_HANDLE          VolumeHandle,\r
+  IN OUT EFI_PEI_FILE_HANDLE    *FileHandle\r
+  );\r
+\r
+EFI_STATUS\r
+SecFfsFindSectionData (\r
+  IN EFI_SECTION_TYPE           SectionType,\r
+  IN EFI_PEI_FILE_HANDLE        FileHandle,\r
+  OUT VOID                      **SectionData\r
+  );\r
+\r
+\r
+/**\r
+  This service enables a given PEIM to register an interface into the PEI Foundation.\r
+\r
+  @param  PpiList               A pointer to the list of interfaces that the caller shall install.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully installed.\r
+  @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.\r
+  @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
+                                EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesInstallPpi (\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR     *PpiList\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to replace an entry in the PPI database with an alternate entry.\r
+\r
+  @param  OldPpi                The pointer to the old PEI PPI Descriptors.\r
+  @param  NewPpi                The pointer to the new PEI PPI Descriptors.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully installed.\r
+  @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.\r
+  @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
+                                EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
+  @retval EFI_NOT_FOUND         The PPI for which the reinstallation was requested has not been\r
+                                installed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesReInstallPpi (\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR     *OldPpi,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR     *NewPpi\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to discover a given instance of an interface.\r
+\r
+  So this is, well a hack, so we can reuse the same libraries as the PEI Core \r
+  for XIP modules.... \r
+\r
+  @param  Guid                  A pointer to the GUID whose corresponding interface needs to be\r
+                                found.\r
+  @param  Instance              The N-th instance of the interface that is required.\r
+  @param  PpiDescriptor         A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.\r
+  @param  Ppi                   A pointer to the instance of the interface.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully returned.\r
+  @retval EFI_NOT_FOUND         The PPI descriptor is not found in the database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesLocatePpi (\r
+  IN CONST EFI_GUID             *Guid,\r
+  IN UINTN                      Instance,\r
+  IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
+  IN OUT VOID                   **Ppi\r
+  )\r
+{\r
+  EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
+   \r
+  if (Instance != 0) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  \r
+  for (PpiList = EMU_MAGIC_PAGE()->PpiList; ; PpiList++) {\r
+    if (CompareGuid (PpiList->Guid, Guid)) {\r
+      if (PpiDescriptor != NULL) {\r
+        *PpiDescriptor = PpiList;\r
+      }\r
+      if (Ppi != NULL) {\r
+        *Ppi = PpiList->Ppi;\r
+      }\r
+      return EFI_SUCCESS;\r
+    }\r
+    \r
+    if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r
+      break;\r
+    }\r
+  } \r
+  \r
+  \r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to register a given service to be invoked when another service is\r
+  installed or reinstalled.\r
+\r
+  @param  NotifyList            A pointer to the list of notification interfaces \r
+                                that the caller shall install.\r
+\r
+  @retval EFI_SUCCESS           The interface was successfully installed.\r
+  @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.\r
+  @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do\r
+                                 not have the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES\r
+                                 bit set in the Flags field.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesNotifyPpi (\r
+  IN CONST EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyList\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to ascertain the present value of the boot mode.\r
+\r
+  @param  BootMode              A pointer to contain the value of the boot mode.\r
+\r
+  @retval EFI_SUCCESS           The boot mode was returned successfully.\r
+  @retval EFI_INVALID_PARAMETER BootMode is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesGetBootMode (\r
+  OUT EFI_BOOT_MODE          *BootMode\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to update the boot mode variable.\r
+\r
+  @param  BootMode              The value of the boot mode to set.\r
+\r
+  @retval EFI_SUCCESS           The value was successfully updated\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesSetBootMode (\r
+  IN EFI_BOOT_MODE              BootMode\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables a PEIM to ascertain the address of the list of HOBs in memory.\r
+\r
+  @param  HobList               A pointer to the list of HOBs that the PEI Foundation \r
+                                will initialize.\r
+  \r
+  @retval EFI_SUCCESS           The list was successfully returned.\r
+  @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesGetHobList (\r
+  OUT VOID                      **HobList\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to create various types of HOBs.\r
+\r
+  @param  Type                  The type of HOB to be installed.\r
+  @param  Length                The length of the HOB to be added.\r
+  @param  Hob                   The address of a pointer that will contain the \r
+                                HOB header.\r
+\r
+  @retval EFI_SUCCESS           The HOB was successfully created.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space for HOB creation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesCreateHob (\r
+  IN UINT16                     Type,\r
+  IN UINT16                     Length,\r
+  OUT VOID                      **Hob\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to discover additional firmware volumes.\r
+\r
+  @param  Instance              This instance of the firmware volume to find.  The \r
+                                value 0 is the Boot Firmware Volume (BFV).\r
+  @param  VolumeHandle          Handle of the firmware volume header of the volume\r
+                                to return.\r
+\r
+  @retval EFI_SUCCESS           The volume was found.\r
+  @retval EFI_NOT_FOUND         The volume was not found.\r
+  @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindNextVolume (\r
+  IN UINTN                          Instance,\r
+  IN OUT EFI_PEI_FV_HANDLE          *VolumeHandle\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to discover additional firmware files.\r
+\r
+  @param  SearchType            A filter to find files only of this type.\r
+  @param  VolumeHandle          The pointer to the firmware volume header of the \r
+                                volume to search. This parameter must point to a \r
+                                valid FFS volume. \r
+  @param  FileHandle            Handle of the current file from which to begin searching.\r
+\r
+  @retval EFI_SUCCESS           The file was found.\r
+  @retval EFI_NOT_FOUND         The file was not found.\r
+  @retval EFI_NOT_FOUND         The header checksum was not zero.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindNextFile (\r
+  IN EFI_FV_FILETYPE            SearchType,\r
+  IN EFI_PEI_FV_HANDLE          VolumeHandle,\r
+  IN OUT EFI_PEI_FILE_HANDLE    *FileHandle\r
+  )\r
+{\r
+  return SecFfsFindNextFile (SearchType, VolumeHandle, FileHandle);\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to discover sections of a given type within a valid FFS file.\r
+\r
+  @param  SectionType           The value of the section type to find.\r
+  @param  FileHandle            A pointer to the file header that contains the set \r
+                                of sections to be searched.\r
+  @param  SectionData           A pointer to the discovered section, if successful.\r
+\r
+  @retval EFI_SUCCESS           The section was found.\r
+  @retval EFI_NOT_FOUND         The section was not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindSectionData (\r
+  IN EFI_SECTION_TYPE           SectionType,\r
+  IN EFI_PEI_FILE_HANDLE        FileHandle,\r
+  OUT VOID                      **SectionData\r
+  )\r
+{\r
+  return SecFfsFindSectionData (SectionType, FileHandle, SectionData);\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to register the permanent memory configuration\r
+  that has been initialized with the PEI Foundation.\r
+\r
+  @param  MemoryBegin           The value of a region of installed memory.\r
+  @param  MemoryLength          The corresponding length of a region of installed memory.\r
+\r
+  @retval EFI_SUCCESS           The region was successfully installed in a HOB.\r
+  @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no additional space for HOB creation.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesInstallPeiMemory (\r
+  IN EFI_PHYSICAL_ADDRESS       MemoryBegin,\r
+  IN UINT64                     MemoryLength\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service enables PEIMs to allocate memory after the permanent memory has been\r
+   installed by a PEIM.\r
+\r
+  @param  MemoryType            Type of memory to allocate.\r
+  @param  Pages                 The number of pages to allocate.\r
+  @param  Memory                Pointer of memory allocated.\r
+\r
+  @retval EFI_SUCCESS           The memory range was successfully allocated.\r
+  @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.\r
+  @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.\r
+  @retval EFI_OUT_OF_RESOURCES  The pages could not be allocated.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesAllocatePages (\r
+  IN EFI_MEMORY_TYPE            MemoryType,\r
+  IN UINTN                      Pages,\r
+  OUT EFI_PHYSICAL_ADDRESS      *Memory\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service allocates memory from the Hand-Off Block (HOB) heap.\r
+\r
+  @param  Size                  The number of bytes to allocate from the pool.\r
+  @param  Buffer                If the call succeeds, a pointer to a pointer to \r
+                                the allocate buffer; otherwise, undefined.\r
+\r
+  @retval EFI_SUCCESS           The allocation was successful\r
+  @retval EFI_OUT_OF_RESOURCES  There is not enough heap to allocate the requested size.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesAllocatePool (\r
+  IN UINTN                      Size,\r
+  OUT VOID                      **Buffer\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  Resets the entire platform.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesResetSystem (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service is a wrapper for the PEI Service RegisterForShadow(), except the \r
+  pointer to the PEI Services Table has been removed.  See the Platform \r
+  Initialization Pre-EFI Initialization Core Interface Specification for details. \r
+\r
+  @param FileHandle             PEIM's file handle. Must be the currently\r
+                                executing PEIM.\r
+  \r
+  @retval EFI_SUCCESS           The PEIM was successfully registered for\r
+                                shadowing.\r
+\r
+  @retval EFI_ALREADY_STARTED   The PEIM was previously\r
+                                registered for shadowing.\r
+\r
+  @retval EFI_NOT_FOUND         The FileHandle does not refer to a\r
+                                valid file handle.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesRegisterForShadow (\r
+  IN  EFI_PEI_FILE_HANDLE FileHandle\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services \r
+  Table has been removed.  See the Platform Initialization Pre-EFI Initialization Core Interface \r
+  Specification for details. \r
+\r
+  @param FileHandle              The handle of the file.\r
+\r
+  @param FileInfo                 Upon exit, points to the file's\r
+                                  information.\r
+\r
+  @retval EFI_SUCCESS             File information returned.\r
+  \r
+  @retval EFI_INVALID_PARAMETER   If FileHandle does not\r
+                                  represent a valid file.\r
+  \r
+  @retval EFI_INVALID_PARAMETER   FileInfo is NULL.\r
+  \r
+**/\r
+EFI_STATUS\r
+EFIAPI \r
+PeiServicesFfsGetFileInfo (\r
+  IN CONST  EFI_PEI_FILE_HANDLE   FileHandle,\r
+  OUT EFI_FV_FILE_INFO            *FileInfo\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services \r
+  Table has been removed.  See the Platform Initialization Pre-EFI Initialization Core Interface \r
+  Specification for details. \r
+\r
+  @param FileName                 A pointer to the name of the file to\r
+                                  find within the firmware volume.\r
+\r
+  @param VolumeHandle             The firmware volume to search FileHandle\r
+                                  Upon exit, points to the found file's\r
+                                  handle or NULL if it could not be found.\r
+  @param FileHandle               The pointer to found file handle \r
+\r
+  @retval EFI_SUCCESS             File was found.\r
+\r
+  @retval EFI_NOT_FOUND           File was not found.\r
+\r
+  @retval EFI_INVALID_PARAMETER   VolumeHandle or FileHandle or\r
+                                  FileName was NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsFindFileByName (\r
+  IN CONST  EFI_GUID            *FileName,\r
+  IN CONST  EFI_PEI_FV_HANDLE   VolumeHandle,\r
+  OUT       EFI_PEI_FILE_HANDLE *FileHandle\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+\r
+/**\r
+  This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services \r
+  Table has been removed.  See the Platform Initialization Pre-EFI Initialization Core Interface \r
+  Specification for details. \r
+\r
+  @param VolumeHandle             Handle of the volume.\r
+\r
+  @param VolumeInfo               Upon exit, points to the volume's\r
+                                  information.\r
+\r
+  @retval EFI_SUCCESS             File information returned.\r
+  \r
+  @retval EFI_INVALID_PARAMETER   If FileHandle does not\r
+                                  represent a valid file.\r
+  \r
+  @retval EFI_INVALID_PARAMETER   If FileInfo is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiServicesFfsGetVolumeInfo (\r
+  IN  EFI_PEI_FV_HANDLE       VolumeHandle,\r
+  OUT EFI_FV_INFO             *VolumeInfo\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+/**\r
+  Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.\r
+  \r
+  This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using \r
+  the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.\r
+  If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().\r
+  If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().\r
+\r
+  \r
+  @param  FvFormat             Unique identifier of the format of the memory-mapped \r
+                               firmware volume.  This parameter is optional and \r
+                               may be NULL.  If NULL is specified, the \r
+                               EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r
+  @param  FvInfo               Points to a buffer which allows the \r
+                               EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume. \r
+                               The format of this buffer is specific to the FvFormat. \r
+                               For memory-mapped firmware volumes, this typically \r
+                               points to the first byte of the firmware volume.\r
+  @param  FvInfoSize           The size, in bytes, of FvInfo. For memory-mapped \r
+                               firmware volumes, this is typically the size of \r
+                               the firmware volume.\r
+  @param  ParentFvName         If the new firmware volume originated from a file \r
+                               in a different firmware volume, then this parameter \r
+                               specifies the GUID name of the originating firmware\r
+                               volume. Otherwise, this parameter must be NULL.\r
+  @param  ParentFileName       If the new firmware volume originated from a file \r
+                               in a different firmware volume, then this parameter \r
+                               specifies the GUID file name of the originating \r
+                               firmware file. Otherwise, this parameter must be NULL.\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiServicesInstallFvInfoPpi (\r
+  IN CONST EFI_GUID                *FvFormat, OPTIONAL\r
+  IN CONST VOID                    *FvInfo,\r
+  IN       UINT32                  FvInfoSize,\r
+  IN CONST EFI_GUID                *ParentFvName, OPTIONAL\r
+  IN CONST EFI_GUID                *ParentFileName OPTIONAL\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return;\r
+}\r
+\r
diff --git a/EmulatorPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf b/EmulatorPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf
new file mode 100644 (file)
index 0000000..fdf8acc
--- /dev/null
@@ -0,0 +1,49 @@
+## @file\r
+# PEI Services Library implementation.\r
+#\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = SecPeiServicesLib\r
+  FILE_GUID                      = E3E4A441-8465-0F41-8AF4-F67EBE984099\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PeiServicesLib|SEC PEIM PEI_CORE \r
+  PI_SPECIFICATION_VERSION       = 0x0001000A\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC (EBC is for build only)\r
+#\r
+\r
+[Sources]\r
+  PeiServicesLib.c\r
+  FwVol.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+  BaseMemoryLib\r
+  PpiListLib\r
+\r
+[Pcd]\r
+  gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage\r
+\r
+\r
+\r
+\r
+\r
diff --git a/EmulatorPkg/Library/SecPpiListLib/PpiListLib.c b/EmulatorPkg/Library/SecPpiListLib/PpiListLib.c
new file mode 100644 (file)
index 0000000..42c0d97
--- /dev/null
@@ -0,0 +1,17 @@
+/*++ @file
+
+Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
+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 <PiPei.h>
+
+CONST EFI_PEI_PPI_DESCRIPTOR  *gPpiList = NULL;
+
diff --git a/EmulatorPkg/Library/SecPpiListLib/SecPpiListLib.inf b/EmulatorPkg/Library/SecPpiListLib/SecPpiListLib.inf
new file mode 100644 (file)
index 0000000..e4b4967
--- /dev/null
@@ -0,0 +1,31 @@
+## @file\r
+# Place thunk PPI in HOB.\r
+#\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = SecPpiListLib\r
+  FILE_GUID                      = F950E820-0457-8143-86AD-30E4A45FD4BF\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PpiListLib|SEC BASE USER_DEFINED\r
+\r
+[Sources]\r
+  PpiListLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
diff --git a/EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.c b/EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.c
new file mode 100644 (file)
index 0000000..3c2fd93
--- /dev/null
@@ -0,0 +1,76 @@
+/** @file\r
+  Emulator Thunk to abstract OS services from pure EFI code\r
+\r
+  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
+  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+  \r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+\r
+\r
+UINTN                   gThunkPpiListSize = 0;\r
+EFI_PEI_PPI_DESCRIPTOR  *gThunkPpiList = NULL;\r
+\r
+\r
+\r
+EFI_PEI_PPI_DESCRIPTOR *\r
+GetThunkPpiList (\r
+  VOID\r
+  )\r
+{\r
+  UINTN Index;\r
+  \r
+  if (gThunkPpiList == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR)) - 1;\r
+  gThunkPpiList[Index].Flags |= EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r
+  \r
+  return gThunkPpiList;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+AddThunkPpi (\r
+  IN  UINTN     Flags,\r
+  IN  EFI_GUID  *Guid,\r
+  IN  VOID      *Ppi\r
+  )\r
+{\r
+  UINTN Index;\r
+\r
+  gThunkPpiList = ReallocatePool (\r
+                    gThunkPpiListSize,\r
+                    gThunkPpiListSize + sizeof (EFI_PEI_PPI_DESCRIPTOR),\r
+                    gThunkPpiList\r
+                    );\r
+  if (gThunkPpiList == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  \r
+  Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR));\r
+  gThunkPpiList[Index].Flags = Flags;\r
+  gThunkPpiList[Index].Guid  = Guid;\r
+  gThunkPpiList[Index].Ppi   = Ppi;\r
+  gThunkPpiListSize += sizeof (EFI_PEI_PPI_DESCRIPTOR);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+\r
+\r
diff --git a/EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.inf b/EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.inf
new file mode 100644 (file)
index 0000000..54f53ab
--- /dev/null
@@ -0,0 +1,38 @@
+## @file\r
+# Place thunk PPI in HOB.\r
+#\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = ThunkPpiList\r
+  FILE_GUID                      = 465FDE84-E8B0-B04B-A843-A03F68F617A9\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = MemoryAllocationLib|SEC BASE USER_DEFINED\r
+\r
+[Sources]\r
+  ThunkPpiList.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  BaseMemoryLib\r
+\r
+[BuildOptions]\r
+   XCODE:*_*_*_DLINK_PATH == gcc\r
+\r
diff --git a/EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.c b/EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.c
new file mode 100644 (file)
index 0000000..5aed594
--- /dev/null
@@ -0,0 +1,138 @@
+/** @file\r
+  Emulator Thunk to abstract OS services from pure EFI code\r
+\r
+  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
+  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+  \r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Uefi.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+\r
+#include <Protocol/EmuIoThunk.h>\r
+\r
+\r
+#define EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('E','m','u','T')\r
+\r
+typedef struct {\r
+  UINTN                 Signature;\r
+  EMU_IO_THUNK_PROTOCOL Data;\r
+  BOOLEAN               EmuBusDriver;\r
+  LIST_ENTRY            Link;\r
+} EMU_IO_THUNK_PROTOCOL_DATA;\r
+\r
+LIST_ENTRY  mThunkList = INITIALIZE_LIST_HEAD_VARIABLE (mThunkList);\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+AddThunkProtocol (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *ThunkIo,  \r
+  IN  CHAR16                  *ConfigString,\r
+  IN  BOOLEAN                 EmuBusDriver\r
+  )\r
+{\r
+  CHAR16                      *StartString;\r
+  CHAR16                      *SubString;\r
+  UINTN                       Instance;\r
+  EMU_IO_THUNK_PROTOCOL_DATA  *Private;\r
+  \r
+  if (ThunkIo == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  Instance = 0;\r
+  StartString = AllocatePool (StrSize (ConfigString));\r
+  StrCpy (StartString, ConfigString);\r
+  while (*StartString != '\0') {\r
+\r
+    //\r
+    // Find the end of the sub string\r
+    //\r
+    SubString = StartString;\r
+    while (*SubString != '\0' && *SubString != '!') {\r
+      SubString++;\r
+    }\r
+\r
+    if (*SubString == '!') {\r
+      //\r
+      // Replace token with '\0' to make sub strings. If this is the end\r
+      //  of the string SubString will already point to NULL.\r
+      //\r
+      *SubString = '\0';\r
+      SubString++;\r
+    }\r
+\r
+    Private = AllocatePool (sizeof (EMU_IO_THUNK_PROTOCOL_DATA));\r
+    if (Private == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+    Private->Signature          = EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE;\r
+    Private->EmuBusDriver       = EmuBusDriver;\r
+\r
+    CopyMem (&Private->Data, ThunkIo, sizeof (EMU_IO_THUNK_PROTOCOL));    \r
+    Private->Data.Instance      = Instance++;\r
+    Private->Data.ConfigString  = StartString;\r
+    \r
+    InsertTailList (&mThunkList, &Private->Link);\r
+\r
+    //\r
+    // Parse Next sub string. This will point to '\0' if we are at the end.\r
+    //\r
+    StartString = SubString;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GetNextThunkProtocol (\r
+  IN  BOOLEAN                 EmuBusDriver,\r
+  OUT EMU_IO_THUNK_PROTOCOL   **Instance  OPTIONAL\r
+  )\r
+{\r
+  LIST_ENTRY                   *Link; \r
+  EMU_IO_THUNK_PROTOCOL_DATA   *Private; \r
+  \r
+  if (mThunkList.ForwardLink == &mThunkList) {\r
+    // Skip parsing an empty list\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  \r
+  for (Link = mThunkList.ForwardLink; Link != &mThunkList; Link = Link->ForwardLink) {\r
+    Private = CR (Link, EMU_IO_THUNK_PROTOCOL_DATA, Link, EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE);\r
+    if (EmuBusDriver & !Private->EmuBusDriver) {\r
+      continue;\r
+    } else if (*Instance == NULL) {\r
+      // Find 1st match in list\r
+      *Instance = &Private->Data;\r
+      return EFI_SUCCESS;\r
+    } else if (*Instance == &Private->Data) {\r
+      // Matched previous call so look for valid next entry\r
+      Link = Link->ForwardLink;\r
+      if (Link == &mThunkList) {\r
+        return EFI_NOT_FOUND;\r
+      }\r
+      Private = CR (Link, EMU_IO_THUNK_PROTOCOL_DATA, Link, EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE);\r
+      *Instance = &Private->Data;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+   \r
+   \r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
diff --git a/EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.inf b/EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.inf
new file mode 100644 (file)
index 0000000..0666883
--- /dev/null
@@ -0,0 +1,36 @@
+## @file\r
+#\r
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = ThunkProtocolList\r
+  FILE_GUID                      = 7833616E-AE0D-594F-870C-80E68682D587\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = MemoryAllocationLib|BASE SEC USER_DEFINED\r
+\r
+[Sources]\r
+  ThunkProtocolList.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  BaseMemoryLib\r
+\r
+\r
+\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturer.uni b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturer.uni
new file mode 100644 (file)
index 0000000..669654e
Binary files /dev/null and b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturer.uni differ
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerData.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerData.c
new file mode 100644 (file)
index 0000000..52d1204
--- /dev/null
@@ -0,0 +1,57 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscBaseBoardManufacturerData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_BASE_BOARD_MANUFACTURER_DATA, MiscBaseBoardManufacturer) = {\r
+  STRING_TOKEN(STR_MISC_BASE_BOARD_MANUFACTURER),\r
+  STRING_TOKEN(STR_MISC_BASE_BOARD_PRODUCT_NAME),\r
+  STRING_TOKEN(STR_MISC_BASE_BOARD_VERSION),\r
+  STRING_TOKEN(STR_MISC_BASE_BOARD_SERIAL_NUMBER),\r
+  STRING_TOKEN(STR_MISC_BASE_BOARD_ASSET_TAG),\r
+  STRING_TOKEN(STR_MISC_BASE_BOARD_CHASSIS_LOCATION),\r
+  {                         // BaseBoardFeatureFlags\r
+    1,                      // Motherboard\r
+    0,                      // RequiresDaughterCard\r
+    0,                      // Removable\r
+    1,                      // Replaceable,\r
+    0,                      // HotSwappable\r
+    0,                      // Reserved\r
+  },\r
+  EfiBaseBoardTypeUnknown,  // BaseBoardType\r
+  {                         // BaseBoardChassisLink\r
+    EFI_MISC_SUBCLASS_GUID, // ProducerName\r
+    1,                      // Instance\r
+    1,                      // SubInstance\r
+  },\r
+  0,                        // BaseBoardNumberLinks\r
+  {                         // LinkN\r
+    EFI_MISC_SUBCLASS_GUID, // ProducerName\r
+    1,                      // Instance\r
+    1,                      // SubInstance\r
+  },\r
+};\r
+\r
+/* eof - MiscBaseBoardManufacturerData.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
new file mode 100644 (file)
index 0000000..04f5a1e
--- /dev/null
@@ -0,0 +1,167 @@
+/** @file\r
+  BaseBoard manufacturer information boot time changes.\r
+  SMBIOS type 2.\r
+\r
+  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+/**\r
+  This function makes boot time changes to the contents of the\r
+  MiscBaseBoardManufacturer (Type 2).\r
+\r
+  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
+\r
+  @retval EFI_SUCCESS                All parameters were valid.\r
+  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
+  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
+\r
+**/\r
+MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)\r
+{\r
+  CHAR8                           *OptionalStrStart;\r
+  UINTN                           ManuStrLen;\r
+  UINTN                           ProductStrLen;\r
+  UINTN                           VerStrLen;\r
+  UINTN                           AssertTagStrLen;\r
+  UINTN                           SerialNumStrLen;\r
+  UINTN                           ChassisStrLen;\r
+  EFI_STATUS                      Status;\r
+  EFI_STRING                      Manufacturer;\r
+  EFI_STRING                      Product;\r
+  EFI_STRING                      Version;\r
+  EFI_STRING                      SerialNumber;\r
+  EFI_STRING                      AssertTag;\r
+  EFI_STRING                      Chassis;\r
+  STRING_REF                      TokenToGet;\r
+  EFI_SMBIOS_HANDLE               SmbiosHandle;\r
+  SMBIOS_TABLE_TYPE2              *SmbiosRecord;\r
+  EFI_MISC_BASE_BOARD_MANUFACTURER   *ForType2InputData;\r
+\r
+  ForType2InputData = (EFI_MISC_BASE_BOARD_MANUFACTURER *)RecordData;\r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (RecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER);\r
+  Manufacturer = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  ManuStrLen = StrLen(Manufacturer);\r
+  if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME);\r
+  Product = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  ProductStrLen = StrLen(Product);\r
+  if (ProductStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION);\r
+  Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  VerStrLen = StrLen(Version);\r
+  if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_SERIAL_NUMBER);\r
+  SerialNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  SerialNumStrLen = StrLen(SerialNumber);\r
+  if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG);\r
+  AssertTag = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  AssertTagStrLen = StrLen(AssertTag);\r
+  if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION);\r
+  Chassis = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  ChassisStrLen = StrLen(Chassis);\r
+  if (ChassisStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+\r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);\r
+  //\r
+  // Make handle chosen by smbios protocol.add automatically.\r
+  //\r
+  SmbiosRecord->Hdr.Handle = 0;  \r
+  //\r
+  // Manu will be the 1st optional string following the formatted structure.\r
+  // \r
+  SmbiosRecord->Manufacturer = 1;  \r
+  //\r
+  // ProductName will be the 2st optional string following the formatted structure.\r
+  // \r
+  SmbiosRecord->ProductName  = 2;  \r
+  //\r
+  // Version will be the 3rd optional string following the formatted structure.\r
+  //\r
+  SmbiosRecord->Version = 3;  \r
+  //\r
+  // SerialNumber will be the 4th optional string following the formatted structure.\r
+  //\r
+  SmbiosRecord->SerialNumber = 4;  \r
+  //\r
+  // AssertTag will be the 5th optional string following the formatted structure.\r
+  //\r
+  SmbiosRecord->AssetTag = 5;  \r
+\r
+  //\r
+  // LocationInChassis will be the 6th optional string following the formatted structure.\r
+  //\r
+  SmbiosRecord->LocationInChassis = 6;  \r
+  SmbiosRecord->FeatureFlag = (*(BASE_BOARD_FEATURE_FLAGS*)&(ForType2InputData->BaseBoardFeatureFlags));\r
+  SmbiosRecord->ChassisHandle  = 0;\r
+  SmbiosRecord->BoardType      = (UINT8)ForType2InputData->BaseBoardType;\r
+  SmbiosRecord->NumberOfContainedObjectHandles = 0;\r
+  \r
+  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
+  //\r
+  // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string\r
+  //\r
+  OptionalStrStart -= 2;\r
+  UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);\r
+  UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);\r
+  UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);\r
+  UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1);\r
+  UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);\r
+  UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1);\r
+  //\r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  SmbiosHandle = 0;\r
+  Status = Smbios-> Add(\r
+                      Smbios, \r
+                      NULL,\r
+                      &SmbiosHandle, \r
+                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
+                      );\r
+\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendor.uni b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendor.uni
new file mode 100644 (file)
index 0000000..dda02d2
Binary files /dev/null and b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendor.uni differ
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendorData.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendorData.c
new file mode 100644 (file)
index 0000000..b9a8ced
--- /dev/null
@@ -0,0 +1,88 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscBiosVendorData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_BIOS_VENDOR_DATA, MiscBiosVendor) = {\r
+  STRING_TOKEN(STR_MISC_BIOS_VENDOR),       // BiosVendor\r
+  STRING_TOKEN(STR_MISC_BIOS_VERSION),      // BiosVersion\r
+  STRING_TOKEN(STR_MISC_BIOS_RELEASE_DATE), // BiosReleaseDate\r
+  0xBABE, // BiosStartingAddress\r
+  {       // BiosPhysicalDeviceSize\r
+    2,    // Value\r
+    3,    // Exponent\r
+  },\r
+  {       // BiosCharacteristics1\r
+    0,    // Reserved1                         :2\r
+    0,    // Unknown                           :1\r
+    1,    // BiosCharacteristicsNotSupported   :1\r
+    0,    // IsaIsSupported                    :1\r
+    0,    // McaIsSupported                    :1\r
+    0,    // EisaIsSupported                   :1\r
+    0,    // PciIsSupported                    :1\r
+    0,    // PcmciaIsSupported                 :1\r
+    0,    // PlugAndPlayIsSupported            :1\r
+    0,    // ApmIsSupported                    :1\r
+    0,    // BiosIsUpgradable                  :1\r
+    0,    // BiosShadowingAllowed              :1\r
+    0,    // VlVesaIsSupported                 :1\r
+    0,    // EscdSupportIsAvailable            :1\r
+    0,    // BootFromCdIsSupported             :1\r
+    0,    // SelectableBootIsSupported         :1\r
+    0,    // RomBiosIsSocketed                 :1\r
+    0,    // BootFromPcmciaIsSupported         :1\r
+    0,    // EDDSpecificationIsSupported       :1\r
+    0,    // JapaneseNecFloppyIsSupported      :1\r
+    0,    // JapaneseToshibaFloppyIsSupported  :1\r
+    0,    // Floppy525_360IsSupported          :1\r
+    0,    // Floppy525_12IsSupported           :1\r
+    0,    // Floppy35_720IsSupported           :1\r
+    0,    // Floppy35_288IsSupported           :1\r
+    0,    // PrintScreenIsSupported            :1\r
+    0,    // Keyboard8042IsSupported           :1\r
+    0,    // SerialIsSupported                 :1\r
+    0,    // PrinterIsSupported                :1\r
+    0,    // CgaMonoIsSupported                :1\r
+    0,    // NecPc98                           :1\r
+    0,    // AcpiIsSupported                   :1\r
+    0,    // UsbLegacyIsSupported              :1\r
+    0,    // AgpIsSupported                    :1\r
+    0,    // I20BootIsSupported                :1\r
+    0,    // Ls120BootIsSupported              :1\r
+    0,    // AtapiZipDriveBootIsSupported      :1\r
+    0,    // Boot1394IsSupported               :1\r
+    0,    // SmartBatteryIsSupported           :1\r
+    0,    // BiosBootSpecIsSupported           :1\r
+    0,    // FunctionKeyNetworkBootIsSupported :1\r
+    0     // Reserved                          :22\r
+  },\r
+  {       // BiosCharacteristics2\r
+    0,    // BiosReserved                      :16\r
+    0,    // SystemReserved                    :16\r
+    0     // Reserved                          :32\r
+  },\r
+};\r
+\r
+/* eof - MiscBiosVendorData.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c
new file mode 100644 (file)
index 0000000..6d64ef4
--- /dev/null
@@ -0,0 +1,202 @@
+/** @file\r
+  BIOS vendor information boot time changes.\r
+  Misc. subclass type 2.\r
+  SMBIOS type 0.\r
+\r
+  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+/**\r
+  This function returns the value & exponent to Base2 for a given\r
+  Hex value. This is used to calculate the BiosPhysicalDeviceSize.\r
+\r
+  @param Value                      The hex value which is to be converted into value-exponent form\r
+  @param Exponent                   The exponent out of the conversion\r
+\r
+  @retval EFI_SUCCESS               All parameters were valid and *Value & *Exponent have been set.\r
+  @retval EFI_INVALID_PARAMETER     Invalid parameter was found.\r
+  \r
+**/\r
+EFI_STATUS  \r
+GetValueExponentBase2(\r
+  IN OUT UINTN        *Value,\r
+  OUT    UINTN        *Exponent\r
+  )\r
+{\r
+  if ((Value == NULL) || (Exponent == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  while ((*Value % 2) == 0) {\r
+    *Value=*Value/2;\r
+    (*Exponent)++;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a byte, with '64k'\r
+  as the unit.\r
+\r
+  @param  Base2Data              Pointer to Base2_Data\r
+\r
+  @retval EFI_SUCCESS            Transform successfully.       \r
+  @retval EFI_INVALID_PARAMETER  Invalid parameter was found.    \r
+\r
+**/\r
+UINT16\r
+Base2ToByteWith64KUnit (\r
+  IN      EFI_EXP_BASE2_DATA  *Base2Data\r
+  )\r
+{  \r
+  UINT16              Value;\r
+  UINT16              Exponent;\r
+\r
+  Value     = Base2Data->Value;\r
+  Exponent  = Base2Data->Exponent;\r
+  Exponent -= 16;\r
+  Value <<= Exponent;\r
+\r
+  return Value;\r
+}\r
+\r
+\r
+/**\r
+  This function makes boot time changes to the contents of the\r
+  MiscBiosVendor (Type 0).\r
+\r
+  @param  RecordData                 Pointer to copy of RecordData from the Data Table.\r
+\r
+  @retval EFI_SUCCESS                All parameters were valid.\r
+  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
+  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
+\r
+**/\r
+MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor)\r
+{\r
+  CHAR8                 *OptionalStrStart;\r
+  UINTN                 VendorStrLen;\r
+  UINTN                 VerStrLen;\r
+  UINTN                 DateStrLen;\r
+  CHAR16                *Version;\r
+  CHAR16                *ReleaseDate;\r
+  EFI_STATUS            Status;\r
+  EFI_STRING            Char16String;\r
+  STRING_REF            TokenToGet;\r
+  STRING_REF            TokenToUpdate;\r
+  SMBIOS_TABLE_TYPE0    *SmbiosRecord;\r
+  EFI_SMBIOS_HANDLE     SmbiosHandle;\r
+  EFI_MISC_BIOS_VENDOR *ForType0InputData;\r
+\r
+  ForType0InputData        = (EFI_MISC_BIOS_VENDOR *)RecordData;\r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (RecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Version = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString);\r
+  if (StrLen (Version) > 0) {     \r
+    TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_VERSION);\r
+    HiiSetString (mHiiHandle, TokenToUpdate, Version, NULL);\r
+  }\r
+  \r
+  ReleaseDate = (CHAR16 *) PcdGetPtr (PcdFirmwareReleaseDateString);\r
+  if (StrLen(ReleaseDate) > 0) {\r
+    TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE);\r
+    HiiSetString (mHiiHandle, TokenToUpdate, ReleaseDate, NULL);\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_BIOS_VENDOR);\r
+  Char16String = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  VendorStrLen = StrLen(Char16String);\r
+  if (VendorStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_BIOS_VERSION);\r
+  Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  VerStrLen = StrLen(Version);\r
+  if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE);\r
+  ReleaseDate = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  DateStrLen = StrLen(ReleaseDate);\r
+  if (DateStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE0) + VendorStrLen + 1 + VerStrLen + 1 + DateStrLen + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE0) + VendorStrLen + 1 + VerStrLen + 1 + DateStrLen + 1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BIOS_INFORMATION;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE0);\r
+  //\r
+  // Make handle chosen by smbios protocol.add automatically.\r
+  //\r
+  SmbiosRecord->Hdr.Handle = 0;\r
+  //\r
+  // Vendor will be the 1st optional string following the formatted structure.\r
+  //\r
+  SmbiosRecord->Vendor = 1;  \r
+  //\r
+  // Version will be the 2nd optional string following the formatted structure.\r
+  //\r
+  SmbiosRecord->BiosVersion = 2;\r
+  SmbiosRecord->BiosSegment = (UINT16)ForType0InputData->BiosStartingAddress;\r
+  //\r
+  // ReleaseDate will be the 3rd optional string following the formatted structure.\r
+  //\r
+  SmbiosRecord->BiosReleaseDate = 3;\r
+  //\r
+  // Nt32 has no PCD value to indicate BIOS Size, just fill 0 for simply.\r
+  //\r
+  SmbiosRecord->BiosSize = 0;\r
+  SmbiosRecord->BiosCharacteristics = *(MISC_BIOS_CHARACTERISTICS*)(&ForType0InputData->BiosCharacteristics1);\r
+  //\r
+  // CharacterExtensionBytes also store in ForType0InputData->BiosCharacteristics1 later two bytes to save size.\r
+  //\r
+  SmbiosRecord->BIOSCharacteristicsExtensionBytes[0] = *((UINT8 *) &ForType0InputData->BiosCharacteristics1 + 4);\r
+  SmbiosRecord->BIOSCharacteristicsExtensionBytes[1] = *((UINT8 *) &ForType0InputData->BiosCharacteristics1 + 5);\r
+\r
+  SmbiosRecord->SystemBiosMajorRelease = ForType0InputData->BiosMajorRelease;\r
+  SmbiosRecord->SystemBiosMinorRelease = ForType0InputData->BiosMinorRelease;\r
+  SmbiosRecord->EmbeddedControllerFirmwareMajorRelease = ForType0InputData->BiosEmbeddedFirmwareMajorRelease;\r
+  SmbiosRecord->EmbeddedControllerFirmwareMinorRelease = ForType0InputData->BiosEmbeddedFirmwareMinorRelease;\r
+\r
+  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
+  UnicodeStrToAsciiStr(Char16String, OptionalStrStart);\r
+  UnicodeStrToAsciiStr(Version, OptionalStrStart + VendorStrLen + 1);\r
+  UnicodeStrToAsciiStr(ReleaseDate, OptionalStrStart + VendorStrLen + 1 + VerStrLen + 1);\r
+  //\r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  SmbiosHandle = 0;\r
+  Status = Smbios-> Add(\r
+                      Smbios, \r
+                      NULL,\r
+                      &SmbiosHandle, \r
+                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
+                      );\r
+\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBootInformationData.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBootInformationData.c
new file mode 100644 (file)
index 0000000..0b7c57a
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscBootInformationData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_BOOT_INFORMATION_STATUS_DATA, BootInformationStatus) = {\r
+  EfiBootInformationStatusNoError,  // BootInformationStatus\r
+  {0}                                 // BootInformationData\r
+};\r
+\r
+/* eof - MiscBootInformationData.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBootInformationFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBootInformationFunction.c
new file mode 100644 (file)
index 0000000..65c9792
--- /dev/null
@@ -0,0 +1,73 @@
+/** @file\r
+  boot information boot time changes.\r
+  SMBIOS type 32.\r
+\r
+  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+\r
+/**\r
+  This function makes boot time changes to the contents of the\r
+  MiscBootInformation (Type 32).\r
+\r
+  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
+\r
+  @retval EFI_SUCCESS                All parameters were valid.\r
+  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
+  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
+\r
+**/\r
+\r
+MISC_SMBIOS_TABLE_FUNCTION(BootInformationStatus)\r
+{\r
+  EFI_STATUS                         Status;\r
+  EFI_SMBIOS_HANDLE                  SmbiosHandle;\r
+  SMBIOS_TABLE_TYPE32                *SmbiosRecord;\r
+  EFI_MISC_BOOT_INFORMATION_STATUS*  ForType32InputData;\r
\r
+  ForType32InputData = (EFI_MISC_BOOT_INFORMATION_STATUS *)RecordData;\r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (RecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE32) + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE32) + 1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE32);\r
+  //\r
+  // Make handle chosen by smbios protocol.add automatically.\r
+  //\r
+  SmbiosRecord->Hdr.Handle = 0;  \r
+  SmbiosRecord->BootStatus = (UINT8)ForType32InputData->BootInformationStatus;\r
+\r
+  //\r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  SmbiosHandle = 0;\r
+  Status = Smbios-> Add(\r
+                      Smbios, \r
+                      NULL,\r
+                      &SmbiosHandle, \r
+                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
+                      );\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturer.uni b/EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturer.uni
new file mode 100644 (file)
index 0000000..177ff38
Binary files /dev/null and b/EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturer.uni differ
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerData.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerData.c
new file mode 100644 (file)
index 0000000..795658b
--- /dev/null
@@ -0,0 +1,45 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscChassisManufacturerData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Chassis Manufacturer data.\r
+//\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_CHASSIS_MANUFACTURER_DATA, MiscChassisManufacturer) = {\r
+  STRING_TOKEN(STR_MISC_CHASSIS_MANUFACTURER),  // ChassisManufactrurer\r
+  STRING_TOKEN(STR_MISC_CHASSIS_VERSION),       // ChassisVersion\r
+  STRING_TOKEN(STR_MISC_CHASSIS_SERIAL_NUMBER), // ChassisSerialNumber\r
+  STRING_TOKEN(STR_MISC_CHASSIS_ASSET_TAG),     // ChassisAssetTag\r
+  {                               // ChassisTypeStatus\r
+    EfiMiscChassisTypeOther,      // ChassisType\r
+    0,                            // ChassisLockPresent\r
+    0                             // Reserved\r
+  },\r
+  EfiChassisStateOther,           // ChassisBootupState\r
+  EfiChassisStateOther,           // ChassisPowerSupplyState\r
+  EfiChassisStateOther,           // ChassisThermalState\r
+  EfiChassisSecurityStatusOther,  // ChassisSecurityState\r
+  0                               // ChassisOemDefined\r
+};\r
+\r
+/* eof - MiscChassisManufacaturerData.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c
new file mode 100644 (file)
index 0000000..fd1262b
--- /dev/null
@@ -0,0 +1,137 @@
+/** @file\r
+  Chassis manufacturer information boot time changes.\r
+  SMBIOS type 3.\r
+\r
+  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+/**\r
+  This function makes boot time changes to the contents of the\r
+  MiscChassisManufacturer (Type 3).\r
+\r
+  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
+\r
+  @retval EFI_SUCCESS                All parameters were valid.\r
+  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
+  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
+\r
+**/\r
+MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer)\r
+{\r
+  CHAR8                           *OptionalStrStart;\r
+  UINTN                           ManuStrLen;\r
+  UINTN                           VerStrLen;\r
+  UINTN                           AssertTagStrLen;\r
+  UINTN                           SerialNumStrLen;\r
+  EFI_STATUS                      Status;\r
+  EFI_STRING                      Manufacturer;\r
+  EFI_STRING                      Version;\r
+  EFI_STRING                      SerialNumber;\r
+  EFI_STRING                      AssertTag;\r
+  STRING_REF                      TokenToGet;\r
+  EFI_SMBIOS_HANDLE               SmbiosHandle;\r
+  SMBIOS_TABLE_TYPE3              *SmbiosRecord;\r
+  EFI_MISC_CHASSIS_MANUFACTURER   *ForType3InputData;\r
+\r
+  ForType3InputData = (EFI_MISC_CHASSIS_MANUFACTURER *)RecordData;\r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (RecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_MANUFACTURER);\r
+  Manufacturer = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  ManuStrLen = StrLen(Manufacturer);\r
+  if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_VERSION);\r
+  Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  VerStrLen = StrLen(Version);\r
+  if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_SERIAL_NUMBER);\r
+  SerialNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  SerialNumStrLen = StrLen(SerialNumber);\r
+  if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_ASSET_TAG);\r
+  AssertTag = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  AssertTagStrLen = StrLen(AssertTag);\r
+  if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1  + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1  + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE3);\r
+  //\r
+  // Make handle chosen by smbios protocol.add automatically.\r
+  //\r
+  SmbiosRecord->Hdr.Handle = 0;  \r
+  //\r
+  // Manu will be the 1st optional string following the formatted structure.\r
+  // \r
+  SmbiosRecord->Manufacturer = 1;  \r
+  SmbiosRecord->Type = (UINT8)ForType3InputData->ChassisType.ChassisType;\r
+  //\r
+  // Version will be the 2nd optional string following the formatted structure.\r
+  //\r
+  SmbiosRecord->Version = 2;  \r
+  //\r
+  // SerialNumber will be the 3rd optional string following the formatted structure.\r
+  //\r
+  SmbiosRecord->SerialNumber = 3;  \r
+  //\r
+  // AssertTag will be the 4th optional string following the formatted structure.\r
+  //\r
+  SmbiosRecord->AssetTag = 4;  \r
+  SmbiosRecord->BootupState = (UINT8)ForType3InputData->ChassisBootupState;\r
+  SmbiosRecord->PowerSupplyState = (UINT8)ForType3InputData->ChassisPowerSupplyState;\r
+  SmbiosRecord->ThermalState = (UINT8)ForType3InputData->ChassisThermalState;\r
+  SmbiosRecord->SecurityStatus = (UINT8)ForType3InputData->ChassisSecurityState;\r
+  CopyMem (SmbiosRecord->OemDefined,(UINT8*)&ForType3InputData->ChassisOemDefined, 4);\r
+\r
+  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
+  UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);\r
+  UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1);\r
+  UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1);\r
+  UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);\r
+\r
+  //\r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  SmbiosHandle = 0;\r
+  Status = Smbios-> Add(\r
+                      Smbios, \r
+                      NULL,\r
+                      &SmbiosHandle, \r
+                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
+                      );\r
+\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscDevicePath.h b/EmulatorPkg/MiscSubClassPlatformDxe/MiscDevicePath.h
new file mode 100644 (file)
index 0000000..b1a9acf
--- /dev/null
@@ -0,0 +1,175 @@
+/*++\r
\r
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscDevicePath.h\r
+\r
+Abstract:\r
+\r
+  Misc class required EFI Device Path definitions (Ports, slots & \r
+  onboard devices)\r
+\r
+**/\r
+\r
+#ifndef _MISC_DEVICE_PATH_H\r
+#define _MISC_DEVICE_PATH_H\r
+\r
+\r
+#pragma pack(1)\r
+//\r
+// USB\r
+//\r
+\r
+/* For reference:\r
+#define USB1_1_STR  "ACPI(PNP0A03,0)/PCI(1D,0)."\r
+#define USB1_2_STR  "ACPI(PNP0A03,0)/PCI(1D,1)."\r
+#define USB1_3_STR  "ACPI(PNP0A03,0)/PCI(1D,2)."\r
+#define USB2_1_STR  "ACPI(PNP0A03,0)/PCI(1D,7)." \r
+*/\r
+\r
+//\r
+// #define acpi { 0x02, 0x01, 0x00, 0x0C, 0x0a0341d0, 0x00000000 }\r
+// #define pci( device,function)  { 0x01, 0x01, 0x00, 0x06, device, function }\r
+// #define end  { 0xFF, 0xFF, 0x00, 0x04 }\r
+//\r
+#define DP_ACPI \\r
+  { \\r
+      {ACPI_DEVICE_PATH, ACPI_DP, {(UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), (UINT8) \\r
+      ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)}}, EISA_PNP_ID (0x0A03), 0 \\r
+  }\r
+#define DP_PCI(device, function) \\r
+  { \\r
+      {HARDWARE_DEVICE_PATH, HW_PCI_DP, {(UINT8) (sizeof (PCI_DEVICE_PATH)), (UINT8) \\r
+       ((sizeof (PCI_DEVICE_PATH)) >> 8)}}, function, device \\r
+  }\r
+#define DP_END \\r
+  { \\r
+    END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, {END_DEVICE_PATH_LENGTH, 0} \\r
+  }\r
+\r
+#define DP_LPC(eisaid, function) \\r
+  { \\r
+    {ACPI_DEVICE_PATH, ACPI_DP, {(UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), (UINT8) \\r
+     ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)}}, EISA_PNP_ID (eisaid), function \\r
+  }\r
+\r
+//\r
+// Shanmu >> moved to TianoDevicePath.h\r
+//\r
+\r
+/*\r
+typedef struct _USB_PORT_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      PciBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} USB_PORT_DEVICE_PATH;\r
+\r
+\r
+//IDE ??I am not sure. Should this be ATAPI_DEVICE_PATH\r
+typedef struct _IDE_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      PciBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} IDE_DEVICE_PATH;\r
+\r
+//RMC Connector\r
+typedef struct _RMC_CONN_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      PciBridgeDevicePath;\r
+  PCI_DEVICE_PATH      PciBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} RMC_CONN_DEVICE_PATH;\r
+\r
+//static RMC_CONN_DEVICE_PATH mRmcConnDevicePath = { acpi, pci( 0x1E,0x00 ),pci( 0x0A,0x00 ), end };\r
+\r
+//RIDE\r
+typedef struct _RIDE_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      PciBridgeDevicePath;\r
+  PCI_DEVICE_PATH      PciBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} RIDE_DEVICE_PATH;\r
+\r
+//static RIDE_DEVICE_PATH mRideDevicePath = { acpi, pci( 0x1E,0x00 ),pci( 0x02,0x00 ), end };\r
+\r
+//Gigabit NIC\r
+//typedef struct _GB_NIC_DEVICE_PATH\r
+//{\r
+//  ACPI_HID_DEVICE_PATH      PciRootBridgeDevicePath;\r
+//  PCI_DEVICE_PATH            PciBridgeDevicePath;\r
+//  PCI_DEVICE_PATH            PciXBridgeDevicePath;\r
+//  PCI_DEVICE_PATH            PciXBusDevicePath;\r
+//  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+//} GB_NIC_DEVICE_PATH;\r
+\r
+//static GB_NIC_DEVICE_PATH mGbNicDevicePath = { acpi, pci( 0x03,0x00 ),pci( 0x1F,0x00 ),pci( 0x07,0x00 ), end };\r
+\r
+\r
+//P/S2 Connector\r
+typedef struct _PS2_CONN_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      LpcBridgeDevicePath;\r
+  ACPI_HID_DEVICE_PATH    LpcBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} PS2_CONN_DEVICE_PATH;\r
+\r
+//static PS2_CONN_DEVICE_PATH mPs2KeyboardDevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0303,0 ), end };\r
+//static PS2_CONN_DEVICE_PATH mPs2MouseDevicePath      = { acpi, pci( 0x1F,0x00 ),lpc( 0x0303,1 ), end };\r
+\r
+//Serial Port Connector\r
+typedef struct _SERIAL_CONN_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      LpcBridgeDevicePath;\r
+  ACPI_HID_DEVICE_PATH    LpcBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} SERIAL_CONN_DEVICE_PATH;\r
+\r
+//static SERIAL_CONN_DEVICE_PATH mCom1DevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0501,0 ), end };\r
+//static SERIAL_CONN_DEVICE_PATH mCom2DevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0501,1 ), end };\r
+\r
+//Parallel Port Connector\r
+typedef struct _PARALLEL_CONN_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      LpcBridgeDevicePath;\r
+  ACPI_HID_DEVICE_PATH    LpcBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} PARALLEL_CONN_DEVICE_PATH;\r
+\r
+//static PARALLEL_CONN_DEVICE_PATH mLpt1DevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0401,0 ), end };\r
+\r
+//Floopy Connector\r
+typedef struct _FLOOPY_CONN_DEVICE_PATH\r
+{\r
+  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
+  PCI_DEVICE_PATH      LpcBridgeDevicePath;\r
+  ACPI_HID_DEVICE_PATH    LpcBusDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} FLOOPY_CONN_DEVICE_PATH;\r
+\r
+//static FLOOPY_CONN_DEVICE_PATH mFloopyADevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0604,0 ), end };\r
+//static FLOOPY_CONN_DEVICE_PATH mFloopyBDevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0604,1 ), end };\r
+\r
+*/\r
+\r
+//\r
+// End Shanmu\r
+//\r
+#pragma pack()\r
+\r
+#endif\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesData.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesData.c
new file mode 100644 (file)
index 0000000..88d9d0f
--- /dev/null
@@ -0,0 +1,38 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscNumberOfInstallableLanguagesData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA, NumberOfInstallableLanguages)\r
+= {\r
+  1,    // NumberOfInstallableLanguages\r
+  {     // LanguageFlags\r
+    0,  // AbbreviatedLanguageFormat\r
+    0   // Reserved\r
+  },\r
+  0,    // CurrentLanguageNumber\r
+};\r
+\r
+/* eof - MiscNumberOfInstallableLanguagesData.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesFunction.c
new file mode 100644 (file)
index 0000000..9bd7f4d
--- /dev/null
@@ -0,0 +1,238 @@
+/** @file\r
+  This driver parses the mSmbiosMiscDataTable structure and reports\r
+  any generated data.\r
+\r
+  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+/*++\r
+  Check whether the language is supported for given HII handle\r
+\r
+  @param   HiiHandle     The HII package list handle.\r
+  @param   Offset        The offest of current lanague in the supported languages.\r
+  @param   CurrentLang   The language code.\r
+\r
+  @retval  TRUE          Supported.\r
+  @retval  FALSE         Not Supported.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CurrentLanguageMatch (\r
+  IN  EFI_HII_HANDLE                   HiiHandle,\r
+  OUT UINT16                           *Offset,\r
+  OUT CHAR8                            *CurrentLang\r
+  )\r
+{\r
+  CHAR8     *DefaultLang;\r
+  CHAR8     *BestLanguage;\r
+  CHAR8     *Languages;\r
+  CHAR8     *MatchLang;\r
+  CHAR8     *EndMatchLang;\r
+  UINTN     CompareLength;\r
+  \r
+  Languages = HiiGetSupportedLanguages (HiiHandle);\r
+  if (Languages == NULL) {\r
+    return;\r
+  }\r
+\r
+  CurrentLang  = GetEfiGlobalVariable (L"PlatformLang");\r
+  DefaultLang  = (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang);\r
+  BestLanguage = GetBestLanguage (\r
+                   Languages,\r
+                   FALSE,\r
+                   (CurrentLang != NULL) ? CurrentLang : "",\r
+                   DefaultLang,\r
+                   NULL\r
+                   );\r
+  if (BestLanguage != NULL) {\r
+    //\r
+    // Find the best matching RFC 4646 language, compute the offset.\r
+    //\r
+    CompareLength = AsciiStrLen (BestLanguage);\r
+    for (MatchLang = Languages, (*Offset) = 0; MatchLang != '\0'; (*Offset)++) {\r
+      //\r
+      // Seek to the end of current match language. \r
+      //\r
+      for (EndMatchLang = MatchLang; *EndMatchLang != '\0' && *EndMatchLang != ';'; EndMatchLang++);\r
+  \r
+      if ((EndMatchLang == MatchLang + CompareLength) && AsciiStrnCmp(MatchLang, BestLanguage, CompareLength) == 0) {\r
+        //\r
+        // Find the current best Language in the supported languages\r
+        //\r
+        break;\r
+      }\r
+      //\r
+      // best language match be in the supported language.\r
+      //\r
+      ASSERT (*EndMatchLang == ';');\r
+      MatchLang = EndMatchLang + 1;\r
+    }\r
+    FreePool (BestLanguage);\r
+  }\r
+\r
+  FreePool (Languages);\r
+  if (CurrentLang != NULL) {\r
+    FreePool (CurrentLang);\r
+  }\r
+  return ;\r
+}\r
+\r
+\r
+/**\r
+  Get next language from language code list (with separator ';').\r
+\r
+  @param  LangCode       Input: point to first language in the list. On\r
+                         Otput: point to next language in the list, or\r
+                                NULL if no more language in the list.\r
+  @param  Lang           The first language in the list.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+GetNextLanguage (\r
+  IN OUT CHAR8      **LangCode,\r
+  OUT CHAR8         *Lang\r
+  )\r
+{\r
+  UINTN  Index;\r
+  CHAR8  *StringPtr;\r
+\r
+  ASSERT (LangCode != NULL);\r
+  ASSERT (*LangCode != NULL);\r
+  ASSERT (Lang != NULL);\r
+\r
+  Index     = 0;\r
+  StringPtr = *LangCode;\r
+  while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {\r
+    Index++;\r
+  }\r
+\r
+  CopyMem (Lang, StringPtr, Index);\r
+  Lang[Index] = 0;\r
+\r
+  if (StringPtr[Index] == ';') {\r
+    Index++;\r
+  }\r
+  *LangCode = StringPtr + Index;\r
+}\r
+\r
+/**\r
+  This function returns the number of supported languages on HiiHandle.\r
+\r
+  @param   HiiHandle    The HII package list handle.\r
+\r
+  @retval  The number of supported languages.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+GetSupportedLanguageNumber (\r
+  IN EFI_HII_HANDLE    HiiHandle\r
+  )\r
+{\r
+  CHAR8   *Lang;\r
+  CHAR8   *Languages;\r
+  CHAR8   *LanguageString;\r
+  UINT16  LangNumber;\r
+  \r
+  Languages = HiiGetSupportedLanguages (HiiHandle);\r
+  if (Languages == NULL) {\r
+    return 0;\r
+  }\r
+\r
+  LangNumber = 0;\r
+  Lang = AllocatePool (AsciiStrSize (Languages));\r
+  if (Lang != NULL) {\r
+    LanguageString = Languages;\r
+    while (*LanguageString != 0) {\r
+      GetNextLanguage (&LanguageString, Lang);\r
+      LangNumber++;\r
+    }\r
+    FreePool (Lang);\r
+  }\r
+  FreePool (Languages);\r
+  return LangNumber;\r
+}\r
+\r
+\r
+/**\r
+  This function makes boot time changes to the contents of the\r
+  MiscNumberOfInstallableLanguages (Type 13).\r
+\r
+  @param  RecordData                 Pointer to copy of RecordData from the Data Table.\r
+\r
+  @retval EFI_SUCCESS                All parameters were valid.\r
+  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
+  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
+\r
+**/\r
+MISC_SMBIOS_TABLE_FUNCTION(NumberOfInstallableLanguages)\r
+{\r
+  UINTN                                     LangStrLen;\r
+  CHAR8                                     CurrentLang[SMBIOS_STRING_MAX_LENGTH + 1];\r
+  CHAR8                                     *OptionalStrStart;\r
+  UINT16                                    Offset;\r
+  EFI_STATUS                                Status;\r
+  EFI_SMBIOS_HANDLE                         SmbiosHandle;\r
+  SMBIOS_TABLE_TYPE13                       *SmbiosRecord;\r
+  EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES  *ForType13InputData;\r
\r
+  ForType13InputData = (EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES *)RecordData;\r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (RecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  ForType13InputData->NumberOfInstallableLanguages = GetSupportedLanguageNumber (mHiiHandle);\r
+\r
+  //\r
+  // Try to check if current langcode matches with the langcodes in installed languages\r
+  //\r
+  ZeroMem(CurrentLang, SMBIOS_STRING_MAX_LENGTH + 1);\r
+  CurrentLanguageMatch (mHiiHandle, &Offset, CurrentLang);\r
+  LangStrLen = AsciiStrLen(CurrentLang);\r
+\r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE13) + LangStrLen + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE13) + LangStrLen + 1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE13);\r
+  //\r
+  // Make handle chosen by smbios protocol.add automatically.\r
+  //\r
+  SmbiosRecord->Hdr.Handle = 0;  \r
+\r
+  SmbiosRecord->InstallableLanguages = (UINT8)ForType13InputData->NumberOfInstallableLanguages;\r
+  SmbiosRecord->Flags = (UINT8)ForType13InputData->LanguageFlags.AbbreviatedLanguageFormat;\r
+  SmbiosRecord->CurrentLanguages = 1;\r
+  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
+  AsciiStrCpy(OptionalStrStart, CurrentLang);\r
+  //\r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  SmbiosHandle = 0;\r
+  Status = Smbios-> Add(\r
+                      Smbios, \r
+                      NULL,\r
+                      &SmbiosHandle, \r
+                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
+                      );\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscOemString.uni b/EmulatorPkg/MiscSubClassPlatformDxe/MiscOemString.uni
new file mode 100644 (file)
index 0000000..782a83b
Binary files /dev/null and b/EmulatorPkg/MiscSubClassPlatformDxe/MiscOemString.uni differ
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscOemStringData.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscOemStringData.c
new file mode 100644 (file)
index 0000000..1d07815
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    MiscOemStringData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_OEM_STRING_DATA, OemString) = {\r
+  { STRING_TOKEN(STR_MISC_OEM_STRING) }\r
+};\r
+\r
+/* eof - MiscOemStringData.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c
new file mode 100644 (file)
index 0000000..94fc71c
--- /dev/null
@@ -0,0 +1,80 @@
+/** @file\r
+  boot information boot time changes.\r
+  SMBIOS type 11.\r
+\r
+  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+/**\r
+  This function makes boot time changes to the contents of the\r
+  MiscOemString (Type 11).\r
+\r
+  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
+\r
+  @retval EFI_SUCCESS                All parameters were valid.\r
+  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
+  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
+\r
+**/\r
+MISC_SMBIOS_TABLE_FUNCTION(OemString)\r
+{\r
+  UINTN                    OemStrLen;\r
+  CHAR8                    *OptionalStrStart;\r
+  EFI_STATUS               Status;\r
+  EFI_STRING               OemStr;\r
+  STRING_REF               TokenToGet;\r
+  EFI_SMBIOS_HANDLE        SmbiosHandle;\r
+  SMBIOS_TABLE_TYPE11      *SmbiosRecord;\r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (RecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_OEM_STRING);\r
+  OemStr = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  OemStrLen = StrLen(OemStr);\r
+  if (OemStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_OEM_STRINGS;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE11);\r
+  //\r
+  // Make handle chosen by smbios protocol.add automatically.\r
+  // \r
+  SmbiosRecord->Hdr.Handle = 0;  \r
+  SmbiosRecord->StringCount = 1;\r
+  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
+  UnicodeStrToAsciiStr(OemStr, OptionalStrStart);\r
+\r
+  //\r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  SmbiosHandle = 0;\r
+  Status = Smbios-> Add(\r
+                      Smbios, \r
+                      NULL,\r
+                      &SmbiosHandle, \r
+                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
+                      );\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignator.uni b/EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignator.uni
new file mode 100644 (file)
index 0000000..87c5a81
Binary files /dev/null and b/EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignator.uni differ
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorData.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorData.c
new file mode 100644 (file)
index 0000000..7d511e1
--- /dev/null
@@ -0,0 +1,99 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscPortInternalConnectorDesignatorData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortInternalConnectorDesignator) = {\r
+  STRING_TOKEN(STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR),  // PortInternalConnectorDesignator\r
+  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_CONNECTOR_DESIGNATOR),  // PortExternalConnectorDesignator\r
+  EfiPortConnectorTypeOther,  // PortInternalConnectorType\r
+  EfiPortConnectorTypeOther,  // PortExternalConnectorType\r
+  EfiPortTypeNone,            // PortType\r
+  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
+};\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortKeyboard) = {\r
+  STRING_TOKEN (STR_MISC_PORT_INTERNAL_KEYBOARD),   // PortInternalConnectorDesignator\r
+  STRING_TOKEN (STR_MISC_PORT_EXTERNAL_KEYBOARD),   // PortExternalConnectorDesignator\r
+  EfiPortConnectorTypeNone, // PortInternalConnectorType\r
+  EfiPortConnectorTypePS2,  // PortExternalConnectorType\r
+  EfiPortTypeKeyboard,      // PortType\r
+  // mPs2KbyboardDevicePath                          // PortPath\r
+  //\r
+  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
+};\r
+\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortMouse) = {\r
+  STRING_TOKEN (STR_MISC_PORT_INTERNAL_MOUSE),      // PortInternalConnectorDesignator\r
+  STRING_TOKEN (STR_MISC_PORT_EXTERNAL_MOUSE),      // PortExternalConnectorDesignator\r
+  EfiPortConnectorTypeNone, // PortInternalConnectorType\r
+  EfiPortConnectorTypePS2,  // PortExternalConnectorType\r
+  EfiPortTypeMouse,         // PortType\r
+  // mPs2MouseDevicePath                // PortPath\r
+  //\r
+  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
+};\r
+\r
+\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom1) = {\r
+  STRING_TOKEN(STR_MISC_PORT_INTERNAL_COM1),\r
+  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM1),\r
+  EfiPortConnectorTypeNone,\r
+  EfiPortConnectorTypeDB9Female,\r
+  EfiPortTypeSerial16550ACompatible,\r
+  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
+};\r
+\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom2) = {\r
+  STRING_TOKEN(STR_MISC_PORT_INTERNAL_COM2),\r
+  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM2),\r
+  EfiPortConnectorTypeNone,\r
+  EfiPortConnectorTypeDB9Female,\r
+  EfiPortTypeSerial16550ACompatible,\r
+  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
+};\r
+\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortExtensionPower) = {\r
+  STRING_TOKEN(STR_MISC_PORT_INTERNAL_EXTENSION_POWER),\r
+  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_EXTENSION_POWER),\r
+  EfiPortConnectorTypeOther,\r
+  EfiPortConnectorTypeNone,\r
+  EfiPortTypeOther,\r
+  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
+};\r
+\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortFloppy) = {\r
+  STRING_TOKEN(STR_MISC_PORT_INTERNAL_FLOPPY),\r
+  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_FLOPPY),\r
+  EfiPortConnectorTypeOnboardFloppy,\r
+  EfiPortConnectorTypeNone,\r
+  EfiPortTypeOther,\r
+  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
+};\r
+\r
+/* eof - MiscPortInternalConnectorDesignatorData.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c
new file mode 100644 (file)
index 0000000..89c8815
--- /dev/null
@@ -0,0 +1,177 @@
+/*++\r
\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscPortInternalConnectorDesignatorFunction.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+\r
+MISC_SMBIOS_TABLE_FUNCTION (\r
+  MiscPortInternalConnectorDesignator\r
+  )\r
+/*++\r
+Description:\r
+\r
+  This function makes boot time changes to the contents of the\r
+  MiscPortConnectorInformation (Type 8).\r
+\r
+Parameters:\r
+\r
+  RecordType\r
+    Type of record to be processed from the Data Table.\r
+    mMiscSubclassDataTable[].RecordType\r
+\r
+  RecordLen\r
+    Size of static RecordData from the Data Table.\r
+    mMiscSubclassDataTable[].RecordLen\r
+\r
+  RecordData\r
+    Pointer to copy of RecordData from the Data Table.  Changes made\r
+    to this copy will be written to the Data Hub but will not alter\r
+    the contents of the static Data Table.\r
+\r
+  LogRecordData\r
+    Set *LogRecordData to TRUE to log RecordData to Data Hub.\r
+    Set *LogRecordData to FALSE when there is no more data to log.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+    All parameters were valid and *RecordData and *LogRecordData have\r
+    been set.\r
+\r
+  EFI_UNSUPPORTED\r
+    Unexpected RecordType value.\r
+\r
+  EFI_INVALID_PARAMETER\r
+    One of the following parameter conditions was true:\r
+      RecordLen was zero.\r
+      RecordData was NULL.\r
+      LogRecordData was NULL.\r
+**/\r
+{\r
+  CHAR8                                        *OptionalStrStart;\r
+  UINTN                                        InternalRefStrLen;\r
+  UINTN                                        ExternalRefStrLen;  \r
+  EFI_STRING                                   InternalRef;\r
+  EFI_STRING                                   ExternalRef;\r
+  STRING_REF                                   TokenForInternal;\r
+  STRING_REF                                   TokenForExternal;\r
+  EFI_STATUS                                   Status;\r
+  SMBIOS_TABLE_TYPE8                           *SmbiosRecord;\r
+  EFI_SMBIOS_HANDLE                            SmbiosHandle;\r
+  EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR  *ForType8InputData;\r
+  \r
+  ForType8InputData = (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *)RecordData;\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (RecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  TokenForInternal = 0;\r
+  TokenForExternal = 0;\r
+  \r
+  switch (ForType8InputData->PortInternalConnectorDesignator) { \r
+\r
+    case STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR:\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_CONNECTOR_DESIGNATOR);\r
+      break;\r
+    case STR_MISC_PORT_INTERNAL_KEYBOARD:\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_KEYBOARD);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_KEYBOARD);\r
+      break;\r
+    case STR_MISC_PORT_INTERNAL_MOUSE:\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_MOUSE);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_MOUSE);\r
+      break;\r
+    case STR_MISC_PORT_INTERNAL_COM1:\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM1);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM1);\r
+      break;\r
+    case STR_MISC_PORT_INTERNAL_COM2:\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM2);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM2);\r
+      break;\r
+    case STR_MISC_PORT_INTERNAL_EXTENSION_POWER:\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_EXTENSION_POWER);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_EXTENSION_POWER);\r
+      break;\r
+    case STR_MISC_PORT_INTERNAL_FLOPPY:\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_FLOPPY);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_FLOPPY);\r
+      break;\r
+    default:\r
+      break;\r
+  }\r
+\r
+  InternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForInternal, NULL);\r
+  InternalRefStrLen = StrLen(InternalRef);\r
+  if (InternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  ExternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForExternal, NULL);\r
+  ExternalRefStrLen = StrLen(ExternalRef);\r
+  if (ExternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE8);\r
+  //\r
+  // Make handle chosen by smbios protocol.add automatically.\r
+  //\r
+  SmbiosRecord->Hdr.Handle = 0;  \r
+  SmbiosRecord->InternalReferenceDesignator = 1;\r
+  SmbiosRecord->InternalConnectorType = (UINT8)ForType8InputData->PortInternalConnectorType;\r
+  SmbiosRecord->ExternalReferenceDesignator = 2;\r
+  SmbiosRecord->ExternalConnectorType = (UINT8)ForType8InputData->PortExternalConnectorType;\r
+  SmbiosRecord->PortType = (UINT8)ForType8InputData->PortType;\r
+  \r
+  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
+  UnicodeStrToAsciiStr(InternalRef, OptionalStrStart);\r
+  UnicodeStrToAsciiStr(ExternalRef, OptionalStrStart + InternalRefStrLen + 1);\r
+\r
+  //\r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  SmbiosHandle = 0;\r
+  Status = Smbios-> Add(\r
+                      Smbios, \r
+                      NULL,\r
+                      &SmbiosHandle, \r
+                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
+                      );\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
+}\r
+\r
+\r
+\r
+/* eof - MiscSystemManufacturerFunction.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesData.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesData.c
new file mode 100644 (file)
index 0000000..f591a2e
--- /dev/null
@@ -0,0 +1,42 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    MiscResetCapabilitiesData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_RESET_CAPABILITIES, MiscResetCapabilities) = {\r
+  {     // ResetCapabilities\r
+    0,  // Status\r
+    0,  // BootOption\r
+    0,  // BootOptionOnLimit\r
+    0,  // WatchdogTimerPresent\r
+    0   // Reserved\r
+  },\r
+  0,    // ResetCount\r
+  0,    // ResetLimit\r
+  0,    // ResetTimerInterval\r
+  0     // ResetTimeout\r
+};\r
+\r
+/* eof - MiscResetCapabilities.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesFunction.c
new file mode 100644 (file)
index 0000000..8303c5a
--- /dev/null
@@ -0,0 +1,76 @@
+/** @file\r
+  ResetCapabilities.\r
+  SMBIOS type 23.\r
+\r
+  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+/**\r
+  This function makes boot time changes to the contents of the\r
+  MiscOemString (Type 11).\r
+\r
+  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
+\r
+  @retval EFI_SUCCESS                All parameters were valid.\r
+  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
+  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
+\r
+**/\r
+MISC_SMBIOS_TABLE_FUNCTION(MiscResetCapabilities)\r
+{\r
+  EFI_STATUS               Status;\r
+  EFI_SMBIOS_HANDLE        SmbiosHandle;\r
+  SMBIOS_TABLE_TYPE23      *SmbiosRecord;\r
+  EFI_MISC_RESET_CAPABILITIES   *ForType23InputData;\r
+  \r
+  ForType23InputData = (EFI_MISC_RESET_CAPABILITIES *)RecordData;\r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (RecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+\r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE23) + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE23) + 1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_RESET;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE23);\r
+  //\r
+  // Make handle chosen by smbios protocol.add automatically.\r
+  // \r
+  SmbiosRecord->Hdr.Handle    = 0;  \r
+  SmbiosRecord->Capabilities  = *(UINT8*)&(ForType23InputData->ResetCapabilities);\r
+  SmbiosRecord->ResetCount    = (UINT16)ForType23InputData->ResetCount;\r
+  SmbiosRecord->ResetLimit    = (UINT16)ForType23InputData->ResetLimit;  \r
+  SmbiosRecord->TimerInterval = (UINT16)ForType23InputData->ResetTimerInterval;\r
+  SmbiosRecord->Timeout       = (UINT16)ForType23InputData->ResetTimeout;\r
+\r
+  //\r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  SmbiosHandle = 0;\r
+  Status = Smbios-> Add(\r
+                      Smbios, \r
+                      NULL,\r
+                      &SmbiosHandle, \r
+                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
+                      );\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
+}\r
+\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.h b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.h
new file mode 100644 (file)
index 0000000..7e5be7e
--- /dev/null
@@ -0,0 +1,122 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  MiscSubclassDriver.h\r
+\r
+Abstract:\r
+\r
+  Header file for MiscSubclass Driver.\r
+\r
+**/\r
+\r
+#ifndef _MISC_SUBCLASS_DRIVER_H\r
+#define _MISC_SUBCLASS_DRIVER_H\r
+\r
+#include <FrameworkDxe.h>\r
+\r
+#include <Guid/DataHubRecords.h>\r
+#include <IndustryStandard/SmBios.h>\r
+#include <Protocol/Smbios.h>\r
+#include <Protocol/EmuIoThunk.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+\r
+#include <MiscDevicePath.h>\r
+#include <Protocol/FrameworkHii.h>\r
+#include <Library/HiiLib.h>\r
+\r
+//\r
+// Data table entry update function.\r
+//\r
+typedef EFI_STATUS (EFIAPI EFI_MISC_SMBIOS_DATA_FUNCTION) (\r
+  IN  VOID                 *RecordData,\r
+  IN  EFI_SMBIOS_PROTOCOL  *Smbios\r
+  );\r
+\r
+//\r
+// Data table entry definition.\r
+//\r
+typedef struct {\r
+  //\r
+  // intermediat input data for SMBIOS record\r
+  //\r
+  VOID                              *RecordData;\r
+  EFI_MISC_SMBIOS_DATA_FUNCTION     *Function;\r
+} EFI_MISC_SMBIOS_DATA_TABLE;\r
+\r
+//\r
+// Data Table extern definitions.\r
+//\r
+#define MISC_SMBIOS_TABLE_EXTERNS(NAME1, NAME2, NAME3) \\r
+extern NAME1 NAME2 ## Data; \\r
+extern EFI_MISC_SMBIOS_DATA_FUNCTION NAME3 ## Function\r
+\r
+\r
+//\r
+// Data Table entries\r
+//\r
+#define MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION(NAME1, NAME2) \\r
+{ \\r
+  & NAME1 ## Data, \\r
+  & NAME2 ## Function \\r
+}\r
+\r
+//\r
+// Global definition macros.\r
+//\r
+#define MISC_SMBIOS_TABLE_DATA(NAME1, NAME2) \\r
+  NAME1 NAME2 ## Data\r
+\r
+#define MISC_SMBIOS_TABLE_FUNCTION(NAME2) \\r
+  EFI_STATUS EFIAPI NAME2 ## Function( \\r
+  IN  VOID                  *RecordData, \\r
+  IN  EFI_SMBIOS_PROTOCOL   *Smbios \\r
+  )\r
+\r
+\r
+//\r
+// Data Table Array\r
+//\r
+extern EFI_MISC_SMBIOS_DATA_TABLE mMiscSubclassDataTable[];\r
+\r
+//\r
+// Data Table Array Entries\r
+//\r
+extern UINTN                        mMiscSubclassDataTableEntries;\r
+extern UINT8                        MiscSubclassStrings[];\r
+extern EFI_HII_HANDLE               mHiiHandle;\r
+\r
+//\r
+// Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+MiscSubclassDriverEntryPoint (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  );\r
+\r
+\r
+#endif /* _MISC_SUBCLASS_DRIVER_H */\r
+\r
+/* eof - MiscSubclassDriver.h */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.inf b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.inf
new file mode 100644 (file)
index 0000000..dd75985
--- /dev/null
@@ -0,0 +1,103 @@
+## @file\r
+# Misc Sub class driver\r
+#\r
+# Parses the MiscSubclassDataTable and reports any generated data to the DataHub.\r
+#  All .uni file who tagged with "ToolCode="DUMMY"" in following file list is included by\r
+#  MiscSubclassDriver.uni file, the StrGather tool will expand MiscSubclassDriver.uni file \r
+#  and parse all .uni file.\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = MiscSubclass\r
+  FILE_GUID                      = f2fbd108-8985-11db-b06a-0040d02b1835\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  ENTRY_POINT                    = MiscSubclassDriverEntryPoint\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  MiscBaseBoardManufacturer.uni\r
+  MiscBaseBoardManufacturerData.c\r
+  MiscBaseBoardManufacturerFunction.c\r
+  MiscBiosVendor.uni\r
+  MiscBiosVendorData.c\r
+  MiscBiosVendorFunction.c\r
+  MiscBootInformationData.c  \r
+  MiscBootInformationFunction.c\r
+  MiscChassisManufacturer.uni\r
+  MiscChassisManufacturerData.c\r
+  MiscChassisManufacturerFunction.c\r
+  MiscNumberOfInstallableLanguagesData.c\r
+  MiscNumberOfInstallableLanguagesFunction.c\r
+  MiscOemString.uni  \r
+  MiscOemStringData.c  \r
+  MiscOemStringFunction.c  \r
+  MiscPortInternalConnectorDesignator.uni\r
+  MiscPortInternalConnectorDesignatorData.c  \r
+  MiscPortInternalConnectorDesignatorFunction.c\r
+  MiscResetCapabilitiesData.c\r
+  MiscResetCapabilitiesFunction.c\r
+  MiscSystemLanguageString.uni\r
+  MiscSystemLanguageStringData.c\r
+  MiscSystemLanguageStringFunction.c\r
+  MiscSystemManufacturer.uni\r
+  MiscSystemManufacturerData.c\r
+  MiscSystemManufacturerFunction.c\r
+  MiscSystemOptionString.uni\r
+  MiscSystemOptionStringData.c\r
+  MiscSystemOptionStringFunction.c\r
+  MiscSystemSlotDesignation.uni\r
+  MiscSystemSlotDesignationData.c\r
+  MiscSystemSlotDesignationFunction.c\r
+  MiscDevicePath.h\r
+  MiscSubClassDriver.h\r
+  MiscSubClassDriver.uni\r
+  MiscSubclassDriverDataTable.c\r
+  MiscSubclassDriverEntryPoint.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  DevicePathLib\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  BaseMemoryLib\r
+  UefiDriverEntryPoint\r
+  UefiLib\r
+  HiiLib\r
+  DebugLib\r
+  BaseLib\r
+  PcdLib\r
+\r
+[Protocols]\r
+  gEfiSmbiosProtocolGuid                        # PROTOCOL ALWAYS_CONSUMED\r
+\r
+[Pcd]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString\r
+  gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang  \r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuMemorySize\r
+\r
+\r
+[Depex]\r
+  gEfiSmbiosProtocolGuid\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.uni b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.uni
new file mode 100644 (file)
index 0000000..7a4e8a2
Binary files /dev/null and b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.uni differ
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubclassDriverDataTable.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubclassDriverDataTable.c
new file mode 100644 (file)
index 0000000..cb71f7d
--- /dev/null
@@ -0,0 +1,78 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscSubclassDriverDataTable.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+\r
+//\r
+// External definitions referenced by Data Table entries.\r
+//\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_BASE_BOARD_MANUFACTURER_DATA, MiscBaseBoardManufacturer, MiscBaseBoardManufacturer);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_BIOS_VENDOR_DATA, MiscBiosVendor,MiscBiosVendor );\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_BOOT_INFORMATION_STATUS_DATA, BootInformationStatus, BootInformationStatus);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_CHASSIS_MANUFACTURER_DATA, MiscChassisManufacturer, MiscChassisManufacturer);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA,NumberOfInstallableLanguages, NumberOfInstallableLanguages);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_OEM_STRING_DATA,OemString, OemString);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortInternalConnectorDesignator, MiscPortInternalConnectorDesignator);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortKeyboard, MiscPortInternalConnectorDesignator);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortMouse, MiscPortInternalConnectorDesignator);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom1, MiscPortInternalConnectorDesignator);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom2, MiscPortInternalConnectorDesignator);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortExtensionPower, MiscPortInternalConnectorDesignator);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortFloppy, MiscPortInternalConnectorDesignator);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_RESET_CAPABILITIES, MiscResetCapabilities, MiscResetCapabilities);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA,SystemLanguageString, SystemLanguageString);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_SYSTEM_MANUFACTURER_DATA, MiscSystemManufacturer, MiscSystemManufacturer);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_SYSTEM_OPTION_STRING_DATA, SystemOptionString, SystemOptionString);\r
+MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA, MiscSystemSlotDesignation, MiscSystemSlotDesignation);\r
+\r
+\r
+//\r
+// Data Table.\r
+//\r
+EFI_MISC_SMBIOS_DATA_TABLE  mMiscSubclassDataTable[] = {\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscBaseBoardManufacturer, MiscBaseBoardManufacturer),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscBiosVendor,MiscBiosVendor ),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( BootInformationStatus, BootInformationStatus),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscChassisManufacturer, MiscChassisManufacturer),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION(NumberOfInstallableLanguages, NumberOfInstallableLanguages),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION(OemString, OemString),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortInternalConnectorDesignator, MiscPortInternalConnectorDesignator),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortKeyboard, MiscPortInternalConnectorDesignator),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortMouse, MiscPortInternalConnectorDesignator),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortCom1, MiscPortInternalConnectorDesignator),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortCom2, MiscPortInternalConnectorDesignator),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortExtensionPower, MiscPortInternalConnectorDesignator),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortFloppy, MiscPortInternalConnectorDesignator),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscResetCapabilities, MiscResetCapabilities),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION(SystemLanguageString, SystemLanguageString),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscSystemManufacturer, MiscSystemManufacturer),\r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( SystemOptionString, SystemOptionString),  \r
+  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscSystemSlotDesignation, MiscSystemSlotDesignation),  \r
+  };\r
\r
+//\r
+// Number of Data Table entries.\r
+//\r
+UINTN mMiscSubclassDataTableEntries = (sizeof mMiscSubclassDataTable) / sizeof (EFI_MISC_SMBIOS_DATA_TABLE);\r
+\r
+/* eof - MiscSubclassDriverDataTable.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c
new file mode 100644 (file)
index 0000000..065ab6f
--- /dev/null
@@ -0,0 +1,170 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  MiscSubclassDriverEntryPoint.c\r
+\r
+Abstract:\r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+EFI_HII_HANDLE  mHiiHandle;\r
+\r
+/**\r
+  This is the standard EFI driver point that detects whether there is a\r
+  MemoryConfigurationData Variable and, if so, reports memory configuration info\r
+  to the DataHub.\r
+\r
+  @param  ImageHandle  Handle for the image of this driver\r
+  @param  SystemTable  Pointer to the EFI System Table\r
+\r
+  @return EFI_SUCCESS if the data is successfully reported\r
+  @return EFI_NOT_FOUND if the HOB list could not be located.\r
+\r
+**/\r
+EFI_STATUS\r
+LogMemorySmbiosRecord (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                      Status;\r
+  UINT64                          TotalMemorySize;\r
+  UINT8                           NumSlots;\r
+  SMBIOS_TABLE_TYPE19             *Type19Record;\r
+  EFI_SMBIOS_HANDLE               MemArrayMappedAddrSmbiosHandle;\r
+  EFI_SMBIOS_PROTOCOL             *Smbios;\r
+  CHAR16                          *MemString;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
+  ASSERT_EFI_ERROR (Status);\r
+  \r
+  NumSlots        = 1;\r
+\r
+  //\r
+  // Process Memory String in form size!size ...\r
+  // So 64!64 is 128 MB\r
+  //\r
+  MemString   = (CHAR16 *)PcdGetPtr (PcdEmuMemorySize);\r
+  for (TotalMemorySize = 0; *MemString != '\0';) {\r
+    TotalMemorySize += StrDecimalToUint64 (MemString);\r
+    while (*MemString != '\0') {\r
+      if (*MemString == '!') {\r
+        MemString++;       \r
+        break;\r
+      }\r
+      MemString++;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Convert Total Memory Size to based on KiloByte\r
+  //\r
+  TotalMemorySize = LShiftU64 (TotalMemorySize, 20);\r
+  //\r
+  // Generate Memory Array Mapped Address info\r
+  //\r
+  Type19Record = AllocatePool(sizeof (SMBIOS_TABLE_TYPE19));\r
+  ZeroMem(Type19Record, sizeof(SMBIOS_TABLE_TYPE19));\r
+  Type19Record->Hdr.Type = EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS;\r
+  Type19Record->Hdr.Length = sizeof(SMBIOS_TABLE_TYPE19);\r
+  Type19Record->Hdr.Handle = 0;\r
+  Type19Record->StartingAddress = 0;\r
+  Type19Record->EndingAddress =  (UINT32)RShiftU64(TotalMemorySize, 10) - 1;\r
+  Type19Record->MemoryArrayHandle = 0;\r
+  Type19Record->PartitionWidth = (UINT8)(NumSlots); \r
+\r
+  //\r
+  // Generate Memory Array Mapped Address info (TYPE 19)\r
+  //\r
+  MemArrayMappedAddrSmbiosHandle = 0;\r
+  Status = Smbios->Add (Smbios, NULL, &MemArrayMappedAddrSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type19Record);\r
+  FreePool(Type19Record);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+MiscSubclassDriverEntryPoint (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+/*++\r
+Description:\r
+\r
+  Standard EFI driver point.  This driver parses the mMiscSubclassDataTable\r
+  structure and reports any generated data to the DataHub.\r
+\r
+Arguments:\r
+\r
+  ImageHandle\r
+    Handle for the image of this driver\r
+\r
+  SystemTable\r
+    Pointer to the EFI System Table\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS\r
+    The data was successfully reported to the Data Hub.\r
+\r
+**/\r
+{\r
+  UINTN                Index;\r
+  EFI_STATUS           EfiStatus;\r
+  EFI_SMBIOS_PROTOCOL  *Smbios;  \r
+\r
+  EfiStatus = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
+\r
+  if (EFI_ERROR(EfiStatus)) {\r
+    DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol.  %r\n", EfiStatus));\r
+    return EfiStatus;\r
+  }\r
+\r
+  mHiiHandle = HiiAddPackages (\r
+                 &gEfiCallerIdGuid,\r
+                 NULL,\r
+                 MiscSubclassStrings,\r
+                 NULL\r
+                 );\r
+  ASSERT (mHiiHandle != NULL);\r
+\r
+  for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {\r
+    //\r
+    // If the entry have a function pointer, just log the data.\r
+    //\r
+    if (mMiscSubclassDataTable[Index].Function != NULL) {\r
+      EfiStatus = (*mMiscSubclassDataTable[Index].Function)(\r
+        mMiscSubclassDataTable[Index].RecordData,\r
+        Smbios\r
+        );\r
+\r
+      if (EFI_ERROR(EfiStatus)) {\r
+        DEBUG((EFI_D_ERROR, "Misc smbios store error.  Index=%d, ReturnStatus=%r\n", Index, EfiStatus));\r
+        return EfiStatus;\r
+      }\r
+    }\r
+  }\r
+\r
+  //\r
+  // Log Memory SMBIOS Record\r
+  //\r
+  EfiStatus = LogMemorySmbiosRecord();\r
+  return EfiStatus;\r
+}\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageString.uni b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageString.uni
new file mode 100644 (file)
index 0000000..709c53a
Binary files /dev/null and b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageString.uni differ
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringData.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringData.c
new file mode 100644 (file)
index 0000000..0dc706e
--- /dev/null
@@ -0,0 +1,33 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscSystemLanguageStringData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA, SystemLanguageString) = {\r
+  0,\r
+  STRING_TOKEN(STR_MISC_SYSTEM_LANGUAGE_STRING)\r
+};\r
+\r
+/* eof - MiscSystemLanguageStringData.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c
new file mode 100644 (file)
index 0000000..3e10c63
--- /dev/null
@@ -0,0 +1,85 @@
+/** @file\r
+  ResetCapabilities.\r
+  SMBIOS type 23.\r
+\r
+  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+/**\r
+  This function makes boot time changes to the contents of the\r
+  MiscOemString (Type 11).\r
+\r
+  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
+\r
+  @retval EFI_SUCCESS                All parameters were valid.\r
+  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
+  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
+\r
+**/\r
+MISC_SMBIOS_TABLE_FUNCTION(SystemLanguageString)\r
+{\r
+  EFI_STATUS               Status;\r
+  EFI_SMBIOS_HANDLE        SmbiosHandle;\r
+  SMBIOS_TABLE_TYPE13      *SmbiosRecord;\r
+  UINTN                    StrLeng;\r
+  CHAR8                    *OptionalStrStart;\r
+  EFI_STRING               Str;\r
+  STRING_REF               TokenToGet;\r
+  \r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (RecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_LANGUAGE_STRING);\r
+  Str = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  StrLeng = StrLen(Str);\r
+  if (StrLeng > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE13) + StrLeng + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE13) + StrLeng + 1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE13);\r
+  //\r
+  // Make handle chosen by smbios protocol.add automatically.\r
+  // \r
+  SmbiosRecord->Hdr.Handle    = 0;\r
+  SmbiosRecord->InstallableLanguages = 1;\r
+  SmbiosRecord->Flags   = 1;\r
+  SmbiosRecord->CurrentLanguages = 1;\r
+  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
+  UnicodeStrToAsciiStr(Str, OptionalStrStart);\r
+  \r
+\r
+  //\r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  SmbiosHandle = 0;\r
+  Status = Smbios-> Add(\r
+                      Smbios, \r
+                      NULL,\r
+                      &SmbiosHandle, \r
+                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
+                      );\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
+}\r
+\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturer.uni b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturer.uni
new file mode 100644 (file)
index 0000000..3ff890b
Binary files /dev/null and b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturer.uni differ
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerData.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerData.c
new file mode 100644 (file)
index 0000000..13befc4
--- /dev/null
@@ -0,0 +1,57 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscSystemManufacturerData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) System Manufacturer data.\r
+//\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_SYSTEM_MANUFACTURER_DATA, MiscSystemManufacturer)\r
+= {\r
+  STRING_TOKEN(STR_MISC_SYSTEM_MANUFACTURER),\r
+  // SystemManufactrurer\r
+  STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME),\r
+  // SystemProductName\r
+  STRING_TOKEN(STR_MISC_SYSTEM_VERSION),\r
+  // SystemVersion\r
+  STRING_TOKEN(STR_MISC_SYSTEM_SERIAL_NUMBER),\r
+  // SystemSerialNumber\r
+  {\r
+    0xbadfaced,\r
+    0xdead,\r
+    0xbeef,\r
+    {\r
+      0x13,\r
+      0x13,\r
+      0x13,\r
+      0x13,\r
+      0x13,\r
+      0x13,\r
+      0x13,\r
+      0x13\r
+    }\r
+  },\r
+  // SystemUuid\r
+  EfiSystemWakeupTypePowerSwitch  // SystemWakeupType\r
+};\r
+\r
+/* eof - MiscSystemManufacturerData.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c
new file mode 100644 (file)
index 0000000..9d2a3cb
--- /dev/null
@@ -0,0 +1,140 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscSystemManufacturerFunction.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+/**\r
+  This function makes boot time changes to the contents of the\r
+  MiscSystemManufacturer (Type 1).\r
+\r
+  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
+\r
+  @retval EFI_SUCCESS                All parameters were valid.\r
+  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
+  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
+\r
+**/\r
+MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)\r
+{\r
+  CHAR8                             *OptionalStrStart;\r
+  UINTN                             ManuStrLen;\r
+  UINTN                             VerStrLen;\r
+  UINTN                             PdNameStrLen;\r
+  UINTN                             SerialNumStrLen;\r
+  EFI_STATUS                        Status;\r
+  EFI_STRING                        Manufacturer;\r
+  EFI_STRING                        ProductName;\r
+  EFI_STRING                        Version;\r
+  EFI_STRING                        SerialNumber;\r
+  STRING_REF                        TokenToGet;\r
+  EFI_SMBIOS_HANDLE                 SmbiosHandle;\r
+  SMBIOS_TABLE_TYPE1                *SmbiosRecord;\r
+  EFI_MISC_SYSTEM_MANUFACTURER      *ForType1InputData;\r
+\r
+  ForType1InputData = (EFI_MISC_SYSTEM_MANUFACTURER *)RecordData;\r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (RecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER);\r
+  Manufacturer = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  ManuStrLen = StrLen(Manufacturer);\r
+  if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME);\r
+  ProductName = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  PdNameStrLen = StrLen(ProductName);\r
+  if (PdNameStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_VERSION);\r
+  Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  VerStrLen = StrLen(Version);\r
+  if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SERIAL_NUMBER);\r
+  SerialNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  SerialNumStrLen = StrLen(SerialNumber);\r
+  if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_INFORMATION;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1);\r
+  //\r
+  // Make handle chosen by smbios protocol.add automatically.\r
+  // \r
+  SmbiosRecord->Hdr.Handle = 0;  \r
+  //\r
+  // Manu will be the 1st optional string following the formatted structure.\r
+  //\r
+  SmbiosRecord->Manufacturer = 1;\r
+  //\r
+  // ProductName will be the 2nd optional string following the formatted structure.\r
+  //\r
+  SmbiosRecord->ProductName = 2;  \r
+  //\r
+  // Version will be the 3rd optional string following the formatted structure.  \r
+  //\r
+  SmbiosRecord->Version = 3;  \r
+  //\r
+  // Version will be the 4th optional string following the formatted structure.\r
+  //\r
+  SmbiosRecord->SerialNumber = 4;\r
+  CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,16);\r
+  SmbiosRecord->WakeUpType = (UINT8)ForType1InputData->SystemWakeupType;\r
+\r
+  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
+  UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);\r
+  UnicodeStrToAsciiStr(ProductName, OptionalStrStart + ManuStrLen + 1);\r
+  UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1);\r
+  UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1);\r
+\r
+  //\r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  SmbiosHandle = 0;\r
+  Status = Smbios-> Add(\r
+                      Smbios, \r
+                      NULL,\r
+                      &SmbiosHandle, \r
+                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
+                      );\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
+}\r
+\r
+/* eof - MiscSystemManufacturerFunction.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionString.uni b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionString.uni
new file mode 100644 (file)
index 0000000..abf2da7
Binary files /dev/null and b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionString.uni differ
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringData.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringData.c
new file mode 100644 (file)
index 0000000..581586b
--- /dev/null
@@ -0,0 +1,32 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MiscSystemOptionStringData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_SYSTEM_OPTION_STRING_DATA, SystemOptionString) = {\r
+  {STRING_TOKEN(STR_MISC_SYSTEM_OPTION_STRING)}\r
+};\r
+\r
+/* eof - MiscSystemOptionStringData.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c
new file mode 100644 (file)
index 0000000..a910634
--- /dev/null
@@ -0,0 +1,83 @@
+/** @file\r
+  BIOS system option string boot time changes.\r
+  SMBIOS type 12.\r
+\r
+  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+\r
+/**\r
+  This function makes boot time changes to the contents of the\r
+  MiscSystemOptionString (Type 12).\r
+\r
+  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
+\r
+  @retval EFI_SUCCESS                All parameters were valid.\r
+  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
+  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
+\r
+**/\r
+MISC_SMBIOS_TABLE_FUNCTION(SystemOptionString)\r
+{\r
+  CHAR8                             *OptionalStrStart;\r
+  UINTN                             OptStrLen;\r
+  EFI_STRING                        OptionString;\r
+  EFI_STATUS                        Status;\r
+  STRING_REF                        TokenToGet;\r
+  EFI_SMBIOS_HANDLE                 SmbiosHandle;\r
+  SMBIOS_TABLE_TYPE12               *SmbiosRecord;\r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (RecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_OPTION_STRING);\r
+  OptionString = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  OptStrLen = StrLen(OptionString);\r
+  if (OptStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
\r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE12);\r
+  //\r
+  // Make handle chosen by smbios protocol.add automatically.\r
+  //\r
+  SmbiosRecord->Hdr.Handle = 0;  \r
+\r
+  SmbiosRecord->StringCount = 1;\r
+  OptionalStrStart = (CHAR8*) (SmbiosRecord + 1);\r
+  UnicodeStrToAsciiStr(OptionString, OptionalStrStart);\r
+  //\r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  SmbiosHandle = 0;\r
+  Status = Smbios-> Add(\r
+                      Smbios, \r
+                      NULL,\r
+                      &SmbiosHandle, \r
+                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
+                      );\r
+\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignation.uni b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignation.uni
new file mode 100644 (file)
index 0000000..45e9ce3
Binary files /dev/null and b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignation.uni differ
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationData.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationData.c
new file mode 100644 (file)
index 0000000..11b2339
--- /dev/null
@@ -0,0 +1,52 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+  \r
+    MiscSystemSlotDesignationData.c\r
+  \r
+Abstract: \r
+\r
+  This driver parses the mMiscSubclassDataTable structure and reports\r
+  any generated data to the DataHub.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+\r
+//\r
+// Static (possibly build generated) Bios Vendor data.\r
+//\r
+MISC_SMBIOS_TABLE_DATA(EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA, MiscSystemSlotDesignation) = {\r
+  STRING_TOKEN(STR_MISC_SYSTEM_SLOT_DESIGNATION),   // SlotDesignation\r
+  EfiSlotTypeOther,         // SlotType\r
+  EfiSlotDataBusWidthOther, // SlotDataBusWidth\r
+  EfiSlotUsageOther,        // SlotUsage\r
+  EfiSlotLengthOther,       // SlotLength\r
+  0,                        // SlotId\r
+  {                         // SlotCharacteristics\r
+    0,                      // CharacteristicsUnknown  :1;\r
+    0,                      // Provides50Volts         :1;\r
+    0,                      // Provides33Volts         :1;\r
+    0,                      // SharedSlot              :1;\r
+    0,                      // PcCard16Supported       :1;\r
+    0,                      // CardBusSupported        :1;\r
+    0,                      // ZoomVideoSupported      :1;\r
+    0,                      // ModemRingResumeSupported:1;\r
+    0,                      // PmeSignalSupported      :1;\r
+    0,                      // HotPlugDevicesSupported :1;\r
+    0,                      // SmbusSignalSupported    :1;\r
+    0                       // Reserved                :21;\r
+  },\r
+  {0, 0, {0, 0}}            // SlotDevicePath\r
+};\r
+\r
+/* eof - MiscSystemSlotsData.c */\r
diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c
new file mode 100644 (file)
index 0000000..72c4137
--- /dev/null
@@ -0,0 +1,97 @@
+/** @file\r
+  BIOS system slot designator information boot time changes.\r
+  SMBIOS type 9.\r
+\r
+  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "MiscSubClassDriver.h"\r
+/**\r
+  This function makes boot time changes to the contents of the\r
+  MiscSystemSlotDesignator structure (Type 9).\r
+\r
+  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
+\r
+  @retval EFI_SUCCESS                All parameters were valid.\r
+  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
+  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
+\r
+**/\r
+MISC_SMBIOS_TABLE_FUNCTION(MiscSystemSlotDesignation)\r
+{\r
+  CHAR8                              *OptionalStrStart;\r
+  UINTN                              SlotDesignationStrLen;\r
+  EFI_STATUS                         Status;\r
+  EFI_STRING                         SlotDesignation;\r
+  STRING_REF                         TokenToGet;\r
+  SMBIOS_TABLE_TYPE9                 *SmbiosRecord;\r
+  EFI_SMBIOS_HANDLE                  SmbiosHandle;\r
+  EFI_MISC_SYSTEM_SLOT_DESIGNATION*  ForType9InputData;\r
+\r
+  ForType9InputData = (EFI_MISC_SYSTEM_SLOT_DESIGNATION *)RecordData;\r
+\r
+  //\r
+  // First check for invalid parameters.\r
+  //\r
+  if (RecordData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  TokenToGet = 0;\r
+  switch (ForType9InputData->SlotDesignation) {\r
+    case STR_MISC_SYSTEM_SLOT_DESIGNATION: \r
+      TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_DESIGNATION);\r
+      break;\r
+    default:\r
+      break;\r
+  }\r
+\r
+  SlotDesignation = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  SlotDesignationStrLen = StrLen(SlotDesignation);\r
+  if (SlotDesignationStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE9) + SlotDesignationStrLen + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE9) +SlotDesignationStrLen + 1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_SLOTS;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE9);\r
+  SmbiosRecord->Hdr.Handle = 0; \r
+  SmbiosRecord->SlotDesignation = 1;\r
+  SmbiosRecord->SlotType = ForType9InputData->SlotType;\r
+  SmbiosRecord->SlotDataBusWidth = ForType9InputData->SlotDataBusWidth;\r
+  SmbiosRecord->CurrentUsage = ForType9InputData->SlotUsage;\r
+  SmbiosRecord->SlotLength = ForType9InputData->SlotLength;\r
+  SmbiosRecord->SlotID = ForType9InputData->SlotId;\r
+  \r
+  //\r
+  // Slot Characteristics\r
+  //\r
+  CopyMem ((UINT8 *) &SmbiosRecord->SlotCharacteristics1,(UINT8 *) &ForType9InputData->SlotCharacteristics,2);\r
+  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
+  UnicodeStrToAsciiStr(SlotDesignation, OptionalStrStart);\r
+  //  \r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  SmbiosHandle = 0;\r
+  Status = Smbios-> Add(\r
+                      Smbios, \r
+                      NULL,\r
+                      &SmbiosHandle, \r
+                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
+                      );\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/RealTimeClockRuntimeDxe/RealTimeClock.c b/EmulatorPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
new file mode 100644 (file)
index 0000000..05c34bd
--- /dev/null
@@ -0,0 +1,305 @@
+/*++\r
+  Emu RTC Architectural Protocol Driver as defined in PI\r
+\r
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+#include <PiDxe.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/EmuThunkLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+#include <Protocol/RealTimeClock.h>\r
+\r
+BOOLEAN\r
+DayValid (\r
+  IN  EFI_TIME  *Time\r
+  );\r
+\r
+BOOLEAN\r
+IsLeapYear (\r
+  IN EFI_TIME   *Time\r
+  );\r
+\r
+EFI_STATUS\r
+RtcTimeFieldsValid (\r
+  IN EFI_TIME *Time\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeRealTimeClock (\r
+  IN EFI_HANDLE                          ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                    *SystemTable\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuGetTime (\r
+  OUT EFI_TIME                                 * Time,\r
+  OUT EFI_TIME_CAPABILITIES                    * Capabilities OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Service routine for RealTimeClockInstance->GetTime \r
+\r
+Arguments:\r
+\r
+  Time          - A pointer to storage that will receive a snapshot of the current time.\r
+\r
+  Capabilities  - A pointer to storage that will receive the capabilities of the real time clock\r
+                  in the platform. This includes the real time clock's resolution and accuracy.  \r
+                  All reported device capabilities are rounded up.  This is an OPTIONAL argument.\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS   - The underlying GetSystemTime call occurred and returned\r
+                  Note that in the NT32 emulation, the GetSystemTime call has no return value\r
+                  thus you will always receive a EFI_SUCCESS on this.\r
+\r
+**/\r
+{\r
+\r
+  //\r
+  // Check parameter for null pointer\r
+  //\r
+  if (Time == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+\r
+  }\r
+\r
+  gEmuThunk->GetTime (Time, Capabilities);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSetTime (\r
+  IN EFI_TIME   *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Service routine for RealTimeClockInstance->SetTime \r
+\r
+Arguments:\r
+\r
+  Time          - A pointer to storage containing the time and date information to\r
+                  program into the real time clock.\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS           - The operation completed successfully.\r
+                  \r
+  EFI_INVALID_PARAMETER - One of the fields in Time is out of range.\r
+\r
+  EFI_DEVICE_ERROR      - The operation could not be complete due to a device error.\r
+\r
+**/\r
+{\r
+  EFI_STATUS            Status;\r
+\r
+  if (Time == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Make sure that the time fields are valid\r
+  //\r
+  Status = RtcTimeFieldsValid (Time);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuGetWakeupTime (\r
+  OUT BOOLEAN        *Enabled,\r
+  OUT BOOLEAN        *Pending,\r
+  OUT EFI_TIME       *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Service routine for RealTimeClockInstance->GetWakeupTime\r
+\r
+Arguments:\r
+  This          - Indicates the protocol instance structure.\r
+\r
+  Enabled       - Indicates if the alarm is currently enabled or disabled.\r
+\r
+  Pending       - Indicates if the alarm signal is pending and requires\r
+                  acknowledgement.\r
+\r
+  Time          - The current alarm setting.\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS           - The operation completed successfully.\r
+                  \r
+  EFI_DEVICE_ERROR      - The operation could not be complete due to a device error.\r
+\r
+  EFI_UNSUPPORTED       - The operation is not supported on this platform.\r
+\r
+**/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuSetWakeupTime (\r
+  IN BOOLEAN      Enable,\r
+  OUT EFI_TIME    *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Service routine for RealTimeClockInstance->SetWakeupTime\r
+\r
+Arguments:\r
+\r
+  Enabled       - Enable or disable the wakeup alarm.\r
+\r
+  Time          - If enable is TRUE, the time to set the wakup alarm for.\r
+                  If enable is FALSE, then this parameter is optional, and\r
+                  may be NULL.\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS           - The operation completed successfully.\r
+                  \r
+  EFI_DEVICE_ERROR      - The operation could not be complete due to a device error.\r
+\r
+  EFI_INVALID_PARAMETER - A field in Time is out of range.\r
+\r
+  EFI_UNSUPPORTED       - The operation is not supported on this platform.\r
+\r
+**/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeRealTimeClock (\r
+  IN EFI_HANDLE                            ImageHandle,\r
+  IN EFI_SYSTEM_TABLE                      *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Install Real Time Clock Protocol \r
+\r
+Arguments:\r
+  ImageHandle - Image Handle\r
+  SystemTable - Pointer to system table\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS - Real Time Clock Services are installed into the Runtime Services Table\r
+\r
+**/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  Handle;\r
+\r
+  SystemTable->RuntimeServices->GetTime       = EmuGetTime;\r
+  SystemTable->RuntimeServices->SetTime       = EmuSetTime;\r
+  SystemTable->RuntimeServices->GetWakeupTime = EmuGetWakeupTime;\r
+  SystemTable->RuntimeServices->SetWakeupTime = EmuSetWakeupTime;\r
+\r
+  Handle = NULL;\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Handle,\r
+                  &gEfiRealTimeClockArchProtocolGuid,\r
+                  NULL,\r
+                  NULL\r
+                  );\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+RtcTimeFieldsValid (\r
+  IN EFI_TIME *Time\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Arguments:\r
\r
+  Returns: \r
+**/\r
+{\r
+  if (Time->Year < 1998 ||\r
+      Time->Year > 2099 ||\r
+      Time->Month < 1 ||\r
+      Time->Month > 12 ||\r
+      (!DayValid (Time)) ||\r
+      Time->Hour > 23 ||\r
+      Time->Minute > 59 ||\r
+      Time->Second > 59 ||\r
+      Time->Nanosecond > 999999999 ||\r
+      (!(Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE || (Time->TimeZone >= -1440 && Time->TimeZone <= 1440))) ||\r
+      (Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT)))\r
+      ) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+BOOLEAN\r
+DayValid (\r
+  IN  EFI_TIME  *Time\r
+  )\r
+{\r
+\r
+  STATIC const INTN  DayOfMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };\r
+\r
+  if (Time->Day < 1 ||\r
+      Time->Day > DayOfMonth[Time->Month - 1] ||\r
+      (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))\r
+      ) {\r
+    return FALSE;\r
+  }\r
+\r
+  return TRUE;\r
+}\r
+\r
+BOOLEAN\r
+IsLeapYear (\r
+  IN EFI_TIME   *Time\r
+  )\r
+{\r
+  if (Time->Year % 4 == 0) {\r
+    if (Time->Year % 100 == 0) {\r
+      if (Time->Year % 400 == 0) {\r
+        return TRUE;\r
+      } else {\r
+        return FALSE;\r
+      }\r
+    } else {\r
+      return TRUE;\r
+    }\r
+  } else {\r
+    return FALSE;\r
+  }\r
+}\r
diff --git a/EmulatorPkg/RealTimeClockRuntimeDxe/RealTimeClock.inf b/EmulatorPkg/RealTimeClockRuntimeDxe/RealTimeClock.inf
new file mode 100644 (file)
index 0000000..bee90cb
--- /dev/null
@@ -0,0 +1,57 @@
+## @file\r
+# Emu Real time clock Architectural Protocol Driver as defined in PI\r
+#\r
+# This real time clock module simulates virtual device by time WinAPI.\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = RealTimeClock\r
+  FILE_GUID                      = f3552032-8985-11db-8429-0040d02b1835\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = InitializeRealTimeClock\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  RealTimeClock.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  EmuThunkLib\r
+  UefiDriverEntryPoint\r
+  UefiLib\r
+  DebugLib\r
+  BaseLib\r
+\r
+\r
+[Protocols]\r
+  gEfiRealTimeClockArchProtocolGuid             # PROTOCOL ALWAYS_PRODUCED\r
+\r
+\r
+[Depex]\r
+  TRUE\r
+\r
diff --git a/EmulatorPkg/ResetRuntimeDxe/Reset.c b/EmulatorPkg/ResetRuntimeDxe/Reset.c
new file mode 100644 (file)
index 0000000..14594c7
--- /dev/null
@@ -0,0 +1,114 @@
+/*++ @file\r
+  Reset Architectural Protocol as defined in UEFI/PI under Emulation\r
+\r
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/EmuThunkLib.h>\r
+\r
+#include <Protocol/Reset.h>\r
+\r
+\r
+VOID\r
+EFIAPI\r
+EmuResetSystem (\r
+  IN EFI_RESET_TYPE   ResetType,\r
+  IN EFI_STATUS       ResetStatus,\r
+  IN UINTN            DataSize,\r
+  IN VOID             *ResetData OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       HandleCount;\r
+  EFI_HANDLE  *HandleBuffer;\r
+  UINTN       Index;\r
+\r
+  //\r
+  // Disconnect all\r
+  //\r
+  Status = gBS->LocateHandleBuffer (\r
+                  AllHandles,\r
+                  NULL,\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &HandleBuffer\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    for (Index = 0; Index < HandleCount; Index++) {\r
+      Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
+    }\r
+  \r
+    gBS->FreePool (HandleBuffer);\r
+  }\r
+\r
+\r
+  //\r
+  // Discard ResetType, always return 0 as exit code\r
+  //\r
+  gEmuThunk->Exit (0);\r
+\r
+  //\r
+  // Should never go here\r
+  //\r
+  ASSERT (FALSE);\r
+\r
+  return;\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeEmuReset (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+\r
+Arguments:\r
+\r
+  ImageHandle of the loaded driver\r
+  Pointer to the System Table\r
+\r
+Returns:\r
+\r
+  Status\r
+**/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  Handle;\r
+\r
+  SystemTable->RuntimeServices->ResetSystem = EmuResetSystem;\r
+\r
+  Handle = NULL;\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Handle,\r
+                  &gEfiResetArchProtocolGuid,\r
+                  NULL,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
+\r
diff --git a/EmulatorPkg/ResetRuntimeDxe/Reset.inf b/EmulatorPkg/ResetRuntimeDxe/Reset.inf
new file mode 100644 (file)
index 0000000..f95822b
--- /dev/null
@@ -0,0 +1,57 @@
+## @file\r
+# Emu Emulation Reset Architectural Protocol Driver as defined in PI\r
+#\r
+# This Reset module simulates system reset by process exit on Emulator.\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuReset\r
+  FILE_GUID                      = 50A18017-37AD-8743-BCF2-DF1A8FF12FAB\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = InitializeEmuReset\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  Reset.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  EmuThunkLib\r
+  UefiDriverEntryPoint\r
+  UefiLib\r
+  DebugLib\r
+  BaseLib\r
+\r
+\r
+[Protocols]\r
+  gEfiResetArchProtocolGuid                     # PROTOCOL ALWAYS_PRODUCED\r
+\r
+\r
+[Depex]\r
+  TRUE\r
+\r
diff --git a/EmulatorPkg/Sec/Ia32/SwitchRam.S b/EmulatorPkg/Sec/Ia32/SwitchRam.S
new file mode 100644 (file)
index 0000000..81e478b
--- /dev/null
@@ -0,0 +1,95 @@
+#------------------------------------------------------------------------------\r
+#\r
+# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http:#opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+# Module Name:\r
+#\r
+#   Stack.asm\r
+#\r
+# Abstract:\r
+#\r
+#   Switch the stack from temporary memory to permenent memory.\r
+#\r
+#------------------------------------------------------------------------------\r
+\r
+ .text\r
\r
+\r
+//------------------------------------------------------------------------------\r
+// VOID\r
+// EFIAPI\r
+// SecSwitchStack (\r
+//   UINT32   TemporaryMemoryBase,\r
+//   UINT32   PermenentMemoryBase\r
+//   )//\r
+//------------------------------------------------------------------------------    \r
+ASM_GLOBAL ASM_PFX(SecSwitchStack)\r
+ASM_PFX(SecSwitchStack):\r
+#\r
+# Save three register: eax, ebx, ecx\r
+#    \r
+    push  %eax\r
+    push  %ebx\r
+    push  %ecx\r
+    push  %edx\r
+    \r
+#\r
+# !!CAUTION!! this function address's is pushed into stack after\r
+# migration of whole temporary memory, so need save it to permenent\r
+# memory at first!\r
+#    \r
+    \r
+    movl  20(%esp), %ebx            # Save the first parameter\r
+    movl  24(%esp), %ecx            # Save the second parameter\r
+    \r
+#\r
+# Save this function's return address into permenent memory at first.\r
+# Then, Fixup the esp point to permenent memory\r
+#\r
+\r
+    movl  %esp, %eax\r
+    subl  %ebx, %eax\r
+    addl  %ecx, %eax\r
+    movl  (%esp), %edx                 # copy pushed register's value to permenent memory\r
+    movl  %edx, (%eax)\r
+    movl  4(%esp), %edx\r
+    movl  %edx, 4(%eax)\r
+    movl  8(%esp), %edx\r
+    movl  %edx, 8(%eax)\r
+    movl  12(%esp), %edx\r
+    movl  %edx, 12(%eax)\r
+    movl  16(%esp), %edx\r
+    movl  %edx, 16(%eax)\r
+    movl  %eax, %esp                   # From now, esp is pointed to permenent memory\r
+\r
+#\r
+# Fixup the ebp point to permenent memory\r
+#\r
+#ifndef __APPLE__\r
+    movl   %ebp, %eax\r
+    subl   %ebx, %eax\r
+    addl   %ecx, %eax\r
+    movl   %eax, %ebp                  # From now, ebp is pointed to permenent memory\r
+    \r
+#\r
+# Fixup callee's ebp point for PeiDispatch\r
+#    \r
+    movl   (%ebp), %eax\r
+    subl   %ebx, %eax\r
+    addl   %ecx, %eax\r
+    movl   %eax, (%ebp)                # From now, Temporary's PPI caller's stack is in permenent memory\r
+#endif    \r
+    \r
+    pop   %edx\r
+    pop   %ecx\r
+    pop   %ebx\r
+    pop   %eax\r
+    ret\r
+\r
diff --git a/EmulatorPkg/Sec/Ia32/TempRam.c b/EmulatorPkg/Sec/Ia32/TempRam.c
new file mode 100644 (file)
index 0000000..525fb95
--- /dev/null
@@ -0,0 +1,65 @@
+/*++ @file
+  Temp RAM PPI
+
+Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
+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 <PiPei.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+
+#include <Ppi/TemporaryRamSupport.h>
+
+VOID
+EFIAPI
+SecSwitchStack (
+  UINT32   TemporaryMemoryBase,
+  UINT32   PermenentMemoryBase
+  );
+
+
+EFI_STATUS
+EFIAPI
+SecTemporaryRamSupport (
+  IN CONST EFI_PEI_SERVICES   **PeiServices,
+  IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,
+  IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,
+  IN UINTN                    CopySize
+  )
+{
+  //
+  // Migrate the whole temporary memory to permenent memory.
+  //
+  CopyMem (
+    (VOID*)(UINTN)PermanentMemoryBase,
+    (VOID*)(UINTN)TemporaryMemoryBase,
+    CopySize
+    );
+
+  //
+  // SecSwitchStack function must be invoked after the memory migration
+  // immediatly, also we need fixup the stack change caused by new call into
+  // permenent memory.
+  //
+  SecSwitchStack ((UINT32) TemporaryMemoryBase, (UINT32) PermanentMemoryBase);
+
+  //
+  // We need *not* fix the return address because currently,
+  // The PeiCore is excuted in flash.
+  //
+
+  //
+  // Simulate to invalid temporary memory, terminate temporary memory
+  //
+  //ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize);
+
+  return EFI_SUCCESS;
+}
diff --git a/EmulatorPkg/Sec/Sec.c b/EmulatorPkg/Sec/Sec.c
new file mode 100644 (file)
index 0000000..4468d6f
--- /dev/null
@@ -0,0 +1,149 @@
+/*++ @file
+  Stub SEC that is called from the OS appliation that is the root of the emulator.
+  
+  The OS application will call the SEC with the PEI Entry Point API.  
+
+Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
+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 "Sec.h"
+
+
+
+EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = { 
+  SecTemporaryRamSupport
+};
+
+
+EFI_PEI_PPI_DESCRIPTOR  gPrivateDispatchTable[] = {
+  {
+    EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+    &gEfiTemporaryRamSupportPpiGuid,
+    &mSecTemporaryRamSupportPpi
+  }
+};
+
+
+
+/**
+  The entry point of PE/COFF Image for the PEI Core, that has been hijacked by this
+  SEC that sits on top of an OS application. So the entry and exit of this module 
+  has the same API. 
+
+  This function is the entry point for the PEI Foundation, which allows the SEC phase
+  to pass information about the stack, temporary RAM and the Boot Firmware Volume.
+  In addition, it also allows the SEC phase to pass services and data forward for use
+  during the PEI phase in the form of one or more PPIs.
+  There is no limit to the number of additional PPIs that can be passed from SEC into
+  the PEI Foundation. As part of its initialization phase, the PEI Foundation will add
+  these SEC-hosted PPIs to its PPI database such that both the PEI Foundation and any
+  modules can leverage the associated service calls and/or code in these early PPIs.
+  This function is required to call ProcessModuleEntryPointList() with the Context
+  parameter set to NULL.  ProcessModuleEntryPoint() is never expected to return.
+  The PEI Core is responsible for calling ProcessLibraryConstructorList() as soon as
+  the PEI Services Table and the file handle for the PEI Core itself have been established.
+  If ProcessModuleEntryPointList() returns, then ASSERT() and halt the system.
+
+  @param SecCoreData  Points to a data structure containing information about the PEI
+                      core's operating environment, such as the size and location of
+                      temporary RAM, the stack location and the BFV location. 
+
+  @param PpiList      Points to a list of one or more PPI descriptors to be installed
+                      initially by the PEI core. An empty PPI list consists of a single
+                      descriptor with the end-tag EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST.
+                      As part of its initialization phase, the PEI Foundation will add
+                      these SEC-hosted PPIs to its PPI database such that both the PEI
+                      Foundation and any modules can leverage the associated service calls
+                      and/or code in these early PPIs.
+
+**/
+VOID 
+EFIAPI
+_ModuleEntryPoint (
+  IN EFI_SEC_PEI_HAND_OFF   *SecCoreData,
+  IN EFI_PEI_PPI_DESCRIPTOR *PpiList 
+  )
+{
+  EFI_STATUS                Status;
+  EFI_PEI_FV_HANDLE         VolumeHandle;
+  EFI_PEI_FILE_HANDLE       FileHandle;
+  VOID                      *PeCoffImage;
+  EFI_PEI_CORE_ENTRY_POINT  EntryPoint;
+  EFI_PEI_PPI_DESCRIPTOR    *Ppi;
+  EFI_PEI_PPI_DESCRIPTOR    *SecPpiList;
+  UINTN                     SecReseveredMemorySize;
+  UINTN                     Index;
+  
+  EMU_MAGIC_PAGE()->PpiList = PpiList;
+  ProcessLibraryConstructorList ();
+  
+  DEBUG ((EFI_D_ERROR, "SEC Has Started\n"));
+  
+  //
+  // Add Our PPIs to the list
+  //
+  SecReseveredMemorySize = sizeof (gPrivateDispatchTable);
+  for (Ppi = PpiList, Index = 1; ; Ppi++, Index++) {
+    SecReseveredMemorySize += sizeof (EFI_PEI_PPI_DESCRIPTOR);
+  
+    if ((Ppi->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {
+      // Since we are appending, need to clear out privious list terminator.
+      Ppi->Flags &= ~EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST; 
+      break;
+    }
+  }
+  
+  // Keep everything on a good alignment
+  SecReseveredMemorySize = ALIGN_VALUE (SecReseveredMemorySize, CPU_STACK_ALIGNMENT);
+  
+#if 0
+  // Tell the PEI Core to not use our buffer in temp RAM
+  SecPpiList = (EFI_PEI_PPI_DESCRIPTOR *)SecCoreData->PeiTemporaryRamBase;
+  SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + SecReseveredMemorySize);
+  SecCoreData->PeiTemporaryRamSize -= SecReseveredMemorySize;
+#else
+  {
+    //
+    // When I subtrack from SecCoreData->PeiTemporaryRamBase PEI Core crashes? Either there is a bug
+    // or I don't understand temp RAM correctly?
+    //
+    EFI_PEI_PPI_DESCRIPTOR    PpiArray[10];
+    
+    SecPpiList = &PpiArray[0];
+    ASSERT (sizeof (PpiArray) >= SecReseveredMemorySize);
+  }
+#endif
+  // Copy existing list, and append our entries. 
+  CopyMem (SecPpiList, PpiList, sizeof (EFI_PEI_PPI_DESCRIPTOR) * Index);
+  CopyMem (&SecPpiList[Index], gPrivateDispatchTable, sizeof (gPrivateDispatchTable));
+
+  // Find PEI Core and transfer control
+  VolumeHandle = (EFI_PEI_FV_HANDLE)(UINTN)SecCoreData->BootFirmwareVolumeBase;
+  FileHandle   = NULL;
+  Status = PeiServicesFfsFindNextFile (EFI_FV_FILETYPE_PEI_CORE, VolumeHandle, &FileHandle);
+  ASSERT_EFI_ERROR (Status);
+  
+  Status = PeiServicesFfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffImage);
+  ASSERT_EFI_ERROR (Status);
+
+  Status = PeCoffLoaderGetEntryPoint (PeCoffImage, (VOID **)&EntryPoint);
+  ASSERT_EFI_ERROR (Status);
+  
+  // Transfer control to PEI Core
+  EntryPoint (SecCoreData, SecPpiList);
+  
+  // PEI Core never returns
+  ASSERT (FALSE);
+  return;
+}
+
+
+
diff --git a/EmulatorPkg/Sec/Sec.h b/EmulatorPkg/Sec/Sec.h
new file mode 100644 (file)
index 0000000..0076012
--- /dev/null
@@ -0,0 +1,51 @@
+/*++ @file
+  Stub SEC that is called from the OS appliation that is the root of the emulator.
+  
+  The OS application will call the SEC with the PEI Entry Point API.  
+
+Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
+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 __SEC_H___
+#define __SEC_H___
+
+
+#include <PiPei.h>
+#include <Library/EmuMagicPageLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/PeCoffGetEntryPointLib.h>
+#include <Library/BaseMemoryLib.h>
+
+#include <Ppi/TemporaryRamSupport.h>
+
+
+//
+// I think this shold be defined in a MdePkg include file?
+//
+VOID
+EFIAPI
+ProcessLibraryConstructorList (
+  VOID
+  );
+
+EFI_STATUS
+EFIAPI
+SecTemporaryRamSupport (
+  IN CONST EFI_PEI_SERVICES   **PeiServices,
+  IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,
+  IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,
+  IN UINTN                    CopySize
+  );
+
+
+#endif
+
diff --git a/EmulatorPkg/Sec/Sec.inf b/EmulatorPkg/Sec/Sec.inf
new file mode 100644 (file)
index 0000000..b17caea
--- /dev/null
@@ -0,0 +1,50 @@
+## @file\r
+# Entry Point of Emu Emulator\r
+#\r
+# Main executable file of Unix Emulator that loads PEI core after initialization finished.\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuSec\r
+  FILE_GUID                      = BCAF98C9-22B0-3B4F-9CBD-C8A6B4DBCEE9\r
+  MODULE_TYPE                    = SEC\r
+  VERSION_STRING                 = 1.0\r
+\r
+\r
+[Sources]\r
+  Sec.c\r
+\r
+[Sources.X64]\r
+  X64/SwitchRam.S\r
+\r
+[Sources.IA32]\r
+  Ia32/TempRam.c\r
+  Ia32/SwitchRam.S\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+  PeCoffGetEntryPointLib\r
+  PeiServicesLib\r
+  PpiListLib\r
+  BaseMemoryLib\r
+\r
+[Ppis]\r
+  gEfiTemporaryRamSupportPpiGuid\r
+  \r
+[Pcd]\r
+  gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage\r
diff --git a/EmulatorPkg/Sec/X64/SwitchRam.S b/EmulatorPkg/Sec/X64/SwitchRam.S
new file mode 100644 (file)
index 0000000..a7219bf
--- /dev/null
@@ -0,0 +1,72 @@
+#------------------------------------------------------------------------------\r
+#\r
+# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+# Portitions copyright (c) 2011, Apple Inc. All rights reserved.\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php.\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#------------------------------------------------------------------------------\r
+\r
+\r
+\r
+//  EFI_STATUS\r
+//  EFIAPI\r
+//  SecTemporaryRamSupport (\r
+//    IN CONST EFI_PEI_SERVICES   **PeiServices,         // %rcx\r
+//    IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,   // %rdx\r
+//    IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,   // %r8 \r
+//    IN UINTN                    CopySize               // %r9\r
+//    )\r
+//\r
+ASM_GLOBAL ASM_PFX(SecTemporaryRamSupport)\r
+ASM_PFX(SecTemporaryRamSupport):\r
+  // Adjust callers %rbp to account for stack move\r
+  subq    %rdx, %rbp     // Calc offset of %rbp in Temp Memory\r
+  addq    %r8,  %rbp     // add in permanent base to offset\r
+  \r
+  pushq   %rbp           // stack frame is for the debugger\r
+  movq    %rsp, %rbp\r
+\r
+  pushq   %rdx          // Save TemporaryMemoryBase\r
+  pushq   %r8           // Save PermanentMemoryBase\r
+  pushq   %r9           // Save CopySize\r
+\r
+  //\r
+  // Copy all of temp RAM to permanent memory, including stack\r
+  //\r
+  // CopyMem (PermanentMemoryBase, TemporaryMemoryBase, CopySize);\r
+  //          %rcx,                %rdx,                %r8\r
+  movq    %r8,  %rcx    // Shift arguments\r
+  movq    %r9,  %r8\r
+  subq    $0x28, %rsp   // Allocate register spill area & 16-byte align stack\r
+  call    ASM_PFX(CopyMem)\r
+  // Temp mem stack now copied to permanent location. %esp still in temp memory\r
+  addq    $0x28, %rsp\r
+\r
+  popq    %r9           // CopySize (old stack)\r
+  popq    %r8           // PermanentMemoryBase (old stack)\r
+  popq    %rdx          // TemporaryMemoryBase (old stack)\r
+    \r
+  movq    %rsp, %rcx    // Move to new stack\r
+  subq    %rdx, %rcx    // Calc offset of stack in Temp Memory\r
+  addq    %r8,  %rcx    // Calc PermanentMemoryBase address\r
+  movq    %rcx, %rsp    // Update stack \r
+  // Stack now points to permanent memory\r
+  \r
+  // ZeroMem (TemporaryMemoryBase /* rcx */, CopySize /* rdx */);\r
+  movq    %rdx, %rcx\r
+  movq    %r9,  %rdx\r
+  subq    $0x28, %rsp   // Allocate register spill area & 16-byte align stack\r
+  call    ASM_PFX(ZeroMem)\r
+  addq    $0x28, %rsp\r
+\r
+  // This data comes off the NEW stack\r
+  popq    %rbp\r
+  ret\r
+\r
+\r
diff --git a/EmulatorPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.c b/EmulatorPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.c
new file mode 100644 (file)
index 0000000..b2b7801
--- /dev/null
@@ -0,0 +1,74 @@
+/*++ @file\r
+  UEFI/PI PEIM to abstract construction of firmware volume in a Unix environment.\r
+\r
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+\r
+#include <Ppi/EmuThunk.h>\r
+#include <Protocol/EmuThunk.h>\r
+\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiInitialzeThunkPpiToProtocolPei (\r
+  IN       EFI_PEI_FILE_HANDLE       FileHandle,\r
+  IN CONST EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Perform a call-back into the SEC simulator to get Unix Stuff\r
+\r
+Arguments:\r
+\r
+  PeiServices - General purpose services available to every PEIM.\r
+    \r
+Returns:\r
+\r
+  None\r
+\r
+**/\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_PEI_PPI_DESCRIPTOR  *PpiDescriptor;\r
+  EMU_THUNK_PPI           *Thunk;\r
+  VOID                    *Ptr;\r
+\r
+  DEBUG ((EFI_D_ERROR, "Emu Thunk PEIM Loaded\n"));\r
+\r
+  Status = PeiServicesLocatePpi (\r
+              &gEmuThunkPpiGuid,        // GUID\r
+              0,                        // INSTANCE\r
+              &PpiDescriptor,           // EFI_PEI_PPI_DESCRIPTOR\r
+              (VOID **)&Thunk           // PPI\r
+              );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Ptr = Thunk->Thunk ();\r
+\r
+  BuildGuidDataHob (\r
+    &gEmuThunkProtocolGuid,              // Guid\r
+    &Ptr,                                // Buffer\r
+    sizeof (VOID *)                      // Sizeof Buffer\r
+    );\r
+  return Status;\r
+}\r
diff --git a/EmulatorPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.inf b/EmulatorPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.inf
new file mode 100644 (file)
index 0000000..a3dece4
--- /dev/null
@@ -0,0 +1,55 @@
+## @file\r
+# Stuff driver\r
+#\r
+# Tiano PEIM to abstract construction of firmware volume in a Emu environment.\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = ThunkPpiToProtocolPei\r
+  FILE_GUID                      = C32A66D5-D8B7-2640-B768-082C8F083C37\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = PeiInitialzeThunkPpiToProtocolPei\r
+\r
+\r
+[Sources]\r
+  ThunkPpiToProtocolPei.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+  PeiServicesTablePointerLib\r
+  PeiServicesLib\r
+  HobLib\r
+  PeimEntryPoint\r
+  DebugLib\r
+\r
+\r
+[Protocols]\r
+  gEmuThunkProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED\r
+\r
+\r
+[Ppis]\r
+  gEmuThunkPpiGuid                          # PPI ALWAYS_CONSUMED\r
+\r
+\r
+[Depex]\r
+  gEmuThunkPpiGuid AND gEfiPeiMemoryDiscoveredPpiGuid\r
+\r
diff --git a/EmulatorPkg/TimerDxe/Timer.c b/EmulatorPkg/TimerDxe/Timer.c
new file mode 100644 (file)
index 0000000..d19ced7
--- /dev/null
@@ -0,0 +1,352 @@
+/*++ @file\r
+  Emu Emulation Timer Architectural Protocol Driver as defined in DXE CIS\r
+\r
+  This Timer module uses an Emu Thread to simulate the timer-tick driven\r
+  timer service.  In the future, the Thread creation should possibly be\r
+  abstracted by the CPU architectural protocol\r
+\r
+Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+\r
+**/\r
+\r
+#include "PiDxe.h"\r
+#include <Protocol/Timer.h>\r
+#include <Protocol/Cpu.h>\r
+#include "Timer.h"\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/EmuThunkLib.h>\r
+\r
+//\r
+// Pointer to the CPU Architectural Protocol instance\r
+//\r
+EFI_CPU_ARCH_PROTOCOL   *mCpu;\r
+\r
+//\r
+// The Timer Architectural Protocol that this driver produces\r
+//\r
+EFI_TIMER_ARCH_PROTOCOL mTimer = {\r
+  EmuTimerDriverRegisterHandler,\r
+  EmuTimerDriverSetTimerPeriod,\r
+  EmuTimerDriverGetTimerPeriod,\r
+  EmuTimerDriverGenerateSoftInterrupt\r
+};\r
+\r
+//\r
+// The notification function to call on every timer interrupt\r
+//\r
+EFI_TIMER_NOTIFY        mTimerNotifyFunction = NULL;\r
+\r
+//\r
+// The current period of the timer interrupt\r
+//\r
+UINT64                  mTimerPeriodMs;\r
+\r
+\r
+VOID\r
+EFIAPI\r
+TimerCallback (UINT64 DeltaMs)\r
+{\r
+  EFI_TPL           OriginalTPL;\r
+  EFI_TIMER_NOTIFY  CallbackFunction;\r
+\r
+\r
+  OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+\r
+  if (OriginalTPL < TPL_HIGH_LEVEL) {\r
+    CallbackFunction = mTimerNotifyFunction;\r
+\r
+    //\r
+    // Only invoke the callback function if a Non-NULL handler has been\r
+    // registered. Assume all other handlers are legal.\r
+    //\r
+    if (CallbackFunction != NULL) {\r
+      CallbackFunction ((UINT64) (DeltaMs * 10000));\r
+    }\r
+  }\r
+\r
+  gBS->RestoreTPL (OriginalTPL);\r
+\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuTimerDriverRegisterHandler (\r
+  IN EFI_TIMER_ARCH_PROTOCOL           *This,\r
+  IN EFI_TIMER_NOTIFY                  NotifyFunction\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function registers the handler NotifyFunction so it is called every time\r
+  the timer interrupt fires.  It also passes the amount of time since the last\r
+  handler call to the NotifyFunction.  If NotifyFunction is NULL, then the\r
+  handler is unregistered.  If the handler is registered, then EFI_SUCCESS is\r
+  returned.  If the CPU does not support registering a timer interrupt handler,\r
+  then EFI_UNSUPPORTED is returned.  If an attempt is made to register a handler\r
+  when a handler is already registered, then EFI_ALREADY_STARTED is returned.\r
+  If an attempt is made to unregister a handler when a handler is not registered,\r
+  then EFI_INVALID_PARAMETER is returned.  If an error occurs attempting to\r
+  register the NotifyFunction with the timer interrupt, then EFI_DEVICE_ERROR\r
+  is returned.\r
+\r
+Arguments:\r
+\r
+  This           - The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  NotifyFunction - The function to call when a timer interrupt fires.  This\r
+                   function executes at TPL_HIGH_LEVEL.  The DXE Core will\r
+                   register a handler for the timer interrupt, so it can know\r
+                   how much time has passed.  This information is used to\r
+                   signal timer based events.  NULL will unregister the handler.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The timer handler was registered.\r
+\r
+  EFI_UNSUPPORTED       - The platform does not support timer interrupts.\r
+\r
+  EFI_ALREADY_STARTED   - NotifyFunction is not NULL, and a handler is already\r
+                          registered.\r
+\r
+  EFI_INVALID_PARAMETER - NotifyFunction is NULL, and a handler was not\r
+                          previously registered.\r
+\r
+  EFI_DEVICE_ERROR      - The timer handler could not be registered.\r
+\r
+**/\r
+{\r
+  //\r
+  // Check for invalid parameters\r
+  //\r
+  if (NotifyFunction == NULL && mTimerNotifyFunction == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (NotifyFunction != NULL && mTimerNotifyFunction != NULL) {\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+\r
+  if (NotifyFunction == NULL) {\r
+    /* Disable timer.  */\r
+    gEmuThunk->SetTimer (0, TimerCallback);\r
+  } else if (mTimerNotifyFunction == NULL) {\r
+    /* Enable Timer.  */\r
+    gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);\r
+  }\r
+  mTimerNotifyFunction = NotifyFunction;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuTimerDriverSetTimerPeriod (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  IN UINT64                   TimerPeriod\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function adjusts the period of timer interrupts to the value specified\r
+  by TimerPeriod.  If the timer period is updated, then the selected timer\r
+  period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned.  If\r
+  the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.\r
+  If an error occurs while attempting to update the timer period, then the\r
+  timer hardware will be put back in its state prior to this call, and\r
+  EFI_DEVICE_ERROR is returned.  If TimerPeriod is 0, then the timer interrupt\r
+  is disabled.  This is not the same as disabling the CPU's interrupts.\r
+  Instead, it must either turn off the timer hardware, or it must adjust the\r
+  interrupt controller so that a CPU interrupt is not generated when the timer\r
+  interrupt fires.\r
+\r
+Arguments:\r
+\r
+  This        - The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  TimerPeriod - The rate to program the timer interrupt in 100 nS units.  If\r
+                the timer hardware is not programmable, then EFI_UNSUPPORTED is\r
+                returned.  If the timer is programmable, then the timer period\r
+                will be rounded up to the nearest timer period that is supported\r
+                by the timer hardware.  If TimerPeriod is set to 0, then the\r
+                timer interrupts will be disabled.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS      - The timer period was changed.\r
+\r
+  EFI_UNSUPPORTED  - The platform cannot change the period of the timer interrupt.\r
+\r
+  EFI_DEVICE_ERROR - The timer period could not be changed due to a device error.\r
+\r
+**/\r
+{\r
+\r
+  //\r
+  // If TimerPeriod is 0, then the timer thread should be canceled\r
+  // If the TimerPeriod is valid, then create and/or adjust the period of the timer thread\r
+  //\r
+  if (TimerPeriod == 0\r
+      || ((TimerPeriod > TIMER_MINIMUM_VALUE)\r
+    && (TimerPeriod < TIMER_MAXIMUM_VALUE))) {\r
+    mTimerPeriodMs = DivU64x32 (TimerPeriod + 5000, 10000);\r
+\r
+    gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuTimerDriverGetTimerPeriod (\r
+  IN EFI_TIMER_ARCH_PROTOCOL            *This,\r
+  OUT UINT64                            *TimerPeriod\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function retrieves the period of timer interrupts in 100 ns units,\r
+  returns that value in TimerPeriod, and returns EFI_SUCCESS.  If TimerPeriod\r
+  is NULL, then EFI_INVALID_PARAMETER is returned.  If a TimerPeriod of 0 is\r
+  returned, then the timer is currently disabled.\r
+\r
+Arguments:\r
+\r
+  This        - The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+  TimerPeriod - A pointer to the timer period to retrieve in 100 ns units.  If\r
+                0 is returned, then the timer is currently disabled.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The timer period was returned in TimerPeriod.\r
+\r
+  EFI_INVALID_PARAMETER - TimerPeriod is NULL.\r
+\r
+**/\r
+{\r
+  if (TimerPeriod == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *TimerPeriod = mTimerPeriodMs * 10000;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuTimerDriverGenerateSoftInterrupt (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function generates a soft timer interrupt. If the platform does not support soft\r
+  timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned.\r
+  If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler()\r
+  service, then a soft timer interrupt will be generated. If the timer interrupt is\r
+  enabled when this service is called, then the registered handler will be invoked. The\r
+  registered handler should not be able to distinguish a hardware-generated timer\r
+  interrupt from a software-generated timer interrupt.\r
+\r
+Arguments:\r
+\r
+  This  -  The EFI_TIMER_ARCH_PROTOCOL instance.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS       - The soft timer interrupt was generated.\r
+\r
+  EFI_UNSUPPORTEDT  - The platform does not support the generation of soft timer interrupts.\r
+\r
+**/\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuTimerDriverInitialize (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize the Timer Architectural Protocol driver\r
+\r
+Arguments:\r
+\r
+  ImageHandle - ImageHandle of the loaded driver\r
+\r
+  SystemTable - Pointer to the System Table\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Timer Architectural Protocol created\r
+\r
+  EFI_OUT_OF_RESOURCES  - Not enough resources available to initialize driver.\r
+\r
+  EFI_DEVICE_ERROR      - A device error occured attempting to initialize the driver.\r
+\r
+**/\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  Handle;\r
+\r
+  //\r
+  // Make sure the Timer Architectural Protocol is not already installed in the system\r
+  //\r
+  ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiTimerArchProtocolGuid);\r
+\r
+  //\r
+  // Get the CPU Architectural Protocol instance\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (void *)&mCpu);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Start the timer thread at the default timer period\r
+  //\r
+  Status = mTimer.SetTimerPeriod (&mTimer, DEFAULT_TIMER_TICK_DURATION);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Install the Timer Architectural Protocol onto a new handle\r
+  //\r
+  Handle = NULL;\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &Handle,\r
+                  &gEfiTimerArchProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &mTimer\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/EmulatorPkg/TimerDxe/Timer.h b/EmulatorPkg/TimerDxe/Timer.h
new file mode 100644 (file)
index 0000000..27fc676
--- /dev/null
@@ -0,0 +1,73 @@
+/*++ @file\r
+  Emu Emulation Architectural Protocol Driver as defined in UEFI/PI.\r
+  This Timer module uses an UNIX Thread to simulate the timer-tick driven\r
+  timer service.\r
+\r
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+**/\r
+\r
+#ifndef _TIMER_H_\r
+#define _TIMER_H_\r
+\r
+\r
+\r
+\r
+//\r
+// Legal timer value range in 100 ns units\r
+//\r
+#define TIMER_MINIMUM_VALUE 0\r
+#define TIMER_MAXIMUM_VALUE (0x100000000ULL - 1)\r
+\r
+//\r
+// Default timer value in 100 ns units (50 ms)\r
+//\r
+#define DEFAULT_TIMER_TICK_DURATION 500000\r
+\r
+//\r
+// Function Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+EmuTimerDriverInitialize (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuTimerDriverRegisterHandler (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  IN EFI_TIMER_NOTIFY         NotifyFunction\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuTimerDriverSetTimerPeriod (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
+  IN UINT64                   TimerPeriod\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuTimerDriverGetTimerPeriod (\r
+  IN EFI_TIMER_ARCH_PROTOCOL   *This,\r
+  OUT UINT64                   *TimerPeriod\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EmuTimerDriverGenerateSoftInterrupt (\r
+  IN EFI_TIMER_ARCH_PROTOCOL  *This\r
+  );\r
+\r
+#endif\r
diff --git a/EmulatorPkg/TimerDxe/Timer.inf b/EmulatorPkg/TimerDxe/Timer.inf
new file mode 100644 (file)
index 0000000..b18be56
--- /dev/null
@@ -0,0 +1,59 @@
+## @file\r
+# Emu Emulation Timer Architectural Protocol Driver as defined in DXE CIS\r
+#\r
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = EmuTimer\r
+  FILE_GUID                      = 87E1BB14-4D5C-7C4E-A90E-E1415687D062\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = EmuTimerDriverInitialize\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  Timer.c\r
+  Timer.h\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  EmuThunkLib\r
+  UefiDriverEntryPoint\r
+  UefiLib\r
+  DebugLib\r
+  BaseLib\r
+\r
+\r
+[Protocols]\r
+  gEfiCpuArchProtocolGuid                       # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiTimerArchProtocolGuid                     # PROTOCOL ALWAYS_PRODUCED\r
+\r
+\r
+[Depex]\r
+  gEfiCpuArchProtocolGuid\r
+\r
diff --git a/EmulatorPkg/Unix/.gdbinit b/EmulatorPkg/Unix/.gdbinit
new file mode 100644 (file)
index 0000000..173818c
--- /dev/null
@@ -0,0 +1,8 @@
+set confirm off
+set output-radix 16
+b SecGdbScriptBreak
+command
+silent
+source SecMain.gdb
+c
+end
diff --git a/EmulatorPkg/Unix/GdbRun b/EmulatorPkg/Unix/GdbRun
new file mode 100644 (file)
index 0000000..428e655
--- /dev/null
@@ -0,0 +1,79 @@
+## @file
+# GDB startup script
+#
+# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+#
+# 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.
+#
+##
+
+#
+# Gdb will set $_exitcode when the program exits.  Pre-init it to an unlikely
+# return value.
+#
+set $_exitcode = 42
+
+#
+# Gdb will call hook-stop on each break.  Check to see if $_exitcode was
+# changed from the value we pre-initialized it to.  If so, the program
+# had exited, so gdb should now quit.
+#
+define hook-stop
+  if $_exitcode != 42
+    quit
+  else
+    source SecMain.gdb
+  end
+end
+
+#
+# We keep track of the number of symbol files we have loaded via gdb
+# scripts in the $SymbolFilesAdded variable
+#
+set $SymbolFileChangesCount = 0
+
+#
+# This macro adds a symbols file for gdb
+#
+# @param  $arg0 - Symbol file changes number
+# @param  $arg1 - Symbol file name
+# @param  $arg2 - Image address
+#
+define AddFirmwareSymbolFile
+  if $SymbolFileChangesCount < $arg0
+    add-symbol-file $arg1 $arg2
+    set $SymbolFileChangesCount = $arg0
+  end
+end
+
+#
+# This macro removes a symbols file for gdb
+#
+# @param  $arg0 - Symbol file changes number
+# @param  $arg1 - Symbol file name
+#
+define RemoveFirmwareSymbolFile
+  if $SymbolFileChangesCount < $arg0
+    #
+    # Currently there is not a method to remove a single symbol file
+    #
+    set $SymbolFileChangesCount = $arg0
+  end
+end
+
+if gInXcode == 1
+  # in Xcode the program is already runing. Issuing a run command 
+  # will cause a fatal debugger error. The break point sciprt that
+  # is used to source this script sets gInCode to 1. 
+else
+  #
+  # Start the program running
+  #
+  run
+end
diff --git a/EmulatorPkg/Unix/Host/BerkeleyPacketFilter.c b/EmulatorPkg/Unix/Host/BerkeleyPacketFilter.c
new file mode 100644 (file)
index 0000000..519d394
--- /dev/null
@@ -0,0 +1,1111 @@
+/**@file\r
+ Berkeley Packet Filter implementation of the EMU_SNP_PROTOCOL that allows the \r
+ emulator to get on real networks.\r
+\r
+ Tested on Mac OS X. \r
+\r
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Portitions copyright (c) 2011, Apple Inc. All rights reserved.\r
+\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+\r
+#include "SecMain.h"\r
+\r
+#ifdef __APPLE__\r
+\r
+\r
+#include <Library/NetLib.h>\r
+\r
+\r
+#define EMU_SNP_PRIVATE_SIGNATURE SIGNATURE_32('E', 'M', 's', 'n')\r
+typedef struct {\r
+  UINTN                       Signature;\r
+\r
+  EMU_IO_THUNK_PROTOCOL       *Thunk;\r
+  EMU_SNP_PROTOCOL            EmuSnp;\r
+  EFI_SIMPLE_NETWORK_MODE     *Mode;\r
+\r
+  int                         BpfFd;\r
+  char                        *InterfaceName;\r
+  EFI_MAC_ADDRESS             MacAddress;\r
+  u_int                       ReadBufferSize;\r
+  VOID                        *ReadBuffer;\r
+\r
+  //\r
+  // Two walking pointers to manage the multiple packets that can be returned\r
+  // in a single read.\r
+  //\r
+  VOID                        *CurrentReadPointer;\r
+  VOID                        *EndReadPointer;\r
+\r
+       UINT32                                                                      ReceivedPackets;\r
+       UINT32                                                                      DroppedPackets;\r
+\r
+} EMU_SNP_PRIVATE;\r
+\r
+#define EMU_SNP_PRIVATE_DATA_FROM_THIS(a) \\r
+         CR(a, EMU_SNP_PRIVATE, EmuSnp, EMU_SNP_PRIVATE_SIGNATURE)\r
+\r
+\r
+//\r
+// Strange, but there doesn't appear to be any structure for the Ethernet header in edk2...\r
+//\r
+\r
+typedef struct {\r
+  UINT8   DstAddr[NET_ETHER_ADDR_LEN];\r
+  UINT8   SrcAddr[NET_ETHER_ADDR_LEN];\r
+  UINT16  Type;\r
+} ETHERNET_HEADER;\r
+\r
+/**\r
+  Register storage for SNP Mode.\r
+\r
+  @param  This Protocol instance pointer.\r
+  @param  Mode SimpleNetworkProtocol Mode structure passed into driver.\r
+\r
+  @retval EFI_SUCCESS           The network interface was started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpCreateMapping (\r
+  IN     EMU_SNP_PROTOCOL         *This,\r
+  IN     EFI_SIMPLE_NETWORK_MODE  *Mode\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Private->Mode = Mode;\r
+  \r
+  //\r
+  // Set the broadcast address.\r
+  //\r
+  SetMem (&Mode->BroadcastAddress, sizeof (EFI_MAC_ADDRESS), 0xFF);\r
+\r
+  CopyMem (&Mode->CurrentAddress, &Private->MacAddress, sizeof (EFI_MAC_ADDRESS));\r
+  CopyMem (&Mode->PermanentAddress, &Private->MacAddress, sizeof (EFI_MAC_ADDRESS));\r
+\r
+  //\r
+  // Since the fake SNP is based on a real NIC, to avoid conflict with the host NIC\r
+  // network stack, we use a different MAC address.\r
+  // So just change the last byte of the MAC address for the real NIC.\r
+  //\r
+  Mode->CurrentAddress.Addr[NET_ETHER_ADDR_LEN - 1]++;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+static struct bpf_insn mFilterInstructionTemplate[] = {\r
+  // Load 4 bytes from the destination MAC address.\r
+  BPF_STMT (BPF_LD + BPF_W + BPF_ABS, OFFSET_OF (ETHERNET_HEADER, DstAddr[0])),\r
+\r
+  // Compare to first 4 bytes of fake MAC address.\r
+  BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0x12345678, 0, 3 ),\r
+\r
+  // Load remaining 2 bytes from the destination MAC address.\r
+  BPF_STMT (BPF_LD + BPF_H + BPF_ABS, OFFSET_OF( ETHERNET_HEADER, DstAddr[4])),\r
+\r
+  // Compare to remaining 2 bytes of fake MAC address.\r
+  BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0x9ABC, 5, 0 ),\r
+\r
+  // Load 4 bytes from the destination MAC address.\r
+  BPF_STMT (BPF_LD + BPF_W + BPF_ABS, OFFSET_OF (ETHERNET_HEADER, DstAddr[0])),\r
+\r
+  // Compare to first 4 bytes of broadcast MAC address.\r
+  BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0xFFFFFFFF, 0, 2),\r
+\r
+  // Load remaining 2 bytes from the destination MAC address.\r
+  BPF_STMT (BPF_LD + BPF_H + BPF_ABS, OFFSET_OF( ETHERNET_HEADER, DstAddr[4])),\r
+\r
+  // Compare to remaining 2 bytes of broadcast MAC address.\r
+  BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0xFFFF, 1, 0),\r
+\r
+  // Reject packet.\r
+  BPF_STMT (BPF_RET + BPF_K, 0),\r
+\r
+  // Receive entire packet.\r
+  BPF_STMT (BPF_RET + BPF_K, -1)\r
+};\r
+\r
+\r
+EFI_STATUS\r
+OpenBpfFileDescriptor (\r
+  IN EMU_SNP_PRIVATE  *Private,\r
+  OUT int             *Fd\r
+  )\r
+{\r
+  char  BfpDeviceName[256];\r
+  int   Index;\r
+\r
+  //\r
+  // Open a Berkeley Packet Filter device.  This must be done as root, so this is probably\r
+  // the place which is most likely to fail...\r
+  //\r
+  for (Index = 0; TRUE; Index++ ) {\r
+    snprintf (BfpDeviceName, sizeof (BfpDeviceName), "/dev/bpf%d", Index);\r
+\r
+    *Fd = open (BfpDeviceName, O_RDWR, 0);\r
+    if ( *Fd >= 0 ) {\r
+      return EFI_SUCCESS;\r
+    }\r
+\r
+    if (errno == EACCES) {\r
+      printf (\r
+        "SNP: Permissions on '%s' are incorrect.  Fix with 'sudo chmod 666 %s'.\n",\r
+        BfpDeviceName, \r
+        BfpDeviceName \r
+        );\r
+    }\r
+    \r
+    if (errno != EBUSY) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  return EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+\r
+/**\r
+  Changes the state of a network interface from "stopped" to "started".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           The network interface was started.\r
+  @retval EFI_ALREADY_STARTED   The network interface is already in the started state.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpStart (\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  )\r
+{\r
+  EFI_STATUS         Status;\r
+  EMU_SNP_PRIVATE    *Private;\r
+  struct ifreq       BoundIf;\r
+  struct bpf_program BpfProgram;\r
+  struct bpf_insn    *FilterProgram;\r
+       u_int                                                    Value;\r
+       u_int                                            ReadBufferSize;\r
+  UINT16             Temp16;\r
+  UINT32             Temp32;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  switch (Private->Mode->State) {\r
+    case EfiSimpleNetworkStopped:\r
+      break;\r
+\r
+    case EfiSimpleNetworkStarted:\r
+    case EfiSimpleNetworkInitialized:\r
+      return EFI_ALREADY_STARTED;\r
+      break;\r
+\r
+    default:\r
+      return EFI_DEVICE_ERROR;\r
+      break;\r
+  }\r
+\r
+  Status = EFI_SUCCESS;\r
+  if (Private->BpfFd == 0) {\r
+    Status = OpenBpfFileDescriptor (Private, &Private->BpfFd);\r
+    if (EFI_ERROR (Status)) {\r
+      goto DeviceErrorExit;\r
+    }\r
+\r
+    //\r
+               // Get the read buffer size.\r
+               //\r
+               if (ioctl (Private->BpfFd, BIOCGBLEN, &ReadBufferSize) < 0) {\r
+                       goto DeviceErrorExit;\r
+               }\r
+               \r
+               //\r
+               // Default value from BIOCGBLEN is usually too small, so use a much larger size, if necessary.\r
+               //\r
+               if (ReadBufferSize < FixedPcdGet32 (PcdNetworkPacketFilterSize)) {\r
+                       ReadBufferSize = FixedPcdGet32 (PcdNetworkPacketFilterSize);\r
+                       if (ioctl (Private->BpfFd, BIOCSBLEN, &ReadBufferSize) < 0) {\r
+                               goto DeviceErrorExit;\r
+                       }\r
+               }\r
+               \r
+               //\r
+    // Associate our interface with this BPF file descriptor.\r
+    //\r
+    AsciiStrCpy (BoundIf.ifr_name, Private->InterfaceName);\r
+    if (ioctl (Private->BpfFd, BIOCSETIF, &BoundIf) < 0) {\r
+      goto DeviceErrorExit;\r
+    }\r
+\r
+    //\r
+               // Enable immediate mode.\r
+    //\r
+    Value = 1;\r
+    if (ioctl (Private->BpfFd, BIOCIMMEDIATE, &Value) < 0) {\r
+      goto DeviceErrorExit;\r
+    }\r
+\r
+    //\r
+    // Enable non-blocking I/O.\r
+    //\r
+    if (fcntl (Private->BpfFd, F_GETFL, 0) == -1) {\r
+      goto DeviceErrorExit;\r
+    }\r
+\r
+    Value |= O_NONBLOCK;\r
+\r
+    if (fcntl (Private->BpfFd, F_SETFL, Value) == -1) {\r
+      goto DeviceErrorExit;\r
+    }\r
+\r
+    //\r
+    // Disable "header complete" flag.  This means the supplied source MAC address is\r
+    // what goes on the wire.\r
+    //\r
+    Value = 1;\r
+    if (ioctl (Private->BpfFd, BIOCSHDRCMPLT, &Value) < 0) {\r
+      goto DeviceErrorExit;\r
+    }\r
+\r
+    //\r
+    // Allocate read buffer.\r
+    //\r
+               Private->ReadBufferSize = ReadBufferSize;\r
+               Private->ReadBuffer = malloc (Private->ReadBufferSize);\r
+    if (Private->ReadBuffer == NULL) {\r
+      goto ErrorExit;\r
+    }\r
+\r
+    Private->CurrentReadPointer = Private->EndReadPointer = Private->ReadBuffer;\r
+\r
+    //\r
+               // Install our packet filter: successful reads should only produce broadcast or unicast\r
+    // packets directed to our fake MAC address.\r
+    //\r
+    FilterProgram = malloc (sizeof (mFilterInstructionTemplate)) ;\r
+    if ( FilterProgram == NULL ) {\r
+      goto ErrorExit;\r
+    }\r
+    \r
+    CopyMem (FilterProgram, &mFilterInstructionTemplate, sizeof (mFilterInstructionTemplate));\r
+\r
+    //\r
+    // Insert out fake MAC address into the filter.  The data has to be host endian.\r
+    //\r
+    CopyMem (&Temp32, &Private->Mode->CurrentAddress.Addr[0], sizeof (UINT32));\r
+    FilterProgram[1].k = NTOHL (Temp32);\r
+    CopyMem (&Temp16, &Private->Mode->CurrentAddress.Addr[4], sizeof (UINT16));\r
+    FilterProgram[3].k = NTOHS (Temp16);\r
+\r
+    BpfProgram.bf_len = sizeof (mFilterInstructionTemplate) / sizeof (struct bpf_insn);\r
+    BpfProgram.bf_insns = FilterProgram;\r
+\r
+    if (ioctl (Private->BpfFd, BIOCSETF, &BpfProgram) < 0) {\r
+      goto DeviceErrorExit;\r
+    }\r
+\r
+    free (FilterProgram);\r
+\r
+    //\r
+    // Enable promiscuous mode.\r
+    //\r
+    if (ioctl (Private->BpfFd, BIOCPROMISC, 0) < 0) {\r
+      goto DeviceErrorExit;\r
+    }\r
+\r
+\r
+    Private->Mode->State = EfiSimpleNetworkStarted;      \r
+  }\r
+\r
+  return Status;\r
+\r
+DeviceErrorExit:\r
+  Status = EFI_DEVICE_ERROR;\r
+ErrorExit:\r
+  if (Private->ReadBuffer != NULL) {\r
+    free (Private->ReadBuffer);\r
+    Private->ReadBuffer = NULL;\r
+  }\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Changes the state of a network interface from "started" to "stopped".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           The network interface was stopped.\r
+  @retval EFI_ALREADY_STARTED   The network interface is already in the stopped state.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpStop (\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  switch ( Private->Mode->State ) {\r
+    case EfiSimpleNetworkStarted:\r
+      break;\r
+\r
+    case EfiSimpleNetworkStopped:\r
+      return EFI_NOT_STARTED;\r
+      break;\r
+\r
+    default:\r
+      return EFI_DEVICE_ERROR;\r
+      break;\r
+  }\r
+\r
+  if (Private->BpfFd != 0) {\r
+    close (Private->BpfFd);\r
+    Private->BpfFd = 0;\r
+  }\r
+\r
+  if (Private->ReadBuffer != NULL) {\r
+    free (Private->ReadBuffer );\r
+    Private->CurrentReadPointer = Private->EndReadPointer = Private->ReadBuffer = NULL;\r
+  }\r
+\r
+  Private->Mode->State = EfiSimpleNetworkStopped;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Resets a network adapter and allocates the transmit and receive buffers \r
+  required by the network interface; optionally, also requests allocation \r
+  of additional transmit and receive buffers.\r
+\r
+  @param  This              The protocol instance pointer.\r
+  @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+  @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+\r
+  @retval EFI_SUCCESS           The network interface was initialized.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_OUT_OF_RESOURCES  There was not enough memory for the transmit and\r
+                                receive buffers.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpInitialize (\r
+  IN EMU_SNP_PROTOCOL                    *This,\r
+  IN UINTN                               ExtraRxBufferSize  OPTIONAL,\r
+  IN UINTN                               ExtraTxBufferSize  OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  switch ( Private->Mode->State ) {\r
+    case EfiSimpleNetworkStarted:\r
+      break;\r
+\r
+    case EfiSimpleNetworkStopped:\r
+      return EFI_NOT_STARTED;\r
+      break;\r
+\r
+    default:\r
+      return EFI_DEVICE_ERROR;\r
+      break;\r
+  }\r
+\r
+  Private->Mode->MCastFilterCount = 0;\r
+  Private->Mode->ReceiveFilterSetting = 0;\r
+  ZeroMem (Private->Mode->MCastFilter, sizeof (Private->Mode->MCastFilter));\r
+\r
+  Private->Mode->State = EfiSimpleNetworkInitialized;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Resets a network adapter and re-initializes it with the parameters that were \r
+  provided in the previous call to Initialize().  \r
+\r
+  @param  This                 The protocol instance pointer.\r
+  @param  ExtendedVerification Indicates that the driver may perform a more\r
+                               exhaustive verification operation of the device\r
+                               during reset.\r
+\r
+  @retval EFI_SUCCESS           The network interface was reset.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpReset (\r
+  IN EMU_SNP_PROTOCOL   *This,\r
+  IN BOOLEAN            ExtendedVerification\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  switch ( Private->Mode->State ) {\r
+    case EfiSimpleNetworkInitialized:\r
+      break;\r
+\r
+    case EfiSimpleNetworkStopped:\r
+      return EFI_NOT_STARTED;\r
+      break;\r
+\r
+    default:\r
+      return EFI_DEVICE_ERROR;\r
+      break;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Resets a network adapter and leaves it in a state that is safe for \r
+  another driver to initialize.\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           The network interface was shutdown.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpShutdown (\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  switch ( Private->Mode->State ) {\r
+    case EfiSimpleNetworkInitialized:\r
+      break;\r
+\r
+    case EfiSimpleNetworkStopped:\r
+      return EFI_NOT_STARTED;\r
+      break;\r
+\r
+    default:\r
+      return EFI_DEVICE_ERROR;\r
+      break;\r
+  }\r
+\r
+  Private->Mode->State = EfiSimpleNetworkStarted;\r
+\r
+  Private->Mode->ReceiveFilterSetting = 0;\r
+  Private->Mode->MCastFilterCount = 0;\r
+  ZeroMem (Private->Mode->MCastFilter, sizeof (Private->Mode->MCastFilter));\r
+\r
+  if (Private->BpfFd != 0) {\r
+    close (Private->BpfFd);\r
+    Private->BpfFd = 0;\r
+  }\r
+\r
+  if (Private->ReadBuffer != NULL) {\r
+    free (Private->ReadBuffer);\r
+    Private->CurrentReadPointer = Private->EndReadPointer = Private->ReadBuffer = NULL;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Manages the multicast receive filters of a network interface.\r
+\r
+  @param  This             The protocol instance pointer.\r
+  @param  Enable           A bit mask of receive filters to enable on the network interface.\r
+  @param  Disable          A bit mask of receive filters to disable on the network interface.\r
+  @param  ResetMCastFilter Set to TRUE to reset the contents of the multicast receive\r
+                           filters on the network interface to their default values.\r
+  @param  McastFilterCnt   Number of multicast HW MAC addresses in the new\r
+                           MCastFilter list. This value must be less than or equal to\r
+                           the MCastFilterCnt field of EMU_SNP_MODE. This\r
+                           field is optional if ResetMCastFilter is TRUE.\r
+  @param  MCastFilter      A pointer to a list of new multicast receive filter HW MAC\r
+                           addresses. This list will replace any existing multicast\r
+                           HW MAC address list. This field is optional if\r
+                           ResetMCastFilter is TRUE.\r
+\r
+  @retval EFI_SUCCESS           The multicast receive filter list was updated.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpReceiveFilters (\r
+  IN EMU_SNP_PROTOCOL                             *This,\r
+  IN UINT32                                       Enable,\r
+  IN UINT32                                       Disable,\r
+  IN BOOLEAN                                      ResetMCastFilter,\r
+  IN UINTN                                        MCastFilterCnt     OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                              *MCastFilter OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  // For now, just succeed...\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Modifies or resets the current station address, if supported.\r
+\r
+  @param  This  The protocol instance pointer.\r
+  @param  Reset Flag used to reset the station address to the network interfaces\r
+                permanent address.\r
+  @param  New   The new station address to be used for the network interface.\r
+\r
+  @retval EFI_SUCCESS           The network interfaces station address was updated.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpStationAddress (\r
+  IN EMU_SNP_PROTOCOL            *This,\r
+  IN BOOLEAN                     Reset,\r
+  IN EFI_MAC_ADDRESS             *New OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+\r
+/**\r
+  Resets or collects the statistics on a network interface.\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
+  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
+                          output the size, in bytes, of the resulting table of\r
+                          statistics.\r
+  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
+                          contains the statistics.\r
+\r
+  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpStatistics (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              Reset,\r
+  IN OUT UINTN                            *StatisticsSize   OPTIONAL,\r
+  OUT EFI_NETWORK_STATISTICS              *StatisticsTable  OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+\r
+/**\r
+  Converts a multicast IP address to a multicast HW MAC address.\r
+\r
+  @param  This The protocol instance pointer.\r
+  @param  IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
+               to FALSE if the multicast IP address is IPv4 [RFC 791].\r
+  @param  IP   The multicast IP address that is to be converted to a multicast\r
+               HW MAC address.\r
+  @param  MAC  The multicast HW MAC address that is to be generated from IP.\r
+\r
+  @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast\r
+                                HW MAC address.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpMCastIpToMac (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              IPv6,\r
+  IN EFI_IP_ADDRESS                       *IP,\r
+  OUT EFI_MAC_ADDRESS                     *MAC\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+\r
+/**\r
+  Performs read and write operations on the NVRAM device attached to a \r
+  network interface.\r
+\r
+  @param  This       The protocol instance pointer.\r
+  @param  ReadWrite  TRUE for read operations, FALSE for write operations.\r
+  @param  Offset     Byte offset in the NVRAM device at which to start the read or\r
+                     write operation. This must be a multiple of NvRamAccessSize and\r
+                     less than NvRamSize.\r
+  @param  BufferSize The number of bytes to read or write from the NVRAM device.\r
+                     This must also be a multiple of NvramAccessSize.\r
+  @param  Buffer     A pointer to the data buffer.\r
+\r
+  @retval EFI_SUCCESS           The NVRAM access was performed.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpNvData (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              ReadWrite,\r
+  IN UINTN                                Offset,\r
+  IN UINTN                                BufferSize,\r
+  IN OUT VOID                             *Buffer\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Reads the current interrupt status and recycled transmit buffer status from \r
+  a network interface.\r
+\r
+  @param  This            The protocol instance pointer.\r
+  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
+                          If this is NULL, the interrupt status will not be read from\r
+                          the device. If this is not NULL, the interrupt status will\r
+                          be read from the device. When the  interrupt status is read,\r
+                          it will also be cleared. Clearing the transmit  interrupt\r
+                          does not empty the recycled transmit buffer array.\r
+  @param  TxBuf           Recycled transmit buffer address. The network interface will\r
+                          not transmit if its internal recycled transmit buffer array\r
+                          is full. Reading the transmit buffer does not clear the\r
+                          transmit interrupt. If this is NULL, then the transmit buffer\r
+                          status will not be read. If there are no transmit buffers to\r
+                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
+\r
+  @retval EFI_SUCCESS           The status of the network interface was retrieved.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpGetStatus (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  OUT UINT32                              *InterruptStatus OPTIONAL,\r
+  OUT VOID                                **TxBuf OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (TxBuf != NULL) {\r
+    *((UINT8 **)TxBuf) =  (UINT8 *)1;\r
+  }\r
+\r
+  if ( InterruptStatus != NULL ) {\r
+    *InterruptStatus = EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Places a packet in the transmit queue of a network interface.\r
+\r
+  @param  This       The protocol instance pointer.\r
+  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
+                     the Transmit() function. If HeaderSize is non-zero, then it\r
+                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
+                     and Protocol parameters must not be NULL.\r
+  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
+                     data) to be transmitted through the network interface.\r
+  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
+                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
+                     then the media header in Buffer must already be filled in by the\r
+                     caller. If HeaderSize is non-zero, then the media header will be\r
+                     filled in by the Transmit() function.\r
+  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
+                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
+                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
+  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
+                     parameter is ignored.\r
+  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
+                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
+                     examples.\r
+\r
+  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_NOT_READY         The network interface is too busy to accept this transmit request.                      \r
+  @retval EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpTransmit (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN UINTN                                HeaderSize,\r
+  IN UINTN                                BufferSize,\r
+  IN VOID                                 *Buffer,\r
+  IN EFI_MAC_ADDRESS                      *SrcAddr  OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                      *DestAddr OPTIONAL,\r
+  IN UINT16                               *Protocol OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+  ETHERNET_HEADER    *EnetHeader;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (Private->Mode->State < EfiSimpleNetworkStarted) {\r
+    return EFI_NOT_STARTED;\r
+  }\r
+\r
+  if ( HeaderSize != 0 ) {\r
+    if ((DestAddr == NULL) || (Protocol == NULL) || (HeaderSize != Private->Mode->MediaHeaderSize)) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    if (SrcAddr == NULL) {\r
+      SrcAddr = &Private->Mode->CurrentAddress;\r
+    }\r
+\r
+    EnetHeader = (ETHERNET_HEADER *) Buffer;\r
+\r
+    CopyMem (EnetHeader->DstAddr, DestAddr, NET_ETHER_ADDR_LEN);\r
+    CopyMem (EnetHeader->SrcAddr, SrcAddr, NET_ETHER_ADDR_LEN);\r
+\r
+    EnetHeader->Type = HTONS(*Protocol);\r
+  }\r
+\r
+  if (write  (Private->BpfFd, Buffer, BufferSize) < 0) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Receives a packet from a network interface.\r
+\r
+  @param  This       The protocol instance pointer.\r
+  @param  HeaderSize The size, in bytes, of the media header received on the network\r
+                     interface. If this parameter is NULL, then the media header size\r
+                     will not be returned.\r
+  @param  BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
+                     bytes, of the packet that was received on the network interface.\r
+  @param  Buffer     A pointer to the data buffer to receive both the media header and\r
+                     the data.\r
+  @param  SrcAddr    The source HW MAC address. If this parameter is NULL, the\r
+                     HW MAC source address will not be extracted from the media\r
+                     header.\r
+  @param  DestAddr   The destination HW MAC address. If this parameter is NULL,\r
+                     the HW MAC destination address will not be extracted from the\r
+                     media header.\r
+  @param  Protocol   The media header type. If this parameter is NULL, then the\r
+                     protocol will not be extracted from the media header. See\r
+                     RFC 1700 section "Ether Types" for examples.\r
+\r
+  @retval  EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
+                                 been updated to the number of bytes received.\r
+  @retval  EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
+                                 request.\r
+  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
+  @retval  EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval  EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpReceive (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  OUT UINTN                               *HeaderSize OPTIONAL,\r
+  IN OUT UINTN                            *BufferSize,\r
+  OUT VOID                                *Buffer,\r
+  OUT EFI_MAC_ADDRESS                     *SrcAddr    OPTIONAL,\r
+  OUT EFI_MAC_ADDRESS                     *DestAddr   OPTIONAL,\r
+  OUT UINT16                              *Protocol   OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+  struct bpf_hdr     *BpfHeader;\r
+       struct bpf_stat    BpfStats;\r
+  ETHERNET_HEADER    *EnetHeader;\r
+  ssize_t            Result;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (Private->Mode->State < EfiSimpleNetworkStarted) {\r
+    return EFI_NOT_STARTED;\r
+  }\r
+\r
+       ZeroMem (&BpfStats, sizeof( BpfStats));\r
+       \r
+       if (ioctl (Private->BpfFd, BIOCGSTATS, &BpfStats) == 0) {\r
+               Private->ReceivedPackets += BpfStats.bs_recv;\r
+               if (BpfStats.bs_drop > Private->DroppedPackets) {\r
+                       printf (\r
+                         "SNP: STATS: RCVD = %d DROPPED = %d.  Probably need to increase BPF PcdNetworkPacketFilterSize?\n",\r
+                               BpfStats.bs_recv, \r
+                               BpfStats.bs_drop - Private->DroppedPackets\r
+                               );\r
+                       Private->DroppedPackets = BpfStats.bs_drop;\r
+               }\r
+       }\r
+\r
+  //\r
+  // Do we have any remaining packets from the previous read?\r
+  //\r
+  if (Private->CurrentReadPointer >= Private->EndReadPointer) {\r
+    Result = read (Private->BpfFd, Private->ReadBuffer, Private->ReadBufferSize);\r
+    if (Result < 0) {\r
+      // EAGAIN means that there's no I/O outstanding against this file descriptor.\r
+      return (errno == EAGAIN) ? EFI_NOT_READY : EFI_DEVICE_ERROR;\r
+    }\r
+\r
+    if (Result == 0) {\r
+      return EFI_NOT_READY;\r
+    }\r
+\r
+    Private->CurrentReadPointer = Private->ReadBuffer;\r
+    Private->EndReadPointer = Private->CurrentReadPointer + Result;\r
+  }\r
+\r
+  BpfHeader = Private->CurrentReadPointer;\r
+  EnetHeader = Private->CurrentReadPointer + BpfHeader->bh_hdrlen;\r
+\r
+  if (BpfHeader->bh_caplen > *BufferSize) {\r
+    *BufferSize = BpfHeader->bh_caplen;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }\r
+\r
+  CopyMem (Buffer, EnetHeader, BpfHeader->bh_caplen);\r
+  *BufferSize = BpfHeader->bh_caplen;\r
+\r
+  if (HeaderSize != NULL) {\r
+    *HeaderSize = sizeof (ETHERNET_HEADER);\r
+  }\r
+\r
+  if (DestAddr != NULL) {\r
+    ZeroMem (DestAddr, sizeof (EFI_MAC_ADDRESS));\r
+    CopyMem (DestAddr, EnetHeader->DstAddr, NET_ETHER_ADDR_LEN);\r
+  }\r
+\r
+  if (SrcAddr != NULL) {\r
+    ZeroMem (SrcAddr, sizeof (EFI_MAC_ADDRESS));\r
+    CopyMem (SrcAddr, EnetHeader->SrcAddr, NET_ETHER_ADDR_LEN);\r
+  }\r
+\r
+  if (Protocol != NULL) {\r
+    *Protocol = NTOHS (EnetHeader->Type);\r
+  }\r
+\r
+  Private->CurrentReadPointer += BPF_WORDALIGN (BpfHeader->bh_hdrlen + BpfHeader->bh_caplen);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EMU_SNP_PROTOCOL gEmuSnpProtocol = {\r
+  GasketSnpCreateMapping,\r
+  GasketSnpStart,\r
+  GasketSnpStop,\r
+  GasketSnpInitialize,\r
+  GasketSnpReset,\r
+  GasketSnpShutdown,\r
+  GasketSnpReceiveFilters,\r
+  GasketSnpStationAddress,\r
+  GasketSnpStatistics,\r
+  GasketSnpMCastIpToMac,\r
+  GasketSnpNvData,\r
+  GasketSnpGetStatus,\r
+  GasketSnpTransmit,\r
+  GasketSnpReceive\r
+};\r
+\r
+EFI_STATUS\r
+GetInterfaceMacAddr (\r
+  EMU_SNP_PRIVATE    *Private\r
+  )\r
+{\r
+       EFI_STATUS                                Status;\r
+  struct ifaddrs      *IfAddrs;\r
+  struct ifaddrs      *If;\r
+  struct sockaddr_dl  *IfSdl;\r
+\r
+  if (getifaddrs (&IfAddrs) != 0) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Convert the interface name to ASCII so we can find it.\r
+  //\r
+  Private->InterfaceName = malloc (StrSize (Private->Thunk->ConfigString));\r
+  if (Private->InterfaceName == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Exit;\r
+  }\r
+\r
+  UnicodeStrToAsciiStr (Private->Thunk->ConfigString, Private->InterfaceName);\r
+\r
+  Status = EFI_NOT_FOUND;\r
+  If = IfAddrs;\r
+  while (If != NULL) {\r
+    IfSdl = (struct sockaddr_dl *)If->ifa_addr;\r
+\r
+    if (IfSdl->sdl_family == AF_LINK) {\r
+      if (!AsciiStrCmp( Private->InterfaceName, If->ifa_name)) {\r
+        CopyMem (&Private->MacAddress, LLADDR (IfSdl), NET_ETHER_ADDR_LEN);\r
+\r
+        Status = EFI_SUCCESS;\r
+        break;\r
+      }\r
+    }\r
+\r
+    If = If->ifa_next;\r
+  }\r
+\r
+Exit:\r
+  freeifaddrs (IfAddrs);\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EmuSnpThunkOpen (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE  *Private;\r
+  \r
+  if (This->Private != NULL) {\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+  \r
+  if (!CompareGuid (This->Protocol, &gEmuSnpProtocolGuid)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  Private = malloc (sizeof (EMU_SNP_PRIVATE));\r
+  if (Private == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  \r
+  Private->Signature = EMU_SNP_PRIVATE_SIGNATURE;\r
+  Private->Thunk     = This;\r
+  CopyMem (&Private->EmuSnp, &gEmuSnpProtocol, sizeof (gEmuSnpProtocol));\r
+  GetInterfaceMacAddr (Private);\r
+  \r
+  This->Interface = &Private->EmuSnp;\r
+  This->Private   = Private;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EmuSnpThunkClose (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE  *Private;\r
+\r
+  if (!CompareGuid (This->Protocol, &gEmuSnpProtocolGuid)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  Private = This->Private;\r
+  free (Private);\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+EMU_IO_THUNK_PROTOCOL gSnpThunkIo = {\r
+  &gEmuSnpProtocolGuid,\r
+  NULL,\r
+  NULL,\r
+  0,\r
+  GasketSnpThunkOpen,\r
+  GasketSnpThunkClose,\r
+  NULL\r
+};\r
+\r
+#endif\r
diff --git a/EmulatorPkg/Unix/Host/BlockIo.c b/EmulatorPkg/Unix/Host/BlockIo.c
new file mode 100644 (file)
index 0000000..bb2da24
--- /dev/null
@@ -0,0 +1,706 @@
+/**@file\r
+\r
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#include "SecMain.h"\r
+\r
+#define EMU_BLOCK_IO_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'M', 'b', 'k')\r
+typedef struct {\r
+  UINTN                       Signature;\r
+\r
+  EMU_IO_THUNK_PROTOCOL       *Thunk;\r
+\r
+  char                        *Filename;\r
+  UINTN                       ReadMode;\r
+  UINTN                       Mode;\r
+\r
+  int                         fd;\r
+\r
+  BOOLEAN                     RemovableMedia;\r
+  BOOLEAN                     WriteProtected;\r
+\r
+  UINT64                      NumberOfBlocks;\r
+  UINT32                      BlockSize;\r
+\r
+  EMU_BLOCK_IO_PROTOCOL       EmuBlockIo;\r
+  EFI_BLOCK_IO_MEDIA          *Media;\r
+\r
+} EMU_BLOCK_IO_PRIVATE;\r
+\r
+#define EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \\r
+         CR(a, EMU_BLOCK_IO_PRIVATE, EmuBlockIo, EMU_BLOCK_IO_PRIVATE_SIGNATURE)\r
+\r
+\r
+\r
+EFI_STATUS\r
+EmuBlockIoReset (\r
+  IN EMU_BLOCK_IO_PROTOCOL    *This,\r
+  IN BOOLEAN                  ExtendedVerification\r
+  );\r
+\r
+\r
+/*++\r
+\r
+This function extends the capability of SetFilePointer to accept 64 bit parameters\r
+\r
+**/\r
+EFI_STATUS\r
+SetFilePointer64 (\r
+  IN  EMU_BLOCK_IO_PRIVATE        *Private,\r
+  IN  INT64                      DistanceToMove,\r
+  OUT UINT64                     *NewFilePointer,\r
+  IN  INT32                      MoveMethod\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+  off_t         res;\r
+  off_t         offset = DistanceToMove;\r
+\r
+  Status = EFI_SUCCESS;\r
+  res = lseek (Private->fd, offset, (int)MoveMethod);\r
+  if (res == -1) {\r
+    Status = EFI_INVALID_PARAMETER;\r
+  } \r
+\r
+  if (NewFilePointer != NULL) {\r
+    *NewFilePointer = res;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EmuBlockIoOpenDevice (\r
+  IN EMU_BLOCK_IO_PRIVATE   *Private\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  UINT64                FileSize;\r
+  struct statfs         buf;\r
+\r
+\r
+  //\r
+  // If the device is already opened, close it\r
+  //\r
+  if (Private->fd >= 0) {\r
+    EmuBlockIoReset (&Private->EmuBlockIo, FALSE);\r
+  }\r
+\r
+  //\r
+  // Open the device\r
+  //\r
+  Private->fd = open (Private->Filename, Private->Mode, 0644);\r
+  if (Private->fd < 0) {\r
+    printf ("EmuOpenBlock: Could not open %s: %s\n", Private->Filename, strerror(errno));\r
+    Private->Media->MediaPresent  = FALSE;\r
+    Status                        = EFI_NO_MEDIA;\r
+    goto Done;\r
+  }\r
+\r
+  if (!Private->Media->MediaPresent) {\r
+    //\r
+    // BugBug: try to emulate if a CD appears - notify drivers to check it out\r
+    //\r
+    Private->Media->MediaPresent = TRUE;\r
+  }\r
+\r
+  //\r
+  // get the size of the file\r
+  //\r
+  Status = SetFilePointer64 (Private, 0, &FileSize, SEEK_END);\r
+  if (EFI_ERROR (Status)) {\r
+    printf ("EmuOpenBlock: Could not get filesize of %s\n", Private->Filename);\r
+    Status = EFI_UNSUPPORTED;\r
+    goto Done;\r
+  }\r
+  \r
+  if (FileSize == 0) {\r
+    // lseek fails on a real device. ioctl calls are OS specific\r
+#if __APPLE__\r
+    {\r
+      UINT32 BlockSize;\r
+     \r
+      if (ioctl (Private->fd, DKIOCGETBLOCKSIZE, &BlockSize) == 0) {\r
+        Private->Media->BlockSize = BlockSize;\r
+      }\r
+      if (ioctl (Private->fd, DKIOCGETBLOCKCOUNT, &Private->NumberOfBlocks) == 0) {\r
+        if ((Private->NumberOfBlocks == 0) && (BlockSize == 0x800)) {\r
+          // A DVD is ~ 4.37 GB so make up a number\r
+          Private->Media->LastBlock = (0x100000000ULL/0x800) - 1;\r
+        } else {\r
+          Private->Media->LastBlock = Private->NumberOfBlocks - 1;\r
+        }\r
+      }\r
+      ioctl (Private->fd, DKIOCGETMAXBLOCKCOUNTWRITE, &Private->Media->OptimalTransferLengthGranularity);  \r
+    }\r
+#else \r
+    {\r
+      size_t BlockSize;\r
+      UINT64 DiskSize;\r
+      \r
+      if (ioctl (Private->fd, BLKSSZGET, &BlockSize) == 0) {\r
+        Private->Media->BlockSize = BlockSize;\r
+      }\r
+      if (ioctl (Private->fd, BLKGETSIZE64, &DiskSize) == 0) {\r
+        Private->NumberOfBlocks = DivU64x32 (DiskSize, (UINT32)BlockSize);\r
+        Private->Media->LastBlock = Private->NumberOfBlocks - 1;\r
+      }\r
+    }\r
+#endif\r
+    \r
+  } else {\r
+    Private->Media->BlockSize = Private->BlockSize;\r
+    Private->NumberOfBlocks = DivU64x32 (FileSize, Private->Media->BlockSize);\r
+    Private->Media->LastBlock = Private->NumberOfBlocks - 1;\r
+    \r
+    if (fstatfs (Private->fd, &buf) == 0) {\r
+#if __APPLE__\r
+      Private->Media->OptimalTransferLengthGranularity = buf.f_iosize/buf.f_bsize;\r
+#else\r
+      Private->Media->OptimalTransferLengthGranularity = buf.f_bsize/buf.f_bsize;\r
+#endif\r
+    }\r
+  } \r
+\r
+  DEBUG ((EFI_D_INIT, "%HEmuOpenBlock: opened %a%N\n", Private->Filename));\r
+  Status = EFI_SUCCESS;\r
+\r
+Done:\r
+  if (EFI_ERROR (Status)) {\r
+    if (Private->fd >= 0) {\r
+      EmuBlockIoReset (&Private->EmuBlockIo, FALSE);\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EmuBlockIoCreateMapping (\r
+  IN     EMU_BLOCK_IO_PROTOCOL    *This,\r
+  IN     EFI_BLOCK_IO_MEDIA       *Media\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_BLOCK_IO_PRIVATE    *Private;\r
+\r
+  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Private->Media = Media;\r
+  \r
+  Media->MediaId          = 0;\r
+  Media->RemovableMedia   = Private->RemovableMedia;\r
+  Media->MediaPresent     = TRUE;\r
+  Media->LogicalPartition = FALSE;\r
+  Media->ReadOnly         = Private->WriteProtected;\r
+  Media->WriteCaching     = FALSE;\r
+  Media->IoAlign          = 1;\r
+  Media->LastBlock        = 0; // Filled in by OpenDevice\r
+  \r
+  // EFI_BLOCK_IO_PROTOCOL_REVISION2\r
+  Media->LowestAlignedLba              = 0;\r
+  Media->LogicalBlocksPerPhysicalBlock = 0; \r
+    \r
+\r
+  // EFI_BLOCK_IO_PROTOCOL_REVISION3\r
+  Media->OptimalTransferLengthGranularity = 0;\r
+    \r
+  Status = EmuBlockIoOpenDevice (Private);\r
+\r
+  \r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EmuBlockIoError (\r
+  IN EMU_BLOCK_IO_PRIVATE      *Private\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  BOOLEAN               ReinstallBlockIoFlag;\r
+\r
+\r
+  switch (errno) {\r
+\r
+  case EAGAIN:\r
+    Status                        = EFI_NO_MEDIA;\r
+    Private->Media->ReadOnly      = FALSE;\r
+    Private->Media->MediaPresent  = FALSE;\r
+    ReinstallBlockIoFlag          = FALSE;\r
+    break;\r
+\r
+  case EACCES:\r
+    Private->Media->ReadOnly      = FALSE;\r
+    Private->Media->MediaPresent  = TRUE;\r
+    Private->Media->MediaId += 1;\r
+    ReinstallBlockIoFlag  = TRUE;\r
+    Status                = EFI_MEDIA_CHANGED;\r
+    break;\r
+\r
+  case EROFS:\r
+    Private->Media->ReadOnly  = TRUE;\r
+    ReinstallBlockIoFlag      = FALSE;\r
+    Status                    = EFI_WRITE_PROTECTED;\r
+    break;\r
+\r
+  default:\r
+    ReinstallBlockIoFlag  = FALSE;\r
+    Status                = EFI_DEVICE_ERROR;\r
+    break;\r
+  }\r
+  return Status;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EmuBlockIoReadWriteCommon (\r
+  IN  EMU_BLOCK_IO_PRIVATE        *Private,\r
+  IN UINT32                       MediaId,\r
+  IN EFI_LBA                      Lba,\r
+  IN UINTN                        BufferSize,\r
+  IN VOID                         *Buffer,\r
+  IN CHAR8                        *CallerName\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       BlockSize;\r
+  UINT64      LastBlock;\r
+  INT64       DistanceToMove;\r
+  UINT64      DistanceMoved;\r
+\r
+  if (Private->fd < 0) {\r
+    Status = EmuBlockIoOpenDevice (Private);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+  }\r
+\r
+  if (!Private->Media->MediaPresent) {\r
+    DEBUG ((EFI_D_INIT, "%s: No Media\n", CallerName));\r
+    return EFI_NO_MEDIA;\r
+  }\r
+\r
+  if (Private->Media->MediaId != MediaId) {\r
+    return EFI_MEDIA_CHANGED;\r
+  }\r
+\r
+  if ((UINTN) Buffer % Private->Media->IoAlign != 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  //\r
+  // Verify buffer size\r
+  //\r
+  BlockSize = Private->Media->BlockSize;\r
+  if (BufferSize == 0) {\r
+    DEBUG ((EFI_D_INIT, "%s: Zero length read\n", CallerName));\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  if ((BufferSize % BlockSize) != 0) {\r
+    DEBUG ((EFI_D_INIT, "%s: Invalid read size\n", CallerName));\r
+    return EFI_BAD_BUFFER_SIZE;\r
+  }\r
+\r
+  LastBlock = Lba + (BufferSize / BlockSize) - 1;\r
+  if (LastBlock > Private->Media->LastBlock) {\r
+    DEBUG ((EFI_D_INIT, "ReadBlocks: Attempted to read off end of device\n"));\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Seek to End of File\r
+  //\r
+  DistanceToMove = MultU64x32 (Lba, BlockSize);\r
+  Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, SEEK_SET);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_INIT, "WriteBlocks: SetFilePointer failed\n"));\r
+    return EmuBlockIoError (Private);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Read BufferSize bytes from Lba into Buffer.\r
+  \r
+  This function reads the requested number of blocks from the device. All the\r
+  blocks are read, or an error is returned.\r
+  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and\r
+  non-blocking I/O is being used, the Event associated with this request will\r
+  not be signaled.\r
+\r
+  @param[in]       This       Indicates a pointer to the calling context.\r
+  @param[in]       MediaId    Id of the media, changes every time the media is \r
+                              replaced.\r
+  @param[in]       Lba        The starting Logical Block Address to read from.\r
+  @param[in, out]  Token           A pointer to the token associated with the transaction.\r
+  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.  \r
+  @param[out]      Buffer     A pointer to the destination buffer for the data. The \r
+                              caller is responsible for either having implicit or \r
+                              explicit ownership of the buffer.\r
+\r
+  @retval EFI_SUCCESS           The read request was queued if Token->Event is\r
+                                not NULL.The data was read correctly from the\r
+                                device if the Token->Event is NULL.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error while performing\r
+                                the read.\r
+  @retval EFI_NO_MEDIA          There is no media in the device.\r
+  @retval EFI_MEDIA_CHANGED     The MediaId is not for the current media.\r
+  @retval EFI_BAD_BUFFER_SIZE   The BufferSize parameter is not a multiple of the\r
+                                intrinsic block size of the device.\r
+  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
+                                or the buffer is not on proper alignment.\r
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack\r
+                                of resources.\r
+**/\r
+EFI_STATUS\r
+EmuBlockIoReadBlocks (\r
+  IN     EMU_BLOCK_IO_PROTOCOL  *This,\r
+  IN     UINT32                 MediaId,\r
+  IN     EFI_LBA                LBA,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
+  IN     UINTN                  BufferSize,\r
+     OUT VOID                   *Buffer\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EMU_BLOCK_IO_PRIVATE    *Private;\r
+  ssize_t                 len;\r
+\r
+  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status  = EmuBlockIoReadWriteCommon (Private, MediaId, LBA, BufferSize, Buffer, "UnixReadBlocks");\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  len = read (Private->fd, Buffer, BufferSize);\r
+  if (len != BufferSize) {\r
+    DEBUG ((EFI_D_INIT, "ReadBlocks: ReadFile failed.\n"));\r
+    Status = EmuBlockIoError (Private);\r
+    goto Done;\r
+  }\r
+\r
+  //\r
+  // If we read then media is present.\r
+  //\r
+  Private->Media->MediaPresent = TRUE;\r
+  Status = EFI_SUCCESS;\r
+\r
+Done:\r
+  if (Token != NULL) {\r
+    if (Token->Event != NULL) {\r
+      // Caller is responcible for signaling EFI Event\r
+      Token->TransactionStatus = Status;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Write BufferSize bytes from Lba into Buffer.\r
+\r
+  This function writes the requested number of blocks to the device. All blocks\r
+  are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,\r
+  EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is\r
+  being used, the Event associated with this request will not be signaled.\r
+\r
+  @param[in]       This       Indicates a pointer to the calling context.\r
+  @param[in]       MediaId    The media ID that the write request is for.\r
+  @param[in]       Lba        The starting logical block address to be written. The\r
+                              caller is responsible for writing to only legitimate\r
+                              locations.\r
+  @param[in, out]  Token      A pointer to the token associated with the transaction.\r
+  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.\r
+  @param[in]       Buffer     A pointer to the source buffer for the data.\r
+\r
+  @retval EFI_SUCCESS           The write request was queued if Event is not NULL.\r
+                                The data was written correctly to the device if\r
+                                the Event is NULL.\r
+  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
+  @retval EFI_NO_MEDIA          There is no media in the device.\r
+  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
+  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
+  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
+                                or the buffer is not on proper alignment.\r
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack\r
+                                of resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuBlockIoWriteBlocks (\r
+  IN     EMU_BLOCK_IO_PROTOCOL  *This,\r
+  IN     UINT32                 MediaId,\r
+  IN     EFI_LBA                LBA,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
+  IN     UINTN                  BufferSize,\r
+  IN     VOID                   *Buffer\r
+  )\r
+{\r
+  EMU_BLOCK_IO_PRIVATE    *Private;\r
+  ssize_t                 len;\r
+  EFI_STATUS              Status;\r
+\r
+\r
+  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Status  = EmuBlockIoReadWriteCommon (Private, MediaId, LBA, BufferSize, Buffer, "UnixWriteBlocks");\r
+  if (EFI_ERROR (Status)) {\r
+    goto Done;\r
+  }\r
+\r
+  len = write (Private->fd, Buffer, BufferSize);\r
+  if (len != BufferSize) {\r
+    DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed.\n"));\r
+    Status = EmuBlockIoError (Private);\r
+    goto Done;\r
+  }\r
+\r
+  //\r
+  // If the write succeeded, we are not write protected and media is present.\r
+  //\r
+  Private->Media->MediaPresent = TRUE;\r
+  Private->Media->ReadOnly     = FALSE;\r
+  Status = EFI_SUCCESS;\r
+\r
+Done:\r
+  if (Token != NULL) {\r
+    if (Token->Event != NULL) {\r
+      // Caller is responcible for signaling EFI Event\r
+      Token->TransactionStatus = Status;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  Flush the Block Device.\r
\r
+  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED\r
+  is returned and non-blocking I/O is being used, the Event associated with\r
+  this request will not be signaled.  \r
+\r
+  @param[in]      This     Indicates a pointer to the calling context.\r
+  @param[in,out]  Token    A pointer to the token associated with the transaction\r
+\r
+  @retval EFI_SUCCESS          The flush request was queued if Event is not NULL.\r
+                               All outstanding data was written correctly to the\r
+                               device if the Event is NULL.\r
+  @retval EFI_DEVICE_ERROR     The device reported an error while writting back\r
+                               the data.\r
+  @retval EFI_WRITE_PROTECTED  The device cannot be written to.\r
+  @retval EFI_NO_MEDIA         There is no media in the device.\r
+  @retval EFI_MEDIA_CHANGED    The MediaId is not for the current media.\r
+  @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
+                               of resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuBlockIoFlushBlocks (\r
+  IN     EMU_BLOCK_IO_PROTOCOL    *This,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN      *Token\r
+  )\r
+{\r
+  EMU_BLOCK_IO_PRIVATE *Private;\r
+\r
+  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (Private->fd >= 0) {\r
+    fsync (Private->fd);\r
+#if __APPLE__\r
+    fcntl (Private->fd, F_FULLFSYNC);\r
+#endif\r
+  }\r
+  \r
+  \r
+  if (Token != NULL) {\r
+    if (Token->Event != NULL) {\r
+      // Caller is responcible for signaling EFI Event\r
+      Token->TransactionStatus = EFI_SUCCESS;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Reset the block device hardware.\r
+\r
+  @param[in]  This                 Indicates a pointer to the calling context.\r
+  @param[in]  ExtendedVerification Indicates that the driver may perform a more\r
+                                   exhausive verfication operation of the device\r
+                                   during reset.\r
+\r
+  @retval EFI_SUCCESS          The device was reset.\r
+  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
+                               not be reset.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuBlockIoReset (\r
+  IN EMU_BLOCK_IO_PROTOCOL    *This,\r
+  IN BOOLEAN                  ExtendedVerification\r
+  )\r
+{\r
+  EMU_BLOCK_IO_PRIVATE *Private;\r
+\r
+  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (Private->fd >= 0) {\r
+    close (Private->fd);\r
+    Private->fd = -1;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+char *\r
+StdDupUnicodeToAscii (\r
+  IN  CHAR16 *Str\r
+  )\r
+{\r
+  UINTN   Size;\r
+  char    *Ascii;\r
+  char    *Ptr;\r
+  \r
+  Size = StrLen (Str) + 1;\r
+  Ascii = malloc (Size);\r
+  if (Ascii == NULL) {\r
+    return NULL;\r
+  }\r
+  \r
+  for (Ptr = Ascii; *Str != '\0'; Ptr++, Str++) {\r
+    *Ptr = *Str;\r
+  }\r
+  *Ptr = 0;\r
+  \r
+  return Ascii;\r
+}\r
+\r
+\r
+EMU_BLOCK_IO_PROTOCOL gEmuBlockIoProtocol = {\r
+  GasketEmuBlockIoReset,\r
+  GasketEmuBlockIoReadBlocks,\r
+  GasketEmuBlockIoWriteBlocks,\r
+  GasketEmuBlockIoFlushBlocks,\r
+  GasketEmuBlockIoCreateMapping\r
+};\r
+\r
+EFI_STATUS\r
+EmuBlockIoThunkOpen (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  )\r
+{\r
+  EMU_BLOCK_IO_PRIVATE  *Private;\r
+  char                  *Str;\r
+  \r
+  if (This->Private != NULL) {\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+  \r
+  if (!CompareGuid (This->Protocol, &gEmuBlockIoProtocolGuid)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  Private = malloc (sizeof (EMU_BLOCK_IO_PRIVATE));\r
+  if (Private == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  \r
+  Private->Signature = EMU_BLOCK_IO_PRIVATE_SIGNATURE;\r
+  Private->Thunk     = This;\r
+  CopyMem (&Private->EmuBlockIo, &gEmuBlockIoProtocol, sizeof (gEmuBlockIoProtocol));\r
+  Private->fd        = -1;\r
+  Private->BlockSize = 512;\r
\r
+  Private->Filename = StdDupUnicodeToAscii (This->ConfigString);\r
+  if (Private->Filename == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
\r
+  Str = strstr (Private->Filename, ":");\r
+  if (Str == NULL) {\r
+    Private->RemovableMedia = FALSE;\r
+    Private->WriteProtected = FALSE;\r
+  } else {\r
+    for (*Str++ = '\0'; *Str != 0; Str++) {\r
+      if (*Str == 'R' || *Str == 'F') {\r
+        Private->RemovableMedia = (BOOLEAN) (*Str == 'R');\r
+      }\r
+      if (*Str == 'O' || *Str == 'W') {\r
+        Private->WriteProtected  = (BOOLEAN) (*Str == 'O');\r
+      }\r
+      if (*Str == ':') {\r
+        Private->BlockSize = strtol (++Str, NULL, 0);\r
+        break;\r
+      }\r
+    }\r
+  }\r
+  \r
+  This->Interface = &Private->EmuBlockIo;\r
+  This->Private   = Private;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EmuBlockIoThunkClose (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  )\r
+{\r
+  EMU_BLOCK_IO_PRIVATE  *Private;\r
+\r
+  if (!CompareGuid (This->Protocol, &gEmuBlockIoProtocolGuid)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  Private = This->Private;\r
+  \r
+  if (This->Private != NULL) {\r
+    if (Private->Filename != NULL) {\r
+      free (Private->Filename);\r
+    }   \r
+    free (This->Private);\r
+    This->Private = NULL;\r
+  }\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+EMU_IO_THUNK_PROTOCOL gBlockIoThunkIo = {\r
+  &gEmuBlockIoProtocolGuid,\r
+  NULL,\r
+  NULL,\r
+  0,\r
+  GasketBlockIoThunkOpen,\r
+  GasketBlockIoThunkClose,\r
+  NULL\r
+};\r
+\r
+\r
diff --git a/EmulatorPkg/Unix/Host/EmuThunk.c b/EmulatorPkg/Unix/Host/EmuThunk.c
new file mode 100644 (file)
index 0000000..fe68603
--- /dev/null
@@ -0,0 +1,432 @@
+/*++ @file
+  Since the SEC is the only program in our emulation we 
+  must use a UEFI/PI mechanism to export APIs to other modules.
+  This is the role of the EFI_EMU_THUNK_PROTOCOL.
+
+  The mUnixThunkTable exists so that a change to EFI_EMU_THUNK_PROTOCOL
+  will cause an error in initializing the array if all the member functions
+  are not added. It looks like adding a element to end and not initializing
+  it may cause the table to be initaliized with the members at the end being
+  set to zero. This is bad as jumping to zero will crash.
+
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
+Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
+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 "SecMain.h"
+
+#ifdef __APPLE__
+#define DebugAssert _Mangle__DebugAssert
+
+#include <assert.h>
+#include <CoreServices/CoreServices.h>
+#include <mach/mach.h>
+#include <mach/mach_time.h>
+
+#undef DebugAssert
+#endif
+
+int settimer_initialized;
+struct timeval settimer_timeval;
+void (*settimer_callback)(UINT64 delta);
+
+BOOLEAN gEmulatorInterruptEnabled = FALSE;
+
+
+UINTN
+SecWriteStdErr (
+  IN UINT8     *Buffer,
+  IN UINTN     NumberOfBytes
+  )
+{
+  ssize_t Return;
+  
+  Return = write (STDERR_FILENO, (const void *)Buffer, (size_t)NumberOfBytes);
+  
+  return (Return == -1) ? 0 : Return;
+}
+
+
+EFI_STATUS
+SecConfigStdIn (
+  VOID
+  )
+{
+  struct termios tty;
+  
+  //
+  // Need to turn off line buffering, ECHO, and make it unbuffered.
+  //
+  tcgetattr (STDIN_FILENO, &tty);
+  tty.c_lflag &= ~(ICANON | ECHO);
+  tcsetattr (STDIN_FILENO, TCSANOW, &tty);
+  
+//  setvbuf (STDIN_FILENO, NULL, _IONBF, 0);
+  
+  // now ioctl FIONREAD will do what we need
+  return EFI_SUCCESS;
+}
+
+UINTN
+SecWriteStdOut (
+  IN UINT8     *Buffer,
+  IN UINTN     NumberOfBytes
+  )
+{
+  ssize_t Return;
+  
+  Return = write (STDOUT_FILENO, (const void *)Buffer, (size_t)NumberOfBytes);
+  
+  return (Return == -1) ? 0 : Return;
+}
+
+UINTN
+SecReadStdIn (
+  IN UINT8     *Buffer,
+  IN UINTN     NumberOfBytes
+  )
+{
+  ssize_t Return;
+  
+  Return = read (STDIN_FILENO, Buffer, (size_t)NumberOfBytes);
+  
+  return (Return == -1) ? 0 : Return;
+}
+
+BOOLEAN
+SecPollStdIn (
+  VOID
+  )
+{
+  int Result;
+  int Bytes;
+  
+  Result = ioctl (STDIN_FILENO, FIONREAD, &Bytes);
+  if (Result == -1) {
+    return FALSE;
+  }
+  
+  return (BOOLEAN)(Bytes > 0);
+}
+
+
+VOID *
+SecMalloc (
+  IN  UINTN Size
+  )
+{
+  return malloc ((size_t)Size);
+}
+
+VOID *
+SecValloc (
+  IN  UINTN Size
+  )
+{
+  return valloc ((size_t)Size);
+}
+
+BOOLEAN
+SecFree (
+  IN  VOID *Ptr
+  )
+{
+  if (EfiSystemMemoryRange (Ptr)) {
+    // If an address range is in the EFI memory map it was alloced via EFI.
+    // So don't free those ranges and let the caller know.
+    return FALSE;
+  }
+  
+  free (Ptr);
+  return TRUE;
+}
+
+
+void
+settimer_handler (int sig)
+{
+  struct timeval timeval;
+  UINT64 delta;
+
+  gettimeofday (&timeval, NULL);
+  delta = ((UINT64)timeval.tv_sec * 1000) + (timeval.tv_usec / 1000)
+    - ((UINT64)settimer_timeval.tv_sec * 1000) 
+    - (settimer_timeval.tv_usec / 1000);
+  settimer_timeval = timeval;
+  
+  if (settimer_callback) {
+    ReverseGasketUint64 (settimer_callback, delta);
+  }
+}
+
+VOID
+SecSetTimer (
+  IN  UINT64                  PeriodMs,
+  IN  EMU_SET_TIMER_CALLBACK  CallBack
+  )
+{
+  struct itimerval timerval;
+  UINT32 remainder;
+
+  if (!settimer_initialized) {
+    struct sigaction act;
+
+    settimer_initialized = 1;
+    act.sa_handler = settimer_handler;
+    act.sa_flags = 0;
+    sigemptyset (&act.sa_mask);
+    gEmulatorInterruptEnabled = TRUE;
+    if (sigaction (SIGALRM, &act, NULL) != 0) {
+      printf ("SetTimer: sigaction error %s\n", strerror (errno));
+    }
+    if (gettimeofday (&settimer_timeval, NULL) != 0) {
+      printf ("SetTimer: gettimeofday error %s\n", strerror (errno));
+    }
+  }
+  timerval.it_value.tv_sec = DivU64x32(PeriodMs, 1000);
+  DivU64x32Remainder(PeriodMs, 1000, &remainder);
+  timerval.it_value.tv_usec = remainder * 1000;
+  timerval.it_value.tv_sec = DivU64x32(PeriodMs, 1000);
+  timerval.it_interval = timerval.it_value;
+  
+  if (setitimer (ITIMER_REAL, &timerval, NULL) != 0) {
+    printf ("SetTimer: setitimer error %s\n", strerror (errno));
+  }
+  settimer_callback = CallBack;
+}
+
+
+VOID
+SecEnableInterrupt (
+  VOID
+  )
+{
+  sigset_t  sigset;
+
+  gEmulatorInterruptEnabled = TRUE;
+  // Since SetTimer() uses SIGALRM we emulate turning on and off interrupts 
+  // by enabling/disabling SIGALRM.
+  sigemptyset (&sigset);
+  sigaddset (&sigset, SIGALRM);
+  pthread_sigmask (SIG_UNBLOCK, &sigset, NULL);
+}
+
+
+VOID
+SecDisableInterrupt (
+  VOID
+  )
+{
+  sigset_t  sigset;
+
+  // Since SetTimer() uses SIGALRM we emulate turning on and off interrupts 
+  // by enabling/disabling SIGALRM.
+  sigemptyset (&sigset);
+  sigaddset (&sigset, SIGALRM);
+  pthread_sigmask (SIG_BLOCK, &sigset, NULL);
+  gEmulatorInterruptEnabled = FALSE;
+}
+
+
+BOOLEAN
+SecInterruptEanbled (void)
+{
+  return gEmulatorInterruptEnabled;
+}
+
+
+UINT64
+QueryPerformanceFrequency (
+  VOID
+  )
+{
+  // Hard code to nanoseconds
+  return 1000000000ULL;
+}
+
+UINT64
+QueryPerformanceCounter (
+  VOID
+  )
+{
+#if __APPLE__
+  UINT64          Start;
+  Nanoseconds     elapsedNano;
+
+  Start = mach_absolute_time ();
+  
+  // Convert to nanoseconds.
+
+  // Have to do some pointer fun because AbsoluteToNanoseconds 
+  // works in terms of UnsignedWide, which is a structure rather 
+    // than a proper 64-bit integer.
+  elapsedNano = AbsoluteToNanoseconds (*(AbsoluteTime *) &Start);
+
+  return *(uint64_t *) &elapsedNano;
+#else
+  // Need to figure out what to do for Linux?
+  return 0;
+#endif
+}
+  
+
+
+VOID
+SecSleep (
+  IN  UINT64 Nanoseconds
+  )
+{
+  struct timespec rq, rm;
+  struct timeval  start, end;
+  unsigned long  MicroSec;
+  
+  rq.tv_sec  = DivU64x32 (Nanoseconds, 1000000000);
+  rq.tv_nsec = ModU64x32 (Nanoseconds, 1000000000);
+
+  //
+  // nanosleep gets interrupted by our timer tic. 
+  // we need to track wall clock time or we will stall for way too long
+  //
+  gettimeofday (&start, NULL);
+  end.tv_sec  = start.tv_sec + rq.tv_sec;
+  MicroSec = (start.tv_usec + rq.tv_nsec/1000);
+  end.tv_usec = MicroSec % 1000000;
+  if (MicroSec > 1000000) {
+    end.tv_sec++;
+  }
+
+  while (nanosleep (&rq, &rm) == -1) {
+    if (errno != EINTR) {
+      break;
+    }
+    gettimeofday (&start, NULL);
+    if (start.tv_sec > end.tv_sec) {
+      break;
+    } if ((start.tv_sec == end.tv_sec) && (start.tv_usec > end.tv_usec)) {
+      break;
+    }
+    rq = rm;
+  } 
+}
+
+
+VOID
+SecCpuSleep (
+  VOID
+  )
+{
+  struct timespec rq, rm;
+
+  // nanosleep gets interrupted by the timer tic
+  rq.tv_sec  = 1;
+  rq.tv_nsec = 0;
+  
+  nanosleep (&rq, &rm);
+}
+
+
+VOID
+SecExit (
+  UINTN   Status
+  )
+{
+  exit (Status);
+}
+
+
+VOID
+SecGetTime (
+  OUT  EFI_TIME               *Time,
+  OUT EFI_TIME_CAPABILITIES   *Capabilities OPTIONAL
+  )
+{
+  struct tm *tm;
+  time_t t;
+
+  t = time (NULL);
+  tm = localtime (&t);
+
+  Time->Year = 1900 + tm->tm_year;
+  Time->Month = tm->tm_mon + 1;
+  Time->Day = tm->tm_mday;
+  Time->Hour = tm->tm_hour;
+  Time->Minute = tm->tm_min;
+  Time->Second = tm->tm_sec;
+  Time->Nanosecond = 0;
+  Time->TimeZone = timezone;
+  Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0)
+    | (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
+    
+  if (Capabilities != NULL) {
+    Capabilities->Resolution  = 1;
+    Capabilities->Accuracy    = 50000000;
+    Capabilities->SetsToZero  = FALSE;
+  }
+}
+
+
+
+VOID
+SecSetTime (
+  IN  EFI_TIME               *Time
+  )
+{
+  // Don't change the time on the system
+  // We could save delta to localtime() and have SecGetTime adjust return values?
+  return;
+}
+
+
+EFI_STATUS
+SecGetNextProtocol (
+  IN  BOOLEAN                 EmuBusDriver,
+  OUT EMU_IO_THUNK_PROTOCOL   **Instance   OPTIONAL
+  )
+{
+  return GetNextThunkProtocol (EmuBusDriver, Instance);
+}
+
+
+EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
+  GasketSecWriteStdErr,
+  GasketSecConfigStdIn,
+  GasketSecWriteStdOut,
+  GasketSecReadStdIn,
+  GasketSecPollStdIn,
+  GasketSecMalloc,
+  GasketSecValloc,
+  GasketSecFree,
+  GasketSecPeCoffGetEntryPoint,
+  GasketSecPeCoffRelocateImageExtraAction,
+  GasketSecPeCoffUnloadImageExtraAction,
+  GasketSecEnableInterrupt,
+  GasketSecDisableInterrupt,
+  GasketQueryPerformanceFrequency,
+  GasketQueryPerformanceCounter,
+  GasketSecSleep,
+  GasketSecCpuSleep,
+  GasketSecExit,
+  GasketSecGetTime,                
+  GasketSecSetTime,
+  GasketSecSetTimer,  
+  GasketSecGetNextProtocol
+};
+
+
+VOID
+SecInitThunkProtocol (
+  VOID
+  )
+{
+  // timezone and daylight lib globals depend on tzset be called 1st.
+  tzset ();
+}
+
diff --git a/EmulatorPkg/Unix/Host/Gasket.h b/EmulatorPkg/Unix/Host/Gasket.h
new file mode 100644 (file)
index 0000000..2c59a56
--- /dev/null
@@ -0,0 +1,651 @@
+/** @file\r
+\r
+  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
+  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _GASKET_H_\r
+#define _GASKET_H_\r
+\r
+//\r
+// EMU_THUNK_PROTOCOL gaskets (EFIAPI to UNIX ABI)\r
+//\r
+\r
+UINTN\r
+EFIAPI\r
+GasketSecWriteStdErr (\r
+  IN UINT8     *Buffer,\r
+  IN UINTN     NumberOfBytes\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSecConfigStdIn (\r
+  VOID\r
+  );\r
+\r
+UINTN\r
+EFIAPI\r
+GasketSecWriteStdOut (\r
+  IN UINT8     *Buffer,\r
+  IN UINTN     NumberOfBytes\r
+  );\r
+  \r
+UINTN\r
+EFIAPI\r
+GasketSecReadStdIn (\r
+  IN UINT8     *Buffer,\r
+  IN UINTN     NumberOfBytes\r
+  );\r
+\r
+BOOLEAN\r
+EFIAPI\r
+GasketSecPollStdIn (\r
+  VOID\r
+  );\r
+\r
+VOID *\r
+EFIAPI\r
+GasketSecMalloc (\r
+  IN  UINTN Size\r
+  );\r
+\r
+VOID *\r
+EFIAPI\r
+GasketSecValloc (\r
+  IN  UINTN Size\r
+  );\r
+  \r
+BOOLEAN\r
+EFIAPI\r
+GasketSecFree (\r
+  IN  VOID *Ptr\r
+  );\r
+\r
+\r
+RETURN_STATUS\r
+EFIAPI\r
+GasketSecPeCoffGetEntryPoint (\r
+  IN     VOID  *Pe32Data,\r
+  IN OUT VOID  **EntryPoint\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+GasketSecPeCoffRelocateImageExtraAction (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+GasketSecPeCoffUnloadImageExtraAction (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+GasketSecSetTimer (\r
+  IN  UINT64                  PeriodMs,\r
+  IN  EMU_SET_TIMER_CALLBACK  CallBack\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+GasketSecEnableInterrupt (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+GasketSecDisableInterrupt (\r
+  VOID\r
+  );\r
+  \r
+UINT64  \r
+EFIAPI\r
+GasketQueryPerformanceFrequency (\r
+  VOID\r
+  );\r
+\r
+UINT64\r
+EFIAPI\r
+GasketQueryPerformanceCounter (\r
+  VOID\r
+  );\r
+\r
+\r
+VOID\r
+EFIAPI\r
+GasketSecSleep (\r
+  IN  UINT64 Nanoseconds\r
+  );\r
+  \r
+VOID\r
+EFIAPI\r
+GasketSecCpuSleep (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+GasketSecExit (\r
+  UINTN   Status\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+GasketSecGetTime (\r
+  OUT  EFI_TIME               *Time,\r
+  OUT EFI_TIME_CAPABILITIES   *Capabilities OPTIONAL\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+GasketSecSetTime (\r
+  IN  EFI_TIME               *Time\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSecGetNextProtocol (\r
+  IN  BOOLEAN                 EmuBusDriver,\r
+  OUT EMU_IO_THUNK_PROTOCOL   **Instance  OPTIONAL\r
+  );\r
+\r
+\r
+// PPIs produced by SEC  \r
+\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+GasketSecUnixPeiAutoScan (\r
+  IN  UINTN                 Index,\r
+  OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,\r
+  OUT UINT64                *MemorySize\r
+  );\r
+  \r
+VOID *\r
+EFIAPI\r
+GasketSecEmuThunkAddress (\r
+  VOID\r
+  );\r
+\r
\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSecUnixUnixFwhAddress (\r
+  IN OUT UINT64                *FwhSize,\r
+  IN OUT EFI_PHYSICAL_ADDRESS  *FwhBase\r
+  );\r
+  \r
+\r
+\r
+//\r
+// Reverse (UNIX to EFIAPI) gaskets\r
+//\r
+\r
+typedef\r
+void\r
+(EFIAPI *CALL_BACK) (\r
+  UINT64 Delta\r
+  );\r
+\r
+UINTN\r
+ReverseGasketUint64 (\r
+  CALL_BACK CallBack,\r
+  UINT64 a\r
+  );\r
+\r
+UINTN\r
+ReverseGasketUint64Uint64 (\r
+  VOID      *CallBack,\r
+  VOID      *Context,\r
+  VOID      *Key\r
+  );\r
+\r
+//\r
+// Gasket functions for EFI_EMU_UGA_IO_PROTOCOL\r
+//\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketX11Size (\r
+  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo,\r
+  UINT32 Width,\r
+  UINT32 Height\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketX11CheckKey (\r
+  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketX11GetKey (\r
+  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo,\r
+  EFI_KEY_DATA                 *key\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketX11KeySetState (\r
+  EMU_GRAPHICS_WINDOW_PROTOCOL  *GraphicsWindowsIo,\r
+  EFI_KEY_TOGGLE_STATE          *KeyToggleState\r
+  );\r
+  \r
+EFI_STATUS\r
+EFIAPI  \r
+GasketX11RegisterKeyNotify ( \r
+  IN EMU_GRAPHICS_WINDOW_PROTOCOL                         *GraphicsWindowsIo, \r
+  IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK     MakeCallBack,\r
+  IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK     BreakCallBack,\r
+  IN VOID                                                 *Context\r
+  );\r
+\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+GasketX11Blt (\r
+  IN  EMU_GRAPHICS_WINDOW_PROTOCOL            *GraphicsWindows,\r
+  IN  EFI_UGA_PIXEL                           *BltBuffer OPTIONAL,\r
+  IN  EFI_UGA_BLT_OPERATION                   BltOperation,\r
+  IN  EMU_GRAPHICS_WINDOWS__BLT_ARGS          *Args\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketX11CheckPointer (\r
+  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo\r
+  );\r
+\r
+EFI_STATUS \r
+EFIAPI \r
+GasketX11GetPointerState (\r
+  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo, \r
+  EFI_SIMPLE_POINTER_STATE *state\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketX11GraphicsWindowOpen (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  );\r
\r
+EFI_STATUS\r
+EFIAPI\r
+GasketX11GraphicsWindowClose (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  );\r
+\r
+// Pthreads\r
+\r
+UINTN\r
+EFIAPI\r
+GasketPthreadMutexLock (\r
+  IN VOID *Mutex\r
+  );            \r
+\r
+\r
+\r
+UINTN\r
+EFIAPI\r
+GasketPthreadMutexUnLock (\r
+  IN VOID *Mutex\r
+  );                        \r
+\r
\r
+UINTN\r
+EFIAPI\r
+GasketPthreadMutexTryLock (\r
+  IN VOID *Mutex\r
+  );                      \r
+\r
\r
+VOID *\r
+EFIAPI\r
+GasketPthreadMutexInit (\r
+  IN VOID\r
+  );                     \r
+\r
\r
+UINTN\r
+EFIAPI\r
+GasketPthreadMutexDestroy (\r
+  IN VOID *Mutex\r
+  );                            \r
+\r
\r
+UINTN\r
+EFIAPI\r
+GasketPthreadCreate (\r
+  IN  VOID                      *Thread,\r
+  IN  VOID                      *Attribute,\r
+  IN  THREAD_THUNK_THREAD_ENTRY Start,\r
+  IN  VOID                      *Context\r
+  );\r
\r
+VOID\r
+EFIAPI\r
+GasketPthreadExit (\r
+  IN VOID *ValuePtr\r
+  );                            \r
+\r
+   \r
+UINTN\r
+EFIAPI\r
+GasketPthreadSelf (\r
+  VOID\r
+  );                              \r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketPthreadOpen (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketPthreadClose (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  );\r
+\r
+\r
+// PosixFileSystem\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketPosixOpenVolume (\r
+  IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL    *This,\r
+  OUT EFI_FILE_PROTOCOL                 **Root\r
+  );\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+GasketPosixFileOpen (\r
+  IN EFI_FILE_PROTOCOL        *This,\r
+  OUT EFI_FILE_PROTOCOL       **NewHandle,\r
+  IN CHAR16                   *FileName,\r
+  IN UINT64                   OpenMode,\r
+  IN UINT64                   Attributes\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketPosixFileCLose (\r
+  IN EFI_FILE_PROTOCOL  *This\r
+  );\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+GasketPosixFileDelete (\r
+  IN EFI_FILE_PROTOCOL  *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketPosixFileRead (\r
+  IN EFI_FILE_PROTOCOL        *This,\r
+  IN OUT UINTN                *BufferSize,\r
+  OUT VOID                    *Buffer\r
+  );\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+GasketPosixFileWrite (\r
+  IN EFI_FILE_PROTOCOL        *This,\r
+  IN OUT UINTN                *BufferSize,\r
+  IN VOID                     *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketPosixFileSetPossition (\r
+  IN EFI_FILE_PROTOCOL        *This,\r
+  IN UINT64                   Position\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketPosixFileGetPossition (\r
+  IN EFI_FILE_PROTOCOL        *This,\r
+  OUT UINT64                  *Position\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketPosixFileGetInfo (\r
+  IN EFI_FILE_PROTOCOL        *This,\r
+  IN EFI_GUID                 *InformationType,\r
+  IN OUT UINTN                *BufferSize,\r
+  OUT VOID                    *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketPosixFileSetInfo (\r
+  IN EFI_FILE_PROTOCOL        *This,\r
+  IN EFI_GUID                 *InformationType,\r
+  IN UINTN                    BufferSize,\r
+  IN VOID                     *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketPosixFileFlush (\r
+  IN EFI_FILE_PROTOCOL  *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketPosixFileSystmeThunkOpen (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketPosixFileSystmeThunkClose (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketEmuBlockIoReset (\r
+  IN EMU_BLOCK_IO_PROTOCOL    *This,\r
+  IN BOOLEAN                  ExtendedVerification\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketEmuBlockIoReadBlocks (\r
+  IN     EMU_BLOCK_IO_PROTOCOL  *This,\r
+  IN     UINT32                 MediaId,\r
+  IN     EFI_LBA                LBA,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
+  IN     UINTN                  BufferSize,\r
+     OUT VOID                   *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketEmuBlockIoWriteBlocks (\r
+  IN     EMU_BLOCK_IO_PROTOCOL  *This,\r
+  IN     UINT32                 MediaId,\r
+  IN     EFI_LBA                LBA,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
+  IN     UINTN                  BufferSize,\r
+  IN     VOID                   *Buffer\r
+  );\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+GasketEmuBlockIoFlushBlocks (\r
+  IN     EMU_BLOCK_IO_PROTOCOL    *This,\r
+  IN OUT EFI_BLOCK_IO2_TOKEN      *Token\r
+  );\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+GasketEmuBlockIoCreateMapping (\r
+  IN     EMU_BLOCK_IO_PROTOCOL    *This,\r
+  IN     EFI_BLOCK_IO_MEDIA       *Media\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketBlockIoThunkOpen (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketBlockIoThunkClose (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpThunkOpen (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpThunkClose (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpCreateMapping (\r
+  IN     EMU_SNP_PROTOCOL         *This,\r
+  IN     EFI_SIMPLE_NETWORK_MODE  *Media\r
+  );\r
\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpStart (\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpStop (\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpInitialize (\r
+  IN EMU_SNP_PROTOCOL                    *This,\r
+  IN UINTN                               ExtraRxBufferSize  OPTIONAL,\r
+  IN UINTN                               ExtraTxBufferSize  OPTIONAL\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpReset (\r
+  IN EMU_SNP_PROTOCOL   *This,\r
+  IN BOOLEAN            ExtendedVerification\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpShutdown (\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpReceiveFilters (\r
+  IN EMU_SNP_PROTOCOL                             *This,\r
+  IN UINT32                                       Enable,\r
+  IN UINT32                                       Disable,\r
+  IN BOOLEAN                                      ResetMCastFilter,\r
+  IN UINTN                                        MCastFilterCnt     OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                              *MCastFilter OPTIONAL\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpStationAddress (\r
+  IN EMU_SNP_PROTOCOL            *This,\r
+  IN BOOLEAN                     Reset,\r
+  IN EFI_MAC_ADDRESS             *New OPTIONAL\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpStatistics (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              Reset,\r
+  IN OUT UINTN                            *StatisticsSize   OPTIONAL,\r
+  OUT EFI_NETWORK_STATISTICS              *StatisticsTable  OPTIONAL\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpMCastIpToMac (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              IPv6,\r
+  IN EFI_IP_ADDRESS                       *IP,\r
+  OUT EFI_MAC_ADDRESS                     *MAC\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpNvData (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              ReadWrite,\r
+  IN UINTN                                Offset,\r
+  IN UINTN                                BufferSize,\r
+  IN OUT VOID                             *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpGetStatus (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  OUT UINT32                              *InterruptStatus OPTIONAL,\r
+  OUT VOID                                **TxBuf OPTIONAL\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpTransmit (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN UINTN                                HeaderSize,\r
+  IN UINTN                                BufferSize,\r
+  IN VOID                                 *Buffer,\r
+  IN EFI_MAC_ADDRESS                      *SrcAddr  OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                      *DestAddr OPTIONAL,\r
+  IN UINT16                               *Protocol OPTIONAL\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSnpReceive (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  OUT UINTN                               *HeaderSize OPTIONAL,\r
+  IN OUT UINTN                            *BufferSize,\r
+  OUT VOID                                *Buffer,\r
+  OUT EFI_MAC_ADDRESS                     *SrcAddr    OPTIONAL,\r
+  OUT EFI_MAC_ADDRESS                     *DestAddr   OPTIONAL,\r
+  OUT UINT16                              *Protocol   OPTIONAL\r
+  );\r
+\r
\r
+#endif\r
+\r
+\r
diff --git a/EmulatorPkg/Unix/Host/Ia32/Gasket.S b/EmulatorPkg/Unix/Host/Ia32/Gasket.S
new file mode 100644 (file)
index 0000000..aa031ec
--- /dev/null
@@ -0,0 +1,1492 @@
+#------------------------------------------------------------------------------
+#
+# Manage differenced between UNIX ABI and EFI/Windows ABI
+#
+# For IA-32 the only difference is Mac OS X requires a 16-byte aligned stack.
+# For Linux this stack adjustment is a no-op, but we may as well make the 
+# the code common. 
+#
+# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
+# 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.
+#
+#------------------------------------------------------------------------------
+
+
+  .text
+  
+//
+// EMU_THUNK_PROTOCOL gaskets (EFIAPI to UNIX ABI)
+//
+
+
+ASM_GLOBAL ASM_PFX(GasketSecWriteStdErr) 
+ASM_PFX(GasketSecWriteStdErr):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecWriteStdErr)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecConfigStdIn) 
+ASM_PFX(GasketSecConfigStdIn):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecConfigStdIn)
+  
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecWriteStdOut) 
+ASM_PFX(GasketSecWriteStdOut):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecWriteStdOut)
+  
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecReadStdIn)  
+ASM_PFX(GasketSecReadStdIn):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecReadStdIn)
+  
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecPollStdIn)  
+ASM_PFX(GasketSecPollStdIn):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecPollStdIn)
+  
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecMalloc) 
+ASM_PFX(GasketSecMalloc):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(SecMalloc)
+  
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecValloc) 
+ASM_PFX(GasketSecValloc):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(SecValloc)
+  
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecFree) 
+ASM_PFX(GasketSecFree):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(SecFree)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecSetTimer) 
+ASM_PFX(GasketSecSetTimer):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl 16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    8(%ebp), %eax
+       movl    12(%ebp), %edx
+       movl    %edx, 4(%esp)
+       movl    %eax, (%esp)
+
+  call  ASM_PFX(SecSetTimer)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecEnableInterrupt) 
+ASM_PFX(GasketSecEnableInterrupt):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(SecEnableInterrupt)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecDisableInterrupt) 
+ASM_PFX(GasketSecDisableInterrupt):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(SecDisableInterrupt)
+  
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketQueryPerformanceFrequency) 
+ASM_PFX(GasketQueryPerformanceFrequency):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(QueryPerformanceFrequency)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketQueryPerformanceCounter) 
+ASM_PFX(GasketQueryPerformanceCounter):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(QueryPerformanceCounter)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecSleep) 
+ASM_PFX(GasketSecSleep):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    8(%ebp), %eax
+       movl    12(%ebp), %ecx
+       movl    %ecx, 4(%esp)
+       movl    %eax, (%esp)
+
+  call  ASM_PFX(SecSleep)
+  
+  leave
+  ret
+  
+   
+ASM_GLOBAL ASM_PFX(GasketSecCpuSleep) 
+ASM_PFX(GasketSecCpuSleep):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call  ASM_PFX(SecCpuSleep)
+  
+  leave
+  ret
+  
+  
+ASM_GLOBAL ASM_PFX(GasketSecExit) 
+ASM_PFX(GasketSecExit):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(SecExit)     // Less to do as we will never return to EFI ABI world
+LDEAD_LOOP:
+  jmp  LDEAD_LOOP              // _exit should never return
+
+  
+ASM_GLOBAL ASM_PFX(GasketSecGetTime) 
+ASM_PFX(GasketSecGetTime):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecGetTime)
+
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecSetTime) 
+ASM_PFX(GasketSecSetTime):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecSetTime)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecGetNextProtocol) 
+ASM_PFX(GasketSecGetNextProtocol):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(SecGetNextProtocol)
+  
+  leave
+  ret
+
+// PPIs produced by SEC
+
+ASM_GLOBAL ASM_PFX(GasketSecPeCoffGetEntryPoint) 
+ASM_PFX(GasketSecPeCoffGetEntryPoint):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(SecPeCoffGetEntryPoint)
+  
+  leave
+  ret
+ASM_GLOBAL ASM_PFX(GasketSecPeCoffRelocateImageExtraAction) 
+ASM_PFX(GasketSecPeCoffRelocateImageExtraAction):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(SecPeCoffRelocateImageExtraAction)
+  
+  leave
+  ret
+ASM_GLOBAL ASM_PFX(GasketSecPeCoffUnloadImageExtraAction) 
+ASM_PFX(GasketSecPeCoffUnloadImageExtraAction):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(SecPeCoffUnloadImageExtraAction)
+  
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecEmuThunkAddress) 
+ASM_PFX(GasketSecEmuThunkAddress):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(SecEmuThunkAddress)
+  
+  leave
+  ret
+
+//
+// Gasket functions for EFI_EMU_UGA_IO_PROTOCOL
+//
+
+ASM_GLOBAL ASM_PFX(GasketX11Size) 
+ASM_PFX(GasketX11Size):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(X11Size)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11CheckKey) 
+ASM_PFX(GasketX11CheckKey):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11CheckKey)
+  
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketX11GetKey) 
+ASM_PFX(GasketX11GetKey):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11GetKey)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11KeySetState) 
+ASM_PFX(GasketX11KeySetState):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11KeySetState)
+  
+  leave
+  ret
+
+  
+ASM_GLOBAL ASM_PFX(GasketX11RegisterKeyNotify) 
+ASM_PFX(GasketX11RegisterKeyNotify):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(X11RegisterKeyNotify)
+  
+  leave
+  ret
+
+  
+ASM_GLOBAL ASM_PFX(GasketX11Blt) 
+ASM_PFX(GasketX11Blt):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(X11Blt)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11CheckPointer) 
+ASM_PFX(GasketX11CheckPointer):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11CheckPointer)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11GetPointerState) 
+ASM_PFX(GasketX11GetPointerState):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11GetPointerState)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowOpen) 
+ASM_PFX(GasketX11GraphicsWindowOpen):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11GraphicsWindowOpen)
+  
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowClose) 
+ASM_PFX(GasketX11GraphicsWindowClose):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11GraphicsWindowClose)
+  
+  leave
+  ret
+
+
+// Pthreads
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexLock) 
+ASM_PFX(GasketPthreadMutexLock):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadMutexLock)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexUnLock) 
+ASM_PFX(GasketPthreadMutexUnLock):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadMutexUnLock)
+  
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexTryLock) 
+ASM_PFX(GasketPthreadMutexTryLock):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadMutexTryLock)
+  
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexInit) 
+ASM_PFX(GasketPthreadMutexInit):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(PthreadMutexInit)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexDestroy) 
+ASM_PFX(GasketPthreadMutexDestroy):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadMutexDestroy)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadCreate)  
+ASM_PFX(GasketPthreadCreate):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(PthreadCreate)
+  
+  leave
+  ret
+
+                          
+ASM_GLOBAL ASM_PFX(GasketPthreadExit) 
+ASM_PFX(GasketPthreadExit):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadExit)
+  
+  leave
+  ret
+
+
+                             
+ASM_GLOBAL ASM_PFX(GasketPthreadSelf) 
+ASM_PFX(GasketPthreadSelf):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(PthreadSelf)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadOpen) 
+ASM_PFX(GasketPthreadOpen):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadOpen)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadClose)  
+ASM_PFX(GasketPthreadClose):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadClose)
+  
+  leave
+  ret
+
+
+
+
+//
+// UNIX ABI to EFI ABI call
+//
+// UINTN
+// ReverseGasketUint64 (
+//   void *Api,
+//   UINTN Arg1
+//   );
+ASM_GLOBAL ASM_PFX(ReverseGasketUint64)
+ASM_PFX(ReverseGasketUint64):
+       pushl   %ebp
+       movl    %esp, %ebp
+       subl    $8, %esp
+       movl    16(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, (%esp)
+       calll   *8(%ebp)
+       addl    $8, %esp
+       popl    %ebp
+       ret
+
+
+
+//
+// UNIX ABI to EFI ABI call
+//
+// UINTN
+// ReverseGasketUint64Uint64 (
+//   void *Api,
+//   UINTN Arg1
+//   UINTN Arg2
+//   );
+ASM_GLOBAL ASM_PFX(ReverseGasketUint64Uint64)
+ASM_PFX(ReverseGasketUint64Uint64):
+       pushl   %ebp
+       movl    %esp, %ebp
+       subl    $24, %esp
+       movl    24(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    20(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, (%esp)
+       calll   *8(%ebp)
+       addl    $24, %esp
+       popl    %ebp
+       ret
+  
+
+ASM_GLOBAL ASM_PFX(GasketSecUnixPeiAutoScan)  
+ASM_PFX(GasketSecUnixPeiAutoScan):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(SecUnixPeiAutoScan)
+  
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecUnixFdAddress) 
+ASM_PFX(GasketSecUnixFdAddress):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(SecUnixFdAddress)
+
+  leave
+  ret
+
+
+// EmuIoThunk SimpleFileSystem
+
+ASM_GLOBAL ASM_PFX(GasketPosixOpenVolume) 
+ASM_PFX(GasketPosixOpenVolume):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(PosixOpenVolume)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileOpen) 
+ASM_PFX(GasketPosixFileOpen):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $56, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    28(%ebp), %eax
+       movl    32(%ebp), %ecx
+       movl    %ecx, 24(%esp)
+       movl    %eax, 20(%esp)
+       movl    20(%ebp), %eax
+       movl    24(%ebp), %ecx
+       movl    %ecx, 16(%esp)
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+  call    ASM_PFX(PosixFileOpen)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileCLose) 
+ASM_PFX(GasketPosixFileCLose):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PosixFileCLose)
+
+  leave
+  ret
+
+   
+ASM_GLOBAL ASM_PFX(GasketPosixFileDelete) 
+ASM_PFX(GasketPosixFileDelete):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PosixFileDelete)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileRead) 
+ASM_PFX(GasketPosixFileRead):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(PosixFileRead)
+
+  leave
+  ret
+
+  
+ASM_GLOBAL ASM_PFX(GasketPosixFileWrite) 
+ASM_PFX(GasketPosixFileWrite):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(PosixFileWrite)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileSetPossition) 
+ASM_PFX(GasketPosixFileSetPossition):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    12(%ebp), %eax
+       movl    16(%ebp), %ecx
+       movl    %ecx, 8(%esp)
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(PosixFileSetPossition)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileGetPossition) 
+ASM_PFX(GasketPosixFileGetPossition):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PosixFileGetPossition)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileGetInfo) 
+ASM_PFX(GasketPosixFileGetInfo):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(PosixFileGetInfo)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileSetInfo) 
+ASM_PFX(GasketPosixFileSetInfo):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(PosixFileSetInfo)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileFlush) 
+ASM_PFX(GasketPosixFileFlush):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PosixFileFlush)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkOpen) 
+ASM_PFX(GasketPosixFileSystmeThunkOpen):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PosixFileSystmeThunkOpen)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkClose) 
+ASM_PFX(GasketPosixFileSystmeThunkClose):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PosixFileSystmeThunkClose)
+
+  leave
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReset) 
+ASM_PFX(GasketEmuBlockIoReset):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuBlockIoReset)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReadBlocks) 
+ASM_PFX(GasketEmuBlockIoReadBlocks):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $56, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    32(%ebp), %eax
+       movl    %eax, 24(%esp)
+       movl    28(%ebp), %eax
+       movl    %eax, 20(%esp)
+       movl    24(%ebp), %eax
+       movl    %eax, 16(%esp)
+       movl    16(%ebp), %eax
+       movl    20(%ebp), %edx
+       movl    %edx, 12(%esp)
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuBlockIoReadBlocks)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoWriteBlocks)  
+ASM_PFX(GasketEmuBlockIoWriteBlocks):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $56, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    32(%ebp), %eax
+       movl    %eax, 24(%esp)
+       movl    28(%ebp), %eax
+       movl    %eax, 20(%esp)
+       movl    24(%ebp), %eax
+       movl    %eax, 16(%esp)
+       movl    16(%ebp), %eax
+       movl    20(%ebp), %edx
+       movl    %edx, 12(%esp)
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuBlockIoWriteBlocks)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoFlushBlocks)  
+ASM_PFX(GasketEmuBlockIoFlushBlocks):  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+
+  call    ASM_PFX(EmuBlockIoFlushBlocks)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoCreateMapping) 
+ASM_PFX(GasketEmuBlockIoCreateMapping):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuBlockIoCreateMapping)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketBlockIoThunkOpen)  
+ASM_PFX(GasketBlockIoThunkOpen):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuBlockIoThunkOpen)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketBlockIoThunkClose)  
+ASM_PFX(GasketBlockIoThunkClose):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuBlockIoThunkClose)
+
+  leave
+  ret
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpCreateMapping) 
+ASM_PFX(GasketSnpCreateMapping):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpCreateMapping)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpStart) 
+ASM_PFX(GasketSnpStart):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpStart)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpStop) 
+ASM_PFX(GasketSnpStop):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpStop)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpInitialize) 
+ASM_PFX(GasketSnpInitialize):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpInitialize)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpReset)  
+ASM_PFX(GasketSnpReset):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpReset)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpShutdown) 
+ASM_PFX(GasketSnpShutdown):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpShutdown)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpReceiveFilters)  
+ASM_PFX(GasketSnpReceiveFilters):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    28(%ebp), %eax
+       movl    %eax, 20(%esp)
+       movl    24(%ebp), %eax
+       movl    %eax, 16(%esp)
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpReceiveFilters)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpStationAddress)  
+ASM_PFX(GasketSnpStationAddress):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  leave
+  ret
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpStatistics) 
+ASM_PFX(GasketSnpStatistics):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpStatistics)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpMCastIpToMac) 
+ASM_PFX(GasketSnpMCastIpToMac):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpMCastIpToMac)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpNvData) 
+ASM_PFX(GasketSnpNvData):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    24(%ebp), %eax
+       movl    %eax, 16(%esp)
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpNvData)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpGetStatus) 
+ASM_PFX(GasketSnpGetStatus):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpGetStatus)
+
+  leave
+  ret
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpTransmit) 
+ASM_PFX(GasketSnpTransmit):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $56, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    32(%ebp), %eax
+       movl    %eax, 24(%esp)
+       movl    28(%ebp), %eax
+       movl    %eax, 20(%esp)
+       movl    24(%ebp), %eax
+       movl    %eax, 16(%esp)
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpTransmit)
+
+  leave
+  ret
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpReceive) 
+ASM_PFX(GasketSnpReceive):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $56, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    32(%ebp), %eax
+       movl    %eax, 24(%esp)
+       movl    28(%ebp), %eax
+       movl    %eax, 20(%esp)
+       movl    24(%ebp), %eax
+       movl    %eax, 16(%esp)
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpReceive)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpThunkOpen) 
+ASM_PFX(GasketSnpThunkOpen):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpThunkOpen)
+
+  leave
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpThunkClose) 
+ASM_PFX(GasketSnpThunkClose):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpThunkClose)
+
+  leave
+  ret
+
+
diff --git a/EmulatorPkg/Unix/Host/Ia32/SwitchStack.c b/EmulatorPkg/Unix/Host/Ia32/SwitchStack.c
new file mode 100644 (file)
index 0000000..c75073a
--- /dev/null
@@ -0,0 +1,74 @@
+/*++
+
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+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 "SecMain.h"
+
+
+/**
+  Transfers control to a function starting with a new stack.
+
+  Transfers control to the function specified by EntryPoint using the new stack
+  specified by NewStack and passing in the parameters specified by Context1 and
+  Context2. Context1 and Context2 are optional and may be NULL. The function
+  EntryPoint must never return.
+
+  If EntryPoint is NULL, then ASSERT().
+  If NewStack is NULL, then ASSERT().
+
+  @param  EntryPoint  A pointer to function to call with the new stack.
+  @param  Context1    A pointer to the context to pass into the EntryPoint
+                      function.
+  @param  Context2    A pointer to the context to pass into the EntryPoint
+                      function.
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint
+                      function.
+
+**/
+VOID
+EFIAPI
+PeiSwitchStacks (
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,
+  IN      VOID                      *Context1,  OPTIONAL
+  IN      VOID                      *Context2,  OPTIONAL
+  IN      VOID                      *NewStack
+  )
+{
+  BASE_LIBRARY_JUMP_BUFFER  JumpBuffer;
+  
+  ASSERT (EntryPoint != NULL);
+  ASSERT (NewStack != NULL);
+
+  //
+  // Stack should be aligned with CPU_STACK_ALIGNMENT
+  //
+  ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);
+
+  JumpBuffer.Eip = (UINTN)EntryPoint;
+  JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);
+  JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2);
+  ((VOID**)JumpBuffer.Esp)[1] = Context1;
+  ((VOID**)JumpBuffer.Esp)[2] = Context2;
+
+  LongJump (&JumpBuffer, (UINTN)-1);
+  
+
+  //
+  // PeiSwitchStacks () will never return
+  //
+  ASSERT (FALSE);  
+}
+
+
+
diff --git a/EmulatorPkg/Unix/Host/LinuxPacketFilter.c b/EmulatorPkg/Unix/Host/LinuxPacketFilter.c
new file mode 100644 (file)
index 0000000..20a08c9
--- /dev/null
@@ -0,0 +1,604 @@
+/**@file\r
+ Linux Packet Filter implementation of the EMU_SNP_PROTOCOL that allows the \r
+ emulator to get on real networks.\r
+\r
+ Currently only the Berkeley Packet Filter is fully implemented and this file\r
+ is just a template that needs to get filled in. \r
+\r
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Portitions copyright (c) 2011, Apple Inc. All rights reserved.\r
+\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+\r
+#include "SecMain.h"\r
+\r
+#ifndef __APPLE__\r
+\r
+#define EMU_SNP_PRIVATE_SIGNATURE SIGNATURE_32('E', 'M', 's', 'n')\r
+typedef struct {\r
+  UINTN                       Signature;\r
+\r
+  EMU_IO_THUNK_PROTOCOL       *Thunk;\r
+\r
+\r
+  EMU_SNP_PROTOCOL            EmuSnp;\r
+  EFI_SIMPLE_NETWORK_MODE     *Mode;\r
+\r
+} EMU_SNP_PRIVATE;\r
+\r
+#define EMU_SNP_PRIVATE_DATA_FROM_THIS(a) \\r
+         CR(a, EMU_SNP_PRIVATE, EmuSnp, EMU_SNP_PRIVATE_SIGNATURE)\r
+\r
+/**\r
+  Register storage for SNP Mode.\r
+\r
+  @param  This Protocol instance pointer.\r
+  @param  Mode SimpleNetworkProtocol Mode structure passed into driver.\r
+\r
+  @retval EFI_SUCCESS           The network interface was started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpCreateMapping (\r
+  IN     EMU_SNP_PROTOCOL         *This,\r
+  IN     EFI_SIMPLE_NETWORK_MODE  *Mode\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  Private->Mode = Mode;\r
+    \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Changes the state of a network interface from "stopped" to "started".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           The network interface was started.\r
+  @retval EFI_ALREADY_STARTED   The network interface is already in the started state.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpStart (\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Changes the state of a network interface from "started" to "stopped".\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           The network interface was stopped.\r
+  @retval EFI_ALREADY_STARTED   The network interface is already in the stopped state.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpStop (\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Resets a network adapter and allocates the transmit and receive buffers \r
+  required by the network interface; optionally, also requests allocation \r
+  of additional transmit and receive buffers.\r
+\r
+  @param  This              The protocol instance pointer.\r
+  @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+  @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
+                            that the driver should allocate for the network interface.\r
+                            Some network interfaces will not be able to use the extra\r
+                            buffer, and the caller will not know if it is actually\r
+                            being used.\r
+\r
+  @retval EFI_SUCCESS           The network interface was initialized.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_OUT_OF_RESOURCES  There was not enough memory for the transmit and\r
+                                receive buffers.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpInitialize (\r
+  IN EMU_SNP_PROTOCOL                    *This,\r
+  IN UINTN                               ExtraRxBufferSize  OPTIONAL,\r
+  IN UINTN                               ExtraTxBufferSize  OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Resets a network adapter and re-initializes it with the parameters that were \r
+  provided in the previous call to Initialize().  \r
+\r
+  @param  This                 The protocol instance pointer.\r
+  @param  ExtendedVerification Indicates that the driver may perform a more\r
+                               exhaustive verification operation of the device\r
+                               during reset.\r
+\r
+  @retval EFI_SUCCESS           The network interface was reset.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpReset (\r
+  IN EMU_SNP_PROTOCOL   *This,\r
+  IN BOOLEAN            ExtendedVerification\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Resets a network adapter and leaves it in a state that is safe for \r
+  another driver to initialize.\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           The network interface was shutdown.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpShutdown (\r
+  IN EMU_SNP_PROTOCOL  *This\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Manages the multicast receive filters of a network interface.\r
+\r
+  @param  This             The protocol instance pointer.\r
+  @param  Enable           A bit mask of receive filters to enable on the network interface.\r
+  @param  Disable          A bit mask of receive filters to disable on the network interface.\r
+  @param  ResetMCastFilter Set to TRUE to reset the contents of the multicast receive\r
+                           filters on the network interface to their default values.\r
+  @param  McastFilterCnt   Number of multicast HW MAC addresses in the new\r
+                           MCastFilter list. This value must be less than or equal to\r
+                           the MCastFilterCnt field of EMU_SNP_MODE. This\r
+                           field is optional if ResetMCastFilter is TRUE.\r
+  @param  MCastFilter      A pointer to a list of new multicast receive filter HW MAC\r
+                           addresses. This list will replace any existing multicast\r
+                           HW MAC address list. This field is optional if\r
+                           ResetMCastFilter is TRUE.\r
+\r
+  @retval EFI_SUCCESS           The multicast receive filter list was updated.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpReceiveFilters (\r
+  IN EMU_SNP_PROTOCOL                             *This,\r
+  IN UINT32                                       Enable,\r
+  IN UINT32                                       Disable,\r
+  IN BOOLEAN                                      ResetMCastFilter,\r
+  IN UINTN                                        MCastFilterCnt     OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                              *MCastFilter OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Modifies or resets the current station address, if supported.\r
+\r
+  @param  This  The protocol instance pointer.\r
+  @param  Reset Flag used to reset the station address to the network interfaces\r
+                permanent address.\r
+  @param  New   The new station address to be used for the network interface.\r
+\r
+  @retval EFI_SUCCESS           The network interfaces station address was updated.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpStationAddress (\r
+  IN EMU_SNP_PROTOCOL            *This,\r
+  IN BOOLEAN                     Reset,\r
+  IN EFI_MAC_ADDRESS             *New OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Resets or collects the statistics on a network interface.\r
+\r
+  @param  This            Protocol instance pointer.\r
+  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
+  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
+                          output the size, in bytes, of the resulting table of\r
+                          statistics.\r
+  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
+                          contains the statistics.\r
+\r
+  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpStatistics (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              Reset,\r
+  IN OUT UINTN                            *StatisticsSize   OPTIONAL,\r
+  OUT EFI_NETWORK_STATISTICS              *StatisticsTable  OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Converts a multicast IP address to a multicast HW MAC address.\r
+\r
+  @param  This The protocol instance pointer.\r
+  @param  IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
+               to FALSE if the multicast IP address is IPv4 [RFC 791].\r
+  @param  IP   The multicast IP address that is to be converted to a multicast\r
+               HW MAC address.\r
+  @param  MAC  The multicast HW MAC address that is to be generated from IP.\r
+\r
+  @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast\r
+                                HW MAC address.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
+                                size needed to hold the statistics is returned in\r
+                                StatisticsSize.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpMCastIpToMac (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              IPv6,\r
+  IN EFI_IP_ADDRESS                       *IP,\r
+  OUT EFI_MAC_ADDRESS                     *MAC\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Performs read and write operations on the NVRAM device attached to a \r
+  network interface.\r
+\r
+  @param  This       The protocol instance pointer.\r
+  @param  ReadWrite  TRUE for read operations, FALSE for write operations.\r
+  @param  Offset     Byte offset in the NVRAM device at which to start the read or\r
+                     write operation. This must be a multiple of NvRamAccessSize and\r
+                     less than NvRamSize.\r
+  @param  BufferSize The number of bytes to read or write from the NVRAM device.\r
+                     This must also be a multiple of NvramAccessSize.\r
+  @param  Buffer     A pointer to the data buffer.\r
+\r
+  @retval EFI_SUCCESS           The NVRAM access was performed.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpNvData (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN BOOLEAN                              ReadWrite,\r
+  IN UINTN                                Offset,\r
+  IN UINTN                                BufferSize,\r
+  IN OUT VOID                             *Buffer\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Reads the current interrupt status and recycled transmit buffer status from \r
+  a network interface.\r
+\r
+  @param  This            The protocol instance pointer.\r
+  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
+                          If this is NULL, the interrupt status will not be read from\r
+                          the device. If this is not NULL, the interrupt status will\r
+                          be read from the device. When the  interrupt status is read,\r
+                          it will also be cleared. Clearing the transmit  interrupt\r
+                          does not empty the recycled transmit buffer array.\r
+  @param  TxBuf           Recycled transmit buffer address. The network interface will\r
+                          not transmit if its internal recycled transmit buffer array\r
+                          is full. Reading the transmit buffer does not clear the\r
+                          transmit interrupt. If this is NULL, then the transmit buffer\r
+                          status will not be read. If there are no transmit buffers to\r
+                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
+\r
+  @retval EFI_SUCCESS           The status of the network interface was retrieved.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpGetStatus (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  OUT UINT32                              *InterruptStatus OPTIONAL,\r
+  OUT VOID                                **TxBuf OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Places a packet in the transmit queue of a network interface.\r
+\r
+  @param  This       The protocol instance pointer.\r
+  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
+                     the Transmit() function. If HeaderSize is non-zero, then it\r
+                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
+                     and Protocol parameters must not be NULL.\r
+  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
+                     data) to be transmitted through the network interface.\r
+  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
+                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
+                     then the media header in Buffer must already be filled in by the\r
+                     caller. If HeaderSize is non-zero, then the media header will be\r
+                     filled in by the Transmit() function.\r
+  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
+                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
+                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
+  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
+                     parameter is ignored.\r
+  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
+                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
+                     examples.\r
+\r
+  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_NOT_READY         The network interface is too busy to accept this transmit request.                      \r
+  @retval EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpTransmit (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  IN UINTN                                HeaderSize,\r
+  IN UINTN                                BufferSize,\r
+  IN VOID                                 *Buffer,\r
+  IN EFI_MAC_ADDRESS                      *SrcAddr  OPTIONAL,\r
+  IN EFI_MAC_ADDRESS                      *DestAddr OPTIONAL,\r
+  IN UINT16                               *Protocol OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Receives a packet from a network interface.\r
+\r
+  @param  This       The protocol instance pointer.\r
+  @param  HeaderSize The size, in bytes, of the media header received on the network\r
+                     interface. If this parameter is NULL, then the media header size\r
+                     will not be returned.\r
+  @param  BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
+                     bytes, of the packet that was received on the network interface.\r
+  @param  Buffer     A pointer to the data buffer to receive both the media header and\r
+                     the data.\r
+  @param  SrcAddr    The source HW MAC address. If this parameter is NULL, the\r
+                     HW MAC source address will not be extracted from the media\r
+                     header.\r
+  @param  DestAddr   The destination HW MAC address. If this parameter is NULL,\r
+                     the HW MAC destination address will not be extracted from the\r
+                     media header.\r
+  @param  Protocol   The media header type. If this parameter is NULL, then the\r
+                     protocol will not be extracted from the media header. See\r
+                     RFC 1700 section "Ether Types" for examples.\r
+\r
+  @retval  EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
+                                 been updated to the number of bytes received.\r
+  @retval  EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
+                                 request.\r
+  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
+  @retval  EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
+  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
+  @retval  EFI_UNSUPPORTED       This function is not supported by the network interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EmuSnpReceive (\r
+  IN EMU_SNP_PROTOCOL                     *This,\r
+  OUT UINTN                               *HeaderSize OPTIONAL,\r
+  IN OUT UINTN                            *BufferSize,\r
+  OUT VOID                                *Buffer,\r
+  OUT EFI_MAC_ADDRESS                     *SrcAddr    OPTIONAL,\r
+  OUT EFI_MAC_ADDRESS                     *DestAddr   OPTIONAL,\r
+  OUT UINT16                              *Protocol   OPTIONAL\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE    *Private;\r
+\r
+  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+\r
+EMU_SNP_PROTOCOL gEmuSnpProtocol = {\r
+  GasketSnpCreateMapping,\r
+  GasketSnpStart,\r
+  GasketSnpStop,\r
+  GasketSnpInitialize,\r
+  GasketSnpReset,\r
+  GasketSnpShutdown,\r
+  GasketSnpReceiveFilters,\r
+  GasketSnpStationAddress,\r
+  GasketSnpStatistics,\r
+  GasketSnpMCastIpToMac,\r
+  GasketSnpNvData,\r
+  GasketSnpGetStatus,\r
+  GasketSnpTransmit,\r
+  GasketSnpReceive\r
+};\r
+\r
+EFI_STATUS\r
+EmuSnpThunkOpen (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE  *Private;\r
+  \r
+  if (This->Private != NULL) {\r
+    return EFI_ALREADY_STARTED;\r
+  }\r
+  \r
+  if (!CompareGuid (This->Protocol, &gEmuSnpProtocolGuid)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  Private = malloc (sizeof (EMU_SNP_PRIVATE));\r
+  if (Private == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  \r
+  Private->Signature = EMU_SNP_PRIVATE_SIGNATURE;\r
+  Private->Thunk     = This;\r
+  CopyMem (&Private->EmuSnp, &gEmuSnpProtocol, sizeof (gEmuSnpProtocol));\r
+  \r
+  This->Interface = &Private->EmuSnp;\r
+  This->Private   = Private;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EmuSnpThunkClose (\r
+  IN  EMU_IO_THUNK_PROTOCOL   *This\r
+  )\r
+{\r
+  EMU_SNP_PRIVATE  *Private;\r
+\r
+  if (!CompareGuid (This->Protocol, &gEmuSnpProtocolGuid)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  Private = This->Private;\r
+  free (Private);\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+\r
+EMU_IO_THUNK_PROTOCOL gSnpThunkIo = {\r
+  &gEmuSnpProtocolGuid,\r
+  NULL,\r
+  NULL,\r
+  0,\r
+  GasketSnpThunkOpen,\r
+  GasketSnpThunkClose,\r
+  NULL\r
+};\r
+\r
+#endif\r
diff --git a/EmulatorPkg/Unix/Host/MemoryAllocationLib.c b/EmulatorPkg/Unix/Host/MemoryAllocationLib.c
new file mode 100644 (file)
index 0000000..76b7271
--- /dev/null
@@ -0,0 +1,145 @@
+/*++ @file
+
+  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+
+  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 "Base.h"
+#include "Library/BaseMemoryLib.h"
+#include "Library/MemoryAllocationLib.h"
+
+#include <stdlib.h>
+
+/**
+  Allocates a buffer of type EfiBootServicesData.
+
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
+  pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+  @param  AllocationSize        The number of bytes to allocate.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocatePool (
+  IN UINTN  AllocationSize
+  )
+{
+  return (VOID*) malloc (AllocationSize);
+}
+
+
+/**
+  Allocates and zeros a buffer of type EfiBootServicesData.
+
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the
+  request, then NULL is returned.
+
+  @param  AllocationSize        The number of bytes to allocate and zero.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateZeroPool (
+  IN UINTN  AllocationSize
+  )
+{
+  VOID *Buffer;
+
+  Buffer = AllocatePool (AllocationSize);
+  if (Buffer == NULL) {
+    return NULL;
+  }
+
+  ZeroMem (Buffer, AllocationSize);
+
+  return Buffer;
+}
+
+
+/**
+  Reallocates a buffer of type EfiBootServicesData.
+
+  Allocates and zeros the number bytes specified by NewSize from memory of type
+  EfiBootServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and 
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and 
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not 
+  enough memory remaining to satisfy the request, then NULL is returned.
+  
+  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
+  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
+
+  @param  OldSize        The size, in bytes, of OldBuffer.
+  @param  NewSize        The size, in bytes, of the buffer to reallocate.
+  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional 
+                         parameter that may be NULL.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+ReallocatePool (
+  IN UINTN  OldSize,
+  IN UINTN  NewSize,
+  IN VOID   *OldBuffer  OPTIONAL
+  )
+{
+  VOID *NewBuffer;
+
+  NewBuffer = AllocatePool (NewSize);
+  if (NewBuffer == NULL) {
+    return NULL;
+  }
+
+  if (OldBuffer != NULL) {
+    if (OldSize > 0) {
+      CopyMem (NewBuffer, OldBuffer, OldSize);
+    }
+
+    FreePool (OldBuffer);
+  }
+
+  return NewBuffer;
+}
+
+
+/**
+  Frees a buffer that was previously allocated with one of the pool allocation functions in the
+  Memory Allocation Library.
+
+  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the
+  pool allocation services of the Memory Allocation Library.  If it is not possible to free pool
+  resources, then this function will perform no actions.
+  
+  If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
+  then ASSERT().
+
+  @param  Buffer                Pointer to the buffer to free.
+
+**/
+VOID
+EFIAPI
+FreePool (
+  IN VOID   *Buffer
+  )
+{
+  free ((void *) Buffer);
+}
+
diff --git a/EmulatorPkg/Unix/Host/PosixFileSystem.c b/EmulatorPkg/Unix/Host/PosixFileSystem.c
new file mode 100644 (file)
index 0000000..3141a3c
--- /dev/null
@@ -0,0 +1,1556 @@
+/*++ @file
+ POSIX Pthreads to emulate APs and implement threads
+
+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 "SecMain.h"
+
+
+#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'P', 'f', 's')
+
+typedef struct {
+  UINTN                           Signature;
+  EMU_IO_THUNK_PROTOCOL           *Thunk;
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;
+  CHAR8                           *FilePath;
+  CHAR16                          *VolumeLabel;
+  BOOLEAN                         FileHandlesOpen;
+} EMU_SIMPLE_FILE_SYSTEM_PRIVATE;
+
+#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \
+  CR (a, \
+      EMU_SIMPLE_FILE_SYSTEM_PRIVATE, \
+      SimpleFileSystem, \
+      EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \
+      )
+
+
+#define EMU_EFI_FILE_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'P', 'f', 'i')
+
+typedef struct {
+  UINTN                           Signature;
+  EMU_IO_THUNK_PROTOCOL           *Thunk;
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
+  EFI_FILE_PROTOCOL               EfiFile;
+  int                             fd;
+  DIR                             *Dir;
+  BOOLEAN                         IsRootDirectory;
+  BOOLEAN                         IsDirectoryPath;
+  BOOLEAN                         IsOpenedByRead;
+  char                            *FileName;
+  struct dirent                   *Dirent;
+} EMU_EFI_FILE_PRIVATE;
+
+#define EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \
+  CR (a, \
+      EMU_EFI_FILE_PRIVATE, \
+      EfiFile, \
+      EMU_EFI_FILE_PRIVATE_SIGNATURE \
+      )
+
+EFI_STATUS
+PosixFileGetInfo (
+  IN EFI_FILE_PROTOCOL        *This,
+  IN EFI_GUID                 *InformationType,
+  IN OUT UINTN                *BufferSize,
+  OUT VOID                    *Buffer
+  );
+
+EFI_STATUS
+PosixFileSetInfo (
+  IN EFI_FILE_PROTOCOL        *This,
+  IN EFI_GUID                 *InformationType,
+  IN UINTN                    BufferSize,
+  IN VOID                     *Buffer
+  );
+
+
+EFI_FILE_PROTOCOL gPosixFileProtocol = {
+  EFI_FILE_REVISION,
+  GasketPosixFileOpen,
+  GasketPosixFileCLose,
+  GasketPosixFileDelete,
+  GasketPosixFileRead,
+  GasketPosixFileWrite,
+  GasketPosixFileGetPossition,
+  GasketPosixFileSetPossition,
+  GasketPosixFileGetInfo,
+  GasketPosixFileSetInfo,
+  GasketPosixFileFlush
+};
+
+EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gPosixFileSystemProtocol = {
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION,
+  GasketPosixOpenVolume,
+};
+
+
+/**
+  Open the root directory on a volume.
+
+  @param  This Protocol instance pointer.
+  @param  Root Returns an Open file handle for the root directory
+
+  @retval EFI_SUCCESS          The device was opened.
+  @retval EFI_UNSUPPORTED      This volume does not support the file system.
+  @retval EFI_NO_MEDIA         The device has no media.
+  @retval EFI_DEVICE_ERROR     The device reported an error.
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
+  @retval EFI_ACCESS_DENIED    The service denied access to the file.
+  @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
+
+**/
+EFI_STATUS
+PosixOpenVolume (
+  IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL    *This,
+  OUT EFI_FILE_PROTOCOL                 **Root
+  )
+{
+  EFI_STATUS                        Status;
+  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *Private;
+  EMU_EFI_FILE_PRIVATE              *PrivateFile;
+
+  Private     = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (This);
+
+  Status = EFI_OUT_OF_RESOURCES;
+  PrivateFile = malloc (sizeof (EMU_EFI_FILE_PRIVATE));
+  if (PrivateFile == NULL) {
+    goto Done;
+  }
+  
+  PrivateFile->FileName = malloc (AsciiStrSize (Private->FilePath));
+  if (PrivateFile->FileName == NULL) {
+    goto Done;
+  }
+  AsciiStrCpy (PrivateFile->FileName, Private->FilePath);
+  
+  PrivateFile->Signature            = EMU_EFI_FILE_PRIVATE_SIGNATURE;
+  PrivateFile->Thunk                = Private->Thunk;
+  PrivateFile->SimpleFileSystem     = This;
+  PrivateFile->IsRootDirectory      = TRUE;
+  PrivateFile->IsDirectoryPath      = TRUE;
+  PrivateFile->IsOpenedByRead       = TRUE;
+  
+  CopyMem (&PrivateFile->EfiFile, &gPosixFileProtocol, sizeof (EFI_FILE_PROTOCOL));
+
+  PrivateFile->fd                   = -1;
+  PrivateFile->Dir                  = NULL;
+  PrivateFile->Dirent               = NULL;
+  
+  *Root = &PrivateFile->EfiFile;
+
+  PrivateFile->Dir = opendir (PrivateFile->FileName);
+  if (PrivateFile->Dir == NULL) {
+    Status = EFI_ACCESS_DENIED;
+  } else {
+    Status = EFI_SUCCESS;
+  }
+
+Done:
+  if (EFI_ERROR (Status)) {
+    if (PrivateFile != NULL) {
+      if (PrivateFile->FileName != NULL) {
+        free (PrivateFile->FileName);
+      }
+
+      free (PrivateFile);
+    }
+    
+    *Root = NULL;
+  }
+  
+  return Status;
+}
+
+
+EFI_STATUS
+ErrnoToEfiStatus ()
+{
+  switch (errno) {
+  case EACCES:
+    return EFI_ACCESS_DENIED;
+    
+  case EDQUOT:
+  case ENOSPC:
+    return EFI_VOLUME_FULL;
+     
+  default:
+    return EFI_DEVICE_ERROR;      
+  }
+}
+
+VOID
+CutPrefix (
+  IN  CHAR8  *Str,
+  IN  UINTN   Count
+  )
+{
+  CHAR8  *Pointer;
+
+  if (AsciiStrLen (Str) < Count) {
+    ASSERT (0);
+  }
+
+  for (Pointer = Str; *(Pointer + Count); Pointer++) {
+    *Pointer = *(Pointer + Count);
+  }
+
+  *Pointer = *(Pointer + Count);
+}
+
+
+VOID
+PosixSystemTimeToEfiTime (
+  IN  time_t                SystemTime,
+  OUT EFI_TIME              *Time
+  )
+{
+  struct tm *tm;
+
+  tm           = gmtime (&SystemTime);
+  Time->Year   = tm->tm_year;
+  Time->Month  = tm->tm_mon + 1;
+  Time->Day    = tm->tm_mday;
+  Time->Hour   = tm->tm_hour;
+  Time->Minute = tm->tm_min;
+  Time->Second = tm->tm_sec;
+  Time->Nanosecond = 0;
+  
+  Time->TimeZone = timezone;
+  Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0) | (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
+}
+
+
+EFI_STATUS
+UnixSimpleFileSystemFileInfo (
+  EMU_EFI_FILE_PRIVATE            *PrivateFile,
+  IN     CHAR8                    *FileName,
+  IN OUT UINTN                    *BufferSize,
+  OUT    VOID                     *Buffer
+  )
+{
+  EFI_STATUS                  Status;
+  UINTN                       Size;
+  UINTN                       NameSize;
+  UINTN                       ResultSize;
+  EFI_FILE_INFO               *Info;
+  CHAR8                       *RealFileName;
+  CHAR8                       *TempPointer;
+  CHAR16                      *BufferFileName;
+  struct stat                 buf;
+
+  if (FileName != NULL) {
+    RealFileName = FileName;
+  } else if (PrivateFile->IsRootDirectory) {
+    RealFileName = "";
+  } else {
+    RealFileName  = PrivateFile->FileName;
+  }
+
+  TempPointer = RealFileName;
+  while (*TempPointer) {
+    if (*TempPointer == '/') {
+      RealFileName = TempPointer + 1;
+    }
+
+    TempPointer++;
+  }
+
+  Size        = SIZE_OF_EFI_FILE_INFO;
+  NameSize    = AsciiStrSize (RealFileName) * 2;
+  ResultSize  = Size + NameSize;
+
+  if (*BufferSize < ResultSize) {
+    *BufferSize = ResultSize;
+    return EFI_BUFFER_TOO_SMALL;
+  }
+  if (stat (FileName == NULL ? PrivateFile->FileName : FileName, &buf) < 0) {
+    return EFI_DEVICE_ERROR;
+  }
+
+  Status  = EFI_SUCCESS;
+
+  Info    = Buffer;
+  ZeroMem (Info, ResultSize);
+
+  Info->Size          = ResultSize;
+  Info->FileSize      = buf.st_size;
+  Info->PhysicalSize  = MultU64x32 (buf.st_blocks, buf.st_blksize);
+
+  PosixSystemTimeToEfiTime (buf.st_ctime, &Info->CreateTime);
+  PosixSystemTimeToEfiTime (buf.st_atime, &Info->LastAccessTime);
+  PosixSystemTimeToEfiTime (buf.st_mtime, &Info->ModificationTime);
+
+  if (!(buf.st_mode & S_IWUSR)) {
+    Info->Attribute |= EFI_FILE_READ_ONLY;
+  }
+
+  if (S_ISDIR(buf.st_mode)) {
+    Info->Attribute |= EFI_FILE_DIRECTORY;
+  }
+
+
+  BufferFileName = (CHAR16 *)((CHAR8 *) Buffer + Size);
+  while (*RealFileName) {
+    *BufferFileName++ = *RealFileName++;
+  }
+  *BufferFileName = 0;
+
+  *BufferSize = ResultSize;
+  return Status;
+}
+
+BOOLEAN
+IsZero (
+  IN VOID   *Buffer,
+  IN UINTN  Length
+  )
+{
+  if (Buffer == NULL || Length == 0) {
+    return FALSE;
+  }
+
+  if (*(UINT8 *) Buffer != 0) {
+    return FALSE;
+  }
+
+  if (Length > 1) {
+    if (!CompareMem (Buffer, (UINT8 *) Buffer + 1, Length - 1)) {
+      return FALSE;
+    }
+  }
+
+  return TRUE;
+}
+
+
+
+/**
+  Opens a new file relative to the source file's location.
+
+  @param  This       The protocol instance pointer.
+  @param  NewHandle  Returns File Handle for FileName.
+  @param  FileName   Null terminated string. "\", ".", and ".." are supported.
+  @param  OpenMode   Open mode for file.
+  @param  Attributes Only used for EFI_FILE_MODE_CREATE.
+
+  @retval EFI_SUCCESS          The device was opened.
+  @retval EFI_NOT_FOUND        The specified file could not be found on the device.
+  @retval EFI_NO_MEDIA         The device has no media.
+  @retval EFI_MEDIA_CHANGED    The media has changed.
+  @retval EFI_DEVICE_ERROR     The device reported an error.
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
+  @retval EFI_ACCESS_DENIED    The service denied access to the file.
+  @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
+  @retval EFI_VOLUME_FULL      The volume is full.
+
+**/
+EFI_STATUS
+PosixFileOpen (
+  IN EFI_FILE_PROTOCOL        *This,
+  OUT EFI_FILE_PROTOCOL       **NewHandle,
+  IN CHAR16                   *FileName,
+  IN UINT64                   OpenMode,
+  IN UINT64                   Attributes
+  )
+{
+  EFI_FILE_PROTOCOL                 *Root;
+  EMU_EFI_FILE_PRIVATE              *PrivateFile;
+  EMU_EFI_FILE_PRIVATE              *NewPrivateFile;
+  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *PrivateRoot;
+  EFI_STATUS                        Status;
+  CHAR16                            *Src;
+  char                              *Dst;
+  CHAR8                             *RealFileName;
+  char                              *ParseFileName;
+  char                              *GuardPointer;
+  CHAR8                             TempChar;
+  UINTN                             Count;
+  BOOLEAN                           TrailingDash;
+  BOOLEAN                           LoopFinish;
+  UINTN                             InfoSize;
+  EFI_FILE_INFO                     *Info;
+  struct stat                       finfo;
+  int                               res;
+  
+
+  PrivateFile     = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+  PrivateRoot     = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
+  NewPrivateFile  = NULL;
+  Status          = EFI_OUT_OF_RESOURCES;
+
+  //
+  // BUGBUG: assume an open of root
+  // if current location, return current data
+  //
+  if ((StrCmp (FileName, L"\\") == 0) || 
+      (StrCmp (FileName, L".") == 0 && PrivateFile->IsRootDirectory)) {
+OpenRoot:
+    Status          = PosixOpenVolume (PrivateFile->SimpleFileSystem, &Root);
+    NewPrivateFile  = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (Root);
+    goto Done;
+  }
+
+  TrailingDash = FALSE;
+  if (FileName[StrLen (FileName) - 1] == L'\\') {
+    TrailingDash = TRUE;
+    FileName[StrLen (FileName) - 1]  = 0;
+  }
+
+  //
+  // Attempt to open the file
+  //
+  NewPrivateFile = malloc (sizeof (EMU_EFI_FILE_PRIVATE));
+  if (NewPrivateFile == NULL) {
+    goto Done;
+  }
+
+  CopyMem (NewPrivateFile, PrivateFile, sizeof (EMU_EFI_FILE_PRIVATE));
+
+  NewPrivateFile->FileName = malloc (AsciiStrSize (PrivateFile->FileName) + 1 + StrLen (FileName) + 1);
+  if (NewPrivateFile->FileName == NULL) {
+    goto Done;
+  }
+
+  if (*FileName == L'\\') {
+    AsciiStrCpy (NewPrivateFile->FileName, PrivateRoot->FilePath);
+    // Skip first '\'.
+    Src = FileName + 1;
+  } else {
+    AsciiStrCpy (NewPrivateFile->FileName, PrivateFile->FileName);
+    Src = FileName;
+  }
+  Dst = NewPrivateFile->FileName + AsciiStrLen (NewPrivateFile->FileName);
+  GuardPointer = NewPrivateFile->FileName + AsciiStrLen (PrivateRoot->FilePath);
+  *Dst++ = '/';
+  // Convert unicode to ascii and '\' to '/'
+  while (*Src) {
+    if (*Src == '\\') {
+      *Dst++ = '/';
+    } else {
+      *Dst++ = *Src;
+    }
+    Src++;
+  }
+  *Dst = 0;
+      
+
+  //
+  // Get rid of . and .., except leading . or ..
+  //
+
+  //
+  // GuardPointer protect simplefilesystem root path not be destroyed
+  //
+
+  LoopFinish    = FALSE;
+  while (!LoopFinish) {
+    LoopFinish = TRUE;
+
+    for (ParseFileName = GuardPointer; *ParseFileName; ParseFileName++) {
+      if (*ParseFileName == '.' &&
+          (*(ParseFileName + 1) == 0 || *(ParseFileName + 1) == '/') &&
+          *(ParseFileName - 1) == '/'
+          ) {
+
+        //
+        // cut /.
+        //
+        CutPrefix (ParseFileName - 1, 2);
+        LoopFinish = FALSE;
+        break;
+      }
+
+      if (*ParseFileName == '.' &&
+          *(ParseFileName + 1) == '.' &&
+          (*(ParseFileName + 2) == 0 || *(ParseFileName + 2) == '/') &&
+          *(ParseFileName - 1) == '/'
+          ) {
+
+        ParseFileName--;
+        Count = 3;
+
+        while (ParseFileName != GuardPointer) {
+          ParseFileName--;
+          Count++;
+          if (*ParseFileName == '/') {
+            break;
+          }
+        }
+
+        //
+        // cut /.. and its left directory
+        //
+        CutPrefix (ParseFileName, Count);
+        LoopFinish = FALSE;
+        break;
+      }
+    }
+  }
+
+  if (AsciiStrCmp (NewPrivateFile->FileName, PrivateRoot->FilePath) == 0) {
+    NewPrivateFile->IsRootDirectory = TRUE;
+    free (NewPrivateFile->FileName);
+    free (NewPrivateFile);
+    goto OpenRoot;
+  }
+
+  RealFileName = NewPrivateFile->FileName + AsciiStrLen(NewPrivateFile->FileName) - 1;
+  while (RealFileName > NewPrivateFile->FileName && *RealFileName != '/') {
+    RealFileName--;
+  }
+  
+  TempChar            = *(RealFileName - 1);
+  *(RealFileName - 1) = 0;
+  *(RealFileName - 1) = TempChar;
+
+
+  //
+  // Test whether file or directory
+  //
+  NewPrivateFile->IsRootDirectory = FALSE;
+  NewPrivateFile->fd = -1;
+  NewPrivateFile->Dir = NULL;
+  if (OpenMode & EFI_FILE_MODE_CREATE) {
+    if (Attributes & EFI_FILE_DIRECTORY) {
+      NewPrivateFile->IsDirectoryPath = TRUE;
+    } else {
+      NewPrivateFile->IsDirectoryPath = FALSE;
+    }
+  } else {
+    res = stat (NewPrivateFile->FileName, &finfo);
+    if (res == 0 && S_ISDIR(finfo.st_mode)) {
+      NewPrivateFile->IsDirectoryPath = TRUE;
+    } else {
+      NewPrivateFile->IsDirectoryPath = FALSE;
+    }
+  }
+
+  if (OpenMode & EFI_FILE_MODE_WRITE) {
+    NewPrivateFile->IsOpenedByRead = FALSE;
+  } else {
+    NewPrivateFile->IsOpenedByRead = TRUE;
+  }
+
+  Status = EFI_SUCCESS;
+
+  //
+  // deal with directory
+  //
+  if (NewPrivateFile->IsDirectoryPath) {
+    if ((OpenMode & EFI_FILE_MODE_CREATE)) {
+      //
+      // Create a directory
+      //
+      if (mkdir (NewPrivateFile->FileName, 0777) != 0) {
+        if (errno != EEXIST) {
+          //free (TempFileName);
+          Status = EFI_ACCESS_DENIED;
+          goto Done;
+        }
+      }
+    }
+
+    NewPrivateFile->Dir = opendir (NewPrivateFile->FileName);
+    if (NewPrivateFile->Dir == NULL) {
+      if (errno == EACCES) {
+        Status = EFI_ACCESS_DENIED;
+      } else {
+        Status = EFI_NOT_FOUND;
+      }
+
+      goto Done;
+    }
+
+  } else {
+    //
+    // deal with file
+    //
+    NewPrivateFile->fd = open (
+                          NewPrivateFile->FileName,
+                          ((OpenMode & EFI_FILE_MODE_CREATE) ? O_CREAT : 0) | (NewPrivateFile->IsOpenedByRead ? O_RDONLY : O_RDWR),
+                          0666
+                          );
+    if (NewPrivateFile->fd < 0) {
+      if (errno == ENOENT) {
+        Status = EFI_NOT_FOUND;
+      } else {
+        Status = EFI_ACCESS_DENIED;
+      }
+    }
+  }
+
+  if ((OpenMode & EFI_FILE_MODE_CREATE) && Status == EFI_SUCCESS) {
+    //
+    // Set the attribute
+    //
+    InfoSize  = 0;
+    Info      = NULL;
+    Status    = PosixFileGetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, &InfoSize, Info);
+    if (Status != EFI_BUFFER_TOO_SMALL) {
+      Status = EFI_DEVICE_ERROR;
+      goto Done;
+    }
+    
+    Info = malloc (InfoSize);
+    if (Info == NULL) {
+      goto Done;
+    }
+
+    Status = PosixFileGetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, &InfoSize, Info);
+    if (EFI_ERROR (Status)) {
+      goto Done;
+    }
+
+    Info->Attribute = Attributes;
+    PosixFileSetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, InfoSize, Info);
+    
+    free (Info);
+  }
+
+Done: ;
+  if (TrailingDash) {
+    FileName[StrLen (FileName) + 1]  = 0;
+    FileName[StrLen (FileName)]      = L'\\';
+  }
+
+  if (EFI_ERROR (Status)) {
+    if (NewPrivateFile) {
+      if (NewPrivateFile->FileName) {
+        free (NewPrivateFile->FileName);
+      }
+
+      free (NewPrivateFile);
+    }
+  } else {
+    *NewHandle = &NewPrivateFile->EfiFile;
+  }
+
+  return Status;
+}
+
+
+
+/**
+  Close the file handle
+
+  @param  This          Protocol instance pointer.
+
+  @retval EFI_SUCCESS   The device was opened.
+
+**/
+EFI_STATUS
+PosixFileCLose (
+  IN EFI_FILE_PROTOCOL  *This
+  )
+{
+  EMU_EFI_FILE_PRIVATE *PrivateFile;
+
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+
+  if (PrivateFile->fd >= 0) {
+    close (PrivateFile->fd);
+  }
+  if (PrivateFile->Dir != NULL) {
+    closedir (PrivateFile->Dir);
+  }
+
+  PrivateFile->fd = -1;
+  PrivateFile->Dir = NULL;
+
+  if (PrivateFile->FileName) {
+    free (PrivateFile->FileName);
+  }
+
+  free (PrivateFile);
+
+  return EFI_SUCCESS;
+}
+
+
+/**
+  Close and delete the file handle.
+
+  @param  This                     Protocol instance pointer.
+                                   
+  @retval EFI_SUCCESS              The device was opened.
+  @retval EFI_WARN_DELETE_FAILURE  The handle was closed but the file was not deleted.
+
+**/
+EFI_STATUS
+PosixFileDelete (
+  IN EFI_FILE_PROTOCOL  *This
+  )
+{
+  EFI_STATUS              Status;
+  EMU_EFI_FILE_PRIVATE   *PrivateFile;
+  
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+  Status      = EFI_WARN_DELETE_FAILURE;
+
+  if (PrivateFile->IsDirectoryPath) {
+    if (PrivateFile->Dir != NULL) {
+      closedir (PrivateFile->Dir);
+      PrivateFile->Dir = NULL;
+    }
+
+    if (rmdir (PrivateFile->FileName) == 0) {
+      Status = EFI_SUCCESS;
+    }
+  } else {
+    close (PrivateFile->fd);
+    PrivateFile->fd = -1;
+
+    if (!PrivateFile->IsOpenedByRead) {
+      if (!unlink (PrivateFile->FileName)) {
+        Status = EFI_SUCCESS;
+      }
+    }
+  }
+
+  free (PrivateFile->FileName);
+  free (PrivateFile);
+
+  return Status;
+}
+
+
+/**
+  Read data from the file.
+
+  @param  This       Protocol instance pointer.
+  @param  BufferSize On input size of buffer, on output amount of data in buffer.
+  @param  Buffer     The buffer in which data is read.
+
+  @retval EFI_SUCCESS          Data was read.
+  @retval EFI_NO_MEDIA         The device has no media.
+  @retval EFI_DEVICE_ERROR     The device reported an error.
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
+  @retval EFI_BUFFER_TO_SMALL  BufferSize is too small. BufferSize contains required size.
+
+**/
+EFI_STATUS
+PosixFileRead (
+  IN EFI_FILE_PROTOCOL        *This,
+  IN OUT UINTN                *BufferSize,
+  OUT VOID                    *Buffer
+  )
+{
+  EMU_EFI_FILE_PRIVATE    *PrivateFile;
+  EFI_STATUS              Status;
+  int                     Res;
+  UINTN                   Size;
+  UINTN                   NameSize;
+  UINTN                   ResultSize;
+  CHAR8                   *FullFileName;
+
+
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+
+  if (!PrivateFile->IsDirectoryPath) {
+    if (PrivateFile->fd < 0) {
+      Status = EFI_DEVICE_ERROR;
+      goto Done;
+    }
+
+    Res = read (PrivateFile->fd, Buffer, *BufferSize);
+    if (Res < 0) {
+      Status = EFI_DEVICE_ERROR;
+      goto Done;
+    }
+    *BufferSize = Res;
+    Status = EFI_SUCCESS;
+    goto Done;
+  }
+
+  //
+  // Read on a directory.
+  //
+  if (PrivateFile->Dir == NULL) {
+    Status = EFI_DEVICE_ERROR;
+    goto Done;
+  }
+
+  if (PrivateFile->Dirent == NULL) {
+    PrivateFile->Dirent = readdir (PrivateFile->Dir);
+    if (PrivateFile->Dirent == NULL) {
+      *BufferSize = 0;
+      Status = EFI_SUCCESS;
+      goto Done;
+    }
+  }
+
+  Size        = SIZE_OF_EFI_FILE_INFO;
+  NameSize    = AsciiStrLen (PrivateFile->Dirent->d_name) + 1;
+  ResultSize  = Size + 2 * NameSize;
+
+  if (*BufferSize < ResultSize) {
+    *BufferSize = ResultSize;
+    Status = EFI_BUFFER_TOO_SMALL;
+    goto Done;
+  }
+  Status  = EFI_SUCCESS;
+
+  *BufferSize = ResultSize;
+
+  FullFileName = malloc (AsciiStrLen(PrivateFile->FileName) + 1 + NameSize);
+  if (FullFileName == NULL) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto Done;  
+  }
+         
+  AsciiStrCpy (FullFileName, PrivateFile->FileName);
+  AsciiStrCat (FullFileName, "/");
+  AsciiStrCat (FullFileName, PrivateFile->Dirent->d_name);
+  Status = UnixSimpleFileSystemFileInfo (
+            PrivateFile,
+            FullFileName,
+            BufferSize,
+            Buffer
+            );
+  free (FullFileName);
+
+  PrivateFile->Dirent = NULL;
+
+Done:
+  return Status;
+}
+
+
+
+/**
+  Write data to a file.
+
+  @param  This       Protocol instance pointer.
+  @param  BufferSize On input size of buffer, on output amount of data in buffer.
+  @param  Buffer     The buffer in which data to write.
+
+  @retval EFI_SUCCESS          Data was written.
+  @retval EFI_UNSUPPORTED      Writes to Open directory are not supported.
+  @retval EFI_NO_MEDIA         The device has no media.
+  @retval EFI_DEVICE_ERROR     The device reported an error.
+  @retval EFI_DEVICE_ERROR     An attempt was made to write to a deleted file.
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
+  @retval EFI_WRITE_PROTECTED  The device is write protected.
+  @retval EFI_ACCESS_DENIED    The file was open for read only.
+  @retval EFI_VOLUME_FULL      The volume is full.
+
+**/
+EFI_STATUS
+PosixFileWrite (
+  IN EFI_FILE_PROTOCOL        *This,
+  IN OUT UINTN                *BufferSize,
+  IN VOID                     *Buffer
+  )
+{
+  EMU_EFI_FILE_PRIVATE  *PrivateFile;
+  int                   Res;
+
+
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+
+  if (PrivateFile->fd < 0) {
+    return EFI_DEVICE_ERROR;
+  }
+
+  if (PrivateFile->IsDirectoryPath) {
+    return EFI_UNSUPPORTED;
+  }
+
+  if (PrivateFile->IsOpenedByRead) {
+    return EFI_ACCESS_DENIED;
+  }
+
+  Res = write (PrivateFile->fd, Buffer, *BufferSize);
+  if (Res == (UINTN)-1) {
+    return ErrnoToEfiStatus ();
+  }
+  
+  *BufferSize = Res;
+  return EFI_SUCCESS;
+}
+
+
+
+/**
+  Set a files current position
+
+  @param  This            Protocol instance pointer.
+  @param  Position        Byte position from the start of the file.
+                          
+  @retval EFI_SUCCESS     Data was written.
+  @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.
+
+**/
+EFI_STATUS
+PosixFileSetPossition (
+  IN EFI_FILE_PROTOCOL        *This,
+  IN UINT64                   Position
+  )
+{
+  EMU_EFI_FILE_PRIVATE    *PrivateFile;
+  off_t                   Pos;
+
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+
+  if (PrivateFile->IsDirectoryPath) {
+    if (Position != 0) {
+      return EFI_UNSUPPORTED;
+    }
+
+    if (PrivateFile->Dir == NULL) {
+      return EFI_DEVICE_ERROR;
+    }
+    rewinddir (PrivateFile->Dir);
+    return EFI_SUCCESS;
+  } else {
+    if (Position == (UINT64) -1) {
+      Pos = lseek (PrivateFile->fd, 0, SEEK_END);
+    } else {
+      Pos = lseek (PrivateFile->fd, Position, SEEK_SET);
+    }
+    if (Pos == (off_t)-1) {
+      return ErrnoToEfiStatus ();
+    }
+    return EFI_SUCCESS;
+  }
+}
+
+
+
+/**
+  Get a file's current position
+
+  @param  This            Protocol instance pointer.
+  @param  Position        Byte position from the start of the file.
+                          
+  @retval EFI_SUCCESS     Data was written.
+  @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open..
+
+**/
+EFI_STATUS
+PosixFileGetPossition (
+  IN EFI_FILE_PROTOCOL        *This,
+  OUT UINT64                  *Position
+  )
+{
+  EFI_STATUS            Status;
+  EMU_EFI_FILE_PRIVATE  *PrivateFile;
+  
+  PrivateFile   = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+
+  if (PrivateFile->IsDirectoryPath) {
+    Status = EFI_UNSUPPORTED;
+  } else {
+    *Position = (UINT64)lseek (PrivateFile->fd, 0, SEEK_CUR);
+    Status = (*Position == (UINT64) -1) ? ErrnoToEfiStatus () : EFI_SUCCESS;
+  }
+
+  return Status;
+}
+
+
+/**
+  Get information about a file.
+
+  @param  This            Protocol instance pointer.
+  @param  InformationType Type of information to return in Buffer.
+  @param  BufferSize      On input size of buffer, on output amount of data in buffer.
+  @param  Buffer          The buffer to return data.
+
+  @retval EFI_SUCCESS          Data was returned.
+  @retval EFI_UNSUPPORTED      InformationType is not supported.
+  @retval EFI_NO_MEDIA         The device has no media.
+  @retval EFI_DEVICE_ERROR     The device reported an error.
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
+  @retval EFI_WRITE_PROTECTED  The device is write protected.
+  @retval EFI_ACCESS_DENIED    The file was open for read only.
+  @retval EFI_BUFFER_TOO_SMALL Buffer was too small; required size returned in BufferSize.
+
+**/
+EFI_STATUS
+PosixFileGetInfo (
+  IN EFI_FILE_PROTOCOL        *This,
+  IN EFI_GUID                 *InformationType,
+  IN OUT UINTN                *BufferSize,
+  OUT VOID                    *Buffer
+  )
+{
+  EFI_STATUS                        Status;
+  EMU_EFI_FILE_PRIVATE              *PrivateFile;
+  EFI_FILE_SYSTEM_INFO              *FileSystemInfoBuffer;
+  int                               UnixStatus;
+  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *PrivateRoot;
+  struct statfs                     buf;
+
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+  PrivateRoot = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
+
+  Status = EFI_SUCCESS;
+  if (CompareGuid (InformationType, &gEfiFileInfoGuid)) {
+    Status = UnixSimpleFileSystemFileInfo (PrivateFile, NULL, BufferSize, Buffer);
+  } else if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
+    if (*BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel)) {
+      *BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
+      return EFI_BUFFER_TOO_SMALL;
+    }
+
+    UnixStatus = statfs (PrivateFile->FileName, &buf);
+    if (UnixStatus < 0) {
+      return EFI_DEVICE_ERROR;
+    }
+
+    FileSystemInfoBuffer            = (EFI_FILE_SYSTEM_INFO *) Buffer;
+    FileSystemInfoBuffer->Size      = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
+    FileSystemInfoBuffer->ReadOnly  = FALSE;
+
+    //
+    // Succeeded
+    //
+    FileSystemInfoBuffer->VolumeSize  = MultU64x32 (buf.f_blocks, buf.f_bsize);
+    FileSystemInfoBuffer->FreeSpace   = MultU64x32 (buf.f_bavail, buf.f_bsize);
+    FileSystemInfoBuffer->BlockSize   = buf.f_bsize;
+
+
+    StrCpy ((CHAR16 *) FileSystemInfoBuffer->VolumeLabel, PrivateRoot->VolumeLabel);
+    *BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
+    
+  } else if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
+    if (*BufferSize < StrSize (PrivateRoot->VolumeLabel)) {
+      *BufferSize = StrSize (PrivateRoot->VolumeLabel);
+      return EFI_BUFFER_TOO_SMALL;
+    }
+
+    StrCpy ((CHAR16 *) Buffer, PrivateRoot->VolumeLabel);
+    *BufferSize = StrSize (PrivateRoot->VolumeLabel);
+
+  }
+
+  return Status;
+}
+
+
+/**
+  Set information about a file
+
+  @param  File            Protocol instance pointer.
+  @param  InformationType Type of information in Buffer.
+  @param  BufferSize      Size of buffer.
+  @param  Buffer          The data to write.
+
+  @retval EFI_SUCCESS          Data was returned.
+  @retval EFI_UNSUPPORTED      InformationType is not supported.
+  @retval EFI_NO_MEDIA         The device has no media.
+  @retval EFI_DEVICE_ERROR     The device reported an error.
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
+  @retval EFI_WRITE_PROTECTED  The device is write protected.
+  @retval EFI_ACCESS_DENIED    The file was open for read only.
+
+**/
+EFI_STATUS
+PosixFileSetInfo (
+  IN EFI_FILE_PROTOCOL        *This,
+  IN EFI_GUID                 *InformationType,
+  IN UINTN                    BufferSize,
+  IN VOID                     *Buffer
+  )
+{
+  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *PrivateRoot;
+  EMU_EFI_FILE_PRIVATE              *PrivateFile;
+  EFI_FILE_INFO                     *OldFileInfo;
+  EFI_FILE_INFO                     *NewFileInfo;
+  EFI_STATUS                        Status;
+  UINTN                             OldInfoSize;
+  mode_t                            NewAttr;
+  struct stat                       OldAttr;
+  CHAR8                             *OldFileName;
+  CHAR8                             *NewFileName;
+  CHAR8                             *CharPointer;
+  BOOLEAN                           AttrChangeFlag;
+  BOOLEAN                           NameChangeFlag;
+  BOOLEAN                           SizeChangeFlag;
+  BOOLEAN                           TimeChangeFlag;
+  struct tm                         NewLastAccessSystemTime;
+  struct tm                         NewLastWriteSystemTime;
+  EFI_FILE_SYSTEM_INFO              *NewFileSystemInfo;
+  CHAR8                             *AsciiFilePtr;
+  CHAR16                            *UnicodeFilePtr;
+  int                               UnixStatus;
+  struct utimbuf                    Utime;
+  
+
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+  PrivateRoot = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
+  errno       = 0;
+  Status      = EFI_UNSUPPORTED;
+  OldFileInfo = NewFileInfo = NULL;
+  OldFileName = NewFileName = NULL;
+  AttrChangeFlag = NameChangeFlag = SizeChangeFlag = TimeChangeFlag = FALSE;
+
+  //
+  // Set file system information.
+  //
+  if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
+    if (BufferSize < (SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel))) {
+      Status = EFI_BAD_BUFFER_SIZE;
+      goto Done;
+    }
+
+    NewFileSystemInfo = (EFI_FILE_SYSTEM_INFO *) Buffer;
+
+    free (PrivateRoot->VolumeLabel);
+
+    PrivateRoot->VolumeLabel = malloc (StrSize (NewFileSystemInfo->VolumeLabel));
+    if (PrivateRoot->VolumeLabel == NULL) {
+      goto Done;
+    }
+
+    StrCpy (PrivateRoot->VolumeLabel, NewFileSystemInfo->VolumeLabel);
+
+    Status = EFI_SUCCESS;
+    goto Done;
+  }
+
+  //
+  // Set volume label information.
+  //
+  if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
+    if (BufferSize < StrSize (PrivateRoot->VolumeLabel)) {
+      Status = EFI_BAD_BUFFER_SIZE;
+      goto Done;
+    }
+
+    StrCpy (PrivateRoot->VolumeLabel, (CHAR16 *) Buffer);
+
+    Status = EFI_SUCCESS;
+    goto Done;
+  }
+
+  if (!CompareGuid (InformationType, &gEfiFileInfoGuid)) {
+    Status = EFI_UNSUPPORTED;
+    goto Done;
+  }
+
+  if (BufferSize < SIZE_OF_EFI_FILE_INFO) {
+    Status = EFI_BAD_BUFFER_SIZE;
+    goto Done;
+  }
+
+  //
+  // Set file/directory information.
+  //
+
+  //
+  // Check for invalid set file information parameters.
+  //
+  NewFileInfo = (EFI_FILE_INFO *) Buffer;
+  if (NewFileInfo->Size <= sizeof (EFI_FILE_INFO) ||
+      (NewFileInfo->Attribute &~(EFI_FILE_VALID_ATTR)) ||
+      (sizeof (UINTN) == 4 && NewFileInfo->Size > 0xFFFFFFFF)
+      ) {
+    Status = EFI_INVALID_PARAMETER;
+    goto Done;
+  }
+
+  //
+  // Get current file information so we can determine what kind
+  // of change request this is.
+  //
+  OldInfoSize = 0;
+  Status = UnixSimpleFileSystemFileInfo (PrivateFile, NULL, &OldInfoSize, NULL);
+  if (Status != EFI_BUFFER_TOO_SMALL) {
+    Status = EFI_DEVICE_ERROR;
+    goto Done;
+  }
+
+  OldFileInfo = malloc (OldInfoSize);
+  if (OldFileInfo == NULL) {
+    goto Done;
+  }
+
+  Status = UnixSimpleFileSystemFileInfo (PrivateFile, NULL, &OldInfoSize, OldFileInfo);
+  if (EFI_ERROR (Status)) {
+    goto Done;
+  }
+
+  OldFileName = malloc (AsciiStrSize (PrivateFile->FileName));
+  if (OldFileInfo == NULL) {
+    goto Done;
+  }
+
+  AsciiStrCpy (OldFileName, PrivateFile->FileName);
+
+  //
+  // Make full pathname from new filename and rootpath.
+  //
+  if (NewFileInfo->FileName[0] == '\\') {
+    NewFileName = malloc (AsciiStrLen (PrivateRoot->FilePath) + 1 + StrLen (NewFileInfo->FileName) + 1);
+    if (NewFileName == NULL) {
+      goto Done;
+    }
+
+    AsciiStrCpy (NewFileName, PrivateRoot->FilePath);
+    AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName);
+    UnicodeFilePtr = NewFileInfo->FileName + 1;
+    *AsciiFilePtr++ ='/';
+  } else {
+    NewFileName = malloc (AsciiStrLen (PrivateFile->FileName) + 2 + StrLen (NewFileInfo->FileName) + 1);
+    if (NewFileName == NULL) {
+      goto Done;
+    }
+
+    AsciiStrCpy (NewFileName, PrivateRoot->FilePath);
+    AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName);
+    if ((AsciiFilePtr[-1] != '/') && (NewFileInfo->FileName[0] != '/')) {
+      // make sure there is a / between Root FilePath and NewFileInfo Filename
+      AsciiFilePtr[0] = '/';      
+      AsciiFilePtr[1] = '\0';
+      AsciiFilePtr++;
+    }
+    UnicodeFilePtr = NewFileInfo->FileName;
+  }
+  // Convert to ascii.
+  while (*UnicodeFilePtr) {
+    *AsciiFilePtr++ = *UnicodeFilePtr++;
+  }
+  *AsciiFilePtr = 0;
+
+  //
+  // Is there an attribute change request?
+  //
+  if (NewFileInfo->Attribute != OldFileInfo->Attribute) {
+    if ((NewFileInfo->Attribute & EFI_FILE_DIRECTORY) != (OldFileInfo->Attribute & EFI_FILE_DIRECTORY)) {
+      Status = EFI_INVALID_PARAMETER;
+      goto Done;
+    }
+
+    AttrChangeFlag = TRUE;
+  }
+
+  //
+  // Is there a name change request?
+  // bugbug: - Should really use EFI_UNICODE_COLLATION_PROTOCOL
+  //
+  if (StrCmp (NewFileInfo->FileName, OldFileInfo->FileName)) {
+    NameChangeFlag = TRUE;
+  }
+
+  //
+  // Is there a size change request?
+  //
+  if (NewFileInfo->FileSize != OldFileInfo->FileSize) {
+    SizeChangeFlag = TRUE;
+  }
+
+  //
+  // Is there a time stamp change request?
+  //
+  if (!IsZero (&NewFileInfo->CreateTime, sizeof (EFI_TIME)) &&
+      CompareMem (&NewFileInfo->CreateTime, &OldFileInfo->CreateTime, sizeof (EFI_TIME))
+      ) {
+    TimeChangeFlag = TRUE;
+  } else if (!IsZero (&NewFileInfo->LastAccessTime, sizeof (EFI_TIME)) &&
+             CompareMem (&NewFileInfo->LastAccessTime, &OldFileInfo->LastAccessTime, sizeof (EFI_TIME))
+             ) {
+    TimeChangeFlag = TRUE;
+  } else if (!IsZero (&NewFileInfo->ModificationTime, sizeof (EFI_TIME)) &&
+             CompareMem (&NewFileInfo->ModificationTime, &OldFileInfo->ModificationTime, sizeof (EFI_TIME))
+             ) {
+    TimeChangeFlag = TRUE;
+  }
+
+  //
+  // All done if there are no change requests being made.
+  //
+  if (!(AttrChangeFlag || NameChangeFlag || SizeChangeFlag || TimeChangeFlag)) {
+    Status = EFI_SUCCESS;
+    goto Done;
+  }
+
+  //
+  // Set file or directory information.
+  //
+  if (stat (OldFileName, &OldAttr) != 0) {
+    Status = ErrnoToEfiStatus ();
+    goto Done;
+  }
+
+  //
+  // Name change.
+  //
+  if (NameChangeFlag) {
+    //
+    // Close the handles first
+    //
+    if (PrivateFile->IsOpenedByRead) {
+      Status = EFI_ACCESS_DENIED;
+      goto Done;
+    }
+
+    for (CharPointer = NewFileName; *CharPointer != 0 && *CharPointer != L'/'; CharPointer++) {
+    }
+
+    if (*CharPointer != 0) {
+      Status = EFI_ACCESS_DENIED;
+      goto Done;
+    }
+
+    UnixStatus = rename (OldFileName, NewFileName);
+    if (UnixStatus == 0) {
+      //
+      // modify file name
+      //
+      free (PrivateFile->FileName);
+
+      PrivateFile->FileName = malloc (AsciiStrSize (NewFileName));
+      if (PrivateFile->FileName == NULL) {
+        goto Done;
+      }
+
+      AsciiStrCpy (PrivateFile->FileName, NewFileName);
+    } else {
+      Status    = EFI_DEVICE_ERROR;
+      goto Done;
+    }
+  }
+
+  //
+  //  Size change
+  //
+  if (SizeChangeFlag) {
+    if (PrivateFile->IsDirectoryPath) {
+      Status = EFI_UNSUPPORTED;
+      goto Done;
+    }
+
+    if (PrivateFile->IsOpenedByRead || OldFileInfo->Attribute & EFI_FILE_READ_ONLY) {
+      Status = EFI_ACCESS_DENIED;
+      goto Done;
+    }
+
+    if (ftruncate (PrivateFile->fd, NewFileInfo->FileSize) != 0) {
+      Status = ErrnoToEfiStatus ();
+      goto Done;
+    }
+
+  }
+
+  //
+  // Time change
+  //
+  if (TimeChangeFlag) {
+    NewLastAccessSystemTime.tm_year    = NewFileInfo->LastAccessTime.Year;
+    NewLastAccessSystemTime.tm_mon     = NewFileInfo->LastAccessTime.Month;
+    NewLastAccessSystemTime.tm_mday    = NewFileInfo->LastAccessTime.Day;
+    NewLastAccessSystemTime.tm_hour    = NewFileInfo->LastAccessTime.Hour;
+    NewLastAccessSystemTime.tm_min     = NewFileInfo->LastAccessTime.Minute;
+    NewLastAccessSystemTime.tm_sec     = NewFileInfo->LastAccessTime.Second;
+    NewLastAccessSystemTime.tm_isdst   = 0;
+
+    Utime.actime = mktime (&NewLastAccessSystemTime);
+
+    NewLastWriteSystemTime.tm_year    = NewFileInfo->ModificationTime.Year;
+    NewLastWriteSystemTime.tm_mon     = NewFileInfo->ModificationTime.Month;
+    NewLastWriteSystemTime.tm_mday    = NewFileInfo->ModificationTime.Day;
+    NewLastWriteSystemTime.tm_hour    = NewFileInfo->ModificationTime.Hour;
+    NewLastWriteSystemTime.tm_min     = NewFileInfo->ModificationTime.Minute;
+    NewLastWriteSystemTime.tm_sec     = NewFileInfo->ModificationTime.Second;
+    NewLastWriteSystemTime.tm_isdst   = 0;
+
+    Utime.modtime = mktime (&NewLastWriteSystemTime);
+
+    if (Utime.actime == (time_t)-1 || Utime.modtime == (time_t)-1) {
+      goto Done;
+    }
+
+    if (utime (PrivateFile->FileName, &Utime) == -1) {
+      Status = ErrnoToEfiStatus ();
+      goto Done;
+    }
+  }
+
+  //
+  // No matter about AttrChangeFlag, Attribute must be set.
+  // Because operation before may cause attribute change.
+  //
+  NewAttr = OldAttr.st_mode;
+
+  if (NewFileInfo->Attribute & EFI_FILE_READ_ONLY) {
+    NewAttr &= ~(S_IRUSR | S_IRGRP | S_IROTH);
+  } else {
+    NewAttr |= S_IRUSR;
+  }
+
+  if (chmod (NewFileName, NewAttr) != 0) {
+    Status = ErrnoToEfiStatus ();
+  }
+
+Done:
+  if (OldFileInfo != NULL) {
+    free (OldFileInfo);
+  }
+
+  if (OldFileName != NULL) {
+    free (OldFileName);
+  }
+
+  if (NewFileName != NULL) {
+    free (NewFileName);
+  }
+
+  return Status;
+}
+
+
+/**
+  Flush data back for the file handle.
+
+  @param  This Protocol instance pointer.
+
+  @retval EFI_SUCCESS          Data was written.
+  @retval EFI_UNSUPPORTED      Writes to Open directory are not supported.
+  @retval EFI_NO_MEDIA         The device has no media.
+  @retval EFI_DEVICE_ERROR     The device reported an error.
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
+  @retval EFI_WRITE_PROTECTED  The device is write protected.
+  @retval EFI_ACCESS_DENIED    The file was open for read only.
+  @retval EFI_VOLUME_FULL      The volume is full.
+
+**/
+EFI_STATUS
+PosixFileFlush (
+  IN EFI_FILE_PROTOCOL  *This
+  )
+{
+  EMU_EFI_FILE_PRIVATE     *PrivateFile;
+
+  
+  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
+
+  if (PrivateFile->IsDirectoryPath) {
+    return EFI_UNSUPPORTED;
+  }
+
+  if (PrivateFile->IsOpenedByRead) {
+    return EFI_ACCESS_DENIED;
+  }
+
+  if (PrivateFile->fd < 0) {
+    return EFI_DEVICE_ERROR;
+  }
+
+  if (fsync (PrivateFile->fd) != 0) {
+    return ErrnoToEfiStatus ();
+  }
+
+  return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+PosixFileSystmeThunkOpen (
+  IN  EMU_IO_THUNK_PROTOCOL   *This
+  )
+{
+  EMU_SIMPLE_FILE_SYSTEM_PRIVATE  *Private;
+  UINTN                           i;
+  
+  if (This->Private != NULL) {
+    return EFI_ALREADY_STARTED;
+  }
+  
+  if (!CompareGuid (This->Protocol, &gEfiSimpleFileSystemProtocolGuid)) {
+    return EFI_UNSUPPORTED;
+  }
+  
+  Private = malloc (sizeof (EMU_SIMPLE_FILE_SYSTEM_PRIVATE));
+  if (Private == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  Private->FilePath = malloc (StrLen (This->ConfigString) + 1);
+  if (Private->FilePath == NULL) {
+    free (Private);
+    return EFI_OUT_OF_RESOURCES;    
+  }
+  
+  // Convert Unicode to Ascii
+  for (i = 0; This->ConfigString[i] != 0; i++) {
+    Private->FilePath[i] = This->ConfigString[i];
+  }
+  Private->FilePath[i] = 0;
+
+
+  Private->VolumeLabel = malloc (StrSize (L"EFI_EMULATED"));
+  if (Private->VolumeLabel == NULL) {
+    free (Private->FilePath);
+    free (Private);
+    return EFI_OUT_OF_RESOURCES;
+  }
+  StrCpy (Private->VolumeLabel, L"EFI_EMULATED");
+  
+  Private->Signature = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE;
+  Private->Thunk     = This;
+  CopyMem (&Private->SimpleFileSystem, &gPosixFileSystemProtocol, sizeof (Private->SimpleFileSystem));
+  Private->FileHandlesOpen = FALSE;
+  This->Interface = &Private->SimpleFileSystem;
+  This->Private   = Private;
+  return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+PosixFileSystmeThunkClose (
+  IN  EMU_IO_THUNK_PROTOCOL   *This
+  )
+{
+  EMU_SIMPLE_FILE_SYSTEM_PRIVATE  *Private;
+
+  if (!CompareGuid (This->Protocol, &gEfiSimpleFileSystemProtocolGuid)) {
+    return EFI_UNSUPPORTED;
+  }
+  
+  Private = This->Private;
+  
+  if (Private->FileHandlesOpen) {
+    //
+    // Close only supported if all the EFI_FILE_HANDLEs have been closed.
+    //
+    return EFI_NOT_READY;
+  }
+
+  if (This->Private != NULL) {
+    if (Private->VolumeLabel != NULL) {
+      free (Private->VolumeLabel);
+    }   
+    free (This->Private);
+    This->Private = NULL;
+  }
+  
+  return EFI_SUCCESS;
+}
+
+
+EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo = {
+  &gEfiSimpleFileSystemProtocolGuid,
+  NULL,
+  NULL,
+  0,
+  GasketPosixFileSystmeThunkOpen,
+  GasketPosixFileSystmeThunkClose,
+  NULL
+};
+
+
diff --git a/EmulatorPkg/Unix/Host/Pthreads.c b/EmulatorPkg/Unix/Host/Pthreads.c
new file mode 100644 (file)
index 0000000..b6b6ae8
--- /dev/null
@@ -0,0 +1,235 @@
+/*++ @file
+ POSIX Pthreads to emulate APs and implement threads
+
+Copyright (c) 2011, Apple Inc. All rights reserved.
+Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+
+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 "SecMain.h"
+#include <pthread.h>
+
+
+UINTN
+EFIAPI
+PthreadMutexLock (
+  IN VOID *Mutex
+  )
+{
+  return (UINTN)pthread_mutex_lock ((pthread_mutex_t *)Mutex);
+}
+
+
+
+UINTN
+EFIAPI
+PthreadMutexUnLock (
+  IN VOID *Mutex
+  )                        
+{
+  return (UINTN)pthread_mutex_unlock ((pthread_mutex_t *)Mutex);
+}
+
+UINTN
+EFIAPI
+PthreadMutexTryLock (
+  IN VOID *Mutex
+  )                      
+{
+  return (UINTN)pthread_mutex_trylock ((pthread_mutex_t *)Mutex);
+}
+
+
+VOID *
+PthreadMutexInit (
+  IN VOID
+  )
+{
+  pthread_mutex_t *Mutex;
+  int             err;
+  
+  Mutex = malloc (sizeof (pthread_mutex_t));
+  err = pthread_mutex_init (Mutex, NULL);
+  if (err == 0) {
+    return Mutex;
+  }
+  
+  return NULL;
+}
+
+
+UINTN
+PthreadMutexDestroy (
+  IN VOID *Mutex
+  )
+{
+  if (Mutex != NULL) {
+    return pthread_mutex_destroy ((pthread_mutex_t *)Mutex);
+  }
+  
+  return -1;
+}
+
+// Can't store this data on PthreadCreate stack so we need a global
+typedef struct {
+  pthread_mutex_t             Mutex;
+  THREAD_THUNK_THREAD_ENTRY   Start;
+} THREAD_MANGLE;
+
+THREAD_MANGLE mThreadMangle = {
+  PTHREAD_MUTEX_INITIALIZER,
+  NULL
+};
+
+VOID *
+SecFakePthreadStart (
+  VOID  *Context
+  )
+{
+  THREAD_THUNK_THREAD_ENTRY Start;
+  sigset_t                  SigMask;
+  
+  // Save global on the stack before we unlock
+  Start   = mThreadMangle.Start;
+  pthread_mutex_unlock (&mThreadMangle.Mutex);
+  
+  // Mask all signals to the APs
+  sigfillset (&SigMask); 
+  pthread_sigmask (SIG_BLOCK, &SigMask, NULL);
+  
+  //
+  // We have to start the thread in SEC as we need to follow
+  // OS X calling conventions. We can then call back into 
+  // to the callers Start.
+  //
+  // This is a great example of how all problems in computer 
+  // science can be solved by adding another level of indirection
+  //
+ return  (VOID *)ReverseGasketUint64 ((CALL_BACK)Start, (UINTN)Context);
+}
+  
+UINTN
+PthreadCreate (
+  IN  VOID                      *Thread,
+  IN  VOID                      *Attribute,
+  IN  THREAD_THUNK_THREAD_ENTRY Start,
+  IN  VOID                      *Context
+  )
+{
+  int         err;
+  BOOLEAN     EnabledOnEntry;    
+  
+  //
+  // Threads inherit interrupt state so disable interrupts before we start thread
+  //
+  if (SecInterruptEanbled ()) {
+    SecDisableInterrupt ();
+    EnabledOnEntry = TRUE;
+  } else {
+    EnabledOnEntry = FALSE;
+  }
+  
+  // Aquire lock for global, SecFakePthreadStart runs in a different thread.
+  pthread_mutex_lock (&mThreadMangle.Mutex);
+  mThreadMangle.Start   = Start;
+  
+  err = pthread_create (Thread, Attribute, SecFakePthreadStart, Context);
+  if (err != 0) {
+    // Thread failed to launch so release the lock;
+    pthread_mutex_unlock (&mThreadMangle.Mutex);
+  }
+  
+  if (EnabledOnEntry) {
+    // Restore interrupt state
+    SecEnableInterrupt ();
+  }    
+
+  return err;
+}
+
+
+VOID
+PthreadExit (
+  IN VOID *ValuePtr
+  )
+{ 
+  pthread_exit (ValuePtr);
+  return;
+}
+
+   
+UINTN
+PthreadSelf (
+  VOID
+  )
+{
+  // POSIX currently allows pthread_t to be a structure or arithmetic type.
+  // Check out sys/types.h to make sure this will work if you are porting. 
+  // On OS X (Darwin) pthread_t is a pointer to a structure so this code works.
+  return (UINTN)pthread_self (); 
+}
+
+
+EMU_THREAD_THUNK_PROTOCOL gPthreadThunk = {
+  GasketPthreadMutexLock,
+  GasketPthreadMutexUnLock,
+  GasketPthreadMutexTryLock,
+  GasketPthreadMutexInit,
+  GasketPthreadMutexDestroy,
+  GasketPthreadCreate,
+  GasketPthreadExit,
+  GasketPthreadSelf
+};
+
+
+EFI_STATUS
+PthreadOpen (
+  IN  EMU_IO_THUNK_PROTOCOL   *This
+  )
+{
+  if (This->Instance != 0) {
+    // Only single instance is supported
+    return EFI_NOT_FOUND;
+  }
+  
+  if (This->ConfigString[0] == L'0') {
+    // If AP count is zero no need for threads
+    return EFI_NOT_FOUND;
+  }
+  
+  This->Interface = &gPthreadThunk;
+  
+  return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+PthreadClose (
+  IN  EMU_IO_THUNK_PROTOCOL   *This
+  )
+{
+  return EFI_SUCCESS;
+}
+
+
+EMU_IO_THUNK_PROTOCOL gPthreadThunkIo = {
+  &gEmuThreadThunkProtocolGuid,
+  NULL,
+  NULL,
+  0,
+  GasketPthreadOpen,
+  GasketPthreadClose,
+  NULL
+};
+
+
diff --git a/EmulatorPkg/Unix/Host/SecMain.c b/EmulatorPkg/Unix/Host/SecMain.c
new file mode 100644 (file)
index 0000000..2806347
--- /dev/null
@@ -0,0 +1,1226 @@
+/*++ @file
+
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
+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 "SecMain.h"
+
+#ifdef __APPLE__
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
+
+//
+// Globals
+//
+
+EMU_THUNK_PPI mSecEmuThunkPpi = {
+  GasketSecUnixPeiAutoScan,
+  GasketSecUnixFdAddress,
+  GasketSecEmuThunkAddress
+};
+
+char *gGdbWorkingFileName = NULL;
+unsigned int mScriptSymbolChangesCount = 0;
+
+
+//
+// Default information about where the FD is located.
+//  This array gets filled in with information from EFI_FIRMWARE_VOLUMES
+//  EFI_FIRMWARE_VOLUMES is a host environment variable set by system.cmd.
+//  The number of array elements is allocated base on parsing
+//  EFI_FIRMWARE_VOLUMES and the memory is never freed.
+//
+UINTN       gFdInfoCount = 0;
+EMU_FD_INFO *gFdInfo;
+
+//
+// Array that supports seperate memory rantes.
+//  The memory ranges are set in system.cmd via the EFI_MEMORY_SIZE variable.
+//  The number of array elements is allocated base on parsing
+//  EFI_MEMORY_SIZE and the memory is never freed.
+//
+UINTN              gSystemMemoryCount = 0;
+EMU_SYSTEM_MEMORY  *gSystemMemory;
+
+
+
+UINTN                        mImageContextModHandleArraySize = 0;
+IMAGE_CONTEXT_TO_MOD_HANDLE  *mImageContextModHandleArray = NULL;
+
+EFI_PEI_PPI_DESCRIPTOR  *gPpiList;
+
+
+int gInXcode = 0;
+
+
+/*++
+  Breakpoint target for Xcode project. Set in the Xcode XML
+  
+  Xcode breakpoint will 'source SecMain.gdb'
+  gGdbWorkingFileName is set to SecMain.gdb
+
+**/
+VOID
+SecGdbConfigBreak (
+  VOID
+  )
+{
+}
+
+
+
+/*++
+
+Routine Description:
+  Main entry point to SEC for Unix. This is a unix program
+
+Arguments:
+  Argc - Number of command line arguments
+  Argv - Array of command line argument strings
+  Envp - Array of environmemt variable strings
+
+Returns:
+  0 - Normal exit
+  1 - Abnormal exit
+
+**/
+int
+main (
+  IN  int   Argc,
+  IN  char  **Argv,
+  IN  char  **Envp
+  )
+{
+  EFI_STATUS            Status;
+  EFI_PHYSICAL_ADDRESS  InitialStackMemory;
+  UINT64                InitialStackMemorySize;
+  UINTN                 Index;
+  UINTN                 Index1;
+  UINTN                 Index2;
+  UINTN                 PeiIndex;
+  CHAR8                 *FileName;
+  BOOLEAN               Done;
+  EFI_PEI_FILE_HANDLE   FileHandle;
+  VOID                  *SecFile;
+  CHAR16                *MemorySizeStr;
+  CHAR16                *FirmwareVolumesStr;
+  UINTN                 *StackPointer;
+  FILE                  *GdbTempFile;
+  
+  //
+  // Xcode does not support sourcing gdb scripts directly, so the Xcode XML 
+  // has a break point script to source the GdbRun script.
+  //
+  SecGdbConfigBreak ();
+  
+  //
+  // If dlopen doesn't work, then we build a gdb script to allow the
+  // symbols to be loaded.
+  //
+  Index = strlen (*Argv);
+  gGdbWorkingFileName = AllocatePool (Index + strlen(".gdb") + 1);
+  strcpy (gGdbWorkingFileName, *Argv);
+  strcat (gGdbWorkingFileName, ".gdb");
+
+  //
+  // Empty out the gdb symbols script file.
+  //
+  GdbTempFile = fopen (gGdbWorkingFileName, "w");
+  if (GdbTempFile != NULL) {
+    fclose (GdbTempFile);
+  }
+
+  printf ("\nEDK II UNIX Host Emulation Environment from edk2.sourceforge.net\n");
+  
+  setbuf (stdout, 0);
+  setbuf (stderr, 0);
+
+  MemorySizeStr      = (CHAR16 *) PcdGetPtr (PcdEmuMemorySize);
+  FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdEmuFirmwareVolume);
+
+  //
+  // PPIs pased into PEI_CORE
+  //
+  AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEmuThunkPpiGuid, &mSecEmuThunkPpi);
+
+  SecInitThunkProtocol ();
+  
+  //
+  // Emulator Bus Driver Thunks
+  //
+  AddThunkProtocol (&gX11ThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuGop), TRUE); 
+  AddThunkProtocol (&gPosixFileSystemThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuFileSystem), TRUE); 
+  AddThunkProtocol (&gBlockIoThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuVirtualDisk), TRUE); 
+  AddThunkProtocol (&gSnpThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuNetworkInterface), TRUE); 
+
+  //
+  // Emulator other Thunks
+  //
+  AddThunkProtocol (&gPthreadThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuApCount), FALSE); 
+
+  // EmuSecLibConstructor ();
+  
+  gPpiList = GetThunkPpiList (); 
+
+  //
+  // Allocate space for gSystemMemory Array
+  //
+  gSystemMemoryCount  = CountSeperatorsInString (MemorySizeStr, '!') + 1;
+  gSystemMemory       = AllocateZeroPool (gSystemMemoryCount * sizeof (EMU_SYSTEM_MEMORY));
+  if (gSystemMemory == NULL) {
+    printf ("ERROR : Can not allocate memory for system.  Exiting.\n");
+    exit (1);
+  }
+  //
+  // Allocate space for gSystemMemory Array
+  //
+  gFdInfoCount  = CountSeperatorsInString (FirmwareVolumesStr, '!') + 1;
+  gFdInfo       = AllocateZeroPool (gFdInfoCount * sizeof (EMU_FD_INFO));
+  if (gFdInfo == NULL) {
+    printf ("ERROR : Can not allocate memory for fd info.  Exiting.\n");
+    exit (1);
+  }
+
+  printf ("  BootMode 0x%02x\n", (unsigned int)PcdGet32 (PcdEmuBootMode));
+
+  //
+  // Open up a 128K file to emulate temp memory for SEC.
+  //  on a real platform this would be SRAM, or using the cache as RAM.
+  //  Set InitialStackMemory to zero so UnixOpenFile will allocate a new mapping
+  //
+  InitialStackMemorySize  = STACK_SIZE;
+  InitialStackMemory = (UINTN)MapMemory (
+                                0, (UINT32) InitialStackMemorySize,
+                                PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE
+                                );
+  if (InitialStackMemory == 0) {
+    printf ("ERROR : Can not open SecStack Exiting\n");
+    exit (1);
+  }
+
+  printf ("  OS Emulator passing in %u KB of temp RAM at 0x%08lx to SEC\n",
+    (unsigned int)(InitialStackMemorySize / 1024),
+    (unsigned long)InitialStackMemory
+    );
+
+  for (StackPointer = (UINTN*) (UINTN) InitialStackMemory;
+     StackPointer < (UINTN*)(UINTN)((UINTN) InitialStackMemory + (UINT64) InitialStackMemorySize);
+     StackPointer ++) {
+    *StackPointer = 0x5AA55AA5;
+  }
+
+  //
+  // Open All the firmware volumes and remember the info in the gFdInfo global
+  //
+  FileName = (CHAR8 *) AllocatePool (StrLen (FirmwareVolumesStr) + 1);
+  if (FileName == NULL) {
+    printf ("ERROR : Can not allocate memory for firmware volume string\n");
+    exit (1);
+  }
+
+  Index2 = 0;
+  for (Done = FALSE, Index = 0, PeiIndex = 0, SecFile = NULL;
+       FirmwareVolumesStr[Index2] != 0;
+       Index++) {
+    for (Index1 = 0; (FirmwareVolumesStr[Index2] != '!') && (FirmwareVolumesStr[Index2] != 0); Index2++) {
+      FileName[Index1++] = FirmwareVolumesStr[Index2];
+    }
+    if (FirmwareVolumesStr[Index2] == '!') {
+      Index2++;
+    }
+    FileName[Index1]  = '\0';
+
+    if (Index == 0) {
+      // Map FV Recovery Read Only and other areas Read/Write
+      Status = MapFd0 (
+                FileName,
+                &gFdInfo[0].Address,
+                &gFdInfo[0].Size
+                );
+    } else {
+      //
+      // Open the FD and remmeber where it got mapped into our processes address space
+      // Maps Read Only
+      //
+      Status = MapFile (
+                FileName,
+                &gFdInfo[Index].Address,
+                &gFdInfo[Index].Size
+                );
+    }
+    if (EFI_ERROR (Status)) {
+      printf ("ERROR : Can not open Firmware Device File %s (%x).  Exiting.\n", FileName, (unsigned int)Status);
+      exit (1);
+    }
+
+    printf ("  FD loaded from %s at 0x%08lx",FileName, (unsigned long)gFdInfo[Index].Address);
+
+    if (SecFile == NULL) {
+      //
+      // Assume the beginning of the FD is an FV and look for the SEC Core.
+      // Load the first one we find.
+      //
+      FileHandle = NULL;
+      Status = PeiServicesFfsFindNextFile (
+                  EFI_FV_FILETYPE_SECURITY_CORE, 
+                  (EFI_PEI_FV_HANDLE)(UINTN)gFdInfo[Index].Address, 
+                  &FileHandle
+                  );
+      if (!EFI_ERROR (Status)) {
+        Status = PeiServicesFfsFindSectionData (EFI_SECTION_PE32, FileHandle, &SecFile);
+        if (!EFI_ERROR (Status)) {
+          PeiIndex = Index;
+          printf (" contains SEC Core");
+        }
+      }
+    }
+
+    printf ("\n");
+  }
+  //
+  // Calculate memory regions and store the information in the gSystemMemory
+  //  global for later use. The autosizing code will use this data to
+  //  map this memory into the SEC process memory space.
+  //
+  Index1 = 0;
+  Index = 0;
+  while (1) {
+    UINTN val = 0;
+    //
+    // Save the size of the memory.
+    //
+    while (MemorySizeStr[Index1] >= '0' && MemorySizeStr[Index1] <= '9') {
+      val = val * 10 + MemorySizeStr[Index1] - '0';
+      Index1++;
+    }
+    gSystemMemory[Index++].Size = val * 0x100000;
+    if (MemorySizeStr[Index1] == 0) {
+      break;
+    }
+    Index1++;
+  }
+
+  printf ("\n");
+
+  //
+  // Hand off to SEC
+  //
+  SecLoadFromCore ((UINTN) InitialStackMemory, (UINTN) InitialStackMemorySize, (UINTN) gFdInfo[0].Address, SecFile);
+
+  //
+  // If we get here, then the SEC Core returned. This is an error as SEC should
+  //  always hand off to PEI Core and then on to DXE Core.
+  //
+  printf ("ERROR : SEC returned\n");
+  exit (1);
+}
+
+
+EFI_PHYSICAL_ADDRESS *
+MapMemory (
+  IN INTN   fd,
+  IN UINT64 length,
+  IN INTN   prot,
+  IN INTN   flags
+  )
+{
+  STATIC UINTN base  = 0x40000000;
+  CONST UINTN  align = (1 << 24);
+  VOID         *res  = NULL;
+  BOOLEAN      isAligned = 0;
+
+  //
+  // Try to get an aligned block somewhere in the address space of this
+  // process.
+  //
+  while((!isAligned) && (base != 0)) {
+    res = mmap ((void *)base, length, prot, flags, fd, 0);
+    if (res == MAP_FAILED) {
+      return NULL;
+    }
+    if ((((UINTN)res) & ~(align-1)) == (UINTN)res) {
+      isAligned=1;
+    } else {
+      munmap(res, length);
+      base += align;
+    }
+  }
+  return res;
+}
+
+
+/*++
+
+Routine Description:
+  Opens and memory maps a file using Unix services. If BaseAddress is non zero
+  the process will try and allocate the memory starting at BaseAddress.
+
+Arguments:
+  FileName            - The name of the file to open and map
+  MapSize             - The amount of the file to map in bytes
+  CreationDisposition - The flags to pass to CreateFile().  Use to create new files for
+                        memory emulation, and exiting files for firmware volume emulation
+  BaseAddress         - The base address of the mapped file in the user address space.
+                         If passed in as NULL the a new memory region is used.
+                         If passed in as non NULL the request memory region is used for
+                          the mapping of the file into the process space.
+  Length              - The size of the mapped region in bytes
+
+Returns:
+  EFI_SUCCESS      - The file was opened and mapped.
+  EFI_NOT_FOUND    - FileName was not found in the current directory
+  EFI_DEVICE_ERROR - An error occured attempting to map the opened file
+
+**/
+EFI_STATUS
+MapFile (
+  IN  CHAR8                     *FileName,
+  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,
+  OUT UINT64                    *Length
+  )
+{
+  int     fd;
+  VOID    *res;
+  UINTN   FileSize;
+
+  fd = open (FileName, O_RDWR);
+  if (fd < 0) {
+    return EFI_NOT_FOUND;
+  }
+  FileSize = lseek (fd, 0, SEEK_END);
+
+
+  res = MapMemory (fd, FileSize, PROT_READ | PROT_EXEC, MAP_PRIVATE);
+
+  close (fd);
+
+  if (res == NULL) {
+    perror ("MapFile() Failed");
+    return EFI_DEVICE_ERROR;
+  }
+      
+  *Length = (UINT64) FileSize;
+  *BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) res;
+
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+MapFd0 (
+  IN  CHAR8                     *FileName,
+  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,
+  OUT UINT64                    *Length
+  )
+{
+  int     fd;
+  void    *res, *res2, *res3;
+  UINTN   FileSize;
+  UINTN   FvSize;
+  void    *EmuMagicPage;
+
+  fd = open (FileName, O_RDWR);
+  if (fd < 0) {
+    return EFI_NOT_FOUND;
+  }
+  FileSize = lseek (fd, 0, SEEK_END);
+  FvSize = FixedPcdGet64 (PcdEmuFlashFvRecoverySize);
+
+  // Assume start of FD is Recovery FV, and make it write protected
+  res = mmap (
+          (void *)(UINTN)FixedPcdGet64 (PcdEmuFlashFvRecoveryBase), 
+          FvSize, 
+          PROT_READ | PROT_EXEC, 
+          MAP_PRIVATE, 
+          fd, 
+          0
+          );
+  if (res == MAP_FAILED) {
+    perror ("MapFd0() Failed res =");
+    close (fd);
+    return EFI_DEVICE_ERROR;
+  } else if (res != (void *)(UINTN)FixedPcdGet64 (PcdEmuFlashFvRecoveryBase)) {
+    // We could not load at the build address, so we need to allow writes
+    munmap (res, FvSize);
+    res = mmap (
+            (void *)(UINTN)FixedPcdGet64 (PcdEmuFlashFvRecoveryBase), 
+            FvSize, 
+            PROT_READ | PROT_WRITE | PROT_EXEC, 
+            MAP_PRIVATE, 
+            fd, 
+            0
+            );
+    if (res == MAP_FAILED) {
+      perror ("MapFd0() Failed res =");
+      close (fd);
+      return EFI_DEVICE_ERROR;
+    }
+  }
+  
+  // Map the rest of the FD as read/write
+  res2 = mmap (
+          (void *)(UINTN)(FixedPcdGet64 (PcdEmuFlashFvRecoveryBase) + FvSize), 
+          FileSize - FvSize, 
+          PROT_READ | PROT_WRITE | PROT_EXEC, 
+          MAP_SHARED,
+          fd, 
+          FvSize
+          );
+  close (fd);
+  if (res2 == MAP_FAILED) {
+    perror ("MapFd0() Failed res2 =");
+    return EFI_DEVICE_ERROR;
+  }
+
+  //
+  // If enabled use the magic page to communicate between modules 
+  // This replaces the PI PeiServicesTable pointer mechanism that
+  // deos not work in the emulator. It also allows the removal of
+  // writable globals from SEC, PEI_CORE (libraries), PEIMs
+  //
+  EmuMagicPage = (void *)(UINTN)FixedPcdGet64 (PcdPeiServicesTablePage);
+  if (EmuMagicPage != NULL) {
+    res3 =  mmap (
+              (void *)EmuMagicPage, 
+              4096, 
+              PROT_READ | PROT_WRITE, 
+              MAP_PRIVATE | MAP_ANONYMOUS,
+              0, 
+              0
+              );
+    if (res3 != EmuMagicPage) {
+      printf ("MapFd0(): Could not allocate PeiServicesTablePage @ %lx\n", (long unsigned int)EmuMagicPage);
+      return EFI_DEVICE_ERROR;
+    }
+  }
+  
+  *Length = (UINT64) FileSize;
+  *BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) res;
+
+  return EFI_SUCCESS;  
+}
+
+
+/*++
+
+Routine Description:
+  This is the service to load the SEC Core from the Firmware Volume
+
+Arguments:
+  LargestRegion           - Memory to use for SEC.
+  LargestRegionSize       - Size of Memory to use for PEI
+  BootFirmwareVolumeBase  - Start of the Boot FV
+  PeiCorePe32File         - SEC PE32
+
+Returns:
+  Success means control is transfered and thus we should never return
+
+**/
+VOID
+SecLoadFromCore (
+  IN  UINTN   LargestRegion,
+  IN  UINTN   LargestRegionSize,
+  IN  UINTN   BootFirmwareVolumeBase,
+  IN  VOID    *PeiCorePe32File
+  )
+{
+  EFI_STATUS                  Status;
+  EFI_PHYSICAL_ADDRESS        TopOfMemory;
+  VOID                        *TopOfStack;
+  EFI_PHYSICAL_ADDRESS        PeiCoreEntryPoint;
+  EFI_SEC_PEI_HAND_OFF        *SecCoreData;
+  UINTN                       PeiStackSize;
+
+  //
+  // Compute Top Of Memory for Stack and PEI Core Allocations
+  //
+  TopOfMemory  = LargestRegion + LargestRegionSize;
+  PeiStackSize = (UINTN)RShiftU64((UINT64)STACK_SIZE,1);
+
+  //
+  // |-----------| <---- TemporaryRamBase + TemporaryRamSize
+  // |   Heap    |
+  // |           |
+  // |-----------| <---- StackBase / PeiTemporaryMemoryBase
+  // |           |
+  // |  Stack    |
+  // |-----------| <---- TemporaryRamBase
+  //
+  TopOfStack  = (VOID *)(LargestRegion + PeiStackSize);
+  TopOfMemory = LargestRegion + PeiStackSize;
+
+  //
+  // Reservet space for storing PeiCore's parament in stack.
+  //
+  TopOfStack  = (VOID *)((UINTN)TopOfStack - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT);
+  TopOfStack  = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
+
+
+  //
+  // Bind this information into the SEC hand-off state
+  //
+  SecCoreData                         = (EFI_SEC_PEI_HAND_OFF*)(UINTN) TopOfStack;
+  SecCoreData->DataSize               = sizeof(EFI_SEC_PEI_HAND_OFF);
+  SecCoreData->BootFirmwareVolumeBase = (VOID*)BootFirmwareVolumeBase;
+  SecCoreData->BootFirmwareVolumeSize = PcdGet32 (PcdEmuFirmwareFdSize);
+  SecCoreData->TemporaryRamBase       = (VOID*)(UINTN)LargestRegion;
+  SecCoreData->TemporaryRamSize       = STACK_SIZE;
+  SecCoreData->StackBase              = SecCoreData->TemporaryRamBase;
+  SecCoreData->StackSize              = PeiStackSize;
+  SecCoreData->PeiTemporaryRamBase    = (VOID*) ((UINTN) SecCoreData->TemporaryRamBase + PeiStackSize);
+  SecCoreData->PeiTemporaryRamSize    = STACK_SIZE - PeiStackSize;
+
+  //
+  // Find the SEC Core Entry Point
+  //
+  Status = SecPeCoffGetEntryPoint (PeiCorePe32File, (VOID **)&PeiCoreEntryPoint);
+  if (EFI_ERROR (Status)) {
+    return ;
+  }
+
+  //
+  // Transfer control to the SEC Core
+  //
+  PeiSwitchStacks (
+    (SWITCH_STACK_ENTRY_POINT) (UINTN) PeiCoreEntryPoint,
+    SecCoreData,
+    (VOID *)gPpiList,
+    TopOfStack
+    );
+  //
+  // If we get here, then the SEC Core returned.  This is an error
+  //
+  return ;
+}
+
+
+/*++
+
+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.
+  It uses gSystemMemory[] and gSystemMemoryCount that were created by
+  parsing the host environment variable EFI_MEMORY_SIZE.
+  The size comes from the varaible and the address comes from the call to
+  UnixOpenFile.
+
+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
+
+**/
+EFI_STATUS
+SecUnixPeiAutoScan (
+  IN  UINTN                 Index,
+  OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,
+  OUT UINT64                *MemorySize
+  )
+{
+  void *res;
+
+  if (Index >= gSystemMemoryCount) {
+    return EFI_UNSUPPORTED;
+  }
+
+  *MemoryBase = 0;
+  res = MapMemory (
+          0, gSystemMemory[Index].Size,
+          PROT_READ | PROT_WRITE | PROT_EXEC,
+          MAP_PRIVATE | MAP_ANONYMOUS
+          );
+  if (res == MAP_FAILED) {
+    return EFI_DEVICE_ERROR;
+  }
+  *MemorySize = gSystemMemory[Index].Size;
+  *MemoryBase = (UINTN)res;
+  gSystemMemory[Index].Memory = *MemoryBase;
+
+  return EFI_SUCCESS;
+}
+
+
+/*++
+
+Routine Description:
+ Check to see if an address range is in the EFI GCD memory map.
+ This is all of GCD for system memory passed to DXE Core. FV 
+ mapping and other device mapped into system memory are not
+ inlcuded in the check. 
+
+Arguments:
+  Index      - Which memory region to use
+  MemoryBase - Return Base address of memory region
+  MemorySize - Return size in bytes of the memory region
+
+Returns:
+  TRUE -  Address is in the EFI GCD memory map
+  FALSE - Address is NOT in memory map
+
+**/
+BOOLEAN
+EfiSystemMemoryRange (
+  IN  VOID *MemoryAddress
+  )
+{
+  UINTN                 Index;
+  EFI_PHYSICAL_ADDRESS  MemoryBase;
+  
+  MemoryBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MemoryAddress;
+  for (Index = 0; Index < gSystemMemoryCount; Index++) {
+    if ((MemoryBase >= gSystemMemory[Index].Memory) &&
+        (MemoryBase < (gSystemMemory[Index].Memory + gSystemMemory[Index].Size)) ) {
+      return TRUE;
+    }
+  }
+  
+  return FALSE;
+}
+
+
+/*++
+
+Routine Description:
+  Since the SEC is the only Unix program in stack it must export
+  an interface to do POSIX calls.  gUnix is initailized in UnixThunk.c.
+
+Arguments:
+  InterfaceSize - sizeof (EFI_WIN_NT_THUNK_PROTOCOL);
+  InterfaceBase - Address of the gUnix global
+
+Returns:
+  EFI_SUCCESS - Data returned
+
+**/
+VOID *
+SecEmuThunkAddress (
+  VOID
+  )
+{
+  return &gEmuThunkProtocol;
+}
+
+
+
+RETURN_STATUS
+EFIAPI
+SecPeCoffGetEntryPoint (
+  IN     VOID  *Pe32Data,
+  IN OUT VOID  **EntryPoint
+  )
+{
+  EFI_STATUS                    Status;
+  PE_COFF_LOADER_IMAGE_CONTEXT  ImageContext;
+
+  ZeroMem (&ImageContext, sizeof (ImageContext));
+  ImageContext.Handle     = Pe32Data;
+  ImageContext.ImageRead  = (PE_COFF_LOADER_READ_FILE) SecImageRead;
+
+  Status                  = PeCoffLoaderGetImageInfo (&ImageContext);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  if (ImageContext.ImageAddress != (UINTN)Pe32Data) {
+    //
+    // Relocate image to match the address where it resides
+    //
+    ImageContext.ImageAddress = (UINTN)Pe32Data;
+    Status = PeCoffLoaderLoadImage (&ImageContext);
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+
+    Status = PeCoffLoaderRelocateImage (&ImageContext);
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+  } else {
+    //
+    // Or just return image entry point
+    //
+    ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer (Pe32Data);
+    Status = PeCoffLoaderGetEntryPoint (Pe32Data, EntryPoint);
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+    ImageContext.EntryPoint = (UINTN)*EntryPoint;
+  }
+
+  // On Unix a dlopen is done that will change the entry point
+  SecPeCoffRelocateImageExtraAction (&ImageContext);
+  *EntryPoint = (VOID *)(UINTN)ImageContext.EntryPoint;
+  
+  return Status;
+}
+
+
+
+/*++
+
+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
+
+**/
+EFI_STATUS
+SecUnixFdAddress (
+  IN     UINTN                 Index,
+  IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,
+  IN OUT UINT64                *FdSize,
+  IN OUT EFI_PHYSICAL_ADDRESS  *FixUp
+  )
+{
+  if (Index >= gFdInfoCount) {
+    return EFI_UNSUPPORTED;
+  }
+
+  *FdBase = gFdInfo[Index].Address;
+  *FdSize = gFdInfo[Index].Size;
+  *FixUp  = 0;
+
+  if (*FdBase == 0 && *FdSize == 0) {
+    return EFI_UNSUPPORTED;
+  }
+
+  if (Index == 0) {
+    //
+    // FD 0 has XIP code and well known PCD values
+    // If the memory buffer could not be allocated at the FD build address
+    // the Fixup is the difference.
+    //
+    *FixUp = *FdBase - PcdGet64 (PcdEmuFdBaseAddress);
+  }
+
+  return EFI_SUCCESS;
+}
+
+
+/*++
+
+Routine Description:
+  Count the number of seperators in String
+
+Arguments:
+  String    - String to process
+  Seperator - Item to count
+
+Returns:
+  Number of Seperator in String
+
+**/
+UINTN
+CountSeperatorsInString (
+  IN  const CHAR16   *String,
+  IN  CHAR16         Seperator
+  )
+{
+  UINTN Count;
+
+  for (Count = 0; *String != '\0'; String++) {
+    if (*String == Seperator) {
+      Count++;
+    }
+  }
+
+  return Count;
+}
+
+
+EFI_STATUS
+EFIAPI
+SecImageRead (
+  IN     VOID    *FileHandle,
+  IN     UINTN   FileOffset,
+  IN OUT UINTN   *ReadSize,
+  OUT    VOID    *Buffer
+  )
+/*++
+
+Routine Description:
+  Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file
+
+Arguments:
+  FileHandle - The handle to the PE/COFF file
+  FileOffset - The offset, in bytes, into the file to read
+  ReadSize   - The number of bytes to read from the file starting at FileOffset
+  Buffer     - A pointer to the buffer to read the data into.
+
+Returns:
+  EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset
+
+**/
+{
+  CHAR8 *Destination8;
+  CHAR8 *Source8;
+  UINTN Length;
+
+  Destination8  = Buffer;
+  Source8       = (CHAR8 *) ((UINTN) FileHandle + FileOffset);
+  Length        = *ReadSize;
+  while (Length--) {
+    *(Destination8++) = *(Source8++);
+  }
+
+  return EFI_SUCCESS;
+}
+
+
+/*++
+
+Routine Description:
+  Store the ModHandle in an array indexed by the Pdb File name.
+  The ModHandle is needed to unload the image.
+
+Arguments:
+  ImageContext - Input data returned from PE Laoder Library. Used to find the
+                 .PDB file name of the PE Image.
+  ModHandle    - Returned from LoadLibraryEx() and stored for call to
+                 FreeLibrary().
+
+Returns:
+  EFI_SUCCESS - ModHandle was stored.
+
+**/
+EFI_STATUS
+AddHandle (
+  IN  PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext,
+  IN  VOID                                 *ModHandle
+  )
+{
+  UINTN                       Index;
+  IMAGE_CONTEXT_TO_MOD_HANDLE *Array;
+  UINTN                       PreviousSize;
+
+
+  Array = mImageContextModHandleArray;
+  for (Index = 0; Index < mImageContextModHandleArraySize; Index++, Array++) {
+    if (Array->ImageContext == NULL) {
+      //
+      // Make a copy of the stirng and store the ModHandle
+      //
+      Array->ImageContext = ImageContext;
+      Array->ModHandle    = ModHandle;
+      return EFI_SUCCESS;
+    }
+  }
+
+  //
+  // No free space in mImageContextModHandleArray so grow it by
+  // IMAGE_CONTEXT_TO_MOD_HANDLE entires. realloc will
+  // copy the old values to the new locaiton. But it does
+  // not zero the new memory area.
+  //
+  PreviousSize = mImageContextModHandleArraySize * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE);
+  mImageContextModHandleArraySize += MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE;
+
+  mImageContextModHandleArray = ReallocatePool (
+                                  (mImageContextModHandleArraySize - 1) * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE),
+                                  mImageContextModHandleArraySize * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE),
+                                  mImageContextModHandleArray
+                                  );
+  if (mImageContextModHandleArray == NULL) {
+    ASSERT (FALSE);
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  memset (mImageContextModHandleArray + PreviousSize, 0, MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE));
+
+  return AddHandle (ImageContext, ModHandle);
+}
+
+
+/*++
+
+Routine Description:
+  Return the ModHandle and delete the entry in the array.
+
+Arguments:
+  ImageContext - Input data returned from PE Laoder Library. Used to find the
+                 .PDB file name of the PE Image.
+
+Returns:
+  ModHandle - ModHandle assoicated with ImageContext is returned
+  NULL      - No ModHandle associated with ImageContext
+
+**/
+VOID *
+RemoveHandle (
+  IN  PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
+  )
+{
+  UINTN                        Index;
+  IMAGE_CONTEXT_TO_MOD_HANDLE  *Array;
+
+  if (ImageContext->PdbPointer == NULL) {
+    //
+    // If no PDB pointer there is no ModHandle so return NULL
+    //
+    return NULL;
+  }
+
+  Array = mImageContextModHandleArray;
+  for (Index = 0; Index < mImageContextModHandleArraySize; Index++, Array++) {
+    if (Array->ImageContext == ImageContext) {
+      //
+      // If you find a match return it and delete the entry
+      //
+      Array->ImageContext = NULL;
+      return Array->ModHandle;
+    }
+  }
+
+  return NULL;
+}
+
+
+
+BOOLEAN
+IsPdbFile (
+  IN  CHAR8   *PdbFileName
+  )
+{
+  UINTN Len;
+
+  if (PdbFileName == NULL) {
+    return FALSE;
+  }
+
+  Len = strlen (PdbFileName);
+  if ((Len < 5)|| (PdbFileName[Len - 4] != '.')) {
+    return FALSE;
+  }
+
+  if ((PdbFileName[Len - 3] == 'P' || PdbFileName[Len - 3] == 'p') &&
+      (PdbFileName[Len - 2] == 'D' || PdbFileName[Len - 2] == 'd') &&
+      (PdbFileName[Len - 1] == 'B' || PdbFileName[Len - 1] == 'b')) {
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+
+#define MAX_SPRINT_BUFFER_SIZE 0x200
+
+void
+PrintLoadAddress (
+  IN PE_COFF_LOADER_IMAGE_CONTEXT          *ImageContext
+  )
+{
+  if (ImageContext->PdbPointer == NULL) {
+    fprintf (stderr,
+      "0x%08lx Loading NO DEBUG with entry point 0x%08lx\n",
+      (unsigned long)(ImageContext->ImageAddress),
+      (unsigned long)ImageContext->EntryPoint
+      );
+  } else {
+    fprintf (stderr,
+      "0x%08lx Loading %s with entry point 0x%08lx\n",
+      (unsigned long)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders),
+      ImageContext->PdbPointer,
+      (unsigned long)ImageContext->EntryPoint
+      );
+  }
+  // Keep output synced up
+  fflush (stderr);
+}
+
+
+/**
+  Loads the image using dlopen so symbols will be automatically
+  loaded by gdb.
+
+  @param  ImageContext  The PE/COFF image context
+
+  @retval TRUE - The image was successfully loaded
+  @retval FALSE - The image was successfully loaded
+
+**/
+BOOLEAN
+DlLoadImage (
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
+  )
+{
+
+#ifdef __APPLE__
+
+  return FALSE;
+
+#else
+
+  void        *Handle = NULL;
+  void        *Entry = NULL;
+
+  if (ImageContext->PdbPointer == NULL) {
+    return FALSE;
+  }
+
+  if (!IsPdbFile (ImageContext->PdbPointer)) {
+    return FALSE;
+  }
+
+  fprintf (
+     stderr,
+     "Loading %s 0x%08lx - entry point 0x%08lx\n",
+     ImageContext->PdbPointer,
+     (unsigned long)ImageContext->ImageAddress,
+     (unsigned long)ImageContext->EntryPoint
+     );
+
+  Handle = dlopen (ImageContext->PdbPointer, RTLD_NOW);
+  if (Handle != NULL) {
+    Entry = dlsym (Handle, "_ModuleEntryPoint");
+    AddHandle (ImageContext, Handle);
+  } else {
+    printf("%s\n", dlerror());
+  }
+
+  if (Entry != NULL) {
+    ImageContext->EntryPoint = (UINTN)Entry;
+    printf ("Change %s Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, (unsigned long)Entry);
+    return TRUE;
+  } else {
+    return FALSE;
+  }
+
+#endif
+}
+
+
+/**
+  Adds the image to a gdb script so it's symbols can be loaded.
+  The AddFirmwareSymbolFile helper macro is used.
+
+  @param  ImageContext  The PE/COFF image context
+
+**/
+VOID
+GdbScriptAddImage (
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
+  )
+{
+
+  PrintLoadAddress (ImageContext);
+
+  if (ImageContext->PdbPointer != NULL && !IsPdbFile (ImageContext->PdbPointer)) {
+    FILE  *GdbTempFile;
+    GdbTempFile = fopen (gGdbWorkingFileName, "a");
+    if (GdbTempFile != NULL) {
+      long unsigned int SymbolsAddr = (long unsigned int)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders);
+      mScriptSymbolChangesCount++;
+      fprintf (
+        GdbTempFile,
+        "AddFirmwareSymbolFile 0x%x %s 0x%08lx\n",
+        mScriptSymbolChangesCount,
+        ImageContext->PdbPointer,
+        SymbolsAddr
+        );
+      fclose (GdbTempFile);
+    } else {
+      ASSERT (FALSE);
+    }
+  }
+}
+
+
+VOID
+EFIAPI
+SecPeCoffRelocateImageExtraAction (
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
+  )
+{
+  if (!DlLoadImage (ImageContext)) {
+    GdbScriptAddImage (ImageContext);
+  }
+}
+
+
+/**
+  Adds the image to a gdb script so it's symbols can be unloaded.
+  The RemoveFirmwareSymbolFile helper macro is used.
+
+  @param  ImageContext  The PE/COFF image context
+
+**/
+VOID
+GdbScriptRemoveImage (
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
+  )
+{
+  FILE  *GdbTempFile;
+
+  //
+  // Need to skip .PDB files created from VC++
+  //
+  if (IsPdbFile (ImageContext->PdbPointer)) {
+    return;
+  }
+
+  //
+  // Write the file we need for the gdb script
+  //
+  GdbTempFile = fopen (gGdbWorkingFileName, "a");
+  if (GdbTempFile != NULL) {
+    mScriptSymbolChangesCount++;
+    fprintf (
+      GdbTempFile,
+      "RemoveFirmwareSymbolFile 0x%x %s\n",
+      mScriptSymbolChangesCount,
+      ImageContext->PdbPointer
+      );
+    fclose (GdbTempFile);
+  } else {
+    ASSERT (FALSE);
+  }
+}
+
+
+VOID
+EFIAPI
+SecPeCoffUnloadImageExtraAction (
+  IN PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
+  )
+{
+  VOID *Handle;
+
+  //
+  // Check to see if the image symbols were loaded with gdb script, or dlopen
+  //
+  Handle = RemoveHandle (ImageContext);
+  if (Handle != NULL) {
+#ifndef __APPLE__
+    dlclose (Handle);
+#endif
+    return;
+  }
+
+  GdbScriptRemoveImage (ImageContext);
+}
+
+
diff --git a/EmulatorPkg/Unix/Host/SecMain.h b/EmulatorPkg/Unix/Host/SecMain.h
new file mode 100644 (file)
index 0000000..5cd7178
--- /dev/null
@@ -0,0 +1,356 @@
+/*++ @file\r
+\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
+\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _SEC_MAIN_H__\r
+#define _SEC_MAIN_H__\r
+\r
+//\r
+// Name mangle to prevent build errors. I.e conflicts between EFI and OS\r
+//\r
+#define NTOHL   _UNIX_EFI_NAME_MANGLE_NTOHL_\r
+#define HTONL   _UNIX_EFI_NAME_MANGLE_HTONL_\r
+#define NTOHS   _UNIX_EFI_NAME_MANGLE_NTOHS_\r
+#define HTONS   _UNIX_EFI_NAME_MANGLE_HTOHS_\r
+#define B0      _UNIX_EFI_NAME_MANGLE_B0_\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+\r
+#include <sys/types.h>\r
+#include <sys/stat.h>\r
+#include <sys/termios.h>\r
+#include <sys/time.h>\r
+\r
+#if __CYGWIN__\r
+#include <sys/dirent.h>\r
+#else\r
+#include <sys/dir.h>\r
+#endif\r
+\r
+#include <sys/mman.h>\r
+#include <dlfcn.h>\r
+\r
+#include <unistd.h>\r
+#include <poll.h>\r
+#include <fcntl.h>\r
+#include <time.h>\r
+#include <signal.h>\r
+#include <errno.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <sys/ioctl.h>\r
+#include <sys/statvfs.h>\r
+\r
+#include <sys/socket.h>\r
+#include <netdb.h>\r
+#include <netinet/in.h>\r
+#include <net/if.h>\r
+#include <ifaddrs.h>\r
+\r
+#ifdef __APPLE__\r
+#include <net/if_dl.h>\r
+#include <net/bpf.h>\r
+#include <sys/param.h>\r
+#include <sys/mount.h>\r
+#include <sys/disk.h>\r
+#define _XOPEN_SOURCE\r
+#ifndef _Bool\r
+  #define _Bool char // for clang debug\r
+#endif\r
+#else\r
+#include <termio.h>\r
+#include <sys/vfs.h>\r
+#include <linux/fs.h>\r
+#endif \r
+\r
+#include <utime.h>\r
+\r
+#undef NTOHL\r
+#undef HTONL\r
+#undef NTOHS\r
+#undef HTONS\r
+#undef B0\r
+\r
+\r
+#include <PiPei.h>\r
+#include <Uefi.h>\r
+\r
+#include <Library/PeCoffLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+\r
+#include <Library/ThunkPpiList.h>\r
+#include <Library/ThunkProtocolList.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/PeCoffGetEntryPointLib.h>\r
+#include <Library/EmuMagicPageLib.h>\r
+\r
+#include <Ppi/EmuThunk.h>\r
+#include <Ppi/StatusCode.h>\r
+\r
+#include <Protocol/SimplePointer.h>\r
+#include <Protocol/SimpleTextIn.h>\r
+#include <Protocol/SimpleTextInEx.h>\r
+#include <Protocol/UgaDraw.h>\r
+#include <Protocol/SimpleFileSystem.h>\r
+\r
+#include <Protocol/EmuThunk.h>\r
+#include <Protocol/EmuIoThunk.h>\r
+#include <Protocol/EmuGraphicsWindow.h>\r
+#include <Protocol/EmuThread.h>\r
+#include <Protocol/EmuBlockIo.h>\r
+#include <Protocol/EmuSnp.h>\r
+\r
+#include <Guid/FileInfo.h>\r
+#include <Guid/FileSystemInfo.h>\r
+#include <Guid/FileSystemVolumeLabelInfo.h>\r
+\r
+\r
+#include "Gasket.h"\r
+\r
+\r
+#define STACK_SIZE                0x20000      \r
+\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS  Address;\r
+  UINT64                Size;\r
+} EMU_FD_INFO;\r
+\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS  Memory;\r
+  UINT64                Size;\r
+} EMU_SYSTEM_MEMORY;\r
+\r
+\r
+#define MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE 0x100\r
+\r
+typedef struct {\r
+  PE_COFF_LOADER_IMAGE_CONTEXT   *ImageContext;\r
+  VOID                           *ModHandle;\r
+} IMAGE_CONTEXT_TO_MOD_HANDLE;\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecUnixPeiLoadFile (\r
+  VOID                  *Pe32Data,  \r
+  EFI_PHYSICAL_ADDRESS  *ImageAddress,  \r
+  UINT64                *ImageSize,  \r
+  EFI_PHYSICAL_ADDRESS  *EntryPoint  \r
+  );\r
+\r
+int\r
+main (\r
+  IN  int   Argc,\r
+  IN  char  **Argv,\r
+  IN  char  **Envp\r
+  );\r
+\r
+VOID\r
+SecLoadFromCore (\r
+  IN  UINTN   LargestRegion,\r
+  IN  UINTN   LargestRegionSize,\r
+  IN  UINTN   BootFirmwareVolumeBase,\r
+  IN  VOID    *PeiCoreFile\r
+  );\r
+\r
+EFI_STATUS\r
+SecLoadFile (\r
+  IN  VOID                    *Pe32Data,\r
+  IN  EFI_PHYSICAL_ADDRESS    *ImageAddress,\r
+  IN  UINT64                  *ImageSize,\r
+  IN  EFI_PHYSICAL_ADDRESS    *EntryPoint\r
+  );\r
+\r
+EFI_STATUS\r
+SecFfsFindPeiCore (\r
+  IN  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader,\r
+  OUT VOID                        **Pe32Data\r
+  );\r
+\r
+EFI_STATUS\r
+SecFfsFindNextFile (\r
+  IN EFI_FV_FILETYPE             SearchType,\r
+  IN EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader,\r
+  IN OUT EFI_FFS_FILE_HEADER     **FileHeader\r
+  );\r
+\r
+EFI_STATUS\r
+SecFfsFindSectionData (\r
+  IN EFI_SECTION_TYPE      SectionType,\r
+  IN EFI_FFS_FILE_HEADER   *FfsFileHeader,\r
+  IN OUT VOID              **SectionData\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecUnixPeCoffLoaderLoadAsDll (\r
+  IN CHAR8    *PdbFileName,\r
+  IN VOID     **ImageEntryPoint,\r
+  OUT VOID    **ModHandle\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecUnixPeCoffLoaderFreeLibrary (\r
+  OUT VOID    *ModHandle\r
+  );\r
+\r
+EFI_STATUS\r
+SecUnixFdAddress (\r
+  IN     UINTN                 Index,\r
+  IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,\r
+  IN OUT UINT64                *FdSize,\r
+  IN OUT EFI_PHYSICAL_ADDRESS  *FixUp\r
+  )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSecUnixFdAddress (\r
+  IN     UINTN                 Index,\r
+  IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,\r
+  IN OUT UINT64                *FdSize,\r
+  IN OUT EFI_PHYSICAL_ADDRESS  *FixUp\r
+  )\r
+;\r
+\r
+\r
+EFI_STATUS\r
+GetImageReadFunction (\r
+  IN PE_COFF_LOADER_IMAGE_CONTEXT          *ImageContext,\r
+  IN EFI_PHYSICAL_ADDRESS                  *TopOfMemory\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecImageRead (\r
+  IN     VOID    *FileHandle,\r
+  IN     UINTN   FileOffset,\r
+  IN OUT UINTN   *ReadSize,\r
+  OUT    VOID    *Buffer\r
+  );\r
+\r
+CHAR16                            *\r
+AsciiToUnicode (\r
+  IN  CHAR8   *Ascii,\r
+  IN  UINTN   *StrLen OPTIONAL\r
+  );\r
+\r
+UINTN\r
+CountSeperatorsInString (\r
+  IN  const CHAR16   *String,\r
+  IN  CHAR16   Seperator\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SecTemporaryRamSupport (\r
+  IN CONST EFI_PEI_SERVICES   **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,\r
+  IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,\r
+  IN UINTN                    CopySize\r
+  );\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+GasketSecTemporaryRamSupport (\r
+  IN CONST EFI_PEI_SERVICES   **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,\r
+  IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,\r
+  IN UINTN                    CopySize\r
+  );\r
+\r
+\r
+RETURN_STATUS\r
+EFIAPI\r
+SecPeCoffGetEntryPoint (\r
+  IN     VOID  *Pe32Data,\r
+  IN OUT VOID  **EntryPoint\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+SecPeCoffRelocateImageExtraAction (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+SecPeCoffLoaderUnloadImageExtraAction (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  );\r
+\r
+\r
+VOID\r
+PeiSwitchStacks (\r
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
+  IN      VOID                      *Context1,  OPTIONAL\r
+  IN      VOID                      *Context2,  OPTIONAL\r
+  IN      VOID                      *NewStack\r
+  );\r
+\r
+VOID\r
+SecInitThunkProtocol (\r
+  VOID\r
+  );\r
\r
+  \r
+EFI_PHYSICAL_ADDRESS *\r
+MapMemory (\r
+  INTN fd,\r
+  UINT64 length,\r
+  INTN   prot,\r
+  INTN   flags);\r
+\r
+EFI_STATUS\r
+MapFile (\r
+  IN  CHAR8                     *FileName,\r
+  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,\r
+  OUT UINT64                    *Length\r
+  );\r
+\r
+EFI_STATUS\r
+MapFd0 (\r
+  IN  CHAR8                     *FileName,\r
+  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,\r
+  OUT UINT64                    *Length\r
+  );\r
+\r
+BOOLEAN\r
+EfiSystemMemoryRange (\r
+  IN  VOID *MemoryAddress\r
+  );\r
+\r
+\r
+VOID SecSleep (UINT64 Nanoseconds);\r
+VOID SecEnableInterrupt (VOID);\r
+VOID SecDisableInterrupt (VOID);\r
+BOOLEAN SecInterruptEanbled (VOID);\r
+\r
+\r
+extern EMU_THUNK_PROTOCOL    gEmuThunkProtocol;\r
+extern EMU_IO_THUNK_PROTOCOL gX11ThunkIo;\r
+extern EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo;\r
+extern EMU_IO_THUNK_PROTOCOL gPthreadThunkIo;\r
+extern EMU_IO_THUNK_PROTOCOL gBlockIoThunkIo;\r
+extern EMU_IO_THUNK_PROTOCOL gSnpThunkIo;\r
+\r
+#endif\r
diff --git a/EmulatorPkg/Unix/Host/SecMain.inf b/EmulatorPkg/Unix/Host/SecMain.inf
new file mode 100644 (file)
index 0000000..9bda6f8
--- /dev/null
@@ -0,0 +1,140 @@
+## @file\r
+# Entry Point of Emu Emulator\r
+#\r
+# Main executable file of Unix Emulator that loads PEI core after initialization finished.\r
+# Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = SecMain\r
+  FILE_GUID                      = 8863C0AD-7724-C84B-88E5-A33B116D1485\r
+  MODULE_TYPE                    = USER_DEFINED\r
+  VERSION_STRING                 = 1.0\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  SecMain.c\r
+  EmuThunk.c\r
+  X11GraphicsWindow.c\r
+  Pthreads.c\r
+  PosixFileSystem.c\r
+  BlockIo.c\r
+  LinuxPacketFilter.c\r
+  BerkeleyPacketFilter.c\r
+  MemoryAllocationLib.c\r
+  \r
+[Sources.X64]\r
+  X64/Gasket.S        # convert between Emu x86_64 ABI and EFI X64 ABI\r
+  X64/SwitchStack.S\r
+\r
+[Sources.IA32]\r
+  Ia32/Gasket.S       # enforce 16-byte stack alignment for Mac OS X\r
+  Ia32/SwitchStack.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  EmulatorPkg/EmulatorPkg.dec\r
+\r
+[LibraryClasses]\r
+  DebugLib\r
+  PcdLib\r
+  PrintLib\r
+  BaseMemoryLib\r
+  BaseLib\r
+  PeCoffLib\r
+  ThunkPpiList\r
+  ThunkProtocolList\r
+  PpiListLib\r
+  PeiServicesLib\r
+  PeCoffGetEntryPointLib\r
+\r
+[Ppis]\r
+  gEfiPeiStatusCodePpiGuid                      # PPI ALWAYS_PRODUCED\r
+  gEmuThunkPpiGuid\r
+\r
+[Protocols]\r
+  gEmuIoThunkProtocolGuid\r
+  gEmuIoThunkProtocolGuid\r
+  gEmuGraphicsWindowProtocolGuid\r
+  gEmuThreadThunkProtocolGuid\r
+  gEmuBlockIoProtocolGuid\r
+  gEmuSnpProtocolGuid\r
+  gEfiSimpleFileSystemProtocolGuid\r
+\r
+[Guids]\r
+  gEfiFileSystemVolumeLabelInfoIdGuid           # SOMETIMES_CONSUMED\r
+  gEfiFileInfoGuid                              # SOMETIMES_CONSUMED\r
+  gEfiFileSystemInfoGuid                        # SOMETIMES_CONSUMED\r
+\r
+[Pcd]\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuBootMode\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFirmwareVolume\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuMemorySize\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFdBaseAddress\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFirmwareFdSize\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFirmwareBlockSize\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuApCount\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuVirtualDisk\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuGop|L"GOP Window"\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFileSystem\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuSerialPort\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuNetworkInterface\r
+  gEmulatorPkgTokenSpaceGuid.PcdNetworkPacketFilterSize\r
+\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashFvRecoveryBase\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashFvRecoverySize\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogBase\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogSize\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwWorkingBase\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
+  gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage\r
+\r
+\r
+[BuildOptions]\r
+   GCC:*_*_IA32_DLINK_FLAGS == -o $(BIN_DIR)/SecMain -m elf_i386 -dynamic-linker /lib$(LIB_ARCH_SFX)/ld-linux.so.2 /usr/lib$(LIB_ARCH_SFX)/crt1.o /usr/lib$(LIB_ARCH_SFX)/crti.o -L/usr/X11R6/lib -lXext -lX11 /usr/lib$(LIB_ARCH_SFX)/crtn.o\r
+   GCC:*_*_*_DLINK2_FLAGS == -lpthread -lc\r
+   GCC:*_*_IA32_CC_FLAGS == -m32 -g -fshort-wchar -fno-strict-aliasing -Wall -malign-double -idirafter/usr/include -c -include $(DEST_DIR_DEBUG)/AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings\r
+   GCC:*_*_IA32_PP_FLAGS == -m32 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h\r
+   GCC:*_*_IA32_ASM_FLAGS == -m32 -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h\r
+\r
+   GCC:*_*_X64_DLINK_FLAGS == -o $(BIN_DIR)/SecMain -m elf_x86_64 -dynamic-linker /lib$(LIB_ARCH_SFX)/ld-linux-x86-64.so.2 /usr/lib$(LIB_ARCH_SFX)/crt1.o /usr/lib$(LIB_ARCH_SFX)/crti.o -L/usr/X11R6/lib -lXext -lX11 /usr/lib$(LIB_ARCH_SFX)/crtn.o\r
+   GCC:*_*_X64_CC_FLAGS == -m64 -g -fshort-wchar -fno-strict-aliasing -Wall -malign-double -idirafter/usr/include -c -include $(DEST_DIR_DEBUG)/AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings\r
+   GCC:*_GCC44_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))"\r
+   GCC:*_GCC45_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))"\r
+   GCC:*_*_X64_PP_FLAGS == -m64 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h\r
+   GCC:*_*_X64_ASM_FLAGS == -m64 -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h\r
+\r
+#\r
+# Need to do this link via gcc and not ld as the pathing to libraries changes from OS version to OS version\r
+#\r
+   XCODE:*_*_IA32_DLINK_PATH == gcc\r
+   XCODE:*_*_IA32_CC_FLAGS == -arch i386 -O0 -g -include $(DEST_DIR_DEBUG)/AutoGen.h -c -fshort-wchar -fno-strict-aliasing\r
+   XCODE:*_*_IA32_DLINK_FLAGS == -arch i386 -o $(BIN_DIR)/SecMain -L/usr/X11R6/lib -lXext -lX11 -framework Carbon\r
+   XCODE:*_*_IA32_ASM_FLAGS == -arch i386 -g\r
+\r
+   XCODE:*_*_X64_DLINK_PATH == gcc\r
+   XCODE:*_*_X64_DLINK_FLAGS == -o $(BIN_DIR)/SecMain -L/usr/X11R6/lib -lXext -lX11 -framework Carbon\r
+   XCODE:*_*_X64_ASM_FLAGS == -g\r
+\r
diff --git a/EmulatorPkg/Unix/Host/X11GraphicsWindow.c b/EmulatorPkg/Unix/Host/X11GraphicsWindow.c
new file mode 100644 (file)
index 0000000..ddcf1e7
--- /dev/null
@@ -0,0 +1,1028 @@
+/*++ @file
+
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
+
+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 "SecMain.h"
+
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <X11/extensions/XShm.h>
+#include <X11/keysym.h>
+#include <X11/cursorfont.h>
+
+#define KEYSYM_LOWER  0
+#define KEYSYM_UPPER  1
+
+
+struct uga_drv_shift_mask {
+  unsigned char shift;
+  unsigned char size;
+  unsigned char csize;
+};
+
+#define NBR_KEYS 32
+typedef struct {
+  EMU_GRAPHICS_WINDOW_PROTOCOL GraphicsIo;
+
+  Display     *display;
+  int         screen;      // values for window_size in main 
+  Window      win;
+  GC          gc;
+  Visual      *visual;
+
+  int           depth;
+  unsigned int  width;
+  unsigned int  height;
+  unsigned int  line_bytes;
+  unsigned int  pixel_shift;
+  unsigned char *image_data;
+
+  struct uga_drv_shift_mask r, g, b;
+
+  int             use_shm;
+  XShmSegmentInfo xshm_info;
+  XImage          *image;
+  char            *Title;
+
+  unsigned int key_rd;
+  unsigned int key_wr;
+  unsigned int key_count;
+  EFI_KEY_DATA keys[NBR_KEYS];
+
+  EFI_KEY_STATE KeyState;
+  
+  EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK    MakeRegisterdKeyCallback;
+  EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK    BreakRegisterdKeyCallback;
+  VOID                                                *RegisterdKeyCallbackContext;
+  
+  int                        previous_x;
+  int                        previous_y;
+  EFI_SIMPLE_POINTER_STATE   pointer_state;
+  int                        pointer_state_changed;
+} GRAPHICS_IO_PRIVATE;
+
+void
+HandleEvents(
+  IN GRAPHICS_IO_PRIVATE *Drv
+  );
+
+void
+fill_shift_mask (
+  IN  struct uga_drv_shift_mask *sm, 
+  IN  unsigned long             mask
+  )
+{
+  sm->shift = 0;
+  sm->size = 0;
+  while ((mask & 1) == 0) {
+    mask >>= 1;
+    sm->shift++;
+  }
+  while (mask & 1) {
+    sm->size++;
+    mask >>= 1;
+  }
+  sm->csize = 8 - sm->size;
+}
+
+int
+TryCreateShmImage (
+  IN  GRAPHICS_IO_PRIVATE *Drv
+  )
+{
+  Drv->image = XShmCreateImage (
+                 Drv->display, Drv->visual,
+                 Drv->depth, ZPixmap, NULL, &Drv->xshm_info,
+                 Drv->width, Drv->height
+                 );
+  if (Drv->image == NULL) {
+    return 0;
+  }
+
+  switch (Drv->image->bitmap_unit) {
+  case 32:
+    Drv->pixel_shift = 2;
+    break;
+  case 16:
+    Drv->pixel_shift = 1;
+    break;
+  case 8:
+    Drv->pixel_shift = 0;
+    break;
+  }
+
+  Drv->xshm_info.shmid = shmget (
+                          IPC_PRIVATE, Drv->image->bytes_per_line * Drv->image->height,
+                          IPC_CREAT | 0777
+                          );
+  if (Drv->xshm_info.shmid < 0) {
+    XDestroyImage(Drv->image);
+    return 0;
+  }
+      
+  Drv->image_data = shmat (Drv->xshm_info.shmid, NULL, 0);
+  if(!Drv->image_data) {
+    shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL);
+    XDestroyImage(Drv->image);
+    return 0;
+  }
+  
+#ifndef __APPLE__  
+  //
+  // This closes shared memory in real time on OS X. Only closes after folks quit using
+  // it on Linux. 
+  //
+  shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL);
+#endif
+
+  Drv->xshm_info.shmaddr = (char*)Drv->image_data;
+  Drv->image->data = (char*)Drv->image_data;
+
+  if (!XShmAttach (Drv->display, &Drv->xshm_info)) {
+    shmdt (Drv->image_data);
+    XDestroyImage(Drv->image);
+    return 0;
+  }
+  return 1;
+}
+
+
+EFI_STATUS
+X11Size (
+  IN  EMU_GRAPHICS_WINDOW_PROTOCOL  *GraphicsIo, 
+  IN  UINT32                        Width, 
+  IN  UINT32                        Height
+  )
+{
+  GRAPHICS_IO_PRIVATE *Drv;
+  XSizeHints          size_hints;
+
+  // Destroy current buffer if created. 
+  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
+  if (Drv->image != NULL) {
+    // Before destroy buffer, need to make sure the buffer available for access. 
+    XDestroyImage (Drv->image);
+
+    if (Drv->use_shm) {
+      shmdt (Drv->image_data);
+    }
+
+    Drv->image_data = NULL;
+    Drv->image = NULL;
+  }
+
+  Drv->width = Width;
+  Drv->height = Height;
+  XResizeWindow (Drv->display, Drv->win, Width, Height);
+
+  // Allocate image. 
+  if (XShmQueryExtension(Drv->display) && TryCreateShmImage(Drv)) {
+    Drv->use_shm = 1;
+  } else {
+    Drv->use_shm = 0;
+    if (Drv->depth > 16) {
+      Drv->pixel_shift = 2;
+    } else if (Drv->depth > 8) {
+      Drv->pixel_shift = 1;
+    } else {
+      Drv->pixel_shift = 0;
+    }
+      
+    Drv->image_data = malloc ((Drv->width * Drv->height) << Drv->pixel_shift);
+    Drv->image = XCreateImage (
+                    Drv->display, Drv->visual, Drv->depth,
+                    ZPixmap, 0, (char *)Drv->image_data,
+                    Drv->width, Drv->height,
+                    8 << Drv->pixel_shift, 0
+                    );
+  }
+  
+  Drv->line_bytes = Drv->image->bytes_per_line;
+
+  fill_shift_mask (&Drv->r, Drv->image->red_mask);
+  fill_shift_mask (&Drv->g, Drv->image->green_mask);
+  fill_shift_mask (&Drv->b, Drv->image->blue_mask);
+
+  // Set WM hints.  
+  size_hints.flags = PSize | PMinSize | PMaxSize;
+  size_hints.min_width = size_hints.max_width = size_hints.base_width = Width;
+  size_hints.min_height = size_hints.max_height = size_hints.base_height = Height;
+  XSetWMNormalHints (Drv->display, Drv->win, &size_hints);
+
+  XMapWindow (Drv->display, Drv->win);
+  HandleEvents (Drv);
+  return EFI_SUCCESS;
+}
+
+void
+handleKeyEvent (
+  IN  GRAPHICS_IO_PRIVATE *Drv, 
+  IN  XEvent              *ev, 
+  IN  BOOLEAN             Make
+  )
+{
+  KeySym        *KeySym;
+  EFI_KEY_DATA  KeyData;
+  int           KeySymArraySize;
+  if (Make) {
+    if (Drv->key_count == NBR_KEYS) {
+      return;
+    }
+  }
+
+  // keycode is a physical key on the keyboard
+  // KeySym is a mapping of a physical key
+  // KeyboardMapping is the array of KeySym for a given keycode. key, shifted key, option key, command key, ...
+  //
+  // Returns an array of KeySymArraySize of KeySym for the keycode. [0] is lower case, [1] is upper case,
+  // [2] and [3] are based on option and command modifiers. The problem we have is command V
+  // could be mapped to a crazy Unicode character so the old scheme of returning a string. 
+  //
+  KeySym = XGetKeyboardMapping (Drv->display, ev->xkey.keycode, 1, &KeySymArraySize);
+   
+  KeyData.Key.ScanCode = 0;
+  KeyData.Key.UnicodeChar = 0;
+  KeyData.KeyState.KeyShiftState = 0;
+
+  //
+  // Skipping EFI_SCROLL_LOCK_ACTIVE & EFI_NUM_LOCK_ACTIVE since they are not on Macs  
+  //
+  if ((ev->xkey.state & LockMask) == 0) {
+    Drv->KeyState.KeyToggleState &= ~EFI_CAPS_LOCK_ACTIVE;
+  } else {
+    if (Make) {
+      Drv->KeyState.KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;
+    }
+  }
+  
+  // Skipping EFI_MENU_KEY_PRESSED and EFI_SYS_REQ_PRESSED
+  
+  switch (*KeySym) {
+  case XK_Control_R:
+    if (Make) {
+      Drv->KeyState.KeyShiftState |=  EFI_RIGHT_CONTROL_PRESSED;
+    } else {
+      Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_CONTROL_PRESSED;
+    }
+   break;
+  case XK_Control_L:
+    if (Make) {    
+      Drv->KeyState.KeyShiftState |=  EFI_LEFT_CONTROL_PRESSED;
+    } else {
+      Drv->KeyState.KeyShiftState &= ~EFI_LEFT_CONTROL_PRESSED;
+    }
+    break;
+
+  case XK_Shift_R:
+    if (Make) {
+      Drv->KeyState.KeyShiftState |=  EFI_RIGHT_SHIFT_PRESSED;
+    } else {
+      Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_SHIFT_PRESSED;
+    }
+    break;
+  case XK_Shift_L:
+    if (Make) {
+      Drv->KeyState.KeyShiftState |=  EFI_LEFT_SHIFT_PRESSED;
+    } else {
+      Drv->KeyState.KeyShiftState &= ~EFI_LEFT_SHIFT_PRESSED;
+    }
+    break;
+  
+  case XK_Mode_switch:
+    if (Make) {
+      Drv->KeyState.KeyShiftState |=  EFI_LEFT_ALT_PRESSED;
+    } else {
+      Drv->KeyState.KeyShiftState &= ~EFI_LEFT_ALT_PRESSED;
+    }
+    break;
+
+  case XK_Meta_R:
+    if (Make) {
+      Drv->KeyState.KeyShiftState |=  EFI_RIGHT_LOGO_PRESSED;
+    } else {
+      Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_LOGO_PRESSED;
+    }
+    break;
+  case XK_Meta_L:
+    if (Make) {
+      Drv->KeyState.KeyShiftState |=  EFI_LEFT_LOGO_PRESSED;
+    } else {
+      Drv->KeyState.KeyShiftState &= ~EFI_LEFT_LOGO_PRESSED;
+    }
+    break;
+  
+  case XK_KP_Home:
+  case XK_Home:       KeyData.Key.ScanCode = SCAN_HOME;       break;
+  
+  case XK_KP_End:
+  case XK_End:        KeyData.Key.ScanCode = SCAN_END;        break;
+  
+  case XK_KP_Left: 
+  case XK_Left:       KeyData.Key.ScanCode = SCAN_LEFT;       break;
+  
+  case XK_KP_Right:
+  case XK_Right:      KeyData.Key.ScanCode = SCAN_RIGHT;      break;
+  
+  case XK_KP_Up:
+  case XK_Up:         KeyData.Key.ScanCode = SCAN_UP;         break;
+  
+  case XK_KP_Down:
+  case XK_Down:       KeyData.Key.ScanCode = SCAN_DOWN;       break;
+  
+  case XK_KP_Delete:
+  case XK_Delete:       KeyData.Key.ScanCode = SCAN_DELETE;     break;
+  
+  case XK_KP_Insert:  
+  case XK_Insert:     KeyData.Key.ScanCode = SCAN_INSERT;     break;
+  
+  case XK_KP_Page_Up:
+  case XK_Page_Up:    KeyData.Key.ScanCode = SCAN_PAGE_UP;    break;
+  
+  case XK_KP_Page_Down:
+  case XK_Page_Down:  KeyData.Key.ScanCode = SCAN_PAGE_DOWN;  break;
+  
+  case XK_Escape:     KeyData.Key.ScanCode = SCAN_ESC;        break;
+
+  case XK_Pause:      KeyData.Key.ScanCode = SCAN_PAUSE;      break;
+
+  case XK_KP_F1:
+  case XK_F1:   KeyData.Key.ScanCode = SCAN_F1;   break;
+  
+  case XK_KP_F2:
+  case XK_F2:   KeyData.Key.ScanCode = SCAN_F2;   break;
+
+  case XK_KP_F3:
+  case XK_F3:   KeyData.Key.ScanCode = SCAN_F3;   break;
+
+  case XK_KP_F4:
+  case XK_F4:   KeyData.Key.ScanCode = SCAN_F4;   break;
+
+  case XK_F5:   KeyData.Key.ScanCode = SCAN_F5;   break;
+  case XK_F6:   KeyData.Key.ScanCode = SCAN_F6;   break;
+  case XK_F7:   KeyData.Key.ScanCode = SCAN_F7;   break;
+  
+  // Don't map into X11 by default on a Mac
+  // System Preferences->Keyboard->Keyboard Shortcuts can be configured 
+  // to not use higher function keys as shortcuts and the will show up
+  // in X11. 
+  case XK_F8:   KeyData.Key.ScanCode = SCAN_F8;   break;
+  case XK_F9:   KeyData.Key.ScanCode = SCAN_F9;   break;
+  case XK_F10:  KeyData.Key.ScanCode = SCAN_F10;  break;
+  
+  case XK_F11:  KeyData.Key.ScanCode = SCAN_F11;  break;
+  case XK_F12:  KeyData.Key.ScanCode = SCAN_F12;  break;
+  
+  case XK_F13:  KeyData.Key.ScanCode = SCAN_F13;  break;
+  case XK_F14:  KeyData.Key.ScanCode = SCAN_F14;  break;
+  case XK_F15:  KeyData.Key.ScanCode = SCAN_F15;  break;
+  case XK_F16:  KeyData.Key.ScanCode = SCAN_F16;  break;
+  case XK_F17:  KeyData.Key.ScanCode = SCAN_F17;  break;
+  case XK_F18:  KeyData.Key.ScanCode = SCAN_F18;  break;
+  case XK_F19:  KeyData.Key.ScanCode = SCAN_F19;  break;
+  case XK_F20:  KeyData.Key.ScanCode = SCAN_F20;  break;
+  case XK_F21:  KeyData.Key.ScanCode = SCAN_F21;  break;
+  case XK_F22:  KeyData.Key.ScanCode = SCAN_F22;  break;
+  case XK_F23:  KeyData.Key.ScanCode = SCAN_F23;  break;
+  case XK_F24:  KeyData.Key.ScanCode = SCAN_F24;  break;
+
+  // No mapping in X11
+  //case XK_:   KeyData.Key.ScanCode = SCAN_MUTE;            break;             
+  //case XK_:   KeyData.Key.ScanCode = SCAN_VOLUME_UP;       break;            
+  //case XK_:   KeyData.Key.ScanCode = SCAN_VOLUME_DOWN;     break;       
+  //case XK_:   KeyData.Key.ScanCode = SCAN_BRIGHTNESS_UP;   break;      
+  //case XK_:   KeyData.Key.ScanCode = SCAN_BRIGHTNESS_DOWN; break;    
+  //case XK_:   KeyData.Key.ScanCode = SCAN_SUSPEND;         break; 
+  //case XK_:   KeyData.Key.ScanCode = SCAN_HIBERNATE;       break; 
+  //case XK_:   KeyData.Key.ScanCode = SCAN_TOGGLE_DISPLAY;  break;       
+  //case XK_:   KeyData.Key.ScanCode = SCAN_RECOVERY;        break;      
+  //case XK_:   KeyData.Key.ScanCode = SCAN_EJECT;           break;     
+
+  case XK_BackSpace:  KeyData.Key.UnicodeChar = 0x0008; break;
+
+  case XK_KP_Tab:
+  case XK_Tab:        KeyData.Key.UnicodeChar = 0x0009; break;
+
+  case XK_Linefeed:   KeyData.Key.UnicodeChar = 0x000a; break;
+  
+  case XK_KP_Enter:
+  case XK_Return:     KeyData.Key.UnicodeChar = 0x000d; break;
+
+  case XK_KP_Equal      : KeyData.Key.UnicodeChar = L'='; break;                     
+  case XK_KP_Multiply   : KeyData.Key.UnicodeChar = L'*'; break;                  
+  case XK_KP_Add        : KeyData.Key.UnicodeChar = L'+'; break;                       
+  case XK_KP_Separator  : KeyData.Key.UnicodeChar = L'~'; break;                  
+  case XK_KP_Subtract   : KeyData.Key.UnicodeChar = L'-'; break;                  
+  case XK_KP_Decimal    : KeyData.Key.UnicodeChar = L'.'; break;                   
+  case XK_KP_Divide     : KeyData.Key.UnicodeChar = L'/'; break;                    
+
+  case XK_KP_0    : KeyData.Key.UnicodeChar = L'0'; break;                         
+  case XK_KP_1    : KeyData.Key.UnicodeChar = L'1'; break;                         
+  case XK_KP_2    : KeyData.Key.UnicodeChar = L'2'; break;                         
+  case XK_KP_3    : KeyData.Key.UnicodeChar = L'3'; break;                         
+  case XK_KP_4    : KeyData.Key.UnicodeChar = L'4'; break;                        
+  case XK_KP_5    : KeyData.Key.UnicodeChar = L'5'; break;                         
+  case XK_KP_6    : KeyData.Key.UnicodeChar = L'6'; break;                         
+  case XK_KP_7    : KeyData.Key.UnicodeChar = L'7'; break;                         
+  case XK_KP_8    : KeyData.Key.UnicodeChar = L'8'; break;                        
+  case XK_KP_9    : KeyData.Key.UnicodeChar = L'9'; break;                         
+
+  default:
+    ;
+  }
+
+  // The global state is our state
+  KeyData.KeyState.KeyShiftState = Drv->KeyState.KeyShiftState;
+  KeyData.KeyState.KeyToggleState = Drv->KeyState.KeyToggleState;
+
+  if (*KeySym < XK_BackSpace) {
+    if (((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED)) != 0) ||
+        ((Drv->KeyState.KeyToggleState & EFI_CAPS_LOCK_ACTIVE) != 0) ) {
+      
+      KeyData.Key.UnicodeChar = (CHAR16)KeySym[KEYSYM_UPPER];
+
+      // Per UEFI spec since we converted the Unicode clear the shift bits we pass up 
+      KeyData.KeyState.KeyShiftState &= ~(EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED);
+    } else {
+      KeyData.Key.UnicodeChar = (CHAR16)KeySym[KEYSYM_LOWER];
+    }
+  } else {
+    // XK_BackSpace is the start of XK_MISCELLANY. These are the XK_? keys we process in this file 
+    ; 
+  }
+  
+  if (Make) {
+    memcpy (&Drv->keys[Drv->key_wr], &KeyData, sizeof (EFI_KEY_DATA));
+    Drv->key_wr = (Drv->key_wr + 1) % NBR_KEYS;
+    Drv->key_count++; 
+    if (Drv->MakeRegisterdKeyCallback != NULL) {
+      ReverseGasketUint64Uint64 (Drv->MakeRegisterdKeyCallback ,Drv->RegisterdKeyCallbackContext, &KeyData);
+    }
+  } else {
+    if (Drv->BreakRegisterdKeyCallback != NULL) {
+      ReverseGasketUint64Uint64 (Drv->BreakRegisterdKeyCallback ,Drv->RegisterdKeyCallbackContext, &KeyData);
+    }
+  }
+}
+
+
+void
+handleMouseMoved(
+  IN  GRAPHICS_IO_PRIVATE   *Drv, 
+  IN  XEvent                *ev
+  )
+{
+  if (ev->xmotion.x != Drv->previous_x) {
+    Drv->pointer_state.RelativeMovementX += ( ev->xmotion.x - Drv->previous_x );
+    Drv->previous_x = ev->xmotion.x;
+    Drv->pointer_state_changed = 1;
+  }
+
+  if (ev->xmotion.y != Drv->previous_y) {
+    Drv->pointer_state.RelativeMovementY += ( ev->xmotion.y - Drv->previous_y );
+    Drv->previous_y = ev->xmotion.y;
+    Drv->pointer_state_changed = 1;
+  }
+
+  Drv->pointer_state.RelativeMovementZ = 0;
+}
+
+void
+handleMouseDown (
+  IN  GRAPHICS_IO_PRIVATE *Drv, 
+  IN  XEvent              *ev, 
+  IN  BOOLEAN             Pressed
+  )
+{
+  if (ev->xbutton.button == Button1) {
+    Drv->pointer_state_changed = (Drv->pointer_state.LeftButton != Pressed);
+    Drv->pointer_state.LeftButton = Pressed;
+  }
+  if ( ev->xbutton.button == Button2 ) {
+    Drv->pointer_state_changed = (Drv->pointer_state.RightButton != Pressed);
+    Drv->pointer_state.RightButton = Pressed;
+  }
+}
+
+void
+Redraw (
+  IN  GRAPHICS_IO_PRIVATE *Drv, 
+  IN  UINTN               X, 
+  IN  UINTN               Y, 
+  IN  UINTN               Width, 
+  IN  UINTN               Height
+  )
+{
+  if (Drv->use_shm) {
+    XShmPutImage (
+      Drv->display, Drv->win, Drv->gc, Drv->image, X, Y, X, Y, Width, Height, False
+      );
+  } else {
+    XPutImage (
+      Drv->display, Drv->win, Drv->gc, Drv->image, X, Y, X, Y, Width, Height
+      );
+  }
+  XFlush(Drv->display);
+}
+
+void
+HandleEvent(GRAPHICS_IO_PRIVATE *Drv, XEvent *ev)
+{
+  switch (ev->type) {
+  case Expose:
+    Redraw (Drv, ev->xexpose.x, ev->xexpose.y,
+      ev->xexpose.width, ev->xexpose.height);
+    break;
+  case GraphicsExpose:
+    Redraw (Drv, ev->xgraphicsexpose.x, ev->xgraphicsexpose.y,
+      ev->xgraphicsexpose.width, ev->xgraphicsexpose.height);
+    break;
+  case KeyPress:
+    handleKeyEvent (Drv, ev, TRUE);
+    break;
+  case KeyRelease:
+    handleKeyEvent (Drv, ev, FALSE);
+    break;
+  case MappingNotify:
+    XRefreshKeyboardMapping (&ev->xmapping);
+    break;
+  case MotionNotify:
+    handleMouseMoved (Drv, ev);
+    break;
+  case ButtonPress:
+    handleMouseDown (Drv, ev, TRUE);
+  break;
+  case ButtonRelease:
+    handleMouseDown (Drv, ev, FALSE);
+  break;
+#if 0
+  case DestroyNotify:
+    XCloseDisplay (Drv->display);
+    exit (1);
+    break;
+#endif
+  case NoExpose:
+  default:
+    break;
+  }
+}
+
+void
+HandleEvents (
+  IN  GRAPHICS_IO_PRIVATE *Drv
+  )
+{
+  XEvent ev;
+
+  while (XPending (Drv->display) != 0) {
+    XNextEvent (Drv->display, &ev);
+    HandleEvent (Drv, &ev);
+  }
+}
+
+unsigned long
+X11PixelToColor (
+  IN  GRAPHICS_IO_PRIVATE *Drv, 
+  IN  EFI_UGA_PIXEL       pixel
+  )
+{
+  return ((pixel.Red   >> Drv->r.csize) << Drv->r.shift)
+       | ((pixel.Green >> Drv->g.csize) << Drv->g.shift)
+       | ((pixel.Blue  >> Drv->b.csize) << Drv->b.shift);
+}
+
+EFI_UGA_PIXEL
+X11ColorToPixel (
+  IN  GRAPHICS_IO_PRIVATE *Drv, 
+  IN  unsigned long       val
+  )
+{
+  EFI_UGA_PIXEL Pixel;
+
+  memset (&Pixel, 0, sizeof (EFI_UGA_PIXEL));
+  
+  // Truncation not an issue since X11 and EFI are both using 8 bits per color
+  Pixel.Red =   (val >> Drv->r.shift) << Drv->r.csize;
+  Pixel.Green = (val >> Drv->g.shift) << Drv->g.csize;
+  Pixel.Blue =  (val >> Drv->b.shift) << Drv->b.csize;
+
+  return Pixel;
+}
+
+
+EFI_STATUS
+X11CheckKey (
+  IN  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
+  )
+{
+  GRAPHICS_IO_PRIVATE  *Drv;
+  
+  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
+  
+  HandleEvents (Drv);
+  
+  if (Drv->key_count != 0) {
+    return EFI_SUCCESS;
+  }
+  
+  return EFI_NOT_READY;
+}
+
+EFI_STATUS
+X11GetKey (
+  IN  EMU_GRAPHICS_WINDOW_PROTOCOL  *GraphicsIo, 
+  IN  EFI_KEY_DATA                  *KeyData
+  )
+{
+  EFI_STATUS          EfiStatus;
+  GRAPHICS_IO_PRIVATE *Drv;
+  
+  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
+
+  EfiStatus = X11CheckKey (GraphicsIo);
+  if (EFI_ERROR (EfiStatus)) {
+    return EfiStatus;
+  }
+  
+  CopyMem (KeyData, &Drv->keys[Drv->key_rd], sizeof (EFI_KEY_DATA));
+  Drv->key_rd = (Drv->key_rd + 1) % NBR_KEYS;
+  Drv->key_count--;
+  
+  return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+X11KeySetState (
+  IN EMU_GRAPHICS_WINDOW_PROTOCOL   *GraphicsIo, 
+  IN EFI_KEY_TOGGLE_STATE           *KeyToggleState
+  )
+{
+  GRAPHICS_IO_PRIVATE  *Drv;
+  
+  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;  
+  
+  if (*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) {
+    if ((Drv->KeyState.KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == 0) {
+      //
+      // We could create an XKeyEvent and send a XK_Caps_Lock to
+      // the UGA/GOP Window
+      //
+    }
+  }
+    
+  Drv->KeyState.KeyToggleState = *KeyToggleState;
+  return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+X11RegisterKeyNotify (
+  IN EMU_GRAPHICS_WINDOW_PROTOCOL                        *GraphicsIo, 
+  IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK    MakeCallBack,
+  IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK    BreakCallBack,
+  IN VOID                                                *Context
+  )
+{
+  GRAPHICS_IO_PRIVATE  *Drv;
+
+  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;  
+
+  Drv->MakeRegisterdKeyCallback    = MakeCallBack;
+  Drv->BreakRegisterdKeyCallback   = BreakCallBack;
+  Drv->RegisterdKeyCallbackContext = Context;
+
+  return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+X11Blt (
+  IN EMU_GRAPHICS_WINDOW_PROTOCOL             *GraphicsIo,
+  IN  EFI_UGA_PIXEL                           *BltBuffer OPTIONAL,
+  IN  EFI_UGA_BLT_OPERATION                   BltOperation,
+  IN  EMU_GRAPHICS_WINDOWS__BLT_ARGS          *Args
+  )
+{
+  GRAPHICS_IO_PRIVATE *Private;
+  UINTN             DstY;
+  UINTN             SrcY;
+  UINTN             DstX;
+  UINTN             SrcX;
+  UINTN             Index;
+  EFI_UGA_PIXEL     *Blt;
+  UINT8             *Dst;
+  UINT8             *Src;
+  UINTN             Nbr;
+  unsigned long     Color;
+  XEvent            ev;
+
+  Private = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
+
+
+  //
+  //  Check bounds
+  //
+  if (BltOperation == EfiUgaVideoToBltBuffer
+      || BltOperation == EfiUgaVideoToVideo) {
+    //
+    // Source is Video.
+    //
+    if (Args->SourceY + Args->Height > Private->height) {
+      return EFI_INVALID_PARAMETER;
+    }
+
+    if (Args->SourceX + Args->Width > Private->width) {
+      return EFI_INVALID_PARAMETER;
+    }
+  }
+
+  if (BltOperation == EfiUgaBltBufferToVideo
+      || BltOperation == EfiUgaVideoToVideo
+      || BltOperation == EfiUgaVideoFill) {
+    //
+    // Destination is Video
+    //
+    if (Args->DestinationY + Args->Height > Private->height) {
+      return EFI_INVALID_PARAMETER;
+    }
+
+    if (Args->DestinationX + Args->Width > Private->width) {
+      return EFI_INVALID_PARAMETER;
+    }
+  }
+
+  switch (BltOperation) {
+  case EfiUgaVideoToBltBuffer:
+    Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (Args->DestinationY * Args->Delta) + Args->DestinationX * sizeof (EFI_UGA_PIXEL));
+    Args->Delta -= Args->Width * sizeof (EFI_UGA_PIXEL);
+    for (SrcY = Args->SourceY; SrcY < (Args->Height + Args->SourceY); SrcY++) {
+      for (SrcX = Args->SourceX; SrcX < (Args->Width + Args->SourceX); SrcX++) {
+        *Blt++ = X11ColorToPixel (Private, XGetPixel (Private->image, SrcX, SrcY));
+      }
+      Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Args->Delta);
+    }
+    break;
+  case EfiUgaBltBufferToVideo:
+    Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (Args->SourceY * Args->Delta) + Args->SourceX * sizeof (EFI_UGA_PIXEL));
+    Args->Delta -= Args->Width * sizeof (EFI_UGA_PIXEL);
+    for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) {
+      for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) {
+        XPutPixel(Private->image, DstX, DstY, X11PixelToColor(Private, *Blt));
+        Blt++;
+      }
+      Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Args->Delta);
+    }
+    break;
+  case EfiUgaVideoToVideo:
+    Dst = Private->image_data + (Args->DestinationX << Private->pixel_shift)
+          + Args->DestinationY * Private->line_bytes;
+    Src = Private->image_data + (Args->SourceX << Private->pixel_shift)
+          + Args->SourceY * Private->line_bytes;
+    Nbr = Args->Width << Private->pixel_shift;
+    if (Args->DestinationY < Args->SourceY) {
+      for (Index = 0; Index < Args->Height; Index++) {
+        memcpy (Dst, Src, Nbr);
+        Dst += Private->line_bytes;
+        Src += Private->line_bytes;
+      }
+    } else {
+      Dst += (Args->Height - 1) * Private->line_bytes;
+      Src += (Args->Height - 1) * Private->line_bytes;
+      for (Index = 0; Index < Args->Height; Index++) {
+      //
+      // Source and Destination Y may be equal, therefore Dst and Src may
+      // overlap.
+      //
+      memmove (Dst, Src, Nbr);
+      Dst -= Private->line_bytes;
+      Src -= Private->line_bytes;
+      }
+    }
+    break;
+  case EfiUgaVideoFill:
+    Color = X11PixelToColor(Private, *BltBuffer);
+    for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) {
+      for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) {
+        XPutPixel(Private->image, DstX, DstY, Color);
+      }
+    }
+    break;
+  default:
+    return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  //  Refresh screen.
+  //
+  switch (BltOperation) {
+  case EfiUgaVideoToVideo:
+    XCopyArea(
+      Private->display, Private->win, Private->win, Private->gc,
+      Args->SourceX, Args->SourceY, Args->Width, Args->Height, 
+      Args->DestinationX, Args->DestinationY
+      );
+      
+    while (1) {
+      XNextEvent (Private->display, &ev);
+      HandleEvent (Private, &ev);
+      if (ev.type == NoExpose || ev.type == GraphicsExpose) {
+        break;
+      }
+    }
+    break;
+  case EfiUgaVideoFill:
+    Color = X11PixelToColor (Private, *BltBuffer);
+    XSetForeground (Private->display, Private->gc, Color);
+    XFillRectangle (
+      Private->display, Private->win, Private->gc,
+      Args->DestinationX, Args->DestinationY, Args->Width, Args->Height
+      );
+    XFlush (Private->display);
+    break;
+  case EfiUgaBltBufferToVideo:
+    Redraw (Private, Args->DestinationX, Args->DestinationY, Args->Width, Args->Height);
+    break;
+  default:
+    break;
+  }
+  return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+X11CheckPointer (
+  IN  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
+  )
+{
+  GRAPHICS_IO_PRIVATE  *Drv;
+
+  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
+
+  HandleEvents (Drv);
+  if (Drv->pointer_state_changed != 0) {
+    return EFI_SUCCESS;
+  }
+  
+  return EFI_NOT_READY;
+}
+
+
+EFI_STATUS
+X11GetPointerState (
+  IN  EMU_GRAPHICS_WINDOW_PROTOCOL  *GraphicsIo, 
+  IN  EFI_SIMPLE_POINTER_STATE      *State
+  )
+{
+  EFI_STATUS          EfiStatus;
+  GRAPHICS_IO_PRIVATE *Drv;
+
+  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
+
+  EfiStatus = X11CheckPointer (GraphicsIo);
+  if (EfiStatus != EFI_SUCCESS) {
+    return EfiStatus;
+  }
+  
+  memcpy (State, &Drv->pointer_state, sizeof (EFI_SIMPLE_POINTER_STATE));
+
+  Drv->pointer_state.RelativeMovementX = 0;
+  Drv->pointer_state.RelativeMovementY = 0;
+  Drv->pointer_state.RelativeMovementZ = 0;
+  Drv->pointer_state_changed = 0;
+  return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+X11GraphicsWindowOpen (
+  IN  EMU_IO_THUNK_PROTOCOL   *This
+  )
+{
+  GRAPHICS_IO_PRIVATE *Drv;
+  unsigned int        border_width = 0;
+  char                *display_name = NULL;
+
+  Drv = (GRAPHICS_IO_PRIVATE *)calloc (1, sizeof (GRAPHICS_IO_PRIVATE));
+  if (Drv == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  Drv->GraphicsIo.Size                = GasketX11Size;
+  Drv->GraphicsIo.CheckKey            = GasketX11CheckKey;
+  Drv->GraphicsIo.GetKey              = GasketX11GetKey;
+  Drv->GraphicsIo.KeySetState         = GasketX11KeySetState;
+  Drv->GraphicsIo.RegisterKeyNotify   = GasketX11RegisterKeyNotify;
+  Drv->GraphicsIo.Blt                 = GasketX11Blt;
+  Drv->GraphicsIo.CheckPointer        = GasketX11CheckPointer;
+  Drv->GraphicsIo.GetPointerState     = GasketX11GetPointerState;
+  
+
+  Drv->key_count = 0;
+  Drv->key_rd = 0;
+  Drv->key_wr = 0;
+  Drv->KeyState.KeyShiftState      = EFI_SHIFT_STATE_VALID;
+  Drv->KeyState.KeyToggleState     = EFI_TOGGLE_STATE_VALID;
+  Drv->MakeRegisterdKeyCallback    = NULL;
+  Drv->BreakRegisterdKeyCallback   = NULL;
+  Drv->RegisterdKeyCallbackContext = NULL;
+  
+  
+  Drv->display = XOpenDisplay (display_name);
+  if (Drv->display == NULL) {
+    fprintf (stderr, "uga: cannot connect to X server %s\n", XDisplayName (display_name));
+    free (Drv);
+    return EFI_DEVICE_ERROR;
+  }
+  Drv->screen = DefaultScreen (Drv->display);
+  Drv->visual = DefaultVisual (Drv->display, Drv->screen);
+  Drv->win = XCreateSimpleWindow (
+                Drv->display, RootWindow (Drv->display, Drv->screen),
+                0, 0, 4, 4, border_width,
+                WhitePixel (Drv->display, Drv->screen),
+                BlackPixel (Drv->display, Drv->screen)
+                );
+
+  Drv->depth = DefaultDepth (Drv->display, Drv->screen);
+  XDefineCursor (Drv->display, Drv->win, XCreateFontCursor (Drv->display, XC_pirate)); 
+
+  Drv->Title = malloc (StrSize (This->ConfigString));  
+  UnicodeStrToAsciiStr (This->ConfigString, Drv->Title);
+  XStoreName (Drv->display, Drv->win, Drv->Title);
+
+//  XAutoRepeatOff (Drv->display);
+  XSelectInput (
+    Drv->display, Drv->win,
+    ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask 
+    );
+  Drv->gc = DefaultGC (Drv->display, Drv->screen);
+
+  This->Private   = (VOID *)Drv;
+  This->Interface = (VOID *)Drv;
+  return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+X11GraphicsWindowClose (
+  IN  EMU_IO_THUNK_PROTOCOL   *This
+  )
+{
+  GRAPHICS_IO_PRIVATE *Drv;
+
+  Drv = (GRAPHICS_IO_PRIVATE *)This->Private;
+
+  if (Drv == NULL) {
+    return EFI_SUCCESS;
+  }
+  
+  if (Drv->image != NULL) {
+    XDestroyImage(Drv->image);
+
+    if (Drv->use_shm) {
+      shmdt (Drv->image_data);
+    }
+
+    Drv->image_data = NULL;
+    Drv->image = NULL;
+  }
+  XDestroyWindow (Drv->display, Drv->win);
+  XCloseDisplay (Drv->display);
+  
+#ifdef __APPLE__
+  // Free up the shared memory
+  shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL);
+#endif
+  
+  free (Drv);
+  return EFI_SUCCESS;
+}
+
+
+EMU_IO_THUNK_PROTOCOL gX11ThunkIo = {
+  &gEmuGraphicsWindowProtocolGuid,
+  NULL,
+  NULL,
+  0,
+  GasketX11GraphicsWindowOpen,
+  GasketX11GraphicsWindowClose,
+  NULL
+};
+
+
diff --git a/EmulatorPkg/Unix/Host/X64/Gasket.S b/EmulatorPkg/Unix/Host/X64/Gasket.S
new file mode 100644 (file)
index 0000000..7ea49bb
--- /dev/null
@@ -0,0 +1,1631 @@
+#------------------------------------------------------------------------------
+#
+# Manage differenced between UNIX ABI and EFI/Windows ABI
+#
+# EFI  Arg passing: RCX, RDX, R8,  R9
+#                   Callee allocates 32 bytes on stack to spill registers
+# UNIX Arg passing: RDI, RSI, RDX, RCX, R8, R9
+# RSI, RDI calle-save on EFI, scatch on UNIX callign
+#
+# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
+# 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.
+#
+#------------------------------------------------------------------------------
+
+//
+// Gaskets are EFI ABI to UNIX ABI calls
+// EFI ABI code will sub 40 (0x28) from %rsp before calling a function
+//  This is the 32 (0x20) byte to spill registers and 8 bytes to align stack on 16 byte boundry.
+//
+  .text
+
+// 32 byte shadow to spill rcx-r9, 8 bytes to align stack on 16 byte boundry
+// Any call with 0 - 4 arguments allocates 40 bytes on the stack.
+// For more than 4 args you always have to increase in quanta of 16 so 5 or 6 args is 56, 
+// 7 or 8 args is 72, and 9 or 10 args is 88
+
+
+
+  .text
+  
+//
+// EMU_THUNK_PROTOCOL gaskets (EFIAPI to UNIX ABI)
+//
+
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSecWriteStdErr)
+ASM_PFX(GasketSecWriteStdErr):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call  ASM_PFX(SecWriteStdErr)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecConfigStdIn)
+ASM_PFX(GasketSecConfigStdIn):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  call  ASM_PFX(SecConfigStdIn)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecWriteStdOut)
+ASM_PFX(GasketSecWriteStdOut):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call  ASM_PFX(SecWriteStdOut)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecReadStdIn)
+ASM_PFX(GasketSecReadStdIn):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call  ASM_PFX(SecReadStdIn)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecPollStdIn)
+ASM_PFX(GasketSecPollStdIn):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  call  ASM_PFX(SecPollStdIn)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecMalloc)
+ASM_PFX(GasketSecMalloc):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call  ASM_PFX(SecMalloc)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecValloc)
+ASM_PFX(GasketSecValloc):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call  ASM_PFX(SecValloc)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecFree)
+ASM_PFX(GasketSecFree):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call  ASM_PFX(SecFree)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecSetTimer)
+ASM_PFX(GasketSecSetTimer):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call  ASM_PFX(SecSetTimer)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecEnableInterrupt)
+ASM_PFX(GasketSecEnableInterrupt):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  call    ASM_PFX(SecEnableInterrupt)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecDisableInterrupt)
+ASM_PFX(GasketSecDisableInterrupt):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  call    ASM_PFX(SecDisableInterrupt)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketQueryPerformanceFrequency)
+ASM_PFX(GasketQueryPerformanceFrequency):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  call    ASM_PFX(QueryPerformanceFrequency)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketQueryPerformanceCounter)
+ASM_PFX(GasketQueryPerformanceCounter):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  call    ASM_PFX(QueryPerformanceCounter)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecSleep)
+ASM_PFX(GasketSecSleep):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call  ASM_PFX(SecSleep)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+  
+  
+ASM_GLOBAL ASM_PFX(GasketSecCpuSleep)
+ASM_PFX(GasketSecCpuSleep):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  call  ASM_PFX(SecCpuSleep)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+  
+  
+ASM_GLOBAL ASM_PFX(GasketSecExit)
+ASM_PFX(GasketSecExit):
+  pushq   %rbp                 // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  movq    %rcx, %rdi           // Swizzle args 
+  call    ASM_PFX(SecExit)     // Less to do as we will never return to EFI ABI world
+LDEAD_LOOP:
+  jmp  LDEAD_LOOP              // _exit should never return
+
+  
+ASM_GLOBAL ASM_PFX(GasketSecGetTime)
+ASM_PFX(GasketSecGetTime):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call  ASM_PFX(SecGetTime)
+
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecSetTime)
+ASM_PFX(GasketSecSetTime):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call  ASM_PFX(SecSetTime)
+
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecGetNextProtocol)
+ASM_PFX(GasketSecGetNextProtocol):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+
+  call    ASM_PFX(SecGetNextProtocol)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+// PPIs produced by SEC
+
+ASM_GLOBAL ASM_PFX(GasketSecPeCoffGetEntryPoint)
+ASM_PFX(GasketSecPeCoffGetEntryPoint):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call    ASM_PFX(SecPeCoffGetEntryPoint)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+ASM_GLOBAL ASM_PFX(GasketSecPeCoffRelocateImageExtraAction)
+ASM_PFX(GasketSecPeCoffRelocateImageExtraAction):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(SecPeCoffRelocateImageExtraAction)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+ASM_GLOBAL ASM_PFX(GasketSecPeCoffUnloadImageExtraAction)
+ASM_PFX(GasketSecPeCoffUnloadImageExtraAction):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(SecPeCoffUnloadImageExtraAction)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecEmuThunkAddress)
+ASM_PFX(GasketSecEmuThunkAddress):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  call    ASM_PFX(SecEmuThunkAddress)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+//
+// Gasket functions for EFI_EMU_UGA_IO_PROTOCOL
+//
+
+ASM_GLOBAL ASM_PFX(GasketX11Size)
+ASM_PFX(GasketX11Size):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+
+  call    ASM_PFX(X11Size)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11CheckKey)
+ASM_PFX(GasketX11CheckKey):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(X11CheckKey)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketX11GetKey)
+ASM_PFX(GasketX11GetKey):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call    ASM_PFX(X11GetKey)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11KeySetState)
+ASM_PFX(GasketX11KeySetState):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call    ASM_PFX(X11KeySetState)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+  
+ASM_GLOBAL ASM_PFX(GasketX11RegisterKeyNotify)
+ASM_PFX(GasketX11RegisterKeyNotify):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+
+  call    ASM_PFX(X11RegisterKeyNotify)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+  
+ASM_GLOBAL ASM_PFX(GasketX11Blt)
+ASM_PFX(GasketX11Blt):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+
+  call    ASM_PFX(X11Blt)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11CheckPointer)
+ASM_PFX(GasketX11CheckPointer):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(X11CheckPointer)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11GetPointerState)
+ASM_PFX(GasketX11GetPointerState):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call    ASM_PFX(X11GetPointerState)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowOpen)
+ASM_PFX(GasketX11GraphicsWindowOpen):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(X11GraphicsWindowOpen)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowClose)
+ASM_PFX(GasketX11GraphicsWindowClose):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %r9,  %rcx
+
+  call    ASM_PFX(X11GraphicsWindowClose)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+// Pthreads
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexLock)
+ASM_PFX(GasketPthreadMutexLock):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(PthreadMutexLock)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexUnLock)
+ASM_PFX(GasketPthreadMutexUnLock):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(PthreadMutexUnLock)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexTryLock)
+ASM_PFX(GasketPthreadMutexTryLock):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(PthreadMutexTryLock)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexInit)
+ASM_PFX(GasketPthreadMutexInit):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+
+  call    ASM_PFX(PthreadMutexInit)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexDestroy)
+ASM_PFX(GasketPthreadMutexDestroy):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(PthreadMutexDestroy)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadCreate)
+ASM_PFX(GasketPthreadCreate):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+
+  call    ASM_PFX(PthreadCreate)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+                          
+ASM_GLOBAL ASM_PFX(GasketPthreadExit)
+ASM_PFX(GasketPthreadExit):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(PthreadExit)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+                            
+ASM_GLOBAL ASM_PFX(GasketPthreadSelf)
+ASM_PFX(GasketPthreadSelf):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+
+  call    ASM_PFX(PthreadSelf)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadOpen)
+ASM_PFX(GasketPthreadOpen):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(PthreadOpen)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadClose)
+ASM_PFX(GasketPthreadClose):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(PthreadClose)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+
+
+//
+// UNIX ABI to EFI ABI call
+//
+// UINTN
+// ReverseGasketUint64 (
+//   void *Api,
+//   UINTN Arg1
+//   );
+ASM_GLOBAL ASM_PFX(ReverseGasketUint64)
+ASM_PFX(ReverseGasketUint64):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  movq    %rdi, %rax    // Swizzle args 
+  movq    %rsi, %rcx     
+
+  subq  $32, %rsp        // 32-byte shadow space
+  call  *%rax
+  addq  $32, %rsp
+
+  popq   %rbp          
+  ret
+
+//
+// UNIX ABI to EFI ABI call
+//
+// UINTN
+// ReverseGasketUint64Uint64 (
+//   void *Api,
+//   UINTN Arg1
+//   UINTN Arg2
+//   );
+ASM_GLOBAL ASM_PFX(ReverseGasketUint64Uint64)
+ASM_PFX(ReverseGasketUint64Uint64):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  movq    %rdi, %rax    // Swizzle args 
+  movq    %rsi, %rcx     
+
+  subq  $32, %rsp        // 32-byte shadow space
+  call  *%rax
+  addq  $32, %rsp
+
+  popq   %rbp          
+  ret
+  
+
+ASM_GLOBAL ASM_PFX(GasketSecUnixPeiAutoScan)
+ASM_PFX(GasketSecUnixPeiAutoScan):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+
+  call    ASM_PFX(SecUnixPeiAutoScan)
+  
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecUnixFdAddress)
+ASM_PFX(GasketSecUnixFdAddress):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+
+  call    ASM_PFX(SecUnixFdAddress)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+// EmuIoThunk SimpleFileSystem
+
+ASM_GLOBAL ASM_PFX(GasketPosixOpenVolume)
+ASM_PFX(GasketPosixOpenVolume):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+
+  call    ASM_PFX(PosixOpenVolume)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileOpen)
+ASM_PFX(GasketPosixFileOpen):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+  movq    48(%rbp), %r8 
+  call    ASM_PFX(PosixFileOpen)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileCLose)
+ASM_PFX(GasketPosixFileCLose):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(PosixFileCLose)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+  
+ASM_GLOBAL ASM_PFX(GasketPosixFileDelete)
+ASM_PFX(GasketPosixFileDelete):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(PosixFileDelete)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileRead)
+ASM_PFX(GasketPosixFileRead):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+
+  call    ASM_PFX(PosixFileRead)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+  
+ASM_GLOBAL ASM_PFX(GasketPosixFileWrite)
+ASM_PFX(GasketPosixFileWrite):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+
+  call    ASM_PFX(PosixFileWrite)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileSetPossition)
+ASM_PFX(GasketPosixFileSetPossition):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call    ASM_PFX(PosixFileSetPossition)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileGetPossition)
+ASM_PFX(GasketPosixFileGetPossition):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call    ASM_PFX(PosixFileGetPossition)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileGetInfo)
+ASM_PFX(GasketPosixFileGetInfo):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+
+  call    ASM_PFX(PosixFileGetInfo)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileSetInfo)
+ASM_PFX(GasketPosixFileSetInfo):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+
+  call    ASM_PFX(PosixFileSetInfo)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileFlush)
+ASM_PFX(GasketPosixFileFlush):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(PosixFileFlush)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkOpen)
+ASM_PFX(GasketPosixFileSystmeThunkOpen):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(PosixFileSystmeThunkOpen)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkClose)
+ASM_PFX(GasketPosixFileSystmeThunkClose):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(PosixFileSystmeThunkClose)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReset)
+ASM_PFX(GasketEmuBlockIoReset):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call    ASM_PFX(EmuBlockIoReset)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReadBlocks)
+ASM_PFX(GasketEmuBlockIoReadBlocks):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+  movq    48(%rbp), %r8   
+  movq    56(%rbp), %r9   
+
+  call    ASM_PFX(EmuBlockIoReadBlocks)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoWriteBlocks)
+ASM_PFX(GasketEmuBlockIoWriteBlocks):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+  movq    48(%rbp), %r8   
+  movq    56(%rbp), %r9   
+
+  call    ASM_PFX(EmuBlockIoWriteBlocks)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoFlushBlocks)
+ASM_PFX(GasketEmuBlockIoFlushBlocks):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi    
+
+  call    ASM_PFX(EmuBlockIoFlushBlocks)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoCreateMapping)
+ASM_PFX(GasketEmuBlockIoCreateMapping):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call    ASM_PFX(EmuBlockIoCreateMapping)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketBlockIoThunkOpen)
+ASM_PFX(GasketBlockIoThunkOpen):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(EmuBlockIoThunkOpen)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketBlockIoThunkClose)
+ASM_PFX(GasketBlockIoThunkClose):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(EmuBlockIoThunkClose)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpCreateMapping)
+ASM_PFX(GasketSnpCreateMapping):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call    ASM_PFX(EmuSnpCreateMapping)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpStart)
+ASM_PFX(GasketSnpStart):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(EmuSnpStart)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpStop)
+ASM_PFX(GasketSnpStop):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(EmuSnpStop)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpInitialize)
+ASM_PFX(GasketSnpInitialize):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+
+  call    ASM_PFX(EmuSnpInitialize)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpReset)
+ASM_PFX(GasketSnpReset):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call    ASM_PFX(EmuSnpReset)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpShutdown)
+ASM_PFX(GasketSnpShutdown):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(EmuSnpShutdown)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpReceiveFilters)
+ASM_PFX(GasketSnpReceiveFilters):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+  movq    48(%rbp), %r8   
+  movq    56(%rbp), %r9   
+
+  call    ASM_PFX(EmuSnpReceiveFilters)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpStationAddress)
+ASM_PFX(GasketSnpStationAddress):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+
+  call    ASM_PFX(EmuSnpStationAddress)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpStatistics)
+ASM_PFX(GasketSnpStatistics):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+
+  call    ASM_PFX(EmuSnpStatistics)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpMCastIpToMac)
+ASM_PFX(GasketSnpMCastIpToMac):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+
+  call    ASM_PFX(EmuSnpMCastIpToMac)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpNvData)
+ASM_PFX(GasketSnpNvData):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+  movq    48(%rbp), %r8   
+
+  call    ASM_PFX(EmuSnpNvData)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpGetStatus)
+ASM_PFX(GasketSnpGetStatus):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+
+  call    ASM_PFX(EmuSnpGetStatus)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpTransmit)
+ASM_PFX(GasketSnpTransmit):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+       subq    $16, %rsp       // Allocate space for args on the stack 
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+  movq    48(%rbp), %r8   
+  movq    56(%rbp), %r9   
+  movq    64(%rbp), %rax
+  movq    %rax,     (%rsp)
+
+  call    ASM_PFX(EmuSnpTransmit)
+       addq    $16, %rsp
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpReceive)
+ASM_PFX(GasketSnpReceive):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+       subq    $16, %rsp       // Allocate space for args on the stack
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+  movq    %r8,  %rdx
+  movq    %r9,  %rcx
+  movq    48(%rbp), %r8   
+  movq    56(%rbp), %r9   
+  movq    64(%rbp), %rax
+  movq    %rax,     (%rsp)
+
+  call    ASM_PFX(EmuSnpReceive)
+       addq    $16, %rsp
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpThunkOpen)
+ASM_PFX(GasketSnpThunkOpen):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(EmuSnpThunkOpen)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpThunkClose)
+ASM_PFX(GasketSnpThunkClose):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq   %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+
+  call    ASM_PFX(EmuSnpThunkClose)
+
+  popq    %rdi          // restore state
+  popq    %rsi
+  popq    %rbp
+  ret
+
+
diff --git a/EmulatorPkg/Unix/Host/X64/SwitchStack.S b/EmulatorPkg/Unix/Host/X64/SwitchStack.S
new file mode 100644 (file)
index 0000000..8a57b78
--- /dev/null
@@ -0,0 +1,53 @@
+#------------------------------------------------------------------------------\r
+#\r
+# Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+# Portitions copyright (c) 2011, Apple Inc. All rights reserved.\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php.\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#------------------------------------------------------------------------------\r
+\r
+\r
+#------------------------------------------------------------------------------\r
+# Routine Description:\r
+#\r
+#   Routine for switching stacks with 2 parameters EFI ABI\r
+#   Convert UNIX to EFI ABI\r
+#\r
+# Arguments:\r
+#\r
+#   (rdi) EntryPoint    - Entry point with new stack.\r
+#   (rsi) Context1      - Parameter1 for entry point. (rcx)\r
+#   (rdx) Context2      - Parameter2 for entry point. (rdx) \r
+#   (rcx) NewStack      - The pointer to new stack.\r
+#\r
+# Returns:\r
+#\r
+#   None\r
+#\r
+#------------------------------------------------------------------------------\r
+ASM_GLOBAL ASM_PFX(PeiSwitchStacks)\r
+ASM_PFX(PeiSwitchStacks):\r
+    pushq   $0            // tells gdb to stop unwinding frame\r
+    movq    %rsp, %rbp\r
+\r
+    movq    %rcx, %rsp    // update stack pointer\r
+    \r
+    movq    %rdi, %rax    // entry point to %rax\r
+    movq    %rsi, %rcx    // Adjust Context1\r
+                          // Context2 already in the rigth spot\r
+    \r
+    #\r
+    # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,\r
+    # in case the callee wishes to spill them.\r
+    #\r
+    subq    $32, %rsp  // 32-byte shadow space plus alignment pad\r
+    call    *%rax\r
+\r
+  \r
+\r
diff --git a/EmulatorPkg/Unix/UnixX64.dsc b/EmulatorPkg/Unix/UnixX64.dsc
new file mode 100644 (file)
index 0000000..922df01
--- /dev/null
@@ -0,0 +1,455 @@
+## @file\r
+#\r
+# UEFI/PI Emulation Platform with UEFI HII interface supported.\r
+#\r
+# The Emulation Platform can be used to debug individual modules, prior to creating\r
+#       a real platform. This also provides an example for how an DSC is created.\r
+# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.<BR>\r
+#\r
+#    This program and the accompanying materials\r
+#    are licensed and made available under the terms and conditions of the BSD License\r
+#    which accompanies this distribution. The full text of the license may be found at\r
+#    http://opensource.org/licenses/bsd-license.php\r
+#\r
+#    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  PLATFORM_NAME                  = EmuUnix\r
+  PLATFORM_GUID                  = 05FD064D-1073-E844-936C-A0E16317107D\r
+  PLATFORM_VERSION               = 0.3\r
+  DSC_ SPECIFICATION             = 0x00010005\r
+!if $(BUILD_32)\r
+  OUTPUT_DIRECTORY               = Build/EmuUnixIa32\r
+!else\r
+  OUTPUT_DIRECTORY               = Build/EmuUnixX64\r
+!endif\r
+\r
+  SUPPORTED_ARCHITECTURES        = X64|IA32\r
+  BUILD_TARGETS                  = DEBUG|RELEASE\r
+  SKUID_IDENTIFIER               = DEFAULT\r
+  FLASH_DEFINITION               = EmulatorPkg/Unix/UnixX64.fdf\r
+\r
+################################################################################\r
+#\r
+# SKU Identification section - list of all SKU IDs supported by this Platform.\r
+#\r
+################################################################################\r
+[SkuIds]\r
+  0|DEFAULT\r
+\r
+################################################################################\r
+#\r
+# Library Class section - list of all Library Classes needed by this Platform.\r
+#\r
+################################################################################\r
+[LibraryClasses]\r
+  #\r
+  # Entry point\r
+  #\r
+  PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf\r
+  PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf\r
+  DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf\r
+  UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf\r
+  UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
+  #\r
+  # Basic\r
+  #\r
+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf\r
+  SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf\r
+  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
+  CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf\r
+  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
+  PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf\r
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
+\r
+  #\r
+  # UEFI & PI\r
+  #\r
+  UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf\r
+  UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
+  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf\r
+  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf\r
+  UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf\r
+  HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf\r
+  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf\r
+  UefiDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf\r
+\r
+  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
+  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf\r
+  DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
+  #\r
+  # Generic Modules\r
+  #\r
+  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
+  NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf\r
+  IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf\r
+  UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf\r
+  DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf\r
+  OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf\r
+  GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
+  SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf\r
+  TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf\r
+  SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf\r
+  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
+  #\r
+  # Platform\r
+  #\r
+  PlatformBdsLib|EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf\r
+  KeyMapLib|EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.inf\r
+  \r
+  #\r
+  # Misc\r
+  #\r
+  DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf\r
+  PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf\r
+  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf\r
+  PeiServicesTablePointerLib|EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointerLibMagicPage.inf\r
+  DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
+\r
+\r
+[LibraryClasses.common.SEC]\r
+  PeiServicesLib|EmulatorPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf\r
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+  PeCoffGetEntryPointLib|EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.inf\r
+  PeCoffExtraActionLib|EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf\r
+  SerialPortLib|EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf\r
+  PpiListLib|EmulatorPkg/Library/SecPpiListLib/SecPpiListLib.inf\r
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
+  TimerLib|EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.inf\r
+\r
+[LibraryClasses.common.USER_DEFINED, LibraryClasses.common.BASE]\r
+  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
+  PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf\r
+  MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+  PpiListLib|EmulatorPkg/Library/SecPpiListLib/SecPpiListLib.inf\r
+  ThunkPpiList|EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.inf\r
+  ThunkProtocolList|EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.inf\r
+  PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf\r
+  PpiListLib|EmulatorPkg/Library/SecPpiListLib/SecPpiListLib.inf\r
+  PeiServicesLib|EmulatorPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf\r
+\r
+\r
+[LibraryClasses.common.PEIM, LibraryClasses.common.PEI_CORE]\r
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
+  MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r
+  ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf\r
+  PeCoffGetEntryPointLib|EmulatorPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.inf\r
+  PeCoffExtraActionLib|EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf\r
+  ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf\r
+  SerialPortLib|EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf\r
+  ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf\r
+  TimerLib|EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.inf\r
+\r
+[LibraryClasses.common.PEI_CORE]\r
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+\r
+[LibraryClasses.common.PEIM]\r
+  PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf\r
+\r
+[LibraryClasses.common.DXE_CORE]\r
+  HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf\r
+  MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf\r
+  ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf\r
+  PeCoffExtraActionLib|EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf\r
+  ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf\r
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+  TimerLib|EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.inf\r
+  EmuThunkLib|EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.inf\r
+\r
+[LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.DXE_DRIVER, LibraryClasses.common.UEFI_APPLICATION]\r
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
+  MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
+  ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf\r
+  EmuThunkLib|EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.inf\r
+  PeCoffExtraActionLib|EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf\r
+  ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf\r
+  TimerLib|EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.inf\r
+\r
+[LibraryClasses.common.UEFI_DRIVER]\r
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
\r
+[LibraryClasses.common.UEFI_APPLICATION]\r
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+\r
+\r
+################################################################################\r
+#\r
+# Pcd Section - list of all EDK II PCD Entries defined by this Platform.\r
+#\r
+################################################################################\r
+[PcdsFeatureFlag]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|TRUE\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst|FALSE\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE\r
+\r
+[PcdsFixedAtBuild]\r
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000040\r
+  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0f\r
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x1f\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0x0\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x0\r
+\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFirmwareFdSize|0x002a0000\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFirmwareBlockSize|0x10000\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFirmwareVolume|L"../FV/FV_RECOVERY.fd"\r
+  \r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuMemorySizeForSecMain|L"64!64"\r
+\r
+!if $(BUILD_NEW_SHELL)\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }\r
+!else\r
+!if $(USE_NEW_SHELL)\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }\r
+!endif\r
+!endif\r
+\r
+#define BOOT_WITH_FULL_CONFIGURATION                  0x00\r
+#define BOOT_WITH_MINIMAL_CONFIGURATION               0x01\r
+#define BOOT_ASSUMING_NO_CONFIGURATION_CHANGES        0x02\r
+#define BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS 0x03\r
+#define BOOT_WITH_DEFAULT_SETTINGS                    0x04\r
+#define BOOT_ON_S4_RESUME                             0x05\r
+#define BOOT_ON_S5_RESUME                             0x06\r
+#define BOOT_ON_S2_RESUME                             0x10\r
+#define BOOT_ON_S3_RESUME                             0x11\r
+#define BOOT_ON_FLASH_UPDATE                          0x12\r
+#define BOOT_IN_RECOVERY_MODE                         0x20\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuBootMode|0\r
+  \r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuApCount|L"1"\r
+\r
+  # For a CD-ROM/DVD use L"diag.dmg:RO:2048"\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"disk.dmg:FW"\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuGop|L"GOP Window"\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuFileSystem|L".!../../../../EdkShellBinPkg/Bin"\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuSerialPort|L"/dev/ttyS0"\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuNetworkInterface|L"en0"\r
+\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuCpuModel|L"Intel(R) Processor Model"\r
+  gEmulatorPkgTokenSpaceGuid.PcdEmuCpuSpeed|L"3000"\r
+\r
+  #  0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8\r
+  gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|1\r
+\r
+################################################################################\r
+#\r
+# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform\r
+#\r
+################################################################################\r
+\r
+[PcdsDynamicDefault.common.DEFAULT]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0\r
+\r
+[PcdsDynamicHii.common.DEFAULT]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Setup"|gEmuSystemConfigGuid|0x0|80\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|L"Setup"|gEmuSystemConfigGuid|0x4|25\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|10\r
+\r
+\r
+###################################################################################################\r
+#\r
+# Components Section - list of the modules and components that will be processed by compilation\r
+#                      tools and the EDK II tools to generate PE32/PE32+/Coff image files.\r
+#\r
+# Note: The EDK II DSC file is not used to specify how compiled binary images get placed\r
+#       into firmware volume images. This section is just a list of modules to compile from\r
+#       source into UEFI-compliant binaries.\r
+#       It is the FDF file that contains information on combining binary files into firmware\r
+#       volume images, whose concept is beyond UEFI and is described in PI specification.\r
+#       Binary modules do not need to be listed in this section, as they should be\r
+#       specified in the FDF file. For example: Shell binary (Shell_Full.efi), FAT binary (Fat.efi),\r
+#       Logo (Logo.bmp), and etc.\r
+#       There may also be modules listed in this section that are not required in the FDF file,\r
+#       When a module listed here is excluded from FDF file, then UEFI-compliant binary will be\r
+#       generated for it, but the binary will not be put into any firmware volume.\r
+#\r
+###################################################################################################\r
+\r
+!ifndef $(SKIP_MAIN_BUILD)\r
+[Components.X64]\r
+  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf {\r
+    <LibraryClasses>\r
+      # turn off CR3 write so that DXE IPL will not crash emulator\r
+      BaseLib|UnixPkg/Library/UnixBaseLib/UnixBaseLib.inf\r
+  }\r
+\r
+[Components.IA32]\r
+  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf \r
+!endif\r
+\r
+[Components]\r
+!ifdef $(UNIX_SEC_BUILD)\r
+  ##\r
+  #  Emulator, OS POSIX application\r
+  ##\r
+  EmulatorPkg/Unix/Host/SecMain.inf\r
+!endif\r
+\r
+!ifndef $(SKIP_MAIN_BUILD)\r
+  #\r
+  # Generic SEC\r
+  #\r
+  EmulatorPkg/Sec/Sec.inf\r
+\r
+  ##\r
+  #  PEI Phase modules\r
+  ##\r
+  MdeModulePkg/Core/Pei/PeiMain.inf\r
+  MdeModulePkg/Universal/PCD/Pei/Pcd.inf  {\r
+   <LibraryClasses>\r
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+  }\r
+  MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf\r
+  MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf \r
+  \r
+  IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf\r
+  EmulatorPkg/BootModePei/BootModePei.inf\r
+  MdeModulePkg/Universal/Variable/Pei/VariablePei.inf\r
+  EmulatorPkg/AutoScanPei/AutoScanPei.inf\r
+  EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.inf\r
+  EmulatorPkg/FlashMapPei/FlashMapPei.inf\r
+  EmulatorPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.inf\r
+\r
+  ##\r
+  #  DXE Phase modules\r
+  ##\r
+  MdeModulePkg/Core/Dxe/DxeMain.inf {\r
+    <LibraryClasses>\r
+      DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
+      NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf\r
+      NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
+  }\r
+  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {\r
+    <LibraryClasses>\r
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+  }\r
+\r
+  MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf\r
+  MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf {\r
+   <LibraryClasses>\r
+      DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
+      SerialPortLib|EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf    \r
+  }\r
+\r
+  MdeModulePkg/Universal/Metronome/Metronome.inf\r
+  EmulatorPkg/RealTimeClockRuntimeDxe/RealTimeClock.inf\r
+  EmulatorPkg/ResetRuntimeDxe/Reset.inf\r
+  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
+  EmulatorPkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf\r
+  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
+  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
+  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
+  EmulatorPkg/EmuThunkDxe/EmuThunk.inf\r
+  EmulatorPkg/CpuRuntimeDxe/Cpu.inf\r
+  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf\r
+  EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.inf\r
+  EmulatorPkg/TimerDxe/Timer.inf\r
+\r
+\r
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf\r
+  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
+  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
+  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
+  MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
+  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
+  MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
+  EmbeddedPkg/SerialDxe/SerialDxe.inf {\r
+   <LibraryClasses>\r
+      DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
+      SerialPortLib|EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf    \r
+  }\r
+  \r
+  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
+  IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf\r
+  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf \r
+  #{\r
+  #  <LibraryClasses>  \r
+  #    NULL|EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.inf\r
+  #}\r
+  \r
+  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
+  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
+  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
+  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf\r
+  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
+  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
+  IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf\r
+\r
+  EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.inf\r
+  EmulatorPkg/EmuGopDxe/EmuGopDxe.inf\r
+  EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf\r
+  EmulatorPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf\r
+  EmulatorPkg/EmuSnpDxe/EmuSnpDxe.inf\r
+\r
+  MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
+\r
+  #\r
+  # Network stack drivers\r
+  #\r
+  MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf\r
+  MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf\r
+  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf\r
+  MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf\r
+  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf\r
+  MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf\r
+  MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf\r
+  MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf\r
+  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf\r
+  MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf\r
+\r
+  MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf\r
+  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf\r
+  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
+  MdeModulePkg/Universal/PrintDxe/PrintDxe.inf\r
+  MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf {\r
+    <LibraryClasses>\r
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+  }\r
+\r
+!if $(BUILD_FAT)\r
+  FatPkg/EnhancedFatDxe/Fat.inf\r
+!endif\r
+\r
+!if $(BUILD_NEW_SHELL)\r
+  ShellPkg/Application/Shell/Shell.inf {\r
+    <LibraryClasses>\r
+      ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf\r
+      NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf\r
+      NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf\r
+      NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf\r
+      NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf\r
+      NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf\r
+      NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf\r
+      NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf\r
+      HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf\r
+      FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
+      ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf\r
+      SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf\r
+      PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
+      MemoryAllocationLib|EmulatorPkg/Library/GuardUefiMemoryAllocationLib/GuardUefiMemoryAllocationLib.inf\r
+      SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf\r
+      SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf\r
+\r
+    <PcdsFixedAtBuild>\r
+      gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF\r
+      gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE\r
+      gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000\r
+  }\r
+!endif\r
+\r
+!endif\r
+\r
diff --git a/EmulatorPkg/Unix/UnixX64.fdf b/EmulatorPkg/Unix/UnixX64.fdf
new file mode 100644 (file)
index 0000000..2977a9f
--- /dev/null
@@ -0,0 +1,395 @@
+## @file\r
+# This is Unix FDF file with UEFI HII features enabled\r
+#\r
+# Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
+# Portions copyright (c) 2009 - 2011, Apple Inc. All rights reserved.<BR>\r
+#\r
+#    This program and the accompanying materials\r
+#    are licensed and made available under the terms and conditions of the BSD License\r
+#    which accompanies this distribution. The full text of the license may be found at\r
+#    http://opensource.org/licenses/bsd-license.php\r
+#\r
+#    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+\r
+################################################################################\r
+#\r
+# FD Section\r
+# The [FD] Section is made up of the definition statements and a\r
+# description of what goes into  the Flash Device Image.  Each FD section\r
+# defines one flash "device" image.  A flash device image may be one of\r
+# the following: Removable media bootable image (like a boot floppy\r
+# image,) an Option ROM image (that would be "flashed" into an add-in\r
+# card,) a System "Flash"  image (that would be burned into a system's\r
+# flash) or an Update ("Capsule") image that will be used to update and\r
+# existing system flash.\r
+#\r
+################################################################################\r
+[FD.Fv_Recovery]\r
+#\r
+# In OS X PEIMs are really XIP, so we need to make this address match the malloced \r
+# buffer for the FD (0x41000000). If this address does not match the FV will get\r
+# relocated in place (works, but not a great idea).\r
+#\r
+BaseAddress   = 0x102000000|gEmulatorPkgTokenSpaceGuid.PcdEmuFdBaseAddress   #The base address of the FLASH Device.\r
+Size          = 0x005a0000|gEmulatorPkgTokenSpaceGuid.PcdEmuFirmwareFdSize  #The size in bytes of the FLASH Device\r
+ErasePolarity = 1\r
+BlockSize     = 0x10000\r
+NumBlocks     = 0x5a\r
+\r
+################################################################################\r
+#\r
+# Following are lists of FD Region layout which correspond to the locations of different\r
+# images within the flash device.\r
+#\r
+# Regions must be defined in ascending order and may not overlap.\r
+#\r
+# A Layout Region start with a eight digit hex offset (leading "0x" required) followed by\r
+# the pipe "|" character, followed by the size of the region, also in hex with the leading\r
+# "0x" characters. Like:\r
+# Offset|Size\r
+# PcdOffsetCName|PcdSizeCName\r
+# RegionType <FV, DATA, or FILE>\r
+#\r
+################################################################################\r
+0x00000000|0x00580000\r
+gEmulatorPkgTokenSpaceGuid.PcdEmuFlashFvRecoveryBase|gEmulatorPkgTokenSpaceGuid.PcdEmuFlashFvRecoverySize\r
+FV = FvRecovery\r
+\r
+0x00580000|0x0000c000\r
+gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
+#NV_VARIABLE_STORE\r
+DATA = {\r
+  ## This is the EFI_FIRMWARE_VOLUME_HEADER\r
+  # ZeroVector []\r
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  # FileSystemGuid: gEfiSystemNvDataFvGuid         =\r
+  #  { 0xFFF12B8D, 0x7696, 0x4C8B, { 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50 }}\r
+  0x8D, 0x2B, 0xF1, 0xFF, 0x96, 0x76, 0x8B, 0x4C,\r
+  0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50,\r
+  # FvLength: 0x20000\r
+  0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  # Signature "_FVH"       #Attributes\r
+  0x5f, 0x46, 0x56, 0x48, 0xff, 0xfe, 0x04, 0x00,\r
+  # HeaderLength #CheckSum #ExtHeaderOffset #Reserved #Revision\r
+  0x48, 0x00, 0x36, 0x09, 0x00, 0x00, 0x00, 0x02,\r
+  # Blockmap[0]: 2 Blocks * 0x10000 Bytes / Block\r
+  0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,\r
+  # Blockmap[1]: End\r
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
+  ## This is the VARIABLE_STORE_HEADER\r
+  #Signature: gEfiVariableGuid =\r
+  #  { 0xddcf3616, 0x3275, 0x4164, { 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d }}\r
+  0x16, 0x36, 0xcf, 0xdd, 0x75, 0x32, 0x64, 0x41,\r
+  0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d,\r
+  #Size: 0xc000 (gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize) - 0x48 (size of EFI_FIRMWARE_VOLUME_HEADER) = 0xBFB8\r
+  # This can speed up the Variable Dispatch a bit.\r
+  0xB8, 0xBF, 0x00, 0x00,\r
+  #FORMATTED: 0x5A #HEALTHY: 0xFE #Reserved: UINT16 #Reserved1: UINT32\r
+  0x5A, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r
+}\r
+\r
+0x0058c000|0x00002000\r
+#NV_EVENT_LOG\r
+gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogBase|gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogSize\r
+\r
+0x0058e000|0x00002000\r
+gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize\r
+#NV_FTW_WORKING\r
+DATA = {\r
+  # EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER->Signature = gEfiSystemNvDataFvGuid         =\r
+  #  { 0xFFF12B8D, 0x7696, 0x4C8B, { 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50 }}\r
+  0x8D, 0x2B, 0xF1, 0xFF, 0x96, 0x76, 0x8B, 0x4C,\r
+  0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50,\r
+  # Crc:UINT32            #WorkingBlockValid:1, WorkingBlockInvalid:1, Reserved\r
+  0x77, 0x13, 0x9B, 0xD7, 0xFE, 0xFF, 0xFF, 0xFF,\r
+  # WriteQueueSize: UINT64\r
+  0xE0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r
+}\r
+\r
+0x00590000|0x00010000\r
+#NV_FTW_SPARE\r
+gEmulatorPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
+\r
+################################################################################\r
+#\r
+# FV Section\r
+#\r
+# [FV] section is used to define what components or modules are placed within a flash\r
+# device file.  This section also defines order the components and modules are positioned\r
+# within the image.  The [FV] section consists of define statements, set statements and\r
+# module statements.\r
+#\r
+################################################################################\r
+[FV.FvRecovery]\r
+FvAlignment        = 16         #FV alignment and FV attributes setting.\r
+ERASE_POLARITY     = 1\r
+MEMORY_MAPPED      = TRUE\r
+STICKY_WRITE       = TRUE\r
+LOCK_CAP           = TRUE\r
+LOCK_STATUS        = TRUE\r
+WRITE_DISABLED_CAP = TRUE\r
+WRITE_ENABLED_CAP  = TRUE\r
+WRITE_STATUS       = TRUE\r
+WRITE_LOCK_CAP     = TRUE\r
+WRITE_LOCK_STATUS  = TRUE\r
+READ_DISABLED_CAP  = TRUE\r
+READ_ENABLED_CAP   = TRUE\r
+READ_STATUS        = TRUE\r
+READ_LOCK_CAP      = TRUE\r
+READ_LOCK_STATUS   = TRUE\r
+\r
+################################################################################\r
+#\r
+# The INF statements point to EDK component and EDK II module INF files, which will be placed into this FV image.\r
+# Parsing tools will scan the INF file to determine the type of component or module.\r
+# The component or module type is used to reference the standard rules\r
+# defined elsewhere in the FDF file.\r
+#\r
+# The format for INF statements is:\r
+# INF $(PathAndInfFileName)\r
+#\r
+################################################################################\r
+##\r
+#  PEI Phase modules\r
+##\r
+##\r
+#  PEI Apriori file example, more PEIM module added later.\r
+##\r
+APRIORI PEI {\r
+  INF  MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf\r
+  INF  MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf\r
+  INF  MdeModulePkg/Universal/PCD/Pei/Pcd.inf\r
+  }\r
+APRIORI DXE {\r
+  INF  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
+  INF  MdeModulePkg/Universal/Metronome/Metronome.inf\r
+  }\r
+INF  EmulatorPkg/Sec/Sec.inf\r
+INF  MdeModulePkg/Core/Pei/PeiMain.inf\r
+INF  MdeModulePkg/Universal/PCD/Pei/Pcd.inf\r
+INF  MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf\r
+INF  MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf\r
+INF  EmulatorPkg/BootModePei/BootModePei.inf\r
+INF  EmulatorPkg/AutoScanPei/AutoScanPei.inf\r
+INF  EmulatorPkg/FirmwareVolumePei/FirmwareVolumePei.inf\r
+INF  EmulatorPkg/FlashMapPei/FlashMapPei.inf\r
+INF  EmulatorPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.inf\r
+INF  MdeModulePkg/Universal/Variable/Pei/VariablePei.inf\r
+INF  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf\r
+\r
+##\r
+#  DXE Phase modules\r
+##\r
+INF  MdeModulePkg/Core/Dxe/DxeMain.inf\r
+INF  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf  \r
+INF  MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf\r
+INF  MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf\r
+INF  MdeModulePkg/Universal/Metronome/Metronome.inf\r
+INF  EmulatorPkg/RealTimeClockRuntimeDxe/RealTimeClock.inf\r
+INF  EmulatorPkg/ResetRuntimeDxe/Reset.inf\r
+INF  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
+INF  EmulatorPkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf\r
+INF  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
+INF  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
+INF  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
+INF  EmulatorPkg/EmuThunkDxe/EmuThunk.inf\r
+INF  EmulatorPkg/CpuRuntimeDxe/Cpu.inf\r
+INF  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf\r
+INF  EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.inf\r
+INF  EmulatorPkg/TimerDxe/Timer.inf\r
+INF  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf\r
+INF  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
+INF  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
+INF  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
+INF  MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
+INF  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
+INF  MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
+\r
+INF  EmbeddedPkg/SerialDxe/SerialDxe.inf\r
+INF  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
+INF  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
+INF  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
+INF  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
+INF  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
+INF  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf\r
+INF  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
+INF  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
+INF  IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf\r
+INF  MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf\r
+\r
+INF  EmulatorPkg/EmuBusDriverDxe/EmuBusDriverDxe.inf \r
+INF  EmulatorPkg/EmuGopDxe/EmuGopDxe.inf\r
+INF  EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf\r
+INF  EmulatorPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf\r
+INF  EmulatorPkg/EmuSnpDxe/EmuSnpDxe.inf\r
+\r
+INF  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf\r
+INF  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
+INF  MdeModulePkg/Universal/PrintDxe/PrintDxe.inf\r
+INF  IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf \r
+INF  MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf\r
+INF  MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
+\r
+#\r
+# Network stack drivers\r
+#\r
+!if $(NETWORK_SUPPORT)\r
+INF  EmulatorPkg/EmuSnpDxe/EmuSnpDxe.inf\r
+!endif\r
+INF  MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf\r
+INF  MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf\r
+INF  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf\r
+INF  MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf\r
+INF  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf\r
+INF  MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf\r
+INF  MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf\r
+INF  MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf\r
+INF  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf\r
+INF  MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf\r
+\r
\r
+!if $(BUILD_FAT)\r
+INF FatPkg/EnhancedFatDxe/Fat.inf\r
+!else\r
+INF  RuleOverride = BINARY FatBinPkg/EnhancedFatDxe/Fat.inf\r
+!endif\r
+\r
+!if $(BUILD_NEW_SHELL)\r
+INF  ShellPkg/Application/Shell/Shell.inf\r
+!else\r
+!if $(USE_NEW_SHELL)\r
+INF  RuleOverride = BINARY ShellBinPkg/UefiShell/UefiShell.inf\r
+!else\r
+INF  RuleOverride = BINARY EdkShellBinPkg/FullShell/FullShell.inf\r
+!endif\r
+!endif\r
+\r
+FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {\r
+  SECTION RAW = MdeModulePkg/Logo/Logo.bmp\r
+}\r
+   \r
+   \r
+################################################################################\r
+#  \r
+# Rules are use with the [FV] section's module INF type to define\r
+# how an FFS file is created for a given INF file. The following Rule are the default\r
+# rules for the different module type. User can add the customized rules to define the\r
+# content of the FFS file.\r
+#  \r
+################################################################################\r
+   \r
+   \r
+############################################################################\r
+# Example of a DXE_DRIVER FFS file with a Checksum encapsulation section   # \r
+############################################################################\r
+#  \r
+#[Rule.Common.DXE_DRIVER]\r
+#  FILE DRIVER = $(NAMED_GUID) {\r
+#    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex\r
+#    COMPRESS PI_STD {\r
+#      GUIDED {\r
+#        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+#        UI       STRING="$(MODULE_NAME)" Optional\r
+#        VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+#      }\r
+#    }\r
+#  }\r
+#\r
+############################################################################\r
+[Rule.Common.SEC]\r
+  FILE SEC = $(NAMED_GUID)  {\r
+    PE32     PE32    Align=32       $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+    UI       STRING ="$(MODULE_NAME)" Optional         \r
+    VERSION  STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)    \r
+  }\r
+\r
+\r
+[Rule.Common.PEI_CORE]\r
+  FILE PEI_CORE = $(NAMED_GUID) {\r
+    PE32     PE32    Align=32       $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+    UI       STRING ="$(MODULE_NAME)" Optional         \r
+    VERSION  STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)    \r
+  }\r
+\r
+[Rule.Common.PEIM]\r
+  FILE PEIM = $(NAMED_GUID) {\r
+     PEI_DEPEX PEI_DEPEX Optional        $(INF_OUTPUT)/$(MODULE_NAME).depex\r
+     PE32      PE32   Align=32       $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+     UI       STRING="$(MODULE_NAME)" Optional         \r
+     VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)   \r
+  }\r
+\r
+[Rule.Common.DXE_CORE]\r
+  FILE DXE_CORE = $(NAMED_GUID) {\r
+    COMPRESS PI_STD {\r
+      PE32     PE32           $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+      UI       STRING="$(MODULE_NAME)" Optional\r
+      VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+    }\r
+  }\r
+\r
+[Rule.Common.UEFI_DRIVER]\r
+  FILE DRIVER = $(NAMED_GUID) {\r
+    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex\r
+    COMPRESS PI_STD {\r
+      GUIDED {\r
+        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+        UI       STRING="$(MODULE_NAME)" Optional\r
+        VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+      }\r
+    }\r
+  }\r
+\r
+[Rule.Common.DXE_DRIVER]\r
+  FILE DRIVER = $(NAMED_GUID) {\r
+    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex\r
+    COMPRESS PI_STD {\r
+      GUIDED {\r
+        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+        UI       STRING="$(MODULE_NAME)" Optional\r
+        VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+      }\r
+    }\r
+  }\r
+\r
+[Rule.Common.DXE_RUNTIME_DRIVER]\r
+  FILE DRIVER = $(NAMED_GUID) {\r
+    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex\r
+    COMPRESS PI_STD {\r
+      GUIDED {\r
+        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+        UI       STRING="$(MODULE_NAME)" Optional\r
+        VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+      }\r
+    }\r
+  }\r
+\r
+[Rule.Common.UEFI_APPLICATION]\r
+  FILE APPLICATION = $(NAMED_GUID) {\r
+    COMPRESS PI_STD {\r
+      GUIDED {\r
+        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+        UI       STRING="$(MODULE_NAME)" Optional\r
+        VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+      }\r
+    }\r
+  }\r
+\r
+[Rule.Common.UEFI_DRIVER.BINARY]\r
+  FILE DRIVER = $(NAMED_GUID) {\r
+    DXE_DEPEX DXE_DEPEX Optional      |.depex\r
+    PE32      PE32                    |.efi\r
+    UI        STRING="$(MODULE_NAME)" Optional\r
+    VERSION   STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+  }\r
+\r
+[Rule.Common.UEFI_APPLICATION.BINARY]\r
+  FILE APPLICATION = $(NAMED_GUID) {\r
+    PE32      PE32                    |.efi\r
+    UI        STRING="$(MODULE_NAME)" Optional\r
+    VERSION   STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+  }\r
+\r
diff --git a/EmulatorPkg/Unix/Xcode/xcode_project32/XcodeBuild.sh b/EmulatorPkg/Unix/Xcode/xcode_project32/XcodeBuild.sh
new file mode 100755 (executable)
index 0000000..09d1a28
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# External makefile Xcode project project uses this script to build and clean from the Xcode GUI
+#
+# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
+#
+# 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.
+#
+
+# force exit on error
+set -e
+
+#
+# Source the workspace and set up the environment variables we need
+#
+cd ../..
+echo `pwd`
+./build.sh $1 $2 $3 $4 $5 $6 $8
diff --git a/EmulatorPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/default.pbxuser b/EmulatorPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/default.pbxuser
new file mode 100644 (file)
index 0000000..e2dfcb9
--- /dev/null
@@ -0,0 +1,191 @@
+// !$*UTF8*$!
+{
+       08FB7793FE84155DC02AAC07 /* Project object */ = {
+               activeBuildConfigurationName = Debug;
+               activeExecutable = BA11A1010FB10BCE00D06FEC /* SecMain.dll */;
+               activeTarget = D28A88AD04BDD90700651E21 /* xcode_project */;
+               breakpoints = (
+                       BA11A11A0FB10E0700D06FEC /* SecGdbConfigBreak */,
+               );
+               codeSenseManager = BA11A0FE0FB10B4800D06FEC /* Code sense */;
+               executables = (
+                       BA11A1010FB10BCE00D06FEC /* SecMain.dll */,
+               );
+               perUserDictionary = {
+                       "PBXConfiguration.PBXBreakpointsDataSource.v1:1CA1AED706398EBD00589147" = {
+                               PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
+                               PBXFileTableDataSourceColumnSortingKey = PBXBreakpointsDataSource_BreakpointID;
+                               PBXFileTableDataSourceColumnWidthsKey = (
+                                       20,
+                                       20,
+                                       198,
+                                       20,
+                                       99,
+                                       99,
+                                       29,
+                                       20,
+                               );
+                               PBXFileTableDataSourceColumnsKey = (
+                                       PBXBreakpointsDataSource_ActionID,
+                                       PBXBreakpointsDataSource_TypeID,
+                                       PBXBreakpointsDataSource_BreakpointID,
+                                       PBXBreakpointsDataSource_UseID,
+                                       PBXBreakpointsDataSource_LocationID,
+                                       PBXBreakpointsDataSource_ConditionID,
+                                       PBXBreakpointsDataSource_IgnoreCountID,
+                                       PBXBreakpointsDataSource_ContinueID,
+                               );
+                       };
+                       PBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = {
+                               PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
+                               PBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID;
+                               PBXFileTableDataSourceColumnWidthsKey = (
+                                       22,
+                                       300,
+                                       229,
+                               );
+                               PBXFileTableDataSourceColumnsKey = (
+                                       PBXExecutablesDataSource_ActiveFlagID,
+                                       PBXExecutablesDataSource_NameID,
+                                       PBXExecutablesDataSource_CommentsID,
+                               );
+                       };
+                       PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = {
+                               PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
+                               PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
+                               PBXFileTableDataSourceColumnWidthsKey = (
+                                       20,
+                                       341,
+                                       20,
+                                       48,
+                                       43,
+                                       43,
+                                       20,
+                               );
+                               PBXFileTableDataSourceColumnsKey = (
+                                       PBXFileDataSource_FiletypeID,
+                                       PBXFileDataSource_Filename_ColumnID,
+                                       PBXFileDataSource_Built_ColumnID,
+                                       PBXFileDataSource_ObjectSize_ColumnID,
+                                       PBXFileDataSource_Errors_ColumnID,
+                                       PBXFileDataSource_Warnings_ColumnID,
+                                       PBXFileDataSource_Target_ColumnID,
+                               );
+                       };
+                       PBXPerProjectTemplateStateSaveDate = 263260969;
+                       PBXWorkspaceStateSaveDate = 263260969;
+               };
+               sourceControlManager = BA11A0FD0FB10B4800D06FEC /* Source Control */;
+               userBuildSettings = {
+               };
+       };
+       BA11A0FD0FB10B4800D06FEC /* Source Control */ = {
+               isa = PBXSourceControlManager;
+               fallbackIsa = XCSourceControlManager;
+               isSCMEnabled = 0;
+               repositoryNamesForRoots = {
+               };
+               scmConfiguration = {
+               };
+       };
+       BA11A0FE0FB10B4800D06FEC /* Code sense */ = {
+               isa = PBXCodeSenseManager;
+               indexTemplatePath = "";
+       };
+       BA11A1010FB10BCE00D06FEC /* SecMain.dll */ = {
+               isa = PBXExecutable;
+               activeArgIndices = (
+               );
+               argumentStrings = (
+               );
+               autoAttachOnCrash = 1;
+               breakpointsEnabled = 1;
+               configStateDict = {
+                       "PBXLSLaunchAction-0" = {
+                               PBXLSLaunchAction = 0;
+                               PBXLSLaunchStartAction = 1;
+                               PBXLSLaunchStdioStyle = 2;
+                               PBXLSLaunchStyle = 0;
+                               class = PBXLSRunLaunchConfig;
+                               commandLineArgs = (
+                               );
+                               displayName = "Executable Runner";
+                               environment = {
+                               };
+                               identifier = com.apple.Xcode.launch.runConfig;
+                               remoteHostInfo = "";
+                               startActionInfo = "";
+                       };
+                       "PBXLSLaunchAction-1" = {
+                               PBXLSLaunchAction = 1;
+                               PBXLSLaunchStartAction = 1;
+                               PBXLSLaunchStdioStyle = 2;
+                               PBXLSLaunchStyle = 0;
+                               class = PBXGDB_LaunchConfig;
+                               commandLineArgs = (
+                               );
+                               displayName = GDB;
+                               environment = {
+                               };
+                               identifier = com.apple.Xcode.launch.GDBMI_Config;
+                               remoteHostInfo = "";
+                               startActionInfo = "";
+                       };
+               };
+               customDataFormattersEnabled = 0;
+               dataTipCustomDataFormattersEnabled = 1;
+               dataTipShowTypeColumn = 1;
+               dataTipSortType = 0;
+               debuggerPlugin = GDBDebugging;
+               disassemblyDisplayState = 0;
+               dylibVariantSuffix = "";
+               enableDebugStr = 1;
+               environmentEntries = (
+               );
+               executableSystemSymbolLevel = 0;
+               executableUserSymbolLevel = 0;
+               launchableReference = BA11A1020FB10BCE00D06FEC /* SecMain.dll */;
+               libgmallocEnabled = 0;
+               name = SecMain.dll;
+               savedGlobals = {
+               };
+               showTypeColumn = 0;
+               sourceDirectories = (
+               );
+               startupPath = ../../../../Build/EmuUnixIa32/DEBUG_XCLANG/IA32;
+       };
+       BA11A1020FB10BCE00D06FEC /* SecMain.dll */ = {
+               isa = PBXFileReference;
+               lastKnownFileType = "compiled.mach-o.executable";
+               name = SecMain.dll;
+               path = ../../../../Build/EmuUnixIa32/DEBUG_XCLANG/IA32/SecMain;
+               sourceTree = SOURCE_ROOT;
+       };
+       BA11A11A0FB10E0700D06FEC /* SecGdbConfigBreak */ = {
+               isa = PBXSymbolicBreakpoint;
+               actions = (
+                       BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */,
+               );
+               breakpointStyle = 1;
+               continueAfterActions = 1;
+               countType = 0;
+               delayBeforeContinue = 0;
+               hitCount = 0;
+               ignoreCount = 0;
+               location = SecMain;
+               modificationTime = 263261853.260195;
+               originalNumberOfMultipleMatches = 1;
+               state = 1;
+               symbolName = SecGdbConfigBreak;
+       };
+       BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */ = {
+               isa = XCBreakpointCommandAction;
+               command = "set gInXcode=1\nsource ../../../../EmulatorPkg/Unix/GdbRun";
+               fallbackIsa = XCBreakpointAction;
+               logCommand = 0;
+               useDebuggerSideImplementation = 1;
+       };
+       D28A88AD04BDD90700651E21 /* xcode_project */ = {
+               activeExec = 0;
+       };
+}
diff --git a/EmulatorPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/project.pbxproj b/EmulatorPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/project.pbxproj
new file mode 100644 (file)
index 0000000..8ff531e
--- /dev/null
@@ -0,0 +1,124 @@
+// !$*UTF8*$!
+{
+       archiveVersion = 1;
+       classes = {
+       };
+       objectVersion = 45;
+       objects = {
+
+/* Begin PBXGroup section */
+               08FB7794FE84155DC02AAC07 /* xcode_project */ = {
+                       isa = PBXGroup;
+                       children = (
+                       );
+                       name = xcode_project;
+                       sourceTree = "<group>";
+               };
+/* End PBXGroup section */
+
+/* Begin PBXLegacyTarget section */
+               D28A88AD04BDD90700651E21 /* xcode_project */ = {
+                       isa = PBXLegacyTarget;
+                       buildArgumentsString = "$(ACTION)";
+                       buildConfigurationList = 1DEB918F08733D9F0010E9CD /* Build configuration list for PBXLegacyTarget "xcode_project" */;
+                       buildPhases = (
+                       );
+                       buildToolPath = ./XcodeBuild.sh;
+                       buildWorkingDirectory = "";
+                       dependencies = (
+                       );
+                       name = xcode_project;
+                       passBuildSettingsInEnvironment = 1;
+                       productName = xcode_project;
+               };
+/* End PBXLegacyTarget section */
+
+/* Begin PBXProject section */
+               08FB7793FE84155DC02AAC07 /* Project object */ = {
+                       isa = PBXProject;
+                       buildConfigurationList = 1DEB919308733D9F0010E9CD /* Build configuration list for PBXProject "xcode_project" */;
+                       compatibilityVersion = "Xcode 3.1";
+                       developmentRegion = English;
+                       hasScannedForEncodings = 1;
+                       knownRegions = (
+                               English,
+                               Japanese,
+                               French,
+                               German,
+                       );
+                       mainGroup = 08FB7794FE84155DC02AAC07 /* xcode_project */;
+                       projectDirPath = "";
+                       projectRoot = "";
+                       targets = (
+                               D28A88AD04BDD90700651E21 /* xcode_project */,
+                       );
+               };
+/* End PBXProject section */
+
+/* Begin XCBuildConfiguration section */
+               1DEB919008733D9F0010E9CD /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = xcode_project;
+                       };
+                       name = Debug;
+               };
+               1DEB919108733D9F0010E9CD /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                               GCC_ENABLE_FIX_AND_CONTINUE = NO;
+                               OTHER_CFLAGS = "";
+                               OTHER_LDFLAGS = "";
+                               PRODUCT_NAME = xcode_project;
+                       };
+                       name = Release;
+               };
+               1DEB919408733D9F0010E9CD /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES;
+                               GCC_WARN_UNUSED_VARIABLE = YES;
+                               ONLY_ACTIVE_ARCH = YES;
+                               PREBINDING = NO;
+                               SDKROOT = macosx10.6;
+                       };
+                       name = Debug;
+               };
+               1DEB919508733D9F0010E9CD /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES;
+                               GCC_WARN_UNUSED_VARIABLE = YES;
+                               PREBINDING = NO;
+                               SDKROOT = macosx10.6;
+                       };
+                       name = Release;
+               };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+               1DEB918F08733D9F0010E9CD /* Build configuration list for PBXLegacyTarget "xcode_project" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               1DEB919008733D9F0010E9CD /* Debug */,
+                               1DEB919108733D9F0010E9CD /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
+               1DEB919308733D9F0010E9CD /* Build configuration list for PBXProject "xcode_project" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               1DEB919408733D9F0010E9CD /* Debug */,
+                               1DEB919508733D9F0010E9CD /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
+/* End XCConfigurationList section */
+       };
+       rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
+}
diff --git a/EmulatorPkg/Unix/Xcode/xcode_project64/XcodeBuild.sh b/EmulatorPkg/Unix/Xcode/xcode_project64/XcodeBuild.sh
new file mode 100755 (executable)
index 0000000..634b1b0
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# External makefile Xcode project project uses this script to build and clean from the Xcode GUI
+#
+# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
+#
+# 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.
+#
+
+# force exit on error
+set -e
+
+#
+# Source the workspace and set up the environment variables we need
+#
+cd ../..
+echo `pwd`
+./build64.sh $1 $2 $3 $4 $5 $6 $8
diff --git a/EmulatorPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/default.pbxuser b/EmulatorPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/default.pbxuser
new file mode 100644 (file)
index 0000000..55c869f
--- /dev/null
@@ -0,0 +1,191 @@
+// !$*UTF8*$!
+{
+       08FB7793FE84155DC02AAC07 /* Project object */ = {
+               activeBuildConfigurationName = Debug;
+               activeExecutable = BA11A1010FB10BCE00D06FEC /* SecMain.dll */;
+               activeTarget = D28A88AD04BDD90700651E21 /* xcode_project */;
+               breakpoints = (
+                       BA11A11A0FB10E0700D06FEC /* SecGdbConfigBreak */,
+               );
+               codeSenseManager = BA11A0FE0FB10B4800D06FEC /* Code sense */;
+               executables = (
+                       BA11A1010FB10BCE00D06FEC /* SecMain.dll */,
+               );
+               perUserDictionary = {
+                       "PBXConfiguration.PBXBreakpointsDataSource.v1:1CA1AED706398EBD00589147" = {
+                               PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
+                               PBXFileTableDataSourceColumnSortingKey = PBXBreakpointsDataSource_BreakpointID;
+                               PBXFileTableDataSourceColumnWidthsKey = (
+                                       20,
+                                       20,
+                                       198,
+                                       20,
+                                       99,
+                                       99,
+                                       29,
+                                       20,
+                               );
+                               PBXFileTableDataSourceColumnsKey = (
+                                       PBXBreakpointsDataSource_ActionID,
+                                       PBXBreakpointsDataSource_TypeID,
+                                       PBXBreakpointsDataSource_BreakpointID,
+                                       PBXBreakpointsDataSource_UseID,
+                                       PBXBreakpointsDataSource_LocationID,
+                                       PBXBreakpointsDataSource_ConditionID,
+                                       PBXBreakpointsDataSource_IgnoreCountID,
+                                       PBXBreakpointsDataSource_ContinueID,
+                               );
+                       };
+                       PBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = {
+                               PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
+                               PBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID;
+                               PBXFileTableDataSourceColumnWidthsKey = (
+                                       22,
+                                       300,
+                                       229,
+                               );
+                               PBXFileTableDataSourceColumnsKey = (
+                                       PBXExecutablesDataSource_ActiveFlagID,
+                                       PBXExecutablesDataSource_NameID,
+                                       PBXExecutablesDataSource_CommentsID,
+                               );
+                       };
+                       PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = {
+                               PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
+                               PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
+                               PBXFileTableDataSourceColumnWidthsKey = (
+                                       20,
+                                       341,
+                                       20,
+                                       48,
+                                       43,
+                                       43,
+                                       20,
+                               );
+                               PBXFileTableDataSourceColumnsKey = (
+                                       PBXFileDataSource_FiletypeID,
+                                       PBXFileDataSource_Filename_ColumnID,
+                                       PBXFileDataSource_Built_ColumnID,
+                                       PBXFileDataSource_ObjectSize_ColumnID,
+                                       PBXFileDataSource_Errors_ColumnID,
+                                       PBXFileDataSource_Warnings_ColumnID,
+                                       PBXFileDataSource_Target_ColumnID,
+                               );
+                       };
+                       PBXPerProjectTemplateStateSaveDate = 263260969;
+                       PBXWorkspaceStateSaveDate = 263260969;
+               };
+               sourceControlManager = BA11A0FD0FB10B4800D06FEC /* Source Control */;
+               userBuildSettings = {
+               };
+       };
+       BA11A0FD0FB10B4800D06FEC /* Source Control */ = {
+               isa = PBXSourceControlManager;
+               fallbackIsa = XCSourceControlManager;
+               isSCMEnabled = 0;
+               repositoryNamesForRoots = {
+               };
+               scmConfiguration = {
+               };
+       };
+       BA11A0FE0FB10B4800D06FEC /* Code sense */ = {
+               isa = PBXCodeSenseManager;
+               indexTemplatePath = "";
+       };
+       BA11A1010FB10BCE00D06FEC /* SecMain.dll */ = {
+               isa = PBXExecutable;
+               activeArgIndices = (
+               );
+               argumentStrings = (
+               );
+               autoAttachOnCrash = 1;
+               breakpointsEnabled = 1;
+               configStateDict = {
+                       "PBXLSLaunchAction-0" = {
+                               PBXLSLaunchAction = 0;
+                               PBXLSLaunchStartAction = 1;
+                               PBXLSLaunchStdioStyle = 2;
+                               PBXLSLaunchStyle = 0;
+                               class = PBXLSRunLaunchConfig;
+                               commandLineArgs = (
+                               );
+                               displayName = "Executable Runner";
+                               environment = {
+                               };
+                               identifier = com.apple.Xcode.launch.runConfig;
+                               remoteHostInfo = "";
+                               startActionInfo = "";
+                       };
+                       "PBXLSLaunchAction-1" = {
+                               PBXLSLaunchAction = 1;
+                               PBXLSLaunchStartAction = 1;
+                               PBXLSLaunchStdioStyle = 2;
+                               PBXLSLaunchStyle = 0;
+                               class = PBXGDB_LaunchConfig;
+                               commandLineArgs = (
+                               );
+                               displayName = GDB;
+                               environment = {
+                               };
+                               identifier = com.apple.Xcode.launch.GDBMI_Config;
+                               remoteHostInfo = "";
+                               startActionInfo = "";
+                       };
+               };
+               customDataFormattersEnabled = 0;
+               dataTipCustomDataFormattersEnabled = 1;
+               dataTipShowTypeColumn = 1;
+               dataTipSortType = 0;
+               debuggerPlugin = GDBDebugging;
+               disassemblyDisplayState = 0;
+               dylibVariantSuffix = "";
+               enableDebugStr = 1;
+               environmentEntries = (
+               );
+               executableSystemSymbolLevel = 0;
+               executableUserSymbolLevel = 0;
+               launchableReference = BA11A1020FB10BCE00D06FEC /* SecMain.dll */;
+               libgmallocEnabled = 0;
+               name = SecMain.dll;
+               savedGlobals = {
+               };
+               showTypeColumn = 0;
+               sourceDirectories = (
+               );
+               startupPath = ../../../../Build/EmuUnixX64/DEBUG_XCLANG/X64;
+       };
+       BA11A1020FB10BCE00D06FEC /* SecMain.dll */ = {
+               isa = PBXFileReference;
+               lastKnownFileType = "compiled.mach-o.executable";
+               name = SecMain.dll;
+               path = ../../../../Build/EmuUnixX64/DEBUG_XCLANG/X64/SecMain;
+               sourceTree = SOURCE_ROOT;
+       };
+       BA11A11A0FB10E0700D06FEC /* SecGdbConfigBreak */ = {
+               isa = PBXSymbolicBreakpoint;
+               actions = (
+                       BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */,
+               );
+               breakpointStyle = 1;
+               continueAfterActions = 1;
+               countType = 0;
+               delayBeforeContinue = 0;
+               hitCount = 0;
+               ignoreCount = 0;
+               location = SecMain;
+               modificationTime = 263261853.260195;
+               originalNumberOfMultipleMatches = 1;
+               state = 1;
+               symbolName = SecGdbConfigBreak;
+       };
+       BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */ = {
+               isa = XCBreakpointCommandAction;
+               command = "set gInXcode=1\nsource ../../../../EmulatorPkg/Unix/GdbRun";
+               fallbackIsa = XCBreakpointAction;
+               logCommand = 0;
+               useDebuggerSideImplementation = 1;
+       };
+       D28A88AD04BDD90700651E21 /* xcode_project */ = {
+               activeExec = 0;
+       };
+}
diff --git a/EmulatorPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/project.pbxproj b/EmulatorPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/project.pbxproj
new file mode 100644 (file)
index 0000000..9bd13bd
--- /dev/null
@@ -0,0 +1,124 @@
+// !$*UTF8*$!
+{
+       archiveVersion = 1;
+       classes = {
+       };
+       objectVersion = 45;
+       objects = {
+
+/* Begin PBXGroup section */
+               08FB7794FE84155DC02AAC07 /* xcode_project */ = {
+                       isa = PBXGroup;
+                       children = (
+                       );
+                       name = xcode_project;
+                       sourceTree = "<group>";
+               };
+/* End PBXGroup section */
+
+/* Begin PBXLegacyTarget section */
+               D28A88AD04BDD90700651E21 /* xcode_project */ = {
+                       isa = PBXLegacyTarget;
+                       buildArgumentsString = "$(ACTION)";
+                       buildConfigurationList = 1DEB918F08733D9F0010E9CD /* Build configuration list for PBXLegacyTarget "xcode_project" */;
+                       buildPhases = (
+                       );
+                       buildToolPath = ./XcodeBuild.sh;
+                       buildWorkingDirectory = "";
+                       dependencies = (
+                       );
+                       name = xcode_project;
+                       passBuildSettingsInEnvironment = 1;
+                       productName = xcode_project;
+               };
+/* End PBXLegacyTarget section */
+
+/* Begin PBXProject section */
+               08FB7793FE84155DC02AAC07 /* Project object */ = {
+                       isa = PBXProject;
+                       buildConfigurationList = 1DEB919308733D9F0010E9CD /* Build configuration list for PBXProject "xcode_project" */;
+                       compatibilityVersion = "Xcode 3.1";
+                       developmentRegion = English;
+                       hasScannedForEncodings = 1;
+                       knownRegions = (
+                               English,
+                               Japanese,
+                               French,
+                               German,
+                       );
+                       mainGroup = 08FB7794FE84155DC02AAC07 /* xcode_project */;
+                       projectDirPath = "";
+                       projectRoot = "";
+                       targets = (
+                               D28A88AD04BDD90700651E21 /* xcode_project */,
+                       );
+               };
+/* End PBXProject section */
+
+/* Begin XCBuildConfiguration section */
+               1DEB919008733D9F0010E9CD /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               PRODUCT_NAME = xcode_project;
+                       };
+                       name = Debug;
+               };
+               1DEB919108733D9F0010E9CD /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                               GCC_ENABLE_FIX_AND_CONTINUE = NO;
+                               OTHER_CFLAGS = "";
+                               OTHER_LDFLAGS = "";
+                               PRODUCT_NAME = xcode_project;
+                       };
+                       name = Release;
+               };
+               1DEB919408733D9F0010E9CD /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES;
+                               GCC_WARN_UNUSED_VARIABLE = YES;
+                               ONLY_ACTIVE_ARCH = YES;
+                               PREBINDING = NO;
+                               SDKROOT = macosx10.6;
+                       };
+                       name = Debug;
+               };
+               1DEB919508733D9F0010E9CD /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+                               GCC_WARN_ABOUT_RETURN_TYPE = YES;
+                               GCC_WARN_UNUSED_VARIABLE = YES;
+                               PREBINDING = NO;
+                               SDKROOT = macosx10.6;
+                       };
+                       name = Release;
+               };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+               1DEB918F08733D9F0010E9CD /* Build configuration list for PBXLegacyTarget "xcode_project" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               1DEB919008733D9F0010E9CD /* Debug */,
+                               1DEB919108733D9F0010E9CD /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
+               1DEB919308733D9F0010E9CD /* Build configuration list for PBXProject "xcode_project" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               1DEB919408733D9F0010E9CD /* Debug */,
+                               1DEB919508733D9F0010E9CD /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
+/* End XCConfigurationList section */
+       };
+       rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
+}
diff --git a/EmulatorPkg/Unix/build.sh b/EmulatorPkg/Unix/build.sh
new file mode 100755 (executable)
index 0000000..b7dc0bb
--- /dev/null
@@ -0,0 +1,137 @@
+#!/bin/bash
+#
+# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
+# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+#
+# 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.
+#
+
+set -e
+shopt -s nocasematch
+
+
+#
+# Setup workspace if it is not set
+#
+if [ -z "$WORKSPACE" ]
+then
+  echo Initializing workspace
+  if [ ! -e `pwd`/edksetup.sh ]
+  then
+    cd ../..
+  fi
+# This version is for the tools in the BaseTools project.
+# this assumes svn pulls have the same root dir
+#  export EDK_TOOLS_PATH=`pwd`/../BaseTools
+# This version is for the tools source in edk2
+  export EDK_TOOLS_PATH=`pwd`/BaseTools
+  echo $EDK_TOOLS_PATH
+  source edksetup.sh BaseTools
+else
+  echo Building from: $WORKSPACE
+fi
+
+#
+# Pick a default tool type for a given OS
+#
+UNIXPKG_TOOLS=GCC44
+NETWORK_SUPPORT=
+BUILD_NEW_SHELL=
+BUILD_FAT=
+case `uname` in
+  CYGWIN*) echo Cygwin not fully supported yet. ;;
+  Darwin*)
+      Major=$(uname -r | cut -f 1 -d '.')
+      if [[ $Major == 9 ]]
+      then
+        echo UnixPkg requires Snow Leopard or later OS
+        exit 1
+      else
+        TARGET_TOOLS=XCODE32
+        UNIXPKG_TOOLS=XCLANG
+      fi
+      BUILD_NEW_SHELL="-D BUILD_NEW_SHELL"
+      BUILD_FAT="-D BUILD_FAT"
+      ;;
+esac
+
+if [ -d /lib32 ]
+then
+  export LIB_ARCH_SFX=32
+fi
+
+if [ -z "$TARGET_TOOLS" ]
+then
+  TARGET_TOOLS=$UNIXPKG_TOOLS
+fi
+
+BUILD_ROOT_ARCH=$WORKSPACE/Build/EmuUnixIa32/DEBUG_"$UNIXPKG_TOOLS"/IA32
+
+if  [[ ! -f `which build` || ! -f `which GenFv` ]];
+then
+  # build the tools if they don't yet exist. Bin scheme
+  echo Building tools as they are not in the path
+  make -C $WORKSPACE/BaseTools
+elif [[ ( -f `which build` ||  -f `which GenFv` )  && ! -d  $EDK_TOOLS_PATH/Source/C/bin ]];
+then
+  # build the tools if they don't yet exist. BinWrapper scheme
+  echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
+  make -C $WORKSPACE/BaseTools
+else
+  echo using prebuilt tools
+fi
+
+
+for arg in "$@"
+do
+  if [[ $arg == run ]]; then
+    case `uname` in
+      Darwin*)
+        #
+        # On Darwin we can't use dlopen, so we have to load the real PE/COFF images.
+        # This .gdbinit script sets a breakpoint that loads symbols for the PE/COFFEE
+        # images that get loaded in SecMain
+        #
+        cp $WORKSPACE/EmulatorPkg/Unix/.gdbinit $WORKSPACE/Build/EmuUnixIa32/DEBUG_"$UNIXPKG_TOOLS"/IA32
+        ;;
+    esac
+
+    /usr/bin/gdb $BUILD_ROOT_ARCH/SecMain -q -cd=$BUILD_ROOT_ARCH -x $WORKSPACE/EmulatorPkg/Unix/GdbRun
+    exit
+  fi
+
+  if [[ $arg == cleanall ]]; then
+    make -C $WORKSPACE/BaseTools clean
+    build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc -a IA32 -t $TARGET_TOOLS -D SEC_ONLY -n 3 clean
+    build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc -a IA32 -t $UNIXPKG_TOOLS -n 3 clean
+    build -p $WORKSPACE/ShellPkg/ShellPkg.dsc -a IA32 -t $UNIXPKG_TOOLS -n 3 clean
+    exit $?
+  fi
+
+  if [[ $arg == clean ]]; then
+    build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc -a IA32 -t $TARGET_TOOLS -D SEC_ONLY -n 3 clean
+    build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc -a IA32 -t $UNIXPKG_TOOLS -n 3 clean
+    exit $?
+  fi
+
+done
+
+
+#
+# Build the edk2 UnixPkg
+#
+if [[ $TARGET_TOOLS == $UNIXPKG_TOOLS ]]; then
+  build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc      -a IA32 -t $UNIXPKG_TOOLS -D BUILD_32 -D UNIX_SEC_BUILD $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
+else
+  build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc      -a IA32 -t $TARGET_TOOLS  -D BUILD_32 -D UNIX_SEC_BUILD -D SKIP_MAIN_BUILD -n 3 $1 $2 $3 $4 $5 $6 $7 $8  modules
+  build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc      -a IA32 -t $UNIXPKG_TOOLS -D BUILD_32 $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
+  cp $WORKSPACE/Build/EmuUnixIa32/DEBUG_"$TARGET_TOOLS"/IA32/SecMain $WORKSPACE/Build/EmuUnixIa32/DEBUG_"$UNIXPKG_TOOLS"/IA32
+fi
+exit $?
+
diff --git a/EmulatorPkg/Unix/build64.sh b/EmulatorPkg/Unix/build64.sh
new file mode 100755 (executable)
index 0000000..25d14df
--- /dev/null
@@ -0,0 +1,138 @@
+#!/bin/bash
+#
+# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
+# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+#
+# 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.
+#
+
+set -e
+shopt -s nocasematch
+
+
+#
+# Setup workspace if it is not set
+#
+if [ -z "$WORKSPACE" ]
+then
+  echo Initializing workspace
+  if [ ! -e `pwd`/edksetup.sh ]
+  then
+    cd ../..
+  fi
+# This version is for the tools in the BaseTools project.
+# this assumes svn pulls have the same root dir
+#  export EDK_TOOLS_PATH=`pwd`/../BaseTools
+# This version is for the tools source in edk2
+  export EDK_TOOLS_PATH=`pwd`/BaseTools
+  echo $EDK_TOOLS_PATH
+  source edksetup.sh BaseTools
+else
+  echo Building from: $WORKSPACE
+fi
+
+#
+# Pick a default tool type for a given OS
+#
+UNIXPKG_TOOLS=GCC44
+NETWORK_SUPPORT=
+BUILD_NEW_SHELL=
+BUILD_FAT=
+case `uname` in
+  CYGWIN*) echo Cygwin not fully supported yet. ;;
+  Darwin*)
+      Major=$(uname -r | cut -f 1 -d '.')
+      if [[ $Major == 9 ]]
+      then
+        echo UnixPkg requires Snow Leopard or later OS
+        exit 1
+      else
+        TARGET_TOOLS=XCODE32
+        UNIXPKG_TOOLS=XCLANG
+      fi
+#      NETWORK_SUPPORT="-D NETWORK_SUPPORT"
+      BUILD_NEW_SHELL="-D BUILD_NEW_SHELL"
+      BUILD_FAT="-D BUILD_FAT"
+      ;;
+esac
+
+if [ -d /lib64 ]
+then
+  export LIB_ARCH_SFX=64
+fi
+
+if [ -z "$TARGET_TOOLS" ]
+then
+  TARGET_TOOLS=$UNIXPKG_TOOLS
+fi
+
+BUILD_ROOT_ARCH=$WORKSPACE/Build/EmuUnixX64/DEBUG_"$UNIXPKG_TOOLS"/X64
+
+if  [[ ! -f `which build` || ! -f `which GenFv` ]];
+then
+  # build the tools if they don't yet exist. Bin scheme
+  echo Building tools as they are not in the path
+  make -C $WORKSPACE/BaseTools
+elif [[ ( -f `which build` ||  -f `which GenFv` )  && ! -d  $EDK_TOOLS_PATH/Source/C/bin ]];
+then
+  # build the tools if they don't yet exist. BinWrapper scheme
+  echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
+  make -C $WORKSPACE/BaseTools
+else
+  echo using prebuilt tools
+fi
+
+
+for arg in "$@"
+do
+  if [[ $arg == run ]]; then
+    case `uname` in
+      Darwin*)
+        #
+        # On Darwin we can't use dlopen, so we have to load the real PE/COFF images.
+        # This .gdbinit script sets a breakpoint that loads symbols for the PE/COFFEE
+        # images that get loaded in SecMain
+        #
+        cp $WORKSPACE/EmulatorPkg/Unix/.gdbinit $WORKSPACE/Build/EmuUnixX64/DEBUG_"$UNIXPKG_TOOLS"/X64
+        ;;
+    esac
+
+    /usr/bin/gdb $BUILD_ROOT_ARCH/SecMain -q -cd=$BUILD_ROOT_ARCH -x $WORKSPACE/EmulatorPkg/Unix/GdbRun
+    exit
+  fi
+
+  if [[ $arg == cleanall ]]; then
+    make -C $WORKSPACE/BaseTools clean
+    build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc -a X64 -t $TARGET_TOOLS -D SEC_ONLY -n 3 clean
+    build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc -a X64 -t $UNIXPKG_TOOLS -n 3 clean
+    build -p $WORKSPACE/ShellPkg/ShellPkg.dsc -a X64 -t $UNIXPKG_TOOLS -n 3 clean
+    exit $?
+  fi
+
+  if [[ $arg == clean ]]; then
+    build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc -a X64 -t $TARGET_TOOLS -D SEC_ONLY -n 3 clean
+    build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc -a X64 -t $UNIXPKG_TOOLS -n 3 clean
+    exit $?
+  fi
+
+done
+
+
+#
+# Build the edk2 UnixPkg
+#
+if [[ $TARGET_TOOLS == $UNIXPKG_TOOLS ]]; then
+  build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc      -a X64 -t $UNIXPKG_TOOLS -D UNIX_SEC_BUILD $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
+else
+  build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc      -a X64 -t $TARGET_TOOLS  -D UNIX_SEC_BUILD -D SKIP_MAIN_BUILD -n 3 $1 $2 $3 $4 $5 $6 $7 $8  modules
+  build -p $WORKSPACE/EmulatorPkg/Unix/UnixX64.dsc      -a X64 -t $UNIXPKG_TOOLS $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
+  cp $WORKSPACE/Build/EmuUnixX64/DEBUG_"$TARGET_TOOLS"/X64/SecMain $WORKSPACE/Build/EmuUnixX64/DEBUG_"$UNIXPKG_TOOLS"/X64
+fi
+exit $?
+
diff --git a/EmulatorPkg/build.sh b/EmulatorPkg/build.sh
new file mode 100755 (executable)
index 0000000..28de82c
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
+#
+# 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.
+#
+
+cd Unix
+. build.sh $1 $2 $3 $4 $5 $6 $7 $8
+
diff --git a/EmulatorPkg/build64.sh b/EmulatorPkg/build64.sh
new file mode 100755 (executable)
index 0000000..a1d47b7
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
+#
+# 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.
+#
+
+cd Unix
+. build64.sh $1 $2 $3 $4 $5 $6 $7 $8
+
diff --git a/InOsEmuPkg/AutoScanPei/AutoScanPei.c b/InOsEmuPkg/AutoScanPei/AutoScanPei.c
deleted file mode 100644 (file)
index 78cdd34..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#include "PiPei.h"\r
-#include <Ppi/EmuThunk.h>\r
-#include <Ppi/MemoryDiscovered.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/PeimEntryPoint.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/PeiServicesTablePointerLib.h>\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PeimInitializeAutoScanPei (\r
-  IN       EFI_PEI_FILE_HANDLE       FileHandle,\r
-  IN CONST EFI_PEI_SERVICES          **PeiServices\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Perform a call-back into the SEC simulator to get a memory value\r
-\r
-Arguments:\r
-  FfsHeader   - General purpose data available to every PEIM\r
-  PeiServices - General purpose services available to every PEIM.\r
-    \r
-Returns:\r
-  None\r
-\r
-**/\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_PEI_PPI_DESCRIPTOR      *PpiDescriptor;\r
-  EMU_THUNK_PPI               *Thunk;\r
-  UINT64                      MemorySize;\r
-  EFI_PHYSICAL_ADDRESS        MemoryBase;\r
-  UINTN                       Index;\r
-  EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;\r
-\r
-\r
-  DEBUG ((EFI_D_ERROR, "Emu Autoscan PEIM Loaded\n"));\r
-\r
-  //\r
-  // Get the PEI UNIX Autoscan PPI\r
-  //\r
-  Status = PeiServicesLocatePpi (\r
-             &gEmuThunkPpiGuid,      // GUID\r
-             0,                      // INSTANCE\r
-             &PpiDescriptor,         // EFI_PEI_PPI_DESCRIPTOR\r
-             (VOID **)&Thunk         // PPI\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Index = 0;\r
-  do {\r
-    Status = Thunk->MemoryAutoScan (Index, &MemoryBase, &MemorySize);\r
-    if (!EFI_ERROR (Status)) {\r
-      Attributes =\r
-        (\r
-          EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
-          EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
-          EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
-          EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r
-          EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
-          EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE\r
-        );\r
-\r
-      if (Index == 0) {\r
-        //\r
-        // Register the memory with the PEI Core\r
-        //\r
-        Status = PeiServicesInstallPeiMemory (MemoryBase, MemorySize);\r
-        ASSERT_EFI_ERROR (Status);\r
-\r
-        Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED;\r
-      }\r
-      \r
-      BuildResourceDescriptorHob (\r
-        EFI_RESOURCE_SYSTEM_MEMORY,\r
-        Attributes,\r
-        MemoryBase,\r
-        MemorySize\r
-        );\r
-    }\r
-    Index++;\r
-  } while (!EFI_ERROR (Status));\r
-\r
-  //\r
-  // Build the CPU hob with 36-bit addressing and 16-bits of IO space.\r
-  //\r
-  BuildCpuHob (36, 16);\r
-  \r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/AutoScanPei/AutoScanPei.inf b/InOsEmuPkg/AutoScanPei/AutoScanPei.inf
deleted file mode 100644 (file)
index b8692ca..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-## @file\r
-# Component description file for EmuAutoScan module\r
-#\r
-# This module abstracts memory auto-scan in a Emu environment.\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = AutoScanPei\r
-  FILE_GUID                      = 2D6F6BCC-9681-8E42-8579-B57DCD0060F0\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = PeimInitializeAutoScanPei\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  AutoScanPei.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-#  MdeModulePkg/MdeModulePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  PeiServicesTablePointerLib\r
-  PeiServicesLib\r
-  HobLib\r
-  BaseMemoryLib\r
-  BaseLib\r
-  PeimEntryPoint\r
-  DebugLib\r
-\r
-\r
-[Ppis]\r
-  gEfiPeiMemoryDiscoveredPpiGuid                # PPI ALWAYS_PRODUCED\r
-  gEmuThunkPpiGuid                              # PPI ALWAYS_CONSUMED\r
-\r
-\r
-[Depex]\r
-  gEmuThunkPpiGuid AND gEfiPeiMasterBootModePpiGuid\r
-\r
diff --git a/InOsEmuPkg/BootModePei/BootModePei.c b/InOsEmuPkg/BootModePei/BootModePei.c
deleted file mode 100644 (file)
index e26e929..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-\r
-\r
-//\r
-// The package level header files this module uses\r
-//\r
-#include <PiPei.h>\r
-\r
-#include <Library/PcdLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-\r
-\r
-//\r
-// The protocols, PPI and GUID defintions for this module\r
-//\r
-#include <Ppi/MasterBootMode.h>\r
-#include <Ppi/BootInRecoveryMode.h>\r
-//\r
-// The Library classes this module consumes\r
-//\r
-#include <Library/DebugLib.h>\r
-#include <Library/PeimEntryPoint.h>\r
-\r
-\r
-//\r
-// Module globals\r
-//\r
-EFI_PEI_PPI_DESCRIPTOR  mPpiListBootMode = {\r
-  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
-  &gEfiPeiMasterBootModePpiGuid,\r
-  NULL\r
-};\r
-\r
-EFI_PEI_PPI_DESCRIPTOR  mPpiListRecoveryBootMode = {\r
-  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
-  &gEfiPeiBootInRecoveryModePpiGuid,\r
-  NULL\r
-};\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeBootMode (\r
-  IN       EFI_PEI_FILE_HANDLE       FileHandle,\r
-  IN CONST EFI_PEI_SERVICES          **PeiServices\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Peform the boot mode determination logic\r
-\r
-Arguments:\r
-\r
-  PeiServices - General purpose services available to every PEIM.\r
-    \r
-Returns:\r
-\r
-  Status -  EFI_SUCCESS if the boot mode could be set\r
-\r
-**/\r
-{\r
-  EFI_STATUS    Status;\r
-  EFI_BOOT_MODE BootMode;\r
-\r
-  DEBUG ((EFI_D_ERROR, "Emu Boot Mode PEIM Loaded\n"));\r
-\r
-  BootMode  = FixedPcdGet32 (PcdEmuBootMode);\r
-\r
-  Status    = PeiServicesSetBootMode (BootMode);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = PeiServicesInstallPpi (&mPpiListBootMode);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  if (BootMode == BOOT_IN_RECOVERY_MODE) {\r
-    Status = PeiServicesInstallPpi (&mPpiListRecoveryBootMode);\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/BootModePei/BootModePei.inf b/InOsEmuPkg/BootModePei/BootModePei.inf
deleted file mode 100644 (file)
index d162552..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-## @file\r
-# Component description file for BootMode module\r
-#\r
-# This module provides platform specific function to detect boot mode.\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = BootModePei\r
-  FILE_GUID                      = 64196C76-58E3-0B4D-9484-B54F7C4349CA\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = InitializeBootMode\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  BootModePei.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  PeiServicesTablePointerLib\r
-  PeiServicesLib\r
-  BaseLib\r
-  PeimEntryPoint\r
-  DebugLib\r
-\r
-\r
-[Ppis]\r
-  gEfiPeiMasterBootModePpiGuid                  # PPI ALWAYS_PRODUCED\r
-  gEfiPeiBootInRecoveryModePpiGuid              # PPI SOMETIMES_PRODUCED\r
-\r
-[FixedPcd]\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuBootMode\r
-\r
-[Depex]\r
-  TRUE\r
-\r
diff --git a/InOsEmuPkg/CpuRuntimeDxe/Cpu.c b/InOsEmuPkg/CpuRuntimeDxe/Cpu.c
deleted file mode 100644 (file)
index 5ec315b..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-/*++ @file\r
-  Emu driver to produce CPU Architectural Protocol.\r
-  \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "CpuDriver.h"\r
-\r
-UINT64  mTimerPeriod;\r
-\r
-CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {\r
-  CPU_ARCH_PROT_PRIVATE_SIGNATURE,\r
-  NULL,\r
-  {\r
-    EmuFlushCpuDataCache,\r
-    EmuEnableInterrupt,\r
-    EmuDisableInterrupt,\r
-    EmuGetInterruptState,\r
-    EmuInit,\r
-    EmuRegisterInterruptHandler,\r
-    EmuGetTimerValue,\r
-    EmuSetMemoryAttributes,\r
-    0,\r
-    4\r
-  },\r
-  {\r
-    {\r
-      CpuMemoryServiceRead,\r
-      CpuMemoryServiceWrite\r
-    },\r
-    {\r
-      CpuIoServiceRead,\r
-      CpuIoServiceWrite\r
-    }\r
-  },\r
-  TRUE\r
-};\r
-\r
-#define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100\r
-\r
-\r
-\r
-//\r
-// Service routines for the driver\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-EmuFlushCpuDataCache (\r
-  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
-  IN EFI_PHYSICAL_ADDRESS   Start,\r
-  IN UINT64                 Length,\r
-  IN EFI_CPU_FLUSH_TYPE     FlushType\r
-  )\r
-{\r
-  if (FlushType == EfiCpuFlushTypeWriteBackInvalidate) {\r
-    //\r
-    // Only WB flush is supported. We actually need do nothing on Emu emulator\r
-    // environment. Classify this to follow EFI spec\r
-    //\r
-    return EFI_SUCCESS;\r
-  }\r
-  //\r
-  // Other flush types are not supported by Emu emulator\r
-  //\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuEnableInterrupt (\r
-  IN EFI_CPU_ARCH_PROTOCOL  *This\r
-  )\r
-{\r
-  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
-\r
-  Private                 = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
-  Private->InterruptState = TRUE;\r
-  gEmuThunk->EnableInterrupt ();\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuDisableInterrupt (\r
-  IN EFI_CPU_ARCH_PROTOCOL  *This\r
-  )\r
-{\r
-  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
-\r
-  Private                 = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
-  Private->InterruptState = FALSE;\r
-  gEmuThunk->DisableInterrupt ();\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGetInterruptState (\r
-  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
-  OUT BOOLEAN               *State\r
-  )\r
-{\r
-  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
-\r
-  if (State == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
-  *State  = Private->InterruptState;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuInit (\r
-  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
-  IN EFI_CPU_INIT_TYPE      InitType\r
-  )\r
-{\r
-  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
-\r
-  Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuRegisterInterruptHandler (\r
-  IN EFI_CPU_ARCH_PROTOCOL      *This,\r
-  IN EFI_EXCEPTION_TYPE         InterruptType,\r
-  IN EFI_CPU_INTERRUPT_HANDLER  InterruptHandler\r
-  )\r
-{\r
-  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
-\r
-  //\r
-  // Do parameter checking for EFI spec conformance\r
-  //\r
-  if (InterruptType < 0 || InterruptType > 0xff) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Do nothing for Emu emulation\r
-  //\r
-  Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGetTimerValue (\r
-  IN  EFI_CPU_ARCH_PROTOCOL *This,\r
-  IN  UINT32                TimerIndex,\r
-  OUT UINT64                *TimerValue,\r
-  OUT UINT64                *TimerPeriod OPTIONAL\r
-  )\r
-{\r
-  if (TimerValue == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (TimerIndex != 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  *TimerValue = gEmuThunk->QueryPerformanceCounter ();\r
-  \r
-  if (TimerPeriod != NULL) {\r
-    *TimerPeriod = mTimerPeriod;\r
-  } \r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSetMemoryAttributes (\r
-  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
-  IN EFI_PHYSICAL_ADDRESS   BaseAddress,\r
-  IN UINT64                 Length,\r
-  IN UINT64                 Attributes\r
-  )\r
-{\r
-  CPU_ARCH_PROTOCOL_PRIVATE *Private;\r
-\r
-  //\r
-  // Check for invalid parameter for Spec conformance\r
-  //\r
-  if (Length == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Do nothing for Nt32 emulation\r
-  //\r
-  Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-\r
-\r
-/**\r
-  Logs SMBIOS record.\r
-\r
-  @param  Smbios   Pointer to SMBIOS protocol instance.\r
-  @param  Buffer   Pointer to the data buffer.\r
-\r
-**/\r
-VOID\r
-LogSmbiosData (\r
-  IN  EFI_SMBIOS_PROTOCOL        *Smbios,\r
-  IN  UINT8                      *Buffer\r
-  )\r
-{\r
-  EFI_STATUS         Status;\r
-  EFI_SMBIOS_HANDLE  SmbiosHandle;\r
-  \r
-  SmbiosHandle = 0;\r
-  Status = Smbios->Add (\r
-                     Smbios,\r
-                     NULL,\r
-                     &SmbiosHandle,\r
-                     (EFI_SMBIOS_TABLE_HEADER*)Buffer\r
-                     );\r
-  ASSERT_EFI_ERROR (Status);\r
-}\r
-\r
-VOID\r
-CpuUpdateSmbios (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  UINT32                      TotalSize;\r
-  EFI_SMBIOS_PROTOCOL         *Smbios;\r
-  EFI_HII_HANDLE              HiiHandle;\r
-  STRING_REF                  Token;\r
-  UINTN                       CpuVerStrLen;\r
-  EFI_STRING                  CpuVerStr;\r
-  SMBIOS_TABLE_TYPE4          *SmbiosRecord;\r
-  CHAR8                       *OptionalStrStart;\r
-\r
-  //\r
-  // Locate Smbios protocol.\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);\r
-  \r
-  if (EFI_ERROR (Status)) {\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Initialize strings to HII database\r
-  //\r
-  HiiHandle = HiiAddPackages (\r
-                &gEfiCallerIdGuid,\r
-                NULL,\r
-                CpuStrings,\r
-                NULL\r
-                );\r
-  ASSERT (HiiHandle != NULL);\r
-\r
-  Token  = STRING_TOKEN (STR_PROCESSOR_VERSION);\r
-  CpuVerStr = HiiGetPackageString(&gEfiCallerIdGuid, Token, NULL);\r
-  CpuVerStrLen = StrLen(CpuVerStr);\r
-  ASSERT (CpuVerStrLen <= SMBIOS_STRING_MAX_LENGTH);\r
-\r
-  TotalSize = sizeof(SMBIOS_TABLE_TYPE4) + CpuVerStrLen + 1 + 1;\r
-  SmbiosRecord = AllocatePool(TotalSize);\r
-  ZeroMem(SmbiosRecord, TotalSize);\r
-\r
-  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE4);\r
-  //\r
-  // Make handle chosen by smbios protocol.add automatically.\r
-  //\r
-  SmbiosRecord->Hdr.Handle = 0;  \r
-  //\r
-  // Processor version is the 1st string.\r
-  //\r
-  SmbiosRecord->ProcessorVersion = 1;\r
-  //\r
-  // Store CPU frequency data record to data hub - It's an emulator so make up a value\r
-  //\r
-  SmbiosRecord->CurrentSpeed  = 1234;\r
-\r
-  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
-  UnicodeStrToAsciiStr(CpuVerStr, OptionalStrStart);\r
-\r
-  //\r
-  // Now we have got the full smbios record, call smbios protocol to add this record.\r
-  //\r
-  LogSmbiosData(Smbios, (UINT8 *) SmbiosRecord);\r
-  FreePool (SmbiosRecord);\r
-}\r
-\r
-\r
-\r
-/**\r
-  Callback function for idle events.\r
\r
-  @param  Event                 Event whose notification function is being invoked.\r
-  @param  Context               The pointer to the notification function's context,\r
-                                which is implementation-dependent.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-IdleLoopEventCallback (\r
-  IN EFI_EVENT                Event,\r
-  IN VOID                     *Context\r
-  )\r
-{\r
-  gEmuThunk->CpuSleep ();\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeCpu (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  UINT64        Frequency;\r
-  EFI_EVENT     IdleLoopEvent;\r
-\r
-  //\r
-  // Retrieve the frequency of the performance counter in Hz.\r
-  //  \r
-  Frequency = gEmuThunk->QueryPerformanceFrequency ();\r
-  \r
-  //\r
-  // Convert frequency in Hz to a clock period in femtoseconds.\r
-  //\r
-  mTimerPeriod = DivU64x64Remainder (1000000000000000ULL, Frequency, NULL);\r
-\r
-  CpuUpdateSmbios ();\r
-  \r
-  CpuMpServicesInit ();\r
-  \r
-  Status = gBS->CreateEventEx (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  IdleLoopEventCallback,\r
-                  NULL,\r
-                  &gIdleLoopEventGuid,\r
-                  &IdleLoopEvent\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &mCpuTemplate.Handle,\r
-                  &gEfiCpuArchProtocolGuid,   &mCpuTemplate.Cpu,\r
-                  &gEfiCpuIo2ProtocolGuid,    &mCpuTemplate.CpuIo,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/CpuRuntimeDxe/Cpu.inf b/InOsEmuPkg/CpuRuntimeDxe/Cpu.inf
deleted file mode 100644 (file)
index d548c8a..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-## @file\r
-# Component description file for Cpu module.\r
-#\r
-# This CPU module abstracts the interrupt subsystem of a platform and the CPU-specific setjump-long pair.\r
-#\r
-# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = Cpu\r
-  FILE_GUID                      = f3794b60-8985-11db-8e53-0040d02b1835\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = InitializeCpu\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  CpuIo.c\r
-  Cpu.c\r
-  CpuDriver.h\r
-  Strings.uni\r
-  MpService.c\r
-  \r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  UefiDriverEntryPoint\r
-  UefiLib\r
-  HiiLib\r
-  DebugLib\r
-  BaseLib\r
-  EmuThunkLib\r
-  PcdLib\r
-\r
-[Protocols]\r
-  gEmuIoThunkProtocolGuid                       # PROTOCOL_NOTIFY SOMETIMES_CONSUMED\r
-  gEfiSmbiosProtocolGuid                        # PROTOCOL SOMETIMES_CONSUMED\r
-  gEfiHiiProtocolGuid                           # PROTOCOL SOMETIMES_CONSUMED\r
-  gEfiCpuIo2ProtocolGuid                        # PROTOCOL ALWAYS_PRODUCED\r
-  gEfiCpuArchProtocolGuid                       # PROTOCOL ALWAYS_PRODUCED\r
-  gEmuThreadThunkProtocolGuid\r
-  gEfiMpServiceProtocolGuid\r
-\r
-[Guids]\r
-  gIdleLoopEventGuid                            ## CONSUMES ## GUID\r
-\r
-[Pcd]\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuMpServicesPollingInterval\r
-\r
-[Depex]\r
-  gEfiSmbiosProtocolGuid\r
diff --git a/InOsEmuPkg/CpuRuntimeDxe/CpuDriver.h b/InOsEmuPkg/CpuRuntimeDxe/CpuDriver.h
deleted file mode 100644 (file)
index 69505ff..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#ifndef _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_\r
-#define _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_\r
-\r
-\r
-#include <FrameworkDxe.h>\r
-#include <IndustryStandard/SmBios.h>\r
-\r
-#include <Protocol/Cpu.h>\r
-#include <Protocol/Smbios.h>\r
-#include <Protocol/FrameworkHii.h>\r
-#include <Protocol/MpService.h>\r
-#include <Protocol/EmuThread.h>\r
-#include <Protocol/CpuIo2.h>\r
-\r
-#include <Guid/DataHubRecords.h>\r
-#include <Guid/IdleLoopEvent.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/EmuThunkLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-\r
-extern UINT8  CpuStrings[];\r
-\r
-//\r
-// Internal Data Structures\r
-//\r
-#define CPU_ARCH_PROT_PRIVATE_SIGNATURE SIGNATURE_32 ('c', 'a', 'p', 'd')\r
-\r
-typedef struct {\r
-  UINTN                 Signature;\r
-  EFI_HANDLE            Handle;\r
-\r
-  EFI_CPU_ARCH_PROTOCOL Cpu;\r
-  EFI_CPU_IO2_PROTOCOL  CpuIo;\r
-\r
-  //\r
-  // Local Data for CPU interface goes here\r
-  //\r
-  BOOLEAN               InterruptState;\r
-\r
-} CPU_ARCH_PROTOCOL_PRIVATE;\r
-\r
-#define CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \\r
-  CR (a, \\r
-      CPU_ARCH_PROTOCOL_PRIVATE, \\r
-      Cpu, \\r
-      CPU_ARCH_PROT_PRIVATE_SIGNATURE \\r
-      )\r
-\r
-\r
-\r
-typedef enum {\r
-  CPU_STATE_IDLE,\r
-  CPU_STATE_BLOCKED,\r
-  CPU_STATE_READY,\r
-  CPU_STATE_BUSY,\r
-  CPU_STATE_FINISHED\r
-} PROCESSOR_STATE;\r
-\r
-\r
-//\r
-// Define Individual Processor Data block.\r
-//\r
-typedef struct {\r
-  EFI_PROCESSOR_INFORMATION   Info;\r
-  EFI_AP_PROCEDURE            Procedure;\r
-  VOID                        *Parameter;\r
-  VOID                        *StateLock;\r
-  VOID                        *ProcedureLock;\r
-  PROCESSOR_STATE             State;\r
-  EFI_EVENT                   CheckThisAPEvent;   \r
-} PROCESSOR_DATA_BLOCK;\r
-\r
-\r
-//\r
-// Define MP data block which consumes individual processor block.\r
-//\r
-typedef struct {\r
-  UINTN                       NumberOfProcessors;\r
-  UINTN                       NumberOfEnabledProcessors;\r
-  EFI_EVENT                   CheckAllAPsEvent;\r
-  EFI_EVENT                   WaitEvent;\r
-  UINTN                       FinishCount;\r
-  UINTN                       StartCount;\r
-  EFI_AP_PROCEDURE            Procedure;\r
-  VOID                        *ProcedureArgument;\r
-  BOOLEAN                     SingleThread;\r
-  UINTN                       StartedNumber;\r
-  PROCESSOR_DATA_BLOCK        *ProcessorData;\r
-  UINTN                       Timeout;\r
-  UINTN                       *FailedList;\r
-  UINTN                       FailedListIndex;\r
-  BOOLEAN                     TimeoutActive;\r
-} MP_SYSTEM_DATA;\r
-\r
-\r
-\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceRead (\r
-  IN  EFI_CPU_IO2_PROTOCOL              *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
-  IN  UINT64                            Address,\r
-  IN  UINTN                             Count,\r
-  IN  OUT VOID                          *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceWrite (\r
-  IN EFI_CPU_IO2_PROTOCOL               *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
-  IN  UINT64                            Address,\r
-  IN  UINTN                             Count,\r
-  IN  OUT VOID                          *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceRead (\r
-  IN EFI_CPU_IO2_PROTOCOL               *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
-  IN  UINT64                            UserAddress,\r
-  IN  UINTN                             Count,\r
-  IN  OUT VOID                          *UserBuffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceWrite (\r
-  IN EFI_CPU_IO2_PROTOCOL               *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
-  IN  UINT64                            UserAddress,\r
-  IN  UINTN                             Count,\r
-  IN  OUT VOID                          *UserBuffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeCpu (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuFlushCpuDataCache (\r
-  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
-  IN EFI_PHYSICAL_ADDRESS   Start,\r
-  IN UINT64                 Length,\r
-  IN EFI_CPU_FLUSH_TYPE     FlushType\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuEnableInterrupt (\r
-  IN EFI_CPU_ARCH_PROTOCOL  *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuDisableInterrupt (\r
-  IN EFI_CPU_ARCH_PROTOCOL  *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGetInterruptState (\r
-  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
-  OUT BOOLEAN               *State\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuInit (\r
-  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
-  IN EFI_CPU_INIT_TYPE      InitType\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuRegisterInterruptHandler (\r
-  IN EFI_CPU_ARCH_PROTOCOL      *This,\r
-  IN EFI_EXCEPTION_TYPE         InterruptType,\r
-  IN EFI_CPU_INTERRUPT_HANDLER  InterruptHandler\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGetTimerValue (\r
-  IN  EFI_CPU_ARCH_PROTOCOL *This,\r
-  IN  UINT32                TimerIndex,\r
-  OUT UINT64                *TimerValue,\r
-  OUT UINT64                *TimerPeriod OPTIONAL\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSetMemoryAttributes (\r
-  IN EFI_CPU_ARCH_PROTOCOL  *This,\r
-  IN EFI_PHYSICAL_ADDRESS   BaseAddress,\r
-  IN UINT64                 Length,\r
-  IN UINT64                 Attributes\r
-  );\r
-\r
-EFI_STATUS\r
-CpuMpServicesInit (\r
-  VOID\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMpServicesWhoAmI (\r
-  IN EFI_MP_SERVICES_PROTOCOL  *This,\r
-  OUT UINTN                    *ProcessorNumber\r
-  );\r
-\r
-extern EFI_MP_SERVICES_PROTOCOL  mMpSercicesTemplate;\r
-\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/CpuRuntimeDxe/CpuIo.c b/InOsEmuPkg/CpuRuntimeDxe/CpuIo.c
deleted file mode 100644 (file)
index 6f63375..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-/*++ @file\r
-  This is the code that publishes the CPU I/O Protocol.\r
-  The intent herein is to have a single I/O service that can load\r
-  as early as possible, extend into runtime, and be layered upon by \r
-  the implementations of architectural protocols and the PCI Root\r
-  Bridge I/O Protocol.\r
-\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#include <FrameworkDxe.h>\r
-#include <Protocol/Cpu.h>\r
-#include <Protocol/DataHub.h>\r
-#include <Guid/DataHubRecords.h>\r
-#include <Protocol/CpuIo2.h>\r
-#include <Protocol/FrameworkHii.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <CpuDriver.h>\r
-\r
-#define IA32_MAX_IO_ADDRESS   0xFFFF\r
-#define IA32_MAX_MEM_ADDRESS  0xFFFFFFFF\r
-\r
-EFI_STATUS\r
-CpuIoCheckAddressRange (\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
-  IN  UINT64                            Address,\r
-  IN  UINTN                             Count,\r
-  IN  VOID                              *Buffer,\r
-  IN  UINT64                            Limit\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceRead (\r
-  IN  EFI_CPU_IO2_PROTOCOL              *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
-  IN  UINT64                            Address,\r
-  IN  UINTN                             Count,\r
-  IN  OUT VOID                          *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Perform the Memory Access Read service for the CPU I/O Protocol\r
-\r
-Arguments:\r
-\r
-  Pointer to an instance of the CPU I/O Protocol\r
-  Width of the Memory Access\r
-  Address of the Memory access\r
-  Count of the number of accesses to perform\r
-  Pointer to the buffer to read or write from memory\r
-\r
-Returns:\r
-\r
-  Status\r
-\r
-  EFI_SUCCESS             - The data was read from or written to the EFI \r
-                            System.\r
-  EFI_INVALID_PARAMETER   - Width is invalid for this EFI System.\r
-  EFI_INVALID_PARAMETER   - Buffer is NULL.\r
-  EFI_UNSUPPORTED         - The Buffer is not aligned for the given Width.\r
-  EFI_UNSUPPORTED         - The address range specified by Address, Width, \r
-                            and Count is not valid for this EFI System.\r
-\r
-**/\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  if (!Buffer) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Do nothing for Nt32 version\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceWrite (\r
-  IN EFI_CPU_IO2_PROTOCOL               *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
-  IN  UINT64                            Address,\r
-  IN  UINTN                             Count,\r
-  IN  OUT VOID                          *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Perform the Memory Access Read service for the CPU I/O Protocol\r
-\r
-Arguments:\r
-\r
-  Pointer to an instance of the CPU I/O Protocol\r
-  Width of the Memory Access\r
-  Address of the Memory access\r
-  Count of the number of accesses to perform\r
-  Pointer to the buffer to read or write from memory\r
-\r
-Returns:\r
-\r
-  Status\r
-\r
-  EFI_SUCCESS             - The data was read from or written to the EFI System.\r
-  EFI_INVALID_PARAMETER   - Width is invalid for this EFI System.\r
-  EFI_INVALID_PARAMETER   - Buffer is NULL.\r
-  EFI_UNSUPPORTED         - The Buffer is not aligned for the given Width.\r
-  EFI_UNSUPPORTED         - The address range specified by Address, Width, and \r
-                            Count is not valid for this EFI System.\r
-\r
-**/\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  if (!Buffer) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = CpuIoCheckAddressRange (Width, Address, Count, Buffer, IA32_MAX_MEM_ADDRESS);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Do nothing for Nt32 version\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceRead (\r
-  IN EFI_CPU_IO2_PROTOCOL               *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
-  IN  UINT64                            UserAddress,\r
-  IN  UINTN                             Count,\r
-  IN  OUT VOID                          *UserBuffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  This is the service that implements the I/O read\r
-\r
-Arguments:\r
-\r
-  Pointer to an instance of the CPU I/O Protocol\r
-  Width of the Memory Access\r
-  Address of the I/O access\r
-  Count of the number of accesses to perform\r
-  Pointer to the buffer to read or write from I/O space\r
-\r
-Returns:\r
-\r
-  Status\r
-  EFI_SUCCESS             - The data was read from or written to the EFI System.\r
-  EFI_INVALID_PARAMETER   - Width is invalid for this EFI System.\r
-  EFI_INVALID_PARAMETER   - Buffer is NULL.\r
-  EFI_UNSUPPORTED         - The Buffer is not aligned for the given Width.\r
-  EFI_UNSUPPORTED         - The address range specified by Address, Width, and \r
-                            Count is not valid for this EFI System.\r
-**/\r
-{\r
-  UINTN       Address;\r
-  EFI_STATUS  Status;\r
-\r
-  if (!UserBuffer) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Address = (UINTN) UserAddress;\r
-\r
-  if (Width >= EfiCpuIoWidthMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = CpuIoCheckAddressRange (Width, Address, Count, UserBuffer, IA32_MAX_IO_ADDRESS);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Do nothing for Nt32 version\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceWrite (\r
-  IN EFI_CPU_IO2_PROTOCOL               *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
-  IN  UINT64                            UserAddress,\r
-  IN  UINTN                             Count,\r
-  IN  OUT VOID                          *UserBuffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  \r
-  This is the service that implements the I/O Write\r
-\r
-Arguments:\r
-\r
-  Pointer to an instance of the CPU I/O Protocol\r
-  Width of the Memory Access\r
-  Address of the I/O access\r
-  Count of the number of accesses to perform\r
-  Pointer to the buffer to read or write from I/O space\r
-\r
-Returns:\r
-\r
-  Status\r
-\r
-  Status\r
-  EFI_SUCCESS             - The data was read from or written to the EFI System.\r
-  EFI_INVALID_PARAMETER   - Width is invalid for this EFI System.\r
-  EFI_INVALID_PARAMETER   - Buffer is NULL.\r
-  EFI_UNSUPPORTED         - The Buffer is not aligned for the given Width.\r
-  EFI_UNSUPPORTED         - The address range specified by Address, Width, and \r
-                            Count is not valid for this EFI System.\r
-\r
-**/\r
-{\r
-  UINTN       Address;\r
-  EFI_STATUS  Status;\r
-\r
-  if (!UserBuffer) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Address = (UINTN) UserAddress;\r
-\r
-  if (Width >= EfiCpuIoWidthMaximum) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = CpuIoCheckAddressRange (Width, Address, Count, UserBuffer, IA32_MAX_IO_ADDRESS);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Do nothing for Nt32 version\r
-  //\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-  Width   - TODO: add argument description\r
-  Address - TODO: add argument description\r
-  Count   - TODO: add argument description\r
-  Buffer  - TODO: add argument description\r
-  Limit   - TODO: add argument description\r
-\r
-Returns:\r
-\r
-  EFI_UNSUPPORTED - TODO: Add description for return value\r
-  EFI_UNSUPPORTED - TODO: Add description for return value\r
-  EFI_UNSUPPORTED - TODO: Add description for return value\r
-  EFI_SUCCESS - TODO: Add description for return value\r
-\r
-**/\r
-EFI_STATUS\r
-CpuIoCheckAddressRange (\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH         Width,\r
-  IN  UINT64                            Address,\r
-  IN  UINTN                             Count,\r
-  IN  VOID                              *Buffer,\r
-  IN  UINT64                            Limit\r
-  )\r
-{\r
-  UINTN AlignMask;\r
-\r
-  if (Address > Limit) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // For FiFo type, the target address won't increase during the access, so treat count as 1\r
-  //\r
-  if (Width >= EfiCpuIoWidthFifoUint8 && Width <= EfiCpuIoWidthFifoUint64) {\r
-    Count = 1;\r
-  }\r
-\r
-  Width = Width & 0x03;\r
-  if (Address - 1 + (1 << Width) * Count > Limit) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  AlignMask = (1 << Width) - 1;\r
-  if ((UINTN) Buffer & AlignMask) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
diff --git a/InOsEmuPkg/CpuRuntimeDxe/MpService.c b/InOsEmuPkg/CpuRuntimeDxe/MpService.c
deleted file mode 100644 (file)
index 7f3b199..0000000
+++ /dev/null
@@ -1,1366 +0,0 @@
-/** @file\r
-  Construct MP Services Protocol on top of the EMU Thread protocol.\r
-  This code makes APs show up in the emulator. PcdEmuApCount is the\r
-  number of APs the emulator should produce.\r
-\r
-  The MP Services Protocol provides a generalized way of performing following tasks:\r
-    - Retrieving information of multi-processor environment and MP-related status of\r
-      specific processors.\r
-    - Dispatching user-provided function to APs.\r
-    - Maintain MP-related processor status.\r
-\r
-  The MP Services Protocol must be produced on any system with more than one logical\r
-  processor.\r
-\r
-  The Protocol is available only during boot time.\r
-\r
-  MP Services Protocol is hardware-independent. Most of the logic of this protocol\r
-  is architecturally neutral. It abstracts the multi-processor environment and \r
-  status of processors, and provides interfaces to retrieve information, maintain, \r
-  and dispatch.\r
-\r
-  MP Services Protocol may be consumed by ACPI module. The ACPI module may use this \r
-  protocol to retrieve data that are needed for an MP platform and report them to OS.\r
-  MP Services Protocol may also be used to program and configure processors, such \r
-  as MTRR synchronization for memory space attributes setting in DXE Services.\r
-  MP Services Protocol may be used by non-CPU DXE drivers to speed up platform boot \r
-  by taking advantage of the processing capabilities of the APs, for example, using \r
-  APs to help test system memory in parallel with other device initialization.\r
-  Diagnostics applications may also use this protocol for multi-processor.\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-Portitions Copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials are licensed and made available under\r
-the terms and conditions of the BSD License that accompanies this distribution.\r
-The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php.\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-**/\r
-\r
-#include "CpuDriver.h"\r
-\r
-\r
-MP_SYSTEM_DATA                gMPSystem;\r
-EMU_THREAD_THUNK_PROTOCOL     *gThread = NULL; \r
-EFI_EVENT                     gReadToBootEvent;\r
-BOOLEAN                       gReadToBoot = FALSE;\r
-UINTN                         gPollInterval;\r
-\r
-\r
-BOOLEAN\r
-IsBSP (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       ProcessorNumber;\r
-  \r
-  Status = CpuMpServicesWhoAmI (&mMpSercicesTemplate, &ProcessorNumber);\r
-  if (EFI_ERROR (Status)) {\r
-    return FALSE;\r
-  }\r
-  \r
-  return (gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0;\r
-}\r
-\r
-\r
-VOID\r
-SetApProcedure (\r
-  IN   PROCESSOR_DATA_BLOCK  *Processor,\r
-  IN   EFI_AP_PROCEDURE      Procedure,\r
-  IN   VOID                  *ProcedureArgument\r
-  )\r
-{\r
-  gThread->MutexLock (Processor->ProcedureLock);\r
-  Processor->Parameter  = ProcedureArgument;\r
-  Processor->Procedure  = Procedure;\r
-  gThread->MutexUnlock (Processor->ProcedureLock);\r
-}\r
-\r
-\r
-EFI_STATUS\r
-GetNextBlockedNumber (\r
-  OUT UINTN                               *NextNumber\r
-  )\r
-{\r
-  UINTN                 Number;\r
-  PROCESSOR_STATE       ProcessorState;\r
-  PROCESSOR_DATA_BLOCK  *Data;\r
-\r
-  for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {\r
-    Data = &gMPSystem.ProcessorData[Number];\r
-    if ((Data->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0) {\r
-      // Skip BSP\r
-      continue;\r
-    }\r
-\r
-    gThread->MutexLock (Data->StateLock);\r
-    ProcessorState = Data->State;\r
-    gThread->MutexUnlock (Data->StateLock);\r
-\r
-    if (ProcessorState == CPU_STATE_BLOCKED) {\r
-      *NextNumber = Number;\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-\r
-\r
-/**\r
-  This service retrieves the number of logical processor in the platform\r
-  and the number of those logical processors that are enabled on this boot.\r
-  This service may only be called from the BSP.\r
-\r
-  This function is used to retrieve the following information:\r
-    - The number of logical processors that are present in the system.\r
-    - The number of enabled logical processors in the system at the instant \r
-      this call is made.\r
-\r
-  Because MP Service Protocol provides services to enable and disable processors \r
-  dynamically, the number of enabled logical processors may vary during the \r
-  course of a boot session.\r
-  \r
-  If this service is called from an AP, then EFI_DEVICE_ERROR is returned. \r
-  If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then \r
-  EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors \r
-  is returned in NumberOfProcessors, the number of currently enabled processor \r
-  is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.\r
-\r
-  @param[in]  This                        A pointer to the EFI_MP_SERVICES_PROTOCOL\r
-                                          instance.\r
-  @param[out] NumberOfProcessors          Pointer to the total number of logical\r
-                                          processors in the system, including the BSP\r
-                                          and disabled APs.\r
-  @param[out] NumberOfEnabledProcessors   Pointer to the number of enabled logical\r
-                                          processors that exist in system, including\r
-                                          the BSP.\r
-\r
-  @retval EFI_SUCCESS             The number of logical processors and enabled \r
-                                  logical processors was retrieved.\r
-  @retval EFI_DEVICE_ERROR        The calling processor is an AP.\r
-  @retval EFI_INVALID_PARAMETER   NumberOfProcessors is NULL.\r
-  @retval EFI_INVALID_PARAMETER   NumberOfEnabledProcessors is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMpServicesGetNumberOfProcessors (\r
-  IN  EFI_MP_SERVICES_PROTOCOL  *This,\r
-  OUT UINTN                     *NumberOfProcessors,\r
-  OUT UINTN                     *NumberOfEnabledProcessors\r
-  )\r
-{\r
-  if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  if (!IsBSP ()) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  \r
-  *NumberOfProcessors        = gMPSystem.NumberOfProcessors;\r
-  *NumberOfEnabledProcessors = gMPSystem.NumberOfEnabledProcessors;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
-/**\r
-  Gets detailed MP-related information on the requested processor at the\r
-  instant this call is made. This service may only be called from the BSP.\r
-\r
-  This service retrieves detailed MP-related information about any processor \r
-  on the platform. Note the following:\r
-    - The processor information may change during the course of a boot session.\r
-    - The information presented here is entirely MP related.\r
-  \r
-  Information regarding the number of caches and their sizes, frequency of operation,\r
-  slot numbers is all considered platform-related information and is not provided \r
-  by this service.\r
-\r
-  @param[in]  This                  A pointer to the EFI_MP_SERVICES_PROTOCOL\r
-                                    instance.\r
-  @param[in]  ProcessorNumber       The handle number of processor.\r
-  @param[out] ProcessorInfoBuffer   A pointer to the buffer where information for\r
-                                    the requested processor is deposited.\r
-\r
-  @retval EFI_SUCCESS             Processor information was returned.\r
-  @retval EFI_DEVICE_ERROR        The calling processor is an AP.\r
-  @retval EFI_INVALID_PARAMETER   ProcessorInfoBuffer is NULL.\r
-  @retval EFI_NOT_FOUND           The processor with the handle specified by\r
-                                  ProcessorNumber does not exist in the platform.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMpServicesGetProcessorInfo (\r
-  IN  EFI_MP_SERVICES_PROTOCOL   *This,\r
-  IN  UINTN                      ProcessorNumber,\r
-  OUT EFI_PROCESSOR_INFORMATION  *ProcessorInfoBuffer\r
-  )\r
-{\r
-  if (ProcessorInfoBuffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  if (!IsBSP ()) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  \r
-  if (ProcessorNumber >= gMPSystem.NumberOfProcessors) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  \r
-  CopyMem (ProcessorInfoBuffer, &gMPSystem.ProcessorData[ProcessorNumber], sizeof (EFI_PROCESSOR_INFORMATION));\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  This service executes a caller provided function on all enabled APs. APs can \r
-  run either simultaneously or one at a time in sequence. This service supports \r
-  both blocking and non-blocking requests. The non-blocking requests use EFI \r
-  events so the BSP can detect when the APs have finished. This service may only \r
-  be called from the BSP.\r
-\r
-  This function is used to dispatch all the enabled APs to the function specified \r
-  by Procedure.  If any enabled AP is busy, then EFI_NOT_READY is returned \r
-  immediately and Procedure is not started on any AP.\r
-\r
-  If SingleThread is TRUE, all the enabled APs execute the function specified by \r
-  Procedure one by one, in ascending order of processor handle number. Otherwise, \r
-  all the enabled APs execute the function specified by Procedure simultaneously.\r
-\r
-  If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all \r
-  APs finish or TimeoutInMicroseconds expires. Otherwise, execution is in non-blocking \r
-  mode, and the BSP returns from this service without waiting for APs. If a \r
-  non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT \r
-  is signaled, then EFI_UNSUPPORTED must be returned.\r
-\r
-  If the timeout specified by TimeoutInMicroseconds expires before all APs return \r
-  from Procedure, then Procedure on the failed APs is terminated. All enabled APs \r
-  are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r
-  and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its \r
-  content points to the list of processor handle numbers in which Procedure was \r
-  terminated.\r
-\r
-  Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() \r
-  to make sure that the nature of the code that is executed on the BSP and the \r
-  dispatched APs is well controlled. The MP Services Protocol does not guarantee \r
-  that the Procedure function is MP-safe. Hence, the tasks that can be run in \r
-  parallel are limited to certain independent tasks and well-controlled exclusive \r
-  code. EFI services and protocols may not be called by APs unless otherwise \r
-  specified.\r
-\r
-  In blocking execution mode, BSP waits until all APs finish or \r
-  TimeoutInMicroseconds expires.\r
-\r
-  In non-blocking execution mode, BSP is freed to return to the caller and then \r
-  proceed to the next task without having to wait for APs. The following \r
-  sequence needs to occur in a non-blocking execution mode:\r
-\r
-    -# The caller that intends to use this MP Services Protocol in non-blocking \r
-       mode creates WaitEvent by calling the EFI CreateEvent() service.  The caller \r
-       invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent \r
-       is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests \r
-       the function specified by Procedure to be started on all the enabled APs, \r
-       and releases the BSP to continue with other tasks.\r
-    -# The caller can use the CheckEvent() and WaitForEvent() services to check \r
-       the state of the WaitEvent created in step 1.\r
-    -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP \r
-       Service signals WaitEvent by calling the EFI SignalEvent() function. If \r
-       FailedCpuList is not NULL, its content is available when WaitEvent is \r
-       signaled. If all APs returned from Procedure prior to the timeout, then \r
-       FailedCpuList is set to NULL. If not all APs return from Procedure before \r
-       the timeout, then FailedCpuList is filled in with the list of the failed \r
-       APs. The buffer is allocated by MP Service Protocol using AllocatePool(). \r
-       It is the caller's responsibility to free the buffer with FreePool() service.\r
-    -# This invocation of SignalEvent() function informs the caller that invoked\r
-       EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed\r
-       the specified task or a timeout occurred. The contents of FailedCpuList \r
-       can be examined to determine which APs did not complete the specified task \r
-       prior to the timeout.\r
-\r
-  @param[in]  This                    A pointer to the EFI_MP_SERVICES_PROTOCOL\r
-                                      instance.\r
-  @param[in]  Procedure               A pointer to the function to be run on \r
-                                      enabled APs of the system. See type\r
-                                      EFI_AP_PROCEDURE.\r
-  @param[in]  SingleThread            If TRUE, then all the enabled APs execute \r
-                                      the function specified by Procedure one by \r
-                                      one, in ascending order of processor handle \r
-                                      number.  If FALSE, then all the enabled APs \r
-                                      execute the function specified by Procedure\r
-                                      simultaneously.\r
-  @param[in]  WaitEvent               The event created by the caller with CreateEvent()\r
-                                      service.  If it is NULL, then execute in \r
-                                      blocking mode. BSP waits until all APs finish \r
-                                      or TimeoutInMicroseconds expires.  If it's \r
-                                      not NULL, then execute in non-blocking mode. \r
-                                      BSP requests the function specified by \r
-                                      Procedure to be started on all the enabled \r
-                                      APs, and go on executing immediately. If \r
-                                      all return from Procedure, or TimeoutInMicroseconds\r
-                                      expires, this event is signaled. The BSP \r
-                                      can use the CheckEvent() or WaitForEvent() \r
-                                      services to check the state of event.  Type \r
-                                      EFI_EVENT is defined in CreateEvent() in \r
-                                      the Unified Extensible Firmware Interface \r
-                                      Specification.  \r
-  @param[in]  TimeoutInMicrosecsond   Indicates the time limit in microseconds for \r
-                                      APs to return from Procedure, either for \r
-                                      blocking or non-blocking mode. Zero means \r
-                                      infinity.  If the timeout expires before \r
-                                      all APs return from Procedure, then Procedure\r
-                                      on the failed APs is terminated. All enabled \r
-                                      APs are available for next function assigned \r
-                                      by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() \r
-                                      or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().\r
-                                      If the timeout expires in blocking mode, \r
-                                      BSP returns EFI_TIMEOUT.  If the timeout \r
-                                      expires in non-blocking mode, WaitEvent \r
-                                      is signaled with SignalEvent().\r
-  @param[in]  ProcedureArgument       The parameter passed into Procedure for \r
-                                      all APs.\r
-  @param[out] FailedCpuList           If NULL, this parameter is ignored. Otherwise, \r
-                                      if all APs finish successfully, then its \r
-                                      content is set to NULL. If not all APs \r
-                                      finish before timeout expires, then its \r
-                                      content is set to address of the buffer \r
-                                      holding handle numbers of the failed APs. \r
-                                      The buffer is allocated by MP Service Protocol, \r
-                                      and it's the caller's responsibility to \r
-                                      free the buffer with FreePool() service.\r
-                                      In blocking mode, it is ready for consumption \r
-                                      when the call returns. In non-blocking mode, \r
-                                      it is ready when WaitEvent is signaled.  The \r
-                                      list of failed CPU is terminated by \r
-                                      END_OF_CPU_LIST.\r
-\r
-  @retval EFI_SUCCESS             In blocking mode, all APs have finished before \r
-                                  the timeout expired.\r
-  @retval EFI_SUCCESS             In non-blocking mode, function has been dispatched \r
-                                  to all enabled APs.\r
-  @retval EFI_UNSUPPORTED         A non-blocking mode request was made after the \r
-                                  UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was \r
-                                  signaled.\r
-  @retval EFI_DEVICE_ERROR        Caller processor is AP.\r
-  @retval EFI_NOT_STARTED         No enabled APs exist in the system.\r
-  @retval EFI_NOT_READY           Any enabled APs are busy.\r
-  @retval EFI_TIMEOUT             In blocking mode, the timeout expired before \r
-                                  all enabled APs have finished.\r
-  @retval EFI_INVALID_PARAMETER   Procedure is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMpServicesStartupAllAps (\r
-  IN  EFI_MP_SERVICES_PROTOCOL  *This,\r
-  IN  EFI_AP_PROCEDURE          Procedure,\r
-  IN  BOOLEAN                   SingleThread,\r
-  IN  EFI_EVENT                 WaitEvent               OPTIONAL,\r
-  IN  UINTN                     TimeoutInMicroseconds,\r
-  IN  VOID                      *ProcedureArgument      OPTIONAL,\r
-  OUT UINTN                     **FailedCpuList         OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  PROCESSOR_DATA_BLOCK  *ProcessorData;\r
-  UINTN                 ListIndex;\r
-  UINTN                 Number;\r
-  UINTN                 NextNumber;\r
-  PROCESSOR_STATE       APInitialState;\r
-  PROCESSOR_STATE       ProcessorState;\r
-  INTN                  Timeout;\r
-\r
-\r
-  if (!IsBSP ()) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  \r
-  if (gMPSystem.NumberOfProcessors == 1) {\r
-    return EFI_NOT_STARTED;\r
-  }\r
-\r
-  if (Procedure == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  if ((WaitEvent != NULL)  && gReadToBoot) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  \r
-  \r
-  if (FailedCpuList != NULL) {\r
-    gMPSystem.FailedList = AllocatePool ((gMPSystem.NumberOfProcessors + 1) * sizeof (UINTN));\r
-    if (gMPSystem.FailedList == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    SetMemN (gMPSystem.FailedList, (gMPSystem.NumberOfProcessors + 1) * sizeof (UINTN), END_OF_CPU_LIST);\r
-    gMPSystem.FailedListIndex = 0;\r
-    *FailedCpuList = gMPSystem.FailedList;\r
-  }\r
-\r
-  Timeout = TimeoutInMicroseconds;\r
-\r
-  ListIndex                   = 0;\r
-  ProcessorData               = NULL;\r
-\r
-  gMPSystem.FinishCount   = 0;\r
-  gMPSystem.StartCount    = 0;\r
-  gMPSystem.SingleThread  = SingleThread;\r
-  APInitialState          = CPU_STATE_READY;\r
-\r
-  for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {\r
-    ProcessorData = &gMPSystem.ProcessorData[Number];\r
-\r
-    if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {\r
-      // Skip BSP\r
-      continue;\r
-    }\r
-\r
-    if ((ProcessorData->Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0) {\r
-      // Skip Disabled processors\r
-      gMPSystem.FailedList[gMPSystem.FailedListIndex++] = Number;\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Get APs prepared, and put failing APs into FailedCpuList\r
-    // if "SingleThread", only 1 AP will put to ready state, other AP will be put to ready\r
-    // state 1 by 1, until the previous 1 finished its task\r
-    // if not "SingleThread", all APs are put to ready state from the beginning\r
-    //\r
-    if (ProcessorData->State == CPU_STATE_IDLE) {\r
-      gMPSystem.StartCount++;\r
-\r
-      gThread->MutexLock (&ProcessorData->StateLock);\r
-      ProcessorData->State = APInitialState;\r
-      gThread->MutexUnlock (&ProcessorData->StateLock);\r
-\r
-      if (SingleThread) {\r
-        APInitialState = CPU_STATE_BLOCKED;\r
-      }\r
-    } else {\r
-      return EFI_NOT_READY;\r
-    }\r
-  }\r
-  \r
-  if (WaitEvent != NULL) {\r
-    for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {\r
-      ProcessorData = &gMPSystem.ProcessorData[Number];  \r
-      if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {\r
-       // Skip BSP\r
-        continue;\r
-      }\r
-\r
-      if ((ProcessorData->Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0) {\r
-        // Skip Disabled processors\r
-        continue;\r
-      }\r
-    \r
-      SetApProcedure (ProcessorData, Procedure, ProcedureArgument);\r
-    }\r
-\r
-    //\r
-    // Save data into private data structure, and create timer to poll AP state before exiting\r
-    //\r
-    gMPSystem.Procedure         = Procedure;\r
-    gMPSystem.ProcedureArgument = ProcedureArgument;\r
-    gMPSystem.WaitEvent         = WaitEvent;\r
-    gMPSystem.Timeout           = TimeoutInMicroseconds;\r
-    gMPSystem.TimeoutActive     = (BOOLEAN)(TimeoutInMicroseconds != 0);\r
-    Status = gBS->SetTimer (\r
-                    gMPSystem.CheckAllAPsEvent,\r
-                    TimerPeriodic,\r
-                    gPollInterval\r
-                    );\r
-    return Status;\r
-\r
-  }\r
-\r
-  while (TRUE) {\r
-    for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {\r
-      ProcessorData = &gMPSystem.ProcessorData[Number];  \r
-      if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {\r
-       // Skip BSP\r
-        continue;\r
-      }\r
-\r
-      if ((ProcessorData->Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0) {\r
-        // Skip Disabled processors\r
-        continue;\r
-      }\r
-\r
-      gThread->MutexLock (ProcessorData->StateLock);\r
-      ProcessorState = ProcessorData->State;\r
-      gThread->MutexUnlock (ProcessorData->StateLock);\r
-\r
-      switch (ProcessorState) {\r
-      case CPU_STATE_READY:\r
-        SetApProcedure (ProcessorData, Procedure, ProcedureArgument);\r
-        break;\r
-\r
-      case CPU_STATE_FINISHED:\r
-        gMPSystem.FinishCount++;\r
-        if (SingleThread) {\r
-          Status = GetNextBlockedNumber (&NextNumber);\r
-          if (!EFI_ERROR (Status)) {\r
-            gMPSystem.ProcessorData[NextNumber].State = CPU_STATE_READY;\r
-          }\r
-        }\r
-\r
-        ProcessorData->State = CPU_STATE_IDLE;\r
-        break;\r
-\r
-      default:\r
-        break;\r
-      }\r
-    }\r
-\r
-    if (gMPSystem.FinishCount == gMPSystem.StartCount) {\r
-      Status = EFI_SUCCESS;\r
-      goto Done;\r
-    }\r
-\r
-    if ((TimeoutInMicroseconds != 0) && (Timeout < 0)) {\r
-      Status = EFI_TIMEOUT;\r
-      goto Done;\r
-    }\r
-\r
-    gBS->Stall (gPollInterval);\r
-    Timeout -= gPollInterval;\r
-  }\r
-\r
-Done:\r
-  if (FailedCpuList != NULL) {\r
-    if (gMPSystem.FailedListIndex == 0) {\r
-      FreePool (*FailedCpuList);\r
-      *FailedCpuList = NULL;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  This service lets the caller get one enabled AP to execute a caller-provided \r
-  function. The caller can request the BSP to either wait for the completion \r
-  of the AP or just proceed with the next task by using the EFI event mechanism. \r
-  See EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() for more details on non-blocking \r
-  execution support.  This service may only be called from the BSP.\r
-\r
-  This function is used to dispatch one enabled AP to the function specified by \r
-  Procedure passing in the argument specified by ProcedureArgument.  If WaitEvent \r
-  is NULL, execution is in blocking mode. The BSP waits until the AP finishes or \r
-  TimeoutInMicroSecondss expires. Otherwise, execution is in non-blocking mode. \r
-  BSP proceeds to the next task without waiting for the AP. If a non-blocking mode \r
-  is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled, \r
-  then EFI_UNSUPPORTED must be returned.\r
-  \r
-  If the timeout specified by TimeoutInMicroseconds expires before the AP returns \r
-  from Procedure, then execution of Procedure by the AP is terminated. The AP is \r
-  available for subsequent calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and \r
-  EFI_MP_SERVICES_PROTOCOL.StartupThisAP().\r
-\r
-  @param[in]  This                    A pointer to the EFI_MP_SERVICES_PROTOCOL\r
-                                      instance.\r
-  @param[in]  Procedure               A pointer to the function to be run on \r
-                                      enabled APs of the system. See type\r
-                                      EFI_AP_PROCEDURE.\r
-  @param[in]  ProcessorNumber         The handle number of the AP. The range is \r
-                                      from 0 to the total number of logical\r
-                                      processors minus 1. The total number of \r
-                                      logical processors can be retrieved by\r
-                                      EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
-  @param[in]  WaitEvent               The event created by the caller with CreateEvent()\r
-                                      service.  If it is NULL, then execute in \r
-                                      blocking mode. BSP waits until all APs finish \r
-                                      or TimeoutInMicroseconds expires.  If it's \r
-                                      not NULL, then execute in non-blocking mode. \r
-                                      BSP requests the function specified by \r
-                                      Procedure to be started on all the enabled \r
-                                      APs, and go on executing immediately. If \r
-                                      all return from Procedure or TimeoutInMicroseconds\r
-                                      expires, this event is signaled. The BSP \r
-                                      can use the CheckEvent() or WaitForEvent() \r
-                                      services to check the state of event.  Type \r
-                                      EFI_EVENT is defined in CreateEvent() in \r
-                                      the Unified Extensible Firmware Interface \r
-                                      Specification.  \r
-  @param[in]  TimeoutInMicrosecsond   Indicates the time limit in microseconds for \r
-                                      APs to return from Procedure, either for \r
-                                      blocking or non-blocking mode. Zero means \r
-                                      infinity.  If the timeout expires before \r
-                                      all APs return from Procedure, then Procedure\r
-                                      on the failed APs is terminated. All enabled \r
-                                      APs are available for next function assigned \r
-                                      by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() \r
-                                      or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().\r
-                                      If the timeout expires in blocking mode, \r
-                                      BSP returns EFI_TIMEOUT.  If the timeout \r
-                                      expires in non-blocking mode, WaitEvent \r
-                                      is signaled with SignalEvent().\r
-  @param[in]  ProcedureArgument       The parameter passed into Procedure for \r
-                                      all APs.\r
-  @param[out] Finished                If NULL, this parameter is ignored.  In \r
-                                      blocking mode, this parameter is ignored.\r
-                                      In non-blocking mode, if AP returns from \r
-                                      Procedure before the timeout expires, its\r
-                                      content is set to TRUE. Otherwise, the \r
-                                      value is set to FALSE. The caller can\r
-                                      determine if the AP returned from Procedure \r
-                                      by evaluating this value.\r
-\r
-  @retval EFI_SUCCESS             In blocking mode, specified AP finished before \r
-                                  the timeout expires.\r
-  @retval EFI_SUCCESS             In non-blocking mode, the function has been \r
-                                  dispatched to specified AP.\r
-  @retval EFI_UNSUPPORTED         A non-blocking mode request was made after the \r
-                                  UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was \r
-                                  signaled.\r
-  @retval EFI_DEVICE_ERROR        The calling processor is an AP.\r
-  @retval EFI_TIMEOUT             In blocking mode, the timeout expired before \r
-                                  the specified AP has finished.\r
-  @retval EFI_NOT_READY           The specified AP is busy.\r
-  @retval EFI_NOT_FOUND           The processor with the handle specified by \r
-                                  ProcessorNumber does not exist.\r
-  @retval EFI_INVALID_PARAMETER   ProcessorNumber specifies the BSP or disabled AP.\r
-  @retval EFI_INVALID_PARAMETER   Procedure is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMpServicesStartupThisAP (\r
-  IN  EFI_MP_SERVICES_PROTOCOL  *This,\r
-  IN  EFI_AP_PROCEDURE          Procedure,\r
-  IN  UINTN                     ProcessorNumber,\r
-  IN  EFI_EVENT                 WaitEvent               OPTIONAL,\r
-  IN  UINTN                     TimeoutInMicroseconds,\r
-  IN  VOID                      *ProcedureArgument      OPTIONAL,\r
-  OUT BOOLEAN                   *Finished               OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS      Status;\r
-  INTN            Timeout;\r
-  \r
-  if (!IsBSP ()) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  \r
-  if (Procedure == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-    \r
-  if (ProcessorNumber >= gMPSystem.NumberOfProcessors) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  \r
-  if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (gMPSystem.ProcessorData[ProcessorNumber].State != CPU_STATE_IDLE) {\r
-    return EFI_NOT_READY;\r
-  }\r
-\r
-  if ((WaitEvent != NULL)  && gReadToBoot) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Timeout = TimeoutInMicroseconds;\r
-\r
-  gMPSystem.StartCount   = 1;\r
-  gMPSystem.FinishCount  = 0;\r
-\r
-  SetApProcedure (&gMPSystem.ProcessorData[ProcessorNumber], Procedure, ProcedureArgument);\r
-\r
-  if (WaitEvent != NULL) {\r
-      // Non Blocking\r
-      gMPSystem.WaitEvent = WaitEvent;\r
-      Status = gBS->SetTimer (\r
-                      gMPSystem.ProcessorData[ProcessorNumber].CheckThisAPEvent,\r
-                      TimerPeriodic,\r
-                      gPollInterval\r
-                      );\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  // Blocking\r
-  while (TRUE) {\r
-    gThread->MutexLock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
-    if (gMPSystem.ProcessorData[ProcessorNumber].State == CPU_STATE_FINISHED) {\r
-      gMPSystem.ProcessorData[ProcessorNumber].State = CPU_STATE_IDLE;\r
-      gThread->MutexUnlock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
-      break;\r
-    }\r
-\r
-    gThread->MutexUnlock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
-\r
-    if ((TimeoutInMicroseconds != 0) && (Timeout < 0)) {\r
-      return EFI_TIMEOUT;\r
-    }\r
-\r
-    gBS->Stall (gPollInterval);\r
-    Timeout -= gPollInterval;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-\r
-}\r
-\r
-\r
-/**\r
-  This service switches the requested AP to be the BSP from that point onward. \r
-  This service changes the BSP for all purposes.   This call can only be performed \r
-  by the current BSP.\r
-\r
-  This service switches the requested AP to be the BSP from that point onward. \r
-  This service changes the BSP for all purposes. The new BSP can take over the \r
-  execution of the old BSP and continue seamlessly from where the old one left \r
-  off. This service may not be supported after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT \r
-  is signaled.\r
-\r
-  If the BSP cannot be switched prior to the return from this service, then \r
-  EFI_UNSUPPORTED must be returned.\r
-\r
-  @param[in] This              A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
-  @param[in] ProcessorNumber   The handle number of AP that is to become the new \r
-                               BSP. The range is from 0 to the total number of \r
-                               logical processors minus 1. The total number of \r
-                               logical processors can be retrieved by\r
-                               EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
-  @param[in] EnableOldBSP      If TRUE, then the old BSP will be listed as an \r
-                               enabled AP. Otherwise, it will be disabled.\r
-\r
-  @retval EFI_SUCCESS             BSP successfully switched.\r
-  @retval EFI_UNSUPPORTED         Switching the BSP cannot be completed prior to \r
-                                  this service returning.\r
-  @retval EFI_UNSUPPORTED         Switching the BSP is not supported.\r
-  @retval EFI_SUCCESS             The calling processor is an AP.\r
-  @retval EFI_NOT_FOUND           The processor with the handle specified by\r
-                                  ProcessorNumber does not exist.\r
-  @retval EFI_INVALID_PARAMETER   ProcessorNumber specifies the current BSP or \r
-                                  a disabled AP.\r
-  @retval EFI_NOT_READY           The specified AP is busy.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMpServicesSwitchBSP (\r
-  IN EFI_MP_SERVICES_PROTOCOL  *This,\r
-  IN  UINTN                    ProcessorNumber,\r
-  IN  BOOLEAN                  EnableOldBSP\r
-  )\r
-{\r
-  UINTN   Index;\r
-  \r
-  if (!IsBSP ()) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  \r
-  if (ProcessorNumber >= gMPSystem.NumberOfProcessors) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  \r
-  if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  for (Index = 0; Index < gMPSystem.NumberOfProcessors; Index++) {\r
-    if ((gMPSystem.ProcessorData[Index].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0) {\r
-      break;\r
-    }\r
-  }\r
-  ASSERT (Index != gMPSystem.NumberOfProcessors);\r
-  \r
-  if (gMPSystem.ProcessorData[ProcessorNumber].State != CPU_STATE_IDLE) {\r
-    return EFI_NOT_READY;\r
-  }\r
-  \r
-  // Skip for now as we need switch a bunch of stack stuff around and it's complex\r
-  // May not be worth it?\r
-  return EFI_NOT_READY;\r
-}\r
-\r
-\r
-/**\r
-  This service lets the caller enable or disable an AP from this point onward.  \r
-  This service may only be called from the BSP.\r
-\r
-  This service allows the caller enable or disable an AP from this point onward. \r
-  The caller can optionally specify the health status of the AP by Health. If \r
-  an AP is being disabled, then the state of the disabled AP is implementation \r
-  dependent. If an AP is enabled, then the implementation must guarantee that a \r
-  complete initialization sequence is performed on the AP, so the AP is in a state \r
-  that is compatible with an MP operating system. This service may not be supported \r
-  after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled.\r
-\r
-  If the enable or disable AP operation cannot be completed prior to the return \r
-  from this service, then EFI_UNSUPPORTED must be returned.\r
-\r
-  @param[in] This              A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
-  @param[in] ProcessorNumber   The handle number of AP that is to become the new \r
-                               BSP. The range is from 0 to the total number of \r
-                               logical processors minus 1. The total number of \r
-                               logical processors can be retrieved by\r
-                               EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
-  @param[in] EnableAP          Specifies the new state for the processor for \r
-                               enabled, FALSE for disabled.\r
-  @param[in] HealthFlag        If not NULL, a pointer to a value that specifies \r
-                               the new health status of the AP. This flag \r
-                               corresponds to StatusFlag defined in \r
-                               EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only \r
-                               the PROCESSOR_HEALTH_STATUS_BIT is used. All other \r
-                               bits are ignored.  If it is NULL, this parameter \r
-                               is ignored.\r
-\r
-  @retval EFI_SUCCESS             The specified AP was enabled or disabled successfully.\r
-  @retval EFI_UNSUPPORTED         Enabling or disabling an AP cannot be completed \r
-                                  prior to this service returning.\r
-  @retval EFI_UNSUPPORTED         Enabling or disabling an AP is not supported.\r
-  @retval EFI_DEVICE_ERROR        The calling processor is an AP.\r
-  @retval EFI_NOT_FOUND           Processor with the handle specified by ProcessorNumber\r
-                                  does not exist.\r
-  @retval EFI_INVALID_PARAMETER   ProcessorNumber specifies the BSP.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMpServicesEnableDisableAP (\r
-  IN  EFI_MP_SERVICES_PROTOCOL  *This,\r
-  IN  UINTN                     ProcessorNumber,\r
-  IN  BOOLEAN                   EnableAP,\r
-  IN  UINT32                    *HealthFlag OPTIONAL\r
-  )\r
-{\r
-  if (!IsBSP ()) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  \r
-  if (ProcessorNumber >= gMPSystem.NumberOfProcessors) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  \r
-  if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }  \r
-\r
-  if (gMPSystem.ProcessorData[ProcessorNumber].State != CPU_STATE_IDLE) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  gThread->MutexLock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
-  \r
-  if (EnableAP) {\r
-    if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0 ) {\r
-      gMPSystem.NumberOfEnabledProcessors++;\r
-    }\r
-    gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_ENABLED_BIT;\r
-  } else {\r
-    if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == PROCESSOR_ENABLED_BIT ) {\r
-      gMPSystem.NumberOfEnabledProcessors--;\r
-    }\r
-    gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag &= ~PROCESSOR_ENABLED_BIT;\r
-  }\r
-  \r
-  if (HealthFlag != NULL) {\r
-    gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag &= ~PROCESSOR_HEALTH_STATUS_BIT;\r
-    gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= (*HealthFlag & PROCESSOR_HEALTH_STATUS_BIT);\r
-  }\r
-  \r
-  gThread->MutexUnlock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  This return the handle number for the calling processor.  This service may be \r
-  called from the BSP and APs.\r
-\r
-  This service returns the processor handle number for the calling processor. \r
-  The returned value is in the range from 0 to the total number of logical \r
-  processors minus 1. The total number of logical processors can be retrieved \r
-  with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be \r
-  called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER \r
-  is returned. Otherwise, the current processors handle number is returned in \r
-  ProcessorNumber, and EFI_SUCCESS is returned.\r
-\r
-  @param[in] This              A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
-  @param[in] ProcessorNumber   The handle number of AP that is to become the new \r
-                               BSP. The range is from 0 to the total number of \r
-                               logical processors minus 1. The total number of \r
-                               logical processors can be retrieved by\r
-                               EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
-\r
-  @retval EFI_SUCCESS             The current processor handle number was returned \r
-                                  in ProcessorNumber.\r
-  @retval EFI_INVALID_PARAMETER   ProcessorNumber is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMpServicesWhoAmI (\r
-  IN EFI_MP_SERVICES_PROTOCOL  *This,\r
-  OUT UINTN                    *ProcessorNumber\r
-  )\r
-{\r
-  UINTN   Index;\r
-  UINT64  ProcessorId;\r
-  \r
-  if (ProcessorNumber == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  ProcessorId = gThread->Self ();\r
-  for (Index = 0; Index < gMPSystem.NumberOfProcessors; Index++) {\r
-    if (gMPSystem.ProcessorData[Index].Info.ProcessorId == ProcessorId) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  *ProcessorNumber = Index;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
-EFI_MP_SERVICES_PROTOCOL  mMpSercicesTemplate = {\r
-  CpuMpServicesGetNumberOfProcessors,\r
-  CpuMpServicesGetProcessorInfo,\r
-  CpuMpServicesStartupAllAps,\r
-  CpuMpServicesStartupThisAP,\r
-  CpuMpServicesSwitchBSP,\r
-  CpuMpServicesEnableDisableAP,\r
-  CpuMpServicesWhoAmI\r
-};\r
-\r
-\r
-\r
-/*++\r
-  If timeout occurs in StartupAllAps(), a timer is set, which invokes this\r
-  procedure periodically to check whether all APs have finished.\r
-\r
-\r
---*/\r
-VOID\r
-EFIAPI\r
-CpuCheckAllAPsStatus (\r
-  IN  EFI_EVENT   Event,\r
-  IN  VOID        *Context\r
-  )\r
-{\r
-  UINTN                 ProcessorNumber;\r
-  UINTN                 NextNumber;\r
-  PROCESSOR_DATA_BLOCK  *ProcessorData;\r
-  PROCESSOR_DATA_BLOCK  *NextData;\r
-  EFI_STATUS            Status;\r
-  PROCESSOR_STATE       ProcessorState;\r
-  UINTN                 Cpu;\r
-  BOOLEAN               Found;\r
-\r
-  if (gMPSystem.TimeoutActive) {\r
-    gMPSystem.Timeout -= gPollInterval;\r
-  }\r
-  \r
-  ProcessorData = (PROCESSOR_DATA_BLOCK *) Context;\r
-\r
-  for (ProcessorNumber = 0; ProcessorNumber < gMPSystem.NumberOfProcessors; ProcessorNumber++) {\r
-    if ((ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {\r
-     // Skip BSP\r
-      continue;\r
-    }\r
-\r
-    if ((ProcessorData->Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0) {\r
-      // Skip Disabled processors\r
-      continue;\r
-    }\r
-\r
-    // This is an Interrupt Service routine.\r
-    // This can grab a lock that is held in a non-interrupt\r
-    // context. Meaning deadlock. Which is a bad thing.\r
-    // So, try lock it. If we can get it, cool, do our thing.\r
-    // otherwise, just dump out & try again on the next iteration.\r
-    Status = gThread->MutexTryLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
-    if (EFI_ERROR(Status)) {\r
-      return;\r
-    }\r
-    ProcessorState = gMPSystem.ProcessorData[ProcessorNumber].State;\r
-    gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
-\r
-    switch (ProcessorState) {\r
-    case CPU_STATE_READY:\r
-      SetApProcedure (ProcessorData, gMPSystem.Procedure, gMPSystem.ProcedureArgument);\r
-      break;\r
-\r
-    case CPU_STATE_FINISHED:\r
-      if (gMPSystem.SingleThread) {\r
-        Status = GetNextBlockedNumber (&NextNumber);\r
-        if (!EFI_ERROR (Status)) {\r
-          NextData = &gMPSystem.ProcessorData[NextNumber];\r
-\r
-          gThread->MutexLock (&NextData->ProcedureLock);\r
-          NextData->State = CPU_STATE_READY;\r
-          gThread->MutexUnlock (&NextData->ProcedureLock);\r
-\r
-          SetApProcedure (NextData, gMPSystem.Procedure, gMPSystem.ProcedureArgument);\r
-        }\r
-      }\r
-\r
-      gMPSystem.ProcessorData[ProcessorNumber].State = CPU_STATE_IDLE;\r
-      gMPSystem.FinishCount++;\r
-      break;\r
-\r
-    default:\r
-      break;\r
-    }\r
-  }\r
-  \r
-  if (gMPSystem.TimeoutActive && gMPSystem.Timeout < 0) {\r
-    //\r
-    // Timeout\r
-    //\r
-    if (gMPSystem.FailedList != NULL) {\r
-      for (ProcessorNumber = 0; ProcessorNumber < gMPSystem.NumberOfProcessors; ProcessorNumber++) {\r
-        if ((ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {\r
-         // Skip BSP\r
-          continue;\r
-        }\r
-\r
-        if ((ProcessorData->Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0) {\r
-          // Skip Disabled processors\r
-          continue;\r
-        }\r
-    \r
-        // Mark the \r
-        Status = gThread->MutexTryLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
-        if (EFI_ERROR(Status)) {\r
-          return;\r
-        }\r
-        ProcessorState = gMPSystem.ProcessorData[ProcessorNumber].State;\r
-        gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
-    \r
-        if (ProcessorState != CPU_STATE_IDLE) {\r
-          // If we are retrying make sure we don't double count\r
-          for (Cpu = 0, Found = FALSE; Cpu < gMPSystem.NumberOfProcessors; Cpu++) {\r
-            if (gMPSystem.FailedList[Cpu] == END_OF_CPU_LIST) {\r
-              break;\r
-            }\r
-            if (gMPSystem.FailedList[ProcessorNumber] == Cpu) {\r
-              Found = TRUE;\r
-              break;\r
-            }\r
-          }\r
-          if (!Found) {\r
-            gMPSystem.FailedList[gMPSystem.FailedListIndex++] = Cpu;\r
-          }\r
-        }\r
-      }\r
-    }\r
-    // Force terminal exit\r
-    gMPSystem.FinishCount = gMPSystem.StartCount;\r
-  }\r
-\r
-  if (gMPSystem.FinishCount != gMPSystem.StartCount) {\r
-    return;\r
-  }\r
-  \r
-  gBS->SetTimer (\r
-         gMPSystem.CheckAllAPsEvent,\r
-         TimerCancel,\r
-         0\r
-         );\r
-\r
-  if (gMPSystem.FailedListIndex == 0) {\r
-    if (gMPSystem.FailedList != NULL) {\r
-      FreePool (gMPSystem.FailedList);\r
-      gMPSystem.FailedList = NULL;\r
-    }\r
-  }\r
-\r
-  Status = gBS->SignalEvent (gMPSystem.WaitEvent);\r
-\r
-  return ;\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-CpuCheckThisAPStatus (\r
-  IN  EFI_EVENT                           Event,\r
-  IN  VOID                                *Context\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  PROCESSOR_DATA_BLOCK  *ProcessorData;\r
-  PROCESSOR_STATE       ProcessorState;\r
-\r
-  ProcessorData = (PROCESSOR_DATA_BLOCK *) Context;\r
-\r
-  //\r
-  // This is an Interrupt Service routine.\r
-  // that can grab a lock that is held in a non-interrupt\r
-  // context. Meaning deadlock. Which is a badddd thing.\r
-  // So, try lock it. If we can get it, cool, do our thing.\r
-  // otherwise, just dump out & try again on the next iteration.\r
-  //\r
-  Status = gThread->MutexTryLock (ProcessorData->StateLock);\r
-  if (EFI_ERROR(Status)) {\r
-    return;\r
-  }\r
-  ProcessorState = ProcessorData->State;\r
-  gThread->MutexUnlock (ProcessorData->StateLock);\r
-\r
-  if (ProcessorState == CPU_STATE_FINISHED) {\r
-    Status = gBS->SetTimer (ProcessorData->CheckThisAPEvent, TimerCancel, 0);\r
-    ASSERT_EFI_ERROR (Status);\r
-    \r
-    Status = gBS->SignalEvent (gMPSystem.WaitEvent);\r
-    ASSERT_EFI_ERROR (Status);\r
-    \r
-    gThread->MutexLock (ProcessorData->StateLock);\r
-    ProcessorData->State = CPU_STATE_IDLE;\r
-    gThread->MutexUnlock (ProcessorData->StateLock);\r
-  }\r
-\r
-  return ;\r
-}\r
-\r
-\r
-/*++\r
-  This function is called by all processors (both BSP and AP) once and collects MP related data\r
-\r
-  MPSystemData  - Pointer to the data structure containing MP related data\r
-  BSP           - TRUE if the CPU is BSP\r
-\r
-  EFI_SUCCESS   - Data for the processor collected and filled in\r
-\r
---*/\r
-EFI_STATUS\r
-FillInProcessorInformation (\r
-  IN     BOOLEAN              BSP,\r
-  IN     UINTN                ProcessorNumber\r
-  )\r
-{\r
-  PROCESSOR_DATA_BLOCK            *ProcessorData;\r
-\r
-  ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];\r
-  \r
-  gMPSystem.ProcessorData[ProcessorNumber].Info.ProcessorId  = gThread->Self ();\r
-  gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag   = PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT;\r
-  if (BSP) {\r
-    gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_AS_BSP_BIT;\r
-  }\r
-  \r
-  gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Package = ProcessorNumber;\r
-  gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Core    = 0;\r
-  gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Thread  = 0;\r
-  gMPSystem.ProcessorData[ProcessorNumber].State = BSP ? CPU_STATE_BUSY : CPU_STATE_IDLE;\r
-  \r
-  gMPSystem.ProcessorData[ProcessorNumber].Procedure        = NULL;\r
-  gMPSystem.ProcessorData[ProcessorNumber].Parameter        = NULL;\r
-  gMPSystem.ProcessorData[ProcessorNumber].StateLock        = gThread->MutexInit ();\r
-  gMPSystem.ProcessorData[ProcessorNumber].ProcedureLock    = gThread->MutexInit ();\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID *\r
-EFIAPI\r
-CpuDriverApIdolLoop (\r
-  VOID  *Context\r
-  )\r
-{\r
-  EFI_AP_PROCEDURE      Procedure;\r
-  VOID                  *Parameter;\r
-  UINTN                 ProcessorNumber;\r
-  PROCESSOR_DATA_BLOCK  *ProcessorData;\r
-  \r
-  ProcessorNumber = (UINTN)Context;\r
-  ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];\r
-    \r
-  ProcessorData->Info.ProcessorId = gThread->Self ();\r
\r
-  while (TRUE) {\r
-    //\r
-    // Make a local copy on the stack to be extra safe\r
-    //\r
-    gThread->MutexLock (ProcessorData->ProcedureLock);\r
-    Procedure = ProcessorData->Procedure;\r
-    Parameter = ProcessorData->Parameter;\r
-    gThread->MutexUnlock (ProcessorData->ProcedureLock);\r
-  \r
-    if (Procedure != NULL) {\r
-      gThread->MutexLock (ProcessorData->StateLock);\r
-      ProcessorData->State = CPU_STATE_BUSY;\r
-      gThread->MutexUnlock (ProcessorData->StateLock);\r
-  \r
-      Procedure (Parameter);\r
-    \r
-      gThread->MutexLock (ProcessorData->ProcedureLock);\r
-      ProcessorData->Procedure = NULL;\r
-      gThread->MutexUnlock (ProcessorData->ProcedureLock);\r
-  \r
-      gThread->MutexLock (ProcessorData->StateLock);\r
-      ProcessorData->State = CPU_STATE_FINISHED;\r
-      gThread->MutexUnlock (ProcessorData->StateLock);  \r
-    }\r
-    \r
-    // Poll 5 times a seconds, 200ms\r
-    // Don't want to burn too many system resources doing nothing.\r
-    gEmuThunk->Sleep (200 * 1000);\r
-  }\r
-  \r
-  return 0;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-InitializeMpSystemData (\r
-  IN   UINTN     NumberOfProcessors\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  UINTN                   Index;\r
-\r
-  \r
-  //\r
-  // Clear the data structure area first.\r
-  //\r
-  ZeroMem (&gMPSystem, sizeof (MP_SYSTEM_DATA));\r
-\r
-  //\r
-  // First BSP fills and inits all known values, including it's own records.\r
-  //\r
-  gMPSystem.NumberOfProcessors         = NumberOfProcessors;\r
-  gMPSystem.NumberOfEnabledProcessors  = NumberOfProcessors;\r
-  \r
-  gMPSystem.ProcessorData = AllocateZeroPool (gMPSystem.NumberOfProcessors * sizeof (PROCESSOR_DATA_BLOCK));\r
-  ASSERT (gMPSystem.ProcessorData != NULL);\r
-\r
-  FillInProcessorInformation (TRUE, 0);\r
-  \r
-  Status = gBS->CreateEvent (\r
-                  EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
-                  TPL_CALLBACK,\r
-                  CpuCheckAllAPsStatus,\r
-                  NULL,\r
-                  &gMPSystem.CheckAllAPsEvent\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-\r
-  for (Index = 0; Index < gMPSystem.NumberOfProcessors; Index++) {\r
-    if ((gMPSystem.ProcessorData[Index].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {\r
-     // Skip BSP\r
-      continue;\r
-    }\r
-    \r
-    FillInProcessorInformation (FALSE, Index);\r
-    \r
-    Status = gThread->CreateThread (\r
-                        (VOID *)&gMPSystem.ProcessorData[Index].Info.ProcessorId, \r
-                        NULL,\r
-                        CpuDriverApIdolLoop,\r
-                        (VOID *)Index\r
-                        );\r
-                      \r
-              \r
-    Status = gBS->CreateEvent (\r
-                         EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
-                         TPL_CALLBACK,\r
-                         CpuCheckThisAPStatus,\r
-                         (VOID *)  &gMPSystem.ProcessorData[Index],\r
-                         &gMPSystem.ProcessorData[Index].CheckThisAPEvent\r
-                         );\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
-/**\r
-  Invoke a notification event\r
-\r
-  @param  Event                 Event whose notification function is being invoked.\r
-  @param  Context               The pointer to the notification function's context,\r
-                                which is implementation-dependent.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-CpuReadToBootFunction (\r
-  IN  EFI_EVENT                Event,\r
-  IN  VOID                     *Context\r
-  )\r
-{\r
-  gReadToBoot = TRUE;\r
-}\r
-\r
-\r
-\r
-EFI_STATUS\r
-CpuMpServicesInit (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_HANDLE              Handle;\r
-  EMU_IO_THUNK_PROTOCOL   *IoThunk;\r
-  UINTN                   MaxCpus;\r
-\r
-  MaxCpus = 1; // BSP\r
-  \r
-  IoThunk = GetIoThunkInstance (&gEmuThreadThunkProtocolGuid, 0);\r
-  if (IoThunk != NULL) {\r
-    Status = IoThunk->Open (IoThunk);\r
-    if (!EFI_ERROR (Status)) {\r
-      if (IoThunk->ConfigString != NULL) {\r
-        MaxCpus += StrDecimalToUintn (IoThunk->ConfigString);\r
-        gThread = IoThunk->Interface;\r
-      }\r
-    }\r
-  }\r
-\r
-  if (MaxCpus == 1) {\r
-    // We are not MP so nothing to do\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  gPollInterval = PcdGet64 (PcdEmuMpServicesPollingInterval);\r
-\r
-  Status  = InitializeMpSystemData (MaxCpus);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = EfiCreateEventReadyToBootEx (TPL_CALLBACK, CpuReadToBootFunction, NULL, &gReadToBootEvent);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Now install the MP services protocol.\r
-  //\r
-  Handle = NULL;\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Handle,\r
-                  &gEfiMpServiceProtocolGuid,   &mMpSercicesTemplate,\r
-                  NULL\r
-                  );\r
-  return Status;\r
-}\r
-\r
-\r
diff --git a/InOsEmuPkg/CpuRuntimeDxe/Strings.uni b/InOsEmuPkg/CpuRuntimeDxe/Strings.uni
deleted file mode 100644 (file)
index 4f8d41e..0000000
Binary files a/InOsEmuPkg/CpuRuntimeDxe/Strings.uni and /dev/null differ
diff --git a/InOsEmuPkg/EmuBlockIoDxe/ComponentName.c b/InOsEmuPkg/EmuBlockIoDxe/ComponentName.c
deleted file mode 100644 (file)
index 2cad6ca..0000000
+++ /dev/null
@@ -1,354 +0,0 @@
-/**@file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  ComponentName.c\r
-\r
-Abstract:\r
-\r
-**/\r
-\r
-#include "EmuBlockIo.h"\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED  EFI_COMPONENT_NAME_PROTOCOL     gEmuBlockIoComponentName = {\r
-  EmuBlockIoComponentNameGetDriverName,\r
-  EmuBlockIoComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBlockIoComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuBlockIoComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuBlockIoComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-EFI_UNICODE_STRING_TABLE mEmuBlockIoDriverNameTable[] = {\r
-  { "eng;en", L"Emu Block I/O Driver" },\r
-  { NULL , NULL }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-          Language,\r
-          This->SupportedLanguages,\r
-          mEmuBlockIoDriverNameTable,\r
-          DriverName,\r
-           (BOOLEAN)(This == &gEmuBlockIoComponentName)\r
-          );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_BLOCK_IO_PROTOCOL   *BlockIo;\r
-  EMU_BLOCK_IO_PRIVATE    *Private;\r
-\r
-  //\r
-  // This is a device driver, so ChildHandle must be NULL.\r
-  //\r
-  if (ChildHandle != NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Make sure this driver is currently managing ControllerHandle\r
-  //\r
-  Status = EfiTestManagedDevice (\r
-             ControllerHandle,\r
-             gEmuBlockIoDriverBinding.DriverBindingHandle,\r
-             &gEmuIoThunkProtocolGuid\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Get our context back\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  (VOID  **)&BlockIo,\r
-                  gEmuBlockIoDriverBinding.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo);\r
-\r
-  return LookupUnicodeString2 (\r
-          Language,\r
-           This->SupportedLanguages,\r
-           Private->ControllerNameTable,\r
-           ControllerName,\r
-           (BOOLEAN)(This == &gEmuBlockIoComponentName)\r
-          );\r
-}\r
diff --git a/InOsEmuPkg/EmuBlockIoDxe/DriverConfiguration.c b/InOsEmuPkg/EmuBlockIoDxe/DriverConfiguration.c
deleted file mode 100644 (file)
index 44a3cc3..0000000
+++ /dev/null
@@ -1,338 +0,0 @@
-/**@file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  DriverConfiguration.c\r
-\r
-Abstract:\r
-\r
-**/\r
-\r
-#include "EmuBlockIo.h"\r
-\r
-//\r
-// EFI Driver Configuration Functions\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoDriverConfigurationSetOptions (\r
-  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL                      *This,\r
-  IN  EFI_HANDLE                                             ControllerHandle,\r
-  IN  EFI_HANDLE                                             ChildHandle  OPTIONAL,\r
-  IN  CHAR8                                                  *Language,\r
-  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED               *ActionRequired\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoDriverConfigurationOptionsValid (\r
-  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL               *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle  OPTIONAL\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoDriverConfigurationForceDefaults (\r
-  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL                      *This,\r
-  IN  EFI_HANDLE                                             ControllerHandle,\r
-  IN  EFI_HANDLE                                             ChildHandle  OPTIONAL,\r
-  IN  UINT32                                                 DefaultType,\r
-  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED               *ActionRequired\r
-  );\r
-\r
-//\r
-// EFI Driver Configuration Protocol\r
-//\r
-EFI_DRIVER_CONFIGURATION_PROTOCOL gEmuBlockIoDriverConfiguration = {\r
-  EmuBlockIoDriverConfigurationSetOptions,\r
-  EmuBlockIoDriverConfigurationOptionsValid,\r
-  EmuBlockIoDriverConfigurationForceDefaults,\r
-  "eng"\r
-};\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Allows the user to set controller specific options for a controller that a \r
-    driver is currently managing.\r
-\r
-  Arguments:\r
-    This             - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.\r
-    ControllerHandle - The handle of the controller to set options on.\r
-    ChildHandle      - The handle of the child controller to set options on.  This\r
-                       is an optional parameter that may be NULL.  It will be NULL \r
-                       for device drivers, and for a bus drivers that wish to set \r
-                       options for the bus controller.  It will not be NULL for a \r
-                       bus driver that wishes to set options for one of its child \r
-                       controllers.\r
-    Language         - A pointer to a three character ISO 639-2 language identifier.\r
-                       This is the language of the user interface that should be \r
-                       presented to the user, and it must match one of the languages \r
-                       specified in SupportedLanguages.  The number of languages \r
-                       supported by a driver is up to the driver writer.\r
-    ActionRequired   - A pointer to the action that the calling agent is required \r
-                       to perform when this function returns.  See "Related \r
-                       Definitions" for a list of the actions that the calling \r
-                       agent is required to perform prior to accessing \r
-                       ControllerHandle again.\r
-\r
-  Returns:\r
-    EFI_SUCCESS           - The driver specified by This successfully set the \r
-                            configuration options for the controller specified \r
-                            by ControllerHandle..\r
-    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
-    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
-    EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
-    EFI_UNSUPPORTED       - The driver specified by This does not support setting \r
-                            configuration options for the controller specified by \r
-                            ControllerHandle and ChildHandle.\r
-    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
-                            language specified by Language.\r
-    EFI_DEVICE_ERROR      - A device error occurred while attempt to set the \r
-                            configuration options for the controller specified \r
-                            by ControllerHandle and ChildHandle.\r
-    EFI_OUT_RESOURCES     - There are not enough resources available to set the \r
-                            configuration options for the controller specified \r
-                            by ControllerHandle and ChildHandle.\r
-\r
---*/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoDriverConfigurationSetOptions (\r
-  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL                      *This,\r
-  IN  EFI_HANDLE                                             ControllerHandle,\r
-  IN  EFI_HANDLE                                             ChildHandle  OPTIONAL,\r
-  IN  CHAR8                                                  *Language,\r
-  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED               *ActionRequired\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
-  CHAR8                 *SupportedLanguage;\r
-\r
-  SupportedLanguage = This->SupportedLanguages;\r
-\r
-  Status            = EFI_UNSUPPORTED;\r
-  while (*SupportedLanguage != 0) {\r
-    if (AsciiStrnCmp (Language, SupportedLanguage, 3) == 0) {\r
-      Status = EFI_SUCCESS;\r
-    }\r
-\r
-    SupportedLanguage += 3;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if (ActionRequired == NULL || ControllerHandle == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (ChildHandle != NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Validate controller handle\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (VOID **)&BlockIo,\r
-                  gEmuBlockIoDriverBinding.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-          ControllerHandle,\r
-          &gEmuIoThunkProtocolGuid,\r
-          gEmuBlockIoDriverBinding.DriverBindingHandle,\r
-          ControllerHandle\r
-          );\r
-\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (Status == EFI_UNSUPPORTED) {\r
-    return Status;\r
-  } else if (Status != EFI_ALREADY_STARTED) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *ActionRequired = EfiDriverConfigurationActionNone;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Tests to see if a controller's current configuration options are valid.\r
-\r
-  Arguments:\r
-    This             - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.\r
-    ControllerHandle - The handle of the controller to test if it's current \r
-                       configuration options are valid.\r
-    ChildHandle      - The handle of the child controller to test if it's current\r
-                       configuration options are valid.  This is an optional \r
-                       parameter that may be NULL.  It will be NULL for device \r
-                       drivers.  It will also be NULL for a bus drivers that wish\r
-                       to test the configuration options for the bus controller.\r
-                       It will not be NULL for a bus driver that wishes to test \r
-                       configuration options for one of its child controllers.\r
-\r
-  Returns:\r
-    EFI_SUCCESS           - The controller specified by ControllerHandle and \r
-                            ChildHandle that is being managed by the driver \r
-                            specified by This has a valid set of  configuration\r
-                            options.\r
-    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
-    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
-    EFI_UNSUPPORTED       - The driver specified by This is not currently \r
-                            managing the controller specified by ControllerHandle \r
-                            and ChildHandle.\r
-    EFI_DEVICE_ERROR      - The controller specified by ControllerHandle and \r
-                            ChildHandle that is being managed by the driver \r
-                            specified by This has an invalid set of configuration \r
-                            options.\r
-\r
---*/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoDriverConfigurationOptionsValid (\r
-  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL               *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle  OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
-\r
-  if (ChildHandle != NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (ControllerHandle == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Validate controller handle\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (VOID **)&BlockIo,\r
-                  gEmuBlockIoDriverBinding.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-          ControllerHandle,\r
-          &gEmuIoThunkProtocolGuid,\r
-          gEmuBlockIoDriverBinding.DriverBindingHandle,\r
-          ControllerHandle\r
-          );\r
-\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (Status == EFI_UNSUPPORTED) {\r
-    return Status;\r
-  } else if (Status != EFI_ALREADY_STARTED) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/*++\r
-\r
-  Routine Description:\r
-    Forces a driver to set the default configuration options for a controller.\r
-\r
-  Arguments:\r
-    This             - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.\r
-    ControllerHandle - The handle of the controller to force default configuration options on.\r
-    ChildHandle      - The handle of the child controller to force default configuration options on  This is an optional parameter that may be NULL.  It will be NULL for device drivers.  It will also be NULL for a bus drivers that wish to force default configuration options for the bus controller.  It will not be NULL for a bus driver that wishes to force default configuration options for one of its child controllers.\r
-    DefaultType      - The type of default configuration options to force on the controller specified by ControllerHandle and ChildHandle.  See Table 9-1 for legal values.  A DefaultType of 0x00000000 must be supported by this protocol.\r
-    ActionRequired   - A pointer to the action that the calling agent is required to perform when this function returns.  See "Related Definitions" in Section 9.1for a list of the actions that the calling agent is required to perform prior to accessing ControllerHandle again.\r
-\r
-  Returns:\r
-    EFI_SUCCESS           - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
-    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
-    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
-    EFI_INVALID_PARAMETER - ActionRequired is NULL.\r
-    EFI_UNSUPPORTED       - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
-    EFI_UNSUPPORTED       - The driver specified by This does not support the configuration type specified by DefaultType.\r
-    EFI_DEVICE_ERROR      - A device error occurred while attempt to force the default configuration options on the controller specified by  ControllerHandle and ChildHandle.\r
-    EFI_OUT_RESOURCES     - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.\r
-\r
---*/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoDriverConfigurationForceDefaults (\r
-  IN  EFI_DRIVER_CONFIGURATION_PROTOCOL                      *This,\r
-  IN  EFI_HANDLE                                             ControllerHandle,\r
-  IN  EFI_HANDLE                                             ChildHandle  OPTIONAL,\r
-  IN  UINT32                                                 DefaultType,\r
-  OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED               *ActionRequired\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
-\r
-  if (ChildHandle != NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (ActionRequired == NULL || ControllerHandle == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Validate controller handle\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (VOID **)&BlockIo,\r
-                  gEmuBlockIoDriverBinding.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-          ControllerHandle,\r
-          &gEmuIoThunkProtocolGuid,\r
-          gEmuBlockIoDriverBinding.DriverBindingHandle,\r
-          ControllerHandle\r
-          );\r
-\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (Status == EFI_UNSUPPORTED) {\r
-    return Status;\r
-  } else if (Status != EFI_ALREADY_STARTED) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *ActionRequired = EfiDriverConfigurationActionNone;\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/InOsEmuPkg/EmuBlockIoDxe/DriverDiagnostics.c b/InOsEmuPkg/EmuBlockIoDxe/DriverDiagnostics.c
deleted file mode 100644 (file)
index ebb730b..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/**@file\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  DriverDiagnostics.c\r
-\r
-Abstract:\r
-\r
-**/\r
-\r
-#include "EmuBlockIo.h"\r
-\r
-//\r
-// EFI Driver Diagnostics Functions\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoDriverDiagnosticsRunDiagnostics (\r
-  IN  EFI_DRIVER_DIAGNOSTICS_PROTOCOL               *This,\r
-  IN  EFI_HANDLE                                    ControllerHandle,\r
-  IN  EFI_HANDLE                                    ChildHandle  OPTIONAL,\r
-  IN  EFI_DRIVER_DIAGNOSTIC_TYPE                    DiagnosticType,\r
-  IN  CHAR8                                         *Language,\r
-  OUT EFI_GUID                                      **ErrorType,\r
-  OUT UINTN                                         *BufferSize,\r
-  OUT CHAR16                                        **Buffer\r
-  );\r
-\r
-//\r
-// EFI Driver Diagnostics Protocol\r
-//\r
-EFI_DRIVER_DIAGNOSTICS_PROTOCOL gEmuBlockIoDriverDiagnostics = {\r
-  EmuBlockIoDriverDiagnosticsRunDiagnostics,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Driver Diagnostics 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gEmuBlockIoDriverDiagnostics2 = {\r
-  (EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS) EmuBlockIoDriverDiagnosticsRunDiagnostics,\r
-  "en"\r
-};\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoDriverDiagnosticsRunDiagnostics (\r
-  IN  EFI_DRIVER_DIAGNOSTICS_PROTOCOL               *This,\r
-  IN  EFI_HANDLE                                    ControllerHandle,\r
-  IN  EFI_HANDLE                                    ChildHandle  OPTIONAL,\r
-  IN  EFI_DRIVER_DIAGNOSTIC_TYPE                    DiagnosticType,\r
-  IN  CHAR8                                         *Language,\r
-  OUT EFI_GUID                                      **ErrorType,\r
-  OUT UINTN                                         *BufferSize,\r
-  OUT CHAR16                                        **Buffer\r
-  )\r
-/*++\r
-\r
-  Routine Description:\r
-    Runs diagnostics on a controller.\r
-\r
-  Arguments:\r
-    This             - A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOL instance.\r
-    ControllerHandle - The handle of the controller to run diagnostics on.\r
-    ChildHandle      - The handle of the child controller to run diagnostics on  \r
-                       This is an optional parameter that may be NULL.  It will \r
-                       be NULL for device drivers.  It will also be NULL for a \r
-                       bus drivers that wish to run diagnostics on the bus \r
-                       controller.  It will not be NULL for a bus driver that \r
-                       wishes to run diagnostics on one of its child controllers.\r
-    DiagnosticType   - Indicates type of diagnostics to perform on the controller \r
-                       specified by ControllerHandle and ChildHandle.   See \r
-                       "Related Definitions" for the list of supported types.\r
-    Language         - A pointer to a three character ISO 639-2 language \r
-                       identifier or a Null-terminated ASCII string array indicating\r
-                       the language.  This is the language in which the optional\r
-                       error message should be returned in Buffer, and it must \r
-                       match one of the languages specified in SupportedLanguages.\r
-                       The number of languages supported by a driver is up to \r
-                       the driver writer.  \r
-    ErrorType        - A GUID that defines the format of the data returned in \r
-                       Buffer.  \r
-    BufferSize       - The size, in bytes, of the data returned in Buffer.  \r
-    Buffer           - A buffer that contains a Null-terminated Unicode string \r
-                       plus some additional data whose format is defined by \r
-                       ErrorType.  Buffer is allocated by this function with \r
-                       AllocatePool(), and it is the caller's responsibility \r
-                       to free it with a call to FreePool().  \r
-\r
-  Returns:\r
-    EFI_SUCCESS           - The controller specified by ControllerHandle and \r
-                            ChildHandle passed the diagnostic.\r
-    EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
-    EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
-                            EFI_HANDLE.\r
-    EFI_INVALID_PARAMETER - Language is NULL.\r
-    EFI_INVALID_PARAMETER - ErrorType is NULL.\r
-    EFI_INVALID_PARAMETER - BufferType is NULL.\r
-    EFI_INVALID_PARAMETER - Buffer is NULL.\r
-    EFI_UNSUPPORTED       - The driver specified by This does not support \r
-                            running diagnostics for the controller specified \r
-                            by ControllerHandle and ChildHandle.\r
-    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
-                            type of diagnostic specified by DiagnosticType.\r
-    EFI_UNSUPPORTED       - The driver specified by This does not support the \r
-                            language specified by Language.\r
-    EFI_OUT_OF_RESOURCES  - There are not enough resources available to complete\r
-                            the diagnostics.\r
-    EFI_OUT_OF_RESOURCES  - There are not enough resources available to return\r
-                            the status information in ErrorType, BufferSize, \r
-                            and Buffer.\r
-    EFI_DEVICE_ERROR      - The controller specified by ControllerHandle and \r
-                            ChildHandle did not pass the diagnostic.\r
-\r
---*/\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
-  CHAR8                 *SupportedLanguages;\r
-  BOOLEAN               Iso639Language;\r
-  BOOLEAN               Found;\r
-  UINTN                 Index;\r
-\r
-  if (Language         == NULL ||\r
-      ErrorType        == NULL ||\r
-      Buffer           == NULL ||\r
-      ControllerHandle == NULL ||\r
-      BufferSize       == NULL) {\r
-\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  SupportedLanguages = This->SupportedLanguages;\r
-  Iso639Language = (BOOLEAN)(This == &gEmuBlockIoDriverDiagnostics);\r
-  //\r
-  // Make sure Language is in the set of Supported Languages\r
-  //\r
-  Found = FALSE;\r
-  while (*SupportedLanguages != 0) {\r
-    if (Iso639Language) {\r
-      if (CompareMem (Language, SupportedLanguages, 3) == 0) {\r
-        Found = TRUE;\r
-      break;\r
-    }\r
-      SupportedLanguages += 3;\r
-    } else {\r
-      for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);\r
-      if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) {\r
-        Found = TRUE;\r
-        break;\r
-  }\r
-      SupportedLanguages += Index;\r
-      for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);\r
-    }\r
-  }\r
-  //\r
-  // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED\r
-  //\r
-  if (!Found) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  *ErrorType  = NULL;\r
-  *BufferSize = 0;\r
-  if (DiagnosticType != EfiDriverDiagnosticTypeStandard) {\r
-    *ErrorType  = &gEfiBlockIoProtocolGuid;\r
-    *BufferSize = 0x60;\r
-    Buffer = AllocatePool ((UINTN) (*BufferSize));\r
-    CopyMem (*Buffer, L"Windows Block I/O Driver Diagnostics Failed\n", *BufferSize);\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  //\r
-  // This is a device driver, so ChildHandle must be NULL.\r
-  //\r
-  if (ChildHandle != NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Validate controller handle\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (VOID **)&BlockIo,\r
-                  gEmuBlockIoDriverBinding.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    gBS->CloseProtocol (\r
-          ControllerHandle,\r
-          &gEmuIoThunkProtocolGuid,\r
-          gEmuBlockIoDriverBinding.DriverBindingHandle,\r
-          ControllerHandle\r
-          );\r
-\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (Status == EFI_UNSUPPORTED) {\r
-    return Status;\r
-  } else if (Status != EFI_ALREADY_STARTED) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/InOsEmuPkg/EmuBlockIoDxe/EmuBlockIo.c b/InOsEmuPkg/EmuBlockIoDxe/EmuBlockIo.c
deleted file mode 100644 (file)
index b679d8f..0000000
+++ /dev/null
@@ -1,747 +0,0 @@
-/**@file\r
-\r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-bbe\r
-**/\r
-\r
-#include "EmuBlockIo.h"\r
-\r
-\r
-/**\r
-  Reset the block device hardware.\r
-\r
-  @param[in]  This                 Indicates a pointer to the calling context.\r
-  @param[in]  ExtendedVerification Indicates that the driver may perform a more\r
-                                   exhausive verfication operation of the device\r
-                                   during reset.\r
-\r
-  @retval EFI_SUCCESS          The device was reset.\r
-  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
-                               not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIo2Reset (\r
-  IN EFI_BLOCK_IO2_PROTOCOL  *This,\r
-  IN BOOLEAN                 ExtendedVerification\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_BLOCK_IO_PRIVATE    *Private;\r
-  EFI_TPL                 OldTpl;\r
-\r
-  Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  Status = Private->Io->Reset (Private->Io, ExtendedVerification);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Read BufferSize bytes from Lba into Buffer.\r
-  \r
-  This function reads the requested number of blocks from the device. All the\r
-  blocks are read, or an error is returned.\r
-  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and\r
-  non-blocking I/O is being used, the Event associated with this request will\r
-  not be signaled.\r
-\r
-  @param[in]       This       Indicates a pointer to the calling context.\r
-  @param[in]       MediaId    Id of the media, changes every time the media is \r
-                              replaced.\r
-  @param[in]       Lba        The starting Logical Block Address to read from.\r
-  @param[in, out]  Token           A pointer to the token associated with the transaction.\r
-  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.  \r
-  @param[out]      Buffer     A pointer to the destination buffer for the data. The \r
-                              caller is responsible for either having implicit or \r
-                              explicit ownership of the buffer.\r
-\r
-  @retval EFI_SUCCESS           The read request was queued if Token->Event is\r
-                                not NULL.The data was read correctly from the\r
-                                device if the Token->Event is NULL.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing\r
-                                the read.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId is not for the current media.\r
-  @retval EFI_BAD_BUFFER_SIZE   The BufferSize parameter is not a multiple of the\r
-                                intrinsic block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
-                                or the buffer is not on proper alignment.\r
-  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack\r
-                                of resources.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIo2ReadBlocksEx (\r
-  IN     EFI_BLOCK_IO2_PROTOCOL *This,\r
-  IN     UINT32                 MediaId,\r
-  IN     EFI_LBA                LBA,\r
-  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
-  IN     UINTN                  BufferSize,\r
-     OUT VOID                  *Buffer\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_BLOCK_IO_PRIVATE    *Private;\r
-  EFI_TPL                 OldTpl;\r
-\r
-  Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  Status = Private->Io->ReadBlocks (Private->Io, MediaId, LBA, Token, BufferSize, Buffer);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Write BufferSize bytes from Lba into Buffer.\r
-\r
-  This function writes the requested number of blocks to the device. All blocks\r
-  are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,\r
-  EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is\r
-  being used, the Event associated with this request will not be signaled.\r
-\r
-  @param[in]       This       Indicates a pointer to the calling context.\r
-  @param[in]       MediaId    The media ID that the write request is for.\r
-  @param[in]       Lba        The starting logical block address to be written. The\r
-                              caller is responsible for writing to only legitimate\r
-                              locations.\r
-  @param[in, out]  Token      A pointer to the token associated with the transaction.\r
-  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param[in]       Buffer     A pointer to the source buffer for the data.\r
-\r
-  @retval EFI_SUCCESS           The write request was queued if Event is not NULL.\r
-                                The data was written correctly to the device if\r
-                                the Event is NULL.\r
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
-                                or the buffer is not on proper alignment.\r
-  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack\r
-                                of resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI \r
-EmuBlockIo2WriteBlocksEx (\r
-  IN     EFI_BLOCK_IO2_PROTOCOL  *This,\r
-  IN     UINT32                 MediaId,\r
-  IN     EFI_LBA                LBA,\r
-  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
-  IN     UINTN                  BufferSize,\r
-  IN     VOID                   *Buffer\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_BLOCK_IO_PRIVATE    *Private;\r
-  EFI_TPL                 OldTpl;\r
-\r
-  Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  Status = Private->Io->WriteBlocks (Private->Io, MediaId, LBA, Token, BufferSize, Buffer);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-/**\r
-  Flush the Block Device.\r
\r
-  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED\r
-  is returned and non-blocking I/O is being used, the Event associated with\r
-  this request will not be signaled.  \r
-\r
-  @param[in]      This     Indicates a pointer to the calling context.\r
-  @param[in,out]  Token    A pointer to the token associated with the transaction\r
-\r
-  @retval EFI_SUCCESS          The flush request was queued if Event is not NULL.\r
-                               All outstanding data was written correctly to the\r
-                               device if the Event is NULL.\r
-  @retval EFI_DEVICE_ERROR     The device reported an error while writting back\r
-                               the data.\r
-  @retval EFI_WRITE_PROTECTED  The device cannot be written to.\r
-  @retval EFI_NO_MEDIA         There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED    The MediaId is not for the current media.\r
-  @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
-                               of resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIo2Flush (\r
-  IN     EFI_BLOCK_IO2_PROTOCOL   *This,\r
-  IN OUT EFI_BLOCK_IO2_TOKEN      *Token\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_BLOCK_IO_PRIVATE    *Private;\r
-  EFI_TPL                 OldTpl;\r
-\r
-  Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  Status = Private->Io->FlushBlocks (Private->Io, Token);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-/**\r
-  Reset the Block Device.\r
-\r
-  @param  This                 Indicates a pointer to the calling context.\r
-  @param  ExtendedVerification Driver may perform diagnostics on reset.\r
-\r
-  @retval EFI_SUCCESS          The device was reset.\r
-  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
-                               not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoReset (\r
-  IN EFI_BLOCK_IO_PROTOCOL          *This,\r
-  IN BOOLEAN                        ExtendedVerification\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_BLOCK_IO_PRIVATE    *Private;\r
-  EFI_TPL                 OldTpl;\r
-\r
-  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  Status = Private->Io->Reset (Private->Io, ExtendedVerification);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Read BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    Id of the media, changes every time the media is replaced.\r
-  @param  Lba        The starting Logical Block Address to read from\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the destination buffer for the data. The caller is\r
-                     responsible for either having implicit or explicit ownership of the buffer.\r
-\r
-  @retval EFI_SUCCESS           The data was read correctly from the device.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the read.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoReadBlocks (\r
-  IN EFI_BLOCK_IO_PROTOCOL          *This,\r
-  IN UINT32                         MediaId,\r
-  IN EFI_LBA                        Lba,\r
-  IN UINTN                          BufferSize,\r
-  OUT VOID                          *Buffer\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_BLOCK_IO_PRIVATE    *Private;\r
-  EFI_TPL                 OldTpl;\r
-  EFI_BLOCK_IO2_TOKEN     Token;\r
-\r
-  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  Token.Event = NULL;\r
-  Status = Private->Io->ReadBlocks (Private->Io, MediaId, Lba, &Token, BufferSize, Buffer);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Write BufferSize bytes from Lba into Buffer.\r
-\r
-  @param  This       Indicates a pointer to the calling context.\r
-  @param  MediaId    The media ID that the write request is for.\r
-  @param  Lba        The starting logical block address to be written. The caller is\r
-                     responsible for writing to only legitimate locations.\r
-  @param  BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param  Buffer     A pointer to the source buffer for the data.\r
-\r
-  @retval EFI_SUCCESS           The data was written correctly to the device.\r
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
-                                or the buffer is not on proper alignment.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoWriteBlocks (\r
-  IN EFI_BLOCK_IO_PROTOCOL          *This,\r
-  IN UINT32                         MediaId,\r
-  IN EFI_LBA                        Lba,\r
-  IN UINTN                          BufferSize,\r
-  IN VOID                           *Buffer\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_BLOCK_IO_PRIVATE    *Private;\r
-  EFI_TPL                 OldTpl;\r
-  EFI_BLOCK_IO2_TOKEN     Token;\r
-\r
-  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  Token.Event = NULL;\r
-  Status = Private->Io->WriteBlocks (Private->Io, MediaId, Lba, &Token, BufferSize, Buffer);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Flush the Block Device.\r
-\r
-  @param  This              Indicates a pointer to the calling context.\r
-\r
-  @retval EFI_SUCCESS       All outstanding data was written to the device\r
-  @retval EFI_DEVICE_ERROR  The device reported an error while writting back the data\r
-  @retval EFI_NO_MEDIA      There is no media in the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoFlushBlocks (\r
-  IN EFI_BLOCK_IO_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_BLOCK_IO_PRIVATE    *Private;\r
-  EFI_TPL                 OldTpl;\r
-  EFI_BLOCK_IO2_TOKEN     Token;\r
-\r
-  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  Token.Event = NULL;\r
-  Status = Private->Io->FlushBlocks (Private->Io, &Token);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-/**\r
-  Tests to see if this driver supports a given controller. If a child device is provided, \r
-  it further tests to see if this driver supports creating a handle for the specified child device.\r
-\r
-  This function checks to see if the driver specified by This supports the device specified by \r
-  ControllerHandle. Drivers will typically use the device path attached to \r
-  ControllerHandle and/or the services from the bus I/O abstraction attached to \r
-  ControllerHandle to determine if the driver supports ControllerHandle. This function \r
-  may be called many times during platform initialization. In order to reduce boot times, the tests \r
-  performed by this function must be very small, and take as little time as possible to execute. This \r
-  function must not change the state of any hardware devices, and this function must be aware that the \r
-  device specified by ControllerHandle may already be managed by the same driver or a \r
-  different driver. This function must match its calls to AllocatePages() with FreePages(), \r
-  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().  \r
-  Because ControllerHandle may have been previously started by the same driver, if a protocol is \r
-  already in the opened state, then it must not be closed with CloseProtocol(). This is required \r
-  to guarantee the state of ControllerHandle is not modified by this function.\r
-\r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to test. This handle \r
-                                   must support a protocol interface that supplies \r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
-                                   parameter is ignored by device drivers, and is optional for bus \r
-                                   drivers. For bus drivers, if this parameter is not NULL, then \r
-                                   the bus driver must determine if the bus controller specified \r
-                                   by ControllerHandle and the child controller specified \r
-                                   by RemainingDevicePath are both supported by this \r
-                                   bus driver.\r
-\r
-  @retval EFI_SUCCESS              The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is supported by the driver specified by This.\r
-  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is already being managed by the driver\r
-                                   specified by This.\r
-  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is already being managed by a different\r
-                                   driver or an application that requires exclusive access.\r
-                                   Currently not implemented.\r
-  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is not supported by the driver specified by This.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoDriverBindingSupported (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   Handle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_IO_THUNK_PROTOCOL   *EmuIoThunk;\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Handle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (VOID **)&EmuIoThunk,\r
-                  This->DriverBindingHandle,\r
-                  Handle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Make sure GUID is for a File System handle.\r
-  //\r
-  Status = EFI_UNSUPPORTED;\r
-  if (CompareGuid (EmuIoThunk->Protocol, &gEmuBlockIoProtocolGuid)) {\r
-    Status = EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
-  //\r
-  gBS->CloseProtocol (\r
-        Handle,\r
-        &gEmuIoThunkProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Handle\r
-        );\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Starts a device controller or a bus controller.\r
-\r
-  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
-  As a result, much of the error checking on the parameters to Start() has been moved into this \r
-  common boot service. It is legal to call Start() from other locations, \r
-  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE.\r
-  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
-     EFI_DEVICE_PATH_PROTOCOL.\r
-  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
-     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.  \r
-\r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to start. This handle \r
-                                   must support a protocol interface that supplies \r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
-                                   parameter is ignored by device drivers, and is optional for bus \r
-                                   drivers. For a bus driver, if this parameter is NULL, then handles \r
-                                   for all the children of Controller are created by this driver.  \r
-                                   If this parameter is not NULL and the first Device Path Node is \r
-                                   not the End of Device Path Node, then only the handle for the \r
-                                   child device specified by the first Device Path Node of \r
-                                   RemainingDevicePath is created by this driver.\r
-                                   If the first Device Path Node of RemainingDevicePath is \r
-                                   the End of Device Path Node, no child handle is created by this\r
-                                   driver.\r
-\r
-  @retval EFI_SUCCESS              The device was started.\r
-  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.Currently not implemented.\r
-  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
-  @retval Others                   The driver failded to start the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoDriverBindingStart (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
-  IN  EFI_HANDLE                    Handle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EMU_IO_THUNK_PROTOCOL       *EmuIoThunk;\r
-  EMU_BLOCK_IO_PRIVATE        *Private = NULL;\r
-\r
-  //\r
-  // Grab the protocols we need\r
-  //\r
-  \r
-  Status = gBS->OpenProtocol (\r
-                  Handle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (void *)&EmuIoThunk,\r
-                  This->DriverBindingHandle,\r
-                  Handle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  \r
-  if (!CompareGuid (EmuIoThunk->Protocol, &gEmuBlockIoProtocolGuid)) {\r
-    Status = EFI_UNSUPPORTED;\r
-    goto Done;\r
-  }\r
-\r
-  Status = EmuIoThunk->Open (EmuIoThunk);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  Private = AllocatePool (sizeof (EMU_BLOCK_IO_PRIVATE));\r
-  if (Private == NULL) {\r
-    goto Done;\r
-  }\r
-\r
-  Private->Signature = EMU_BLOCK_IO_PRIVATE_SIGNATURE;\r
-  Private->IoThunk   = EmuIoThunk;\r
-  Private->Io        = EmuIoThunk->Interface;\r
-  Private->EfiHandle = Handle;\r
-  \r
-  Private->BlockIo.Revision    = EFI_BLOCK_IO_PROTOCOL_REVISION2;\r
-  Private->BlockIo.Media       = &Private->Media;\r
-  Private->BlockIo.Reset       = EmuBlockIoReset;\r
-  Private->BlockIo.ReadBlocks  = EmuBlockIoReadBlocks;\r
-  Private->BlockIo.WriteBlocks = EmuBlockIoWriteBlocks;\r
-  Private->BlockIo.FlushBlocks = EmuBlockIoFlushBlocks;\r
-\r
-  Private->BlockIo2.Media         = &Private->Media;\r
-  Private->BlockIo2.Reset         = EmuBlockIo2Reset;\r
-  Private->BlockIo2.ReadBlocksEx  = EmuBlockIo2ReadBlocksEx;\r
-  Private->BlockIo2.WriteBlocksEx = EmuBlockIo2WriteBlocksEx;\r
-  Private->BlockIo2.FlushBlocksEx = EmuBlockIo2Flush;\r
-\r
-  Private->ControllerNameTable = NULL;\r
-\r
-  Status = Private->Io->CreateMapping (Private->Io, &Private->Media);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  AddUnicodeString2 (\r
-    "eng",\r
-    gEmuBlockIoComponentName.SupportedLanguages,\r
-    &Private->ControllerNameTable,\r
-    EmuIoThunk->ConfigString,\r
-    TRUE\r
-    );\r
-    \r
-  AddUnicodeString2 (\r
-    "en",\r
-    gEmuBlockIoComponentName2.SupportedLanguages,\r
-    &Private->ControllerNameTable,\r
-    EmuIoThunk->ConfigString,\r
-    FALSE\r
-    );\r
-\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Handle,\r
-                  &gEfiBlockIoProtocolGuid,    &Private->BlockIo,\r
-                  &gEfiBlockIo2ProtocolGuid,   &Private->BlockIo2,\r
-                  NULL\r
-                  );\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-    if (Private != NULL) {\r
-      if (Private->ControllerNameTable != NULL) {\r
-        FreeUnicodeStringTable (Private->ControllerNameTable);\r
-      }\r
-      \r
-      gBS->FreePool (Private);\r
-    \r
-    }\r
-    \r
-    gBS->CloseProtocol (\r
-          Handle,\r
-          &gEmuIoThunkProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          Handle\r
-          );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Stops a device controller or a bus controller.\r
-  \r
-  The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
-  As a result, much of the error checking on the parameters to Stop() has been moved \r
-  into this common boot service. It is legal to call Stop() from other locations, \r
-  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
-     same driver's Start() function.\r
-  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
-     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
-     Start() function, and the Start() function must have called OpenProtocol() on\r
-     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
-  \r
-  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must \r
-                                support a bus specific I/O protocol for the driver \r
-                                to use to stop the device.\r
-  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
-  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL \r
-                                if NumberOfChildren is 0.\r
-\r
-  @retval EFI_SUCCESS           The device was stopped.\r
-  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBlockIoDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   Handle,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_BLOCK_IO_PROTOCOL   *BlockIo;\r
-  EFI_STATUS              Status;\r
-  EMU_BLOCK_IO_PRIVATE *Private;\r
-\r
-  //\r
-  // Get our context back\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Handle,\r
-                  &gEfiBlockIoProtocolGuid,\r
-                  (void *)&BlockIo,\r
-                  This->DriverBindingHandle,\r
-                  Handle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo);\r
-  Status = Private->IoThunk->Close (Private->IoThunk);\r
-\r
-  Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                  Private->EfiHandle,\r
-                  &gEfiBlockIoProtocolGuid,   &Private->BlockIo,\r
-                  &gEfiBlockIo2ProtocolGuid,  &Private->BlockIo2,\r
-                  NULL\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = gBS->CloseProtocol (\r
-                    Handle,\r
-                    &gEmuIoThunkProtocolGuid,\r
-                    This->DriverBindingHandle,\r
-                    Handle\r
-                    );\r
-  }\r
-  \r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Free our instance data\r
-    //\r
-    FreeUnicodeStringTable (Private->ControllerNameTable);\r
-    gBS->FreePool (Private);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-\r
-\r
-EFI_DRIVER_BINDING_PROTOCOL gEmuBlockIoDriverBinding = {\r
-  EmuBlockIoDriverBindingSupported,\r
-  EmuBlockIoDriverBindingStart,\r
-  EmuBlockIoDriverBindingStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-\r
-\r
-\r
-/**\r
-  The user Entry Point for module EmuBlockIo . The user code starts with this function.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-  \r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeEmuBlockIo (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  Status = EfiLibInstallAllDriverProtocols2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gEmuBlockIoDriverBinding,\r
-             ImageHandle,\r
-             &gEmuBlockIoComponentName,\r
-             &gEmuBlockIoComponentName2,\r
-             NULL,\r
-             NULL,\r
-             &gEmuBlockIoDriverDiagnostics,\r
-             &gEmuBlockIoDriverDiagnostics2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-\r
diff --git a/InOsEmuPkg/EmuBlockIoDxe/EmuBlockIo.h b/InOsEmuPkg/EmuBlockIoDxe/EmuBlockIo.h
deleted file mode 100644 (file)
index b11f305..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  EmuBlockIo.h\r
-\r
-Abstract:\r
-\r
-  Produce block IO abstractions for real devices on your PC using Posix APIs.\r
-  The configuration of what devices to mount or emulate comes from UNIX \r
-  environment variables. The variables must be visible to the Microsoft* \r
-  Developer Studio for them to work.\r
-\r
-  * Other names and brands may be claimed as the property of others.\r
-\r
-**/\r
-\r
-#ifndef _EMU_BLOCK_IO_H_\r
-#define _EMU_BLOCK_IO_H_\r
-\r
-#include <PiDxe.h>\r
-#include <Protocol/EmuIoThunk.h>\r
-#include <Protocol/BlockIo.h>\r
-#include <Protocol/BlockIo2.h>\r
-#include <Protocol/EmuBlockIo.h>\r
-\r
-#include <Guid/EmuPhysicalDisk.h>\r
-#include <Guid/EmuVirtualDisk.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-\r
-//\r
-// Language supported for driverconfiguration protocol\r
-//\r
-\r
-#define EMU_BLOCK_IO_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'M', 'b', 'k')\r
-typedef struct {\r
-  UINTN                       Signature;\r
-  EMU_IO_THUNK_PROTOCOL       *IoThunk;\r
-  EMU_BLOCK_IO_PROTOCOL       *Io;\r
-\r
-  EFI_HANDLE                  EfiHandle;\r
-  EFI_BLOCK_IO_PROTOCOL       BlockIo;\r
-  EFI_BLOCK_IO2_PROTOCOL      BlockIo2;\r
-  EFI_BLOCK_IO_MEDIA          Media;\r
-\r
-  EFI_UNICODE_STRING_TABLE    *ControllerNameTable;\r
-\r
-} EMU_BLOCK_IO_PRIVATE;\r
-\r
-#define EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \\r
-         CR(a, EMU_BLOCK_IO_PRIVATE, BlockIo, EMU_BLOCK_IO_PRIVATE_SIGNATURE)\r
-\r
-#define EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS(a) \\r
-         CR(a, EMU_BLOCK_IO_PRIVATE, BlockIo2, EMU_BLOCK_IO_PRIVATE_SIGNATURE)\r
-\r
-\r
-//\r
-// Block I/O Global Variables\r
-//\r
-extern EFI_DRIVER_BINDING_PROTOCOL        gEmuBlockIoDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL        gEmuBlockIoComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL       gEmuBlockIoComponentName2;\r
-extern EFI_DRIVER_CONFIGURATION_PROTOCOL  gEmuBlockIoDriverConfiguration;\r
-extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL    gEmuBlockIoDriverDiagnostics;\r
-extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL   gEmuBlockIoDriverDiagnostics2;\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf b/InOsEmuPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf
deleted file mode 100644 (file)
index 82460e4..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-## @file\r
-# Block Io driver\r
-#\r
-# Produce block IO abstractions for real devices on your PC using Unix APIs.\r
-#  The configuration of what devices to mount or emulate comes from\r
-#  environment variables.\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuBlockIo\r
-  FILE_GUID                      = C6760651-A38D-5F4F-AEAF-F6661549DF75\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = InitializeEmuBlockIo\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-#  DRIVER_BINDING                =  gUnixBlockIoDriverBinding                    \r
-#  COMPONENT_NAME                =  gUnixBlockIoComponentName                    \r
-#  DRIVER_DIAG                   =  gUnixBlockIoDriverDiagnostics                \r
-#\r
-\r
-[Sources]\r
-  DriverDiagnostics.c\r
-  DriverConfiguration.c\r
-  ComponentName.c\r
-  EmuBlockIo.c\r
-  EmuBlockIo.h\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  BaseLib\r
-  DebugLib\r
-\r
-\r
-[Guids]\r
-  gEmuPhysicalDisksGuid                    # SOMETIMES_CONSUMED\r
-  gEmuVirtualDisksGuid                     # ALWAYS_CONSUMED\r
-\r
-\r
-[Protocols]\r
-  gEfiBlockIoProtocolGuid                     # PROTOCOL BY_START\r
-  gEfiBlockIo2ProtocolGuid                    # PROTOCOL BY_START\r
-  gEmuIoThunkProtocolGuid                     # PROTOCOL TO_START\r
-  gEmuBlockIoProtocolGuid                     # PROTOCOL BY_START\r
diff --git a/InOsEmuPkg/EmuBusDriverDxe/ComponentName.c b/InOsEmuPkg/EmuBusDriverDxe/ComponentName.c
deleted file mode 100644 (file)
index e8be214..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-**/\r
-\r
-#include "EmuBusDriverDxe.h"\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBusDriverComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBusDriverComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL     gEmuBusDriverComponentName = {\r
-  EmuBusDriverComponentNameGetDriverName,\r
-  EmuBusDriverComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuBusDriverComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuBusDriverComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuBusDriverNameTable[] = {\r
-  { "eng", L"Emu Bus Driver" },\r
-  { NULL , NULL }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBusDriverComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-          Language,\r
-          This->SupportedLanguages,\r
-          mEmuBusDriverNameTable,\r
-          DriverName,\r
-          (BOOLEAN)(This == &gEmuBusDriverComponentName)\r
-          );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBusDriverComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_IO_THUNK_PROTOCOL   *EmuIo;\r
-  EMU_IO_DEVICE           *Private;\r
-\r
-  //\r
-  // Make sure this driver is currently managing ControllHandle\r
-  //\r
-  Status = EfiTestManagedDevice (\r
-             ControllerHandle,\r
-             gEmuBusDriverBinding.DriverBindingHandle,\r
-             &gEmuThunkProtocolGuid\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // This is a bus driver, so ChildHandle can not be NULL.\r
-  //\r
-  if (ChildHandle == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = EfiTestChildHandle (\r
-             ControllerHandle,\r
-             ChildHandle,\r
-             &gEmuThunkProtocolGuid\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Get our context back\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ChildHandle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (VOID**)&EmuIo,\r
-                  gEmuBusDriverBinding.DriverBindingHandle,\r
-                  ChildHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Private = EMU_IO_DEVICE_FROM_THIS (EmuIo);\r
-\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           Private->ControllerNameTable,\r
-           ControllerName,\r
-           (BOOLEAN)(This == &gEmuBusDriverComponentName)\r
-          );\r
-}\r
diff --git a/InOsEmuPkg/EmuBusDriverDxe/EmuBusDriverDxe.c b/InOsEmuPkg/EmuBusDriverDxe/EmuBusDriverDxe.c
deleted file mode 100644 (file)
index b590ed2..0000000
+++ /dev/null
@@ -1,529 +0,0 @@
-/** @file\r
- Emu Bus driver\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-**/\r
-\r
-#include "EmuBusDriverDxe.h"\r
-\r
-\r
-\r
-//\r
-// DriverBinding protocol global\r
-//\r
-EFI_DRIVER_BINDING_PROTOCOL           gEmuBusDriverBinding = {\r
-  EmuBusDriverBindingSupported,\r
-  EmuBusDriverBindingStart,\r
-  EmuBusDriverBindingStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBusDriverBindingSupported (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
-  EMU_THUNK_PROTOCOL        *EmuThunk;\r
-\r
-  //\r
-  // Check the contents of the first Device Path Node of RemainingDevicePath to make sure\r
-  // it is a legal Device Path Node for this bus driver's children.\r
-  //\r
-  if (RemainingDevicePath != NULL) {\r
-    //\r
-    // Check if RemainingDevicePath is the End of Device Path Node, \r
-    // if yes, go on checking other conditions\r
-    //\r
-    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
-      //\r
-      // If RemainingDevicePath isn't the End of Device Path Node,\r
-      // check its validation\r
-      //\r
-      if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH ||\r
-          RemainingDevicePath->SubType != HW_VENDOR_DP ||\r
-          DevicePathNodeLength(RemainingDevicePath) != sizeof(EMU_VENDOR_DEVICE_PATH_NODE)) {\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-    }\r
-  }\r
-  \r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEmuThunkProtocolGuid,\r
-                  (VOID **)&EmuThunk   ,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
-  //\r
-  gBS->CloseProtocol (\r
-        ControllerHandle,\r
-        &gEmuThunkProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        ControllerHandle\r
-        );\r
-\r
-  //\r
-  // Open the EFI Device Path protocol needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **)&ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-\r
-  //\r
-  // Close protocol, don't use device path protocol in the Support() function\r
-  //\r
-  gBS->CloseProtocol (\r
-        ControllerHandle,\r
-        &gEfiDevicePathProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        ControllerHandle\r
-        );\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBusDriverBindingStart (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  EFI_STATUS                      InstallStatus;\r
-  EMU_THUNK_PROTOCOL              *EmuThunk;\r
-  EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;\r
-  EMU_IO_DEVICE                   *EmuDevice;\r
-  EMU_BUS_DEVICE                  *EmuBusDevice;\r
-  EMU_IO_THUNK_PROTOCOL           *EmuIoThunk;\r
-  UINT16                          ComponentName[512];\r
-  EMU_VENDOR_DEVICE_PATH_NODE     *Node;\r
-  BOOLEAN                         CreateDevice;\r
-\r
-  InstallStatus = EFI_UNSUPPORTED;\r
-  Status = EFI_UNSUPPORTED;\r
-\r
-  //\r
-  // Grab the protocols we need\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **)&ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
-    return Status;\r
-  }\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEmuThunkProtocolGuid,\r
-                  (VOID **)&EmuThunk,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
-    return Status;\r
-  }\r
-\r
-  if (Status != EFI_ALREADY_STARTED) {\r
-    EmuBusDevice = AllocatePool (sizeof (EMU_BUS_DEVICE));\r
-    if (EmuBusDevice == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    EmuBusDevice->Signature           = EMU_BUS_DEVICE_SIGNATURE;\r
-    EmuBusDevice->ControllerNameTable = NULL;\r
-\r
-    AddUnicodeString2 (\r
-      "eng",\r
-      gEmuBusDriverComponentName.SupportedLanguages,\r
-      &EmuBusDevice->ControllerNameTable,\r
-      L"InOsEmu Bus Controller",\r
-      TRUE\r
-      );\r
-    AddUnicodeString2 (\r
-      "en",\r
-      gEmuBusDriverComponentName2.SupportedLanguages,\r
-      &EmuBusDevice->ControllerNameTable,\r
-      L"InOsEmu Bus Controller",\r
-      FALSE\r
-      );\r
-\r
-\r
-    Status = gBS->InstallMultipleProtocolInterfaces (\r
-                    &ControllerHandle,\r
-                    &gEfiCallerIdGuid, EmuBusDevice,\r
-                    NULL\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      FreeUnicodeStringTable (EmuBusDevice->ControllerNameTable);\r
-      gBS->FreePool (EmuBusDevice);\r
-      return Status;\r
-    }\r
-  }\r
-\r
-\r
-  for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) {\r
-    Status = EmuThunk->GetNextProtocol (TRUE, &EmuIoThunk);\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-\r
-    CreateDevice = TRUE;\r
-    if (RemainingDevicePath != NULL) {\r
-      CreateDevice  = FALSE;\r
-      //\r
-      // Check if RemainingDevicePath is the End of Device Path Node, \r
-      // if yes, don't create any child device \r
-      //\r
-      if (!IsDevicePathEnd (RemainingDevicePath)) {\r
-        //\r
-        // If RemainingDevicePath isn't the End of Device Path Node,\r
-        // check its validation\r
-        //\r
-        Node          = (EMU_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath;\r
-        if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH &&\r
-            Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP &&\r
-            DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (EMU_VENDOR_DEVICE_PATH_NODE)\r
-            ) {\r
-          if (CompareGuid (&Node->VendorDevicePath.Guid, EmuIoThunk->Protocol) && Node->Instance == EmuIoThunk->Instance) {\r
-            CreateDevice = TRUE;\r
-          }\r
-        }\r
-      }\r
-    }\r
-\r
-    if (CreateDevice) {\r
-      //\r
-      // Allocate instance structure, and fill in parent information.\r
-      //\r
-      EmuDevice = AllocatePool (sizeof (EMU_IO_DEVICE));\r
-      if (EmuDevice == NULL) {\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      EmuDevice->Handle             = NULL;\r
-      EmuDevice->ControllerHandle   = ControllerHandle;\r
-      EmuDevice->ParentDevicePath   = ParentDevicePath;\r
-      CopyMem (&EmuDevice->EmuIoThunk, EmuIoThunk, sizeof (EMU_IO_THUNK_PROTOCOL));\r
-      \r
-      EmuDevice->ControllerNameTable = NULL;\r
-\r
-      StrnCpy (ComponentName, EmuIoThunk->ConfigString, sizeof (ComponentName)/sizeof (CHAR16));\r
-\r
-      EmuDevice->DevicePath = EmuBusCreateDevicePath (\r
-                                  ParentDevicePath,\r
-                                  EmuIoThunk->Protocol,\r
-                                  EmuIoThunk->Instance\r
-                                  );\r
-      if (EmuDevice->DevicePath == NULL) {\r
-        gBS->FreePool (EmuDevice);\r
-        return EFI_OUT_OF_RESOURCES;\r
-      }\r
-\r
-      AddUnicodeString (\r
-        "eng",\r
-        gEmuBusDriverComponentName.SupportedLanguages,\r
-        &EmuDevice->ControllerNameTable,\r
-        ComponentName\r
-        );\r
-\r
-      EmuDevice->Signature = EMU_IO_DEVICE_SIGNATURE;\r
-\r
-      InstallStatus = gBS->InstallMultipleProtocolInterfaces (\r
-                            &EmuDevice->Handle,\r
-                            &gEfiDevicePathProtocolGuid,  EmuDevice->DevicePath,\r
-                            &gEmuIoThunkProtocolGuid,     &EmuDevice->EmuIoThunk,\r
-                            NULL\r
-                            );\r
-      if (EFI_ERROR (InstallStatus)) {\r
-        FreeUnicodeStringTable (EmuDevice->ControllerNameTable);\r
-        gBS->FreePool (EmuDevice);\r
-      } else {\r
-        //\r
-        // Open For Child Device\r
-        //\r
-        Status = gBS->OpenProtocol (\r
-                        ControllerHandle,\r
-                        &gEmuThunkProtocolGuid,\r
-                        (VOID **)&EmuThunk   ,\r
-                        This->DriverBindingHandle,\r
-                        EmuDevice->Handle,\r
-                        EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-                        );\r
-        if (!EFI_ERROR (Status)) {\r
-          InstallStatus = EFI_SUCCESS;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  return InstallStatus;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBusDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  UINTN                     Index;\r
-  BOOLEAN                   AllChildrenStopped;\r
-  EMU_IO_THUNK_PROTOCOL     *EmuIoThunk;\r
-  EMU_BUS_DEVICE            *EmuBusDevice;\r
-  EMU_IO_DEVICE             *EmuDevice;\r
-  EMU_THUNK_PROTOCOL        *EmuThunk;\r
-\r
-  //\r
-  // Complete all outstanding transactions to Controller.\r
-  // Don't allow any new transaction to Controller to be started.\r
-  //\r
-\r
-  if (NumberOfChildren == 0) {\r
-    //\r
-    // Close the bus driver\r
-    //\r
-    Status = gBS->OpenProtocol (\r
-                    ControllerHandle,\r
-                    &gEfiCallerIdGuid,\r
-                    (VOID **)&EmuBusDevice,\r
-                    This->DriverBindingHandle,\r
-                    ControllerHandle,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    gBS->UninstallMultipleProtocolInterfaces (\r
-          ControllerHandle,\r
-          &gEfiCallerIdGuid,  EmuBusDevice,\r
-          NULL\r
-          );\r
-\r
-    FreeUnicodeStringTable (EmuBusDevice->ControllerNameTable);\r
-\r
-    gBS->FreePool (EmuBusDevice);\r
-\r
-    gBS->CloseProtocol (\r
-          ControllerHandle,\r
-          &gEmuThunkProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          ControllerHandle\r
-          );\r
-\r
-    gBS->CloseProtocol (\r
-          ControllerHandle,\r
-          &gEfiDevicePathProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          ControllerHandle\r
-          );\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  AllChildrenStopped = TRUE;\r
-\r
-  for (Index = 0; Index < NumberOfChildren; Index++) {\r
-\r
-    Status = gBS->OpenProtocol (\r
-                    ChildHandleBuffer[Index],\r
-                    &gEmuIoThunkProtocolGuid,\r
-                    (VOID **)&EmuIoThunk,\r
-                    This->DriverBindingHandle,\r
-                    ControllerHandle,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      EmuDevice = EMU_IO_DEVICE_FROM_THIS (EmuIoThunk);\r
-\r
-      Status = gBS->CloseProtocol (\r
-                      ControllerHandle,\r
-                      &gEmuThunkProtocolGuid,\r
-                      This->DriverBindingHandle,\r
-                      EmuDevice->Handle\r
-                      );\r
-\r
-      Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                      EmuDevice->Handle,\r
-                      &gEfiDevicePathProtocolGuid,  EmuDevice->DevicePath,\r
-                      &gEmuIoThunkProtocolGuid,     EmuDevice->EmuIoThunk,\r
-                      NULL\r
-                      );\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        gBS->OpenProtocol (\r
-              ControllerHandle,\r
-              &gEmuThunkProtocolGuid,\r
-              (VOID **) &EmuThunk   ,\r
-              This->DriverBindingHandle,\r
-              EmuDevice->Handle,\r
-              EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-              );\r
-      } else {\r
-        //\r
-        // Close the child handle\r
-        //\r
-        FreeUnicodeStringTable (EmuDevice->ControllerNameTable);\r
-        FreePool (EmuDevice);\r
-      }\r
-    }\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      AllChildrenStopped = FALSE;\r
-    }\r
-  }\r
-\r
-  if (!AllChildrenStopped) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/*++\r
-\r
-Routine Description:\r
-  Create a device path node using Guid and InstanceNumber and append it to\r
-  the passed in RootDevicePath\r
-\r
-Arguments:\r
-  RootDevicePath - Root of the device path to return.\r
-\r
-  Guid           - GUID to use in vendor device path node.\r
-\r
-  InstanceNumber - Instance number to use in the vendor device path. This\r
-                    argument is needed to make sure each device path is unique.\r
-\r
-Returns:\r
-\r
-  EFI_DEVICE_PATH_PROTOCOL \r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EmuBusCreateDevicePath (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *RootDevicePath,\r
-  IN  EFI_GUID                  *Guid,\r
-  IN  UINT16                    InstanceNumber\r
-  )\r
-{\r
-  EMU_VENDOR_DEVICE_PATH_NODE  DevicePath;\r
-\r
-  DevicePath.VendorDevicePath.Header.Type     = HARDWARE_DEVICE_PATH;\r
-  DevicePath.VendorDevicePath.Header.SubType  = HW_VENDOR_DP;\r
-  SetDevicePathNodeLength (&DevicePath.VendorDevicePath.Header, sizeof (EMU_VENDOR_DEVICE_PATH_NODE));\r
-\r
-  //\r
-  // The GUID defines the Class\r
-  //\r
-  CopyMem (&DevicePath.VendorDevicePath.Guid, Guid, sizeof (EFI_GUID));\r
-\r
-  //\r
-  // Add an instance number so we can make sure there are no Device Path\r
-  // duplication.\r
-  //\r
-  DevicePath.Instance = InstanceNumber;\r
-\r
-  return AppendDevicePathNode (\r
-          RootDevicePath,\r
-          (EFI_DEVICE_PATH_PROTOCOL *) &DevicePath\r
-          );\r
-}\r
-\r
-\r
-\r
-/**\r
-  The user Entry Point for module EmuBusDriver. The user code starts with this function.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-  \r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeEmuBusDriver (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  Status = EfiLibInstallAllDriverProtocols (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gEmuBusDriverBinding,\r
-             ImageHandle,\r
-             &gEmuBusDriverComponentName,\r
-             NULL,\r
-             NULL\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-\r
diff --git a/InOsEmuPkg/EmuBusDriverDxe/EmuBusDriverDxe.h b/InOsEmuPkg/EmuBusDriverDxe/EmuBusDriverDxe.h
deleted file mode 100644 (file)
index e5eee56..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#ifndef __EMU_BUS_DRIVER_H__\r
-#define __EMU_BUS_DRIVER_H__\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/EmuThunk.h>\r
-#include <Protocol/EmuIoThunk.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-extern EFI_DRIVER_BINDING_PROTOCOL  gEmuBusDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL  gEmuBusDriverComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL gEmuBusDriverComponentName2;\r
-\r
-\r
-//\r
-// Unix Bus Controller Structure\r
-//\r
-#define EMU_BUS_DEVICE_SIGNATURE SIGNATURE_32 ('L', 'X', 'B', 'D')\r
-\r
-typedef struct {\r
-  UINT64                    Signature;\r
-  EFI_UNICODE_STRING_TABLE  *ControllerNameTable;\r
-} EMU_BUS_DEVICE;\r
-\r
-//\r
-// Unix Child Device Controller Structure\r
-//\r
-#define EMU_IO_DEVICE_SIGNATURE  SIGNATURE_32 ('L', 'X', 'V', 'D')\r
-\r
-typedef struct {\r
-  UINT64                    Signature;\r
-  EFI_HANDLE                Handle;\r
-  EMU_IO_THUNK_PROTOCOL     EmuIoThunk;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-\r
-  //\r
-  // Private data about the parent\r
-  //\r
-  EFI_HANDLE                ControllerHandle;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
-\r
-  EFI_UNICODE_STRING_TABLE  *ControllerNameTable;\r
-\r
-} EMU_IO_DEVICE;\r
-\r
-#define EMU_IO_DEVICE_FROM_THIS(a) \\r
-  CR(a, EMU_IO_DEVICE, EmuIoThunk, EMU_IO_DEVICE_SIGNATURE)\r
-\r
-\r
-\r
-//\r
-// Driver Binding Protocol function prototypes\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBusDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     Handle,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBusDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     ParentHandle,\r
-  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
-  );\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuBusDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   Handle,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  );\r
-\r
-//\r
-// Unix Bus Driver private worker functions\r
-//\r
-EFI_DEVICE_PATH_PROTOCOL  *\r
-EmuBusCreateDevicePath (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *RootDevicePath,\r
-  IN  EFI_GUID                  *Guid,\r
-  IN  UINT16                    InstanceNumber\r
-  );\r
-\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/EmuBusDriverDxe/EmuBusDriverDxe.inf b/InOsEmuPkg/EmuBusDriverDxe/EmuBusDriverDxe.inf
deleted file mode 100644 (file)
index 88c2764..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-## @file\r
-# Emu Bus driver\r
-#\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuBusDriver\r
-  FILE_GUID                      = 9842073D-95D9-9F49-BD3F-2E29525125DF\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = InitializeEmuBusDriver\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-#  DRIVER_BINDING                =  gEmuBusDriverBinding                        \r
-#  COMPONENT_NAME                =  gEmuBusDriverComponentName                  \r
-#\r
-\r
-[Sources]\r
-  ComponentName.c\r
-  EmuBusDriverDxe.c\r
-  \r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  DevicePathLib\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  PcdLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  BaseLib\r
-  DebugLib\r
-\r
-\r
-[Protocols]\r
-  gEfiDevicePathProtocolGuid                    # PROTOCOL TO_START\r
-  gEmuThunkProtocolGuid                         # PROTOCOL TO_START\r
-  gEmuIoThunkProtocolGuid                       # PROTOCOL BY_START\r
-\r
-\r
-\r
diff --git a/InOsEmuPkg/EmuGopDxe/ComponentName.c b/InOsEmuPkg/EmuGopDxe/ComponentName.c
deleted file mode 100644 (file)
index 9360fa1..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2010,Apple Inc. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  ComponentName.c\r
-\r
-Abstract:\r
-\r
-**/\r
-\r
-#include "Gop.h"\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGopComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGopComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-EFI_COMPONENT_NAME_PROTOCOL     gEmuGopComponentName = {\r
-  EmuGopComponentNameGetDriverName,\r
-  EmuGopComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuGopComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuGopComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable[] = {\r
-  { "eng", L"InOsEmu GOP Driver" },\r
-  { NULL , NULL }\r
-};\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGopComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mEmuGopDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gEmuGopComponentName)\r
-           );\r
-}\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGopComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;\r
-  GOP_PRIVATE_DATA              *Private;\r
-\r
-  //\r
-  // This is a device driver, so ChildHandle must be NULL.\r
-  //\r
-  if (ChildHandle != NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Make sure this driver is currently managing ControllerHandle\r
-  //\r
-  Status = EfiTestManagedDevice (\r
-             ControllerHandle,\r
-             gEmuGopDriverBinding.DriverBindingHandle,\r
-             &gEmuIoThunkProtocolGuid\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Get our context back\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiGraphicsOutputProtocolGuid,\r
-                  (VOID **)&GraphicsOutput,\r
-                  gEmuGopDriverBinding.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);\r
-\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           Private->ControllerNameTable,\r
-           ControllerName,\r
-           (BOOLEAN)(This == &gEmuGopComponentName)\r
-           );\r
-}\r
diff --git a/InOsEmuPkg/EmuGopDxe/EmuGopDxe.inf b/InOsEmuPkg/EmuGopDxe/EmuGopDxe.inf
deleted file mode 100644 (file)
index 2a988c9..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-## @file\r
-# GOP driver\r
-#\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuGopDxe\r
-  FILE_GUID                      = BCC87E0D-86D6-4D4D-8040-2D983D368BD1\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = InitializeEmuGop\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-#  DRIVER_BINDING                =  gEmuGopDriverBinding                        \r
-#  COMPONENT_NAME                =  gEmuGopComponentName                        \r
-#\r
-\r
-[Sources]\r
-  ComponentName.c\r
-  GopScreen.c\r
-  GopDriver.c\r
-  GopInput.c\r
-  Gop.h\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  BaseLib\r
-  DebugLib\r
-  KeyMapLib\r
-  \r
-\r
-[Guids]\r
-  gEfiEventExitBootServicesGuid                # SOMETIMES_CONSUMED  Create Event: EVENT_GROUP_GUID\r
-\r
-\r
-[Protocols]\r
-  gEfiGraphicsOutputProtocolGuid\r
-  gEfiSimpleTextInProtocolGuid                  # PROTOCOL BY_START\r
-  gEfiSimpleTextInputExProtocolGuid             # PROTOCOL BY_START\r
-  gEfiSimplePointerProtocolGuid                 # PROTOCOL BY_START\r
-  gEmuIoThunkProtocolGuid                       # PROTOCOL TO_START\r
-  gEmuGraphicsWindowProtocolGuid                # PROTOCOL TO_START\r
diff --git a/InOsEmuPkg/EmuGopDxe/Gop.h b/InOsEmuPkg/EmuGopDxe/Gop.h
deleted file mode 100644 (file)
index 03e33ea..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/*++ @file
-
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
-Portions copyright (c) 2010,Apple Inc. All rights reserved.<BR>
-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 __UGA_H_
-#define __UGA_H_
-
-#include <PiDxe.h>
-
-#include <Protocol/GraphicsOutput.h>
-#include <Protocol/SimpleTextIn.h>
-#include <Protocol/SimpleTextInEx.h>
-#include <Protocol/SimplePointer.h>
-#include <Protocol/EmuIoThunk.h>
-#include <Protocol/EmuGraphicsWindow.h>
-
-#include <Guid/EventGroup.h>
-
-#include <Library/DebugLib.h>
-#include <Library/BaseLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/KeyMapLib.h>
-
-
-#define MAX_Q 256
-
-typedef struct {
-  UINTN         Front;
-  UINTN         Rear;
-  UINTN         Count;
-  EFI_INPUT_KEY Q[MAX_Q];
-} GOP_QUEUE_FIXED;
-
-#define EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('U', 'g', 'S', 'n')
-typedef struct _EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY {
-  UINTN                                 Signature;
-  EFI_HANDLE                            NotifyHandle;
-  EFI_KEY_DATA                          KeyData;
-  EFI_KEY_NOTIFY_FUNCTION               KeyNotificationFn;
-  EFI_EVENT                             Event;
-  LIST_ENTRY                            NotifyEntry;
-} EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY;
-  
-#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
-
-typedef struct {
-  UINT32                     HorizontalResolution;
-  UINT32                     VerticalResolution;
-  UINT32                     ColorDepth;
-  UINT32                     RefreshRate;
-} GOP_MODE_DATA;
-
-
-
-extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName;
-
-#define EMU_UGA_CLASS_NAME       L"EmuGopWindow"
-
-#define GOP_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('G', 'o', 'p', 'N')
-typedef struct {
-  UINT64                            Signature;
-
-  EFI_HANDLE                        Handle;
-  EFI_GRAPHICS_OUTPUT_PROTOCOL      GraphicsOutput;
-  EFI_SIMPLE_TEXT_INPUT_PROTOCOL    SimpleTextIn;
-  EFI_SIMPLE_POINTER_PROTOCOL       SimplePointer;
-
-  EMU_IO_THUNK_PROTOCOL             *EmuIoThunk;
-  EMU_GRAPHICS_WINDOW_PROTOCOL      *EmuGraphicsWindow;
-
-  EFI_UNICODE_STRING_TABLE          *ControllerNameTable;
-
-  EFI_SIMPLE_POINTER_MODE           PointerMode;
-  //
-  // GOP Private Data for QueryMode ()
-  //
-  GOP_MODE_DATA                     *ModeData;
-
-
-  //
-  // UGA Private Data knowing when to start hardware
-  //
-  BOOLEAN                           HardwareNeedsStarting;
-
-  CHAR16                            *WindowName;
-
-  GOP_QUEUE_FIXED                   Queue;
-
-  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInEx;
-  EFI_KEY_STATE                     KeyState;
-  LIST_ENTRY                        NotifyList;  
-} GOP_PRIVATE_DATA;
-
-
-#define GOP_PRIVATE_DATA_FROM_THIS(a)  \
-         CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE)
-
-#define GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS(a)  \
-         CR(a, GOP_PRIVATE_DATA, SimpleTextIn, GOP_PRIVATE_DATA_SIGNATURE)
-
-#define GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS(a)  \
-         CR(a, GOP_PRIVATE_DATA, SimpleTextInEx, GOP_PRIVATE_DATA_SIGNATURE)
-
-#define GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS(a)  \
-         CR(a, GOP_PRIVATE_DATA, SimplePointer, GOP_PRIVATE_DATA_SIGNATURE)
-
-
-//
-// Global Protocol Variables
-//
-extern EFI_DRIVER_BINDING_PROTOCOL  gEmuGopDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL  gEmuGopComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2;
-
-//
-// Gop Hardware abstraction internal worker functions
-//
-EFI_STATUS
-EmuGopSupported (
-  IN  EMU_IO_THUNK_PROTOCOL  *EmuIoThunk
-  );
-
-EFI_STATUS
-EmuGopConstructor (
-  IN  GOP_PRIVATE_DATA    *Private
-  );
-
-EFI_STATUS
-EmuGopDestructor (
-  IN  GOP_PRIVATE_DATA    *Private
-  );
-
-
-EFI_STATUS
-GopPrivateAddQ (
-  IN  GOP_PRIVATE_DATA    *Private,
-  IN  EFI_INPUT_KEY       Key
-  );
-
-EFI_STATUS
-EmuGopInitializeSimpleTextInForWindow (
-  IN  GOP_PRIVATE_DATA    *Private
-  );
-
-EFI_STATUS
-EmuGopInitializeSimplePointerForWindow (
-  IN  GOP_PRIVATE_DATA    *Private
-  );
-
-EFI_STATUS
-EmuGopStartWindow (
-  IN  GOP_PRIVATE_DATA    *Private,
-  IN  UINT32              HorizontalResolution,
-  IN  UINT32              VerticalResolution,
-  IN  UINT32              ColorDepth,
-  IN  UINT32              RefreshRate
-  );
-
-VOID
-EFIAPI
-ShutdownGopEvent (
-  IN EFI_EVENT  Event,
-  IN VOID       *Context
-  );
-
-VOID
-EFIAPI
-GopPrivateMakeCallbackFunction (
-  IN VOID           *Context,
-  IN EFI_KEY_DATA   *KeyData
-  );
-
-VOID
-EFIAPI
-GopPrivateBreakCallbackFunction (
-  IN VOID           *Context,
-  IN EFI_KEY_DATA   *KeyData
-  );
-
-#endif
diff --git a/InOsEmuPkg/EmuGopDxe/GopDriver.c b/InOsEmuPkg/EmuGopDxe/GopDriver.c
deleted file mode 100644 (file)
index 8ddaa86..0000000
+++ /dev/null
@@ -1,443 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2010,Apple Inc. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-\r
-**/\r
-\r
-#include "Gop.h"\r
-\r
-\r
-EFI_STATUS\r
-FreeNotifyList (\r
-  IN OUT LIST_ENTRY           *ListHead\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-  ListHead   - The list head\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Free the notify list successfully\r
-  EFI_INVALID_PARAMETER - ListHead is invalid.\r
-\r
-**/\r
-{\r
-  EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *NotifyNode;\r
-\r
-  if (ListHead == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  while (!IsListEmpty (ListHead)) {\r
-    NotifyNode = CR (\r
-                   ListHead->ForwardLink, \r
-                   EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, \r
-                   NotifyEntry, \r
-                   EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE\r
-                   );\r
-    RemoveEntryList (ListHead->ForwardLink);\r
-    gBS->FreePool (NotifyNode);\r
-  }\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Tests to see if this driver supports a given controller. If a child device is provided, \r
-  it further tests to see if this driver supports creating a handle for the specified child device.\r
-\r
-  This function checks to see if the driver specified by This supports the device specified by \r
-  ControllerHandle. Drivers will typically use the device path attached to \r
-  ControllerHandle and/or the services from the bus I/O abstraction attached to \r
-  ControllerHandle to determine if the driver supports ControllerHandle. This function \r
-  may be called many times during platform initialization. In order to reduce boot times, the tests \r
-  performed by this function must be very small, and take as little time as possible to execute. This \r
-  function must not change the state of any hardware devices, and this function must be aware that the \r
-  device specified by ControllerHandle may already be managed by the same driver or a \r
-  different driver. This function must match its calls to AllocatePages() with FreePages(), \r
-  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().  \r
-  Because ControllerHandle may have been previously started by the same driver, if a protocol is \r
-  already in the opened state, then it must not be closed with CloseProtocol(). This is required \r
-  to guarantee the state of ControllerHandle is not modified by this function.\r
-\r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to test. This handle \r
-                                   must support a protocol interface that supplies \r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
-                                   parameter is ignored by device drivers, and is optional for bus \r
-                                   drivers. For bus drivers, if this parameter is not NULL, then \r
-                                   the bus driver must determine if the bus controller specified \r
-                                   by ControllerHandle and the child controller specified \r
-                                   by RemainingDevicePath are both supported by this \r
-                                   bus driver.\r
-\r
-  @retval EFI_SUCCESS              The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is supported by the driver specified by This.\r
-  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is already being managed by the driver\r
-                                   specified by This.\r
-  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is already being managed by a different\r
-                                   driver or an application that requires exclusive access.\r
-                                   Currently not implemented.\r
-  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is not supported by the driver specified by This.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGopDriverBindingSupported (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
-  IN  EFI_HANDLE                      Handle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_IO_THUNK_PROTOCOL   *EmuIoThunk;\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Handle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (VOID **)&EmuIoThunk,\r
-                  This->DriverBindingHandle,\r
-                  Handle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = EmuGopSupported (EmuIoThunk);\r
-\r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
-  //\r
-  gBS->CloseProtocol (\r
-        Handle,\r
-        &gEmuIoThunkProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        Handle\r
-        );\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Starts a device controller or a bus controller.\r
-\r
-  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
-  As a result, much of the error checking on the parameters to Start() has been moved into this \r
-  common boot service. It is legal to call Start() from other locations, \r
-  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE.\r
-  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
-     EFI_DEVICE_PATH_PROTOCOL.\r
-  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
-     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.  \r
-\r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to start. This handle \r
-                                   must support a protocol interface that supplies \r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
-                                   parameter is ignored by device drivers, and is optional for bus \r
-                                   drivers. For a bus driver, if this parameter is NULL, then handles \r
-                                   for all the children of Controller are created by this driver.  \r
-                                   If this parameter is not NULL and the first Device Path Node is \r
-                                   not the End of Device Path Node, then only the handle for the \r
-                                   child device specified by the first Device Path Node of \r
-                                   RemainingDevicePath is created by this driver.\r
-                                   If the first Device Path Node of RemainingDevicePath is \r
-                                   the End of Device Path Node, no child handle is created by this\r
-                                   driver.\r
-\r
-  @retval EFI_SUCCESS              The device was started.\r
-  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.Currently not implemented.\r
-  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
-  @retval Others                   The driver failded to start the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGopDriverBindingStart (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
-  IN  EFI_HANDLE                      Handle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath\r
-  )\r
-{\r
-  EMU_IO_THUNK_PROTOCOL   *EmuIoThunk;\r
-  EFI_STATUS              Status;\r
-  GOP_PRIVATE_DATA        *Private;\r
-\r
-  //\r
-  // Grab the protocols we need\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  Handle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (VOID **)&EmuIoThunk,\r
-                  This->DriverBindingHandle,\r
-                  Handle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Allocate Private context data for SGO inteface.\r
-  //\r
-  Private = NULL;\r
-  Status = gBS->AllocatePool (\r
-                  EfiBootServicesData,\r
-                  sizeof (GOP_PRIVATE_DATA),\r
-                  (VOID **)&Private\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Set up context record\r
-  //\r
-  Private->Signature           = GOP_PRIVATE_DATA_SIGNATURE;\r
-  Private->Handle              = Handle;\r
-  Private->EmuIoThunk          = EmuIoThunk;\r
-  Private->WindowName          = EmuIoThunk->ConfigString;\r
-  Private->ControllerNameTable = NULL;\r
-\r
-  AddUnicodeString (\r
-    "eng",\r
-    gEmuGopComponentName.SupportedLanguages,\r
-    &Private->ControllerNameTable,\r
-    EmuIoThunk->ConfigString\r
-    );\r
-  AddUnicodeString2 (\r
-    "en",\r
-    gEmuGopComponentName2.SupportedLanguages,\r
-    &Private->ControllerNameTable,\r
-    EmuIoThunk->ConfigString,\r
-    FALSE\r
-    );\r
-\r
-  Status = EmuGopConstructor (Private);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Publish the Gop interface to the world\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Private->Handle,\r
-                  &gEfiGraphicsOutputProtocolGuid,    &Private->GraphicsOutput,\r
-                  &gEfiSimpleTextInProtocolGuid,      &Private->SimpleTextIn,\r
-                  &gEfiSimplePointerProtocolGuid,     &Private->SimplePointer,\r
-                  &gEfiSimpleTextInputExProtocolGuid, &Private->SimpleTextInEx,\r
-                  NULL\r
-                  );\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-\r
-    gBS->CloseProtocol (\r
-          Handle,\r
-          &gEmuIoThunkProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          Handle\r
-          );\r
-\r
-    if (Private != NULL) {\r
-      //\r
-      // On Error Free back private data\r
-      //\r
-      if (Private->ControllerNameTable != NULL) {\r
-        FreeUnicodeStringTable (Private->ControllerNameTable);\r
-      }\r
-      if (Private->SimpleTextIn.WaitForKey != NULL) {\r
-        gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);\r
-      }\r
-      if (Private->SimpleTextInEx.WaitForKeyEx != NULL) {\r
-        gBS->CloseEvent (Private->SimpleTextInEx.WaitForKeyEx);\r
-      }\r
-      FreeNotifyList (&Private->NotifyList);\r
-\r
-      gBS->FreePool (Private);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-/**\r
-  Stops a device controller or a bus controller.\r
-  \r
-  The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
-  As a result, much of the error checking on the parameters to Stop() has been moved \r
-  into this common boot service. It is legal to call Stop() from other locations, \r
-  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
-     same driver's Start() function.\r
-  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
-     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
-     Start() function, and the Start() function must have called OpenProtocol() on\r
-     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
-  \r
-  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must \r
-                                support a bus specific I/O protocol for the driver \r
-                                to use to stop the device.\r
-  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
-  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL \r
-                                if NumberOfChildren is 0.\r
-\r
-  @retval EFI_SUCCESS           The device was stopped.\r
-  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGopDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   Handle,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
-  EFI_STATUS                   Status;\r
-  GOP_PRIVATE_DATA             *Private;\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  Handle,\r
-                  &gEfiGraphicsOutputProtocolGuid,\r
-                  (VOID **)&GraphicsOutput,\r
-                  This->DriverBindingHandle,\r
-                  Handle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // If the GOP interface does not exist the driver is not started\r
-    //\r
-    return EFI_NOT_STARTED;\r
-  }\r
-\r
-  //\r
-  // Get our private context information\r
-  //\r
-  Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);\r
-\r
-  //\r
-  // Remove the SGO interface from the system\r
-  //\r
-  Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                  Private->Handle,\r
-                  &gEfiGraphicsOutputProtocolGuid,    &Private->GraphicsOutput,\r
-                  &gEfiSimpleTextInProtocolGuid,      &Private->SimpleTextIn,\r
-                  &gEfiSimplePointerProtocolGuid,     &Private->SimplePointer,\r
-                  &gEfiSimpleTextInputExProtocolGuid, &Private->SimpleTextInEx,\r
-                  NULL\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Shutdown the hardware\r
-    //\r
-    Status = EmuGopDestructor (Private);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    gBS->CloseProtocol (\r
-          Handle,\r
-          &gEmuIoThunkProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          Handle\r
-          );\r
-\r
-    //\r
-    // Free our instance data\r
-    //\r
-    FreeUnicodeStringTable (Private->ControllerNameTable);\r
-    \r
-    Status = gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);\r
-    ASSERT_EFI_ERROR (Status);\r
-    \r
-    Status = gBS->CloseEvent (Private->SimpleTextInEx.WaitForKeyEx);\r
-    ASSERT_EFI_ERROR (Status);\r
-    \r
-    FreeNotifyList (&Private->NotifyList);\r
-\r
-    gBS->FreePool (Private);\r
-\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-///\r
-/// This protocol provides the services required to determine if a driver supports a given controller. \r
-/// If a controller is supported, then it also provides routines to start and stop the controller.\r
-///\r
-EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding = {\r
-  EmuGopDriverBindingSupported,\r
-  EmuGopDriverBindingStart,\r
-  EmuGopDriverBindingStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-\r
-\r
-/**\r
-  The user Entry Point for module EmuGop. The user code starts with this function.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-  \r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeEmuGop (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gEmuGopDriverBinding,\r
-             ImageHandle,\r
-             &gEmuGopComponentName,\r
-             &gEmuGopComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/InOsEmuPkg/EmuGopDxe/GopInput.c b/InOsEmuPkg/EmuGopDxe/GopInput.c
deleted file mode 100644 (file)
index 0bc2eb5..0000000
+++ /dev/null
@@ -1,897 +0,0 @@
-/*++ @file
-
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-Portions copyright (c) 2010 0 2011,Apple Inc. All rights reserved.<BR>
-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 "Gop.h"
-
-
-BOOLEAN
-GopPrivateIsKeyRegistered (
-  IN EFI_KEY_DATA  *RegsiteredData,
-  IN EFI_KEY_DATA  *InputData
-  )
-/*++
-
-Routine Description:
-
-Arguments:
-
-  RegsiteredData    - A pointer to a buffer that is filled in with the keystroke 
-                      state data for the key that was registered.
-  InputData         - A pointer to a buffer that is filled in with the keystroke 
-                      state data for the key that was pressed.
-
-Returns:
-  TRUE              - Key be pressed matches a registered key.
-  FLASE             - Match failed. 
-  
-**/
-{
-  ASSERT (RegsiteredData != NULL && InputData != NULL);
-  
-  if ((RegsiteredData->Key.ScanCode    != InputData->Key.ScanCode) ||
-      (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {
-    return FALSE;  
-  }      
-  
-  //
-  // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
-  //
-  if (RegsiteredData->KeyState.KeyShiftState != 0 &&
-      RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {
-    return FALSE;    
-  }   
-  if (RegsiteredData->KeyState.KeyToggleState != 0 &&
-      RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {
-    return FALSE;    
-  }     
-  
-  return TRUE;
-
-}
-
-
-VOID
-EFIAPI
-GopPrivateMakeCallbackFunction (
-  IN VOID           *Context,
-  IN EFI_KEY_DATA   *KeyData
-  )
-{ 
-  LIST_ENTRY                        *Link;
-  EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY  *CurrentNotify;
-  GOP_PRIVATE_DATA                  *Private = (GOP_PRIVATE_DATA *)Context;
-  
-  KeyMapMake (KeyData);
-
-  for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
-    CurrentNotify = CR (
-                      Link, 
-                      EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, 
-                      NotifyEntry, 
-                      EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
-                      );
-    if (GopPrivateIsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { 
-      // We could be called at a high TPL so signal an event to call the registered function 
-      // at a lower TPL.
-      gBS->SignalEvent (CurrentNotify->Event);
-    }
-  }    
-}
-
-
-VOID
-EFIAPI
-GopPrivateBreakCallbackFunction (
-  IN VOID           *Context,
-  IN EFI_KEY_DATA   *KeyData
-  )
-{ 
-  KeyMapBreak (KeyData);
-}
-
-
-
-//
-// Simple Text In implementation.
-//
-
-/**
-  Reset the input device and optionally run diagnostics
-
-  @param  This                 Protocol instance pointer.
-  @param  ExtendedVerification Driver may perform diagnostics on reset.
-
-  @retval EFI_SUCCESS          The device was reset.
-  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could not be reset.
-
-**/
-EFI_STATUS
-EFIAPI
-EmuGopSimpleTextInReset (
-  IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL       *This,
-  IN BOOLEAN                              ExtendedVerification
-  )
-{
-  GOP_PRIVATE_DATA  *Private;
-  EFI_KEY_DATA      KeyData;
-  EFI_TPL           OldTpl;
-
-  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
-  if (Private->EmuGraphicsWindow == NULL) {
-    return EFI_SUCCESS;
-  }
-
-  //
-  // Enter critical section
-  //
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
-  //
-  // A reset is draining the Queue
-  //
-  while (Private->EmuGraphicsWindow->GetKey (Private->EmuGraphicsWindow, &KeyData) == EFI_SUCCESS)
-    ;
-
-  //
-  // Leave critical section and return
-  //
-  gBS->RestoreTPL (OldTpl);
-  return EFI_SUCCESS;
-}
-
-
-/**
-  Reads the next keystroke from the input device. The WaitForKey Event can
-  be used to test for existence of a keystroke via WaitForEvent () call.
-
-  @param  This  Protocol instance pointer.
-  @param  Key   A pointer to a buffer that is filled in with the keystroke
-                information for the key that was pressed.
-
-  @retval EFI_SUCCESS      The keystroke information was returned.
-  @retval EFI_NOT_READY    There was no keystroke data available.
-  @retval EFI_DEVICE_ERROR The keystroke information was not returned due to
-                           hardware errors.
-
-**/
-EFI_STATUS
-EFIAPI
-EmuGopSimpleTextInReadKeyStroke (
-  IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL       *This,
-  OUT EFI_INPUT_KEY                       *Key
-  )
-{
-  GOP_PRIVATE_DATA  *Private;
-  EFI_STATUS        Status;
-  EFI_TPL           OldTpl;
-  EFI_KEY_DATA      KeyData;
-
-  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
-  if (Private->EmuGraphicsWindow == NULL) {
-    return EFI_NOT_READY;
-  }
-
-  //
-  // Enter critical section
-  //
-  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);
-
-  Status  = Private->EmuGraphicsWindow->GetKey (Private->EmuGraphicsWindow, &KeyData);
-  CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY));
-
-  //
-  // Leave critical section and return
-  //
-  gBS->RestoreTPL (OldTpl);
-
-  return Status;
-}
-
-
-
-/**
-  SimpleTextIn and SimpleTextInEx Notify Wait Event 
-
-  @param  Event                 Event whose notification function is being invoked.
-  @param  Context               Pointer to GOP_PRIVATE_DATA.
-
-**/
-VOID
-EFIAPI
-EmuGopSimpleTextInWaitForKey (
-  IN EFI_EVENT          Event,
-  IN VOID               *Context
-  )
-{
-  GOP_PRIVATE_DATA  *Private;
-  EFI_STATUS        Status;
-  EFI_TPL           OldTpl;
-
-  Private = (GOP_PRIVATE_DATA *) Context;
-  if (Private->EmuGraphicsWindow == NULL) {
-    return;
-  }
-
-  //
-  // Enter critical section
-  //
-  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);
-
-  Status  = Private->EmuGraphicsWindow->CheckKey (Private->EmuGraphicsWindow);
-  if (!EFI_ERROR (Status)) {
-    //
-    // If a there is a key in the queue signal our event.
-    //
-    gBS->SignalEvent (Event);
-  }
-  //
-  // Leave critical section and return
-  //
-  gBS->RestoreTPL (OldTpl);
-}
-
-
-//
-// Simple Text Input Ex protocol functions
-//
-
-
-/**
-  The Reset() function resets the input device hardware. As part
-  of initialization process, the firmware/device will make a quick
-  but reasonable attempt to verify that the device is functioning.
-  If the ExtendedVerification flag is TRUE the firmware may take
-  an extended amount of time to verify the device is operating on
-  reset. Otherwise the reset operation is to occur as quickly as
-  possible. The hardware verification process is not defined by
-  this specification and is left up to the platform firmware or
-  driver to implement.
-
-  @param This                 A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
-
-  @param ExtendedVerification Indicates that the driver may
-                              perform a more exhaustive
-                              verification operation of the
-                              device during reset.
-
-
-  @retval EFI_SUCCESS       The device was reset.
-  
-  @retval EFI_DEVICE_ERROR  The device is not functioning
-                            correctly and could not be reset.
-
-**/
-EFI_STATUS
-EFIAPI
-EmuGopSimpleTextInExResetEx (
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,
-  IN BOOLEAN                            ExtendedVerification
-  )
-/*++
-
-  Routine Description:
-    Reset the input device and optionaly run diagnostics
-
-  Arguments:
-    This                 - Protocol instance pointer.
-    ExtendedVerification - Driver may perform diagnostics on reset.
-
-  Returns:
-    EFI_SUCCESS           - The device was reset.
-
-**/
-{
-  GOP_PRIVATE_DATA *Private;
-
-  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This);
-  
-  return EFI_SUCCESS;
-}
-
-
-
-/**
-  The function reads the next keystroke from the input device. If
-  there is no pending keystroke the function returns
-  EFI_NOT_READY. If there is a pending keystroke, then
-  KeyData.Key.ScanCode is the EFI scan code defined in Error!
-  Reference source not found. The KeyData.Key.UnicodeChar is the
-  actual printable character or is zero if the key does not
-  represent a printable character (control key, function key,
-  etc.). The KeyData.KeyState is shift state for the character
-  reflected in KeyData.Key.UnicodeChar or KeyData.Key.ScanCode .
-  When interpreting the data from this function, it should be
-  noted that if a class of printable characters that are
-  normally adjusted by shift modifiers (e.g. Shift Key + "f"
-  key) would be presented solely as a KeyData.Key.UnicodeChar
-  without the associated shift state. So in the previous example
-  of a Shift Key + "f" key being pressed, the only pertinent
-  data returned would be KeyData.Key.UnicodeChar with the value
-  of "F". This of course would not typically be the case for
-  non-printable characters such as the pressing of the Right
-  Shift Key + F10 key since the corresponding returned data
-  would be reflected both in the KeyData.KeyState.KeyShiftState
-  and KeyData.Key.ScanCode values. UEFI drivers which implement
-  the EFI_SIMPLE_TEXT_INPUT_EX protocol are required to return
-  KeyData.Key and KeyData.KeyState values. These drivers must
-  always return the most current state of
-  KeyData.KeyState.KeyShiftState and
-  KeyData.KeyState.KeyToggleState. It should also be noted that
-  certain input devices may not be able to produce shift or toggle
-  state information, and in those cases the high order bit in the
-  respective Toggle and Shift state fields should not be active.
-
-  
-  @param This     A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
-
-  @param KeyData  A pointer to a buffer that is filled in with
-                  the keystroke state data for the key that was
-                  pressed.
-
-  
-  @retval EFI_SUCCESS     The keystroke information was
-                          returned.
-  
-  @retval EFI_NOT_READY   There was no keystroke data available.
-                          EFI_DEVICE_ERROR The keystroke
-                          information was not returned due to
-                          hardware errors.
-
-
-**/
-EFI_STATUS
-EFIAPI
-EmuGopSimpleTextInExReadKeyStrokeEx (
-  IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
-  OUT EFI_KEY_DATA                      *KeyData
-  )
-/*++
-
-  Routine Description:
-    Reads the next keystroke from the input device. The WaitForKey Event can 
-    be used to test for existance of a keystroke via WaitForEvent () call.
-
-  Arguments:
-    This       - Protocol instance pointer.
-    KeyData    - A pointer to a buffer that is filled in with the keystroke 
-                 state data for the key that was pressed.
-
-  Returns:
-    EFI_SUCCESS           - The keystroke information was returned.
-    EFI_NOT_READY         - There was no keystroke data availiable.
-    EFI_DEVICE_ERROR      - The keystroke information was not returned due to 
-                            hardware errors.
-    EFI_INVALID_PARAMETER - KeyData is NULL.                        
-
-**/
-{
-  EFI_STATUS        Status;
-  GOP_PRIVATE_DATA  *Private;
-  EFI_TPL           OldTpl;
-
-
-  if (KeyData == NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
-  if (Private->EmuGraphicsWindow == NULL) {
-    return EFI_NOT_READY;
-  }
-
-  //
-  // Enter critical section
-  //
-  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);
-
-  Status  = Private->EmuGraphicsWindow->GetKey(Private->EmuGraphicsWindow, KeyData);
-
-  //
-  // Leave critical section and return
-  //
-  gBS->RestoreTPL (OldTpl);
-
-  return Status;
-}
-
-
-
-/**
-  The SetState() function allows the input device hardware to
-  have state settings adjusted.
-  
-  @param This           A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
-  
-  @param KeyToggleState Pointer to the EFI_KEY_TOGGLE_STATE to
-                        set the state for the input device.
-  
-  
-  @retval EFI_SUCCESS       The device state was set appropriately.
-
-  @retval EFI_DEVICE_ERROR  The device is not functioning
-                            correctly and could not have the
-                            setting adjusted.
-
-  @retval EFI_UNSUPPORTED   The device does not support the
-                            ability to have its state set.
-
-**/
-EFI_STATUS
-EFIAPI
-EmuGopSimpleTextInExSetState (
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,
-  IN EFI_KEY_TOGGLE_STATE               *KeyToggleState
-  )
-{
-  GOP_PRIVATE_DATA  *Private;
-  EFI_STATUS        Status;
-  EFI_TPL           OldTpl;
-
-  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
-  if (Private->EmuGraphicsWindow == NULL) {
-    return EFI_NOT_READY;
-  }
-
-  //
-  // Enter critical section
-  //
-  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);
-
-  Status  = Private->EmuGraphicsWindow->KeySetState (Private->EmuGraphicsWindow, KeyToggleState);
-  //
-  // Leave critical section and return
-  //
-  gBS->RestoreTPL (OldTpl);
-
-  return Status;
-}
-
-
-/**
-  SimpleTextIn and SimpleTextInEx Notify Wait Event 
-
-  @param  Event                 Event whose notification function is being invoked.
-  @param  Context               Pointer to GOP_PRIVATE_DATA.
-
-**/
-VOID
-EFIAPI
-EmuGopRegisterKeyCallback (
-  IN EFI_EVENT          Event,
-  IN VOID               *Context
-  )
-{
-  EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *ExNotify = (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *)Context;
-  
-  ExNotify->KeyNotificationFn (&ExNotify->KeyData);
-}
-
-
-
-/**
-  The RegisterKeystrokeNotify() function registers a function
-  which will be called when a specified keystroke will occur.
-  
-  @param This                     A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
-  
-  @param KeyData                  A pointer to a buffer that is filled in with
-                                  the keystroke information for the key that was
-                                  pressed.
-  
-  @param KeyNotificationFunction  Points to the function to be
-                                  called when the key sequence
-                                  is typed specified by KeyData.
-  
-  
-  @param NotifyHandle             Points to the unique handle assigned to
-                                  the registered notification.
-  
-  @retval EFI_SUCCESS           The device state was set
-                                appropriately.
-
-  @retval EFI_OUT_OF_RESOURCES  Unable to allocate necessary
-                                data structures.
-
-**/
-EFI_STATUS
-EFIAPI
-EmuGopSimpleTextInExRegisterKeyNotify (
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,
-  IN EFI_KEY_DATA                       *KeyData,
-  IN EFI_KEY_NOTIFY_FUNCTION            KeyNotificationFunction,
-  OUT EFI_HANDLE                        *NotifyHandle
-  )
-{
-  EFI_STATUS                          Status;
-  GOP_PRIVATE_DATA                    *Private;
-  EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY     *CurrentNotify;
-  LIST_ENTRY                          *Link;
-  EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY     *NewNotify;
-
-  if (KeyData == NULL || KeyNotificationFunction == NULL || NotifyHandle == NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This);
-
-  //
-  // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
-  //
-  for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
-    CurrentNotify = CR (
-                      Link, 
-                      EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, 
-                      NotifyEntry, 
-                      EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
-                      );
-    if (GopPrivateIsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { 
-      if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {
-        *NotifyHandle = CurrentNotify->NotifyHandle;
-        return EFI_SUCCESS;
-      }
-    }
-  }    
-  
-  //
-  // Allocate resource to save the notification function
-  //  
-  NewNotify = (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *) AllocateZeroPool (sizeof (EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY));
-  if (NewNotify == NULL) {
-    return EFI_OUT_OF_RESOURCES;
-  }
-
-  NewNotify->Signature         = EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE;     
-  NewNotify->KeyNotificationFn = KeyNotificationFunction;
-  NewNotify->NotifyHandle      = (EFI_HANDLE) NewNotify;
-  CopyMem (&NewNotify->KeyData, KeyData, sizeof (KeyData));
-  InsertTailList (&Private->NotifyList, &NewNotify->NotifyEntry);
-  
-  Status = gBS->CreateEvent (
-                  EVT_NOTIFY_SIGNAL,
-                  TPL_NOTIFY,
-                  EmuGopRegisterKeyCallback,
-                  NewNotify,
-                  &NewNotify->Event
-                  );
-  ASSERT_EFI_ERROR (Status);
-
-
-  *NotifyHandle = NewNotify->NotifyHandle;  
-  
-  return EFI_SUCCESS;
-  
-}
-
-
-/**
-  The UnregisterKeystrokeNotify() function removes the
-  notification which was previously registered.
-  
-  @param This               A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
-  
-  @param NotificationHandle The handle of the notification
-                            function being unregistered.
-  
-  @retval EFI_SUCCESS The device state was set appropriately.
-  
-  @retval EFI_INVALID_PARAMETER The NotificationHandle is
-                                invalid.
-
-**/
-EFI_STATUS
-EFIAPI
-EmuGopSimpleTextInExUnregisterKeyNotify (
-  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,
-  IN EFI_HANDLE                         NotificationHandle
-  )
-/*++
-
-  Routine Description:
-    Remove a registered notification function from a particular keystroke.
-
-  Arguments:
-    This                    - Protocol instance pointer.    
-    NotificationHandle      - The handle of the notification function being unregistered.
-
-  Returns:
-    EFI_SUCCESS             - The notification function was unregistered successfully.
-    EFI_INVALID_PARAMETER   - The NotificationHandle is invalid.
-                              
-**/   
-{
-  GOP_PRIVATE_DATA                   *Private;
-  LIST_ENTRY                         *Link;
-  EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify;
-
-  if (NotificationHandle == NULL) {
-    return EFI_INVALID_PARAMETER;
-  } 
-
-  if (((EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY *) NotificationHandle)->Signature != EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE) {
-    return EFI_INVALID_PARAMETER;
-  } 
-
-  Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This);
-
-  for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
-    CurrentNotify = CR (
-                      Link, 
-                      EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY, 
-                      NotifyEntry, 
-                      EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
-                      );       
-    if (CurrentNotify->NotifyHandle == NotificationHandle) {
-      //
-      // Remove the notification function from NotifyList and free resources
-      //
-      RemoveEntryList (&CurrentNotify->NotifyEntry);    
-      
-      gBS->CloseEvent (CurrentNotify->Event);
-
-      gBS->FreePool (CurrentNotify);            
-      return EFI_SUCCESS;
-    }
-  }
-
-  //
-  // Can not find the specified Notification Handle
-  //
-  return EFI_INVALID_PARAMETER;
-}
-
-
-
-/**
-  Initialize SimplelTextIn and SimpleTextInEx protocols in the Private
-  context structure.
-
-  @param  Private               Context structure to fill in. 
-
-  @return EFI_SUCCESS           Initialization was a success
-
-**/
-EFI_STATUS
-EmuGopInitializeSimpleTextInForWindow (
-  IN  GOP_PRIVATE_DATA    *Private
-  )
-{
-  EFI_STATUS  Status;
-
-  //
-  // Initialize Simple Text In protoocol
-  //
-  Private->SimpleTextIn.Reset         = EmuGopSimpleTextInReset;
-  Private->SimpleTextIn.ReadKeyStroke = EmuGopSimpleTextInReadKeyStroke;
-
-  Status = gBS->CreateEvent (
-                  EVT_NOTIFY_WAIT,
-                  TPL_NOTIFY,
-                  EmuGopSimpleTextInWaitForKey,
-                  Private,
-                  &Private->SimpleTextIn.WaitForKey
-                  );
-  ASSERT_EFI_ERROR (Status);
-  
-  
-  //
-  // Initialize Simple Text In Ex
-  //
-  
-  Private->SimpleTextInEx.Reset               = EmuGopSimpleTextInExResetEx;
-  Private->SimpleTextInEx.ReadKeyStrokeEx     = EmuGopSimpleTextInExReadKeyStrokeEx;
-  Private->SimpleTextInEx.SetState            = EmuGopSimpleTextInExSetState;
-  Private->SimpleTextInEx.RegisterKeyNotify   = EmuGopSimpleTextInExRegisterKeyNotify;
-  Private->SimpleTextInEx.UnregisterKeyNotify = EmuGopSimpleTextInExUnregisterKeyNotify;
-
-  Private->SimpleTextInEx.Reset (&Private->SimpleTextInEx, FALSE);
-  
-  InitializeListHead (&Private->NotifyList);
-
-  Status = gBS->CreateEvent (
-                  EVT_NOTIFY_WAIT,
-                  TPL_NOTIFY,
-                  EmuGopSimpleTextInWaitForKey,
-                  Private,
-                  &Private->SimpleTextInEx.WaitForKeyEx
-                  );
-  ASSERT_EFI_ERROR (Status);
-
-
-  return Status;
-}
-
-
-
-
-
-
-
-//
-// Simple Pointer implementation.
-//
-
-
-/**                                                                 
-  Resets the pointer device hardware.
-    
-  @param  This                  A pointer to the EFI_SIMPLE_POINTER_PROTOCOL
-                                instance.                                   
-  @param  ExtendedVerification  Indicates that the driver may perform a more exhaustive
-                                verification operation of the device during reset.                                       
-                                
-  @retval EFI_SUCCESS           The device was reset.
-  @retval EFI_DEVICE_ERROR      The device is not functioning correctly and could not be reset.  
-                                   
-**/
-EFI_STATUS
-EFIAPI
-EmuGopSimplePointerReset (
-  IN EFI_SIMPLE_POINTER_PROTOCOL          *This,
-  IN BOOLEAN                              ExtendedVerification
-  )
-{
-  GOP_PRIVATE_DATA             *Private;
-  EFI_SIMPLE_POINTER_STATE     State;
-  EFI_TPL                      OldTpl;
-
-  Private = GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS (This);
-  if (Private->EmuGraphicsWindow == NULL) {
-    return EFI_SUCCESS;
-  }
-
-  //
-  // Enter critical section
-  //
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
-  //
-  // A reset is draining the Queue
-  //
-  while (Private->EmuGraphicsWindow->GetPointerState (Private->EmuGraphicsWindow, &State) == EFI_SUCCESS)
-    ;
-
-  //
-  // Leave critical section and return
-  //
-  gBS->RestoreTPL (OldTpl);
-  return EFI_SUCCESS;
-}
-
-
-/**                                                                 
-  Retrieves the current state of a pointer device.
-    
-  @param  This                  A pointer to the EFI_SIMPLE_POINTER_PROTOCOL
-                                instance.                                   
-  @param  State                 A pointer to the state information on the pointer device.
-                                
-  @retval EFI_SUCCESS           The state of the pointer device was returned in State.
-  @retval EFI_NOT_READY         The state of the pointer device has not changed since the last call to
-                                GetState().                                                           
-  @retval EFI_DEVICE_ERROR      A device error occurred while attempting to retrieve the pointer device's
-                                current state.                                                           
-                                   
-**/
-EFI_STATUS
-EFIAPI
-EmuGopSimplePointerGetState (
-  IN EFI_SIMPLE_POINTER_PROTOCOL          *This,
-  IN OUT EFI_SIMPLE_POINTER_STATE         *State
-  )
-{
-  GOP_PRIVATE_DATA  *Private;
-  EFI_STATUS        Status;
-  EFI_TPL           OldTpl;
-
-  Private = GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS (This);
-  if (Private->EmuGraphicsWindow == NULL) {
-    return EFI_NOT_READY;
-  }
-
-  //
-  // Enter critical section
-  //
-  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);
-
-  Status  = Private->EmuGraphicsWindow->GetPointerState (Private->EmuGraphicsWindow, State);
-  //
-  // Leave critical section and return
-  //
-  gBS->RestoreTPL (OldTpl);
-
-  return Status;
-}
-
-
-/**
-  SimplePointer Notify Wait Event 
-
-  @param  Event                 Event whose notification function is being invoked.
-  @param  Context               Pointer to GOP_PRIVATE_DATA.
-
-**/
-VOID
-EFIAPI
-EmuGopSimplePointerWaitForInput (
-  IN EFI_EVENT          Event,
-  IN VOID               *Context
-  )
-{
-  GOP_PRIVATE_DATA  *Private;
-  EFI_STATUS        Status;
-  EFI_TPL           OldTpl;
-
-  Private = (GOP_PRIVATE_DATA *) Context;
-  if (Private->EmuGraphicsWindow == NULL) {
-    return;
-  }
-
-  //
-  // Enter critical section
-  //
-  OldTpl  = gBS->RaiseTPL (TPL_NOTIFY);
-
-  Status  = Private->EmuGraphicsWindow->CheckPointer (Private->EmuGraphicsWindow);
-  if (!EFI_ERROR (Status)) {
-    //
-    // If the pointer state has changed, signal our event.
-    //
-    gBS->SignalEvent (Event);
-  }
-  //
-  // Leave critical section and return
-  //
-  gBS->RestoreTPL (OldTpl);
-}
-
-
-/**
-  SimplePointer constructor 
-
-  @param  Private Context structure to fill in.      
-
-  @retval EFI_SUCCESS Constructor had success        
-
-**/
-EFI_STATUS
-EmuGopInitializeSimplePointerForWindow (
-  IN  GOP_PRIVATE_DATA    *Private
-  )
-{
-  EFI_STATUS  Status;
-
-  //
-  // Initialize Simple Pointer protoocol
-  //
-  Private->PointerMode.ResolutionX = 1;
-  Private->PointerMode.ResolutionY = 1;
-  Private->PointerMode.ResolutionZ = 1;
-  Private->PointerMode.LeftButton  = TRUE;
-  Private->PointerMode.RightButton = TRUE;
-
-  Private->SimplePointer.Reset     = EmuGopSimplePointerReset;
-  Private->SimplePointer.GetState  = EmuGopSimplePointerGetState;
-  Private->SimplePointer.Mode      = &Private->PointerMode;
-
-  Status = gBS->CreateEvent (
-                  EVT_NOTIFY_WAIT,
-                  TPL_NOTIFY,
-                  EmuGopSimplePointerWaitForInput,
-                  Private,
-                  &Private->SimplePointer.WaitForInput
-                  );
-
-  return Status;
-}
diff --git a/InOsEmuPkg/EmuGopDxe/GopScreen.c b/InOsEmuPkg/EmuGopDxe/GopScreen.c
deleted file mode 100644 (file)
index 7f4333d..0000000
+++ /dev/null
@@ -1,420 +0,0 @@
-/*++ @file
-
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
-Portions 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.
-
-Module Name:
-
-    EmuGopScreen.c
-
-Abstract:
-
-  This file produces the graphics abstration of UGA. It is called by
-  EmuGopDriver.c file which deals with the EFI 1.1 driver model.
-  This file just does graphics.
-
-**/
-
-#include "Gop.h"
-
-
-EFI_EVENT               mGopScreenExitBootServicesEvent;
-
-GOP_MODE_DATA mGopModeData[] = {
-    { 800,  600, 0, 0 },
-    { 640,  480, 0, 0 },
-    { 720,  400, 0, 0 },
-    {1024,  768, 0, 0 },
-    {1280, 1024, 0, 0 }
-    };
-
-
-/**
-  Returns information for an available graphics mode that the graphics device
-  and the set of active video output devices supports.
-
-  @param  This                  The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
-  @param  ModeNumber            The mode number to return information on.
-  @param  SizeOfInfo            A pointer to the size, in bytes, of the Info buffer.
-  @param  Info                  A pointer to callee allocated buffer that returns information about ModeNumber.
-
-  @retval EFI_SUCCESS           Mode information returned.
-  @retval EFI_BUFFER_TOO_SMALL  The Info buffer was too small.
-  @retval EFI_DEVICE_ERROR      A hardware error occurred trying to retrieve the video mode.
-  @retval EFI_NOT_STARTED       Video display is not initialized. Call SetMode ()
-  @retval EFI_INVALID_PARAMETER One of the input args was NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-EmuGopQuerytMode (
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL          *This,
-  IN  UINT32                                ModeNumber,
-  OUT UINTN                                 *SizeOfInfo,
-  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  **Info
-  )
-{
-  GOP_PRIVATE_DATA  *Private;
-
-  Private = GOP_PRIVATE_DATA_FROM_THIS (This);
-
-  if (Info == NULL || SizeOfInfo == NULL || (UINTN) ModeNumber >= This->Mode->MaxMode) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  *Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
-  if (*Info == NULL) {
-    return EFI_OUT_OF_RESOURCES;
-  }
-
-  *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
-
-  (*Info)->Version = 0;
-  (*Info)->HorizontalResolution = Private->ModeData[ModeNumber].HorizontalResolution;
-  (*Info)->VerticalResolution   = Private->ModeData[ModeNumber].VerticalResolution;
-  (*Info)->PixelFormat = PixelBltOnly;
-  (*Info)->PixelsPerScanLine = (*Info)->HorizontalResolution;
-
-  return EFI_SUCCESS;
-}
-
-
-
-/**
-  Set the video device into the specified mode and clears the visible portions of 
-  the output display to black.
-
-  @param  This              The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
-  @param  ModeNumber        Abstraction that defines the current video mode.
-
-  @retval EFI_SUCCESS       The graphics mode specified by ModeNumber was selected.
-  @retval EFI_DEVICE_ERROR  The device had an error and could not complete the request.
-  @retval EFI_UNSUPPORTED   ModeNumber is not supported by this device.
-
-**/
-EFI_STATUS
-EFIAPI
-EmuGopSetMode (
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL  *This,
-  IN  UINT32                        ModeNumber
-  )
-{
-  EFI_STATUS                      Status;
-  GOP_PRIVATE_DATA                *Private;
-  GOP_MODE_DATA                   *ModeData;
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL   Fill;
-
-  Private = GOP_PRIVATE_DATA_FROM_THIS (This);
-
-  if (ModeNumber >= This->Mode->MaxMode) {
-    return EFI_UNSUPPORTED;
-  }
-
-  ModeData = &Private->ModeData[ModeNumber];
-  This->Mode->Mode = ModeNumber;
-  Private->GraphicsOutput.Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;
-  Private->GraphicsOutput.Mode->Info->VerticalResolution = ModeData->VerticalResolution;
-  Private->GraphicsOutput.Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution;
-
-  if (Private->HardwareNeedsStarting) {
-    Status = EmuGopStartWindow (
-              Private,
-              ModeData->HorizontalResolution,
-              ModeData->VerticalResolution,
-              ModeData->ColorDepth,
-              ModeData->RefreshRate
-              );
-    if (EFI_ERROR (Status)) {
-      return EFI_DEVICE_ERROR;
-    }
-
-    Private->HardwareNeedsStarting = FALSE;
-  }
-  
-  
-  Status = Private->EmuGraphicsWindow->Size(
-                            Private->EmuGraphicsWindow,
-                            ModeData->HorizontalResolution,
-                            ModeData->VerticalResolution
-                            );
-
-
-  Fill.Red                      = 0x7f;
-  Fill.Green                    = 0x7F;
-  Fill.Blue                     = 0x7f;
-  This->Blt (
-          This,
-          &Fill,
-          EfiBltVideoFill,
-          0,
-          0,
-          0,
-          0,
-          ModeData->HorizontalResolution,
-          ModeData->VerticalResolution,
-          ModeData->HorizontalResolution * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
-          );
-  return EFI_SUCCESS;
-}
-
-
-
-/**
-  Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
-  
-  @param  This         Protocol instance pointer.
-  @param  BltBuffer    Buffer containing data to blit into video buffer. This
-                       buffer has a size of Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
-  @param  BltOperation Operation to perform on BlitBuffer and video memory
-  @param  SourceX      X coordinate of source for the BltBuffer.
-  @param  SourceY      Y coordinate of source for the BltBuffer.
-  @param  DestinationX X coordinate of destination for the BltBuffer.
-  @param  DestinationY Y coordinate of destination for the BltBuffer.
-  @param  Width        Width of rectangle in BltBuffer in pixels.
-  @param  Height       Hight of rectangle in BltBuffer in pixels.
-  @param  Delta        OPTIONAL
-
-  @retval EFI_SUCCESS           The Blt operation completed.
-  @retval EFI_INVALID_PARAMETER BltOperation is not valid.
-  @retval EFI_DEVICE_ERROR      A hardware error occured writting to the video buffer.
-
-**/
-EFI_STATUS
-EFIAPI
-EmuGopBlt (
-  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL            *This,
-  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL           *BltBuffer,   OPTIONAL
-  IN  EFI_GRAPHICS_OUTPUT_BLT_OPERATION       BltOperation,
-  IN  UINTN                                   SourceX,
-  IN  UINTN                                   SourceY,
-  IN  UINTN                                   DestinationX,
-  IN  UINTN                                   DestinationY,
-  IN  UINTN                                   Width,
-  IN  UINTN                                   Height,
-  IN  UINTN                                   Delta         OPTIONAL
-  )
-{
-  GOP_PRIVATE_DATA  *Private;
-  EFI_TPL           OriginalTPL;
-  EFI_STATUS        Status;
-  EMU_GRAPHICS_WINDOWS__BLT_ARGS      GopBltArgs;
-
-  Private = GOP_PRIVATE_DATA_FROM_THIS (This);
-
-  if ((BltOperation < 0) || (BltOperation >= EfiGraphicsOutputBltOperationMax)) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  if (Width == 0 || Height == 0) {
-    return EFI_INVALID_PARAMETER;
-  }
-  //
-  // If Delta is zero, then the entire BltBuffer is being used, so Delta
-  // is the number of bytes in each row of BltBuffer.  Since BltBuffer is Width pixels size,
-  // the number of bytes in each row can be computed.
-  //
-  if (Delta == 0) {
-    Delta = Width * sizeof (EFI_UGA_PIXEL);
-  }
-
-  //
-  // We have to raise to TPL Notify, so we make an atomic write the frame buffer.
-  // We would not want a timer based event (Cursor, ...) to come in while we are
-  // doing this operation.
-  //
-  OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY);
-
-  //
-  // Pack UGA Draw protocol parameters to EMU_GRAPHICS_WINDOWS__BLT_ARGS structure to adapt to
-  // GopBlt() API of Unix UGA IO protocol.
-  //
-  GopBltArgs.DestinationX = DestinationX;
-  GopBltArgs.DestinationY = DestinationY;
-  GopBltArgs.Height       = Height;
-  GopBltArgs.Width        = Width;
-  GopBltArgs.SourceX      = SourceX;
-  GopBltArgs.SourceY      = SourceY;
-  GopBltArgs.Delta        = Delta;
-  Status = Private->EmuGraphicsWindow->Blt (
-                            Private->EmuGraphicsWindow,
-                            (EFI_UGA_PIXEL *)BltBuffer,
-                            (EFI_UGA_BLT_OPERATION)BltOperation,
-                            &GopBltArgs
-                            );
-
-  gBS->RestoreTPL (OriginalTPL);
-
-  return Status;
-}
-
-
-//
-// Construction and Destruction functions
-//
-
-EFI_STATUS
-EmuGopSupported (
-  IN  EMU_IO_THUNK_PROTOCOL  *EmuIoThunk
-  )
-{
-  //
-  // Check to see if the IO abstraction represents a device type we support.
-  //
-  // This would be replaced a check of PCI subsystem ID, etc.
-  //
-  if (!CompareGuid (EmuIoThunk->Protocol, &gEmuGraphicsWindowProtocolGuid)) {
-    return EFI_UNSUPPORTED;
-  }
-
-  return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EmuGopStartWindow (
-  IN  GOP_PRIVATE_DATA    *Private,
-  IN  UINT32              HorizontalResolution,
-  IN  UINT32              VerticalResolution,
-  IN  UINT32              ColorDepth,
-  IN  UINT32              RefreshRate
-  )
-{
-  EFI_STATUS          Status;
-
-  //
-  // Register to be notified on exit boot services so we can destroy the window.
-  //
-  Status = gBS->CreateEvent (
-                  EVT_SIGNAL_EXIT_BOOT_SERVICES,
-                  TPL_CALLBACK,
-                  ShutdownGopEvent,
-                  Private,
-                  &mGopScreenExitBootServicesEvent
-                  );
-
-  Status = Private->EmuIoThunk->Open (Private->EmuIoThunk);
-  if (!EFI_ERROR (Status)) {
-    Private->EmuGraphicsWindow = Private->EmuIoThunk->Interface;
-    
-    // Register callback to support RegisterKeyNotify()
-    Status  = Private->EmuGraphicsWindow->RegisterKeyNotify (
-                                            Private->EmuGraphicsWindow, 
-                                            GopPrivateMakeCallbackFunction, 
-                                            GopPrivateBreakCallbackFunction, 
-                                            Private
-                                            );
-    ASSERT_EFI_ERROR (Status);
-  }
-  return Status;
-}
-
-EFI_STATUS
-EmuGopConstructor (
-  GOP_PRIVATE_DATA    *Private
-  )
-{
-  Private->ModeData = mGopModeData;
-
-  Private->GraphicsOutput.QueryMode      = EmuGopQuerytMode;
-  Private->GraphicsOutput.SetMode        = EmuGopSetMode;
-  Private->GraphicsOutput.Blt            = EmuGopBlt;
-
-  //
-  // Allocate buffer for Graphics Output Protocol mode information
-  //
-  Private->GraphicsOutput.Mode = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE));
-  if (Private->GraphicsOutput.Mode == NULL) {
-    return EFI_OUT_OF_RESOURCES;
-  }
-  Private->GraphicsOutput.Mode->Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
-  if (Private->GraphicsOutput.Mode->Info == NULL) {
-    return EFI_OUT_OF_RESOURCES;
-  }
-
-  Private->GraphicsOutput.Mode->MaxMode = sizeof(mGopModeData) / sizeof(GOP_MODE_DATA);
-  //
-  // Till now, we have no idea about the window size.
-  //
-  Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;
-  Private->GraphicsOutput.Mode->Info->Version = 0;
-  Private->GraphicsOutput.Mode->Info->HorizontalResolution = 0;
-  Private->GraphicsOutput.Mode->Info->VerticalResolution = 0;
-  Private->GraphicsOutput.Mode->Info->PixelFormat = PixelBltOnly;
-  Private->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
-  Private->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL;
-  Private->GraphicsOutput.Mode->FrameBufferSize = 0;
-
-  Private->HardwareNeedsStarting  = TRUE;
-  Private->EmuGraphicsWindow                  = NULL;
-
-  EmuGopInitializeSimpleTextInForWindow (Private);
-
-  EmuGopInitializeSimplePointerForWindow (Private);
-
-  return EFI_SUCCESS;
-}
-
-
-
-EFI_STATUS
-EmuGopDestructor (
-  GOP_PRIVATE_DATA     *Private
-  )
-{
-  EFI_STATUS  Status;
-  
-  Status = EFI_SUCCESS;
-  if (!Private->HardwareNeedsStarting) {
-    Status = Private->EmuIoThunk->Close (Private->EmuIoThunk);
-    Private->EmuGraphicsWindow = NULL;
-  }
-
-  //
-  // Free graphics output protocol occupied resource
-  //
-  if (Private->GraphicsOutput.Mode != NULL) {
-    if (Private->GraphicsOutput.Mode->Info != NULL) {
-      FreePool (Private->GraphicsOutput.Mode->Info);
-    }
-    FreePool (Private->GraphicsOutput.Mode);
-  }
-
-  return EFI_SUCCESS;
-}
-
-
-VOID
-EFIAPI
-ShutdownGopEvent (
-  IN EFI_EVENT  Event,
-  IN VOID       *Context
-  )
-/*++
-
-Routine Description:
-
-  This is the UGA screen's callback notification function for exit-boot-services.
-  All we do here is call EmuGopDestructor().
-
-Arguments:
-
-  Event   - not used
-  Context - pointer to the Private structure.
-
-Returns:
-
-  None.
-
-**/
-{
-  EFI_STATUS  Status;
-  Status = EmuGopDestructor (Context);
-}
-
diff --git a/InOsEmuPkg/EmuSimpleFileSystemDxe/ComponentName.c b/InOsEmuPkg/EmuSimpleFileSystemDxe/ComponentName.c
deleted file mode 100644 (file)
index fa6404a..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-/** @file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#include "EmuSimpleFileSystem.h"\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                                        *This,\r
-  IN  EFI_HANDLE                                                         ControllerHandle,\r
-  IN  EFI_HANDLE                                                         ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                                              *Language,\r
-  OUT CHAR16                                                             **ControllerName\r
-  );\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gEmuSimpleFileSystemComponentName = {\r
-  EmuSimpleFileSystemComponentNameGetDriverName,\r
-  EmuSimpleFileSystemComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL  gEmuSimpleFileSystemComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuSimpleFileSystemComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuSimpleFileSystemComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-EFI_UNICODE_STRING_TABLE mEmuSimpleFileSystemDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"Emu Simple File System Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-          Language,\r
-          This->SupportedLanguages,\r
-          mEmuSimpleFileSystemDriverNameTable,\r
-          DriverName,\r
-          (BOOLEAN)(This == &gEmuSimpleFileSystemComponentName)\r
-          );\r
-}\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                                        *This,\r
-  IN  EFI_HANDLE                                                         ControllerHandle,\r
-  IN  EFI_HANDLE                                                         ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                                              *Language,\r
-  OUT CHAR16                                                             **ControllerName\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL   *SimpleFileSystem;\r
-  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *Private;\r
-\r
-  //\r
-  // This is a device driver, so ChildHandle must be NULL.\r
-  //\r
-  if (ChildHandle != NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Make sure this driver is currently managing ControllerHandle\r
-  //\r
-  Status = EfiTestManagedDevice (\r
-             ControllerHandle,\r
-             gEmuSimpleFileSystemDriverBinding.DriverBindingHandle,\r
-             &gEmuIoThunkProtocolGuid\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Get our context back\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  (VOID**)&SimpleFileSystem,\r
-                  gEmuSimpleFileSystemDriverBinding.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem);\r
-\r
-  return LookupUnicodeString2 (\r
-          Language,\r
-          This->SupportedLanguages,\r
-          Private->ControllerNameTable,\r
-          ControllerName,\r
-          (BOOLEAN)(This == &gEmuSimpleFileSystemComponentName)\r
-          );\r
-}\r
diff --git a/InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c b/InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
deleted file mode 100644 (file)
index 551b543..0000000
+++ /dev/null
@@ -1,915 +0,0 @@
-/*++ @file\r
-  Produce Simple File System abstractions for directories on your PC using Posix APIs.\r
-  The configuration of what devices to mount or emulate comes from UNIX \r
-  environment variables. The variables must be visible to the Microsoft* \r
-  Developer Studio for them to work.\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "EmuSimpleFileSystem.h"\r
-\r
-\r
-\r
-\r
-/**\r
-  Opens a new file relative to the source file's location.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  NewHandle  Returns File Handle for FileName.\r
-  @param  FileName   Null terminated string. "\", ".", and ".." are supported.\r
-  @param  OpenMode   Open mode for file.\r
-  @param  Attributes Only used for EFI_FILE_MODE_CREATE.\r
-\r
-  @retval EFI_SUCCESS          The device was opened.\r
-  @retval EFI_NOT_FOUND        The specified file could not be found on the device.\r
-  @retval EFI_NO_MEDIA         The device has no media.\r
-  @retval EFI_MEDIA_CHANGED    The media has changed.\r
-  @retval EFI_DEVICE_ERROR     The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_ACCESS_DENIED    The service denied access to the file.\r
-  @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.\r
-  @retval EFI_VOLUME_FULL      The volume is full.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemOpen (\r
-  IN  EFI_FILE_PROTOCOL   *This,\r
-  OUT EFI_FILE_PROTOCOL   **NewHandle,\r
-  IN  CHAR16              *FileName,\r
-  IN  UINT64              OpenMode,\r
-  IN  UINT64              Attributes\r
-  )\r
-{\r
-  EMU_EFI_FILE_PRIVATE              *PrivateFile;\r
-\r
-  //\r
-  // Check for obvious invalid parameters.\r
-  //\r
-  if (This == NULL || NewHandle == NULL || FileName == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  switch (OpenMode) {\r
-  case EFI_FILE_MODE_CREATE | EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:\r
-    if (Attributes &~EFI_FILE_VALID_ATTR) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (Attributes & EFI_FILE_READ_ONLY) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-  //\r
-  // fall through\r
-  //\r
-  case EFI_FILE_MODE_READ:\r
-  case EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE:\r
-    break;\r
-\r
-  default:\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  PrivateFile     = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return PrivateFile->Io->Open (PrivateFile->Io, NewHandle, FileName, OpenMode, Attributes);\r
-}\r
-\r
-\r
-\r
-/**\r
-  Close the file handle\r
-\r
-  @param  This          Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS   The file was closed.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemClose (\r
-  IN EFI_FILE_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_EFI_FILE_PRIVATE    *PrivateFile;\r
-  EFI_TPL                 OldTpl;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  Status = PrivateFile->Io->Close (PrivateFile->Io);\r
-  if (!EFI_ERROR (Status)) {\r
-    gBS->FreePool (PrivateFile);\r
-  }\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  \r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Close and delete the file handle.\r
-\r
-  @param  This                     Protocol instance pointer.\r
-                                   \r
-  @retval EFI_SUCCESS              The file was closed and deleted.\r
-  @retval EFI_WARN_DELETE_FAILURE  The handle was closed but the file was not deleted.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemDelete (\r
-  IN EFI_FILE_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_EFI_FILE_PRIVATE    *PrivateFile;\r
-  EFI_TPL                 OldTpl;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-  \r
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Status = PrivateFile->Io->Delete (PrivateFile->Io);\r
-  if (!EFI_ERROR (Status)) {\r
-    gBS->FreePool (PrivateFile);\r
-  }\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Read data from the file.\r
-\r
-  @param  This       Protocol instance pointer.\r
-  @param  BufferSize On input size of buffer, on output amount of data in buffer.\r
-  @param  Buffer     The buffer in which data is read.\r
-\r
-  @retval EFI_SUCCESS          Data was read.\r
-  @retval EFI_NO_MEDIA         The device has no media.\r
-  @retval EFI_DEVICE_ERROR     The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_BUFFER_TO_SMALL  BufferSize is too small. BufferSize contains required size.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemRead (\r
-  IN     EFI_FILE_PROTOCOL  *This,\r
-  IN OUT UINTN              *BufferSize,\r
-  OUT    VOID               *Buffer\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_EFI_FILE_PRIVATE    *PrivateFile;\r
-  EFI_TPL                 OldTpl;\r
-\r
-  if (This == NULL || BufferSize == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  if ((*BufferSize != 0) && (Buffer == NULL)) {\r
-    // Buffer can be NULL  if *BufferSize is zero\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-  \r
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Status = PrivateFile->Io->Read (PrivateFile->Io, BufferSize, Buffer);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Write data to a file.\r
-\r
-  @param  This       Protocol instance pointer.\r
-  @param  BufferSize On input size of buffer, on output amount of data in buffer.\r
-  @param  Buffer     The buffer in which data to write.\r
-\r
-  @retval EFI_SUCCESS          Data was written.\r
-  @retval EFI_UNSUPPORTED      Writes to Open directory are not supported.\r
-  @retval EFI_NO_MEDIA         The device has no media.\r
-  @retval EFI_DEVICE_ERROR     The device reported an error.\r
-  @retval EFI_DEVICE_ERROR     An attempt was made to write to a deleted file.\r
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED  The device is write protected.\r
-  @retval EFI_ACCESS_DENIED    The file was open for read only.\r
-  @retval EFI_VOLUME_FULL      The volume is full.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemWrite (\r
-  IN     EFI_FILE_PROTOCOL  *This,\r
-  IN OUT UINTN              *BufferSize,\r
-  IN     VOID               *Buffer\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EMU_EFI_FILE_PRIVATE *PrivateFile;\r
-  EFI_TPL               OldTpl;\r
-\r
-  if (This == NULL || BufferSize == NULL || Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Status = PrivateFile->Io->Write (PrivateFile->Io, BufferSize, Buffer);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Set a files current position\r
-\r
-  @param  This            Protocol instance pointer.\r
-  @param  Position        Byte position from the start of the file.\r
-                          \r
-  @retval EFI_SUCCESS     Position was updated.\r
-  @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemGetPosition (\r
-  IN  EFI_FILE_PROTOCOL   *This,\r
-  OUT UINT64              *Position\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EMU_EFI_FILE_PRIVATE *PrivateFile;\r
-  EFI_TPL               OldTpl;\r
-\r
-  if (This == NULL || Position == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-  \r
-  PrivateFile   = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Status = PrivateFile->Io->GetPosition (PrivateFile->Io, Position);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-/**\r
-  Get a file's current position\r
-\r
-  @param  This            Protocol instance pointer.\r
-  @param  Position        Byte position from the start of the file.\r
-                          \r
-  @retval EFI_SUCCESS     Position was updated.\r
-  @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open..\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemSetPosition (\r
-  IN EFI_FILE_PROTOCOL  *This,\r
-  IN UINT64             Position\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_EFI_FILE_PRIVATE    *PrivateFile;\r
-  EFI_TPL                 OldTpl;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-  \r
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Status = PrivateFile->Io->SetPosition (PrivateFile->Io, Position);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Get information about a file.\r
-\r
-  @param  This            Protocol instance pointer.\r
-  @param  InformationType Type of information to return in Buffer.\r
-  @param  BufferSize      On input size of buffer, on output amount of data in buffer.\r
-  @param  Buffer          The buffer to return data.\r
-\r
-  @retval EFI_SUCCESS          Data was returned.\r
-  @retval EFI_UNSUPPORTED      InformationType is not supported.\r
-  @retval EFI_NO_MEDIA         The device has no media.\r
-  @retval EFI_DEVICE_ERROR     The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED  The device is write protected.\r
-  @retval EFI_ACCESS_DENIED    The file was open for read only.\r
-  @retval EFI_BUFFER_TOO_SMALL Buffer was too small; required size returned in BufferSize.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemGetInfo (\r
-  IN     EFI_FILE_PROTOCOL  *This,\r
-  IN     EFI_GUID           *InformationType,\r
-  IN OUT UINTN              *BufferSize,\r
-  OUT    VOID               *Buffer\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EMU_EFI_FILE_PRIVATE              *PrivateFile;\r
-  EFI_TPL                           OldTpl;\r
-\r
-  if (This == NULL || InformationType == NULL || BufferSize == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-    \r
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Status = PrivateFile->Io->GetInfo (PrivateFile->Io, InformationType, BufferSize, Buffer);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Set information about a file\r
-\r
-  @param  File            Protocol instance pointer.\r
-  @param  InformationType Type of information in Buffer.\r
-  @param  BufferSize      Size of buffer.\r
-  @param  Buffer          The data to write.\r
-\r
-  @retval EFI_SUCCESS          Data was set.\r
-  @retval EFI_UNSUPPORTED      InformationType is not supported.\r
-  @retval EFI_NO_MEDIA         The device has no media.\r
-  @retval EFI_DEVICE_ERROR     The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED  The device is write protected.\r
-  @retval EFI_ACCESS_DENIED    The file was open for read only.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemSetInfo (\r
-  IN EFI_FILE_PROTOCOL*This,\r
-  IN EFI_GUID         *InformationType,\r
-  IN UINTN            BufferSize,\r
-  IN VOID             *Buffer\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EMU_EFI_FILE_PRIVATE              *PrivateFile;\r
-  EFI_TPL                           OldTpl;\r
-\r
-  //\r
-  // Check for invalid parameters.\r
-  //\r
-  if (This == NULL || InformationType == NULL || BufferSize == 0 || Buffer == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-  \r
-  PrivateFile               = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Status = PrivateFile->Io->SetInfo (PrivateFile->Io, InformationType, BufferSize, Buffer);\r
-\r
-  gBS->RestoreTPL (OldTpl);  \r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Flush data back for the file handle.\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS          Data was flushed.\r
-  @retval EFI_UNSUPPORTED      Writes to Open directory are not supported.\r
-  @retval EFI_NO_MEDIA         The device has no media.\r
-  @retval EFI_DEVICE_ERROR     The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED  The device is write protected.\r
-  @retval EFI_ACCESS_DENIED    The file was open for read only.\r
-  @retval EFI_VOLUME_FULL      The volume is full.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemFlush (\r
-  IN EFI_FILE_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EMU_EFI_FILE_PRIVATE      *PrivateFile;\r
-  EFI_TPL                   OldTpl;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-  \r
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Status = PrivateFile->Io->Flush (PrivateFile->Io);\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-/**\r
-  Open the root directory on a volume.\r
-\r
-  @param  This Protocol instance pointer.\r
-  @param  Root Returns an Open file handle for the root directory\r
-\r
-  @retval EFI_SUCCESS          The device was opened.\r
-  @retval EFI_UNSUPPORTED      This volume does not support the file system.\r
-  @retval EFI_NO_MEDIA         The device has no media.\r
-  @retval EFI_DEVICE_ERROR     The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_ACCESS_DENIED    The service denied access to the file.\r
-  @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemOpenVolume (\r
-  IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL  *This,\r
-  OUT EFI_FILE_PROTOCOL               **Root\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *Private;\r
-  EMU_EFI_FILE_PRIVATE              *PrivateFile;\r
-  EFI_TPL                           OldTpl;\r
-\r
-  Status = EFI_UNSUPPORTED;\r
-\r
-  if (This == NULL || Root == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
-\r
-  Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  PrivateFile = AllocatePool (sizeof (EMU_EFI_FILE_PRIVATE));\r
-  if (PrivateFile == NULL) {\r
-    goto Done;\r
-  }\r
-  \r
-  PrivateFile->Signature            = EMU_EFI_FILE_PRIVATE_SIGNATURE;\r
-  PrivateFile->IoThunk              = Private->IoThunk;\r
-  PrivateFile->SimpleFileSystem     = This;\r
-  PrivateFile->EfiFile.Revision     = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION;\r
-  PrivateFile->EfiFile.Open         = EmuSimpleFileSystemOpen;\r
-  PrivateFile->EfiFile.Close        = EmuSimpleFileSystemClose;\r
-  PrivateFile->EfiFile.Delete       = EmuSimpleFileSystemDelete;\r
-  PrivateFile->EfiFile.Read         = EmuSimpleFileSystemRead;\r
-  PrivateFile->EfiFile.Write        = EmuSimpleFileSystemWrite;\r
-  PrivateFile->EfiFile.GetPosition  = EmuSimpleFileSystemGetPosition;\r
-  PrivateFile->EfiFile.SetPosition  = EmuSimpleFileSystemSetPosition;\r
-  PrivateFile->EfiFile.GetInfo      = EmuSimpleFileSystemGetInfo;\r
-  PrivateFile->EfiFile.SetInfo      = EmuSimpleFileSystemSetInfo;\r
-  PrivateFile->EfiFile.Flush        = EmuSimpleFileSystemFlush;\r
-\r
-  *Root = &PrivateFile->EfiFile;\r
-\r
-  Status = Private->Io->OpenVolume (Private->Io, &PrivateFile->Io);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  \r
-  AddUnicodeString2 (\r
-    "eng",\r
-    gEmuSimpleFileSystemComponentName.SupportedLanguages,\r
-    &Private->ControllerNameTable,\r
-    Private->IoThunk->ConfigString,\r
-    TRUE\r
-    );\r
-\r
-  AddUnicodeString2 (\r
-    "en",\r
-    gEmuSimpleFileSystemComponentName.SupportedLanguages,\r
-    &Private->ControllerNameTable,\r
-    Private->IoThunk->ConfigString,\r
-    FALSE\r
-    );\r
-\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-    if (PrivateFile) {\r
-      gBS->FreePool (PrivateFile);\r
-    }\r
-    \r
-    *Root = NULL;\r
-  }\r
-\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Tests to see if this driver supports a given controller. If a child device is provided, \r
-  it further tests to see if this driver supports creating a handle for the specified child device.\r
-\r
-  This function checks to see if the driver specified by This supports the device specified by \r
-  ControllerHandle. Drivers will typically use the device path attached to \r
-  ControllerHandle and/or the services from the bus I/O abstraction attached to \r
-  ControllerHandle to determine if the driver supports ControllerHandle. This function \r
-  may be called many times during platform initialization. In order to reduce boot times, the tests \r
-  performed by this function must be very small, and take as little time as possible to execute. This \r
-  function must not change the state of any hardware devices, and this function must be aware that the \r
-  device specified by ControllerHandle may already be managed by the same driver or a \r
-  different driver. This function must match its calls to AllocatePages() with FreePages(), \r
-  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().  \r
-  Because ControllerHandle may have been previously started by the same driver, if a protocol is \r
-  already in the opened state, then it must not be closed with CloseProtocol(). This is required \r
-  to guarantee the state of ControllerHandle is not modified by this function.\r
-\r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to test. This handle \r
-                                   must support a protocol interface that supplies \r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
-                                   parameter is ignored by device drivers, and is optional for bus \r
-                                   drivers. For bus drivers, if this parameter is not NULL, then \r
-                                   the bus driver must determine if the bus controller specified \r
-                                   by ControllerHandle and the child controller specified \r
-                                   by RemainingDevicePath are both supported by this \r
-                                   bus driver.\r
-\r
-  @retval EFI_SUCCESS              The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is supported by the driver specified by This.\r
-  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is already being managed by the driver\r
-                                   specified by This.\r
-  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is already being managed by a different\r
-                                   driver or an application that requires exclusive access.\r
-                                   Currently not implemented.\r
-  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and\r
-                                   RemainingDevicePath is not supported by the driver specified by This.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemDriverBindingSupported (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_IO_THUNK_PROTOCOL  *EmuIoThunk;\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (VOID **)&EmuIoThunk,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Make sure GUID is for a File System handle.\r
-  //\r
-  Status = EFI_UNSUPPORTED;\r
-  if (CompareGuid (EmuIoThunk->Protocol, &gEfiSimpleFileSystemProtocolGuid)) {\r
-    Status = EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
-  //\r
-  gBS->CloseProtocol (\r
-        ControllerHandle,\r
-        &gEmuIoThunkProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        ControllerHandle\r
-        );\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-/**\r
-  Starts a device controller or a bus controller.\r
-\r
-  The Start() function is designed to be invoked from the EFI boot service ConnectController().\r
-  As a result, much of the error checking on the parameters to Start() has been moved into this \r
-  common boot service. It is legal to call Start() from other locations, \r
-  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE.\r
-  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
-     EFI_DEVICE_PATH_PROTOCOL.\r
-  3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
-     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.  \r
-\r
-  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle     The handle of the controller to start. This handle \r
-                                   must support a protocol interface that supplies \r
-                                   an I/O abstraction to the driver.\r
-  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This \r
-                                   parameter is ignored by device drivers, and is optional for bus \r
-                                   drivers. For a bus driver, if this parameter is NULL, then handles \r
-                                   for all the children of Controller are created by this driver.  \r
-                                   If this parameter is not NULL and the first Device Path Node is \r
-                                   not the End of Device Path Node, then only the handle for the \r
-                                   child device specified by the first Device Path Node of \r
-                                   RemainingDevicePath is created by this driver.\r
-                                   If the first Device Path Node of RemainingDevicePath is \r
-                                   the End of Device Path Node, no child handle is created by this\r
-                                   driver.\r
-\r
-  @retval EFI_SUCCESS              The device was started.\r
-  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.Currently not implemented.\r
-  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.\r
-  @retval Others                   The driver failded to start the device.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemDriverBindingStart (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL   *This,\r
-  IN  EFI_HANDLE                    ControllerHandle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EMU_IO_THUNK_PROTOCOL             *EmuIoThunk;\r
-  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *Private;\r
-\r
-  Private = NULL;\r
-\r
-  //\r
-  // Open the IO Abstraction(s) needed\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (VOID **)&EmuIoThunk,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Validate GUID\r
-  //\r
-  if (!CompareGuid (EmuIoThunk->Protocol, &gEfiSimpleFileSystemProtocolGuid)) {\r
-    Status = EFI_UNSUPPORTED;\r
-    goto Done;\r
-  }\r
-\r
-  Private = AllocateZeroPool (sizeof (EMU_SIMPLE_FILE_SYSTEM_PRIVATE));\r
-  if (Private == NULL) {\r
-    goto Done;\r
-  }\r
-\r
-  Status = EmuIoThunk->Open (EmuIoThunk);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  Private->Signature = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE;\r
-  Private->IoThunk   = EmuIoThunk;\r
-  Private->Io        = EmuIoThunk->Interface;\r
-  \r
-  Private->SimpleFileSystem.Revision    = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION;\r
-  Private->SimpleFileSystem.OpenVolume  = EmuSimpleFileSystemOpenVolume;\r
-\r
-  Private->ControllerNameTable = NULL;\r
-\r
-  AddUnicodeString2 (\r
-    "eng",\r
-    gEmuSimpleFileSystemComponentName.SupportedLanguages,\r
-    &Private->ControllerNameTable,\r
-    EmuIoThunk->ConfigString,\r
-    TRUE\r
-    );\r
-    \r
-  AddUnicodeString2 (\r
-    "en",\r
-    gEmuSimpleFileSystemComponentName2.SupportedLanguages,\r
-    &Private->ControllerNameTable,\r
-    EmuIoThunk->ConfigString,\r
-    FALSE\r
-    );\r
-\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &ControllerHandle,\r
-                  &gEfiSimpleFileSystemProtocolGuid,  &Private->SimpleFileSystem,\r
-                  NULL\r
-                  );\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-    if (Private != NULL) {\r
-      if (Private->ControllerNameTable != NULL) {\r
-        FreeUnicodeStringTable (Private->ControllerNameTable);\r
-      }\r
-      \r
-      gBS->FreePool (Private);\r
-    \r
-    }\r
-\r
-    gBS->CloseProtocol (\r
-          ControllerHandle,\r
-          &gEmuIoThunkProtocolGuid,\r
-          This->DriverBindingHandle,\r
-          ControllerHandle\r
-          );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Stops a device controller or a bus controller.\r
-  \r
-  The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
-  As a result, much of the error checking on the parameters to Stop() has been moved \r
-  into this common boot service. It is legal to call Stop() from other locations, \r
-  but the following calling restrictions must be followed, or the system behavior will not be deterministic.\r
-  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
-     same driver's Start() function.\r
-  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
-     EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
-     Start() function, and the Start() function must have called OpenProtocol() on\r
-     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
-  \r
-  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must \r
-                                support a bus specific I/O protocol for the driver \r
-                                to use to stop the device.\r
-  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.\r
-  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL \r
-                                if NumberOfChildren is 0.\r
-\r
-  @retval EFI_SUCCESS           The device was stopped.\r
-  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSimpleFileSystemDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL   *SimpleFileSystem;\r
-  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *Private;\r
-\r
-  //\r
-  // Get our context back\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiSimpleFileSystemProtocolGuid,\r
-                  (VOID **)&SimpleFileSystem,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem);\r
-  Status = Private->IoThunk->Close (Private->IoThunk);\r
-\r
-  //\r
-  // Uninstall the Simple File System Protocol from ControllerHandle\r
-  //\r
-  Status = gBS->UninstallMultipleProtocolInterfaces (\r
-                  ControllerHandle,\r
-                  &gEfiSimpleFileSystemProtocolGuid,  &Private->SimpleFileSystem,\r
-                  NULL\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = gBS->CloseProtocol (\r
-                    ControllerHandle,\r
-                    &gEmuIoThunkProtocolGuid,\r
-                    This->DriverBindingHandle,\r
-                    ControllerHandle\r
-                    );\r
-  }\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Free our instance data\r
-    //\r
-    FreeUnicodeStringTable (Private->ControllerNameTable);\r
-    gBS->FreePool (Private);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-EFI_DRIVER_BINDING_PROTOCOL gEmuSimpleFileSystemDriverBinding = {\r
-  EmuSimpleFileSystemDriverBindingSupported,\r
-  EmuSimpleFileSystemDriverBindingStart,\r
-  EmuSimpleFileSystemDriverBindingStop,\r
-  0xa,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-\r
-\r
-\r
-/**\r
-  The user Entry Point for module EmuSimpleFileSystem. The user code starts with this function.\r
-\r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
-  @param[in] SystemTable    A pointer to the EFI System Table.\r
-  \r
-  @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeEmuSimpleFileSystem(\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  Status = EfiLibInstallDriverBindingComponentName2 (\r
-             ImageHandle,\r
-             SystemTable,\r
-             &gEmuSimpleFileSystemDriverBinding,\r
-             ImageHandle,\r
-             &gEmuSimpleFileSystemComponentName,\r
-             &gEmuSimpleFileSystemComponentName2\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.h b/InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.h
deleted file mode 100644 (file)
index 5a1182c..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*++ @file\r
-  Produce Simple File System abstractions for a directory on your PC using Unix APIs.\r
-  The configuration of what devices to mount or emulate comes from  \r
-  environment variables.\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-\r
-**/\r
-\r
-#ifndef _EMU_SIMPLE_FILE_SYSTEM_H_\r
-#define _EMU_SIMPLE_FILE_SYSTEM_H_\r
-\r
-#include "PiDxe.h"\r
-\r
-#include <Guid/FileSystemInfo.h>\r
-#include <Guid/FileInfo.h>\r
-#include <Guid/FileSystemVolumeLabelInfo.h>\r
-\r
-#include <Protocol/EmuIoThunk.h>\r
-#include <Protocol/SimpleFileSystem.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-\r
-extern EFI_DRIVER_BINDING_PROTOCOL  gEmuSimpleFileSystemDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL  gEmuSimpleFileSystemComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL gEmuSimpleFileSystemComponentName2;\r
-\r
-#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'M', 'f', 's')\r
-\r
-typedef struct {\r
-  UINTN                           Signature;\r
-  EMU_IO_THUNK_PROTOCOL           *IoThunk;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Io;\r
-  EFI_UNICODE_STRING_TABLE        *ControllerNameTable;\r
-} EMU_SIMPLE_FILE_SYSTEM_PRIVATE;\r
-\r
-#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \\r
-  CR (a, \\r
-      EMU_SIMPLE_FILE_SYSTEM_PRIVATE, \\r
-      SimpleFileSystem, \\r
-      EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \\r
-      )\r
-\r
-#define EMU_EFI_FILE_PRIVATE_SIGNATURE SIGNATURE_32 ('e', 'm', 'f', 's')\r
-\r
-typedef struct {\r
-  UINTN                           Signature;\r
-  EMU_IO_THUNK_PROTOCOL           *IoThunk;\r
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;\r
-  EFI_FILE_PROTOCOL               EfiFile;\r
-  EFI_FILE_PROTOCOL               *Io;\r
-} EMU_EFI_FILE_PRIVATE;\r
-\r
-#define EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \\r
-  CR (a, \\r
-      EMU_EFI_FILE_PRIVATE, \\r
-      EfiFile, \\r
-      EMU_EFI_FILE_PRIVATE_SIGNATURE \\r
-      )\r
-\r
-\r
-\r
-#endif \r
diff --git a/InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf b/InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf
deleted file mode 100644 (file)
index f05f156..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-## @file\r
-# Simple filesystem driver\r
-#\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuSimpleFileSystem\r
-  FILE_GUID                      = 35B72237-3926-CF4A-A7F3-1449F9E0E4BD\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = InitializeEmuSimpleFileSystem\r
-\r
-\r
-[Sources]\r
-  ComponentName.c\r
-  EmuSimpleFileSystem.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  UefiLib\r
-  UefiDriverEntryPoint\r
-  BaseLib\r
-  DebugLib\r
-\r
-\r
-[Guids]\r
-  gEfiFileSystemVolumeLabelInfoIdGuid           # SOMETIMES_CONSUMED\r
-  gEfiFileInfoGuid                              # SOMETIMES_CONSUMED\r
-  gEfiFileSystemInfoGuid                        # SOMETIMES_CONSUMED\r
-\r
-\r
-[Protocols]\r
-  gEfiSimpleFileSystemProtocolGuid               # PROTOCOL BY_START\r
-  gEmuIoThunkProtocolGuid                        # PROTOCOL TO_START\r
-\r
diff --git a/InOsEmuPkg/EmuSnpDxe/ComponentName.c b/InOsEmuPkg/EmuSnpDxe/ComponentName.c
deleted file mode 100644 (file)
index a7c5124..0000000
+++ /dev/null
@@ -1,318 +0,0 @@
-/** @file\r
-\r
- Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
-\r
-    This program and the accompanying materials\r
-    are licensed and made available under the terms and conditions of the BSD License\r
-    which accompanies this distribution. The full text of the license may be found at\r
-    http://opensource.org/licenses/bsd-license.php\r
-\r
-    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  ComponentName.c\r
-\r
-Abstract:\r
-\r
--**/\r
-\r
-#include "EmuSnpDxe.h"\r
-\r
-//\r
-// EFI Component Name Functions\r
-//\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpDriverComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  );\r
-\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpDriverComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  );\r
-\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gEmuSnpDriverComponentName = {\r
-  EmuSnpDriverComponentNameGetDriverName,\r
-  EmuSnpDriverComponentNameGetControllerName,\r
-  "eng"\r
-};\r
-\r
-//\r
-// EFI Component Name 2 Protocol\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuSnpDriverComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuSnpDriverComponentNameGetControllerName,\r
-  "en"\r
-};\r
-\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuSnpDriverNameTable[] = {\r
-  {\r
-    "eng;en",\r
-    L"Emu SNP Driver"\r
-  },\r
-  {\r
-    NULL,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the driver.\r
-\r
-  This function retrieves the user readable name of a driver in the form of a\r
-  Unicode string. If the driver specified by This has a user readable name in\r
-  the language specified by Language, then a pointer to the driver name is\r
-  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
-  by This does not support the language specified by Language,\r
-  then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language. This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified\r
-                                in RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                driver specified by This in the language\r
-                                specified by Language.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
-                                This and the language specified by Language was\r
-                                returned in DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpDriverComponentNameGetDriverName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,\r
-  IN  CHAR8                        *Language,\r
-  OUT CHAR16                       **DriverName\r
-  )\r
-{\r
-  return LookupUnicodeString2 (\r
-           Language,\r
-           This->SupportedLanguages,\r
-           mEmuSnpDriverNameTable,\r
-           DriverName,\r
-           (BOOLEAN)(This == &gEmuSnpDriverComponentName)\r
-           );\r
-}\r
-\r
-/**\r
-  Retrieves a Unicode string that is the user readable name of the controller\r
-  that is being managed by a driver.\r
-\r
-  This function retrieves the user readable name of the controller specified by\r
-  ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
-  driver specified by This has a user readable name in the language specified by\r
-  Language, then a pointer to the controller name is returned in ControllerName,\r
-  and EFI_SUCCESS is returned.  If the driver specified by This is not currently\r
-  managing the controller specified by ControllerHandle and ChildHandle,\r
-  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
-  support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
-\r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
-                                EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
-                                specified by This is managing.  This handle\r
-                                specifies the controller whose name is to be\r
-                                returned.\r
-\r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
-                                the name of.  This is an optional parameter that\r
-                                may be NULL.  It will be NULL for device\r
-                                drivers.  It will also be NULL for a bus drivers\r
-                                that wish to retrieve the name of the bus\r
-                                controller.  It will not be NULL for a bus\r
-                                driver that wishes to retrieve the name of a\r
-                                child controller.\r
-\r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
-                                array indicating the language.  This is the\r
-                                language of the driver name that the caller is\r
-                                requesting, and it must match one of the\r
-                                languages specified in SupportedLanguages. The\r
-                                number of languages supported by a driver is up\r
-                                to the driver writer. Language is specified in\r
-                                RFC 4646 or ISO 639-2 language code format.\r
-\r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
-                                This Unicode string is the name of the\r
-                                controller specified by ControllerHandle and\r
-                                ChildHandle in the language specified by\r
-                                Language from the point of view of the driver\r
-                                specified by This.\r
-\r
-  @retval EFI_SUCCESS           The Unicode string for the user readable name in\r
-                                the language specified by Language for the\r
-                                driver specified by This was returned in\r
-                                DriverName.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
-                                EFI_HANDLE.\r
-\r
-  @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
-  @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
-                                managing the controller specified by\r
-                                ControllerHandle and ChildHandle.\r
-\r
-  @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
-                                the language specified by Language.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpDriverComponentNameGetControllerName (\r
-  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,\r
-  IN  EFI_HANDLE                                      ControllerHandle,\r
-  IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,\r
-  IN  CHAR8                                           *Language,\r
-  OUT CHAR16                                          **ControllerName\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
diff --git a/InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.c b/InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.c
deleted file mode 100644 (file)
index 4432218..0000000
+++ /dev/null
@@ -1,958 +0,0 @@
-/** @file\r
-\r
- Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-\r
-    This program and the accompanying materials\r
-    are licensed and made available under the terms and conditions of the BSD License\r
-    which accompanies this distribution. The full text of the license may be found at\r
-    http://opensource.org/licenses/bsd-license.php\r
-\r
-    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  EmuSnp.c\r
-\r
-Abstract:\r
-\r
--**/\r
-\r
-#include "EmuSnpDxe.h"\r
-\r
-\r
-\r
-EFI_SIMPLE_NETWORK_PROTOCOL gEmuSnpTemplate = {\r
-  EFI_SIMPLE_NETWORK_PROTOCOL_REVISION,  \r
-  EmuSnpStart,             \r
-  EmuSnpStop,              \r
-  EmuSnpInitialize,       \r
-  EmuSnpReset,              \r
-  EmuSnpShutdown,            \r
-  EmuSnpReceiveFilters,          \r
-  EmuSnpStationAddress,          \r
-  EmuSnpStatistics,            \r
-  EmuSnpMcastIptoMac,          \r
-  EmuSnpNvdata,              \r
-  EmuSnpGetStatus,            \r
-  EmuSnpTransmit,            \r
-  EmuSnpReceive,              \r
-  NULL,                     // WaitForPacket\r
-  NULL                      // Mode\r
- };\r
-\r
-\r
-\r
-\r
-/**\r
-  Changes the state of a network interface from "stopped" to "started".\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpStart(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_SNP_PRIVATE_DATA    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
-\r
-  Status = Private->Io->Start (Private->Io);\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Changes the state of a network interface from "started" to "stopped".\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpStop (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_SNP_PRIVATE_DATA    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
-\r
-  Status = Private->Io->Stop (Private->Io);\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Resets a network adapter and allocates the transmit and receive buffers \r
-  required by the network interface; optionally, also requests allocation \r
-  of additional transmit and receive buffers.\r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
-                            that the driver should allocate for the network interface.\r
-                            Some network interfaces will not be able to use the extra\r
-                            buffer, and the caller will not know if it is actually\r
-                            being used.\r
-  @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
-                            that the driver should allocate for the network interface.\r
-                            Some network interfaces will not be able to use the extra\r
-                            buffer, and the caller will not know if it is actually\r
-                            being used.\r
-\r
-  @retval EFI_SUCCESS           Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpInitialize (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
-  IN UINTN                          ExtraRxBufferSize OPTIONAL,\r
-  IN UINTN                          ExtraTxBufferSize OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_SNP_PRIVATE_DATA    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
-\r
-  Status = Private->Io->Initialize (Private->Io, ExtraRxBufferSize, ExtraTxBufferSize);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Resets a network adapter and re-initializes it with the parameters that were \r
-  provided in the previous call to Initialize().  \r
-\r
-  @param  This                 Protocol instance pointer.\r
-  @param  ExtendedVerification Indicates that the driver may perform a more\r
-                               exhaustive verification operation of the device\r
-                               during reset.\r
-\r
-  @retval EFI_SUCCESS           Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpReset (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
-  IN BOOLEAN                        ExtendedVerification\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_SNP_PRIVATE_DATA    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
-\r
-  Status = Private->Io->Reset (Private->Io, ExtendedVerification);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Resets a network adapter and leaves it in a state that is safe for \r
-  another driver to initialize.\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpShutdown (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_SNP_PRIVATE_DATA    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
-\r
-  Status = Private->Io->Shutdown (Private->Io);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Manages the multicast receive filters of a network interface.\r
-\r
-  @param  This               Protocol instance pointer.\r
-  @param  EnableBits         A bit mask of receive filters to enable on the network interface.\r
-  @param  DisableBits        A bit mask of receive filters to disable on the network interface.\r
-  @param  ResetMcastFilter   Set to TRUE to reset the contents of the multicast receive\r
-                             filters on the network interface to their default values.\r
-  @param  McastFilterCount   Number of multicast HW MAC addresses in the new\r
-                             MCastFilter list. This value must be less than or equal to\r
-                             the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This\r
-                             field is optional if ResetMCastFilter is TRUE.\r
-  @param  McastFilter        A pointer to a list of new multicast receive filter HW MAC\r
-                             addresses. This list will replace any existing multicast\r
-                             HW MAC address list. This field is optional if\r
-                             ResetMCastFilter is TRUE.\r
-\r
-  @retval EFI_SUCCESS           The multicast receive filter list was updated.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpReceiveFilters (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
-  IN UINT32                         EnableBits,\r
-  IN UINT32                         DisableBits,\r
-  IN BOOLEAN                        ResetMcastFilter,\r
-  IN UINTN                          McastFilterCount OPTIONAL,\r
-  IN EFI_MAC_ADDRESS                *McastFilter OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_SNP_PRIVATE_DATA    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
-\r
-  Status = Private->Io->ReceiveFilters (\r
-                          Private->Io,\r
-                          EnableBits,\r
-                          DisableBits,\r
-                          ResetMcastFilter,\r
-                          McastFilterCount,\r
-                          McastFilter\r
-                          );\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Modifies or resets the current station address, if supported.\r
-\r
-  @param  This         Protocol instance pointer.\r
-  @param  Reset        Flag used to reset the station address to the network interfaces\r
-                       permanent address.\r
-  @param  NewMacAddr   New station address to be used for the network interface.\r
-\r
-  @retval EFI_UNSUPPORTED       Not supported yet.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpStationAddress (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
-  IN BOOLEAN                        Reset,\r
-  IN EFI_MAC_ADDRESS                *NewMacAddr OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_SNP_PRIVATE_DATA    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
-\r
-  Status = Private->Io->StationAddress (Private->Io, Reset, NewMacAddr);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Resets or collects the statistics on a network interface.\r
-\r
-  @param  This            Protocol instance pointer.\r
-  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
-  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
-                          output the size, in bytes, of the resulting table of\r
-                          statistics.\r
-  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
-                          contains the statistics.\r
-\r
-  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
-                                size needed to hold the statistics is returned in\r
-                                StatisticsSize.\r
-  @retval EFI_UNSUPPORTED       Not supported yet.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpStatistics (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
-  IN BOOLEAN                        Reset,\r
-  IN OUT UINTN                      *StatisticsSize OPTIONAL,\r
-  OUT EFI_NETWORK_STATISTICS        *StatisticsTable OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_SNP_PRIVATE_DATA    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
-\r
-  Status = Private->Io->Statistics (Private->Io, Reset, StatisticsSize, StatisticsTable);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Converts a multicast IP address to a multicast HW MAC address.\r
-\r
-  @param  This Protocol instance pointer.\r
-  @param  Ipv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
-               to FALSE if the multicast IP address is IPv4 [RFC 791].\r
-  @param  Ip   The multicast IP address that is to be converted to a multicast\r
-               HW MAC address.\r
-  @param  Mac  The multicast HW MAC address that is to be generated from IP.\r
-\r
-  @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast\r
-                                HW MAC address.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
-                                size needed to hold the statistics is returned in\r
-                                StatisticsSize.\r
-  @retval EFI_UNSUPPORTED       Not supported yet.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpMcastIptoMac (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
-  IN BOOLEAN                        Ipv6,\r
-  IN EFI_IP_ADDRESS                 *Ip,\r
-  OUT EFI_MAC_ADDRESS               *Mac\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_SNP_PRIVATE_DATA    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
-\r
-  Status = Private->Io->MCastIpToMac (Private->Io, Ipv6, Ip, Mac);\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Performs read and write operations on the NVRAM device attached to a \r
-  network interface.\r
-\r
-  @param  This         Protocol instance pointer.\r
-  @param  ReadOrWrite  TRUE for read operations, FALSE for write operations.\r
-  @param  Offset       Byte offset in the NVRAM device at which to start the read or\r
-                       write operation. This must be a multiple of NvRamAccessSize and\r
-                       less than NvRamSize.\r
-  @param  BufferSize   The number of bytes to read or write from the NVRAM device.\r
-                       This must also be a multiple of NvramAccessSize.\r
-  @param  Buffer       A pointer to the data buffer.\r
-\r
-  @retval EFI_UNSUPPORTED       Not supported yet.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpNvdata (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
-  IN BOOLEAN                        ReadOrWrite,\r
-  IN UINTN                          Offset,\r
-  IN UINTN                          BufferSize,\r
-  IN OUT VOID                       *Buffer\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_SNP_PRIVATE_DATA    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
-\r
-  Status = Private->Io->NvData (Private->Io, ReadOrWrite, Offset, BufferSize, Buffer);\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Reads the current interrupt status and recycled transmit buffer status from \r
-  a network interface.\r
-\r
-  @param  This            Protocol instance pointer.\r
-  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
-                          If this is NULL, the interrupt status will not be read from\r
-                          the device. If this is not NULL, the interrupt status will\r
-                          be read from the device. When the  interrupt status is read,\r
-                          it will also be cleared. Clearing the transmit  interrupt\r
-                          does not empty the recycled transmit buffer array.\r
-  @param  TxBuffer        Recycled transmit buffer address. The network interface will\r
-                          not transmit if its internal recycled transmit buffer array\r
-                          is full. Reading the transmit buffer does not clear the\r
-                          transmit interrupt. If this is NULL, then the transmit buffer\r
-                          status will not be read. If there are no transmit buffers to\r
-                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
-\r
-  @retval EFI_SUCCESS           Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpGetStatus (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
-  OUT UINT32                        *InterruptStatus,\r
-  OUT VOID                          **TxBuffer\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_SNP_PRIVATE_DATA    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
-\r
-  Status = Private->Io->GetStatus (Private->Io, InterruptStatus, TxBuffer);\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Places a packet in the transmit queue of a network interface.\r
-\r
-  @param  This       Protocol instance pointer.\r
-  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
-                     the Transmit() function. If HeaderSize is non-zero, then it\r
-                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
-                     and Protocol parameters must not be NULL.\r
-  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
-                     data) to be transmitted through the network interface.\r
-  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
-                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
-                     then the media header in Buffer must already be filled in by the\r
-                     caller. If HeaderSize is non-zero, then the media header will be\r
-                     filled in by the Transmit() function.\r
-  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
-                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
-                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
-  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
-                     parameter is ignored.\r
-  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
-                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
-                     examples.\r
-\r
-  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpTransmit (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
-  IN UINTN                          HeaderSize,\r
-  IN UINTN                          BufferSize,\r
-  IN VOID*                          Buffer,\r
-  IN EFI_MAC_ADDRESS                *SrcAddr OPTIONAL,\r
-  IN EFI_MAC_ADDRESS                *DestAddr OPTIONAL,\r
-  IN UINT16                         *Protocol OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_SNP_PRIVATE_DATA    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
-\r
-  Status = Private->Io->Transmit (\r
-                          Private->Io,\r
-                          HeaderSize,\r
-                          BufferSize,\r
-                          Buffer,\r
-                          SrcAddr,\r
-                          DestAddr,\r
-                          Protocol\r
-                          );\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Receives a packet from a network interface.\r
-\r
-  @param  This             Protocol instance pointer.\r
-  @param  HeaderSize       The size, in bytes, of the media header received on the network\r
-                           interface. If this parameter is NULL, then the media header size\r
-                           will not be returned.\r
-  @param  BuffSize         On entry, the size, in bytes, of Buffer. On exit, the size, in\r
-                           bytes, of the packet that was received on the network interface.\r
-  @param  Buffer           A pointer to the data buffer to receive both the media header and\r
-                           the data.\r
-  @param  SourceAddr       The source HW MAC address. If this parameter is NULL, the\r
-                           HW MAC source address will not be extracted from the media\r
-                           header.\r
-  @param  DestinationAddr  The destination HW MAC address. If this parameter is NULL,\r
-                           the HW MAC destination address will not be extracted from the\r
-                           media header.\r
-  @param  Protocol         The media header type. If this parameter is NULL, then the\r
-                           protocol will not be extracted from the media header. See\r
-                           RFC 1700 section "Ether Types" for examples.\r
-\r
-  @retval EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
-                                been updated to the number of bytes received.\r
-  @retval EFI_NOT_READY         The network interface is too busy to accept this transmit\r
-                                request.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpReceive (\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL    *This,\r
-  OUT UINTN                         *HeaderSize OPTIONAL,\r
-  IN OUT UINTN                      *BuffSize,\r
-  OUT VOID                          *Buffer,\r
-  OUT EFI_MAC_ADDRESS               *SourceAddr OPTIONAL,\r
-  OUT EFI_MAC_ADDRESS               *DestinationAddr OPTIONAL,\r
-  OUT UINT16                        *Protocol OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_SNP_PRIVATE_DATA    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);\r
-\r
-  Status = Private->Io->Receive (\r
-                          Private->Io,\r
-                          HeaderSize,\r
-                          BuffSize,\r
-                          Buffer,\r
-                          SourceAddr,\r
-                          DestinationAddr,\r
-                          Protocol\r
-                          );\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-/**\r
-  Test to see if this driver supports ControllerHandle. This service\r
-  is called by the EFI boot service ConnectController(). In\r
-  order to make drivers as small as possible, there are a few calling\r
-  restrictions for this service. ConnectController() must\r
-  follow these calling restrictions. If any other agent wishes to call\r
-  Supported() it must also follow these calling restrictions.\r
-\r
-  @param  This                Protocol instance pointer.\r
-  @param  ControllerHandle    Handle of device to test\r
-  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
-                              device to start.\r
-\r
-  @retval EFI_SUCCESS         This driver supports this device\r
-  @retval EFI_UNSUPPORTED     This driver does not support this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   ControllerHandle,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EMU_IO_THUNK_PROTOCOL     *EmuIoThunk;\r
-  MAC_ADDR_DEVICE_PATH      *Node;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;\r
-\r
-  if (RemainingDevicePath != NULL) {\r
-    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
-      Node = (MAC_ADDR_DEVICE_PATH *)RemainingDevicePath;\r
-      if (Node->Header.Type != MESSAGING_DEVICE_PATH ||\r
-          Node->Header.SubType != MSG_MAC_ADDR_DP) {\r
-        // If the remaining device path does not match we don't support the request\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-    }\r
-  }\r
-  \r
-  \r
-  //\r
-  // Open the IO Abstraction(s) needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (VOID **)&EmuIoThunk,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Make sure GUID is for a File System handle.\r
-  //\r
-  Status = EFI_UNSUPPORTED;\r
-  if (CompareGuid (EmuIoThunk->Protocol, &gEmuSnpProtocolGuid)) {\r
-    Status = EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
-  //\r
-  gBS->CloseProtocol (\r
-        ControllerHandle,\r
-        &gEmuIoThunkProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        ControllerHandle\r
-        );\r
-        \r
-        \r
-  //\r
-  // Open the EFI Device Path protocol needed to perform the supported test\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (Status == EFI_ALREADY_STARTED) {\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Close protocol, don't use device path protocol in the Support() function\r
-  //\r
-  gBS->CloseProtocol (\r
-        ControllerHandle,\r
-        &gEfiDevicePathProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        ControllerHandle\r
-        );\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Start this driver on ControllerHandle. This service is called by the\r
-  EFI boot service ConnectController(). In order to make\r
-  drivers as small as possible, there are a few calling restrictions for\r
-  this service. ConnectController() must follow these\r
-  calling restrictions. If any other agent wishes to call Start() it\r
-  must also follow these calling restrictions.\r
-\r
-  @param  This                 Protocol instance pointer.\r
-  @param  ControllerHandle     Handle of device to bind driver to\r
-  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
-                               device to start.\r
-\r
-  @retval EFI_SUCCESS          Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN EFI_HANDLE                   ControllerHandle,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EMU_IO_THUNK_PROTOCOL       *EmuIoThunk;\r
-  EMU_SNP_PRIVATE_DATA        *Private;\r
-  MAC_ADDR_DEVICE_PATH        Node;\r
-  EFI_DEVICE_PATH_PROTOCOL    *ParentDevicePath;\r
-\r
-  Private = NULL;\r
-\r
-  //\r
-  // Grab the protocols we need\r
-  //\r
-  Status = gBS->OpenProtocol(\r
-                  ControllerHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  ( VOID ** ) &ParentDevicePath,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status) && Status) {\r
-    return Status;\r
-  }\r
-\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (VOID **)&EmuIoThunk,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_DRIVER\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if (!CompareGuid (EmuIoThunk->Protocol, &gEmuSnpProtocolGuid)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Status = EmuIoThunk->Open (EmuIoThunk);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  //  Allocate the private data.\r
-  //\r
-  Private = AllocateZeroPool (sizeof (EMU_SNP_PRIVATE_DATA));\r
-  if (Private == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
-  CopyMem (&Private->Snp, &gEmuSnpTemplate, sizeof (EFI_SIMPLE_NETWORK_PROTOCOL));\r
-\r
-  Private->Signature    = EMU_SNP_PRIVATE_DATA_SIGNATURE;\r
-  Private->IoThunk      = EmuIoThunk;\r
-  Private->Io           = EmuIoThunk->Interface;\r
-  Private->EfiHandle    = ControllerHandle;\r
-  Private->DeviceHandle = NULL;\r
-  Private->Snp.Mode     = &Private->Mode;\r
-  Private->ControllerNameTable = NULL;\r
-\r
-  \r
-  Status = Private->Io->CreateMapping (Private->Io, &Private->Mode);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Build the device path by appending the MAC node to the ParentDevicePath\r
-  // from the EmuIo handle.\r
-  //\r
-  ZeroMem (&Node, sizeof (MAC_ADDR_DEVICE_PATH));\r
-\r
-  Node.Header.Type     = MESSAGING_DEVICE_PATH;\r
-  Node.Header.SubType  = MSG_MAC_ADDR_DP;\r
-  Node.IfType          = Private->Mode.IfType;\r
-\r
-  SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL * )&Node, sizeof (MAC_ADDR_DEVICE_PATH));\r
-\r
-  CopyMem (&Node.MacAddress, &Private->Mode.CurrentAddress, sizeof (EFI_MAC_ADDRESS));\r
-\r
-  //\r
-  // Build the device path by appending the MAC node to the ParentDevicePath from the EmuIo handle.\r
-  //\r
-  Private->DevicePath = AppendDevicePathNode (ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&Node);\r
-  if ( Private->DevicePath == NULL ) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
-  AddUnicodeString2 (\r
-    "eng",\r
-    gEmuSnpDriverComponentName.SupportedLanguages,\r
-    &Private->ControllerNameTable,\r
-    EmuIoThunk->ConfigString,\r
-    TRUE\r
-    );\r
-    \r
-  AddUnicodeString2 (\r
-    "en",\r
-    gEmuSnpDriverComponentName2.SupportedLanguages,\r
-    &Private->ControllerNameTable,\r
-    EmuIoThunk->ConfigString,\r
-    FALSE\r
-    );\r
-\r
-  //\r
-  // Create Child Handle\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces(\r
-                  &Private->DeviceHandle,\r
-                  &gEfiSimpleNetworkProtocolGuid, &Private->Snp,\r
-                  &gEfiDevicePathProtocolGuid,    Private->DevicePath,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // Open For Child Device\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  (VOID **)&EmuIoThunk,\r
-                  This->DriverBindingHandle,\r
-                  Private->DeviceHandle,\r
-                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
-                  );\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-    if (Private != NULL) {\r
-      FreePool (Private);\r
-    }\r
-    if (ParentDevicePath != NULL) {\r
-      gBS->CloseProtocol(\r
-            ControllerHandle,\r
-            &gEfiDevicePathProtocolGuid,\r
-            This->DriverBindingHandle,\r
-            ControllerHandle\r
-            );\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Stop this driver on ControllerHandle. This service is called by the\r
-  EFI boot service DisconnectController(). In order to\r
-  make drivers as small as possible, there are a few calling\r
-  restrictions for this service. DisconnectController()\r
-  must follow these calling restrictions. If any other agent wishes\r
-  to call Stop() it must also follow these calling restrictions.\r
-  \r
-  @param  This              Protocol instance pointer.\r
-  @param  ControllerHandle  Handle of device to stop driver on\r
-  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
-                            children is zero stop the entire bus driver.\r
-  @param  ChildHandleBuffer List of Child Handles to Stop.\r
-\r
-  @retval EFI_SUCCESS       Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpDriverBindingStop (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL    *This,\r
-  IN EFI_HANDLE                     ControllerHandle,\r
-  IN UINTN                          NumberOfChildren,\r
-  IN EFI_HANDLE                     *ChildHandleBuffer\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EMU_SNP_PRIVATE_DATA        *Private = NULL;\r
-  EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
-\r
-  //\r
-  // Complete all outstanding transactions to Controller.\r
-  // Don't allow any new transaction to Controller to be started.\r
-  //\r
-  if (NumberOfChildren == 0) {\r
-    //\r
-    // Close the bus driver\r
-    //\r
-    Status = gBS->CloseProtocol (\r
-                    ControllerHandle,\r
-                    &gEmuIoThunkProtocolGuid,\r
-                    This->DriverBindingHandle,\r
-                    ControllerHandle\r
-                    );\r
-\r
-    Status = gBS->CloseProtocol (\r
-                    ControllerHandle,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    This->DriverBindingHandle,\r
-                    ControllerHandle\r
-                    );\r
-    return Status;\r
-  }\r
-\r
-  ASSERT (NumberOfChildren == 1);\r
-  \r
-  \r
-  //\r
-  // Get our context back.\r
-  //\r
-  Status = gBS->OpenProtocol(\r
-                  ChildHandleBuffer[0],\r
-                  &gEfiSimpleNetworkProtocolGuid,\r
-                  ( VOID ** ) &Snp,\r
-                  This->DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (Snp);\r
-  Status = Private->IoThunk->Close (Private->IoThunk);\r
-\r
-  Status = gBS->CloseProtocol(\r
-                  ChildHandleBuffer[0],\r
-                  &gEmuIoThunkProtocolGuid,\r
-                  This->DriverBindingHandle,\r
-                  Private->DeviceHandle\r
-                  );\r
-\r
-  Status = gBS->UninstallMultipleProtocolInterfaces(\r
-                  ChildHandleBuffer[0],\r
-                  &gEfiSimpleNetworkProtocolGuid,   &Private->Snp,\r
-                  &gEfiDevicePathProtocolGuid,      Private->DevicePath,\r
-                  NULL\r
-                  );\r
-\r
-  FreePool (Private->DevicePath);\r
-  FreeUnicodeStringTable (Private->ControllerNameTable);\r
-  FreePool (Private);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-EFI_DRIVER_BINDING_PROTOCOL gEmuSnpDriverBinding = {\r
-  EmuSnpDriverBindingSupported,\r
-  EmuSnpDriverBindingStart,\r
-  EmuSnpDriverBindingStop,\r
-  0xA,\r
-  NULL,\r
-  NULL\r
-};\r
-\r
-\r
-\r
-/**\r
-  This is the declaration of an EFI image entry point. This entry point is\r
-  the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including\r
-  both device drivers and bus drivers.\r
-\r
-  @param  ImageHandle           The firmware allocated handle for the UEFI image.\r
-  @param  SystemTable           A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS           The operation completed successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeEmuSnpDriver (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-\r
-  //\r
-  // Install the Driver Protocols\r
-  //\r
-\r
-  Status = EfiLibInstallDriverBindingComponentName2(\r
-              ImageHandle,\r
-              SystemTable,\r
-              &gEmuSnpDriverBinding,\r
-              ImageHandle,\r
-              &gEmuSnpDriverComponentName,\r
-              &gEmuSnpDriverComponentName2\r
-              );\r
-\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.h b/InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.h
deleted file mode 100644 (file)
index 21bfc42..0000000
+++ /dev/null
@@ -1,488 +0,0 @@
-/** @file\r
-\r
- Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
-\r
-    This program and the accompanying materials\r
-    are licensed and made available under the terms and conditions of the BSD License\r
-    which accompanies this distribution. The full text of the license may be found at\r
-    http://opensource.org/licenses/bsd-license.php\r
-\r
-    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  EmuSnp.h\r
-\r
-Abstract:\r
-\r
--**/\r
-\r
-#ifndef _EMU_SNP_H_\r
-#define _EMU_SNP_H_\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/SimpleNetwork.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/EmuIoThunk.h>\r
-#include <Protocol/EmuSnp.h>\r
-\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/NetLib.h>\r
-\r
-#define NET_ETHER_HEADER_SIZE     14\r
-\r
-//\r
-//  Private data for driver.\r
-//\r
-#define EMU_SNP_PRIVATE_DATA_SIGNATURE SIGNATURE_32( 'U', 'S', 'N', 'P' )\r
-\r
-typedef struct {\r
-  UINTN                       Signature;\r
-  EMU_IO_THUNK_PROTOCOL       *IoThunk;\r
-  EMU_SNP_PROTOCOL            *Io;\r
-  EFI_DEVICE_PATH_PROTOCOL    *DevicePath;\r
-\r
-  EFI_HANDLE                  EfiHandle;\r
-  EFI_HANDLE                  DeviceHandle;\r
-\r
-  EFI_SIMPLE_NETWORK_PROTOCOL Snp;\r
-  EFI_SIMPLE_NETWORK_MODE     Mode;\r
-  \r
-  EFI_UNICODE_STRING_TABLE    *ControllerNameTable;\r
-\r
-} EMU_SNP_PRIVATE_DATA;\r
-\r
-#define EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS(a) \\r
-      CR( a, EMU_SNP_PRIVATE_DATA, Snp, EMU_SNP_PRIVATE_DATA_SIGNATURE )\r
-\r
-extern EFI_DRIVER_BINDING_PROTOCOL    gEmuSnpDriverBinding;\r
-extern EFI_COMPONENT_NAME_PROTOCOL    gEmuSnpDriverComponentName;\r
-extern EFI_COMPONENT_NAME2_PROTOCOL   gEmuSnpDriverComponentName2;\r
-\r
-/**\r
-  Test to see if this driver supports ControllerHandle. This service\r
-  is called by the EFI boot service ConnectController(). In\r
-  order to make drivers as small as possible, there are a few calling\r
-  restrictions for this service. ConnectController() must\r
-  follow these calling restrictions. If any other agent wishes to call\r
-  Supported() it must also follow these calling restrictions.\r
-\r
-  @param  This                Protocol instance pointer.\r
-  @param  ControllerHandle    Handle of device to test\r
-  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
-                              device to start.\r
-\r
-  @retval EFI_SUCCESS         This driver supports this device\r
-  @retval EFI_UNSUPPORTED     This driver does not support this device\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpDriverBindingSupported (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  * This,\r
-  IN EFI_HANDLE                   ControllerHandle,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     * RemainingDevicePath OPTIONAL\r
-  );\r
-\r
-/**\r
-  Start this driver on ControllerHandle. This service is called by the\r
-  EFI boot service ConnectController(). In order to make\r
-  drivers as small as possible, there are a few calling restrictions for\r
-  this service. ConnectController() must follow these\r
-  calling restrictions. If any other agent wishes to call Start() it\r
-  must also follow these calling restrictions.\r
-\r
-  @param  This                 Protocol instance pointer.\r
-  @param  ControllerHandle     Handle of device to bind driver to\r
-  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
-                               device to start.\r
-\r
-  @retval EFI_SUCCESS          Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpDriverBindingStart (\r
-  IN EFI_DRIVER_BINDING_PROTOCOL  * This,\r
-  IN EFI_HANDLE                   ControllerHandle,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     * RemainingDevicePath OPTIONAL\r
-  );\r
-\r
-/**\r
-  Stop this driver on ControllerHandle. This service is called by the\r
-  EFI boot service DisconnectController(). In order to\r
-  make drivers as small as possible, there are a few calling\r
-  restrictions for this service. DisconnectController()\r
-  must follow these calling restrictions. If any other agent wishes\r
-  to call Stop() it must also follow these calling restrictions.\r
-  \r
-  @param  This              Protocol instance pointer.\r
-  @param  ControllerHandle  Handle of device to stop driver on\r
-  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
-                            children is zero stop the entire bus driver.\r
-  @param  ChildHandleBuffer List of Child Handles to Stop.\r
-\r
-  @retval EFI_SUCCESS       Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpDriverBindingStop (\r
-  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
-  IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  UINTN                        NumberOfChildren,\r
-  IN  EFI_HANDLE                   *ChildHandleBuffer\r
-  );\r
-\r
-/**\r
-  Changes the state of a network interface from "stopped" to "started".\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpStart(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This\r
-  );\r
-  \r
-/**\r
-  Changes the state of a network interface from "started" to "stopped".\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpStop(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This\r
-  );\r
-  \r
-/**\r
-  Resets a network adapter and allocates the transmit and receive buffers \r
-  required by the network interface; optionally, also requests allocation \r
-  of additional transmit and receive buffers.\r
-\r
-  @param  This              Protocol instance pointer.\r
-  @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
-                            that the driver should allocate for the network interface.\r
-                            Some network interfaces will not be able to use the extra\r
-                            buffer, and the caller will not know if it is actually\r
-                            being used.\r
-  @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
-                            that the driver should allocate for the network interface.\r
-                            Some network interfaces will not be able to use the extra\r
-                            buffer, and the caller will not know if it is actually\r
-                            being used.\r
-\r
-  @retval EFI_SUCCESS           Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpInitialize(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
-  IN UINTN              ExtraRxBufferSize OPTIONAL,\r
-  IN UINTN              ExtraTxBufferSize OPTIONAL\r
-  );\r
-  \r
-/**\r
-  Resets a network adapter and re-initializes it with the parameters that were \r
-  provided in the previous call to Initialize().  \r
-\r
-  @param  This                 Protocol instance pointer.\r
-  @param  ExtendedVerification Indicates that the driver may perform a more\r
-                               exhaustive verification operation of the device\r
-                               during reset.\r
-\r
-  @retval EFI_SUCCESS           Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpReset(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
-  IN BOOLEAN              ExtendedVerification\r
-  );\r
-\r
-/**\r
-  Resets a network adapter and leaves it in a state that is safe for \r
-  another driver to initialize.\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpShutdown(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This\r
-  );\r
-\r
-/**\r
-  Manages the multicast receive filters of a network interface.\r
-\r
-  @param  This               Protocol instance pointer.\r
-  @param  EnableBits         A bit mask of receive filters to enable on the network interface.\r
-  @param  DisableBits        A bit mask of receive filters to disable on the network interface.\r
-  @param  ResetMcastFilter   Set to TRUE to reset the contents of the multicast receive\r
-                             filters on the network interface to their default values.\r
-  @param  McastFilterCount   Number of multicast HW MAC addresses in the new\r
-                             MCastFilter list. This value must be less than or equal to\r
-                             the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This\r
-                             field is optional if ResetMCastFilter is TRUE.\r
-  @param  McastFilter        A pointer to a list of new multicast receive filter HW MAC\r
-                             addresses. This list will replace any existing multicast\r
-                             HW MAC address list. This field is optional if\r
-                             ResetMCastFilter is TRUE.\r
-\r
-  @retval EFI_SUCCESS           The multicast receive filter list was updated.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpReceiveFilters(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
-  IN UINT32              EnableBits,\r
-  IN UINT32              DisableBits,\r
-  IN BOOLEAN              ResetMcastFilter,\r
-  IN UINTN              McastFilterCount OPTIONAL,\r
-  IN EFI_MAC_ADDRESS*          McastFilter OPTIONAL\r
-  );\r
-\r
-/**\r
-  Modifies or resets the current station address, if supported.\r
-\r
-  @param  This         Protocol instance pointer.\r
-  @param  Reset        Flag used to reset the station address to the network interfaces\r
-                       permanent address.\r
-  @param  NewMacAddr   New station address to be used for the network interface.\r
-\r
-  @retval EFI_UNSUPPORTED       Not supported yet.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpStationAddress(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
-  IN BOOLEAN              Reset,\r
-  IN EFI_MAC_ADDRESS*          NewMacAddr OPTIONAL\r
-  );\r
-\r
-/**\r
-  Resets or collects the statistics on a network interface.\r
-\r
-  @param  This            Protocol instance pointer.\r
-  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
-  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
-                          output the size, in bytes, of the resulting table of\r
-                          statistics.\r
-  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
-                          contains the statistics.\r
-\r
-  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
-                                size needed to hold the statistics is returned in\r
-                                StatisticsSize.\r
-  @retval EFI_UNSUPPORTED       Not supported yet.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpStatistics(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
-  IN BOOLEAN              Reset,\r
-  IN OUT UINTN*            StatisticsSize OPTIONAL,\r
-  OUT EFI_NETWORK_STATISTICS*      StatisticsTable OPTIONAL\r
-  );\r
-  \r
-/**\r
-  Converts a multicast IP address to a multicast HW MAC address.\r
-  \r
-  @param  This  Protocol instance pointer.\r
-  @param  Ipv6  Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
-                to FALSE if the multicast IP address is IPv4 [RFC 791].\r
-  @param  Ip    The multicast IP address that is to be converted to a multicast\r
-                HW MAC address.\r
-  @param  Mac   The multicast HW MAC address that is to be generated from IP.\r
-\r
-  @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast\r
-                                HW MAC address.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
-                                size needed to hold the statistics is returned in\r
-                                StatisticsSize.\r
-  @retval EFI_UNSUPPORTED       Not supported yet.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpMcastIptoMac(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
-  IN BOOLEAN              Ipv6,\r
-  IN EFI_IP_ADDRESS*          Ip,\r
-  OUT EFI_MAC_ADDRESS*        Mac\r
-  );\r
-\r
-/**\r
-  Performs read and write operations on the NVRAM device attached to a \r
-  network interface.\r
-\r
-  @param  This         Protocol instance pointer.\r
-  @param  ReadOrWrite  TRUE for read operations, FALSE for write operations.\r
-  @param  Offset       Byte offset in the NVRAM device at which to start the read or\r
-                       write operation. This must be a multiple of NvRamAccessSize and\r
-                       less than NvRamSize.\r
-  @param  BufferSize   The number of bytes to read or write from the NVRAM device.\r
-                       This must also be a multiple of NvramAccessSize.\r
-  @param  Buffer       A pointer to the data buffer.\r
-\r
-  @retval EFI_UNSUPPORTED       Not supported yet.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpNvdata(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
-  IN BOOLEAN              ReadOrWrite,\r
-  IN UINTN              Offset,\r
-  IN UINTN              BufferSize,\r
-  IN OUT VOID*            Buffer\r
-  );\r
-\r
-/**\r
-  Reads the current interrupt status and recycled transmit buffer status from \r
-  a network interface.\r
-\r
-  @param  This            Protocol instance pointer.\r
-  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
-                          If this is NULL, the interrupt status will not be read from\r
-                          the device. If this is not NULL, the interrupt status will\r
-                          be read from the device. When the  interrupt status is read,\r
-                          it will also be cleared. Clearing the transmit  interrupt\r
-                          does not empty the recycled transmit buffer array.\r
-  @param  TxBuffer        Recycled transmit buffer address. The network interface will\r
-                          not transmit if its internal recycled transmit buffer array\r
-                          is full. Reading the transmit buffer does not clear the\r
-                          transmit interrupt. If this is NULL, then the transmit buffer\r
-                          status will not be read. If there are no transmit buffers to\r
-                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
-\r
-  @retval EFI_SUCCESS           Always succeeds.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpGetStatus(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
-  OUT UINT32*              InterruptStatus,\r
-  OUT VOID**              TxBuffer\r
-  );\r
-\r
-/**\r
-  Places a packet in the transmit queue of a network interface.\r
-\r
-  @param  This       Protocol instance pointer.\r
-  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
-                     the Transmit() function. If HeaderSize is non-zero, then it\r
-                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
-                     and Protocol parameters must not be NULL.\r
-  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
-                     data) to be transmitted through the network interface.\r
-  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
-                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
-                     then the media header in Buffer must already be filled in by the\r
-                     caller. If HeaderSize is non-zero, then the media header will be\r
-                     filled in by the Transmit() function.\r
-  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
-                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
-                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
-  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
-                     parameter is ignored.\r
-  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
-                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
-                     examples.\r
-\r
-  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_ACCESS_DENIED     Error acquire global lock for operation.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpTransmit(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
-  IN UINTN              HeaderSize,\r
-  IN UINTN              BufferSize,\r
-  IN VOID*              Buffer,\r
-  IN EFI_MAC_ADDRESS*          SrcAddr OPTIONAL,\r
-  IN EFI_MAC_ADDRESS*          DestAddr OPTIONAL,\r
-  IN UINT16*              Protocol OPTIONAL\r
-  );\r
-\r
-/**\r
-  Receives a packet from a network interface.\r
-\r
-  @param  This             Protocol instance pointer.\r
-  @param  HeaderSize       The size, in bytes, of the media header received on the network\r
-                           interface. If this parameter is NULL, then the media header size\r
-                           will not be returned.\r
-  @param  BuffSize         On entry, the size, in bytes, of Buffer. On exit, the size, in\r
-                           bytes, of the packet that was received on the network interface.\r
-  @param  Buffer           A pointer to the data buffer to receive both the media header and\r
-                           the data.\r
-  @param  SourceAddr       The source HW MAC address. If this parameter is NULL, the\r
-                           HW MAC source address will not be extracted from the media\r
-                           header.\r
-  @param  DestinationAddr  The destination HW MAC address. If this parameter is NULL,\r
-                           the HW MAC destination address will not be extracted from the\r
-                           media header.\r
-  @param  Protocol         The media header type. If this parameter is NULL, then the\r
-                           protocol will not be extracted from the media header. See\r
-                           RFC 1700 section "Ether Types" for examples.\r
-\r
-  @retval  EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
-                                 been updated to the number of bytes received.\r
-  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
-                                 request.\r
-  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval  EFI_ACCESS_DENIED     Error acquire global lock for operation.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSnpReceive(\r
-  IN EFI_SIMPLE_NETWORK_PROTOCOL*    This,\r
-  OUT UINTN*              HeaderSize OPTIONAL,\r
-  IN OUT UINTN*            BuffSize,\r
-  OUT VOID*              Buffer,\r
-  OUT EFI_MAC_ADDRESS*        SourceAddr OPTIONAL,\r
-  OUT EFI_MAC_ADDRESS*        DestinationAddr OPTIONAL,\r
-  OUT UINT16*              Protocol OPTIONAL\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-EmuSnpWaitForPacketNotify(\r
-  IN EFI_EVENT            Event,\r
-  IN VOID*              Private\r
-  );\r
-\r
-#endif  // _EMU_SNP_H_\r
diff --git a/InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf b/InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf
deleted file mode 100644 (file)
index a9e9230..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#/** @file\r
-# Component name for module EmuSnpDxe\r
-#\r
-# Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>\r
-#\r
-#    This program and the accompanying materials\r
-#    are licensed and made available under the terms and conditions of the BSD License\r
-#    which accompanies this distribution. The full text of the license may be found at\r
-#    http://opensource.org/licenses/bsd-license.php\r
-#\r
-#    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#**/\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuSnpDxe\r
-  FILE_GUID                      = 22597239-6107-DF44-AD3F-5F053E92222E\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  EDK_RELEASE_VERSION            = 0x00020000\r
-  EFI_SPECIFICATION_VERSION      = 0x00020000\r
-\r
-  ENTRY_POINT                    = InitializeEmuSnpDriver\r
-#  UNLOAD_IMAGE                   = EmuSnpUnload\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
-  ComponentName.c\r
-  EmuSnpDxe.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  DevicePathLib\r
-  UefiLib\r
-  UefiBootServicesTableLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-  UefiDriverEntryPoint\r
-  NetLib\r
-\r
-[Protocols]\r
-  gEfiSimpleNetworkProtocolGuid                 # PROTOCOL ALWAYS_CONSUMED\r
-  gEfiDevicePathProtocolGuid                    # PROTOCOL ALWAYS_CONSUMED\r
-  gEmuSnpProtocolGuid\r
-  gEmuIoThunkProtocolGuid\r
-\r
-\r
diff --git a/InOsEmuPkg/EmuThunkDxe/EmuThunk.c b/InOsEmuPkg/EmuThunkDxe/EmuThunk.c
deleted file mode 100644 (file)
index a0661c8..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-\r
-**/\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/EmuThunk.h> \r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/EmuThunkLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-//\r
-// EmuThunk Device Path Protocol Instance\r
-//\r
-EMU_THUNK_DEVICE_PATH mEmuThunkDevicePath = {\r
-  {\r
-    {\r
-      {\r
-        HARDWARE_DEVICE_PATH,\r
-        HW_VENDOR_DP,\r
-        {\r
-          (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),\r
-          (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
-        }\r
-      },\r
-      EMU_THUNK_PROTOCOL_GUID\r
-    },\r
-    0\r
-  },\r
-  {\r
-    END_DEVICE_PATH_TYPE,\r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    {\r
-      END_DEVICE_PATH_LENGTH,\r
-      0\r
-    }\r
-  }\r
-};\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeEmuThunk (\r
-  IN EFI_HANDLE                            ImageHandle,\r
-  IN EFI_SYSTEM_TABLE                      *SystemTable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Install UnixThunk Protocol and it's associated Device Path protocol\r
-\r
-Arguments:\r
-  (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r
-\r
-Returns:\r
-  EFI_SUCEESS - UnixThunk protocol is added or error status from \r
-                gBS->InstallMultiProtocolInterfaces().\r
-\r
-**/\r
-{\r
-  EFI_STATUS  Status;\r
-  EFI_HANDLE  Handle;\r
-\r
-  Handle = NULL;\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Handle,\r
-                  &gEmuThunkProtocolGuid,       gEmuThunk,\r
-                  &gEfiDevicePathProtocolGuid,  &mEmuThunkDevicePath,\r
-                  NULL\r
-                  );\r
-\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/EmuThunkDxe/EmuThunk.inf b/InOsEmuPkg/EmuThunkDxe/EmuThunk.inf
deleted file mode 100644 (file)
index 314a6f3..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-## @file\r
-#   A DXE driver to produce EMU_THUNK_PROTOCOL\r
-#\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuThunk\r
-  FILE_GUID                      = 2F62A818-4A72-CD40-90B9-FF00DAABEE7B\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = InitializeEmuThunk\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  EmuThunk.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  EmuThunkLib\r
-  UefiDriverEntryPoint\r
-  UefiLib\r
-  DebugLib\r
-  DevicePathLib\r
-\r
-\r
-\r
-[Protocols]\r
-  gEfiDevicePathProtocolGuid                # PROTOCOL ALWAYS_PRODUCED\r
-  gEmuThunkProtocolGuid                     # PROTOCOL ALWAYS_PRODUCED\r
-\r
-\r
-[Depex]\r
-  TRUE\r
-\r
diff --git a/InOsEmuPkg/FirmwareVolumePei/FirmwareVolumePei.c b/InOsEmuPkg/FirmwareVolumePei/FirmwareVolumePei.c
deleted file mode 100644 (file)
index ec9fe5c..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#include "PiPei.h"\r
-#include <Ppi/EmuThunk.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/PeimEntryPoint.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/PeiServicesTablePointerLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PeimInitializeFirmwareVolumePei (\r
-  IN       EFI_PEI_FILE_HANDLE       FileHandle,\r
-  IN CONST EFI_PEI_SERVICES          **PeiServices\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Perform a call-back into the SEC simulator to get address of the Firmware Hub\r
-\r
-Arguments:\r
-  FfsHeader   - Ffs Header availible to every PEIM\r
-  PeiServices - General purpose services available to every PEIM.\r
-    \r
-Returns:\r
-  None\r
-\r
-**/\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_PEI_PPI_DESCRIPTOR      *PpiDescriptor;\r
-  EMU_THUNK_PPI               *Thunk;\r
-  EFI_PHYSICAL_ADDRESS        FdBase;\r
-  EFI_PHYSICAL_ADDRESS        FdFixUp;\r
-  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
-  UINT64                      FdSize;\r
-  UINTN                       Index;\r
-\r
-  DEBUG ((EFI_D_ERROR, "Unix Firmware Volume PEIM Loaded\n"));\r
-\r
-  //\r
-  // Get the Fwh Information PPI\r
-  //\r
-  Status = PeiServicesLocatePpi (\r
-              &gEmuThunkPpiGuid,  // GUID\r
-              0,                  // INSTANCE\r
-              &PpiDescriptor,     // EFI_PEI_PPI_DESCRIPTOR\r
-              (VOID **)&Thunk     // PPI\r
-              );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Index = 0;\r
-  do {\r
-    //\r
-    // Get information about all the FD's in the system\r
-    //\r
-    Status = Thunk->FirmwareDevices (Index, &FdBase, &FdSize, &FdFixUp);\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Assume the FD starts with an FV header\r
-      //\r
-      FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FdBase;\r
-\r
-      //\r
-      // Make an FV Hob for the first FV in the FD\r
-      //\r
-      BuildFvHob (FdBase, FvHeader->FvLength);\r
-\r
-      if (Index == 0) {\r
-        //\r
-        // Assume the first FD was produced by the NT32.DSC\r
-        //  All these strange offests are needed to keep in\r
-        //  sync with the FlashMap and NT32.dsc file\r
-        //\r
-        BuildResourceDescriptorHob (\r
-          EFI_RESOURCE_FIRMWARE_DEVICE,\r
-          (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
-          FdBase,\r
-          ( \r
-            FvHeader->FvLength + \r
-            PcdGet32 (PcdFlashNvStorageVariableSize) +\r
-            PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
-            PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
-            PcdGet32 (PcdEmuFlashNvStorageEventLogSize)\r
-          )\r
-        );\r
-\r
-        //\r
-        // Hard code the address of the spare block and variable services.\r
-        //  Assume it's a hard coded offset from FV0 in FD0.\r
-        //\r
-        FdSize  = \r
-          PcdGet32 (PcdFlashNvStorageVariableSize) +\r
-          PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +\r
-          PcdGet32 (PcdFlashNvStorageFtwSpareSize) +\r
-          PcdGet32 (PcdEmuFlashNvStorageEventLogSize);\r
-\r
-        BuildFvHob (FdFixUp + PcdGet64 (PcdEmuFlashNvStorageVariableBase), FdSize);\r
-      } else {\r
-        //\r
-        // For other FD's just map them in.\r
-        //\r
-        BuildResourceDescriptorHob (\r
-          EFI_RESOURCE_FIRMWARE_DEVICE,\r
-          (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE),\r
-          FdBase,\r
-          FdSize\r
-          );\r
-      }\r
-    }\r
-\r
-    Index++;\r
-  } while (!EFI_ERROR (Status));\r
-\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/FirmwareVolumePei/FirmwareVolumePei.inf b/InOsEmuPkg/FirmwareVolumePei/FirmwareVolumePei.inf
deleted file mode 100644 (file)
index 02a4474..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-## @file\r
-# Component description file for EmuFwh module\r
-#\r
-# This PEIM will produce the HOB to describe Firmware Volume, Firmware Devices\r
-#  on the Emu emulator.\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = FirmwareVolumePei\r
-  FILE_GUID                      = 6DB075DE-449E-2644-96D0-CC5A1B4C3B2A\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = PeimInitializeFirmwareVolumePei\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  FirmwareVolumePei.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  PeiServicesTablePointerLib\r
-  PeiServicesLib\r
-  HobLib\r
-  PeimEntryPoint\r
-  DebugLib\r
-\r
-[Pcd]\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogSize\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
-\r
-[Ppis]\r
-  gEmuThunkPpiGuid                               # PPI ALWAYS_CONSUMED\r
-\r
-[Depex]\r
-  gEmuThunkPpiGuid AND gEfiPeiMemoryDiscoveredPpiGuid\r
-\r
diff --git a/InOsEmuPkg/FlashMapPei/FlashMapPei.c b/InOsEmuPkg/FlashMapPei/FlashMapPei.c
deleted file mode 100644 (file)
index 955c462..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*++ @file\r
-  PEIM to build GUIDed HOBs for platform specific flash map\r
-\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-\r
-#include "PiPei.h"\r
-\r
-#include <Guid/SystemNvDataGuid.h>\r
-#include <Ppi/EmuThunk.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/PeimEntryPoint.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/PeiServicesTablePointerLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PeimInitializeFlashMap (\r
-  IN       EFI_PEI_FILE_HANDLE       FileHandle,\r
-  IN CONST EFI_PEI_SERVICES          **PeiServices\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Build GUIDed HOBs for platform specific flash map\r
-  \r
-Arguments:\r
-  FfsHeader   - A pointer to the EFI_FFS_FILE_HEADER structure.\r
-  PeiServices - General purpose services available to every PEIM.\r
-    \r
-Returns:\r
-  EFI_STATUS\r
-\r
-**/\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_THUNK_PPI           *Thunk;\r
-  EFI_PEI_PPI_DESCRIPTOR  *PpiDescriptor;\r
-  EFI_PHYSICAL_ADDRESS    FdBase;\r
-  EFI_PHYSICAL_ADDRESS    FdFixUp;\r
-  UINT64                  FdSize;\r
-\r
-  DEBUG ((EFI_D_ERROR, "InOsEmuPkg Flash Map PEIM Loaded\n"));\r
-\r
-  //\r
-  // Get the Fwh Information PPI\r
-  //\r
-  Status = PeiServicesLocatePpi (\r
-            &gEmuThunkPpiGuid, // GUID\r
-            0,                 // INSTANCE\r
-            &PpiDescriptor,     // EFI_PEI_PPI_DESCRIPTOR\r
-            (VOID **)&Thunk       // PPI\r
-            );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Assume that FD0 contains the Flash map.\r
-  //\r
-  Status = Thunk->FirmwareDevices (0, &FdBase, &FdSize, &FdFixUp);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  \r
-  PcdSet64 (PcdFlashNvStorageVariableBase64, PcdGet64 (PcdEmuFlashNvStorageVariableBase) + FdFixUp);\r
-  PcdSet64 (PcdFlashNvStorageFtwWorkingBase64, PcdGet64 (PcdEmuFlashNvStorageFtwWorkingBase) + FdFixUp);\r
-  PcdSet64 (PcdFlashNvStorageFtwSpareBase64, PcdGet64 (PcdEmuFlashNvStorageFtwSpareBase) + FdFixUp);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/InOsEmuPkg/FlashMapPei/FlashMapPei.inf b/InOsEmuPkg/FlashMapPei/FlashMapPei.inf
deleted file mode 100644 (file)
index ed5bc3b..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-## @file\r
-# Component description file for FlashMap PEI module\r
-#\r
-# This module installs FlashMap PPI which is used to get flash layout information.\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = FlashMapPei\r
-  FILE_GUID                      = C9FAF091-57F8-A64C-A07A-445B124F0D93\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = PeimInitializeFlashMap\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  FlashMapPei.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  PcdLib\r
-  BaseMemoryLib\r
-  PeiServicesTablePointerLib\r
-  PeiServicesLib\r
-  HobLib\r
-  PeimEntryPoint\r
-  DebugLib\r
-\r
-\r
-[Ppis]\r
-  gEmuThunkPpiGuid                               # PPI ALWAYS_CONSUMED\r
-\r
-[Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64\r
-\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwWorkingBase\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase\r
-\r
-[Depex]\r
-  gEmuThunkPpiGuid\r
-\r
diff --git a/InOsEmuPkg/FvbServicesRuntimeDxe/FWBlockService.c b/InOsEmuPkg/FvbServicesRuntimeDxe/FWBlockService.c
deleted file mode 100644 (file)
index a95b180..0000000
+++ /dev/null
@@ -1,1360 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#include "PiDxe.h"\r
-#include <Guid/EventGroup.h>\r
-#include <Protocol/FirmwareVolumeBlock.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/UefiRuntimeLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-#include "FwBlockService.h"\r
-\r
-ESAL_FWB_GLOBAL         *mFvbModuleGlobal;\r
-\r
-#define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)\r
-\r
-EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {\r
-  FVB_DEVICE_SIGNATURE,\r
-  {\r
-    {\r
-      {\r
-        HARDWARE_DEVICE_PATH,\r
-        HW_MEMMAP_DP,\r
-        {\r
-          sizeof (MEMMAP_DEVICE_PATH),\r
-          0\r
-        }\r
-      },\r
-      EfiMemoryMappedIO,\r
-      0,\r
-      0,\r
-    },\r
-    {\r
-      END_DEVICE_PATH_TYPE,\r
-      END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-      {\r
-        sizeof (EFI_DEVICE_PATH_PROTOCOL),\r
-        0\r
-      }\r
-    }\r
-  },\r
-  0,\r
-  {\r
-    FvbProtocolGetAttributes,\r
-    FvbProtocolSetAttributes,\r
-    FvbProtocolGetPhysicalAddress,\r
-    FvbProtocolGetBlockSize,\r
-    FvbProtocolRead,\r
-    FvbProtocolWrite,\r
-    FvbProtocolEraseBlocks,\r
-    NULL\r
-  }\r
-};\r
-\r
-\r
-\r
-VOID\r
-EFIAPI\r
-FvbVirtualddressChangeEvent (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Fixup internal data so that EFI and SAL can be call in virtual mode.\r
-  Call the passed in Child Notify event and convert the mFvbModuleGlobal\r
-  date items to there virtual address.\r
-\r
-  mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]  - Physical copy of instance data\r
-  mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]   - Virtual pointer to common \r
-                                                instance data.\r
-\r
-Arguments:\r
-\r
-  (Standard EFI notify event - EFI_EVENT_NOTIFY)\r
-\r
-Returns: \r
-\r
-  None\r
-\r
-**/\r
-{\r
-  EFI_FW_VOL_INSTANCE *FwhInstance;\r
-  UINTN               Index;\r
-\r
-  EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]);\r
-\r
-  //\r
-  // Convert the base address of all the instances\r
-  //\r
-  Index       = 0;\r
-  FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL];\r
-  while (Index < mFvbModuleGlobal->NumFv) {\r
-    EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase[FVB_VIRTUAL]);\r
-    FwhInstance = (EFI_FW_VOL_INSTANCE *)\r
-      (\r
-        (UINTN) ((UINT8 *) FwhInstance) + FwhInstance->VolumeHeader.HeaderLength +\r
-          (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
-      );\r
-    Index++;\r
-  }\r
-\r
-  EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal);\r
-}\r
-\r
-EFI_STATUS\r
-GetFvbInstance (\r
-  IN  UINTN                               Instance,\r
-  IN  ESAL_FWB_GLOBAL                     *Global,\r
-  OUT EFI_FW_VOL_INSTANCE                 **FwhInstance,\r
-  IN BOOLEAN                              Virtual\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Retrieves the physical address of a memory mapped FV\r
-\r
-Arguments:\r
-  Instance              - The FV instance whose base address is going to be\r
-                          returned\r
-  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
-                          instance data\r
-  FwhInstance           - The EFI_FW_VOL_INSTANCE fimrware instance structure\r
-  Virtual               - Whether CPU is in virtual or physical mode\r
-\r
-Returns: \r
-  EFI_SUCCESS           - Successfully returns\r
-  EFI_INVALID_PARAMETER - Instance not found\r
-\r
-**/\r
-{\r
-  EFI_FW_VOL_INSTANCE *FwhRecord;\r
-\r
-  if (Instance >= Global->NumFv) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Find the right instance of the FVB private data\r
-  //\r
-  FwhRecord = Global->FvInstance[Virtual];\r
-  while (Instance > 0) {\r
-    FwhRecord = (EFI_FW_VOL_INSTANCE *)\r
-      (\r
-        (UINTN) ((UINT8 *) FwhRecord) + FwhRecord->VolumeHeader.HeaderLength +\r
-          (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
-      );\r
-    Instance--;\r
-  }\r
-\r
-  *FwhInstance = FwhRecord;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-FvbGetPhysicalAddress (\r
-  IN UINTN                                Instance,\r
-  OUT EFI_PHYSICAL_ADDRESS                *Address,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Retrieves the physical address of a memory mapped FV\r
-\r
-Arguments:\r
-  Instance              - The FV instance whose base address is going to be\r
-                          returned\r
-  Address               - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS \r
-                          that on successful return, contains the base address\r
-                          of the firmware volume. \r
-  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
-                          instance data\r
-  Virtual               - Whether CPU is in virtual or physical mode\r
-\r
-Returns: \r
-  EFI_SUCCESS           - Successfully returns\r
-  EFI_INVALID_PARAMETER - Instance not found\r
-\r
-**/\r
-{\r
-  EFI_FW_VOL_INSTANCE *FwhInstance = NULL;\r
-  EFI_STATUS          Status;\r
-\r
-  //\r
-  // Find the right instance of the FVB private data\r
-  //\r
-  Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);\r
-  ASSERT_EFI_ERROR (Status);\r
-  *Address = FwhInstance->FvBase[Virtual];\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-FvbGetVolumeAttributes (\r
-  IN UINTN                                Instance,\r
-  OUT EFI_FVB_ATTRIBUTES_2                *Attributes,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Retrieves attributes, insures positive polarity of attribute bits, returns\r
-  resulting attributes in output parameter\r
-\r
-Arguments:\r
-  Instance              - The FV instance whose attributes is going to be \r
-                          returned\r
-  Attributes            - Output buffer which contains attributes\r
-  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
-                          instance data\r
-  Virtual               - Whether CPU is in virtual or physical mode\r
-\r
-Returns: \r
-  EFI_SUCCESS           - Successfully returns\r
-  EFI_INVALID_PARAMETER - Instance not found\r
-\r
-**/\r
-{\r
-  EFI_FW_VOL_INSTANCE *FwhInstance = NULL;\r
-  EFI_STATUS          Status;\r
-\r
-  //\r
-  // Find the right instance of the FVB private data\r
-  //\r
-  Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);\r
-  ASSERT_EFI_ERROR (Status);\r
-  *Attributes = FwhInstance->VolumeHeader.Attributes;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-FvbGetLbaAddress (\r
-  IN  UINTN                               Instance,\r
-  IN  EFI_LBA                             Lba,\r
-  OUT UINTN                               *LbaAddress,\r
-  OUT UINTN                               *LbaLength,\r
-  OUT UINTN                               *NumOfBlocks,\r
-  IN  ESAL_FWB_GLOBAL                     *Global,\r
-  IN  BOOLEAN                             Virtual\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Retrieves the starting address of an LBA in an FV\r
-\r
-Arguments:\r
-  Instance              - The FV instance which the Lba belongs to\r
-  Lba                   - The logical block address\r
-  LbaAddress            - On output, contains the physical starting address \r
-                          of the Lba\r
-  LbaLength             - On output, contains the length of the block\r
-  NumOfBlocks           - A pointer to a caller allocated UINTN in which the\r
-                          number of consecutive blocks starting with Lba is\r
-                          returned. All blocks in this range have a size of\r
-                          BlockSize\r
-  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
-                          instance data\r
-  Virtual               - Whether CPU is in virtual or physical mode\r
-\r
-Returns: \r
-  EFI_SUCCESS           - Successfully returns\r
-  EFI_INVALID_PARAMETER - Instance not found\r
-\r
-**/\r
-{\r
-  UINT32                  NumBlocks;\r
-  UINT32                  BlockLength;\r
-  UINTN                   Offset;\r
-  EFI_LBA                 StartLba;\r
-  EFI_LBA                 NextLba;\r
-  EFI_FW_VOL_INSTANCE     *FwhInstance = NULL;\r
-  EFI_FV_BLOCK_MAP_ENTRY  *BlockMap;\r
-  EFI_STATUS              Status;\r
-\r
-  //\r
-  // Find the right instance of the FVB private data\r
-  //\r
-  Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  StartLba  = 0;\r
-  Offset    = 0;\r
-  BlockMap  = &(FwhInstance->VolumeHeader.BlockMap[0]);\r
-\r
-  //\r
-  // Parse the blockmap of the FV to find which map entry the Lba belongs to\r
-  //\r
-  while (TRUE) {\r
-    NumBlocks   = BlockMap->NumBlocks;\r
-    BlockLength = BlockMap->Length;\r
-\r
-    if (NumBlocks == 0 || BlockLength == 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    NextLba = StartLba + NumBlocks;\r
-\r
-    //\r
-    // The map entry found\r
-    //\r
-    if (Lba >= StartLba && Lba < NextLba) {\r
-      Offset = Offset + (UINTN) MultU64x32 ((Lba - StartLba), BlockLength);\r
-      if (LbaAddress != NULL) {\r
-        *LbaAddress = FwhInstance->FvBase[Virtual] + Offset;\r
-      }\r
-\r
-      if (LbaLength != NULL) {\r
-        *LbaLength = BlockLength;\r
-      }\r
-\r
-      if (NumOfBlocks != NULL) {\r
-        *NumOfBlocks = (UINTN) (NextLba - Lba);\r
-      }\r
-\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    StartLba  = NextLba;\r
-    Offset    = Offset + NumBlocks * BlockLength;\r
-    BlockMap++;\r
-  }\r
-}\r
-\r
-EFI_STATUS\r
-FvbReadBlock (\r
-  IN UINTN                                Instance,\r
-  IN EFI_LBA                              Lba,\r
-  IN UINTN                                BlockOffset,\r
-  IN OUT UINTN                            *NumBytes,\r
-  IN UINT8                                *Buffer,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Reads specified number of bytes into a buffer from the specified block\r
-\r
-Arguments:\r
-  Instance              - The FV instance to be read from\r
-  Lba                   - The logical block address to be read from\r
-  BlockOffset           - Offset into the block at which to begin reading\r
-  NumBytes              - Pointer that on input contains the total size of\r
-                          the buffer. On output, it contains the total number\r
-                          of bytes read\r
-  Buffer                - Pointer to a caller allocated buffer that will be\r
-                          used to hold the data read\r
-  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
-                          instance data\r
-  Virtual               - Whether CPU is in virtual or physical mode\r
-\r
-Returns: \r
-  EFI_SUCCESS           - The firmware volume was read successfully and \r
-                          contents are in Buffer\r
-  EFI_BAD_BUFFER_SIZE   - Read attempted across a LBA boundary. On output,\r
-                          NumBytes contains the total number of bytes returned\r
-                          in Buffer\r
-  EFI_ACCESS_DENIED     - The firmware volume is in the ReadDisabled state\r
-  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
-                          could not be read\r
-  EFI_INVALID_PARAMETER - Instance not found, or NumBytes, Buffer are NULL\r
-\r
-**/\r
-{\r
-  EFI_FVB_ATTRIBUTES_2  Attributes;\r
-  UINTN               LbaAddress;\r
-  UINTN               LbaLength;\r
-  EFI_STATUS          Status;\r
-\r
-  //\r
-  // Check for invalid conditions\r
-  //\r
-  if ((NumBytes == NULL) || (Buffer == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (*NumBytes == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL, Global, Virtual);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check if the FV is read enabled\r
-  //\r
-  FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual);\r
-\r
-  if ((Attributes & EFI_FVB2_READ_STATUS) == 0) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-  //\r
-  // Perform boundary checks and adjust NumBytes\r
-  //\r
-  if (BlockOffset > LbaLength) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (LbaLength < (*NumBytes + BlockOffset)) {\r
-    *NumBytes = (UINT32) (LbaLength - BlockOffset);\r
-    Status    = EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  CopyMem (Buffer, (UINT8 *) (LbaAddress + BlockOffset), (UINTN) (*NumBytes));\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-FvbWriteBlock (\r
-  IN UINTN                                Instance,\r
-  IN EFI_LBA                              Lba,\r
-  IN UINTN                                BlockOffset,\r
-  IN OUT UINTN                            *NumBytes,\r
-  IN UINT8                                *Buffer,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Writes specified number of bytes from the input buffer to the block\r
-\r
-Arguments:\r
-  Instance              - The FV instance to be written to\r
-  Lba                   - The starting logical block index to write to\r
-  BlockOffset           - Offset into the block at which to begin writing\r
-  NumBytes              - Pointer that on input contains the total size of\r
-                          the buffer. On output, it contains the total number\r
-                          of bytes actually written\r
-  Buffer                - Pointer to a caller allocated buffer that contains\r
-                          the source for the write\r
-  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
-                          instance data\r
-  Virtual               - Whether CPU is in virtual or physical mode\r
-\r
-Returns: \r
-  EFI_SUCCESS           - The firmware volume was written successfully\r
-  EFI_BAD_BUFFER_SIZE   - Write attempted across a LBA boundary. On output,\r
-                          NumBytes contains the total number of bytes\r
-                          actually written\r
-  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
-  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
-                          could not be written\r
-  EFI_INVALID_PARAMETER - Instance not found, or NumBytes, Buffer are NULL\r
-\r
-**/\r
-{\r
-  EFI_FVB_ATTRIBUTES_2  Attributes;\r
-  UINTN               LbaAddress;\r
-  UINTN               LbaLength;\r
-  EFI_STATUS          Status;\r
-\r
-  //\r
-  // Check for invalid conditions\r
-  //\r
-  if ((NumBytes == NULL) || (Buffer == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (*NumBytes == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL, Global, Virtual);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Check if the FV is write enabled\r
-  //\r
-  FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual);\r
-\r
-  if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-  //\r
-  // Perform boundary checks and adjust NumBytes\r
-  //\r
-  if (BlockOffset > LbaLength) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (LbaLength < (*NumBytes + BlockOffset)) {\r
-    *NumBytes = (UINT32) (LbaLength - BlockOffset);\r
-    Status    = EFI_BAD_BUFFER_SIZE;\r
-  }\r
-  //\r
-  // Write data\r
-  //\r
-  CopyMem ((UINT8 *) (LbaAddress + BlockOffset), Buffer, (UINTN) (*NumBytes));\r
-\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-FvbEraseBlock (\r
-  IN UINTN                                Instance,\r
-  IN EFI_LBA                              Lba,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Erases and initializes a firmware volume block\r
-\r
-Arguments:\r
-  Instance              - The FV instance to be erased\r
-  Lba                   - The logical block index to be erased\r
-  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
-                          instance data\r
-  Virtual               - Whether CPU is in virtual or physical mode\r
-\r
-Returns: \r
-  EFI_SUCCESS           - The erase request was successfully completed\r
-  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
-  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
-                          could not be written. Firmware device may have been\r
-                          partially erased\r
-  EFI_INVALID_PARAMETER - Instance not found\r
-\r
-**/\r
-{\r
-\r
-  EFI_FVB_ATTRIBUTES_2  Attributes;\r
-  UINTN                 LbaAddress;\r
-  UINTN                 LbaLength;\r
-  EFI_STATUS            Status;\r
-  UINT8                 Data;\r
-\r
-  //\r
-  // Check if the FV is write enabled\r
-  //\r
-  FvbGetVolumeAttributes (Instance, &Attributes, Global, Virtual);\r
-\r
-  if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-  //\r
-  // Get the starting address of the block for erase.\r
-  //\r
-  Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL, Global, Virtual);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if ((Attributes & EFI_FVB2_ERASE_POLARITY) != 0) {\r
-    Data = 0xFF;\r
-  } else {\r
-    Data = 0x0;\r
-  }\r
-\r
-  SetMem ((UINT8 *) LbaAddress, LbaLength, Data);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-FvbSetVolumeAttributes (\r
-  IN UINTN                                Instance,\r
-  IN OUT EFI_FVB_ATTRIBUTES_2             *Attributes,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Modifies the current settings of the firmware volume according to the \r
-  input parameter, and returns the new setting of the volume\r
-\r
-Arguments:\r
-  Instance              - The FV instance whose attributes is going to be \r
-                          modified\r
-  Attributes            - On input, it is a pointer to EFI_FVB_ATTRIBUTES_2 \r
-                          containing the desired firmware volume settings.\r
-                          On successful return, it contains the new settings\r
-                          of the firmware volume\r
-  Global                - Pointer to ESAL_FWB_GLOBAL that contains all\r
-                          instance data\r
-  Virtual               - Whether CPU is in virtual or physical mode\r
-\r
-Returns: \r
-  EFI_SUCCESS           - Successfully returns\r
-  EFI_ACCESS_DENIED     - The volume setting is locked and cannot be modified\r
-  EFI_INVALID_PARAMETER - Instance not found, or The attributes requested are\r
-                          in conflict with the capabilities as declared in the\r
-                          firmware volume header\r
-\r
-**/\r
-{\r
-  EFI_FW_VOL_INSTANCE   *FwhInstance = NULL;\r
-  EFI_FVB_ATTRIBUTES_2  OldAttributes;\r
-  EFI_FVB_ATTRIBUTES_2  *AttribPtr;\r
-  UINT32                Capabilities;\r
-  UINT32                OldStatus;\r
-  UINT32                NewStatus;\r
-  EFI_STATUS            Status;\r
-  EFI_FVB_ATTRIBUTES_2  UnchangedAttributes;\r
-\r
-\r
-  //\r
-  // Find the right instance of the FVB private data\r
-  //\r
-  Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  AttribPtr     = (EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes);\r
-  OldAttributes = *AttribPtr;\r
-  Capabilities  = OldAttributes & (EFI_FVB2_READ_DISABLED_CAP | \\r
-                                   EFI_FVB2_READ_ENABLED_CAP | \\r
-                                   EFI_FVB2_WRITE_DISABLED_CAP | \\r
-                                   EFI_FVB2_WRITE_ENABLED_CAP | \\r
-                                   EFI_FVB2_LOCK_CAP \\r
-                                   );\r
-\r
-  OldStatus     = OldAttributes & EFI_FVB2_STATUS;\r
-  NewStatus     = *Attributes & EFI_FVB2_STATUS;\r
-  UnchangedAttributes = EFI_FVB2_READ_DISABLED_CAP  | \\r
-                        EFI_FVB2_READ_ENABLED_CAP   | \\r
-                        EFI_FVB2_WRITE_DISABLED_CAP | \\r
-                        EFI_FVB2_WRITE_ENABLED_CAP  | \\r
-                        EFI_FVB2_LOCK_CAP           | \\r
-                        EFI_FVB2_STICKY_WRITE       | \\r
-                        EFI_FVB2_MEMORY_MAPPED      | \\r
-                        EFI_FVB2_ERASE_POLARITY     | \\r
-                        EFI_FVB2_READ_LOCK_CAP      | \\r
-                        EFI_FVB2_WRITE_LOCK_CAP     | \\r
-                        EFI_FVB2_ALIGNMENT;\r
-\r
-  //\r
-  // Some attributes of FV is read only can *not* be set\r
-  //\r
-  if ((OldAttributes & UnchangedAttributes) ^ (*Attributes & UnchangedAttributes)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // If firmware volume is locked, no status bit can be updated\r
-  //\r
-  if (OldAttributes & EFI_FVB2_LOCK_STATUS) {\r
-    if (OldStatus ^ NewStatus) {\r
-      return EFI_ACCESS_DENIED;\r
-    }\r
-  }\r
-  //\r
-  // Test read disable\r
-  //\r
-  if ((Capabilities & EFI_FVB2_READ_DISABLED_CAP) == 0) {\r
-    if ((NewStatus & EFI_FVB2_READ_STATUS) == 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Test read enable\r
-  //\r
-  if ((Capabilities & EFI_FVB2_READ_ENABLED_CAP) == 0) {\r
-    if (NewStatus & EFI_FVB2_READ_STATUS) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Test write disable\r
-  //\r
-  if ((Capabilities & EFI_FVB2_WRITE_DISABLED_CAP) == 0) {\r
-    if ((NewStatus & EFI_FVB2_WRITE_STATUS) == 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Test write enable\r
-  //\r
-  if ((Capabilities & EFI_FVB2_WRITE_ENABLED_CAP) == 0) {\r
-    if (NewStatus & EFI_FVB2_WRITE_STATUS) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-  //\r
-  // Test lock\r
-  //\r
-  if ((Capabilities & EFI_FVB2_LOCK_CAP) == 0) {\r
-    if (NewStatus & EFI_FVB2_LOCK_STATUS) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-\r
-  *AttribPtr  = (*AttribPtr) & (0xFFFFFFFF & (~EFI_FVB2_STATUS));\r
-  *AttribPtr  = (*AttribPtr) | NewStatus;\r
-  *Attributes = *AttribPtr;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-//\r
-// FVB protocol APIs\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolGetPhysicalAddress (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
-  OUT EFI_PHYSICAL_ADDRESS                        *Address\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Retrieves the physical address of the device.\r
-\r
-Arguments:\r
-\r
-  This                  - Calling context\r
-  Address               - Output buffer containing the address.\r
-\r
-Returns:\r
-\r
-Returns: \r
-  EFI_SUCCESS           - Successfully returns\r
-\r
-**/\r
-{\r
-  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
-\r
-  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
-\r
-  return FvbGetPhysicalAddress (FvbDevice->Instance, Address, mFvbModuleGlobal, EfiGoneVirtual ());\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolGetBlockSize (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
-  IN  EFI_LBA                                     Lba,\r
-  OUT UINTN                                       *BlockSize,\r
-  OUT UINTN                                       *NumOfBlocks\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Retrieve the size of a logical block\r
-\r
-Arguments:\r
-  This                  - Calling context\r
-  Lba                   - Indicates which block to return the size for.\r
-  BlockSize             - A pointer to a caller allocated UINTN in which\r
-                          the size of the block is returned\r
-  NumOfBlocks           - a pointer to a caller allocated UINTN in which the\r
-                          number of consecutive blocks starting with Lba is\r
-                          returned. All blocks in this range have a size of\r
-                          BlockSize\r
-\r
-Returns: \r
-  EFI_SUCCESS           - The firmware volume was read successfully and \r
-                          contents are in Buffer\r
-\r
-**/\r
-{\r
-  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
-\r
-  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
-\r
-  return FvbGetLbaAddress (\r
-          FvbDevice->Instance,\r
-          Lba,\r
-          NULL,\r
-          BlockSize,\r
-          NumOfBlocks,\r
-          mFvbModuleGlobal,\r
-          EfiGoneVirtual ()\r
-          );\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolGetAttributes (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
-  OUT EFI_FVB_ATTRIBUTES_2                        *Attributes\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-    Retrieves Volume attributes.  No polarity translations are done.\r
-\r
-Arguments:\r
-    This                - Calling context\r
-    Attributes          - output buffer which contains attributes\r
-\r
-Returns: \r
-  EFI_SUCCESS           - Successfully returns\r
-\r
-**/\r
-{\r
-  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
-\r
-  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
-\r
-  return FvbGetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ());\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolSetAttributes (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
-  IN OUT EFI_FVB_ATTRIBUTES_2                     *Attributes\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Sets Volume attributes. No polarity translations are done.\r
-\r
-Arguments:\r
-  This                  - Calling context\r
-  Attributes            - output buffer which contains attributes\r
-\r
-Returns: \r
-  EFI_SUCCESS           - Successfully returns\r
-\r
-**/\r
-{\r
-  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
-\r
-  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
-\r
-  return FvbSetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ());\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolEraseBlocks (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *This,\r
-  ...  \r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The EraseBlock() function erases one or more blocks as denoted by the \r
-  variable argument list. The entire parameter list of blocks must be verified\r
-  prior to erasing any blocks.  If a block is requested that does not exist \r
-  within the associated firmware volume (it has a larger index than the last \r
-  block of the firmware volume), the EraseBlock() function must return\r
-  EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.\r
-\r
-Arguments:\r
-  This                  - Calling context\r
-  ...                   - Starting LBA followed by Number of Lba to erase. \r
-                          a -1 to terminate the list.\r
-\r
-Returns: \r
-  EFI_SUCCESS           - The erase request was successfully completed\r
-  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
-  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
-                          could not be written. Firmware device may have been\r
-                          partially erased\r
-\r
-**/\r
-{\r
-  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
-  EFI_FW_VOL_INSTANCE     *FwhInstance = NULL;\r
-  UINTN                   NumOfBlocks;\r
-  VA_LIST                 args;\r
-  EFI_LBA                 StartingLba;\r
-  UINTN                   NumOfLba;\r
-  EFI_STATUS              Status;\r
-\r
-  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
-\r
-  Status    = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal, &FwhInstance, EfiGoneVirtual ());\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  NumOfBlocks = FwhInstance->NumOfBlocks;\r
-\r
-  VA_START (args, This);\r
-\r
-  do {\r
-    StartingLba = VA_ARG (args, EFI_LBA);\r
-    if (StartingLba == EFI_LBA_LIST_TERMINATOR) {\r
-      break;\r
-    }\r
-\r
-    NumOfLba = VA_ARG (args, UINT32);\r
-\r
-    //\r
-    // Check input parameters\r
-    //\r
-    if (NumOfLba == 0) {\r
-      VA_END (args);\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if ((StartingLba + NumOfLba) > NumOfBlocks) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  } while (1);\r
-\r
-  VA_END (args);\r
-\r
-  VA_START (args, This);\r
-  do {\r
-    StartingLba = VA_ARG (args, EFI_LBA);\r
-    if (StartingLba == EFI_LBA_LIST_TERMINATOR) {\r
-      break;\r
-    }\r
-\r
-    NumOfLba = VA_ARG (args, UINT32);\r
-\r
-    while (NumOfLba > 0) {\r
-      Status = FvbEraseBlock (FvbDevice->Instance, StartingLba, mFvbModuleGlobal, EfiGoneVirtual ());\r
-      if (EFI_ERROR (Status)) {\r
-        VA_END (args);\r
-        return Status;\r
-      }\r
-\r
-      StartingLba++;\r
-      NumOfLba--;\r
-    }\r
-\r
-  } while (1);\r
-\r
-  VA_END (args);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolWrite (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
-  IN EFI_LBA                                      Lba,\r
-  IN UINTN                                        Offset,\r
-  IN OUT UINTN                                    *NumBytes,\r
-  IN UINT8                                        *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Writes data beginning at Lba:Offset from FV. The write terminates either\r
-  when *NumBytes of data have been written, or when a block boundary is\r
-  reached.  *NumBytes is updated to reflect the actual number of bytes\r
-  written. The write opertion does not include erase. This routine will\r
-  attempt to write only the specified bytes. If the writes do not stick,\r
-  it will return an error.\r
-\r
-Arguments:\r
-  This                  - Calling context\r
-  Lba                   - Block in which to begin write\r
-  Offset                - Offset in the block at which to begin write\r
-  NumBytes              - On input, indicates the requested write size. On\r
-                          output, indicates the actual number of bytes written\r
-  Buffer                - Buffer containing source data for the write.\r
-\r
-Returns: \r
-  EFI_SUCCESS           - The firmware volume was written successfully\r
-  EFI_BAD_BUFFER_SIZE   - Write attempted across a LBA boundary. On output,\r
-                          NumBytes contains the total number of bytes\r
-                          actually written\r
-  EFI_ACCESS_DENIED     - The firmware volume is in the WriteDisabled state\r
-  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
-                          could not be written\r
-  EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL\r
-\r
-**/\r
-{\r
-\r
-  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
-\r
-  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
-\r
-  return FvbWriteBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer, mFvbModuleGlobal, EfiGoneVirtual ());\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolRead (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
-  IN EFI_LBA                                      Lba,\r
-  IN UINTN                                        Offset,\r
-  IN OUT UINTN                                    *NumBytes,\r
-  IN UINT8                                        *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Reads data beginning at Lba:Offset from FV. The Read terminates either\r
-  when *NumBytes of data have been read, or when a block boundary is\r
-  reached.  *NumBytes is updated to reflect the actual number of bytes\r
-  written. The write opertion does not include erase. This routine will\r
-  attempt to write only the specified bytes. If the writes do not stick,\r
-  it will return an error.\r
-\r
-Arguments:\r
-  This                  - Calling context\r
-  Lba                   - Block in which to begin Read\r
-  Offset                - Offset in the block at which to begin Read\r
-  NumBytes              - On input, indicates the requested write size. On\r
-                          output, indicates the actual number of bytes Read\r
-  Buffer                - Buffer containing source data for the Read.\r
-\r
-Returns: \r
-  EFI_SUCCESS           - The firmware volume was read successfully and \r
-                          contents are in Buffer\r
-  EFI_BAD_BUFFER_SIZE   - Read attempted across a LBA boundary. On output,\r
-                          NumBytes contains the total number of bytes returned\r
-                          in Buffer\r
-  EFI_ACCESS_DENIED     - The firmware volume is in the ReadDisabled state\r
-  EFI_DEVICE_ERROR      - The block device is not functioning correctly and \r
-                          could not be read\r
-  EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL\r
-\r
-**/\r
-{\r
-\r
-  EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
-\r
-  FvbDevice = FVB_DEVICE_FROM_THIS (This);\r
-\r
-  return FvbReadBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer, mFvbModuleGlobal, EfiGoneVirtual ());\r
-}\r
-EFI_STATUS\r
-ValidateFvHeader (\r
-  EFI_FIRMWARE_VOLUME_HEADER            *FwVolHeader\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Check the integrity of firmware volume header\r
-\r
-Arguments:\r
-  FwVolHeader           - A pointer to a firmware volume header\r
-\r
-Returns: \r
-  EFI_SUCCESS           - The firmware volume is consistent\r
-  EFI_NOT_FOUND         - The firmware volume has corrupted. So it is not an FV\r
-\r
-**/\r
-{\r
-  UINT16  *Ptr;\r
-  UINT16  HeaderLength;\r
-  UINT16  Checksum;\r
-\r
-  //\r
-  // Verify the header revision, header signature, length\r
-  // Length of FvBlock cannot be 2**64-1\r
-  // HeaderLength cannot be an odd number\r
-  //\r
-  if ((FwVolHeader->Revision != EFI_FVH_REVISION) ||\r
-      (FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||\r
-      (FwVolHeader->FvLength == ((UINTN) -1)) ||\r
-      ((FwVolHeader->HeaderLength & 0x01) != 0)\r
-      ) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Verify the header checksum\r
-  //\r
-  HeaderLength  = (UINT16) (FwVolHeader->HeaderLength / 2);\r
-  Ptr           = (UINT16 *) FwVolHeader;\r
-  Checksum      = 0;\r
-  while (HeaderLength > 0) {\r
-    Checksum = Checksum + (*Ptr);\r
-    HeaderLength--;\r
-    Ptr++;\r
-  }\r
-\r
-  if (Checksum != 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbInitialize (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  This function does common initialization for FVB services\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-**/\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_FW_VOL_INSTANCE                 *FwhInstance = NULL;\r
-  EFI_FIRMWARE_VOLUME_HEADER          *FwVolHeader;\r
-  EFI_DXE_SERVICES                    *DxeServices;\r
-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR     Descriptor;\r
-  UINT32                              BufferSize;\r
-  EFI_FV_BLOCK_MAP_ENTRY              *PtrBlockMapEntry;\r
-  EFI_HANDLE                          FwbHandle;\r
-  EFI_FW_VOL_BLOCK_DEVICE             *FvbDevice;\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *OldFwbInterface;\r
-  EFI_DEVICE_PATH_PROTOCOL            *TempFwbDevicePath;\r
-  FV_DEVICE_PATH                      TempFvbDevicePathData;\r
-  UINT32                              MaxLbaSize;\r
-  EFI_PHYSICAL_ADDRESS                BaseAddress;\r
-  UINT64                              Length;\r
-  UINTN                               NumOfBlocks;\r
-  EFI_PEI_HOB_POINTERS                FvHob;\r
-\r
-   //\r
-  // Get the DXE services table\r
-  //\r
-  DxeServices = gDS;\r
-\r
-  //\r
-  // Allocate runtime services data for global variable, which contains\r
-  // the private data of all firmware volume block instances\r
-  //\r
-  Status = gBS->AllocatePool (\r
-                  EfiRuntimeServicesData,\r
-                  sizeof (ESAL_FWB_GLOBAL),\r
-                  (VOID**) &mFvbModuleGlobal\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Calculate the total size for all firmware volume block instances\r
-  //\r
-  BufferSize            = 0;\r
-\r
-  FvHob.Raw = GetHobList ();\r
-  while ((FvHob.Raw = GetNextHob (EFI_HOB_TYPE_FV, FvHob.Raw)) != NULL) {\r
-    BaseAddress = FvHob.FirmwareVolume->BaseAddress;\r
-    Length      = FvHob.FirmwareVolume->Length;\r
-    //\r
-    // Check if it is a "real" flash\r
-    //\r
-    Status = DxeServices->GetMemorySpaceDescriptor (\r
-                            BaseAddress,\r
-                            &Descriptor\r
-                            );\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-\r
-    if (Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) {\r
-      FvHob.Raw = GET_NEXT_HOB (FvHob);\r
-      continue;\r
-    }\r
-\r
-    FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;\r
-    Status      = ValidateFvHeader (FwVolHeader);\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Get FvbInfo\r
-      //\r
-      Status = GetFvbInfo (Length, &FwVolHeader);\r
-      if (EFI_ERROR (Status)) {\r
-        FvHob.Raw = GET_NEXT_HOB (FvHob);\r
-        continue;\r
-      }\r
-    }\r
-\r
-    BufferSize += (sizeof (EFI_FW_VOL_INSTANCE) + FwVolHeader->HeaderLength - sizeof (EFI_FIRMWARE_VOLUME_HEADER));\r
-    FvHob.Raw = GET_NEXT_HOB (FvHob);\r
-  }\r
-\r
-  //\r
-  // Only need to allocate once. There is only one copy of physical memory for\r
-  // the private data of each FV instance. But in virtual mode or in physical\r
-  // mode, the address of the the physical memory may be different.\r
-  //\r
-  Status = gBS->AllocatePool (\r
-                  EfiRuntimeServicesData,\r
-                  BufferSize,\r
-                  (VOID**) &mFvbModuleGlobal->FvInstance[FVB_PHYSICAL]\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Make a virtual copy of the FvInstance pointer.\r
-  //\r
-  FwhInstance = mFvbModuleGlobal->FvInstance[FVB_PHYSICAL];\r
-  mFvbModuleGlobal->FvInstance[FVB_VIRTUAL] = FwhInstance;\r
-\r
-  mFvbModuleGlobal->NumFv                   = 0;\r
-  MaxLbaSize = 0;\r
-\r
-  FvHob.Raw = GetHobList ();\r
-  while (NULL != (FvHob.Raw = GetNextHob (EFI_HOB_TYPE_FV, FvHob.Raw))) {\r
-    BaseAddress = FvHob.FirmwareVolume->BaseAddress;\r
-    Length      = FvHob.FirmwareVolume->Length;\r
-    //\r
-    // Check if it is a "real" flash\r
-    //\r
-    Status = DxeServices->GetMemorySpaceDescriptor (\r
-                            BaseAddress,\r
-                            &Descriptor\r
-                            );\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-\r
-    if (Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) {\r
-      FvHob.Raw = GET_NEXT_HOB (FvHob);\r
-      continue;\r
-    }\r
-\r
-    FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;\r
-    Status      = ValidateFvHeader (FwVolHeader);\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Get FvbInfo to provide in FwhInstance.\r
-      //\r
-      Status = GetFvbInfo (Length, &FwVolHeader);\r
-      if (EFI_ERROR (Status)) {\r
-        FvHob.Raw = GET_NEXT_HOB (FvHob);\r
-        continue;\r
-      }\r
-      //\r
-      //  Write healthy FV header back.\r
-      //\r
-      CopyMem (\r
-        (VOID *) (UINTN) BaseAddress,\r
-        (VOID *) FwVolHeader,\r
-        FwVolHeader->HeaderLength\r
-        );\r
-    }\r
-\r
-    FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN) BaseAddress;\r
-    FwhInstance->FvBase[FVB_VIRTUAL]  = (UINTN) BaseAddress;\r
-\r
-    CopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader, FwVolHeader->HeaderLength);\r
-    FwVolHeader = &(FwhInstance->VolumeHeader);\r
-    EfiInitializeLock (&(FwhInstance->FvbDevLock), TPL_HIGH_LEVEL);\r
-\r
-    NumOfBlocks = 0;\r
-\r
-    for (PtrBlockMapEntry = FwVolHeader->BlockMap; PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) {\r
-      //\r
-      // Get the maximum size of a block. The size will be used to allocate\r
-      // buffer for Scratch space, the intermediate buffer for FVB extension\r
-      // protocol\r
-      //\r
-      if (MaxLbaSize < PtrBlockMapEntry->Length) {\r
-        MaxLbaSize = PtrBlockMapEntry->Length;\r
-      }\r
-\r
-      NumOfBlocks = NumOfBlocks + PtrBlockMapEntry->NumBlocks;\r
-    }\r
-    //\r
-    // The total number of blocks in the FV.\r
-    //\r
-    FwhInstance->NumOfBlocks = NumOfBlocks;\r
-\r
-    //\r
-    // Add a FVB Protocol Instance\r
-    //\r
-    Status = gBS->AllocatePool (\r
-                    EfiRuntimeServicesData,\r
-                    sizeof (EFI_FW_VOL_BLOCK_DEVICE),\r
-                    (VOID**) &FvbDevice\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    CopyMem (FvbDevice, &mFvbDeviceTemplate, sizeof (EFI_FW_VOL_BLOCK_DEVICE));\r
-\r
-    FvbDevice->Instance = mFvbModuleGlobal->NumFv;\r
-    mFvbModuleGlobal->NumFv++;\r
-\r
-    //\r
-    // Set up the devicepath\r
-    //\r
-    FvbDevice->DevicePath.MemMapDevPath.StartingAddress = BaseAddress;\r
-    FvbDevice->DevicePath.MemMapDevPath.EndingAddress   = BaseAddress + (FwVolHeader->FvLength - 1);\r
-\r
-    //\r
-    // Find a handle with a matching device path that has supports FW Block protocol\r
-    //\r
-    TempFwbDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) &TempFvbDevicePathData;\r
-    CopyMem (TempFwbDevicePath, &FvbDevice->DevicePath, sizeof (FV_DEVICE_PATH));\r
-    Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, &TempFwbDevicePath, &FwbHandle);\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // LocateDevicePath fails so install a new interface and device path\r
-      //\r
-      FwbHandle = NULL;\r
-      Status = gBS->InstallMultipleProtocolInterfaces (\r
-                      &FwbHandle,\r
-                      &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                      &FvbDevice->FwVolBlockInstance,\r
-                      &gEfiDevicePathProtocolGuid,\r
-                      &FvbDevice->DevicePath,\r
-                      NULL\r
-                      );\r
-      ASSERT_EFI_ERROR (Status);\r
-    } else if (IsDevicePathEnd (TempFwbDevicePath)) {\r
-      //\r
-      // Device allready exists, so reinstall the FVB protocol\r
-      //\r
-      Status = gBS->HandleProtocol (\r
-                      FwbHandle,\r
-                      &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                      (VOID**)&OldFwbInterface\r
-                      );\r
-      ASSERT_EFI_ERROR (Status);\r
-\r
-      Status = gBS->ReinstallProtocolInterface (\r
-                      FwbHandle,\r
-                      &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                      OldFwbInterface,\r
-                      &FvbDevice->FwVolBlockInstance\r
-                      );\r
-      ASSERT_EFI_ERROR (Status);\r
-\r
-    } else {\r
-      //\r
-      // There was a FVB protocol on an End Device Path node\r
-      //\r
-      ASSERT (FALSE);\r
-    }\r
-\r
-    FwhInstance = (EFI_FW_VOL_INSTANCE *)\r
-      (\r
-        (UINTN) ((UINT8 *) FwhInstance) + FwVolHeader->HeaderLength +\r
-          (sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))\r
-      );\r
-\r
-    FvHob.Raw = GET_NEXT_HOB (FvHob);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/InOsEmuPkg/FvbServicesRuntimeDxe/FvbInfo.c b/InOsEmuPkg/FvbServicesRuntimeDxe/FvbInfo.c
deleted file mode 100644 (file)
index 34f2910..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/*++ @file\r
-  Defines data structure that is the volume header found.These data is intent\r
-  to decouple FVB driver with FV header.\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Guid/EventGroup.h>\r
-#include <Guid/FirmwareFileSystem2.h>\r
-#include <Guid/SystemNvDataGuid.h>\r
-\r
-#include <Protocol/FirmwareVolumeBlock.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/UefiRuntimeLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-\r
-typedef struct {\r
-  UINT64                      FvLength;\r
-  EFI_FIRMWARE_VOLUME_HEADER  FvbInfo;\r
-  //\r
-  // EFI_FV_BLOCK_MAP_ENTRY    ExtraBlockMap[n];//n=0\r
-  //\r
-  EFI_FV_BLOCK_MAP_ENTRY      End[1];\r
-} EFI_FVB_MEDIA_INFO;\r
-\r
-EFI_FVB_MEDIA_INFO  mPlatformFvbMediaInfo[] = {\r
-  //\r
-  // Recovery BOIS FVB\r
-  //\r
-  {\r
-    FixedPcdGet32 (PcdEmuFlashFvRecoverySize),\r
-    {\r
-      {\r
-        0,\r
-      },  // ZeroVector[16]\r
-      EFI_FIRMWARE_FILE_SYSTEM2_GUID,\r
-      FixedPcdGet32 (PcdEmuFlashFvRecoverySize),\r
-      EFI_FVH_SIGNATURE,\r
-      EFI_FVB2_READ_ENABLED_CAP |\r
-        EFI_FVB2_READ_STATUS |\r
-        EFI_FVB2_WRITE_ENABLED_CAP |\r
-        EFI_FVB2_WRITE_STATUS |\r
-        EFI_FVB2_ERASE_POLARITY,\r
-      sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
-      0,  // CheckSum\r
-      0,  // ExtHeaderOffset\r
-      {\r
-        0,\r
-      },  // Reserved[1]\r
-      2,  // Revision\r
-      {\r
-        {\r
-          FixedPcdGet32 (PcdEmuFlashFvRecoverySize)/FixedPcdGet32 (PcdEmuFirmwareBlockSize),\r
-          FixedPcdGet32 (PcdEmuFirmwareBlockSize),\r
-        }\r
-      }\r
-    },\r
-    {\r
-      {\r
-        0,\r
-        0\r
-      }\r
-    }\r
-  },\r
-  //\r
-  // Systen NvStorage FVB\r
-  //\r
-  {\r
-    FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \\r
-    FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \\r
-    FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \\r
-    FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize),\r
-    {\r
-      {\r
-        0,\r
-      },  // ZeroVector[16]\r
-      EFI_SYSTEM_NV_DATA_FV_GUID,\r
-      FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \\r
-      FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \\r
-      FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \\r
-      FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize),\r
-      EFI_FVH_SIGNATURE,\r
-      EFI_FVB2_READ_ENABLED_CAP |\r
-        EFI_FVB2_READ_STATUS |\r
-        EFI_FVB2_WRITE_ENABLED_CAP |\r
-        EFI_FVB2_WRITE_STATUS |\r
-        EFI_FVB2_ERASE_POLARITY,\r
-      sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),\r
-      0,  // CheckSum\r
-      0,  // ExtHeaderOffset\r
-      {\r
-        0,\r
-      },  // Reserved[1]\r
-      2,  // Revision\r
-      {\r
-        {\r
-          (FixedPcdGet32 (PcdFlashNvStorageVariableSize) + \\r
-          FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + \\r
-          FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + \\r
-          FixedPcdGet32 (PcdEmuFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdEmuFirmwareBlockSize),\r
-          FixedPcdGet32 (PcdEmuFirmwareBlockSize),\r
-        }\r
-      }\r
-    },\r
-    {\r
-      {\r
-        0,\r
-        0\r
-      }\r
-    }\r
-  }\r
-};\r
-\r
-EFI_STATUS\r
-GetFvbInfo (\r
-  IN  UINT64                        FvLength,\r
-  OUT EFI_FIRMWARE_VOLUME_HEADER    **FvbInfo\r
-  )\r
-{\r
-  UINTN Index;\r
-\r
-  for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) {\r
-    if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {\r
-      *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
diff --git a/InOsEmuPkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf b/InOsEmuPkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
deleted file mode 100644 (file)
index d343867..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-## @file\r
-# Component description file for Emu Fimware Volume Block DXE driver module.\r
-#\r
-# This DXE runtime driver implements and produces the Fimware Volue Block Protocol on \r
-#  Emu emulator.\r
-# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = FwBlockService\r
-  FILE_GUID                      = A01E498C-96E8-2A4C-95F4-85248F989753\r
-  MODULE_TYPE                    = DXE_RUNTIME_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = FvbInitialize\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  FvbInfo.c\r
-  FWBlockService.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  HobLib\r
-  DebugLib\r
-  UefiRuntimeLib\r
-  DxeServicesTableLib\r
-  BaseLib\r
-  UefiDriverEntryPoint\r
-  UefiLib\r
-  DevicePathLib\r
-\r
-[Guids]\r
-  gEfiEventVirtualAddressChangeGuid             # ALWAYS_CONSUMED  Create Event: EVENT_GROUP_GUID\r
-\r
-[Protocols]\r
-  gEfiFirmwareVolumeBlockProtocolGuid           # PROTOCOL ALWAYS_PRODUCED\r
-  gEfiDevicePathProtocolGuid                    # PROTOCOL SOMETIMES_PRODUCED\r
-\r
-[FixedPcd]\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFirmwareFdSize\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFirmwareBlockSize\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashFvRecoveryBase\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashFvRecoverySize\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogBase\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogSize\r
-\r
-[Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase\r
-\r
-[Depex]\r
-  TRUE\r
-\r
diff --git a/InOsEmuPkg/FvbServicesRuntimeDxe/FwBlockService.h b/InOsEmuPkg/FvbServicesRuntimeDxe/FwBlockService.h
deleted file mode 100644 (file)
index e498451..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*++ @file\r
-  Firmware volume block driver for Intel Firmware Hub (FWH) device\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#ifndef _FW_BLOCK_SERVICE_H\r
-#define _FW_BLOCK_SERVICE_H\r
-\r
-//\r
-// BugBug: Add documentation here for data structure!!!!\r
-//\r
-#define FVB_PHYSICAL  0\r
-#define FVB_VIRTUAL   1\r
-\r
-typedef struct {\r
-  EFI_LOCK                    FvbDevLock;\r
-  UINTN                       FvBase[2];\r
-  UINTN                       NumOfBlocks;\r
-  EFI_FIRMWARE_VOLUME_HEADER  VolumeHeader;\r
-} EFI_FW_VOL_INSTANCE;\r
-\r
-typedef struct {\r
-  UINT32              NumFv;\r
-  EFI_FW_VOL_INSTANCE *FvInstance[2];\r
-} ESAL_FWB_GLOBAL;\r
-\r
-//\r
-// Fvb Protocol instance data\r
-//\r
-#define FVB_DEVICE_FROM_THIS(a)         CR (a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE)\r
-#define FVB_EXTEND_DEVICE_FROM_THIS(a)  CR (a, EFI_FW_VOL_BLOCK_DEVICE, FvbExtension, FVB_DEVICE_SIGNATURE)\r
-#define FVB_DEVICE_SIGNATURE            SIGNATURE_32 ('F', 'V', 'B', 'N')\r
-\r
-typedef struct {\r
-  MEMMAP_DEVICE_PATH        MemMapDevPath;\r
-  EFI_DEVICE_PATH_PROTOCOL  EndDevPath;\r
-} FV_DEVICE_PATH;\r
-\r
-typedef struct {\r
-  UINTN                               Signature;\r
-  FV_DEVICE_PATH                      DevicePath;\r
-  UINTN                               Instance;\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  FwVolBlockInstance;\r
-} EFI_FW_VOL_BLOCK_DEVICE;\r
-\r
-EFI_STATUS\r
-GetFvbInfo (\r
-  IN  UINT64                            FvLength,\r
-  OUT EFI_FIRMWARE_VOLUME_HEADER        **FvbInfo\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-FvbReadBlock (\r
-  IN UINTN                                Instance,\r
-  IN EFI_LBA                              Lba,\r
-  IN UINTN                                BlockOffset,\r
-  IN OUT UINTN                            *NumBytes,\r
-  IN UINT8                                *Buffer,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-FvbWriteBlock (\r
-  IN UINTN                                Instance,\r
-  IN EFI_LBA                              Lba,\r
-  IN UINTN                                BlockOffset,\r
-  IN OUT UINTN                            *NumBytes,\r
-  IN UINT8                                *Buffer,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-FvbEraseBlock (\r
-  IN UINTN                                Instance,\r
-  IN EFI_LBA                              Lba,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-FvbSetVolumeAttributes (\r
-  IN UINTN                                Instance,\r
-  IN OUT EFI_FVB_ATTRIBUTES_2             *Attributes,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-FvbGetVolumeAttributes (\r
-  IN UINTN                                Instance,\r
-  OUT EFI_FVB_ATTRIBUTES_2                *Attributes,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-FvbGetPhysicalAddress (\r
-  IN UINTN                                Instance,\r
-  OUT EFI_PHYSICAL_ADDRESS                *Address,\r
-  IN ESAL_FWB_GLOBAL                      *Global,\r
-  IN BOOLEAN                              Virtual\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbInitialize (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-;\r
-\r
-\r
-VOID\r
-EFIAPI\r
-FvbClassAddressChangeEvent (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-FvbGetLbaAddress (\r
-  IN  UINTN                               Instance,\r
-  IN  EFI_LBA                             Lba,\r
-  OUT UINTN                               *LbaAddress,\r
-  OUT UINTN                               *LbaLength,\r
-  OUT UINTN                               *NumOfBlocks,\r
-  IN  ESAL_FWB_GLOBAL                     *Global,\r
-  IN  BOOLEAN                             Virtual\r
-  )\r
-;\r
-\r
-//\r
-// Protocol APIs\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolGetAttributes (\r
-  IN  CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
-  OUT       EFI_FVB_ATTRIBUTES_2                         *Attributes\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolSetAttributes (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
-  IN OUT   EFI_FVB_ATTRIBUTES_2                         *Attributes\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolGetPhysicalAddress (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
-  OUT      EFI_PHYSICAL_ADDRESS                         *Address\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolGetBlockSize (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
-  IN  EFI_LBA                                     Lba,\r
-  OUT UINTN                                       *BlockSize,\r
-  OUT UINTN                                       *NumOfBlocks\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolRead (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
-  IN EFI_LBA                                      Lba,\r
-  IN UINTN                                        Offset,\r
-  IN OUT UINTN                                    *NumBytes,\r
-  IN UINT8                                        *Buffer\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolWrite (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
-  IN EFI_LBA                                      Lba,\r
-  IN UINTN                                        Offset,\r
-  IN OUT UINTN                                    *NumBytes,\r
-  IN UINT8                                        *Buffer\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-FvbProtocolEraseBlocks (\r
-  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *This,\r
-  ...\r
-  )\r
-;\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/InOsEmuPkg.dec b/InOsEmuPkg/InOsEmuPkg.dec
deleted file mode 100644 (file)
index f18ee28..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-## @file\r
-#\r
-# This is the Emu Emulation Environment Platform\r
-#\r
-# Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#    This program and the accompanying materials are licensed and made available \r
-#    under the terms and conditions of the BSD License which accompanies this distribution.\r
-#    The full text of the license may be found at http://opensource.org/licenses/bsd-license.php\r
-#    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES\r
-#    OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-##\r
-\r
-[Defines]\r
-  DEC_VERSION                    = 0x00010005\r
-  PACKAGE_NAME                   = InOsEmuPkg\r
-  PACKAGE_GUID                   = 36E48BD7-7D92-5A47-A2CD-513F072E3300\r
-  PACKAGE_VERSION                = 0.1\r
-\r
-\r
-[Includes]\r
-  Include\r
-\r
-\r
-[LibraryClasses]\r
-  ThunkPpiList|Include/Library/ThunkPpiList.h\r
-  ThunkProtocolList|Include/Library/ThunkProtocolList.h\r
-  EmuThunkLib|Include/Library/EmuThunkLib.h\r
-  KeyMap|Include/Library/KeyMapLib.h\r
-  PpiListLib|Include/Library/PpiListLib.h\r
-\r
-[Protocols]\r
-  gEmuThunkProtocolGuid          = { 0x5CF32E0B, 0x8EDF, 0x2E44, { 0x9C, 0xDA, 0x93, 0x20, 0x5E, 0x99, 0xEC, 0x1C } }\r
-  gEmuIoThunkProtocolGuid        = { 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } }\r
-  gEmuGraphicsWindowProtocolGuid = { 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 0xC1 } }\r
-  gEmuThreadThunkProtocolGuid    = { 0x3B1E4B7C, 0x09D8, 0x944F, { 0xA4, 0x08, 0x13, 0x09, 0xEB, 0x8B, 0x44, 0x27 } }\r
-  gEmuBlockIoProtocolGuid        = { 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }\r
-  gEmuSnpProtocolGuid            = { 0xFD5FBE54, 0x8C35, 0xB345, { 0x8A, 0x0F, 0x7A, 0xC8, 0xA5, 0xFD, 0x05, 0x21 } }\r
-\r
-[Ppis]\r
-  gEmuThunkPpiGuid               = { 0xE113F896, 0x75CF, 0xF640, { 0x81, 0x7F, 0xC8, 0x5A, 0x79, 0xE8, 0xAE, 0x67 } }\r
-\r
-[Guids]\r
-  gInOsEmuPkgTokenSpaceGuid  = { 0x4F792E68, 0xE8C8, 0x794E, { 0xB1, 0xD8, 0x37, 0x03, 0xF3, 0xF2, 0xD5, 0xA5 } }\r
-  gEmuSystemConfigGuid       = { 0xF8626165, 0x6CEB, 0x924A, { 0xBA, 0xFC, 0xF1, 0x3A, 0xB9, 0xD6, 0x57, 0x28 } }\r
-  gEmuVirtualDisksGuid       = { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }\r
-  gEmuPhysicalDisksGuid      = { 0xf2bdcc96, 0x8985, 0x11db, { 0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }\r
-\r
-[PcdsFixedAtBuild]\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase|0x0|UINT64|0x00001014\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase|0x0|UINT64|0x00001015\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwWorkingBase|0x0|UINT64|0x00001016\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFdBaseAddress|0x0|UINT64|0x00001017\r
-\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogBase|0x0|UINT64|0x0000100e\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogSize|0x0|UINT32|0x0000100f\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashFvRecoveryBase|0x0|UINT64|0x00001010\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashFvRecoverySize|0x0|UINT32|0x00001011\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFirmwareFdSize|0x0|UINT32|0x00001012\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFirmwareBlockSize|0|UINT32|0x00001013\r
\r
-  ## Number of Application Processors (APs) in the system 0 means Uniprocessor mode\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuApCount|L"0"|VOID*|0x00001019\r
-\r
-  ## Magic page to implement PEI Services Table Pointer Lib\r
-  gInOsEmuPkgTokenSpaceGuid.PcdPeiServicesTablePage|0x1003000000|UINT64|0x0000101b\r
-\r
-  ## Size of the packet filter\r
-  gInOsEmuPkgTokenSpaceGuid.PcdNetworkPacketFilterSize|524288|UINT32|0x0000101c\r
-\r
-  \r
-\r
-[PcdsFixedAtBuild, PcdsPatchableInModule] \r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuBootMode|1|UINT32|0x00001006\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFirmwareVolume|L"..\\Fv\\Fv_Recovery.fd"|VOID*|0x00001009\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuMemorySize|L"64!64"|VOID*|0x0000100c\r
-  \r
-  #\r
-  # filename[:[R|F][O|W]][:BlockSize]\r
-  # filename can be a device node, like /dev/disk1\r
-  # R - Removable Media F - Fixed Media\r
-  # O - Write protected W - Writable\r
-  #   Default is Fixed Media, Writable\r
-  # For a file the default BlockSize is 512, and can be overridden via BlockSize,\r
-  #  for example 2048 for an ISO CD image. The block size for a device comes from\r
-  #  the device and is not configurable. \r
-  # Device Size comes from file or device. \r
-  # On Mac OS X you can use Disk Utility to create .dmg files and mount them like disks\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"disk.dmg:FW"|VOID*|0x00001001\r
-  \r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuGop|L"GOP Window"|VOID*|0x00001018\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFileSystem|L".!../../../../../EdkShellBinPkg/bin/ia32/Apps"|VOID*|0x00001004\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuSerialPort|L"/dev/ttyS0"|VOID*|0x00001002\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuNetworkInterface|L"en0"|VOID*|0x0000100d\r
-\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuCpuModel|L"Intel(R) Processor Model"|VOID*|0x00001007\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuCpuSpeed|L"3000"|VOID*|0x00001008\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuMpServicesPollingInterval|0x100|UINT64|0x0000101a\r
-\r
diff --git a/InOsEmuPkg/Include/Guid/EmuPhysicalDisk.h b/InOsEmuPkg/Include/Guid/EmuPhysicalDisk.h
deleted file mode 100644 (file)
index 324dc04..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/** @file\r
-  Setup Variable data structure for Emu platform.\r
-\r
-Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-\r
-**/\r
-\r
-#ifndef __EMU_PHYSICAL_DISK_H__\r
-#define __EMU_PHYSICAL_DISK_H__\r
-\r
-#define EFI_EMU_PHYSICAL_DISK_GUID  \\r
- { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }\r
-\r
-extern EFI_GUID   gEmuPhysicalDisksGuid;\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/Include/Guid/EmuSystemConfig.h b/InOsEmuPkg/Include/Guid/EmuSystemConfig.h
deleted file mode 100644 (file)
index b3a7d9b..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/** @file\r
-  Setup Variable data structure for Emu platform.\r
-\r
-Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-\r
-**/\r
-\r
-#ifndef __EMU_SYSTEM_CONFIG_H__\r
-#define __EMU_SYSTEM_CONFIG_H__\r
-\r
-#define EFI_EMU_SYSTEM_CONFIG_GUID  \\r
- { 0x9C4FB516, 0x3A1E, 0xD847, { 0xA1, 0xA1, 0x70, 0x58, 0xB6, 0x98, 0x67, 0x32 } }\r
-\r
-\r
-#pragma pack(1)\r
-typedef struct {\r
-  //\r
-  // Console output mode\r
-  //\r
-  UINT32        ConOutColumn;\r
-  UINT32        ConOutRow;\r
-} EMU_SYSTEM_CONFIGURATION;\r
-#pragma pack()\r
-\r
-\r
-extern EFI_GUID   gEmuSystemConfigGuid;\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/Include/Guid/EmuVirtualDisk.h b/InOsEmuPkg/Include/Guid/EmuVirtualDisk.h
deleted file mode 100644 (file)
index 17b97dc..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/** @file\r
-  Setup Variable data structure for Emu platform.\r
-\r
-Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-\r
-**/\r
-\r
-#ifndef __EMU_VIRTUAL_DISK_H__\r
-#define __EMU_VIRTUAL_DISK_H__\r
-\r
-#define EFI_EMU_VIRTUAL_DISK_GUID  \\r
- { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }\r
-\r
-extern EFI_GUID   gEmuVirtualDisksGuid;\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/Include/Library/EmuMagicPageLib.h b/InOsEmuPkg/Include/Library/EmuMagicPageLib.h
deleted file mode 100644 (file)
index 03dfcac..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*++ @file
-The PCD, gInOsEmuPkgTokenSpaceGuid.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.<BR>
-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 <PiPei.h>
-#include <Library/PcdLib.h>
-#include <Protocol/EmuThunk.h>
-
-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/InOsEmuPkg/Include/Library/EmuThunkLib.h b/InOsEmuPkg/Include/Library/EmuThunkLib.h
deleted file mode 100644 (file)
index 9d69d4f..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*++ @file
-
-Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
-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 <Protocol/EmuThunk.h>
-
-
-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/InOsEmuPkg/Include/Library/KeyMapLib.h b/InOsEmuPkg/Include/Library/KeyMapLib.h
deleted file mode 100644 (file)
index 7bd29a7..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2011, Apple Inc. All rights reserved. \r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <Protocol/SimpleTextInEx.h>\r
-\r
-\r
-/**\r
-  KeyMapMake gets called on key presses.\r
-\r
-  @param  KeyData       Key that was pressed.\r
-\r
-  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyMapMake (\r
-  IN EFI_KEY_DATA   *KeyData\r
-  );\r
-\r
-/**\r
-  KeyMapBreak gets called on key releases.\r
-\r
-  @param  KeyData       Key that was pressed.\r
-\r
-  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyMapBreak (\r
-  IN EFI_KEY_DATA   *KeyData\r
-  );\r
diff --git a/InOsEmuPkg/Include/Library/PpiListLib.h b/InOsEmuPkg/Include/Library/PpiListLib.h
deleted file mode 100644 (file)
index 061cfca..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*++ @file
-
-Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
-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/InOsEmuPkg/Include/Library/ThunkPpiList.h b/InOsEmuPkg/Include/Library/ThunkPpiList.h
deleted file mode 100644 (file)
index febc972..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/** @file\r
-  All 3rd parties to register the PPIs passed into PEI Core\r
-\r
-  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-  \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiPei.h>\r
-\r
-\r
-EFI_PEI_PPI_DESCRIPTOR *\r
-GetThunkPpiList (\r
-  VOID\r
-  );\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-AddThunkPpi (\r
-  IN  UINTN     Flags,\r
-  IN  EFI_GUID  *Guid,\r
-  IN  VOID      *Ppi\r
-  );\r
-\r
-\r
diff --git a/InOsEmuPkg/Include/Library/ThunkProtocolList.h b/InOsEmuPkg/Include/Library/ThunkProtocolList.h
deleted file mode 100644 (file)
index 5b25f9c..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/** @file\r
-  Emulator Thunk to abstract OS services from pure EFI code\r
-\r
-  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-  \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <Uefi.h>\r
-#include <Protocol/EmuIoThunk.h>\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-AddThunkProtocol (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *ThunkIo,  \r
-  IN  CHAR16                  *ConfigString,\r
-  IN  BOOLEAN                 EmuBusDriver\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GetNextThunkProtocol (\r
-  IN  BOOLEAN                 EmuBusDriver,\r
-  OUT EMU_IO_THUNK_PROTOCOL   **Instance  \r
-  );\r
-  \r
-\r
diff --git a/InOsEmuPkg/Include/Ppi/EmuThunk.h b/InOsEmuPkg/Include/Ppi/EmuThunk.h
deleted file mode 100644 (file)
index 20cdc46..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/** @file\r
-  Emulator Thunk to abstract OS services from pure EFI code\r
-\r
-  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-  \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __EMU_THUNK_PPI_H__\r
-#define __EMU_THUNK_PPI_H__\r
-\r
-#define EMU_THUNK_PPI_GUID  \\r
- { 0xB958B78C, 0x1D3E, 0xEE40, { 0x8B, 0xF4, 0xF0, 0x63, 0x2D, 0x06, 0x39, 0x16 } }\r
-\r
-\r
-\r
-/*++\r
-\r
-Routine Description:\r
-  This service is called from Index == 0 until it returns EFI_UNSUPPORTED.\r
-  It allows discontiguous memory regions to be supported by the emulator.\r
-\r
-Arguments:\r
-  Index      - Which memory region to use\r
-  MemoryBase - Return Base address of memory region\r
-  MemorySize - Return size in bytes of the memory region\r
-\r
-Returns:\r
-  EFI_SUCCESS - If memory region was mapped\r
-  EFI_UNSUPPORTED - If Index is not supported\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_PEI_AUTOSCAN) (\r
-  IN  UINTN                 Index,\r
-  OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,\r
-  OUT UINT64                *MemorySize\r
-  );\r
-\r
-\r
-/*++\r
-\r
-Routine Description:\r
-  Return the FD Size and base address. Since the FD is loaded from a \r
-  file into host memory only the SEC will know it's address.\r
-\r
-Arguments:\r
-  Index  - Which FD, starts at zero.\r
-  FdSize - Size of the FD in bytes\r
-  FdBase - Start address of the FD. Assume it points to an FV Header\r
-  FixUp  - Difference between actual FD address and build address\r
-\r
-Returns:\r
-  EFI_SUCCESS     - Return the Base address and size of the FV\r
-  EFI_UNSUPPORTED - Index does nto map to an FD in the system\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_PEI_FD_INFORMATION) (\r
-  IN     UINTN                  Index,\r
-  IN OUT EFI_PHYSICAL_ADDRESS   *FdBase,\r
-  IN OUT UINT64                 *FdSize,\r
-  IN OUT EFI_PHYSICAL_ADDRESS   *FixUp\r
-  );\r
-\r
-\r
-/*++\r
-\r
-Routine Description:\r
-  Export of EMU_THUNK_PROTOCOL from the SEC.\r
-\r
-Returns:\r
-  EFI_SUCCESS - Data returned\r
-\r
-**/\r
-typedef\r
-VOID *\r
-(EFIAPI *EMU_PEI_THUNK_INTERFACE) (\r
-  VOID\r
-  );\r
-\r
-\r
-\r
-/*++\r
-\r
-Routine Description:\r
-  Loads and relocates a PE/COFF image into memory.\r
-\r
-Arguments:\r
-  Pe32Data         - The base address of the PE/COFF file that is to be loaded and relocated\r
-  ImageAddress     - The base address of the relocated PE/COFF image\r
-  ImageSize        - The size of the relocated PE/COFF image\r
-  EntryPoint       - The entry point of the relocated PE/COFF image\r
-\r
-Returns:\r
-  EFI_SUCCESS   - The file was loaded and relocated\r
-  EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_PEI_LOAD_FILE) (\r
-  VOID                  *Pe32Data,\r
-  EFI_PHYSICAL_ADDRESS  *ImageAddress,\r
-  UINT64                *ImageSize,\r
-  EFI_PHYSICAL_ADDRESS  *EntryPoint\r
-  );\r
-\r
-\r
-typedef struct {\r
-  EMU_PEI_AUTOSCAN                  MemoryAutoScan;\r
-  EMU_PEI_FD_INFORMATION            FirmwareDevices;\r
-  EMU_PEI_THUNK_INTERFACE           Thunk;\r
-} EMU_THUNK_PPI;\r
-\r
-extern EFI_GUID gEmuThunkPpiGuid;\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/Include/Protocol/EmuBlockIo.h b/InOsEmuPkg/Include/Protocol/EmuBlockIo.h
deleted file mode 100644 (file)
index 26d6bb8..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/** @file\r
-  Emu Block IO2 protocol as defined in the UEFI 2.3.1 specification.\r
-\r
-  The Block IO2 protocol defines an extension to the Block IO protocol which\r
-  enables the ability to read and write data at a block level in a non-blocking\r
-  manner.\r
-\r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#ifndef __EMU_BLOCK_IO_H__\r
-#define __EMU_BLOCK_IO_H__\r
-\r
-#include <Protocol/BlockIo.h>\r
-#include <Protocol/BlockIo2.h>\r
-\r
-#define EMU_BLOCK_IO_PROTOCOL_GUID \\r
-{ 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }\r
-\r
-typedef struct _EMU_BLOCK_IO_PROTOCOL   EMU_BLOCK_IO_PROTOCOL;\r
-\r
-\r
-\r
-/**\r
-  Reset the block device hardware.\r
-\r
-  @param[in]  This                 Indicates a pointer to the calling context.\r
-  @param[in]  ExtendedVerification Indicates that the driver may perform a more\r
-                                   exhausive verfication operation of the device\r
-                                   during reset.\r
-\r
-  @retval EFI_SUCCESS          The device was reset.\r
-  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
-                               not be reset.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_BLOCK_RESET) (\r
-  IN EMU_BLOCK_IO_PROTOCOL   *This,\r
-  IN BOOLEAN                 ExtendedVerification\r
-  );\r
-\r
-/**\r
-  Read BufferSize bytes from Lba into Buffer.\r
-  \r
-  This function reads the requested number of blocks from the device. All the\r
-  blocks are read, or an error is returned.\r
-  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and\r
-  non-blocking I/O is being used, the Event associated with this request will\r
-  not be signaled.\r
-\r
-  @param[in]       This       Indicates a pointer to the calling context.\r
-  @param[in]       MediaId    Id of the media, changes every time the media is \r
-                              replaced.\r
-  @param[in]       Lba        The starting Logical Block Address to read from.\r
-  @param[in, out]  Token           A pointer to the token associated with the transaction.\r
-  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.  \r
-  @param[out]      Buffer     A pointer to the destination buffer for the data. The \r
-                              caller is responsible for either having implicit or \r
-                              explicit ownership of the buffer.\r
-\r
-  @retval EFI_SUCCESS           The read request was queued if Token->Event is\r
-                                not NULL.The data was read correctly from the\r
-                                device if the Token->Event is NULL.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing\r
-                                the read.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId is not for the current media.\r
-  @retval EFI_BAD_BUFFER_SIZE   The BufferSize parameter is not a multiple of the\r
-                                intrinsic block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
-                                or the buffer is not on proper alignment.\r
-  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack\r
-                                of resources.\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_BLOCK_READ) (\r
-  IN     EMU_BLOCK_IO_PROTOCOL  *This,\r
-  IN     UINT32                 MediaId,\r
-  IN     EFI_LBA                LBA,\r
-  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
-  IN     UINTN                  BufferSize,\r
-     OUT VOID                   *Buffer\r
-  );\r
-\r
-/**\r
-  Write BufferSize bytes from Lba into Buffer.\r
-\r
-  This function writes the requested number of blocks to the device. All blocks\r
-  are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,\r
-  EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is\r
-  being used, the Event associated with this request will not be signaled.\r
-\r
-  @param[in]       This       Indicates a pointer to the calling context.\r
-  @param[in]       MediaId    The media ID that the write request is for.\r
-  @param[in]       Lba        The starting logical block address to be written. The\r
-                              caller is responsible for writing to only legitimate\r
-                              locations.\r
-  @param[in, out]  Token      A pointer to the token associated with the transaction.\r
-  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param[in]       Buffer     A pointer to the source buffer for the data.\r
-\r
-  @retval EFI_SUCCESS           The write request was queued if Event is not NULL.\r
-                                The data was written correctly to the device if\r
-                                the Event is NULL.\r
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
-                                or the buffer is not on proper alignment.\r
-  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack\r
-                                of resources.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_BLOCK_WRITE) (\r
-  IN     EMU_BLOCK_IO_PROTOCOL  *This,\r
-  IN     UINT32                 MediaId,\r
-  IN     EFI_LBA                LBA,\r
-  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
-  IN     UINTN                  BufferSize,\r
-  IN     VOID                   *Buffer\r
-  );\r
-\r
-/**\r
-  Flush the Block Device.\r
\r
-  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED\r
-  is returned and non-blocking I/O is being used, the Event associated with\r
-  this request will not be signaled.  \r
-\r
-  @param[in]      This     Indicates a pointer to the calling context.\r
-  @param[in,out]  Token    A pointer to the token associated with the transaction\r
-\r
-  @retval EFI_SUCCESS          The flush request was queued if Event is not NULL.\r
-                               All outstanding data was written correctly to the\r
-                               device if the Event is NULL.\r
-  @retval EFI_DEVICE_ERROR     The device reported an error while writting back\r
-                               the data.\r
-  @retval EFI_WRITE_PROTECTED  The device cannot be written to.\r
-  @retval EFI_NO_MEDIA         There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED    The MediaId is not for the current media.\r
-  @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
-                               of resources.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_BLOCK_FLUSH) (\r
-  IN     EMU_BLOCK_IO_PROTOCOL    *This,\r
-  IN OUT EFI_BLOCK_IO2_TOKEN      *Token\r
-  );\r
-\r
-\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_BLOCK_CREATE_MAPPING) (\r
-  IN     EMU_BLOCK_IO_PROTOCOL    *This,\r
-  IN     EFI_BLOCK_IO_MEDIA       *Media\r
-  );\r
-\r
-\r
-///\r
-///  The Block I/O2 protocol defines an extension to the Block I/O protocol which\r
-///  enables the ability to read and write data at a block level in a non-blocking\r
-//   manner.\r
-///\r
-struct _EMU_BLOCK_IO_PROTOCOL  {\r
-  EMU_BLOCK_RESET           Reset;\r
-  EMU_BLOCK_READ            ReadBlocks;\r
-  EMU_BLOCK_WRITE           WriteBlocks;\r
-  EMU_BLOCK_FLUSH           FlushBlocks;\r
-  EMU_BLOCK_CREATE_MAPPING  CreateMapping;\r
-};\r
-\r
-extern EFI_GUID gEmuBlockIoProtocolGuid;\r
-\r
-#endif\r
-\r
diff --git a/InOsEmuPkg/Include/Protocol/EmuFileSystem.h b/InOsEmuPkg/Include/Protocol/EmuFileSystem.h
deleted file mode 100644 (file)
index 3713acf..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/** @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.<BR>
-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 <Protocol/SimplePointer.h>
-#include <Protocol/SimpleTextIn.h>
-#include <Protocol/SimpleTextInEx.h>
-#include <Protocol/UgaDraw.h>
-
-#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/InOsEmuPkg/Include/Protocol/EmuGraphicsWindow.h b/InOsEmuPkg/Include/Protocol/EmuGraphicsWindow.h
deleted file mode 100644 (file)
index e1afa0e..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*++ @file
-
-Copyright (c) 2006, Tristan Gingold. All rights reserved.<BR>
-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 <Protocol/SimplePointer.h>
-#include <Protocol/SimpleTextIn.h>
-#include <Protocol/SimpleTextInEx.h>
-#include <Protocol/UgaDraw.h>
-
-#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/InOsEmuPkg/Include/Protocol/EmuIoThunk.h b/InOsEmuPkg/Include/Protocol/EmuIoThunk.h
deleted file mode 100644 (file)
index af132be..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/** @file\r
-  Emulator Thunk to abstract OS services from pure EFI code\r
-\r
-  Copyright (c) 2010 - 2011, Apple Inc. All rights reserved.<BR>\r
-  \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __EMU_IO_THUNK__ \r
-#define __EMU_IO_THUNK__\r
-\r
-\r
-#define EMU_IO_THUNK_PROTOCO_GUID  \\r
- { 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } }\r
-\r
-\r
-typedef struct _EMU_IO_THUNK_PROTOCOL  EMU_IO_THUNK_PROTOCOL;\r
-\r
-\r
-typedef \r
-EFI_STATUS\r
-(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN) (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  );\r
-\r
-typedef \r
-EFI_STATUS\r
-(EFIAPI *EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE) (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  );\r
-\r
-struct _EMU_IO_THUNK_PROTOCOL {\r
-  EFI_GUID                            *Protocol;\r
-  VOID                                *Interface;  /// Only be valid after Open() is called\r
-  CHAR16                              *ConfigString;\r
-  UINT16                              Instance;\r
-  EMU_IO_THUNK_PROTOCOL_CLOSE_OPEN    Open;\r
-  EMU_IO_THUNK_PROTOCOL_CLOSE_CLOSE   Close;\r
-  VOID                                *Private;    /// Used by implementation \r
-};\r
-\r
-extern EFI_GUID gEmuIoThunkProtocolGuid;\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/Include/Protocol/EmuSnp.h b/InOsEmuPkg/Include/Protocol/EmuSnp.h
deleted file mode 100644 (file)
index fc8e24c..0000000
+++ /dev/null
@@ -1,459 +0,0 @@
-/** @file\r
-  The EMU_SNP_PROTOCOL provides services to initialize a network interface, \r
-  transmit packets, receive packets, and close a network interface.\r
-\r
-\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-Portitions copyright (c) 2011, Apple Inc. All rights reserved. \r
-This program and the accompanying materials are licensed and made available under \r
-the terms and conditions of the BSD License that accompanies this distribution.  \r
-The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php.                                          \r
-    \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.   \r
-\r
-**/\r
-\r
-#ifndef __EMU_SNP_H__\r
-#define __EMU_SNP_H__\r
-\r
-#include <Protocol/SimpleNetwork.h>\r
-\r
-#define EMU_SNP_PROTOCOL_GUID \\r
- { 0xFD5FBE54, 0x8C35, 0xB345, { 0x8A, 0x0F, 0x7A, 0xC8, 0xA5, 0xFD, 0x05, 0x21 } }\r
-\r
-typedef struct _EMU_SNP_PROTOCOL  EMU_SNP_PROTOCOL;\r
-\r
-\r
-/**\r
-  Register storage for SNP Mode.\r
-\r
-  @param  This Protocol instance pointer.\r
-  @param  Mode SimpleNetworkProtocol Mode structure passed into driver.\r
-\r
-  @retval EFI_SUCCESS           The network interface was started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_CREATE_MAPPING)(\r
-  IN EMU_SNP_PROTOCOL         *This,\r
-  IN EFI_SIMPLE_NETWORK_MODE  *Mode\r
-  );\r
-\r
-\r
-/**\r
-  Changes the state of a network interface from "stopped" to "started".\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           The network interface was started.\r
-  @retval EFI_ALREADY_STARTED   The network interface is already in the started state.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_START)(\r
-  IN EMU_SNP_PROTOCOL  *This\r
-  );\r
-\r
-/**\r
-  Changes the state of a network interface from "started" to "stopped".\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           The network interface was stopped.\r
-  @retval EFI_ALREADY_STARTED   The network interface is already in the stopped state.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_STOP)(\r
-  IN EMU_SNP_PROTOCOL  *This\r
-  );\r
-\r
-/**\r
-  Resets a network adapter and allocates the transmit and receive buffers \r
-  required by the network interface; optionally, also requests allocation \r
-  of additional transmit and receive buffers.\r
-\r
-  @param  This              The protocol instance pointer.\r
-  @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
-                            that the driver should allocate for the network interface.\r
-                            Some network interfaces will not be able to use the extra\r
-                            buffer, and the caller will not know if it is actually\r
-                            being used.\r
-  @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
-                            that the driver should allocate for the network interface.\r
-                            Some network interfaces will not be able to use the extra\r
-                            buffer, and the caller will not know if it is actually\r
-                            being used.\r
-\r
-  @retval EFI_SUCCESS           The network interface was initialized.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_OUT_OF_RESOURCES  There was not enough memory for the transmit and\r
-                                receive buffers.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_INITIALIZE)(\r
-  IN EMU_SNP_PROTOCOL                    *This,\r
-  IN UINTN                               ExtraRxBufferSize  OPTIONAL,\r
-  IN UINTN                               ExtraTxBufferSize  OPTIONAL\r
-  );\r
-\r
-/**\r
-  Resets a network adapter and re-initializes it with the parameters that were \r
-  provided in the previous call to Initialize().  \r
-\r
-  @param  This                 The protocol instance pointer.\r
-  @param  ExtendedVerification Indicates that the driver may perform a more\r
-                               exhaustive verification operation of the device\r
-                               during reset.\r
-\r
-  @retval EFI_SUCCESS           The network interface was reset.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_RESET)(\r
-  IN EMU_SNP_PROTOCOL   *This,\r
-  IN BOOLEAN            ExtendedVerification\r
-  );\r
-\r
-/**\r
-  Resets a network adapter and leaves it in a state that is safe for \r
-  another driver to initialize.\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           The network interface was shutdown.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_SHUTDOWN)(\r
-  IN EMU_SNP_PROTOCOL  *This\r
-  );\r
-\r
-/**\r
-  Manages the multicast receive filters of a network interface.\r
-\r
-  @param  This             The protocol instance pointer.\r
-  @param  Enable           A bit mask of receive filters to enable on the network interface.\r
-  @param  Disable          A bit mask of receive filters to disable on the network interface.\r
-  @param  ResetMCastFilter Set to TRUE to reset the contents of the multicast receive\r
-                           filters on the network interface to their default values.\r
-  @param  McastFilterCnt   Number of multicast HW MAC addresses in the new\r
-                           MCastFilter list. This value must be less than or equal to\r
-                           the MCastFilterCnt field of EMU_SNP_MODE. This\r
-                           field is optional if ResetMCastFilter is TRUE.\r
-  @param  MCastFilter      A pointer to a list of new multicast receive filter HW MAC\r
-                           addresses. This list will replace any existing multicast\r
-                           HW MAC address list. This field is optional if\r
-                           ResetMCastFilter is TRUE.\r
-\r
-  @retval EFI_SUCCESS           The multicast receive filter list was updated.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_RECEIVE_FILTERS)(\r
-  IN EMU_SNP_PROTOCOL                             *This,\r
-  IN UINT32                                       Enable,\r
-  IN UINT32                                       Disable,\r
-  IN BOOLEAN                                      ResetMCastFilter,\r
-  IN UINTN                                        MCastFilterCnt     OPTIONAL,\r
-  IN EFI_MAC_ADDRESS                              *MCastFilter OPTIONAL\r
-  );\r
-\r
-/**\r
-  Modifies or resets the current station address, if supported.\r
-\r
-  @param  This  The protocol instance pointer.\r
-  @param  Reset Flag used to reset the station address to the network interfaces\r
-                permanent address.\r
-  @param  New   The new station address to be used for the network interface.\r
-\r
-  @retval EFI_SUCCESS           The network interfaces station address was updated.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_STATION_ADDRESS)(\r
-  IN EMU_SNP_PROTOCOL            *This,\r
-  IN BOOLEAN                     Reset,\r
-  IN EFI_MAC_ADDRESS             *New OPTIONAL\r
-  );\r
-\r
-/**\r
-  Resets or collects the statistics on a network interface.\r
-\r
-  @param  This            Protocol instance pointer.\r
-  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
-  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
-                          output the size, in bytes, of the resulting table of\r
-                          statistics.\r
-  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
-                          contains the statistics.\r
-\r
-  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
-                                size needed to hold the statistics is returned in\r
-                                StatisticsSize.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_STATISTICS)(\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN BOOLEAN                              Reset,\r
-  IN OUT UINTN                            *StatisticsSize   OPTIONAL,\r
-  OUT EFI_NETWORK_STATISTICS              *StatisticsTable  OPTIONAL\r
-  );\r
-\r
-/**\r
-  Converts a multicast IP address to a multicast HW MAC address.\r
-\r
-  @param  This The protocol instance pointer.\r
-  @param  IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
-               to FALSE if the multicast IP address is IPv4 [RFC 791].\r
-  @param  IP   The multicast IP address that is to be converted to a multicast\r
-               HW MAC address.\r
-  @param  MAC  The multicast HW MAC address that is to be generated from IP.\r
-\r
-  @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast\r
-                                HW MAC address.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
-                                size needed to hold the statistics is returned in\r
-                                StatisticsSize.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_MCAST_IP_TO_MAC)(\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN BOOLEAN                              IPv6,\r
-  IN EFI_IP_ADDRESS                       *IP,\r
-  OUT EFI_MAC_ADDRESS                     *MAC\r
-  );\r
-\r
-/**\r
-  Performs read and write operations on the NVRAM device attached to a \r
-  network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  ReadWrite  TRUE for read operations, FALSE for write operations.\r
-  @param  Offset     Byte offset in the NVRAM device at which to start the read or\r
-                     write operation. This must be a multiple of NvRamAccessSize and\r
-                     less than NvRamSize.\r
-  @param  BufferSize The number of bytes to read or write from the NVRAM device.\r
-                     This must also be a multiple of NvramAccessSize.\r
-  @param  Buffer     A pointer to the data buffer.\r
-\r
-  @retval EFI_SUCCESS           The NVRAM access was performed.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_NVDATA)(\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN BOOLEAN                              ReadWrite,\r
-  IN UINTN                                Offset,\r
-  IN UINTN                                BufferSize,\r
-  IN OUT VOID                             *Buffer\r
-  );\r
-\r
-/**\r
-  Reads the current interrupt status and recycled transmit buffer status from \r
-  a network interface.\r
-\r
-  @param  This            The protocol instance pointer.\r
-  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
-                          If this is NULL, the interrupt status will not be read from\r
-                          the device. If this is not NULL, the interrupt status will\r
-                          be read from the device. When the  interrupt status is read,\r
-                          it will also be cleared. Clearing the transmit  interrupt\r
-                          does not empty the recycled transmit buffer array.\r
-  @param  TxBuf           Recycled transmit buffer address. The network interface will\r
-                          not transmit if its internal recycled transmit buffer array\r
-                          is full. Reading the transmit buffer does not clear the\r
-                          transmit interrupt. If this is NULL, then the transmit buffer\r
-                          status will not be read. If there are no transmit buffers to\r
-                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
-\r
-  @retval EFI_SUCCESS           The status of the network interface was retrieved.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_GET_STATUS)(\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  OUT UINT32                              *InterruptStatus OPTIONAL,\r
-  OUT VOID                                **TxBuf OPTIONAL\r
-  );\r
-\r
-/**\r
-  Places a packet in the transmit queue of a network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
-                     the Transmit() function. If HeaderSize is non-zero, then it\r
-                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
-                     and Protocol parameters must not be NULL.\r
-  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
-                     data) to be transmitted through the network interface.\r
-  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
-                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
-                     then the media header in Buffer must already be filled in by the\r
-                     caller. If HeaderSize is non-zero, then the media header will be\r
-                     filled in by the Transmit() function.\r
-  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
-                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
-                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
-  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
-                     parameter is ignored.\r
-  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
-                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
-                     examples.\r
-\r
-  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_NOT_READY         The network interface is too busy to accept this transmit request.                      \r
-  @retval EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_TRANSMIT)(\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN UINTN                                HeaderSize,\r
-  IN UINTN                                BufferSize,\r
-  IN VOID                                 *Buffer,\r
-  IN EFI_MAC_ADDRESS                      *SrcAddr  OPTIONAL,\r
-  IN EFI_MAC_ADDRESS                      *DestAddr OPTIONAL,\r
-  IN UINT16                               *Protocol OPTIONAL\r
-  );\r
-\r
-/**\r
-  Receives a packet from a network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  HeaderSize The size, in bytes, of the media header received on the network\r
-                     interface. If this parameter is NULL, then the media header size\r
-                     will not be returned.\r
-  @param  BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
-                     bytes, of the packet that was received on the network interface.\r
-  @param  Buffer     A pointer to the data buffer to receive both the media header and\r
-                     the data.\r
-  @param  SrcAddr    The source HW MAC address. If this parameter is NULL, the\r
-                     HW MAC source address will not be extracted from the media\r
-                     header.\r
-  @param  DestAddr   The destination HW MAC address. If this parameter is NULL,\r
-                     the HW MAC destination address will not be extracted from the\r
-                     media header.\r
-  @param  Protocol   The media header type. If this parameter is NULL, then the\r
-                     protocol will not be extracted from the media header. See\r
-                     RFC 1700 section "Ether Types" for examples.\r
-\r
-  @retval  EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
-                                 been updated to the number of bytes received.\r
-  @retval  EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
-                                 request.\r
-  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval  EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval  EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_SNP_RECEIVE)(\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  OUT UINTN                               *HeaderSize OPTIONAL,\r
-  IN OUT UINTN                            *BufferSize,\r
-  OUT VOID                                *Buffer,\r
-  OUT EFI_MAC_ADDRESS                     *SrcAddr    OPTIONAL,\r
-  OUT EFI_MAC_ADDRESS                     *DestAddr   OPTIONAL,\r
-  OUT UINT16                              *Protocol   OPTIONAL\r
-  );\r
-\r
-#define EMU_SNP_PROTOCOL_REVISION  0x00010000\r
-\r
-//\r
-// Revision defined in EFI1.1\r
-// \r
-#define EMU_SNP_INTERFACE_REVISION   EMU_SNP_PROTOCOL_REVISION\r
-\r
-///\r
-/// The EMU_SNP_PROTOCOL protocol abstracts OS network sercices \r
-/// from the EFI driver that produces EFI Simple Network Protocol.\r
-///\r
-struct _EMU_SNP_PROTOCOL {\r
-  EMU_SNP_CREATE_MAPPING   CreateMapping;\r
-  EMU_SNP_START            Start;\r
-  EMU_SNP_STOP             Stop;\r
-  EMU_SNP_INITIALIZE       Initialize;\r
-  EMU_SNP_RESET            Reset;\r
-  EMU_SNP_SHUTDOWN         Shutdown;\r
-  EMU_SNP_RECEIVE_FILTERS  ReceiveFilters;\r
-  EMU_SNP_STATION_ADDRESS  StationAddress;\r
-  EMU_SNP_STATISTICS       Statistics;\r
-  EMU_SNP_MCAST_IP_TO_MAC  MCastIpToMac;\r
-  EMU_SNP_NVDATA           NvData;\r
-  EMU_SNP_GET_STATUS       GetStatus;\r
-  EMU_SNP_TRANSMIT         Transmit;\r
-  EMU_SNP_RECEIVE          Receive;\r
-};\r
-\r
-extern EFI_GUID gEmuSnpProtocolGuid;\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/Include/Protocol/EmuThread.h b/InOsEmuPkg/Include/Protocol/EmuThread.h
deleted file mode 100644 (file)
index e518bb1..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/** @file\r
-  Emulator Thunk to abstract OS services from pure EFI code\r
-\r
-  Copyright (c) 2010 - 2011, Apple Inc. All rights reserved.<BR>\r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __EMU_THREAD_THUNK__\r
-#define __EMU_THREAD_THUNK__\r
-\r
-\r
-typedef struct _EMU_THREAD_THUNK_PROTOCOL  EMU_THREAD_THUNK_PROTOCOL;\r
-\r
-\r
-typedef\r
-UINTN\r
-(EFIAPI *THREAD_THUNK_MUTEX_LOCK) (\r
-  IN VOID *Mutex\r
-  );\r
-\r
-\r
-typedef\r
-UINTN\r
-(EFIAPI *THREAD_THUNK_MUTEX_UNLOCK) (\r
-  IN VOID *Mutex\r
-  );\r
-\r
-\r
-typedef\r
-UINTN\r
-(EFIAPI *THREAD_THUNK_MUTEX_TRY_LOCK) (\r
-  IN VOID *Mutex\r
-  );\r
-\r
-\r
-typedef\r
-VOID *\r
-(EFIAPI *THREAD_THUNK_MUTEX_INIT) (\r
-  IN VOID\r
-  );\r
-\r
-\r
-typedef\r
-UINTN\r
-(EFIAPI *THREAD_THUNK_MUTEX_DISTROY) (\r
-  IN VOID *Mutex\r
-  );\r
-\r
-\r
-\r
-typedef\r
-VOID *\r
-(EFIAPI *THREAD_THUNK_THREAD_ENTRY) (\r
-  IN  VOID *Context\r
-  );\r
-\r
-typedef\r
-UINTN\r
-(EFIAPI *THREAD_THUNK_CREATE_THREAD) (\r
-  IN  VOID                      *Thread,\r
-  IN  VOID                      *Attribute,\r
-  IN  THREAD_THUNK_THREAD_ENTRY Start,\r
-  IN  VOID                      *Context\r
-  );\r
-\r
-typedef\r
-VOID\r
-(EFIAPI *THREAD_THUNK_EXIT_THREAD) (\r
-  IN VOID *ValuePtr\r
-  );\r
-\r
-\r
-typedef\r
-UINTN\r
-(EFIAPI *THREAD_THUNK_SELF) (\r
-  VOID\r
-  );\r
-\r
-\r
-struct _EMU_THREAD_THUNK_PROTOCOL {\r
-  THREAD_THUNK_MUTEX_LOCK       MutexLock;\r
-  THREAD_THUNK_MUTEX_UNLOCK     MutexUnlock;\r
-  THREAD_THUNK_MUTEX_TRY_LOCK   MutexTryLock;\r
-  THREAD_THUNK_MUTEX_INIT       MutexInit;\r
-  THREAD_THUNK_MUTEX_DISTROY    MutexDistroy;\r
-  THREAD_THUNK_CREATE_THREAD    CreateThread;\r
-  THREAD_THUNK_EXIT_THREAD      ExitThread;\r
-  THREAD_THUNK_SELF             Self;\r
-};\r
-\r
-extern EFI_GUID gEmuThreadThunkProtocolGuid;\r
-\r
-#endif\r
-\r
diff --git a/InOsEmuPkg/Include/Protocol/EmuThunk.h b/InOsEmuPkg/Include/Protocol/EmuThunk.h
deleted file mode 100644 (file)
index 27921b1..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/** @file\r
-  Emulator Thunk to abstract OS services from pure EFI code\r
-\r
-  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-  \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __EMU_THUNK_PROTOCOL_H__\r
-#define __EMU_THUNK_PROTOCOL_H__\r
-\r
-#define EMU_THUNK_PROTOCOL_GUID  \\r
- { 0x5CF32E0B, 0x8EDF, 0x2E44, { 0x9C, 0xDA, 0x93, 0x20, 0x5E, 0x99, 0xEC, 0x1C } }\r
-\r
-// neded for things like EFI_TIME_CAPABILITIES\r
-#include <Uefi.h>\r
-\r
-#include <Library/PeCoffExtraActionLib.h>\r
-\r
-#include <Protocol/EmuIoThunk.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-\r
-typedef struct {\r
-  VENDOR_DEVICE_PATH  VendorDevicePath;\r
-  UINT32              Instance;\r
-} EMU_VENDOR_DEVICE_PATH_NODE;\r
-\r
-typedef struct {\r
-  EMU_VENDOR_DEVICE_PATH_NODE Vendor;\r
-  EFI_DEVICE_PATH_PROTOCOL    EndDevicePath;\r
-} EMU_THUNK_DEVICE_PATH;\r
-\r
-\r
-\r
-typedef struct _EMU_THUNK_PROTOCOL  EMU_THUNK_PROTOCOL;\r
-\r
-\r
-\r
-typedef \r
-UINTN\r
-(EFIAPI *EMU_WRITE_STD_ERROR) (\r
-  IN UINT8     *Buffer,\r
-  IN UINTN     NumberOfBytes\r
-  );  \r
-  \r
-typedef \r
-EFI_STATUS\r
-(EFIAPI *EMU_CONFIG_STD_IN) (\r
-  VOID\r
-  );\r
-  \r
-typedef \r
-UINTN\r
-(EFIAPI *EMU_WRITE_STD_OUT) (\r
-  IN UINT8     *Buffer,\r
-  IN UINTN     NumberOfBytes\r
-  );\r
-  \r
-typedef \r
-UINTN\r
-(EFIAPI *EMU_READ_STD_IN) (\r
-  OUT UINT8     *Buffer,\r
-  IN  UINTN     NumberOfBytes\r
-  );\r
-\r
-typedef \r
-BOOLEAN\r
-(EFIAPI *EMU_POLL_STD_IN) (\r
-  VOID\r
-  );\r
-\r
-\r
-typedef\r
-VOID *\r
-(EFIAPI *EMU_OS_MALLOC) (\r
-  IN  UINTN Size\r
-  );\r
-\r
-typedef\r
-VOID *\r
-(EFIAPI *EMU_OS_VMALLOC) (\r
-  IN  UINTN Size\r
-  );\r
-  \r
-typedef \r
-BOOLEAN\r
-(EFIAPI *EMU_OS_FREE) (\r
-  IN  VOID *Ptr\r
-  );\r
-\r
-\r
-typedef \r
-EFI_STATUS\r
-(EFIAPI *EMU_PE_COFF_GET_ENTRY_POINT) (\r
-  IN     VOID  *Pe32Data,\r
-  IN OUT VOID  **EntryPoint\r
-  );\r
-\r
-typedef \r
-VOID\r
-(EFIAPI *EMU_PE_COFF_RELOCATE_EXTRA_ACTION) (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  );\r
-\r
-typedef \r
-VOID\r
-(EFIAPI *EMU_PE_COFF_UNLOAD_EXTRA_ACTION) (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  );\r
-\r
-typedef\r
-VOID\r
-(EFIAPI *EMU_ENABLE_INERRUPTS) (\r
-  VOID\r
-  );\r
-  \r
-typedef\r
-VOID\r
-(EFIAPI *EMU_DISABLE_INERRUPTS) (\r
-  VOID\r
-  );\r
-\r
-typedef\r
-UINT64\r
-(EFIAPI *EMU_QUERY_PERFORMANCE_FREQENCY) (\r
-  VOID\r
-  );\r
-\r
-typedef\r
-UINT64\r
-(EFIAPI *EMU_QUERY_PERFORMANCE_COUNTER) (\r
-  VOID\r
-  );\r
-\r
-typedef\r
-VOID\r
-(EFIAPI *EMU_SLEEP) (\r
-  IN  UINT64    Milliseconds\r
-  );\r
-\r
-typedef\r
-VOID\r
-(EFIAPI *EMU_CPU_SLEEP) (\r
-  VOID\r
-  );\r
-\r
-typedef\r
-VOID\r
-(EFIAPI *EMU_EXIT) (\r
-  IN  UINTN    Status\r
-  );\r
-  \r
-typedef\r
-VOID\r
-(EFIAPI *EMU_GET_TIME) (\r
-  OUT  EFI_TIME               *Time,\r
-  OUT EFI_TIME_CAPABILITIES   *Capabilities OPTIONAL\r
-  );\r
-  \r
-typedef\r
-VOID\r
-(EFIAPI *EMU_SET_TIME) (\r
-  IN   EFI_TIME               *Time\r
-  );\r
-\r
-\r
-typedef\r
-VOID\r
-(EFIAPI EMU_SET_TIMER_CALLBACK) (\r
-  IN  UINT64  DeltaMs\r
-  );\r
-\r
-typedef\r
-VOID\r
-(EFIAPI *EMU_SET_TIMER) (\r
-  IN  UINT64                  PeriodMs,\r
-  IN  EMU_SET_TIMER_CALLBACK  CallBack\r
-  );\r
-  \r
-\r
-\r
-/**\r
-  Enumerates the current set of protocol instances that abstract OS services from EFI.\r
-  \r
-  A given protocol can have multiple instances. Usually a protocol is configured via a\r
-  single PCD string. The data associated for each instance is seperated via a ! in the string. \r
-  EMU_IO_THUNK_PROTOCOL_CLOSE.ConfigString will contain the information in the PCD string up to the next !.\r
-  Thus each instance has a unique ConfigString. \r
-\r
-  @param  EmuBusDriver          TRUE means only return protocol instances that need to be produced\r
-                                by the EmuBusDriver. FALSE means return all possible protocols\r
-  @param  Instance              On input the protocol to search for, or NULL to start a search \r
-                                of all the supported protocol instances. \r
-  @param  NextProtocol          On output it represents the next value to be passed into Protocol. \r
-  @param  Interface             A pointer to the EMU_IO_THUNK_PROTOCOL_CLOSE interface. \r
-\r
-  @retval EFI_SUCCESS           The function completed successfully.\r
-  @retval EFI_NOT_FOUND         The next protocol instance was not found.\r
-  @retval EFI_INVALID_PARAMETER Instance is NULL.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EMU_GET_NEXT_PROTOCOL) (\r
-  IN  BOOLEAN                 EmuBusDriver,\r
-  OUT EMU_IO_THUNK_PROTOCOL   **Instance  OPTIONAL\r
-  );\r
-  \r
-\r
-struct _EMU_THUNK_PROTOCOL {\r
-  // Used for early debug printing\r
-  EMU_WRITE_STD_ERROR               WriteStdErr;\r
-  EMU_CONFIG_STD_IN                 ConfigStdIn;\r
-  EMU_WRITE_STD_OUT                 WriteStdOut;\r
-  EMU_READ_STD_IN                   ReadStdIn;\r
-  EMU_POLL_STD_IN                   PollStdIn;\r
-  \r
-  //\r
-  // Map OS malloc/free so we can use OS based guard malloc\r
-  //\r
-  EMU_OS_MALLOC                     Malloc;\r
-  EMU_OS_VMALLOC                    Valloc;\r
-  EMU_OS_FREE                       Free;\r
-  \r
-  \r
-  ///\r
-  /// PE/COFF loader hooks to get symbols loaded\r
-  ///\r
-  EMU_PE_COFF_GET_ENTRY_POINT       PeCoffGetEntryPoint;\r
-  EMU_PE_COFF_RELOCATE_EXTRA_ACTION PeCoffRelocateImageExtraAction;\r
-  EMU_PE_COFF_UNLOAD_EXTRA_ACTION   PeCoffUnloadImageExtraAction;\r
-  \r
-  ///\r
-  /// DXE Architecture Protocol Services\r
-  ///\r
-  EMU_ENABLE_INERRUPTS              EnableInterrupt;\r
-  EMU_DISABLE_INERRUPTS             DisableInterrupt;\r
-  EMU_QUERY_PERFORMANCE_FREQENCY    QueryPerformanceFrequency;\r
-  EMU_QUERY_PERFORMANCE_COUNTER     QueryPerformanceCounter;\r
-\r
-  EMU_SLEEP                         Sleep;\r
-  EMU_CPU_SLEEP                     CpuSleep;\r
-  EMU_EXIT                          Exit;\r
-  EMU_GET_TIME                      GetTime;                \r
-  EMU_SET_TIME                      SetTime;\r
-  EMU_SET_TIMER                     SetTimer;  \r
-  \r
-  ///\r
-  /// Generic System Services\r
-  ///\r
-  EMU_GET_NEXT_PROTOCOL             GetNextProtocol;\r
-};\r
-\r
-extern EFI_GUID gEmuThunkProtocolGuid;\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c b/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c
deleted file mode 100644 (file)
index ba625ae..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/** @file\r
-  Null Platform Hook Library instance.\r
-\r
-  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <Base.h>\r
-\r
-#include <Protocol/EmuThunk.h>\r
-#include <Protocol/EmuGraphicsWindow.h>\r
-#include <Protocol/EmuBlockIo.h>\r
-#include <Protocol/SimpleFileSystem.h>\r
-#include <Protocol/EmuThread.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DevicePathToTextLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-\r
-/**\r
-  Converts a Vendor device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-  @return EFI_NOT_FOUND if no string representation exists.\r
-  @return EFI_SUCCESS   a string representation was created.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DevPathToTextVendorLib (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  EMU_VENDOR_DEVICE_PATH_NODE  *Vendor;\r
-  CHAR16                       *Type;\r
-\r
-  Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *)DevPath;\r
-  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThunkProtocolGuid)) {\r
-    CatPrint (Str, L"EmuThunk()");\r
-    return EFI_SUCCESS;\r
-  }\r
-  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuGraphicsWindowProtocolGuid)) {\r
-    CatPrint (Str, L"EmuGraphics(%d)", Vendor->Instance);\r
-    return EFI_SUCCESS;\r
-  }\r
-  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid)) {\r
-    CatPrint (Str, L"EmuFs(%d)", Vendor->Instance);\r
-    return EFI_SUCCESS;\r
-  }\r
-  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuBlockIoProtocolGuid)) {\r
-    CatPrint (Str, L"EmuBlk(%d)", Vendor->Instance);\r
-    return EFI_SUCCESS;\r
-  }\r
-  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThreadThunkProtocolGuid)) {\r
-    CatPrint (Str, L"EmuThread()");\r
-    return EFI_SUCCESS;\r
-  }\r
-  \r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Hardware Vendor device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Hardware Vendor device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextEmuThunk (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16              *Str;\r
-  VENDOR_DEVICE_PATH  *Vendor;\r
-\r
-  Str    = GetNextParamStr (&TextDeviceNode);\r
-  Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
-                                     HARDWARE_DEVICE_PATH,\r
-                                     HW_VENDOR_DP,\r
-                                     (UINT16) sizeof (VENDOR_DEVICE_PATH)\r
-                                     );\r
-  CopyGuid (&Vendor->Guid, &gEmuThunkProtocolGuid);\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Hardware Vendor device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Hardware Vendor device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextEmuThread (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16              *Str;\r
-  VENDOR_DEVICE_PATH  *Vendor;\r
-\r
-  Str    = GetNextParamStr (&TextDeviceNode);\r
-  Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
-                                     HARDWARE_DEVICE_PATH,\r
-                                     HW_VENDOR_DP,\r
-                                     (UINT16) sizeof (VENDOR_DEVICE_PATH)\r
-                                     );\r
-  CopyGuid (&Vendor->Guid, &gEmuThreadThunkProtocolGuid);\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Hardware Vendor device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Hardware Vendor device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextEmuFs (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                       *Str;\r
-  EMU_VENDOR_DEVICE_PATH_NODE  *Vendor;\r
-\r
-  Str = GetNextParamStr (&TextDeviceNode);\r
-  Vendor    = (EMU_VENDOR_DEVICE_PATH_NODE *) CreateDeviceNode (\r
-                                                   HARDWARE_DEVICE_PATH,\r
-                                                   HW_VENDOR_DP,\r
-                                                   (UINT16) sizeof (EMU_VENDOR_DEVICE_PATH_NODE)\r
-                                                   );\r
-  CopyGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid);\r
-  Vendor->Instance = (UINT32) StrDecimalToUintn (Str);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
-}\r
-\r
-/**\r
-  Register the Filter function\r
-  \r
-  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
-  @param  SystemTable   A pointer to the EFI System Table.\r
-  \r
-  @retval EFI_SUCCESS   The constructor executed correctly.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DevicePathToTextLibConstructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-\r
-{\r
-  DevPathToTextSetVendorDevicePathFilter (DevPathToTextVendorLib);\r
-  DevicePathFromTextAddFilter (L"EmuThunk", DevPathFromTextEmuThunk);\r
-  DevicePathFromTextAddFilter (L"EmuThread", DevPathFromTextEmuThread);\r
-  DevicePathFromTextAddFilter (L"EmuFs", DevPathFromTextEmuFs);\r
-  return EFI_SUCCESS;\r
-}
\ No newline at end of file
diff --git a/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf b/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
deleted file mode 100644 (file)
index 2895b39..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-## @file\r
-#  Null DevicePathToText library.\r
-#\r
-#  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DevicePathTextLib\r
-  FILE_GUID                      = DCD1F939-1732-CA4D-81B7-C757AEC84DBC\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = NULL|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE\r
-  CONSTRUCTOR                    = DevicePathToTextLibConstructor\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  DevicePathTextLib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  DebugLib\r
-  DevicePathLib\r
-\r
-[Protocols]\r
-  gEmuThunkProtocolGuid\r
-  gEmuGraphicsWindowProtocolGuid\r
-  gEfiSimpleFileSystemProtocolGuid\r
-  gEmuBlockIoProtocolGuid\r
-  gEmuThreadThunkProtocolGuid
\ No newline at end of file
diff --git a/InOsEmuPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c b/InOsEmuPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c
deleted file mode 100644 (file)
index db3b313..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/** @file\r
-  A non-functional instance of the Timer Library.\r
-\r
-  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiPei.h>\r
-#include <Library/TimerLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/EmuThunkLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-\r
-#include <Protocol/Timer.h>\r
-\r
-\r
-\r
-/**\r
-  Stalls the CPU for at least the given number of microseconds.\r
-\r
-  Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
-\r
-  @param  MicroSeconds  The minimum number of microseconds to delay.\r
-\r
-  @return The value of MicroSeconds inputted.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-MicroSecondDelay (\r
-  IN      UINTN                     MicroSeconds\r
-  )\r
-{\r
-  return NanoSecondDelay (MicroSeconds * 1000);\r
-}\r
-\r
-\r
-/**\r
-  Stalls the CPU for at least the given number of nanoseconds.\r
-\r
-  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
-\r
-  @param  NanoSeconds The minimum number of nanoseconds to delay.\r
-\r
-  @return The value of NanoSeconds inputted.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-NanoSecondDelay (\r
-  IN      UINTN                     NanoSeconds\r
-  )\r
-{\r
-  gEmuThunk->Sleep (NanoSeconds);\r
-  return NanoSeconds;\r
-}\r
-\r
-\r
-/**\r
-  Retrieves the current value of a 64-bit free running performance counter.\r
-\r
-  The counter can either count up by 1 or count down by 1. If the physical\r
-  performance counter counts by a larger increment, then the counter values\r
-  must be translated. The properties of the counter can be retrieved from\r
-  GetPerformanceCounterProperties().\r
-\r
-  @return The current value of the free running performance counter.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-GetPerformanceCounter (\r
-  VOID\r
-  )\r
-{\r
-  return gEmuThunk->QueryPerformanceCounter ();\r
-}\r
-\r
-/**\r
-  Retrieves the 64-bit frequency in Hz and the range of performance counter\r
-  values.\r
-\r
-  If StartValue is not NULL, then the value that the performance counter starts\r
-  with immediately after is it rolls over is returned in StartValue. If\r
-  EndValue is not NULL, then the value that the performance counter end with\r
-  immediately before it rolls over is returned in EndValue. The 64-bit\r
-  frequency of the performance counter in Hz is always returned. If StartValue\r
-  is less than EndValue, then the performance counter counts up. If StartValue\r
-  is greater than EndValue, then the performance counter counts down. For\r
-  example, a 64-bit free running counter that counts up would have a StartValue\r
-  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
-  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
-\r
-  @param  StartValue  The value the performance counter starts with when it\r
-                      rolls over.\r
-  @param  EndValue    The value that the performance counter ends with before\r
-                      it rolls over.\r
-\r
-  @return The frequency in Hz.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-GetPerformanceCounterProperties (\r
-  OUT      UINT64                    *StartValue,  OPTIONAL\r
-  OUT      UINT64                    *EndValue     OPTIONAL\r
-  )\r
-{\r
-\r
-  if (StartValue != NULL) {\r
-    *StartValue = 0ULL;\r
-  }\r
-  if (EndValue != NULL) {\r
-    *EndValue = (UINT64)-1LL;\r
-  }\r
-  \r
-  return gEmuThunk->QueryPerformanceFrequency ();\r
-}\r
-\r
-\r
diff --git a/InOsEmuPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.inf b/InOsEmuPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.inf
deleted file mode 100644 (file)
index 52d8394..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-## @file\r
-#  NULL instance of Timer Library as a template.\r
-#\r
-#  A non-functional instance of the Timer Library that can be used as a template\r
-#  for the implementation of a functional timer library instance. This library instance can\r
-#  also be used to test build DXE, Runtime, DXE SAL, and DXE SMM modules that require timer\r
-#  services as well as EBC modules that require timer services.\r
-#\r
-#  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuDxeCodeTimerLib\r
-  FILE_GUID                      = FB184AF4-A2F2-EE4E-8885-E81E5D8B0135\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = TimerLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  DxeCoreTimerLib.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  DebugLib\r
-  EmuThunkLib\r
-  \r
diff --git a/InOsEmuPkg/Library/DxeEmuLib/DxeEmuLib.c b/InOsEmuPkg/Library/DxeEmuLib/DxeEmuLib.c
deleted file mode 100644 (file)
index 2e42ea6..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/EmuThunkLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-\r
-EMU_THUNK_PROTOCOL   *gEmuThunk = NULL;\r
-\r
-\r
-/**\r
-  The constructor function caches the pointer of EMU Thunk protocol.\r
-\r
-  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
-  @param  SystemTable   A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DxeEmuLibConstructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  EFI_HOB_GUID_TYPE        *GuidHob;\r
-\r
-  GuidHob = GetFirstGuidHob (&gEmuThunkProtocolGuid);\r
-  ASSERT (GuidHob != NULL);\r
-  \r
-  gEmuThunk = (EMU_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r
-  ASSERT (gEmuThunk != NULL);\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Serach the EMU IO Thunk database for a matching EMU IO Thunk \r
-  Protocol instance.\r
-\r
-  @param  Protocol   Protocol to search for.\r
-  @param  Instance   Instance of protocol to search for.\r
-\r
-  @retval NULL       Protocol and Instance not found.\r
-  @retval other      EMU IO Thunk protocol that matched.\r
-\r
-**/\r
-EMU_IO_THUNK_PROTOCOL *\r
-EFIAPI\r
-GetIoThunkInstance (\r
-  IN  EFI_GUID  *Protocol,\r
-  IN  UINTN     Instance\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_IO_THUNK_PROTOCOL   *EmuIoThunk;\r
-  \r
-  for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) {\r
-    Status = gEmuThunk->GetNextProtocol (FALSE, &EmuIoThunk);\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-  \r
-    if (EmuIoThunk->Instance == Instance) {\r
-      if (CompareGuid (EmuIoThunk->Protocol, Protocol)) {\r
-        return EmuIoThunk;\r
-      }\r
-    }\r
-  }\r
-  \r
-  return NULL;\r
-}
\ No newline at end of file
diff --git a/InOsEmuPkg/Library/DxeEmuLib/DxeEmuLib.inf b/InOsEmuPkg/Library/DxeEmuLib/DxeEmuLib.inf
deleted file mode 100644 (file)
index 0f7f0dd..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-## @file\r
-# A library to produce the global variable 'gEmuThunk'\r
-#\r
-# This library contains a single global variable 'gEmuThunk' along with a constructor to \r
-# initialize that global.\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DxeEmuLib\r
-  FILE_GUID                      = 31479AFD-B06F-4E4A-863B-A8F7E7710778\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = EmuThunkLib \r
-\r
-  CONSTRUCTOR                    = DxeEmuLibConstructor\r
-\r
-\r
-[Sources]\r
-  DxeEmuLib.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  HobLib\r
-  DebugLib\r
-  BaseMemoryLib\r
-\r
-\r
-[Protocols]\r
-  gEmuThunkProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED\r
-\r
diff --git a/InOsEmuPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.c b/InOsEmuPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.c
deleted file mode 100644 (file)
index fdb8d53..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/** @file\r
-  Provides services to perform additional actions to relocate and unload\r
-  PE/Coff image for Emu environment specific purpose such as souce level debug.\r
-  This version only works for DXE phase  \r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/EmuThunk.h>\r
-\r
-#include <Library/PeCoffLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/PeCoffExtraActionLib.h>\r
-\r
-//\r
-// Cache of UnixThunk protocol \r
-//\r
-EMU_THUNK_PROTOCOL   *mThunk = NULL;\r
-\r
-\r
-/**\r
-  The constructor function gets  the pointer of the WinNT thunk functions\r
-  It will ASSERT() if Unix thunk protocol is not installed.\r
-\r
-  @retval EFI_SUCCESS   Unix thunk protocol is found and cached.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DxeEmuPeCoffLibExtraActionConstructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-   EFI_HOB_GUID_TYPE        *GuidHob;\r
-\r
-  //\r
-  // Retrieve EmuThunkProtocol from GUID'ed HOB\r
-  //\r
-  GuidHob = GetFirstGuidHob (&gEmuThunkProtocolGuid);\r
-  ASSERT (GuidHob != NULL);\r
-  mThunk = (EMU_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));\r
-  ASSERT (mThunk != NULL);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Performs additional actions after a PE/COFF image has been loaded and relocated.\r
-\r
-  If ImageContext is NULL, then ASSERT().\r
-\r
-  @param  ImageContext  Pointer to the image context structure that describes the\r
-                        PE/COFF image that has already been loaded and relocated.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PeCoffLoaderRelocateImageExtraAction (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  )\r
-{\r
-  if (mThunk != NULL) {\r
-    mThunk->PeCoffRelocateImageExtraAction (ImageContext);\r
-  }\r
-}\r
-\r
-\r
-\r
-/**\r
-  Performs additional actions just before a PE/COFF image is unloaded.  Any resources\r
-  that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.\r
-  \r
-  If ImageContext is NULL, then ASSERT().\r
-  \r
-  @param  ImageContext  Pointer to the image context structure that describes the\r
-                        PE/COFF image that is being unloaded.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PeCoffLoaderUnloadImageExtraAction (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  )\r
-{\r
-  if (mThunk != NULL) {\r
-    mThunk->PeCoffUnloadImageExtraAction (ImageContext);\r
-  }\r
-}\r
diff --git a/InOsEmuPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf b/InOsEmuPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf
deleted file mode 100644 (file)
index 7c1b4ca..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-## @file
-# PeCoff extra action libary for DXE phase that run Emu emulator.
-#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# 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
-# 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.
-
-#
-#
-##
-
-[Defines]
-  INF_VERSION                    = 0x00010005
-  BASE_NAME                      = DxeEmuPeCoffExtraActionLib
-  FILE_GUID                      = 68FCD487-D230-6846-95B1-5E1F2EF942C4
-  MODULE_TYPE                    = DXE_DRIVER
-  VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = PeCoffExtraActionLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER
-
-  CONSTRUCTOR                    = DxeEmuPeCoffLibExtraActionConstructor
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-#  VALID_ARCHITECTURES           = IA32
-#
-
-[Sources]
-  DxeEmuPeCoffExtraActionLib.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  InOsEmuPkg/InOsEmuPkg.dec
-
-[LibraryClasses]
-  DebugLib
-  HobLib
-  BaseMemoryLib
-
-[Protocols]
-  gEmuThunkProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED
-
diff --git a/InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c b/InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
deleted file mode 100644 (file)
index ccf4fa0..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/** @file\r
-  Serial Port Lib that thunks back to Emulator services to write to StdErr. \r
-  All read functions are stubed out. \r
-\r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-#include <PiDxe.h>\r
-#include <Library/SerialPortLib.h>\r
-#include <Library/EmuThunkLib.h>\r
-\r
-\r
-\r
-\r
-/**\r
-  Initialize the serial device hardware.\r
-  \r
-  If no initialization is required, then return RETURN_SUCCESS.\r
-  If the serial device was successfully initialized, then return RETURN_SUCCESS.\r
-  If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.\r
-  \r
-  @retval RETURN_SUCCESS        The serial device was initialized.\r
-  @retval RETURN_DEVICE_ERROR   The serial device could not be initialized.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortInitialize (\r
-  VOID\r
-  )\r
-{\r
-  return gEmuThunk->ConfigStdIn ();\r
-}\r
-\r
-/**\r
-  Write data from buffer to serial device. \r
\r
-  Writes NumberOfBytes data bytes from Buffer to the serial device.  \r
-  The number of bytes actually written to the serial device is returned.\r
-  If the return value is less than NumberOfBytes, then the write operation failed.\r
-  If Buffer is NULL, then ASSERT(). \r
-  If NumberOfBytes is zero, then return 0.\r
-\r
-  @param  Buffer           The pointer to the data buffer to be written.\r
-  @param  NumberOfBytes    The number of bytes to written to the serial device.\r
-\r
-  @retval 0                NumberOfBytes is 0.\r
-  @retval >0               The number of bytes written to the serial device.  \r
-                           If this value is less than NumberOfBytes, then the read operation failed.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-SerialPortWrite (\r
-  IN UINT8     *Buffer,\r
-  IN UINTN     NumberOfBytes\r
-  )\r
-{\r
-  return gEmuThunk->WriteStdOut (Buffer, NumberOfBytes);\r
-}\r
-\r
-\r
-/**\r
-  Read data from serial device and save the datas in buffer.\r
\r
-  Reads NumberOfBytes data bytes from a serial device into the buffer\r
-  specified by Buffer. The number of bytes actually read is returned. \r
-  If the return value is less than NumberOfBytes, then the rest operation failed.\r
-  If Buffer is NULL, then ASSERT(). \r
-  If NumberOfBytes is zero, then return 0.\r
-\r
-  @param  Buffer           The pointer to the data buffer to store the data read from the serial device.\r
-  @param  NumberOfBytes    The number of bytes which will be read.\r
-\r
-  @retval 0                Read data failed; No data is to be read.\r
-  @retval >0               The actual number of bytes read from serial device.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-SerialPortRead (\r
-  OUT UINT8     *Buffer,\r
-  IN  UINTN     NumberOfBytes\r
-  )\r
-{\r
-  return gEmuThunk->ReadStdIn (Buffer, NumberOfBytes);\r
-}\r
-\r
-/**\r
-  Polls a serial device to see if there is any data waiting to be read.\r
-\r
-  Polls a serial device to see if there is any data waiting to be read.\r
-  If there is data waiting to be read from the serial device, then TRUE is returned.\r
-  If there is no data waiting to be read from the serial device, then FALSE is returned.\r
-\r
-  @retval TRUE             Data is waiting to be read from the serial device.\r
-  @retval FALSE            There is no data waiting to be read from the serial device.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-SerialPortPoll (\r
-  VOID\r
-  )\r
-{\r
-  return gEmuThunk->PollStdIn ();\r
-}\r
-\r
-\r
diff --git a/InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf b/InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf
deleted file mode 100644 (file)
index 0f928dd..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-## @file\r
-#  Write only instance of Serial Port Library with empty functions.\r
-#\r
-#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-#  Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DxeEmuSerialPortLib\r
-  FILE_GUID                      = DF08A29A-F60B-E649-AA79-A1490E863A5D\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = SerialPortLib| DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVE\r
-\r
-\r
-[Sources]\r
-  DxeEmuSerialPortLib.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-  \r
-[LibraryClasses]\r
-  EmuThunkLib\r
-\r
-\r
-\r
-  \r
-\r
diff --git a/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c b/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c
deleted file mode 100644 (file)
index b4ef86e..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/** @file\r
-  Serial Port Lib that thunks back to Emulator services to write to StdErr. \r
-  All read functions are stubed out. \r
-\r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-#include <PiDxe.h>\r
-#include <Library/SerialPortLib.h>\r
-#include <Library/EmuThunkLib.h>\r
-\r
-\r
-\r
-\r
-/**\r
-  Initialize the serial device hardware.\r
-  \r
-  If no initialization is required, then return RETURN_SUCCESS.\r
-  If the serial device was successfully initialized, then return RETURN_SUCCESS.\r
-  If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.\r
-  \r
-  @retval RETURN_SUCCESS        The serial device was initialized.\r
-  @retval RETURN_DEVICE_ERROR   The serial device could not be initialized.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortInitialize (\r
-  VOID\r
-  )\r
-{\r
-  return RETURN_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write data from buffer to serial device. \r
\r
-  Writes NumberOfBytes data bytes from Buffer to the serial device.  \r
-  The number of bytes actually written to the serial device is returned.\r
-  If the return value is less than NumberOfBytes, then the write operation failed.\r
-  If Buffer is NULL, then ASSERT(). \r
-  If NumberOfBytes is zero, then return 0.\r
-\r
-  @param  Buffer           The pointer to the data buffer to be written.\r
-  @param  NumberOfBytes    The number of bytes to written to the serial device.\r
-\r
-  @retval 0                NumberOfBytes is 0.\r
-  @retval >0               The number of bytes written to the serial device.  \r
-                           If this value is less than NumberOfBytes, then the read operation failed.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-SerialPortWrite (\r
-  IN UINT8     *Buffer,\r
-  IN UINTN     NumberOfBytes\r
-  )\r
-{\r
-  return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);\r
-}\r
-\r
-\r
-/**\r
-  Read data from serial device and save the datas in buffer.\r
\r
-  Reads NumberOfBytes data bytes from a serial device into the buffer\r
-  specified by Buffer. The number of bytes actually read is returned. \r
-  If the return value is less than NumberOfBytes, then the rest operation failed.\r
-  If Buffer is NULL, then ASSERT(). \r
-  If NumberOfBytes is zero, then return 0.\r
-\r
-  @param  Buffer           The pointer to the data buffer to store the data read from the serial device.\r
-  @param  NumberOfBytes    The number of bytes which will be read.\r
-\r
-  @retval 0                Read data failed; No data is to be read.\r
-  @retval >0               The actual number of bytes read from serial device.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-SerialPortRead (\r
-  OUT UINT8     *Buffer,\r
-  IN  UINTN     NumberOfBytes\r
-  )\r
-{\r
-  return 0;\r
-}\r
-\r
-/**\r
-  Polls a serial device to see if there is any data waiting to be read.\r
-\r
-  Polls a serial device to see if there is any data waiting to be read.\r
-  If there is data waiting to be read from the serial device, then TRUE is returned.\r
-  If there is no data waiting to be read from the serial device, then FALSE is returned.\r
-\r
-  @retval TRUE             Data is waiting to be read from the serial device.\r
-  @retval FALSE            There is no data waiting to be read from the serial device.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-SerialPortPoll (\r
-  VOID\r
-  )\r
-{\r
-  return FALSE;\r
-}\r
-\r
-\r
diff --git a/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf b/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf
deleted file mode 100644 (file)
index e1b4034..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-## @file\r
-#  Write only instance of Serial Port Library with empty functions.\r
-#\r
-#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-#  Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DxeEmuStdErrSerialPortLib\r
-  FILE_GUID                      = 4EED5138-C512-9E4F-AB13-149B87D40453\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = SerialPortLib| DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVE\r
-\r
-\r
-[Sources]\r
-  DxeEmuStdErrSerialPortLib.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-  \r
-[LibraryClasses]\r
-  EmuThunkLib\r
-\r
-\r
-\r
-  \r
-\r
diff --git a/InOsEmuPkg/Library/DxeTimerLib/DxeTimerLib.c b/InOsEmuPkg/Library/DxeTimerLib/DxeTimerLib.c
deleted file mode 100644 (file)
index 14bb17f..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/** @file\r
-  A non-functional instance of the Timer Library.\r
-\r
-  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiPei.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/TimerLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/EmuThunkLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-\r
-#include <Protocol/Timer.h>\r
-\r
-\r
-STATIC UINT64                  gTimerPeriod = 0;\r
-STATIC EFI_TIMER_ARCH_PROTOCOL *gTimerAp = NULL;\r
-STATIC EFI_EVENT               gTimerEvent = NULL;\r
-STATIC VOID                    *gRegistration = NULL;\r
-\r
-VOID\r
-EFIAPI\r
-RegisterTimerArchProtocol (\r
-  IN EFI_EVENT     Event,\r
-  IN VOID          *Context\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  \r
-  Status = gBS->LocateProtocol (&gEfiTimerArchProtocolGuid, NULL, (VOID **)&gTimerAp);\r
-  if (!EFI_ERROR (Status)) {    \r
-    Status = gTimerAp->GetTimerPeriod (gTimerAp, &gTimerPeriod);\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    // Convert to Nanoseconds.\r
-    gTimerPeriod = MultU64x32 (gTimerPeriod, 100);\r
-    \r
-    if (gTimerEvent == NULL) {\r
-      Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, (VOID **)&gTimerEvent);\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-  }\r
-}\r
-\r
-\r
-\r
-/**\r
-  Stalls the CPU for at least the given number of microseconds.\r
-\r
-  Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
-\r
-  @param  MicroSeconds  The minimum number of microseconds to delay.\r
-\r
-  @return The value of MicroSeconds inputted.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-MicroSecondDelay (\r
-  IN      UINTN                     MicroSeconds\r
-  )\r
-{\r
-  return NanoSecondDelay (MicroSeconds * 1000);\r
-}\r
-\r
-\r
-/**\r
-  Stalls the CPU for at least the given number of nanoseconds.\r
-\r
-  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
-\r
-  @param  NanoSeconds The minimum number of nanoseconds to delay.\r
-\r
-  @return The value of NanoSeconds inputted.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-NanoSecondDelay (\r
-  IN      UINTN                     NanoSeconds\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINT64      HundredNanoseconds;\r
-  UINTN       Index;\r
-  \r
-  if ((gTimerPeriod != 0) && \r
-      ((UINT64)NanoSeconds > gTimerPeriod) && \r
-      (EfiGetCurrentTpl () == TPL_APPLICATION)) {\r
-    //\r
-    // This stall is long, so use gBS->WaitForEvent () to yield CPU to DXE Core\r
-    //\r
-    \r
-    HundredNanoseconds = DivU64x32 (NanoSeconds, 100);\r
-    Status = gBS->SetTimer (gTimerEvent, TimerRelative, HundredNanoseconds);\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    Status = gBS->WaitForEvent (sizeof (gTimerEvent)/sizeof (EFI_EVENT), &gTimerEvent, &Index);\r
-    ASSERT_EFI_ERROR (Status);\r
-  \r
-  } else {\r
-    gEmuThunk->Sleep (NanoSeconds);\r
-  }\r
-  return NanoSeconds;\r
-}\r
-\r
-\r
-/**\r
-  Retrieves the current value of a 64-bit free running performance counter.\r
-\r
-  The counter can either count up by 1 or count down by 1. If the physical\r
-  performance counter counts by a larger increment, then the counter values\r
-  must be translated. The properties of the counter can be retrieved from\r
-  GetPerformanceCounterProperties().\r
-\r
-  @return The current value of the free running performance counter.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-GetPerformanceCounter (\r
-  VOID\r
-  )\r
-{\r
-  return gEmuThunk->QueryPerformanceCounter ();\r
-}\r
-\r
-/**\r
-  Retrieves the 64-bit frequency in Hz and the range of performance counter\r
-  values.\r
-\r
-  If StartValue is not NULL, then the value that the performance counter starts\r
-  with immediately after is it rolls over is returned in StartValue. If\r
-  EndValue is not NULL, then the value that the performance counter end with\r
-  immediately before it rolls over is returned in EndValue. The 64-bit\r
-  frequency of the performance counter in Hz is always returned. If StartValue\r
-  is less than EndValue, then the performance counter counts up. If StartValue\r
-  is greater than EndValue, then the performance counter counts down. For\r
-  example, a 64-bit free running counter that counts up would have a StartValue\r
-  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
-  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
-\r
-  @param  StartValue  The value the performance counter starts with when it\r
-                      rolls over.\r
-  @param  EndValue    The value that the performance counter ends with before\r
-                      it rolls over.\r
-\r
-  @return The frequency in Hz.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-GetPerformanceCounterProperties (\r
-  OUT      UINT64                    *StartValue,  OPTIONAL\r
-  OUT      UINT64                    *EndValue     OPTIONAL\r
-  )\r
-{\r
-\r
-  if (StartValue != NULL) {\r
-    *StartValue = 0ULL;\r
-  }\r
-  if (EndValue != NULL) {\r
-    *EndValue = (UINT64)-1LL;\r
-  }\r
-  \r
-  return gEmuThunk->QueryPerformanceFrequency ();\r
-}\r
-\r
-\r
-/**\r
-  Register for the Timer AP protocol.\r
-\r
-  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
-  @param  SystemTable   A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DxeTimerLibConstructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  EfiCreateProtocolNotifyEvent (\r
-    &gEfiTimerArchProtocolGuid,\r
-    TPL_CALLBACK,\r
-    RegisterTimerArchProtocol,\r
-    NULL,\r
-    &gRegistration\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
diff --git a/InOsEmuPkg/Library/DxeTimerLib/DxeTimerLib.inf b/InOsEmuPkg/Library/DxeTimerLib/DxeTimerLib.inf
deleted file mode 100644 (file)
index ba1e3e2..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-## @file\r
-#  NULL instance of Timer Library as a template.\r
-#\r
-#  A non-functional instance of the Timer Library that can be used as a template\r
-#  for the implementation of a functional timer library instance. This library instance can\r
-#  also be used to test build DXE, Runtime, DXE SAL, and DXE SMM modules that require timer\r
-#  services as well as EBC modules that require timer services.\r
-#\r
-#  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuDxeTimerLib\r
-  FILE_GUID                      = 74B62391-AD0D-1B4D-8784-151404F9D538\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = TimerLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION\r
-\r
-  CONSTRUCTOR                    = DxeTimerLibConstructor\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  DxeTimerLib.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  DebugLib\r
-  EmuThunkLib\r
-  UefiLib\r
-  UefiBootServicesTableLib\r
-  \r
-[Protocols]\r
-  gEfiTimerArchProtocolGuid\r
diff --git a/InOsEmuPkg/Library/EmuBdsLib/BdsPlatform.c b/InOsEmuPkg/Library/EmuBdsLib/BdsPlatform.c
deleted file mode 100644 (file)
index 8f47ef9..0000000
+++ /dev/null
@@ -1,557 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#include "BdsPlatform.h"\r
-\r
-EMU_SYSTEM_CONFIGURATION mSystemConfigData;\r
-\r
-VOID\r
-SetupVariableInit (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  UINTN                           Size;\r
-\r
-  Size = sizeof (mSystemConfigData);\r
-  Status = gRT->GetVariable (\r
-                  L"Setup",\r
-                  &gEmuSystemConfigGuid,\r
-                  NULL,\r
-                  &Size,\r
-                  (VOID *) &mSystemConfigData\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // SetupVariable is corrupt\r
-    //\r
-    mSystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);\r
-    mSystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);\r
-\r
-    Status = gRT->SetVariable (\r
-                    L"Setup",\r
-                    &gEmuSystemConfigGuid,\r
-                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                    sizeof (mSystemConfigData),\r
-                    (VOID *) &mSystemConfigData\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));\r
-    }\r
-  }\r
-}\r
-\r
-//\r
-// BDS Platform Functions\r
-//\r
-VOID\r
-EFIAPI\r
-PlatformBdsInit (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Platform Bds init. Include the platform firmware vendor, revision\r
-  and so crc check.\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
-**/\r
-{\r
-  SetupVariableInit ();\r
-}\r
-\r
-EFI_STATUS\r
-PlatformBdsConnectConsole (\r
-  IN BDS_CONSOLE_CONNECT_ENTRY   *PlatformConsole\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Connect the predefined platform default console device. Always try to find\r
-  and enable the vga device if have.\r
-\r
-Arguments:\r
-\r
-  PlatformConsole         - Predfined platform default console device array.\r
\r
-Returns:\r
-\r
-  EFI_SUCCESS             - Success connect at least one ConIn and ConOut \r
-                            device, there must have one ConOut device is \r
-                            active vga device.\r
-  \r
-  EFI_STATUS              - Return the status of \r
-                            BdsLibConnectAllDefaultConsoles ()\r
-\r
-**/\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       Index;\r
-\r
-  Index   = 0;\r
-  Status  = EFI_SUCCESS;\r
-\r
-  //\r
-  // Have chance to connect the platform default console,\r
-  // the platform default console is the minimue device group\r
-  // the platform should support\r
-  //\r
-  while (PlatformConsole[Index].DevicePath != NULL) {\r
-    //\r
-    // Update the console variable with the connect type\r
-    //\r
-    if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
-      BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);\r
-    }\r
-\r
-    if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
-      BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);\r
-    }\r
-\r
-    if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
-      BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);\r
-    }\r
-\r
-    Index++;\r
-  }\r
-  //\r
-  // Connect the all the default console with current cosole variable\r
-  //\r
-  Status = BdsLibConnectAllDefaultConsoles ();\r
-  return Status;\r
-}\r
-\r
-VOID\r
-PlatformBdsConnectSequence (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Connect with predeined platform connect sequence, \r
-  the OEM/IBV can customize with their own connect sequence.\r
-  \r
-Arguments:\r
-\r
-  None.\r
\r
-Returns:\r
-\r
-  None.\r
-  \r
-**/\r
-{\r
-  UINTN Index;\r
-\r
-  Index = 0;\r
-\r
-  //\r
-  // Here we can get the customized platform connect sequence\r
-  // Notes: we can connect with new variable which record the\r
-  // last time boots connect device path sequence\r
-  //\r
-  while (gPlatformConnectSequence[Index] != NULL) {\r
-    //\r
-    // Build the platform boot option\r
-    //\r
-    BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
-    Index++;\r
-  }\r
-\r
-  //\r
-  // Just use the simple policy to connect all devices\r
-  //\r
-  BdsLibConnectAll ();\r
-}\r
-\r
-VOID\r
-PlatformBdsGetDriverOption (\r
-  IN OUT LIST_ENTRY              *BdsDriverLists\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Load the predefined driver option, OEM/IBV can customize this\r
-  to load their own drivers\r
-  \r
-Arguments:\r
-\r
-  BdsDriverLists  - The header of the driver option link list.\r
\r
-Returns:\r
-\r
-  None.\r
-  \r
-**/\r
-{\r
-  UINTN Index;\r
-\r
-  Index = 0;\r
-\r
-  //\r
-  // Here we can get the customized platform driver option\r
-  //\r
-  while (gPlatformDriverOption[Index] != NULL) {\r
-    //\r
-    // Build the platform boot option\r
-    //\r
-    BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");\r
-    Index++;\r
-  }\r
-\r
-}\r
-\r
-VOID\r
-PlatformBdsDiagnostics (\r
-  IN EXTENDMEM_COVERAGE_LEVEL    MemoryTestLevel,\r
-  IN BOOLEAN                     QuietBoot,\r
-  IN BASEM_MEMORY_TEST           BaseMemoryTest\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Perform the platform diagnostic, such like test memory. OEM/IBV also\r
-  can customize this fuction to support specific platform diagnostic.\r
-  \r
-Arguments:\r
-\r
-  MemoryTestLevel  - The memory test intensive level\r
-  \r
-  QuietBoot        - Indicate if need to enable the quiet boot\r
-\r
-  BaseMemoryTest   - A pointer to BdsMemoryTest()\r
\r
-Returns:\r
-\r
-  None.\r
-  \r
-**/\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Here we can decide if we need to show\r
-  // the diagnostics screen\r
-  // Notes: this quiet boot code should be remove\r
-  // from the graphic lib\r
-  //\r
-  if (QuietBoot) {\r
-    EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
-    //\r
-    // Perform system diagnostic\r
-    //\r
-    Status = BaseMemoryTest (MemoryTestLevel);\r
-    if (EFI_ERROR (Status)) {\r
-      DisableQuietBoot ();\r
-    }\r
-\r
-    return ;\r
-  }\r
-  //\r
-  // Perform system diagnostic\r
-  //\r
-  Status = BaseMemoryTest (MemoryTestLevel);\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-PlatformBdsPolicyBehavior (\r
-  IN OUT LIST_ENTRY                  *DriverOptionList,\r
-  IN OUT LIST_ENTRY                  *BootOptionList,\r
-  IN PROCESS_CAPSULES                ProcessCapsules,\r
-  IN BASEM_MEMORY_TEST               BaseMemoryTest\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The function will excute with as the platform policy, current policy\r
-  is driven by boot mode. IBV/OEM can customize this code for their specific\r
-  policy action.\r
-  \r
-Arguments:\r
-\r
-  DriverOptionList - The header of the driver option link list\r
-  \r
-  BootOptionList   - The header of the boot option link list\r
-\r
-  ProcessCapsules  - A pointer to ProcessCapsules()\r
-\r
-  BaseMemoryTest   - A pointer to BaseMemoryTest()\r
-\r
-Returns:\r
-\r
-  None.\r
-  \r
-**/\r
-{\r
-  EFI_STATUS     Status;\r
-  UINT16         Timeout;\r
-  EFI_BOOT_MODE  BootMode;\r
-\r
-  //\r
-  // Init the time out value\r
-  //\r
-  Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
-\r
-  //\r
-  // Load the driver option as the driver option list\r
-  //\r
-  PlatformBdsGetDriverOption (DriverOptionList);\r
-\r
-  //\r
-  // Get current Boot Mode\r
-  //\r
-  Status = BdsLibGetBootMode (&BootMode);\r
-\r
-  //\r
-  // Go the different platform policy with different boot mode\r
-  // Notes: this part code can be change with the table policy\r
-  //\r
-  switch (BootMode) {\r
-\r
-  case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r
-  case BOOT_WITH_MINIMAL_CONFIGURATION:\r
-    //\r
-    // In no-configuration boot mode, we can connect the\r
-    // console directly.\r
-    //\r
-    BdsLibConnectAllDefaultConsoles ();\r
-    PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r
-\r
-    //\r
-    // Perform some platform specific connect sequence\r
-    //\r
-    PlatformBdsConnectSequence ();\r
-\r
-    //\r
-    // Notes: current time out = 0 can not enter the\r
-    // front page\r
-    //\r
-    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-\r
-    //\r
-    // Check the boot option with the boot option list\r
-    //\r
-    BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
-    break;\r
-\r
-  case BOOT_ON_FLASH_UPDATE:\r
-    //\r
-    // Boot with the specific configuration\r
-    //\r
-    PlatformBdsConnectConsole (gPlatformConsole);\r
-    PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
-    BdsLibConnectAll ();\r
-    ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r
-    break;\r
-\r
-  case BOOT_IN_RECOVERY_MODE:\r
-    //\r
-    // In recovery mode, just connect platform console\r
-    // and show up the front page\r
-    //\r
-    PlatformBdsConnectConsole (gPlatformConsole);\r
-    PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
-\r
-    //\r
-    // In recovery boot mode, we still enter to the\r
-    // frong page now\r
-    //\r
-    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-    break;\r
-\r
-  case BOOT_WITH_FULL_CONFIGURATION:\r
-  case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r
-  case BOOT_WITH_DEFAULT_SETTINGS:\r
-  default:\r
-    //\r
-    // Connect platform console\r
-    //\r
-    Status = PlatformBdsConnectConsole (gPlatformConsole);\r
-    if (EFI_ERROR (Status)) {\r
-      //\r
-      // Here OEM/IBV can customize with defined action\r
-      //\r
-      PlatformBdsNoConsoleAction ();\r
-    }\r
-\r
-    PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r
-\r
-    //\r
-    // Perform some platform specific connect sequence\r
-    //\r
-    PlatformBdsConnectSequence ();\r
-\r
-    //\r
-    // Give one chance to enter the setup if we\r
-    // have the time out\r
-    //\r
-    PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-\r
-    //\r
-    // Here we have enough time to do the enumeration of boot device\r
-    //\r
-    BdsLibEnumerateAllBootOption (BootOptionList);\r
-    break;\r
-  }\r
-\r
-  return ;\r
-\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-PlatformBdsBootSuccess (\r
-  IN  BDS_COMMON_OPTION   *Option\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Hook point after a boot attempt succeeds. We don't expect a boot option to\r
-  return, so the EFI 1.0 specification defines that you will default to an\r
-  interactive mode and stop processing the BootOrder list in this case. This\r
-  is alos a platform implementation and can be customized by IBV/OEM.\r
-\r
-Arguments:\r
-\r
-  Option - Pointer to Boot Option that succeeded to boot.\r
-\r
-Returns:\r
-  \r
-  None.\r
-\r
-**/\r
-{\r
-  CHAR16  *TmpStr;\r
-\r
-  //\r
-  // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
-  // select loop then we need to pop up a UI and wait for user input.\r
-  //\r
-  TmpStr = Option->StatusString;\r
-  if (TmpStr != NULL) {\r
-    BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
-    FreePool (TmpStr);\r
-  }\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-PlatformBdsBootFail (\r
-  IN  BDS_COMMON_OPTION  *Option,\r
-  IN  EFI_STATUS         Status,\r
-  IN  CHAR16             *ExitData,\r
-  IN  UINTN              ExitDataSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  Hook point after a boot attempt fails.\r
-\r
-Arguments:\r
-  \r
-  Option - Pointer to Boot Option that failed to boot.\r
-\r
-  Status - Status returned from failed boot.\r
-\r
-  ExitData - Exit data returned from failed boot.\r
-\r
-  ExitDataSize - Exit data size returned from failed boot.\r
-\r
-Returns:\r
-  \r
-  None.\r
-\r
-**/\r
-{\r
-  CHAR16  *TmpStr;\r
-\r
-  //\r
-  // If Boot returned with failed status then we need to pop up a UI and wait\r
-  // for user input.\r
-  //\r
-  TmpStr = Option->StatusString;\r
-  if (TmpStr != NULL) {\r
-    BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
-    FreePool (TmpStr);\r
-  }\r
-}\r
-\r
-EFI_STATUS\r
-PlatformBdsNoConsoleAction (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  \r
-  This function is remained for IBV/OEM to do some platform action,\r
-  if there no console device can be connected.\r
-\r
-Arguments:\r
-  \r
-  None.\r
-  \r
-Returns:\r
-  \r
-  EFI_SUCCESS      - Direct return success now.\r
-\r
-**/\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-PlatformBdsLockNonUpdatableFlash (\r
-  VOID\r
-  )\r
-{\r
-  return;\r
-}\r
-\r
-/**\r
-  Lock the ConsoleIn device in system table. All key\r
-  presses will be ignored until the Password is typed in. The only way to\r
-  disable the password is to type it in to a ConIn device.\r
-\r
-  @param  Password        Password used to lock ConIn device.\r
-\r
-  @retval EFI_SUCCESS     lock the Console In Spliter virtual handle successfully.\r
-  @retval EFI_UNSUPPORTED Password not found\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-LockKeyboards (\r
-  IN  CHAR16    *Password\r
-  )\r
-{\r
-    return EFI_UNSUPPORTED;\r
-}\r
diff --git a/InOsEmuPkg/Library/EmuBdsLib/BdsPlatform.h b/InOsEmuPkg/Library/EmuBdsLib/BdsPlatform.h
deleted file mode 100644 (file)
index a76ec2e..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#ifndef _BDS_PLATFORM_H\r
-#define _BDS_PLATFORM_H\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Guid/EmuSystemConfig.h>\r
-#include <Protocol/EmuThunk.h>\r
-#include <Protocol/EmuIoThunk.h>\r
-#include <Protocol/EmuGraphicsWindow.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/GenericBdsLib.h>\r
-#include <Library/PlatformBdsLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-\r
-extern BDS_CONSOLE_CONNECT_ENTRY  gPlatformConsole[];\r
-extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformConnectSequence[];\r
-extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformDriverOption[];\r
-\r
-#define gEndEntire \\r
-  { \\r
-    END_DEVICE_PATH_TYPE,\\r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE,\\r
-    END_DEVICE_PATH_LENGTH,\\r
-    0\\r
-  }\r
-\r
-\r
-typedef struct {\r
-  EMU_VENDOR_DEVICE_PATH_NODE     EmuBus;\r
-  EMU_VENDOR_DEVICE_PATH_NODE     EmuGraphicsWindow;\r
-  EFI_DEVICE_PATH_PROTOCOL        End;\r
-} EMU_PLATFORM_UGA_DEVICE_PATH;\r
-\r
-\r
-//\r
-// Platform BDS Functions\r
-//\r
-VOID\r
-PlatformBdsGetDriverOption (\r
-  IN LIST_ENTRY               *BdsDriverLists\r
-  );\r
-\r
-EFI_STATUS\r
-BdsMemoryTest (\r
-  EXTENDMEM_COVERAGE_LEVEL Level\r
-  );\r
-\r
-\r
-VOID\r
-PlatformBdsConnectSequence (\r
-  VOID\r
-  );\r
-\r
-EFI_STATUS\r
-ProcessCapsules (\r
-  EFI_BOOT_MODE BootMode\r
-  );\r
-\r
-EFI_STATUS\r
-PlatformBdsConnectConsole (\r
-  IN BDS_CONSOLE_CONNECT_ENTRY   *PlatformConsole\r
-  );\r
-\r
-EFI_STATUS\r
-PlatformBdsNoConsoleAction (\r
-  VOID\r
-  );\r
-\r
-VOID\r
-PlatformBdsEnterFrontPage (\r
-  IN UINT16                 TimeoutDefault,\r
-  IN BOOLEAN                ConnectAllHappened\r
-  );\r
-\r
-#endif // _BDS_PLATFORM_H\r
diff --git a/InOsEmuPkg/Library/EmuBdsLib/EmuBdsLib.inf b/InOsEmuPkg/Library/EmuBdsLib/EmuBdsLib.inf
deleted file mode 100644 (file)
index 27f6337..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-## @file\r
-# Platfrom BDS driver\r
-#\r
-# Do platform action customized by IBV/OEM.\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuBdsLib\r
-  FILE_GUID                      =  59569181-CBF8-2E44-9C3E-C2AB2F5608E1\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = PlatformBdsLib|DXE_DRIVER   \r
-\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  BdsPlatform.c\r
-  PlatformData.c\r
-  BdsPlatform.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  MemoryAllocationLib\r
-  UefiBootServicesTableLib\r
-  UefiRuntimeServicesTableLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-  PcdLib\r
-  GenericBdsLib\r
-  DevicePathLib\r
-\r
-\r
-[Guids]\r
-  gEmuSystemConfigGuid\r
-\r
-[Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile\r
-  \r
-[Depex]\r
-  gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid\r
diff --git a/InOsEmuPkg/Library/EmuBdsLib/PlatformData.c b/InOsEmuPkg/Library/EmuBdsLib/PlatformData.c
deleted file mode 100644 (file)
index e20099b..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#include "BdsPlatform.h"\r
-\r
-\r
-\r
-EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {\r
-  {\r
-    {\r
-      {\r
-        HARDWARE_DEVICE_PATH,\r
-        HW_VENDOR_DP,\r
-        {\r
-          (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),\r
-          (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
-        }\r
-      },\r
-      EMU_THUNK_PROTOCOL_GUID\r
-    },\r
-    0\r
-  },\r
-  {\r
-      HARDWARE_DEVICE_PATH,\r
-      HW_VENDOR_DP,\r
-      {\r
-        (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),\r
-        (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
-      },\r
-      EMU_GRAPHICS_WINDOW_PROTOCOL_GUID,\r
-      0\r
-  },\r
-  gEndEntire\r
-};\r
-\r
-//\r
-// Predefined platform default console device path\r
-//\r
-BDS_CONSOLE_CONNECT_ENTRY   gPlatformConsole[] = {\r
-  {\r
-    (EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath,\r
-    (CONSOLE_OUT | CONSOLE_IN)\r
-  },\r
-  {\r
-    NULL,\r
-    0\r
-  }\r
-};\r
-\r
-//\r
-// Predefined platform specific driver option\r
-//\r
-EFI_DEVICE_PATH_PROTOCOL    *gPlatformDriverOption[] = { NULL };\r
-\r
-//\r
-// Predefined platform connect sequence\r
-//\r
-EFI_DEVICE_PATH_PROTOCOL    *gPlatformConnectSequence[] = { NULL };\r
diff --git a/InOsEmuPkg/Library/GuardUefiMemoryAllocationLib/GuardUefiMemoryAllocationLib.inf b/InOsEmuPkg/Library/GuardUefiMemoryAllocationLib/GuardUefiMemoryAllocationLib.inf
deleted file mode 100644 (file)
index b37b58e..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-## @file\r
-# Instance of Memory Allocation Library using EFI Boot Services.\r
-#\r
-# Memory Allocation Library that uses EFI Boot Services to allocate\r
-#  and free memory. Calls OS malloc to enable OS based debug tools\r
-#\r
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = GuardUefiMemoryAllocationLib\r
-  FILE_GUID                      = DB290230-3EFA-064F-A317-E146925684FE\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = MemoryAllocationLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER DXE_CORE\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  MemoryAllocationLib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  DebugLib\r
-  BaseMemoryLib\r
-  UefiBootServicesTableLib\r
-  EmuThunkLib\r
diff --git a/InOsEmuPkg/Library/GuardUefiMemoryAllocationLib/MemoryAllocationLib.c b/InOsEmuPkg/Library/GuardUefiMemoryAllocationLib/MemoryAllocationLib.c
deleted file mode 100644 (file)
index c457e7c..0000000
+++ /dev/null
@@ -1,819 +0,0 @@
-/** @file\r
-  Support routines for memory allocation routines based \r
-  on boot services for Dxe phase drivers using OS malloc.\r
-  \r
-  OS malloc is used so OS based malloc debugging tools can be used. \r
-  If a single driver links against this lib protocols from other \r
-  drivers, or EFI boot services can return a buffer that needs to \r
-  freed using the EFI scheme. This is why the gEmuThunk->Free () \r
-  can detect if the memory rang is for EFI so the right free can be\r
-  called.\r
-\r
-  Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-  Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-  This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php.                                            \r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-\r
-#include <Uefi.h>\r
-\r
-\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/EmuThunkLib.h>\r
-\r
-/**\r
-  Allocates one or more 4KB pages of a certain memory type.\r
-\r
-  Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated\r
-  buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL is returned.\r
-  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
-\r
-  @param  MemoryType            The type of memory to allocate.\r
-  @param  Pages                 The number of 4 KB pages to allocate.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-InternalAllocatePages (\r
-  IN EFI_MEMORY_TYPE  MemoryType,  \r
-  IN UINTN            Pages\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PHYSICAL_ADDRESS  Memory; \r
-\r
-  if (Pages == 0) {\r
-    return NULL;\r
-  }\r
-\r
-  return gEmuThunk->Valloc (Pages * EFI_PAGE_SIZE);\r
-}\r
-\r
-/**\r
-  Allocates one or more 4KB pages of type EfiBootServicesData.\r
-\r
-  Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the\r
-  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
-  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
-  returned.\r
-\r
-  @param  Pages                 The number of 4 KB pages to allocate.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocatePages (\r
-  IN UINTN  Pages\r
-  )\r
-{\r
-  return InternalAllocatePages (EfiBootServicesData, Pages);\r
-}\r
-\r
-/**\r
-  Allocates one or more 4KB pages of type EfiRuntimeServicesData.\r
-\r
-  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the\r
-  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
-  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
-  returned.\r
-\r
-  @param  Pages                 The number of 4 KB pages to allocate.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateRuntimePages (\r
-  IN UINTN  Pages\r
-  )\r
-{\r
-  return InternalAllocatePages (EfiRuntimeServicesData, Pages);\r
-}\r
-\r
-/**\r
-  Allocates one or more 4KB pages of type EfiReservedMemoryType.\r
-\r
-  Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the\r
-  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
-  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
-  returned.\r
-\r
-  @param  Pages                 The number of 4 KB pages to allocate.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateReservedPages (\r
-  IN UINTN  Pages\r
-  )\r
-{\r
-  return InternalAllocatePages (EfiReservedMemoryType, Pages);\r
-}\r
-\r
-/**\r
-  Frees one or more 4KB pages that were previously allocated with one of the page allocation\r
-  functions in the Memory Allocation Library.\r
-\r
-  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer\r
-  must have been allocated on a previous call to the page allocation services of the Memory\r
-  Allocation Library.  If it is not possible to free allocated pages, then this function will\r
-  perform no actions.\r
-  \r
-  If Buffer was not allocated with a page allocation function in the Memory Allocation Library,\r
-  then ASSERT().\r
-  If Pages is zero, then ASSERT().\r
\r
-  @param  Buffer                The pointer to the buffer of pages to free.\r
-  @param  Pages                 The number of 4 KB pages to free.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-FreePages (\r
-  IN VOID   *Buffer,\r
-  IN UINTN  Pages\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-\r
-  ASSERT (Pages != 0);\r
-  if (!gEmuThunk->Free (Buffer)) {\r
-    // The Free thunk will not free memory allocated in emulated EFI memory.\r
-    // The assmuption is this was allocated directly by EFI. We need this as some \r
-    // times protocols or EFI BootServices can return dynamically allocated buffers.\r
-    Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-}\r
-\r
-/**\r
-  Allocates one or more 4KB pages of a certain memory type at a specified alignment.\r
-\r
-  Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment\r
-  specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is returned.\r
-  If there is not enough memory at the specified alignment remaining to satisfy the request, then\r
-  NULL is returned.\r
-  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
-\r
-  @param  MemoryType            The type of memory to allocate.\r
-  @param  Pages                 The number of 4 KB pages to allocate.\r
-  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
-                                If Alignment is zero, then byte alignment is used.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-InternalAllocateAlignedPages (\r
-  IN EFI_MEMORY_TYPE  MemoryType,  \r
-  IN UINTN            Pages,\r
-  IN UINTN            Alignment\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  VOID                  *Memory;\r
-  UINTN                 AlignedMemory;\r
-  UINTN                 AlignmentMask;\r
-  UINTN                 UnalignedPages;\r
-  UINTN                 RealPages;\r
-\r
-  //\r
-  // Alignment must be a power of two or zero.\r
-  //\r
-  ASSERT ((Alignment & (Alignment - 1)) == 0);\r
\r
-  if (Pages == 0) {\r
-    return NULL;\r
-  }\r
-  if (Alignment > EFI_PAGE_SIZE) {\r
-    //\r
-    // Caculate the total number of pages since alignment is larger than page size.\r
-    //\r
-    AlignmentMask  = Alignment - 1;\r
-    RealPages      = Pages + EFI_SIZE_TO_PAGES (Alignment);\r
-    //\r
-    // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.\r
-    //\r
-    ASSERT (RealPages > Pages);\r
\r
-    Memory = gEmuThunk->Valloc (Pages * EFI_PAGE_SIZE);\r
-    if (Memory != NULL) {\r
-      return NULL;\r
-    }\r
-    AlignedMemory  = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;\r
-    UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);\r
-    if (UnalignedPages > 0) {\r
-      //\r
-      // Free first unaligned page(s).\r
-      //\r
-      FreePages (Memory, UnalignedPages);\r
-    }\r
-    Memory         = (VOID *) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));\r
-    UnalignedPages = RealPages - Pages - UnalignedPages;\r
-    if (UnalignedPages > 0) {\r
-      //\r
-      // Free last unaligned page(s).\r
-      //\r
-      FreePages (Memory, UnalignedPages);\r
-    }\r
-  } else {\r
-    //\r
-    // Do not over-allocate pages in this case.\r
-    //\r
-    Memory = gEmuThunk->Valloc (Pages * EFI_PAGE_SIZE);\r
-    if (Memory != NULL) {\r
-      return NULL;\r
-    }\r
-    AlignedMemory  = (UINTN) Memory;\r
-  }\r
-  return (VOID *) AlignedMemory;\r
-}\r
-\r
-/**\r
-  Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.\r
-\r
-  Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an\r
-  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
-  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
-  request, then NULL is returned.\r
-  \r
-  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
-\r
-  @param  Pages                 The number of 4 KB pages to allocate.\r
-  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
-                                If Alignment is zero, then byte alignment is used.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateAlignedPages (\r
-  IN UINTN  Pages,\r
-  IN UINTN  Alignment\r
-  )\r
-{\r
-  return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);\r
-}\r
-\r
-/**\r
-  Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.\r
-\r
-  Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an\r
-  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
-  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
-  request, then NULL is returned.\r
-  \r
-  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
-\r
-  @param  Pages                 The number of 4 KB pages to allocate.\r
-  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
-                                If Alignment is zero, then byte alignment is used.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateAlignedRuntimePages (\r
-  IN UINTN  Pages,\r
-  IN UINTN  Alignment\r
-  )\r
-{\r
-  return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);\r
-}\r
-\r
-/**\r
-  Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.\r
-\r
-  Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an\r
-  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is\r
-  returned.  If there is not enough memory at the specified alignment remaining to satisfy the\r
-  request, then NULL is returned.\r
-  \r
-  If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
-\r
-  @param  Pages                 The number of 4 KB pages to allocate.\r
-  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.\r
-                                If Alignment is zero, then byte alignment is used.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateAlignedReservedPages (\r
-  IN UINTN  Pages,\r
-  IN UINTN  Alignment\r
-  )\r
-{\r
-  return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);\r
-}\r
-\r
-/**\r
-  Frees one or more 4KB pages that were previously allocated with one of the aligned page\r
-  allocation functions in the Memory Allocation Library.\r
-\r
-  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer\r
-  must have been allocated on a previous call to the aligned page allocation services of the Memory\r
-  Allocation Library.  If it is not possible to free allocated pages, then this function will \r
-  perform no actions.\r
-  \r
-  If Buffer was not allocated with an aligned page allocation function in the Memory Allocation\r
-  Library, then ASSERT().\r
-  If Pages is zero, then ASSERT().\r
-  \r
-  @param  Buffer                The pointer to the buffer of pages to free.\r
-  @param  Pages                 The number of 4 KB pages to free.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-FreeAlignedPages (\r
-  IN VOID   *Buffer,\r
-  IN UINTN  Pages\r
-  )\r
-{\r
-  FreePages (Buffer, Pages);\r
-}\r
-\r
-/**\r
-  Allocates a buffer of a certain pool type.\r
-\r
-  Allocates the number bytes specified by AllocationSize of a certain pool type and returns a\r
-  pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
-  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
-\r
-  @param  MemoryType            The type of memory to allocate.\r
-  @param  AllocationSize        The number of bytes to allocate.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-InternalAllocatePool (\r
-  IN EFI_MEMORY_TYPE  MemoryType,  \r
-  IN UINTN            AllocationSize\r
-  )\r
-{\r
-  return gEmuThunk->Malloc (AllocationSize);\r
-}\r
-\r
-/**\r
-  Allocates a buffer of type EfiBootServicesData.\r
-\r
-  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a\r
-  pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
-  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
-\r
-  @param  AllocationSize        The number of bytes to allocate.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocatePool (\r
-  IN UINTN  AllocationSize\r
-  )\r
-{\r
-  return InternalAllocatePool (EfiBootServicesData, AllocationSize);\r
-}\r
-\r
-/**\r
-  Allocates a buffer of type EfiRuntimeServicesData.\r
-\r
-  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns\r
-  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
-  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
-\r
-  @param  AllocationSize        The number of bytes to allocate.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateRuntimePool (\r
-  IN UINTN  AllocationSize\r
-  )\r
-{\r
-  return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);\r
-}\r
-\r
-/**\r
-  Allocates a buffer of type EfiReservedMemoryType.\r
-\r
-  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns\r
-  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is\r
-  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.\r
-\r
-  @param  AllocationSize        The number of bytes to allocate.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateReservedPool (\r
-  IN UINTN  AllocationSize\r
-  )\r
-{\r
-  return InternalAllocatePool (EfiReservedMemoryType, AllocationSize);\r
-}\r
-\r
-/**\r
-  Allocates and zeros a buffer of a certain pool type.\r
-\r
-  Allocates the number bytes specified by AllocationSize of a certain pool type, clears the buffer\r
-  with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a valid\r
-  buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the request,\r
-  then NULL is returned.\r
-\r
-  @param  PoolType              The type of memory to allocate.\r
-  @param  AllocationSize        The number of bytes to allocate and zero.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-InternalAllocateZeroPool (\r
-  IN EFI_MEMORY_TYPE  PoolType,  \r
-  IN UINTN            AllocationSize\r
-  ) \r
-{\r
-  VOID  *Memory;\r
-\r
-  Memory = InternalAllocatePool (PoolType, AllocationSize);\r
-  if (Memory != NULL) {\r
-    Memory = ZeroMem (Memory, AllocationSize);\r
-  }\r
-  return Memory;\r
-}\r
-\r
-/**\r
-  Allocates and zeros a buffer of type EfiBootServicesData.\r
-\r
-  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the\r
-  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
-  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
-  request, then NULL is returned.\r
-\r
-  @param  AllocationSize        The number of bytes to allocate and zero.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateZeroPool (\r
-  IN UINTN  AllocationSize\r
-  )\r
-{\r
-  return InternalAllocateZeroPool (EfiBootServicesData, AllocationSize);\r
-}\r
-\r
-/**\r
-  Allocates and zeros a buffer of type EfiRuntimeServicesData.\r
-\r
-  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the\r
-  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
-  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
-  request, then NULL is returned.\r
-\r
-  @param  AllocationSize        The number of bytes to allocate and zero.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateRuntimeZeroPool (\r
-  IN UINTN  AllocationSize\r
-  )\r
-{\r
-  return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);\r
-}\r
-\r
-/**\r
-  Allocates and zeros a buffer of type EfiReservedMemoryType.\r
-\r
-  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the\r
-  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a\r
-  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the\r
-  request, then NULL is returned.\r
-\r
-  @param  AllocationSize        The number of bytes to allocate and zero.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateReservedZeroPool (\r
-  IN UINTN  AllocationSize\r
-  )\r
-{\r
-  return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);\r
-}\r
-\r
-/**\r
-  Copies a buffer to an allocated buffer of a certain pool type.\r
-\r
-  Allocates the number bytes specified by AllocationSize of a certain pool type, copies\r
-  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
-  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
-  is not enough memory remaining to satisfy the request, then NULL is returned.\r
-  If Buffer is NULL, then ASSERT().\r
-  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
-\r
-  @param  PoolType              The type of pool to allocate.\r
-  @param  AllocationSize        The number of bytes to allocate and zero.\r
-  @param  Buffer                The buffer to copy to the allocated buffer.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-InternalAllocateCopyPool (\r
-  IN EFI_MEMORY_TYPE  PoolType,  \r
-  IN UINTN            AllocationSize,\r
-  IN CONST VOID       *Buffer\r
-  ) \r
-{\r
-  VOID  *Memory;\r
-\r
-  ASSERT (Buffer != NULL);\r
-  ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
-\r
-  Memory = InternalAllocatePool (PoolType, AllocationSize);\r
-  if (Memory != NULL) {\r
-     Memory = CopyMem (Memory, Buffer, AllocationSize);\r
-  }\r
-  return Memory;\r
-} \r
-\r
-/**\r
-  Copies a buffer to an allocated buffer of type EfiBootServicesData.\r
-\r
-  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies\r
-  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
-  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
-  is not enough memory remaining to satisfy the request, then NULL is returned.\r
-  \r
-  If Buffer is NULL, then ASSERT().\r
-  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
-\r
-  @param  AllocationSize        The number of bytes to allocate and zero.\r
-  @param  Buffer                The buffer to copy to the allocated buffer.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateCopyPool (\r
-  IN UINTN       AllocationSize,\r
-  IN CONST VOID  *Buffer\r
-  )\r
-{\r
-  return InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer);\r
-}\r
-\r
-/**\r
-  Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.\r
-\r
-  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies\r
-  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
-  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
-  is not enough memory remaining to satisfy the request, then NULL is returned.\r
-  \r
-  If Buffer is NULL, then ASSERT().\r
-  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
-\r
-  @param  AllocationSize        The number of bytes to allocate and zero.\r
-  @param  Buffer                The buffer to copy to the allocated buffer.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateRuntimeCopyPool (\r
-  IN UINTN       AllocationSize,\r
-  IN CONST VOID  *Buffer\r
-  )\r
-{\r
-  return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);\r
-}\r
-\r
-/**\r
-  Copies a buffer to an allocated buffer of type EfiReservedMemoryType.\r
-\r
-  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies\r
-  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the\r
-  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there\r
-  is not enough memory remaining to satisfy the request, then NULL is returned.\r
-  \r
-  If Buffer is NULL, then ASSERT().\r
-  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
-\r
-  @param  AllocationSize        The number of bytes to allocate and zero.\r
-  @param  Buffer                The buffer to copy to the allocated buffer.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateReservedCopyPool (\r
-  IN UINTN       AllocationSize,\r
-  IN CONST VOID  *Buffer\r
-  )\r
-{\r
-  return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);\r
-}\r
-\r
-/**\r
-  Reallocates a buffer of a specified memory type.\r
-\r
-  Allocates and zeros the number bytes specified by NewSize from memory of the type\r
-  specified by PoolType.  If OldBuffer is not NULL, then the smaller of OldSize and \r
-  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
-  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  \r
-  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not \r
-  enough memory remaining to satisfy the request, then NULL is returned.\r
-  \r
-  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize\r
-  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().\r
-\r
-  @param  PoolType       The type of pool to allocate.\r
-  @param  OldSize        The size, in bytes, of OldBuffer.\r
-  @param  NewSize        The size, in bytes, of the buffer to reallocate.\r
-  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional \r
-                         parameter that may be NULL.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-InternalReallocatePool (\r
-  IN EFI_MEMORY_TYPE  PoolType,  \r
-  IN UINTN            OldSize,\r
-  IN UINTN            NewSize,\r
-  IN VOID             *OldBuffer  OPTIONAL\r
-  )\r
-{\r
-  VOID  *NewBuffer;\r
-\r
-  NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);\r
-  if (NewBuffer != NULL && OldBuffer != NULL) {\r
-    CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));\r
-    FreePool (OldBuffer);\r
-  }\r
-  return NewBuffer;\r
-}\r
-\r
-/**\r
-  Reallocates a buffer of type EfiBootServicesData.\r
-\r
-  Allocates and zeros the number bytes specified by NewSize from memory of type\r
-  EfiBootServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and \r
-  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
-  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  \r
-  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not \r
-  enough memory remaining to satisfy the request, then NULL is returned.\r
-  \r
-  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize\r
-  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().\r
-\r
-  @param  OldSize        The size, in bytes, of OldBuffer.\r
-  @param  NewSize        The size, in bytes, of the buffer to reallocate.\r
-  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional \r
-                         parameter that may be NULL.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-ReallocatePool (\r
-  IN UINTN  OldSize,\r
-  IN UINTN  NewSize,\r
-  IN VOID   *OldBuffer  OPTIONAL\r
-  )\r
-{\r
-  return InternalReallocatePool (EfiBootServicesData, OldSize, NewSize, OldBuffer);\r
-}\r
-\r
-/**\r
-  Reallocates a buffer of type EfiRuntimeServicesData.\r
-\r
-  Allocates and zeros the number bytes specified by NewSize from memory of type\r
-  EfiRuntimeServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and \r
-  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
-  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  \r
-  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not \r
-  enough memory remaining to satisfy the request, then NULL is returned.\r
-\r
-  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize\r
-  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().\r
-\r
-  @param  OldSize        The size, in bytes, of OldBuffer.\r
-  @param  NewSize        The size, in bytes, of the buffer to reallocate.\r
-  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional \r
-                         parameter that may be NULL.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-ReallocateRuntimePool (\r
-  IN UINTN  OldSize,\r
-  IN UINTN  NewSize,\r
-  IN VOID   *OldBuffer  OPTIONAL\r
-  )\r
-{\r
-  return InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);\r
-}\r
-\r
-/**\r
-  Reallocates a buffer of type EfiReservedMemoryType.\r
-\r
-  Allocates and zeros the number bytes specified by NewSize from memory of type\r
-  EfiReservedMemoryType.  If OldBuffer is not NULL, then the smaller of OldSize and \r
-  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
-  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  \r
-  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not \r
-  enough memory remaining to satisfy the request, then NULL is returned.\r
-\r
-  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize\r
-  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().\r
-\r
-  @param  OldSize        The size, in bytes, of OldBuffer.\r
-  @param  NewSize        The size, in bytes, of the buffer to reallocate.\r
-  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional \r
-                         parameter that may be NULL.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-ReallocateReservedPool (\r
-  IN UINTN  OldSize,\r
-  IN UINTN  NewSize,\r
-  IN VOID   *OldBuffer  OPTIONAL\r
-  )\r
-{\r
-  return InternalReallocatePool (EfiReservedMemoryType, OldSize, NewSize, OldBuffer);\r
-}\r
-\r
-/**\r
-  Frees a buffer that was previously allocated with one of the pool allocation functions in the\r
-  Memory Allocation Library.\r
-\r
-  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the\r
-  pool allocation services of the Memory Allocation Library.  If it is not possible to free pool\r
-  resources, then this function will perform no actions.\r
-  \r
-  If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,\r
-  then ASSERT().\r
-\r
-  @param  Buffer                The pointer to the buffer to free.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-FreePool (\r
-  IN VOID   *Buffer\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-\r
-  if (!gEmuThunk->Free (Buffer)) {\r
-    // The Free thunk will not free memory allocated in emulated EFI memory.\r
-    // The assmuption is this was allocated directly by EFI. We need this as some \r
-    // times protocols or EFI BootServices can return dynamically allocated buffers.\r
-    Status = gBS->FreePool (Buffer);\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-}\r
-\r
diff --git a/InOsEmuPkg/Library/KeyMapLibNull/KeyMapLibNull.c b/InOsEmuPkg/Library/KeyMapLibNull/KeyMapLibNull.c
deleted file mode 100644 (file)
index 5a80870..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2011, Apple Inc. All rights reserved. \r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <Uefi.h>\r
-#include <Protocol/SimpleTextInEx.h>\r
-\r
-\r
-/**\r
-  KeyMapMake gets called on key presses.\r
-\r
-  @param  KeyData       Key that was pressed.\r
-\r
-  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyMapMake (\r
-  IN EFI_KEY_DATA   *KeyData\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  KeyMapBreak gets called on key releases.\r
-\r
-  @param  KeyData       Key that was pressed.\r
-\r
-  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-KeyMapBreak (\r
-  IN EFI_KEY_DATA   *KeyData\r
-  )\r
-{\r
-  return EFI_SUCCESS;\r
-}
\ No newline at end of file
diff --git a/InOsEmuPkg/Library/KeyMapLibNull/KeyMapLibNull.inf b/InOsEmuPkg/Library/KeyMapLibNull/KeyMapLibNull.inf
deleted file mode 100644 (file)
index 46483df..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-## @file\r
-# A library to produce the global variable 'gEmuThunk'\r
-#\r
-# This library contains a single global variable 'gEmuThunk' along with a constructor to \r
-# initialize that global.\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = KeyMapLibNull\r
-  FILE_GUID                      = 6B7067C7-A843-A34C-9530-48446963B740\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = KeyMapLib \r
-\r
-[Sources]\r
-  KeyMapLibNull.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  HobLib\r
-  DebugLib\r
-\r
-\r
diff --git a/InOsEmuPkg/Library/PeiCoreServicesTablePointerLib/PeiCoreServicesTablePointerLib.inf b/InOsEmuPkg/Library/PeiCoreServicesTablePointerLib/PeiCoreServicesTablePointerLib.inf
deleted file mode 100644 (file)
index 279e088..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-## @file\r
-# Instance of PEI Services Table Pointer Library using global variable for the table pointer.\r
-#\r
-# PEI Services Table Pointer Library implementation that retrieves a pointer to the\r
-#  PEI Services Table from a global variable. Not available to modules that execute from\r
-#  read-only memory.\r
-#\r
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-#  Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = InOsEmuPkgPeiCoreServicesTablePointerLib\r
-  FILE_GUID                      = E9A22529-44FA-3E4A-A66B-1E918E7AB26A\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = PeiServicesTablePointerLib|PEI_CORE\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC (EBC is for build only)\r
-#\r
-\r
-[Sources]\r
-  PeiServicesTablePointer.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-\r
-[LibraryClasses]\r
-  DebugLib\r
-\r
diff --git a/InOsEmuPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c b/InOsEmuPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c
deleted file mode 100644 (file)
index 9b02316..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/** @file\r
-  PEI Services Table Pointer Library.\r
-  \r
-  This library is used for PEIM which does executed from flash device directly but\r
-  executed in memory.\r
-\r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiPei.h>\r
-#include <Library/PeiServicesTablePointerLib.h>\r
-#include <Library/DebugLib.h>\r
-\r
-CONST EFI_PEI_SERVICES  **gPeiServices;\r
-\r
-/**\r
-  Caches a pointer PEI Services Table. \r
\r
-  Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer \r
-  in a CPU specific manner as specified in the CPU binding section of the Platform Initialization \r
-  Pre-EFI Initialization Core Interface Specification. \r
-  \r
-  If PeiServicesTablePointer is NULL, then ASSERT().\r
-  \r
-  @param    PeiServicesTablePointer   The address of PeiServices pointer.\r
-**/\r
-VOID\r
-EFIAPI\r
-SetPeiServicesTablePointer (\r
-  IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r
-  )\r
-{\r
-  ASSERT (PeiServicesTablePointer != NULL);\r
-  gPeiServices = PeiServicesTablePointer;\r
-}\r
-\r
-/**\r
-  Retrieves the cached value of the PEI Services Table pointer.\r
-\r
-  Returns the cached value of the PEI Services Table pointer in a CPU specific manner \r
-  as specified in the CPU binding section of the Platform Initialization Pre-EFI \r
-  Initialization Core Interface Specification.\r
-  \r
-  If the cached PEI Services Table pointer is NULL, then ASSERT().\r
-\r
-  @return  The pointer to PeiServices.\r
-\r
-**/\r
-CONST EFI_PEI_SERVICES **\r
-EFIAPI\r
-GetPeiServicesTablePointer (\r
-  VOID\r
-  )\r
-{\r
-  ASSERT (gPeiServices != NULL);\r
-  return gPeiServices;\r
-}\r
-\r
-\r
-/**\r
-  The constructor function caches the pointer to PEI services.\r
-  \r
-  The constructor function caches the pointer to PEI services.\r
-  It will always return EFI_SUCCESS.\r
-\r
-  @param  FileHandle   The handle of FFS header the loaded driver.\r
-  @param  PeiServices  The pointer to the PEI services.\r
-\r
-  @retval EFI_SUCCESS  The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesTablePointerLibConstructor (\r
-  IN EFI_PEI_FILE_HANDLE        FileHandle,\r
-  IN CONST EFI_PEI_SERVICES     **PeiServices\r
-  )\r
-{\r
-  gPeiServices = PeiServices;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
diff --git a/InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c b/InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.c
deleted file mode 100644 (file)
index b398b53..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/** @file\r
-  Provides services to perform additional actions to relocate and unload\r
-  PE/Coff image for Emu environment specific purpose such as souce level debug.\r
-  This version only works for PEI phase\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-#include <PiPei.h>\r
-#include <Ppi/EmuThunk.h>\r
-#include <Protocol/EmuThunk.h>\r
-\r
-#include <Library/PeCoffLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/PeCoffExtraActionLib.h>\r
-#include <Library/EmuMagicPageLib.h>\r
-\r
-//\r
-// Cache of UnixThunk protocol \r
-//\r
-EMU_THUNK_PROTOCOL   *mThunk = NULL;\r
-\r
-/**\r
-  The function caches the pointer of the Unix thunk functions\r
-  It will ASSERT() if Unix thunk ppi is not installed.\r
-\r
-  @retval EFI_SUCCESS   WinNT thunk protocol is found and cached.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EmuPeCoffGetThunkStucture (\r
-  )\r
-{\r
-  EMU_THUNK_PPI     *ThunkPpi;\r
-  EFI_STATUS        Status;\r
-\r
-  \r
-  //\r
-  // Locate Unix ThunkPpi for retrieving standard output handle\r
-  //\r
-  Status = PeiServicesLocatePpi (\r
-              &gEmuThunkPpiGuid,\r
-              0,\r
-              NULL,\r
-              (VOID **) &ThunkPpi\r
-              );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  EMU_MAGIC_PAGE()->Thunk = (EMU_THUNK_PROTOCOL *) ThunkPpi->Thunk ();\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Performs additional actions after a PE/COFF image has been loaded and relocated.\r
-\r
-  If ImageContext is NULL, then ASSERT().\r
-\r
-  @param  ImageContext  Pointer to the image context structure that describes the\r
-                        PE/COFF image that has already been loaded and relocated.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PeCoffLoaderRelocateImageExtraAction (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  )\r
-{\r
-  if (EMU_MAGIC_PAGE()->Thunk == NULL) {\r
-    EmuPeCoffGetThunkStucture ();\r
-  }\r
-    EMU_MAGIC_PAGE()->Thunk->PeCoffRelocateImageExtraAction (ImageContext);\r
-  }\r
-\r
-\r
-/**\r
-  Performs additional actions just before a PE/COFF image is unloaded.  Any resources\r
-  that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.\r
-  \r
-  If ImageContext is NULL, then ASSERT().\r
-  \r
-  @param  ImageContext  Pointer to the image context structure that describes the\r
-                        PE/COFF image that is being unloaded.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-PeCoffLoaderUnloadImageExtraAction (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  )\r
-{\r
-  if (EMU_MAGIC_PAGE()->Thunk == NULL) {\r
-    EmuPeCoffGetThunkStucture ();\r
-  }\r
-  EMU_MAGIC_PAGE()->Thunk->PeCoffUnloadImageExtraAction (ImageContext);\r
-}\r
diff --git a/InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf b/InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf
deleted file mode 100644 (file)
index e4a3fa7..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-## @file
-# PeCoff extra action libary for Pei phase that run Emu emulator.
-#
-# Lib to provide memory journal status code reporting Routines
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# 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
-# 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.
-
-#
-#
-##
-
-[Defines]
-  INF_VERSION                    = 0x00010005
-  BASE_NAME                      = PeiEmuPeCoffExtraActionLib
-  FILE_GUID                      = 79C4E72A-730B-F040-8129-95877B3A97A8
-  MODULE_TYPE                    = PEIM
-  VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = PeCoffExtraActionLib|PEI_CORE PEIM
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-#  VALID_ARCHITECTURES           = IA32
-#
-
-[Sources]
-  PeiEmuPeCoffExtraActionLib.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  InOsEmuPkg/InOsEmuPkg.dec
-
-[LibraryClasses]
-  BaseLib
-  PeiServicesLib
-  DebugLib
-
-[Ppis]
-  gEmuThunkPpiGuid                          # PPI ALWAYS_CONSUMED
-
-[Pcd]
-  gInOsEmuPkgTokenSpaceGuid.PcdPeiServicesTablePage
diff --git a/InOsEmuPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.c b/InOsEmuPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.c
deleted file mode 100644 (file)
index e229805..0000000
+++ /dev/null
@@ -1,297 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "PiPei.h"\r
-#include <Library/PeCoffGetEntryPointLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <IndustryStandard/PeImage.h>\r
-#include <Library/DebugLib.h>\r
-\r
-#include <Ppi/EmuThunk.h>\r
-#include <Protocol/EmuThunk.h>\r
-\r
-\r
-\r
-/**\r
-  Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded\r
-  into system memory with the PE/COFF Loader Library functions.\r
-\r
-  Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry\r
-  point in EntryPoint.  If the entry point could not be retrieved from the PE/COFF image, then\r
-  return RETURN_INVALID_PARAMETER.  Otherwise return RETURN_SUCCESS.\r
-  If Pe32Data is NULL, then ASSERT().\r
-  If EntryPoint is NULL, then ASSERT().\r
-\r
-  @param  Pe32Data                  The pointer to the PE/COFF image that is loaded in system memory.\r
-  @param  EntryPoint                The pointer to entry point to the PE/COFF image to return.\r
-\r
-  @retval RETURN_SUCCESS            EntryPoint was returned.\r
-  @retval RETURN_INVALID_PARAMETER  The entry point could not be found in the PE/COFF image.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-PeCoffLoaderGetEntryPoint (\r
-  IN     VOID  *Pe32Data,\r
-  IN OUT VOID  **EntryPoint\r
-  )\r
-{\r
-  EMU_THUNK_PPI           *ThunkPpi;\r
-  EFI_STATUS              Status;\r
-  EMU_THUNK_PROTOCOL      *Thunk;\r
-\r
-  //\r
-  // Locate EmuThunkPpi for retrieving standard output handle\r
-  //\r
-  Status = PeiServicesLocatePpi (\r
-              &gEmuThunkPpiGuid,\r
-              0,\r
-              NULL,\r
-              (VOID **) &ThunkPpi\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Thunk  = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();\r
-\r
-  return Thunk->PeCoffGetEntryPoint (Pe32Data, EntryPoint);\r
-}\r
-\r
-/**\r
-  Returns the machine type of PE/COFF image. \r
-  This is copied from MDE BasePeCoffGetEntryPointLib, the code should be sync with it.\r
-  The reason is Emu package needs to load the image to memory to support source\r
-  level debug.\r
-   \r
-\r
-  @param  Pe32Data   Pointer to a PE/COFF header\r
-\r
-  @return            Machine type or zero if not a valid iamge\r
-\r
-**/\r
-UINT16\r
-EFIAPI\r
-PeCoffLoaderGetMachineType (\r
-  IN  VOID  *Pe32Data\r
-  )\r
-{  \r
-  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION  Hdr;\r
-  EFI_IMAGE_DOS_HEADER                 *DosHdr;\r
-\r
-  ASSERT (Pe32Data   != NULL);\r
-\r
-  DosHdr = (EFI_IMAGE_DOS_HEADER  *)Pe32Data;\r
-  if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
-    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));\r
-\r
-  } else {\r
-    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(Pe32Data);\r
-  }\r
-\r
-  if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
-    return Hdr.Te->Machine;\r
-  } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE)  {\r
-    return Hdr.Pe32->FileHeader.Machine;\r
-  }\r
-\r
-  return 0x0000;\r
-}\r
-\r
-/**\r
-  Returns a pointer to the PDB file name for a PE/COFF image that has been\r
-  loaded into system memory with the PE/COFF Loader Library functions.\r
-\r
-  Returns the PDB file name for the PE/COFF image specified by Pe32Data.  If\r
-  the PE/COFF image specified by Pe32Data is not a valid, then NULL is\r
-  returned.  If the PE/COFF image specified by Pe32Data does not contain a\r
-  debug directory entry, then NULL is returned.  If the debug directory entry\r
-  in the PE/COFF image specified by Pe32Data does not contain a PDB file name,\r
-  then NULL is returned.\r
-  If Pe32Data is NULL, then ASSERT().\r
-\r
-  @param  Pe32Data   Pointer to the PE/COFF image that is loaded in system\r
-                     memory.\r
-\r
-  @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL\r
-          if it cannot be retrieved.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-PeCoffLoaderGetPdbPointer (\r
-  IN VOID  *Pe32Data\r
-  )\r
-{\r
-  EFI_IMAGE_DOS_HEADER                  *DosHdr;\r
-  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
-  EFI_IMAGE_DATA_DIRECTORY              *DirectoryEntry;\r
-  EFI_IMAGE_DEBUG_DIRECTORY_ENTRY       *DebugEntry;\r
-  UINTN                                 DirCount;\r
-  VOID                                  *CodeViewEntryPointer;\r
-  INTN                                  TEImageAdjust;\r
-  UINT32                                NumberOfRvaAndSizes;\r
-  UINT16                                Magic;\r
-\r
-  ASSERT (Pe32Data   != NULL);\r
-\r
-  TEImageAdjust       = 0;\r
-  DirectoryEntry      = NULL;\r
-  DebugEntry          = NULL;\r
-  NumberOfRvaAndSizes = 0;\r
-\r
-  DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;\r
-  if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
-    //\r
-    // DOS image header is present, so read the PE header after the DOS image header.\r
-    //\r
-    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));\r
-  } else {\r
-    //\r
-    // DOS image header is not present, so PE header is at the image base.\r
-    //\r
-    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;\r
-  }\r
-\r
-  if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
-    if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {\r
-      DirectoryEntry  = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];\r
-      TEImageAdjust   = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;\r
-      DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te +\r
-                    Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +\r
-                    TEImageAdjust);\r
-    }\r
-  } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {\r
-    //\r
-    // NOTE: We use Machine field to identify PE32/PE32+, instead of Magic.\r
-    //       It is due to backward-compatibility, for some system might\r
-    //       generate PE32+ image with PE32 Magic.\r
-    //\r
-    switch (Hdr.Pe32->FileHeader.Machine) {\r
-    case EFI_IMAGE_MACHINE_IA32:\r
-      //\r
-      // Assume PE32 image with IA32 Machine field.\r
-      //\r
-      Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;\r
-      break;\r
-    case EFI_IMAGE_MACHINE_X64:\r
-    case EFI_IMAGE_MACHINE_IA64:\r
-      //\r
-      // Assume PE32+ image with X64 or IA64 Machine field\r
-      //\r
-      Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;\r
-      break;\r
-    default:\r
-      //\r
-      // For unknow Machine field, use Magic in optional Header\r
-      //\r
-      Magic = Hdr.Pe32->OptionalHeader.Magic;\r
-    }\r
-\r
-    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
-      //\r
-      // Use PE32 offset get Debug Directory Entry\r
-      //\r
-      NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;\r
-      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
-      DebugEntry     = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);\r
-    } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {\r
-      //\r
-      // Use PE32+ offset get Debug Directory Entry\r
-      //\r
-      NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;\r
-      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);\r
-      DebugEntry     = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);\r
-    }\r
-\r
-    if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {\r
-      DirectoryEntry = NULL;\r
-      DebugEntry = NULL;\r
-    }\r
-  } else {\r
-    return NULL;\r
-  }\r
-\r
-  if (DebugEntry == NULL || DirectoryEntry == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY), DebugEntry++) {\r
-    if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {\r
-      if (DebugEntry->SizeOfData > 0) {\r
-        CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust);\r
-        switch (* (UINT32 *) CodeViewEntryPointer) {\r
-        case CODEVIEW_SIGNATURE_NB10:\r
-          return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));\r
-        case CODEVIEW_SIGNATURE_RSDS:\r
-          return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));\r
-        case CODEVIEW_SIGNATURE_MTOC:\r
-          return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));\r
-        default:\r
-          break;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-\r
-/**\r
-  Returns the size of the PE/COFF headers\r
-\r
-  Returns the size of the PE/COFF header specified by Pe32Data.\r
-  If Pe32Data is NULL, then ASSERT().\r
-\r
-  @param  Pe32Data   Pointer to the PE/COFF image that is loaded in system\r
-                     memory.\r
-\r
-  @return Size of PE/COFF header in bytes or zero if not a valid image.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-PeCoffGetSizeOfHeaders (\r
-  IN VOID     *Pe32Data\r
-  )\r
-{\r
-  EFI_IMAGE_DOS_HEADER                  *DosHdr;\r
-  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
-  UINTN                                 SizeOfHeaders;\r
-\r
-  ASSERT (Pe32Data   != NULL);\r
\r
-  DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;\r
-  if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
-    //\r
-    // DOS image header is present, so read the PE header after the DOS image header.\r
-    //\r
-    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));\r
-  } else {\r
-    //\r
-    // DOS image header is not present, so PE header is at the image base.\r
-    //\r
-    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;\r
-  }\r
-\r
-  if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
-    SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;\r
-  } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {\r
-    SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders;\r
-  } else {\r
-    SizeOfHeaders = 0;\r
-  }\r
-\r
-  return SizeOfHeaders;\r
-}\r
-\r
diff --git a/InOsEmuPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.inf b/InOsEmuPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.inf
deleted file mode 100644 (file)
index d09fd22..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-## @file\r
-# Component description file for the EdkNt32PeiPeCoffGetEntryPointLib library.\r
-#\r
-# PeCoffGetEntryPointLib library class for NT32 instance implemented by use NTPeiLoadFile PPI.\r
-# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = PeiEmuPeCoffGetEntryPointLib\r
-  FILE_GUID                      = 1CBED347-7DE6-BC48-AC68-3758598124D2\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = PeCoffGetEntryPointLib \r
-\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  PeiEmuPeCoffGetEntryPointLib.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  PeiServicesLib\r
-  DebugLib\r
-\r
-\r
-[Ppis]\r
-  gEmuThunkPpiGuid                       # PPI ALWAYS_CONSUMED\r
-\r
diff --git a/InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c b/InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c
deleted file mode 100644 (file)
index aa4e80c..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/** @file\r
-  Serial Port Lib that thunks back to Emulator services to write to StdErr. \r
-  All read functions are stubed out. There is no constructor so this lib can \r
-  be linked with PEI Core.\r
-\r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-#include <PiPei.h>\r
-#include <Library/SerialPortLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-\r
-#include <Ppi/EmuThunk.h>\r
-#include <Protocol/EmuThunk.h>\r
-\r
-\r
-\r
-/**\r
-  Initialize the serial device hardware.\r
-  \r
-  If no initialization is required, then return RETURN_SUCCESS.\r
-  If the serial device was successfully initialized, then return RETURN_SUCCESS.\r
-  If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.\r
-  \r
-  @retval RETURN_SUCCESS        The serial device was initialized.\r
-  @retval RETURN_DEVICE_ERROR   The serial device could not be initialized.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortInitialize (\r
-  VOID\r
-  )\r
-{\r
-  return RETURN_SUCCESS;\r
-}\r
-\r
-/**\r
-  Write data from buffer to serial device. \r
\r
-  Writes NumberOfBytes data bytes from Buffer to the serial device.  \r
-  The number of bytes actually written to the serial device is returned.\r
-  If the return value is less than NumberOfBytes, then the write operation failed.\r
-  If Buffer is NULL, then ASSERT(). \r
-  If NumberOfBytes is zero, then return 0.\r
-\r
-  @param  Buffer           The pointer to the data buffer to be written.\r
-  @param  NumberOfBytes    The number of bytes to written to the serial device.\r
-\r
-  @retval 0                NumberOfBytes is 0.\r
-  @retval >0               The number of bytes written to the serial device.  \r
-                           If this value is less than NumberOfBytes, then the read operation failed.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-SerialPortWrite (\r
-  IN UINT8     *Buffer,\r
-  IN UINTN     NumberOfBytes\r
-  )\r
-{\r
-  EMU_THUNK_PPI           *ThunkPpi;\r
-  EFI_STATUS              Status;\r
-  EMU_THUNK_PROTOCOL      *Thunk;\r
-\r
-  //\r
-  // Locate EmuThunkPpi for retrieving standard output handle\r
-  //\r
-  Status = PeiServicesLocatePpi (\r
-              &gEmuThunkPpiGuid,\r
-              0,\r
-              NULL,\r
-              (VOID **) &ThunkPpi\r
-             );\r
-  if (!EFI_ERROR (Status)) {\r
-    Thunk  = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();\r
-    return Thunk->WriteStdErr (Buffer, NumberOfBytes);\r
-  }\r
-  \r
-  return 0;\r
-}\r
-\r
-\r
-/**\r
-  Read data from serial device and save the datas in buffer.\r
\r
-  Reads NumberOfBytes data bytes from a serial device into the buffer\r
-  specified by Buffer. The number of bytes actually read is returned. \r
-  If the return value is less than NumberOfBytes, then the rest operation failed.\r
-  If Buffer is NULL, then ASSERT(). \r
-  If NumberOfBytes is zero, then return 0.\r
-\r
-  @param  Buffer           The pointer to the data buffer to store the data read from the serial device.\r
-  @param  NumberOfBytes    The number of bytes which will be read.\r
-\r
-  @retval 0                Read data failed; No data is to be read.\r
-  @retval >0               The actual number of bytes read from serial device.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-SerialPortRead (\r
-  OUT UINT8     *Buffer,\r
-  IN  UINTN     NumberOfBytes\r
-  )\r
-{\r
-  return 0;\r
-}\r
-\r
-/**\r
-  Polls a serial device to see if there is any data waiting to be read.\r
-\r
-  Polls a serial device to see if there is any data waiting to be read.\r
-  If there is data waiting to be read from the serial device, then TRUE is returned.\r
-  If there is no data waiting to be read from the serial device, then FALSE is returned.\r
-\r
-  @retval TRUE             Data is waiting to be read from the serial device.\r
-  @retval FALSE            There is no data waiting to be read from the serial device.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-SerialPortPoll (\r
-  VOID\r
-  )\r
-{\r
-  return FALSE;\r
-}\r
-\r
-\r
diff --git a/InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf b/InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf
deleted file mode 100644 (file)
index 911957c..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-## @file\r
-#  Write only instance of Serial Port Library with empty functions.\r
-#\r
-#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-#  Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = PeiEmuSerialPortLibNull\r
-  FILE_GUID                      = E4541241-8897-411a-91F8-7D7E45837146\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = SerialPortLib| PEI_CORE PEIM SEC\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  PeiEmuSerialPortLib.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-  \r
-[LibraryClasses]\r
-  PeiServicesLib\r
-\r
-[Ppis]\r
-  gEmuThunkPpiGuid                       # PPI ALWAYS_CONSUMED\r
-\r
-\r
-  \r
-\r
diff --git a/InOsEmuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c b/InOsEmuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
deleted file mode 100644 (file)
index 3454660..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/** @file\r
-  PEI Services Table Pointer Library.\r
-  \r
-  This library is used for PEIM which does executed from flash device directly but\r
-  executed in memory.\r
-\r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  Portiions copyrigth (c) 2011, Apple Inc. All rights reserved. \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiPei.h>\r
-#include <Library/PeiServicesTablePointerLib.h>\r
-#include <Library/DebugLib.h>\r
-\r
-#include <Ppi/MemoryDiscovered.h>\r
-\r
-\r
-CONST EFI_PEI_SERVICES  **gPeiServices = NULL;\r
-\r
-/**\r
-  Caches a pointer PEI Services Table. \r
\r
-  Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer \r
-  in a CPU specific manner as specified in the CPU binding section of the Platform Initialization \r
-  Pre-EFI Initialization Core Interface Specification. \r
-  \r
-  If PeiServicesTablePointer is NULL, then ASSERT().\r
-  \r
-  @param    PeiServicesTablePointer   The address of PeiServices pointer.\r
-**/\r
-VOID\r
-EFIAPI\r
-SetPeiServicesTablePointer (\r
-  IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r
-  )\r
-{\r
-  ASSERT (PeiServicesTablePointer != NULL);\r
-  ASSERT (*PeiServicesTablePointer != NULL);\r
-  gPeiServices = PeiServicesTablePointer;\r
-}\r
-\r
-/**\r
-  Retrieves the cached value of the PEI Services Table pointer.\r
-\r
-  Returns the cached value of the PEI Services Table pointer in a CPU specific manner \r
-  as specified in the CPU binding section of the Platform Initialization Pre-EFI \r
-  Initialization Core Interface Specification.\r
-  \r
-  If the cached PEI Services Table pointer is NULL, then ASSERT().\r
-\r
-  @return  The pointer to PeiServices.\r
-\r
-**/\r
-CONST EFI_PEI_SERVICES **\r
-EFIAPI\r
-GetPeiServicesTablePointer (\r
-  VOID\r
-  )\r
-{\r
-  ASSERT (gPeiServices != NULL);\r
-  ASSERT (*gPeiServices != NULL);\r
-  return gPeiServices;\r
-}\r
-\r
-\r
-\r
-/**\r
-  Notification service to be called when gEmuThunkPpiGuid is installed.\r
-\r
-  @param  PeiServices                 Indirect reference to the PEI Services Table.\r
-  @param  NotifyDescriptor          Address of the notification descriptor data structure. Type\r
-          EFI_PEI_NOTIFY_DESCRIPTOR is defined above.\r
-  @param  Ppi                             Address of the PPI that was installed.\r
-\r
-  @retval   EFI_STATUS                This function will install a PPI to PPI database. The status\r
-                                                  code will be the code for (*PeiServices)->InstallPpi.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesTablePointerNotifyCallback (\r
-  IN EFI_PEI_SERVICES              **PeiServices,\r
-  IN EFI_PEI_NOTIFY_DESCRIPTOR     *NotifyDescriptor,\r
-  IN VOID                          *Ppi\r
-  )\r
-{\r
-  gPeiServices = (CONST EFI_PEI_SERVICES  **)PeiServices;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnThunkList = {\r
-  (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
-  &gEfiPeiMemoryDiscoveredPpiGuid,\r
-  PeiServicesTablePointerNotifyCallback \r
-};\r
-\r
-\r
-/**\r
-  Constructor register notification on when PPI updates. If PPI is \r
-  alreay installed registering the notify will cause the handle to \r
-  run.\r
-\r
-  @param  FileHandle   The handle of FFS header the loaded driver.\r
-  @param  PeiServices  The pointer to the PEI services.\r
-\r
-  @retval EFI_SUCCESS  The constructor always returns EFI_SUCCESS.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesTablePointerLibConstructor (\r
-  IN EFI_PEI_FILE_HANDLE        FileHandle,\r
-  IN CONST EFI_PEI_SERVICES     **PeiServices\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-\r
-  gPeiServices = (CONST EFI_PEI_SERVICES  **)PeiServices;\r
-\r
-  // register to be told when PeiServices pointer is updated\r
-  Status = (*PeiServices)->NotifyPpi (PeiServices, &mNotifyOnThunkList);\r
-  ASSERT_EFI_ERROR (Status);\r
-  return Status;\r
-}\r
-\r
-\r
diff --git a/InOsEmuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf b/InOsEmuPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
deleted file mode 100644 (file)
index b5e9949..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-## @file\r
-# Instance of PEI Services Table Pointer Library using global variable for the table pointer.\r
-#\r
-# PEI Services Table Pointer Library implementation that retrieves a pointer to the\r
-#  PEI Services Table from a global variable. Not available to modules that execute from\r
-#  read-only memory.\r
-#\r
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = InOsEmuPkgPeiServicesTablePointerLib\r
-  FILE_GUID                      =  5FD8B4ED-D66F-C144-9953-AC557C649925\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = PeiServicesTablePointerLib|PEIM\r
-\r
-  CONSTRUCTOR                    = PeiServicesTablePointerLibConstructor\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC (EBC is for build only)\r
-#\r
-\r
-[Sources]\r
-  PeiServicesTablePointer.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-\r
-[LibraryClasses]\r
-  DebugLib\r
-\r
-[Ppis]\r
-  gEfiPeiMemoryDiscoveredPpiGuid\r
-\r
diff --git a/InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c b/InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c
deleted file mode 100644 (file)
index 3f15403..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/** @file\r
-  PEI Services Table Pointer Library.\r
-  \r
-  Store PEI Services Table pointer via gInOsEmuPkgTokenSpaceGuid.PcdPeiServicesTablePage.\r
-  This emulates a platform SRAM. The PI mechaism does not work in the emulator due to\r
-  lack of privledge.\r
-\r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  Portiions copyrigth (c) 2011, Apple Inc. All rights reserved. \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiPei.h>\r
-#include <Library/PeiServicesTablePointerLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/EmuMagicPageLib.h>\r
-\r
-\r
-/**\r
-  Caches a pointer PEI Services Table. \r
\r
-  Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer \r
-  in a CPU specific manner as specified in the CPU binding section of the Platform Initialization \r
-  Pre-EFI Initialization Core Interface Specification. \r
-  \r
-  If PeiServicesTablePointer is NULL, then ASSERT().\r
-  \r
-  @param    PeiServicesTablePointer   The address of PeiServices pointer.\r
-**/\r
-VOID\r
-EFIAPI\r
-SetPeiServicesTablePointer (\r
-  IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r
-  )\r
-{\r
-  ASSERT (PeiServicesTablePointer != NULL);\r
-  ASSERT (*PeiServicesTablePointer != NULL);\r
-  EMU_MAGIC_PAGE()->PeiServicesTablePointer = PeiServicesTablePointer;\r
-}\r
-\r
-/**\r
-  Retrieves the cached value of the PEI Services Table pointer.\r
-\r
-  Returns the cached value of the PEI Services Table pointer in a CPU specific manner \r
-  as specified in the CPU binding section of the Platform Initialization Pre-EFI \r
-  Initialization Core Interface Specification.\r
-  \r
-  If the cached PEI Services Table pointer is NULL, then ASSERT().\r
-\r
-  @return  The pointer to PeiServices.\r
-\r
-**/\r
-CONST EFI_PEI_SERVICES **\r
-EFIAPI\r
-GetPeiServicesTablePointer (\r
-  VOID\r
-  )\r
-{\r
-  CONST EFI_PEI_SERVICES **PeiServicesTablePointer;\r
-  \r
-  PeiServicesTablePointer = EMU_MAGIC_PAGE()->PeiServicesTablePointer;\r
-  ASSERT (PeiServicesTablePointer != NULL);\r
-  ASSERT (*PeiServicesTablePointer != NULL);\r
-  return PeiServicesTablePointer;\r
-}\r
-\r
-\r
-\r
diff --git a/InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointerLibMagicPage.inf b/InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointerLibMagicPage.inf
deleted file mode 100644 (file)
index d16b845..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-## @file\r
-#  PEI Services Table Pointer Library.\r
-#  \r
-#  Store PEI Services Table pointer via gInOsEmuPkgTokenSpaceGuid.PcdPeiServicesTablePage.\r
-#  This emulates a platform SRAM. The PI mechaism does not work in the emulator due to\r
-#  lack of privledge.\r
-#\r
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = InOsEmuPkgPeiServicesTablePointerLib\r
-  FILE_GUID                      = 7488FC06-370A-1C41-B05C-7395559A535A\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = PeiServicesTablePointerLib|PEIM PEI_CORE SEC\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC (EBC is for build only)\r
-#\r
-\r
-[Sources]\r
-  PeiServicesTablePointer.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  DebugLib\r
-\r
-[Pcd]\r
-  gInOsEmuPkgTokenSpaceGuid.PcdPeiServicesTablePage\r
diff --git a/InOsEmuPkg/Library/PeiTimerLib/PeiTimerLib.c b/InOsEmuPkg/Library/PeiTimerLib/PeiTimerLib.c
deleted file mode 100644 (file)
index caf8a7c..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-/** @file\r
-  A non-functional instance of the Timer Library.\r
-\r
-  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiPei.h>\r
-#include <Library/TimerLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-\r
-#include <Ppi/EmuThunk.h>\r
-#include <Protocol/EmuThunk.h>\r
-\r
-/**\r
-  Stalls the CPU for at least the given number of microseconds.\r
-\r
-  Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
-\r
-  @param  MicroSeconds  The minimum number of microseconds to delay.\r
-\r
-  @return The value of MicroSeconds inputted.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-MicroSecondDelay (\r
-  IN      UINTN                     MicroSeconds\r
-  )\r
-{\r
-  return NanoSecondDelay (MicroSeconds * 1000);\r
-}\r
-\r
-/**\r
-  Stalls the CPU for at least the given number of nanoseconds.\r
-\r
-  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
-\r
-  @param  NanoSeconds The minimum number of nanoseconds to delay.\r
-\r
-  @return The value of NanoSeconds inputted.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-NanoSecondDelay (\r
-  IN      UINTN                     NanoSeconds\r
-  )\r
-{\r
-  EMU_THUNK_PPI           *ThunkPpi;\r
-  EFI_STATUS              Status;\r
-  EMU_THUNK_PROTOCOL      *Thunk;\r
-\r
-  //\r
-  // Locate EmuThunkPpi for \r
-  //\r
-  Status = PeiServicesLocatePpi (\r
-              &gEmuThunkPpiGuid,\r
-              0,\r
-              NULL,\r
-              (VOID **) &ThunkPpi\r
-             );\r
-  if (!EFI_ERROR (Status)) {   \r
-    Thunk  = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();\r
-    Thunk->Sleep (NanoSeconds * 100);\r
-    return NanoSeconds;\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-/**\r
-  Retrieves the current value of a 64-bit free running performance counter.\r
-\r
-  The counter can either count up by 1 or count down by 1. If the physical\r
-  performance counter counts by a larger increment, then the counter values\r
-  must be translated. The properties of the counter can be retrieved from\r
-  GetPerformanceCounterProperties().\r
-\r
-  @return The current value of the free running performance counter.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-GetPerformanceCounter (\r
-  VOID\r
-  )\r
-{\r
-  EMU_THUNK_PPI           *ThunkPpi;\r
-  EFI_STATUS              Status;\r
-  EMU_THUNK_PROTOCOL      *Thunk;\r
-\r
-  //\r
-  // Locate EmuThunkPpi for \r
-  //\r
-  Status = PeiServicesLocatePpi (\r
-              &gEmuThunkPpiGuid,\r
-              0,\r
-              NULL,\r
-              (VOID **) &ThunkPpi\r
-             );\r
-  if (!EFI_ERROR (Status)) {   \r
-    Thunk  = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();\r
-    return  Thunk->QueryPerformanceCounter ();\r
-  }\r
-\r
-  return 0;\r
-}\r
-\r
-/**\r
-  Retrieves the 64-bit frequency in Hz and the range of performance counter\r
-  values.\r
-\r
-  If StartValue is not NULL, then the value that the performance counter starts\r
-  with immediately after is it rolls over is returned in StartValue. If\r
-  EndValue is not NULL, then the value that the performance counter end with\r
-  immediately before it rolls over is returned in EndValue. The 64-bit\r
-  frequency of the performance counter in Hz is always returned. If StartValue\r
-  is less than EndValue, then the performance counter counts up. If StartValue\r
-  is greater than EndValue, then the performance counter counts down. For\r
-  example, a 64-bit free running counter that counts up would have a StartValue\r
-  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
-  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
-\r
-  @param  StartValue  The value the performance counter starts with when it\r
-                      rolls over.\r
-  @param  EndValue    The value that the performance counter ends with before\r
-                      it rolls over.\r
-\r
-  @return The frequency in Hz.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-GetPerformanceCounterProperties (\r
-  OUT      UINT64                    *StartValue,  OPTIONAL\r
-  OUT      UINT64                    *EndValue     OPTIONAL\r
-  )\r
-{\r
-  EMU_THUNK_PPI           *ThunkPpi;\r
-  EFI_STATUS              Status;\r
-  EMU_THUNK_PROTOCOL      *Thunk;\r
-\r
-  //\r
-  // Locate EmuThunkPpi for \r
-  //\r
-  Status = PeiServicesLocatePpi (\r
-              &gEmuThunkPpiGuid,\r
-              0,\r
-              NULL,\r
-              (VOID **) &ThunkPpi\r
-             );\r
-  if (!EFI_ERROR (Status)) {\r
-    if (StartValue != NULL) {\r
-      *StartValue = 0ULL;\r
-    }\r
-    if (EndValue != NULL) {\r
-      *EndValue = (UINT64)-1LL;\r
-    }\r
-    \r
-    Thunk  = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();\r
-    return  Thunk->QueryPerformanceFrequency ();\r
-  }\r
-\r
-  return 0;\r
-}\r
diff --git a/InOsEmuPkg/Library/PeiTimerLib/PeiTimerLib.inf b/InOsEmuPkg/Library/PeiTimerLib/PeiTimerLib.inf
deleted file mode 100644 (file)
index c9f4858..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-## @file\r
-#  NULL instance of Timer Library as a template.\r
-#\r
-#  A non-functional instance of the Timer Library that can be used as a template\r
-#  for the implementation of a functional timer library instance. This library instance can\r
-#  also be used to test build DXE, Runtime, DXE SAL, and DXE SMM modules that require timer\r
-#  services as well as EBC modules that require timer services.\r
-#\r
-#  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuPeiTimerLib\r
-  FILE_GUID                      = 6ABE5FDC-AE4B-474E-8E52-9546C96AE536\r
-  MODULE_TYPE                    = BASE\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = TimerLib|PEIM PEI_CORE SEC\r
-\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  PeiTimerLib.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  DebugLib\r
-  PeiServicesLib\r
-\r
-[Ppis]\r
-  gEmuThunkPpiGuid
\ No newline at end of file
diff --git a/InOsEmuPkg/Library/SecPeiServicesLib/FwVol.c b/InOsEmuPkg/Library/SecPeiServicesLib/FwVol.c
deleted file mode 100644 (file)
index ae4ebfb..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-/*++ @file
-  A simple FV stack so the SEC can extract the SEC Core from an
-  FV.
-
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
-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 <PiPei.h>
-
-
-#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
-  (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
-
-EFI_FFS_FILE_STATE
-GetFileState (
-  IN UINT8                ErasePolarity,
-  IN EFI_FFS_FILE_HEADER  *FfsHeader
-  )
-/*++
-
-Routine Description:
-  Returns the highest bit set of the State field
-
-Arguments:
-  ErasePolarity   - Erase Polarity  as defined by EFI_FVB2_ERASE_POLARITY
-                    in the Attributes field.
-  FfsHeader       - Pointer to FFS File Header.
-
-Returns:
-  Returns the highest bit in the State field
-
-**/
-{
-  EFI_FFS_FILE_STATE  FileState;
-  EFI_FFS_FILE_STATE  HighestBit;
-
-  FileState = FfsHeader->State;
-
-  if (ErasePolarity != 0) {
-    FileState = (EFI_FFS_FILE_STATE)~FileState;
-  }
-
-  HighestBit = 0x80;
-  while (HighestBit != 0 && (HighestBit & FileState) == 0) {
-    HighestBit >>= 1;
-  }
-
-  return HighestBit;
-}
-
-UINT8
-CalculateHeaderChecksum (
-  IN EFI_FFS_FILE_HEADER  *FileHeader
-  )
-/*++
-
-Routine Description:
-  Calculates the checksum of the header of a file.
-
-Arguments:
-  FileHeader       - Pointer to FFS File Header.
-
-Returns:
-  Checksum of the header.
-  
-**/
-{
-  UINT8 *ptr;
-  UINTN Index;
-  UINT8 Sum;
-
-  Sum = 0;
-  ptr = (UINT8 *) FileHeader;
-
-  for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) {
-    Sum = (UINT8) (Sum + ptr[Index]);
-    Sum = (UINT8) (Sum + ptr[Index + 1]);
-    Sum = (UINT8) (Sum + ptr[Index + 2]);
-    Sum = (UINT8) (Sum + ptr[Index + 3]);
-  }
-
-  for (; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
-    Sum = (UINT8) (Sum + ptr[Index]);
-  }
-  //
-  // State field (since this indicates the different state of file).
-  //
-  Sum = (UINT8) (Sum - FileHeader->State);
-  //
-  // Checksum field of the file is not part of the header checksum.
-  //
-  Sum = (UINT8) (Sum - FileHeader->IntegrityCheck.Checksum.File);
-
-  return Sum;
-}
-
-EFI_STATUS
-SecFfsFindNextFile (
-  IN EFI_FV_FILETYPE             SearchType,
-  IN EFI_PEI_FV_HANDLE           FvHandle,
-  IN OUT EFI_PEI_FILE_HANDLE     *FileHandle
-  )
-/*++
-
-Routine Description:
-    Given the input file pointer, search for the next matching file in the
-    FFS volume as defined by SearchType. The search starts from FileHeader inside
-    the Firmware Volume defined by FwVolHeader.
-
-Arguments:
-    SearchType - Filter to find only files of this type.
-                 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
-    FwVolHeader - Pointer to the FV header of the volume to search.
-                  This parameter must point to a valid FFS volume.
-    FileHeader  - Pointer to the current file from which to begin searching.
-                  This pointer will be updated upon return to reflect the file
-                  found.
-
-Returns:
-    EFI_NOT_FOUND - No files matching the search criteria were found
-    EFI_SUCCESS
-
-**/
-{
-  EFI_FFS_FILE_HEADER *FfsFileHeader;
-  UINT32              FileLength;
-  UINT32              FileOccupiedSize;
-  UINT32              FileOffset;
-  UINT64              FvLength;
-  UINT8               ErasePolarity;
-  UINT8               FileState;
-  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;
-  EFI_FFS_FILE_HEADER         **FileHeader;
-
-  //
-  // Convert the handle of FV to FV header for memory-mapped firmware volume
-  //
-  FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FvHandle;
-  FileHeader  = (EFI_FFS_FILE_HEADER **)FileHandle;
-
-  FvLength = FwVolHeader->FvLength;
-  if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {
-    ErasePolarity = 1;
-  } else {
-    ErasePolarity = 0;
-  }
-  //
-  // If FileHeader is not specified (NULL) start with the first file in the
-  // firmware volume.  Otherwise, start from the FileHeader.
-  //
-  if (*FileHeader == NULL) {
-    FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength);
-  } else {
-    //
-    // Length is 24 bits wide so mask upper 8 bits
-    // FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.
-    //
-    FileLength        = *(UINT32 *) (*FileHeader)->Size & 0x00FFFFFF;
-    FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);
-    FfsFileHeader     = (EFI_FFS_FILE_HEADER *) ((UINT8 *) *FileHeader + FileOccupiedSize);
-  }
-
-  FileOffset = (UINT32) ((UINT8 *) FfsFileHeader - (UINT8 *) FwVolHeader);
-
-  while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
-    //
-    // Get FileState which is the highest bit of the State
-    //
-    FileState = GetFileState (ErasePolarity, FfsFileHeader);
-
-    switch (FileState) {
-
-    case EFI_FILE_HEADER_INVALID:
-      FileOffset += sizeof (EFI_FFS_FILE_HEADER);
-      FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
-      break;
-
-    case EFI_FILE_DATA_VALID:
-    case EFI_FILE_MARKED_FOR_UPDATE:
-      if (CalculateHeaderChecksum (FfsFileHeader) == 0) {
-        FileLength        = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
-        FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);
-
-        if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
-
-          *FileHeader = FfsFileHeader;
-
-          return EFI_SUCCESS;
-        }
-
-        FileOffset += FileOccupiedSize;
-        FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
-      } else {
-        return EFI_NOT_FOUND;
-      }
-      break;
-
-    case EFI_FILE_DELETED:
-      FileLength        = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
-      FileOccupiedSize  = GET_OCCUPIED_SIZE (FileLength, 8);
-      FileOffset += FileOccupiedSize;
-      FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
-      break;
-
-    default:
-      return EFI_NOT_FOUND;
-
-    }
-  }
-
-  return EFI_NOT_FOUND;
-}
-
-EFI_STATUS
-SecFfsFindSectionData (
-  IN EFI_SECTION_TYPE      SectionType,
-  IN EFI_FFS_FILE_HEADER   *FfsFileHeader,
-  IN OUT VOID              **SectionData
-  )
-/*++
-
-Routine Description:
-    Given the input file pointer, search for the next matching section in the
-    FFS volume.
-
-Arguments:
-    SearchType    - Filter to find only sections of this type.
-    FfsFileHeader - Pointer to the current file to search.
-    SectionData   - Pointer to the Section matching SectionType in FfsFileHeader.
-                     NULL if section not found
-
-Returns:
-    EFI_NOT_FOUND - No files matching the search criteria were found
-    EFI_SUCCESS
-
-**/
-{
-  UINT32                    FileSize;
-  EFI_COMMON_SECTION_HEADER *Section;
-  UINT32                    SectionLength;
-  UINT32                    ParsedLength;
-
-  //
-  // Size is 24 bits wide so mask upper 8 bits.
-  //    Does not include FfsFileHeader header size
-  // FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
-  //
-  Section   = (EFI_COMMON_SECTION_HEADER *) (FfsFileHeader + 1);
-  FileSize  = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
-  FileSize -= sizeof (EFI_FFS_FILE_HEADER);
-
-  *SectionData  = NULL;
-  ParsedLength  = 0;
-  while (ParsedLength < FileSize) {
-    if (Section->Type == SectionType) {
-      *SectionData = (VOID *) (Section + 1);
-      return EFI_SUCCESS;
-    }
-    //
-    // Size is 24 bits wide so mask upper 8 bits.
-    // SectionLength is adjusted it is 4 byte aligned.
-    // Go to the next section
-    //
-    SectionLength = *(UINT32 *) Section->Size & 0x00FFFFFF;
-    SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
-
-    ParsedLength += SectionLength;
-    Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + SectionLength);
-  }
-
-  return EFI_NOT_FOUND;
-}
-
diff --git a/InOsEmuPkg/Library/SecPeiServicesLib/PeiServicesLib.c b/InOsEmuPkg/Library/SecPeiServicesLib/PeiServicesLib.c
deleted file mode 100644 (file)
index bdbf687..0000000
+++ /dev/null
@@ -1,567 +0,0 @@
-/** @file\r
-  Implementation for PEI Services Library.\r
-\r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-\r
-#include <PiPei.h>\r
-#include <Library/EmuMagicPageLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-\r
-\r
-\r
-EFI_STATUS\r
-SecFfsFindNextFile (\r
-  IN EFI_FV_FILETYPE            SearchType,\r
-  IN EFI_PEI_FV_HANDLE          VolumeHandle,\r
-  IN OUT EFI_PEI_FILE_HANDLE    *FileHandle\r
-  );\r
-\r
-EFI_STATUS\r
-SecFfsFindSectionData (\r
-  IN EFI_SECTION_TYPE           SectionType,\r
-  IN EFI_PEI_FILE_HANDLE        FileHandle,\r
-  OUT VOID                      **SectionData\r
-  );\r
-\r
-\r
-/**\r
-  This service enables a given PEIM to register an interface into the PEI Foundation.\r
-\r
-  @param  PpiList               A pointer to the list of interfaces that the caller shall install.\r
-\r
-  @retval EFI_SUCCESS           The interface was successfully installed.\r
-  @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.\r
-  @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
-                                EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
-  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesInstallPpi (\r
-  IN CONST EFI_PEI_PPI_DESCRIPTOR     *PpiList\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  This service enables PEIMs to replace an entry in the PPI database with an alternate entry.\r
-\r
-  @param  OldPpi                The pointer to the old PEI PPI Descriptors.\r
-  @param  NewPpi                The pointer to the new PEI PPI Descriptors.\r
-\r
-  @retval EFI_SUCCESS           The interface was successfully installed.\r
-  @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.\r
-  @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the\r
-                                EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.\r
-  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
-  @retval EFI_NOT_FOUND         The PPI for which the reinstallation was requested has not been\r
-                                installed.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesReInstallPpi (\r
-  IN CONST EFI_PEI_PPI_DESCRIPTOR     *OldPpi,\r
-  IN CONST EFI_PEI_PPI_DESCRIPTOR     *NewPpi\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  This service enables PEIMs to discover a given instance of an interface.\r
-\r
-  So this is, well a hack, so we can reuse the same libraries as the PEI Core \r
-  for XIP modules.... \r
-\r
-  @param  Guid                  A pointer to the GUID whose corresponding interface needs to be\r
-                                found.\r
-  @param  Instance              The N-th instance of the interface that is required.\r
-  @param  PpiDescriptor         A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.\r
-  @param  Ppi                   A pointer to the instance of the interface.\r
-\r
-  @retval EFI_SUCCESS           The interface was successfully returned.\r
-  @retval EFI_NOT_FOUND         The PPI descriptor is not found in the database.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesLocatePpi (\r
-  IN CONST EFI_GUID             *Guid,\r
-  IN UINTN                      Instance,\r
-  IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
-  IN OUT VOID                   **Ppi\r
-  )\r
-{\r
-  EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
-   \r
-  if (Instance != 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  \r
-  for (PpiList = EMU_MAGIC_PAGE()->PpiList; ; PpiList++) {\r
-    if (CompareGuid (PpiList->Guid, Guid)) {\r
-      if (PpiDescriptor != NULL) {\r
-        *PpiDescriptor = PpiList;\r
-      }\r
-      if (Ppi != NULL) {\r
-        *Ppi = PpiList->Ppi;\r
-      }\r
-      return EFI_SUCCESS;\r
-    }\r
-    \r
-    if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r
-      break;\r
-    }\r
-  } \r
-  \r
-  \r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  This service enables PEIMs to register a given service to be invoked when another service is\r
-  installed or reinstalled.\r
-\r
-  @param  NotifyList            A pointer to the list of notification interfaces \r
-                                that the caller shall install.\r
-\r
-  @retval EFI_SUCCESS           The interface was successfully installed.\r
-  @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.\r
-  @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do\r
-                                 not have the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES\r
-                                 bit set in the Flags field.\r
-  @retval EFI_OUT_OF_RESOURCES  There is no additional space in the PPI database.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesNotifyPpi (\r
-  IN CONST EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyList\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  This service enables PEIMs to ascertain the present value of the boot mode.\r
-\r
-  @param  BootMode              A pointer to contain the value of the boot mode.\r
-\r
-  @retval EFI_SUCCESS           The boot mode was returned successfully.\r
-  @retval EFI_INVALID_PARAMETER BootMode is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesGetBootMode (\r
-  OUT EFI_BOOT_MODE          *BootMode\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  This service enables PEIMs to update the boot mode variable.\r
-\r
-  @param  BootMode              The value of the boot mode to set.\r
-\r
-  @retval EFI_SUCCESS           The value was successfully updated\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesSetBootMode (\r
-  IN EFI_BOOT_MODE              BootMode\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  This service enables a PEIM to ascertain the address of the list of HOBs in memory.\r
-\r
-  @param  HobList               A pointer to the list of HOBs that the PEI Foundation \r
-                                will initialize.\r
-  \r
-  @retval EFI_SUCCESS           The list was successfully returned.\r
-  @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesGetHobList (\r
-  OUT VOID                      **HobList\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  This service enables PEIMs to create various types of HOBs.\r
-\r
-  @param  Type                  The type of HOB to be installed.\r
-  @param  Length                The length of the HOB to be added.\r
-  @param  Hob                   The address of a pointer that will contain the \r
-                                HOB header.\r
-\r
-  @retval EFI_SUCCESS           The HOB was successfully created.\r
-  @retval EFI_OUT_OF_RESOURCES  There is no additional space for HOB creation.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesCreateHob (\r
-  IN UINT16                     Type,\r
-  IN UINT16                     Length,\r
-  OUT VOID                      **Hob\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  This service enables PEIMs to discover additional firmware volumes.\r
-\r
-  @param  Instance              This instance of the firmware volume to find.  The \r
-                                value 0 is the Boot Firmware Volume (BFV).\r
-  @param  VolumeHandle          Handle of the firmware volume header of the volume\r
-                                to return.\r
-\r
-  @retval EFI_SUCCESS           The volume was found.\r
-  @retval EFI_NOT_FOUND         The volume was not found.\r
-  @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesFfsFindNextVolume (\r
-  IN UINTN                          Instance,\r
-  IN OUT EFI_PEI_FV_HANDLE          *VolumeHandle\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  This service enables PEIMs to discover additional firmware files.\r
-\r
-  @param  SearchType            A filter to find files only of this type.\r
-  @param  VolumeHandle          The pointer to the firmware volume header of the \r
-                                volume to search. This parameter must point to a \r
-                                valid FFS volume. \r
-  @param  FileHandle            Handle of the current file from which to begin searching.\r
-\r
-  @retval EFI_SUCCESS           The file was found.\r
-  @retval EFI_NOT_FOUND         The file was not found.\r
-  @retval EFI_NOT_FOUND         The header checksum was not zero.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesFfsFindNextFile (\r
-  IN EFI_FV_FILETYPE            SearchType,\r
-  IN EFI_PEI_FV_HANDLE          VolumeHandle,\r
-  IN OUT EFI_PEI_FILE_HANDLE    *FileHandle\r
-  )\r
-{\r
-  return SecFfsFindNextFile (SearchType, VolumeHandle, FileHandle);\r
-}\r
-\r
-/**\r
-  This service enables PEIMs to discover sections of a given type within a valid FFS file.\r
-\r
-  @param  SectionType           The value of the section type to find.\r
-  @param  FileHandle            A pointer to the file header that contains the set \r
-                                of sections to be searched.\r
-  @param  SectionData           A pointer to the discovered section, if successful.\r
-\r
-  @retval EFI_SUCCESS           The section was found.\r
-  @retval EFI_NOT_FOUND         The section was not found.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesFfsFindSectionData (\r
-  IN EFI_SECTION_TYPE           SectionType,\r
-  IN EFI_PEI_FILE_HANDLE        FileHandle,\r
-  OUT VOID                      **SectionData\r
-  )\r
-{\r
-  return SecFfsFindSectionData (SectionType, FileHandle, SectionData);\r
-}\r
-\r
-/**\r
-  This service enables PEIMs to register the permanent memory configuration\r
-  that has been initialized with the PEI Foundation.\r
-\r
-  @param  MemoryBegin           The value of a region of installed memory.\r
-  @param  MemoryLength          The corresponding length of a region of installed memory.\r
-\r
-  @retval EFI_SUCCESS           The region was successfully installed in a HOB.\r
-  @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.\r
-  @retval EFI_OUT_OF_RESOURCES  There is no additional space for HOB creation.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesInstallPeiMemory (\r
-  IN EFI_PHYSICAL_ADDRESS       MemoryBegin,\r
-  IN UINT64                     MemoryLength\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  This service enables PEIMs to allocate memory after the permanent memory has been\r
-   installed by a PEIM.\r
-\r
-  @param  MemoryType            Type of memory to allocate.\r
-  @param  Pages                 The number of pages to allocate.\r
-  @param  Memory                Pointer of memory allocated.\r
-\r
-  @retval EFI_SUCCESS           The memory range was successfully allocated.\r
-  @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.\r
-  @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.\r
-  @retval EFI_OUT_OF_RESOURCES  The pages could not be allocated.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesAllocatePages (\r
-  IN EFI_MEMORY_TYPE            MemoryType,\r
-  IN UINTN                      Pages,\r
-  OUT EFI_PHYSICAL_ADDRESS      *Memory\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  This service allocates memory from the Hand-Off Block (HOB) heap.\r
-\r
-  @param  Size                  The number of bytes to allocate from the pool.\r
-  @param  Buffer                If the call succeeds, a pointer to a pointer to \r
-                                the allocate buffer; otherwise, undefined.\r
-\r
-  @retval EFI_SUCCESS           The allocation was successful\r
-  @retval EFI_OUT_OF_RESOURCES  There is not enough heap to allocate the requested size.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesAllocatePool (\r
-  IN UINTN                      Size,\r
-  OUT VOID                      **Buffer\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  Resets the entire platform.\r
-\r
-  @retval EFI_SUCCESS           The function completed successfully.\r
-  @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesResetSystem (\r
-  VOID\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  This service is a wrapper for the PEI Service RegisterForShadow(), except the \r
-  pointer to the PEI Services Table has been removed.  See the Platform \r
-  Initialization Pre-EFI Initialization Core Interface Specification for details. \r
-\r
-  @param FileHandle             PEIM's file handle. Must be the currently\r
-                                executing PEIM.\r
-  \r
-  @retval EFI_SUCCESS           The PEIM was successfully registered for\r
-                                shadowing.\r
-\r
-  @retval EFI_ALREADY_STARTED   The PEIM was previously\r
-                                registered for shadowing.\r
-\r
-  @retval EFI_NOT_FOUND         The FileHandle does not refer to a\r
-                                valid file handle.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesRegisterForShadow (\r
-  IN  EFI_PEI_FILE_HANDLE FileHandle\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services \r
-  Table has been removed.  See the Platform Initialization Pre-EFI Initialization Core Interface \r
-  Specification for details. \r
-\r
-  @param FileHandle              The handle of the file.\r
-\r
-  @param FileInfo                 Upon exit, points to the file's\r
-                                  information.\r
-\r
-  @retval EFI_SUCCESS             File information returned.\r
-  \r
-  @retval EFI_INVALID_PARAMETER   If FileHandle does not\r
-                                  represent a valid file.\r
-  \r
-  @retval EFI_INVALID_PARAMETER   FileInfo is NULL.\r
-  \r
-**/\r
-EFI_STATUS\r
-EFIAPI \r
-PeiServicesFfsGetFileInfo (\r
-  IN CONST  EFI_PEI_FILE_HANDLE   FileHandle,\r
-  OUT EFI_FV_FILE_INFO            *FileInfo\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-\r
-/**\r
-  This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services \r
-  Table has been removed.  See the Platform Initialization Pre-EFI Initialization Core Interface \r
-  Specification for details. \r
-\r
-  @param FileName                 A pointer to the name of the file to\r
-                                  find within the firmware volume.\r
-\r
-  @param VolumeHandle             The firmware volume to search FileHandle\r
-                                  Upon exit, points to the found file's\r
-                                  handle or NULL if it could not be found.\r
-  @param FileHandle               The pointer to found file handle \r
-\r
-  @retval EFI_SUCCESS             File was found.\r
-\r
-  @retval EFI_NOT_FOUND           File was not found.\r
-\r
-  @retval EFI_INVALID_PARAMETER   VolumeHandle or FileHandle or\r
-                                  FileName was NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesFfsFindFileByName (\r
-  IN CONST  EFI_GUID            *FileName,\r
-  IN CONST  EFI_PEI_FV_HANDLE   VolumeHandle,\r
-  OUT       EFI_PEI_FILE_HANDLE *FileHandle\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-\r
-/**\r
-  This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services \r
-  Table has been removed.  See the Platform Initialization Pre-EFI Initialization Core Interface \r
-  Specification for details. \r
-\r
-  @param VolumeHandle             Handle of the volume.\r
-\r
-  @param VolumeInfo               Upon exit, points to the volume's\r
-                                  information.\r
-\r
-  @retval EFI_SUCCESS             File information returned.\r
-  \r
-  @retval EFI_INVALID_PARAMETER   If FileHandle does not\r
-                                  represent a valid file.\r
-  \r
-  @retval EFI_INVALID_PARAMETER   If FileInfo is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PeiServicesFfsGetVolumeInfo (\r
-  IN  EFI_PEI_FV_HANDLE       VolumeHandle,\r
-  OUT EFI_FV_INFO             *VolumeInfo\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-/**\r
-  Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.\r
-  \r
-  This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using \r
-  the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.\r
-  If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().\r
-  If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().\r
-\r
-  \r
-  @param  FvFormat             Unique identifier of the format of the memory-mapped \r
-                               firmware volume.  This parameter is optional and \r
-                               may be NULL.  If NULL is specified, the \r
-                               EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.\r
-  @param  FvInfo               Points to a buffer which allows the \r
-                               EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume. \r
-                               The format of this buffer is specific to the FvFormat. \r
-                               For memory-mapped firmware volumes, this typically \r
-                               points to the first byte of the firmware volume.\r
-  @param  FvInfoSize           The size, in bytes, of FvInfo. For memory-mapped \r
-                               firmware volumes, this is typically the size of \r
-                               the firmware volume.\r
-  @param  ParentFvName         If the new firmware volume originated from a file \r
-                               in a different firmware volume, then this parameter \r
-                               specifies the GUID name of the originating firmware\r
-                               volume. Otherwise, this parameter must be NULL.\r
-  @param  ParentFileName       If the new firmware volume originated from a file \r
-                               in a different firmware volume, then this parameter \r
-                               specifies the GUID file name of the originating \r
-                               firmware file. Otherwise, this parameter must be NULL.\r
-**/\r
-VOID\r
-EFIAPI\r
-PeiServicesInstallFvInfoPpi (\r
-  IN CONST EFI_GUID                *FvFormat, OPTIONAL\r
-  IN CONST VOID                    *FvInfo,\r
-  IN       UINT32                  FvInfoSize,\r
-  IN CONST EFI_GUID                *ParentFvName, OPTIONAL\r
-  IN CONST EFI_GUID                *ParentFileName OPTIONAL\r
-  )\r
-{\r
-  ASSERT (FALSE);\r
-  return;\r
-}\r
-\r
diff --git a/InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf b/InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf
deleted file mode 100644 (file)
index 3fc6271..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-## @file\r
-# PEI Services Library implementation.\r
-#\r
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = SecPeiServicesLib\r
-  FILE_GUID                      = E3E4A441-8465-0F41-8AF4-F67EBE984099\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = PeiServicesLib|SEC PEIM PEI_CORE \r
-  PI_SPECIFICATION_VERSION       = 0x0001000A\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC (EBC is for build only)\r
-#\r
-\r
-[Sources]\r
-  PeiServicesLib.c\r
-  FwVol.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  DebugLib\r
-  BaseMemoryLib\r
-  PpiListLib\r
-\r
-[Pcd]\r
-  gInOsEmuPkgTokenSpaceGuid.PcdPeiServicesTablePage\r
-\r
-\r
-\r
-\r
-\r
diff --git a/InOsEmuPkg/Library/SecPpiListLib/PpiListLib.c b/InOsEmuPkg/Library/SecPpiListLib/PpiListLib.c
deleted file mode 100644 (file)
index 42c0d97..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*++ @file
-
-Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
-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 <PiPei.h>
-
-CONST EFI_PEI_PPI_DESCRIPTOR  *gPpiList = NULL;
-
diff --git a/InOsEmuPkg/Library/SecPpiListLib/SecPpiListLib.inf b/InOsEmuPkg/Library/SecPpiListLib/SecPpiListLib.inf
deleted file mode 100644 (file)
index 07c2c35..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-## @file\r
-# Place thunk PPI in HOB.\r
-#\r
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = SecPpiListLib\r
-  FILE_GUID                      = F950E820-0457-8143-86AD-30E4A45FD4BF\r
-  MODULE_TYPE                    = BASE\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = PpiListLib|SEC BASE USER_DEFINED\r
-\r
-[Sources]\r
-  PpiListLib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
diff --git a/InOsEmuPkg/Library/ThunkPpiList/ThunkPpiList.c b/InOsEmuPkg/Library/ThunkPpiList/ThunkPpiList.c
deleted file mode 100644 (file)
index 3c2fd93..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/** @file\r
-  Emulator Thunk to abstract OS services from pure EFI code\r
-\r
-  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-  \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiPei.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-\r
-\r
-UINTN                   gThunkPpiListSize = 0;\r
-EFI_PEI_PPI_DESCRIPTOR  *gThunkPpiList = NULL;\r
-\r
-\r
-\r
-EFI_PEI_PPI_DESCRIPTOR *\r
-GetThunkPpiList (\r
-  VOID\r
-  )\r
-{\r
-  UINTN Index;\r
-  \r
-  if (gThunkPpiList == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR)) - 1;\r
-  gThunkPpiList[Index].Flags |= EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r
-  \r
-  return gThunkPpiList;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-AddThunkPpi (\r
-  IN  UINTN     Flags,\r
-  IN  EFI_GUID  *Guid,\r
-  IN  VOID      *Ppi\r
-  )\r
-{\r
-  UINTN Index;\r
-\r
-  gThunkPpiList = ReallocatePool (\r
-                    gThunkPpiListSize,\r
-                    gThunkPpiListSize + sizeof (EFI_PEI_PPI_DESCRIPTOR),\r
-                    gThunkPpiList\r
-                    );\r
-  if (gThunkPpiList == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  \r
-  Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR));\r
-  gThunkPpiList[Index].Flags = Flags;\r
-  gThunkPpiList[Index].Guid  = Guid;\r
-  gThunkPpiList[Index].Ppi   = Ppi;\r
-  gThunkPpiListSize += sizeof (EFI_PEI_PPI_DESCRIPTOR);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
-\r
-\r
diff --git a/InOsEmuPkg/Library/ThunkPpiList/ThunkPpiList.inf b/InOsEmuPkg/Library/ThunkPpiList/ThunkPpiList.inf
deleted file mode 100644 (file)
index aa4bb5a..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-## @file\r
-# Place thunk PPI in HOB.\r
-#\r
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = ThunkPpiList\r
-  FILE_GUID                      = 465FDE84-E8B0-B04B-A843-A03F68F617A9\r
-  MODULE_TYPE                    = BASE\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = MemoryAllocationLib|SEC BASE USER_DEFINED\r
-\r
-[Sources]\r
-  ThunkPpiList.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  BaseMemoryLib\r
-\r
-[BuildOptions]\r
-   XCODE:*_*_*_DLINK_PATH == gcc\r
-\r
diff --git a/InOsEmuPkg/Library/ThunkProtocolList/ThunkProtocolList.c b/InOsEmuPkg/Library/ThunkProtocolList/ThunkProtocolList.c
deleted file mode 100644 (file)
index 5aed594..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/** @file\r
-  Emulator Thunk to abstract OS services from pure EFI code\r
-\r
-  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-  \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <Uefi.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-\r
-#include <Protocol/EmuIoThunk.h>\r
-\r
-\r
-#define EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('E','m','u','T')\r
-\r
-typedef struct {\r
-  UINTN                 Signature;\r
-  EMU_IO_THUNK_PROTOCOL Data;\r
-  BOOLEAN               EmuBusDriver;\r
-  LIST_ENTRY            Link;\r
-} EMU_IO_THUNK_PROTOCOL_DATA;\r
-\r
-LIST_ENTRY  mThunkList = INITIALIZE_LIST_HEAD_VARIABLE (mThunkList);\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-AddThunkProtocol (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *ThunkIo,  \r
-  IN  CHAR16                  *ConfigString,\r
-  IN  BOOLEAN                 EmuBusDriver\r
-  )\r
-{\r
-  CHAR16                      *StartString;\r
-  CHAR16                      *SubString;\r
-  UINTN                       Instance;\r
-  EMU_IO_THUNK_PROTOCOL_DATA  *Private;\r
-  \r
-  if (ThunkIo == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  Instance = 0;\r
-  StartString = AllocatePool (StrSize (ConfigString));\r
-  StrCpy (StartString, ConfigString);\r
-  while (*StartString != '\0') {\r
-\r
-    //\r
-    // Find the end of the sub string\r
-    //\r
-    SubString = StartString;\r
-    while (*SubString != '\0' && *SubString != '!') {\r
-      SubString++;\r
-    }\r
-\r
-    if (*SubString == '!') {\r
-      //\r
-      // Replace token with '\0' to make sub strings. If this is the end\r
-      //  of the string SubString will already point to NULL.\r
-      //\r
-      *SubString = '\0';\r
-      SubString++;\r
-    }\r
-\r
-    Private = AllocatePool (sizeof (EMU_IO_THUNK_PROTOCOL_DATA));\r
-    if (Private == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    Private->Signature          = EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE;\r
-    Private->EmuBusDriver       = EmuBusDriver;\r
-\r
-    CopyMem (&Private->Data, ThunkIo, sizeof (EMU_IO_THUNK_PROTOCOL));    \r
-    Private->Data.Instance      = Instance++;\r
-    Private->Data.ConfigString  = StartString;\r
-    \r
-    InsertTailList (&mThunkList, &Private->Link);\r
-\r
-    //\r
-    // Parse Next sub string. This will point to '\0' if we are at the end.\r
-    //\r
-    StartString = SubString;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GetNextThunkProtocol (\r
-  IN  BOOLEAN                 EmuBusDriver,\r
-  OUT EMU_IO_THUNK_PROTOCOL   **Instance  OPTIONAL\r
-  )\r
-{\r
-  LIST_ENTRY                   *Link; \r
-  EMU_IO_THUNK_PROTOCOL_DATA   *Private; \r
-  \r
-  if (mThunkList.ForwardLink == &mThunkList) {\r
-    // Skip parsing an empty list\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  \r
-  for (Link = mThunkList.ForwardLink; Link != &mThunkList; Link = Link->ForwardLink) {\r
-    Private = CR (Link, EMU_IO_THUNK_PROTOCOL_DATA, Link, EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE);\r
-    if (EmuBusDriver & !Private->EmuBusDriver) {\r
-      continue;\r
-    } else if (*Instance == NULL) {\r
-      // Find 1st match in list\r
-      *Instance = &Private->Data;\r
-      return EFI_SUCCESS;\r
-    } else if (*Instance == &Private->Data) {\r
-      // Matched previous call so look for valid next entry\r
-      Link = Link->ForwardLink;\r
-      if (Link == &mThunkList) {\r
-        return EFI_NOT_FOUND;\r
-      }\r
-      Private = CR (Link, EMU_IO_THUNK_PROTOCOL_DATA, Link, EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE);\r
-      *Instance = &Private->Data;\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-   \r
-   \r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
diff --git a/InOsEmuPkg/Library/ThunkProtocolList/ThunkProtocolList.inf b/InOsEmuPkg/Library/ThunkProtocolList/ThunkProtocolList.inf
deleted file mode 100644 (file)
index 387a650..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-## @file\r
-#\r
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php.\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = ThunkProtocolList\r
-  FILE_GUID                      = 7833616E-AE0D-594F-870C-80E68682D587\r
-  MODULE_TYPE                    = BASE\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = MemoryAllocationLib|BASE SEC USER_DEFINED\r
-\r
-[Sources]\r
-  ThunkProtocolList.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  BaseLib\r
-  BaseMemoryLib\r
-\r
-\r
-\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturer.uni b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturer.uni
deleted file mode 100644 (file)
index 669654e..0000000
Binary files a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturer.uni and /dev/null differ
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerData.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerData.c
deleted file mode 100644 (file)
index 52d1204..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MiscBaseBoardManufacturerData.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-//\r
-// Static (possibly build generated) Bios Vendor data.\r
-//\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_BASE_BOARD_MANUFACTURER_DATA, MiscBaseBoardManufacturer) = {\r
-  STRING_TOKEN(STR_MISC_BASE_BOARD_MANUFACTURER),\r
-  STRING_TOKEN(STR_MISC_BASE_BOARD_PRODUCT_NAME),\r
-  STRING_TOKEN(STR_MISC_BASE_BOARD_VERSION),\r
-  STRING_TOKEN(STR_MISC_BASE_BOARD_SERIAL_NUMBER),\r
-  STRING_TOKEN(STR_MISC_BASE_BOARD_ASSET_TAG),\r
-  STRING_TOKEN(STR_MISC_BASE_BOARD_CHASSIS_LOCATION),\r
-  {                         // BaseBoardFeatureFlags\r
-    1,                      // Motherboard\r
-    0,                      // RequiresDaughterCard\r
-    0,                      // Removable\r
-    1,                      // Replaceable,\r
-    0,                      // HotSwappable\r
-    0,                      // Reserved\r
-  },\r
-  EfiBaseBoardTypeUnknown,  // BaseBoardType\r
-  {                         // BaseBoardChassisLink\r
-    EFI_MISC_SUBCLASS_GUID, // ProducerName\r
-    1,                      // Instance\r
-    1,                      // SubInstance\r
-  },\r
-  0,                        // BaseBoardNumberLinks\r
-  {                         // LinkN\r
-    EFI_MISC_SUBCLASS_GUID, // ProducerName\r
-    1,                      // Instance\r
-    1,                      // SubInstance\r
-  },\r
-};\r
-\r
-/* eof - MiscBaseBoardManufacturerData.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
deleted file mode 100644 (file)
index 04f5a1e..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/** @file\r
-  BaseBoard manufacturer information boot time changes.\r
-  SMBIOS type 2.\r
-\r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-/**\r
-  This function makes boot time changes to the contents of the\r
-  MiscBaseBoardManufacturer (Type 2).\r
-\r
-  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
-\r
-  @retval EFI_SUCCESS                All parameters were valid.\r
-  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
-\r
-**/\r
-MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)\r
-{\r
-  CHAR8                           *OptionalStrStart;\r
-  UINTN                           ManuStrLen;\r
-  UINTN                           ProductStrLen;\r
-  UINTN                           VerStrLen;\r
-  UINTN                           AssertTagStrLen;\r
-  UINTN                           SerialNumStrLen;\r
-  UINTN                           ChassisStrLen;\r
-  EFI_STATUS                      Status;\r
-  EFI_STRING                      Manufacturer;\r
-  EFI_STRING                      Product;\r
-  EFI_STRING                      Version;\r
-  EFI_STRING                      SerialNumber;\r
-  EFI_STRING                      AssertTag;\r
-  EFI_STRING                      Chassis;\r
-  STRING_REF                      TokenToGet;\r
-  EFI_SMBIOS_HANDLE               SmbiosHandle;\r
-  SMBIOS_TABLE_TYPE2              *SmbiosRecord;\r
-  EFI_MISC_BASE_BOARD_MANUFACTURER   *ForType2InputData;\r
-\r
-  ForType2InputData = (EFI_MISC_BASE_BOARD_MANUFACTURER *)RecordData;\r
-\r
-  //\r
-  // First check for invalid parameters.\r
-  //\r
-  if (RecordData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER);\r
-  Manufacturer = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  ManuStrLen = StrLen(Manufacturer);\r
-  if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME);\r
-  Product = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  ProductStrLen = StrLen(Product);\r
-  if (ProductStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION);\r
-  Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  VerStrLen = StrLen(Version);\r
-  if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_SERIAL_NUMBER);\r
-  SerialNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  SerialNumStrLen = StrLen(SerialNumber);\r
-  if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG);\r
-  AssertTag = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  AssertTagStrLen = StrLen(AssertTag);\r
-  if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION);\r
-  Chassis = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  ChassisStrLen = StrLen(Chassis);\r
-  if (ChassisStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-\r
-  //\r
-  // Two zeros following the last string.\r
-  //\r
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);\r
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);\r
-\r
-  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);\r
-  //\r
-  // Make handle chosen by smbios protocol.add automatically.\r
-  //\r
-  SmbiosRecord->Hdr.Handle = 0;  \r
-  //\r
-  // Manu will be the 1st optional string following the formatted structure.\r
-  // \r
-  SmbiosRecord->Manufacturer = 1;  \r
-  //\r
-  // ProductName will be the 2st optional string following the formatted structure.\r
-  // \r
-  SmbiosRecord->ProductName  = 2;  \r
-  //\r
-  // Version will be the 3rd optional string following the formatted structure.\r
-  //\r
-  SmbiosRecord->Version = 3;  \r
-  //\r
-  // SerialNumber will be the 4th optional string following the formatted structure.\r
-  //\r
-  SmbiosRecord->SerialNumber = 4;  \r
-  //\r
-  // AssertTag will be the 5th optional string following the formatted structure.\r
-  //\r
-  SmbiosRecord->AssetTag = 5;  \r
-\r
-  //\r
-  // LocationInChassis will be the 6th optional string following the formatted structure.\r
-  //\r
-  SmbiosRecord->LocationInChassis = 6;  \r
-  SmbiosRecord->FeatureFlag = (*(BASE_BOARD_FEATURE_FLAGS*)&(ForType2InputData->BaseBoardFeatureFlags));\r
-  SmbiosRecord->ChassisHandle  = 0;\r
-  SmbiosRecord->BoardType      = (UINT8)ForType2InputData->BaseBoardType;\r
-  SmbiosRecord->NumberOfContainedObjectHandles = 0;\r
-  \r
-  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
-  //\r
-  // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string\r
-  //\r
-  OptionalStrStart -= 2;\r
-  UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);\r
-  UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);\r
-  UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);\r
-  UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1);\r
-  UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);\r
-  UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1);\r
-  //\r
-  // Now we have got the full smbios record, call smbios protocol to add this record.\r
-  //\r
-  SmbiosHandle = 0;\r
-  Status = Smbios-> Add(\r
-                      Smbios, \r
-                      NULL,\r
-                      &SmbiosHandle, \r
-                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
-                      );\r
-\r
-  FreePool(SmbiosRecord);\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBiosVendor.uni b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBiosVendor.uni
deleted file mode 100644 (file)
index dda02d2..0000000
Binary files a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBiosVendor.uni and /dev/null differ
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBiosVendorData.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBiosVendorData.c
deleted file mode 100644 (file)
index b9a8ced..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MiscBiosVendorData.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-//\r
-// Static (possibly build generated) Bios Vendor data.\r
-//\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_BIOS_VENDOR_DATA, MiscBiosVendor) = {\r
-  STRING_TOKEN(STR_MISC_BIOS_VENDOR),       // BiosVendor\r
-  STRING_TOKEN(STR_MISC_BIOS_VERSION),      // BiosVersion\r
-  STRING_TOKEN(STR_MISC_BIOS_RELEASE_DATE), // BiosReleaseDate\r
-  0xBABE, // BiosStartingAddress\r
-  {       // BiosPhysicalDeviceSize\r
-    2,    // Value\r
-    3,    // Exponent\r
-  },\r
-  {       // BiosCharacteristics1\r
-    0,    // Reserved1                         :2\r
-    0,    // Unknown                           :1\r
-    1,    // BiosCharacteristicsNotSupported   :1\r
-    0,    // IsaIsSupported                    :1\r
-    0,    // McaIsSupported                    :1\r
-    0,    // EisaIsSupported                   :1\r
-    0,    // PciIsSupported                    :1\r
-    0,    // PcmciaIsSupported                 :1\r
-    0,    // PlugAndPlayIsSupported            :1\r
-    0,    // ApmIsSupported                    :1\r
-    0,    // BiosIsUpgradable                  :1\r
-    0,    // BiosShadowingAllowed              :1\r
-    0,    // VlVesaIsSupported                 :1\r
-    0,    // EscdSupportIsAvailable            :1\r
-    0,    // BootFromCdIsSupported             :1\r
-    0,    // SelectableBootIsSupported         :1\r
-    0,    // RomBiosIsSocketed                 :1\r
-    0,    // BootFromPcmciaIsSupported         :1\r
-    0,    // EDDSpecificationIsSupported       :1\r
-    0,    // JapaneseNecFloppyIsSupported      :1\r
-    0,    // JapaneseToshibaFloppyIsSupported  :1\r
-    0,    // Floppy525_360IsSupported          :1\r
-    0,    // Floppy525_12IsSupported           :1\r
-    0,    // Floppy35_720IsSupported           :1\r
-    0,    // Floppy35_288IsSupported           :1\r
-    0,    // PrintScreenIsSupported            :1\r
-    0,    // Keyboard8042IsSupported           :1\r
-    0,    // SerialIsSupported                 :1\r
-    0,    // PrinterIsSupported                :1\r
-    0,    // CgaMonoIsSupported                :1\r
-    0,    // NecPc98                           :1\r
-    0,    // AcpiIsSupported                   :1\r
-    0,    // UsbLegacyIsSupported              :1\r
-    0,    // AgpIsSupported                    :1\r
-    0,    // I20BootIsSupported                :1\r
-    0,    // Ls120BootIsSupported              :1\r
-    0,    // AtapiZipDriveBootIsSupported      :1\r
-    0,    // Boot1394IsSupported               :1\r
-    0,    // SmartBatteryIsSupported           :1\r
-    0,    // BiosBootSpecIsSupported           :1\r
-    0,    // FunctionKeyNetworkBootIsSupported :1\r
-    0     // Reserved                          :22\r
-  },\r
-  {       // BiosCharacteristics2\r
-    0,    // BiosReserved                      :16\r
-    0,    // SystemReserved                    :16\r
-    0     // Reserved                          :32\r
-  },\r
-};\r
-\r
-/* eof - MiscBiosVendorData.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c
deleted file mode 100644 (file)
index 6d64ef4..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/** @file\r
-  BIOS vendor information boot time changes.\r
-  Misc. subclass type 2.\r
-  SMBIOS type 0.\r
-\r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-/**\r
-  This function returns the value & exponent to Base2 for a given\r
-  Hex value. This is used to calculate the BiosPhysicalDeviceSize.\r
-\r
-  @param Value                      The hex value which is to be converted into value-exponent form\r
-  @param Exponent                   The exponent out of the conversion\r
-\r
-  @retval EFI_SUCCESS               All parameters were valid and *Value & *Exponent have been set.\r
-  @retval EFI_INVALID_PARAMETER     Invalid parameter was found.\r
-  \r
-**/\r
-EFI_STATUS  \r
-GetValueExponentBase2(\r
-  IN OUT UINTN        *Value,\r
-  OUT    UINTN        *Exponent\r
-  )\r
-{\r
-  if ((Value == NULL) || (Exponent == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  while ((*Value % 2) == 0) {\r
-    *Value=*Value/2;\r
-    (*Exponent)++;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a byte, with '64k'\r
-  as the unit.\r
-\r
-  @param  Base2Data              Pointer to Base2_Data\r
-\r
-  @retval EFI_SUCCESS            Transform successfully.       \r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter was found.    \r
-\r
-**/\r
-UINT16\r
-Base2ToByteWith64KUnit (\r
-  IN      EFI_EXP_BASE2_DATA  *Base2Data\r
-  )\r
-{  \r
-  UINT16              Value;\r
-  UINT16              Exponent;\r
-\r
-  Value     = Base2Data->Value;\r
-  Exponent  = Base2Data->Exponent;\r
-  Exponent -= 16;\r
-  Value <<= Exponent;\r
-\r
-  return Value;\r
-}\r
-\r
-\r
-/**\r
-  This function makes boot time changes to the contents of the\r
-  MiscBiosVendor (Type 0).\r
-\r
-  @param  RecordData                 Pointer to copy of RecordData from the Data Table.\r
-\r
-  @retval EFI_SUCCESS                All parameters were valid.\r
-  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
-\r
-**/\r
-MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor)\r
-{\r
-  CHAR8                 *OptionalStrStart;\r
-  UINTN                 VendorStrLen;\r
-  UINTN                 VerStrLen;\r
-  UINTN                 DateStrLen;\r
-  CHAR16                *Version;\r
-  CHAR16                *ReleaseDate;\r
-  EFI_STATUS            Status;\r
-  EFI_STRING            Char16String;\r
-  STRING_REF            TokenToGet;\r
-  STRING_REF            TokenToUpdate;\r
-  SMBIOS_TABLE_TYPE0    *SmbiosRecord;\r
-  EFI_SMBIOS_HANDLE     SmbiosHandle;\r
-  EFI_MISC_BIOS_VENDOR *ForType0InputData;\r
-\r
-  ForType0InputData        = (EFI_MISC_BIOS_VENDOR *)RecordData;\r
-\r
-  //\r
-  // First check for invalid parameters.\r
-  //\r
-  if (RecordData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Version = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString);\r
-  if (StrLen (Version) > 0) {     \r
-    TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_VERSION);\r
-    HiiSetString (mHiiHandle, TokenToUpdate, Version, NULL);\r
-  }\r
-  \r
-  ReleaseDate = (CHAR16 *) PcdGetPtr (PcdFirmwareReleaseDateString);\r
-  if (StrLen(ReleaseDate) > 0) {\r
-    TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE);\r
-    HiiSetString (mHiiHandle, TokenToUpdate, ReleaseDate, NULL);\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_BIOS_VENDOR);\r
-  Char16String = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  VendorStrLen = StrLen(Char16String);\r
-  if (VendorStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_BIOS_VERSION);\r
-  Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  VerStrLen = StrLen(Version);\r
-  if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE);\r
-  ReleaseDate = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  DateStrLen = StrLen(ReleaseDate);\r
-  if (DateStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  \r
-  //\r
-  // Two zeros following the last string.\r
-  //\r
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE0) + VendorStrLen + 1 + VerStrLen + 1 + DateStrLen + 1 + 1);\r
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE0) + VendorStrLen + 1 + VerStrLen + 1 + DateStrLen + 1 + 1);\r
-\r
-  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BIOS_INFORMATION;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE0);\r
-  //\r
-  // Make handle chosen by smbios protocol.add automatically.\r
-  //\r
-  SmbiosRecord->Hdr.Handle = 0;\r
-  //\r
-  // Vendor will be the 1st optional string following the formatted structure.\r
-  //\r
-  SmbiosRecord->Vendor = 1;  \r
-  //\r
-  // Version will be the 2nd optional string following the formatted structure.\r
-  //\r
-  SmbiosRecord->BiosVersion = 2;\r
-  SmbiosRecord->BiosSegment = (UINT16)ForType0InputData->BiosStartingAddress;\r
-  //\r
-  // ReleaseDate will be the 3rd optional string following the formatted structure.\r
-  //\r
-  SmbiosRecord->BiosReleaseDate = 3;\r
-  //\r
-  // Nt32 has no PCD value to indicate BIOS Size, just fill 0 for simply.\r
-  //\r
-  SmbiosRecord->BiosSize = 0;\r
-  SmbiosRecord->BiosCharacteristics = *(MISC_BIOS_CHARACTERISTICS*)(&ForType0InputData->BiosCharacteristics1);\r
-  //\r
-  // CharacterExtensionBytes also store in ForType0InputData->BiosCharacteristics1 later two bytes to save size.\r
-  //\r
-  SmbiosRecord->BIOSCharacteristicsExtensionBytes[0] = *((UINT8 *) &ForType0InputData->BiosCharacteristics1 + 4);\r
-  SmbiosRecord->BIOSCharacteristicsExtensionBytes[1] = *((UINT8 *) &ForType0InputData->BiosCharacteristics1 + 5);\r
-\r
-  SmbiosRecord->SystemBiosMajorRelease = ForType0InputData->BiosMajorRelease;\r
-  SmbiosRecord->SystemBiosMinorRelease = ForType0InputData->BiosMinorRelease;\r
-  SmbiosRecord->EmbeddedControllerFirmwareMajorRelease = ForType0InputData->BiosEmbeddedFirmwareMajorRelease;\r
-  SmbiosRecord->EmbeddedControllerFirmwareMinorRelease = ForType0InputData->BiosEmbeddedFirmwareMinorRelease;\r
-\r
-  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
-  UnicodeStrToAsciiStr(Char16String, OptionalStrStart);\r
-  UnicodeStrToAsciiStr(Version, OptionalStrStart + VendorStrLen + 1);\r
-  UnicodeStrToAsciiStr(ReleaseDate, OptionalStrStart + VendorStrLen + 1 + VerStrLen + 1);\r
-  //\r
-  // Now we have got the full smbios record, call smbios protocol to add this record.\r
-  //\r
-  SmbiosHandle = 0;\r
-  Status = Smbios-> Add(\r
-                      Smbios, \r
-                      NULL,\r
-                      &SmbiosHandle, \r
-                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
-                      );\r
-\r
-  FreePool(SmbiosRecord);\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBootInformationData.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBootInformationData.c
deleted file mode 100644 (file)
index 0b7c57a..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MiscBootInformationData.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-//\r
-// Static (possibly build generated) Bios Vendor data.\r
-//\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_BOOT_INFORMATION_STATUS_DATA, BootInformationStatus) = {\r
-  EfiBootInformationStatusNoError,  // BootInformationStatus\r
-  {0}                                 // BootInformationData\r
-};\r
-\r
-/* eof - MiscBootInformationData.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBootInformationFunction.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscBootInformationFunction.c
deleted file mode 100644 (file)
index 65c9792..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/** @file\r
-  boot information boot time changes.\r
-  SMBIOS type 32.\r
-\r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-\r
-/**\r
-  This function makes boot time changes to the contents of the\r
-  MiscBootInformation (Type 32).\r
-\r
-  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
-\r
-  @retval EFI_SUCCESS                All parameters were valid.\r
-  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
-\r
-**/\r
-\r
-MISC_SMBIOS_TABLE_FUNCTION(BootInformationStatus)\r
-{\r
-  EFI_STATUS                         Status;\r
-  EFI_SMBIOS_HANDLE                  SmbiosHandle;\r
-  SMBIOS_TABLE_TYPE32                *SmbiosRecord;\r
-  EFI_MISC_BOOT_INFORMATION_STATUS*  ForType32InputData;\r
\r
-  ForType32InputData = (EFI_MISC_BOOT_INFORMATION_STATUS *)RecordData;\r
-\r
-  //\r
-  // First check for invalid parameters.\r
-  //\r
-  if (RecordData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Two zeros following the last string.\r
-  //\r
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE32) + 1 + 1);\r
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE32) + 1 + 1);\r
-\r
-  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE32);\r
-  //\r
-  // Make handle chosen by smbios protocol.add automatically.\r
-  //\r
-  SmbiosRecord->Hdr.Handle = 0;  \r
-  SmbiosRecord->BootStatus = (UINT8)ForType32InputData->BootInformationStatus;\r
-\r
-  //\r
-  // Now we have got the full smbios record, call smbios protocol to add this record.\r
-  //\r
-  SmbiosHandle = 0;\r
-  Status = Smbios-> Add(\r
-                      Smbios, \r
-                      NULL,\r
-                      &SmbiosHandle, \r
-                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
-                      );\r
-  FreePool(SmbiosRecord);\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscChassisManufacturer.uni b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscChassisManufacturer.uni
deleted file mode 100644 (file)
index 177ff38..0000000
Binary files a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscChassisManufacturer.uni and /dev/null differ
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerData.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerData.c
deleted file mode 100644 (file)
index 795658b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MiscChassisManufacturerData.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-//\r
-// Static (possibly build generated) Chassis Manufacturer data.\r
-//\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_CHASSIS_MANUFACTURER_DATA, MiscChassisManufacturer) = {\r
-  STRING_TOKEN(STR_MISC_CHASSIS_MANUFACTURER),  // ChassisManufactrurer\r
-  STRING_TOKEN(STR_MISC_CHASSIS_VERSION),       // ChassisVersion\r
-  STRING_TOKEN(STR_MISC_CHASSIS_SERIAL_NUMBER), // ChassisSerialNumber\r
-  STRING_TOKEN(STR_MISC_CHASSIS_ASSET_TAG),     // ChassisAssetTag\r
-  {                               // ChassisTypeStatus\r
-    EfiMiscChassisTypeOther,      // ChassisType\r
-    0,                            // ChassisLockPresent\r
-    0                             // Reserved\r
-  },\r
-  EfiChassisStateOther,           // ChassisBootupState\r
-  EfiChassisStateOther,           // ChassisPowerSupplyState\r
-  EfiChassisStateOther,           // ChassisThermalState\r
-  EfiChassisSecurityStatusOther,  // ChassisSecurityState\r
-  0                               // ChassisOemDefined\r
-};\r
-\r
-/* eof - MiscChassisManufacaturerData.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c
deleted file mode 100644 (file)
index fd1262b..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/** @file\r
-  Chassis manufacturer information boot time changes.\r
-  SMBIOS type 3.\r
-\r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-/**\r
-  This function makes boot time changes to the contents of the\r
-  MiscChassisManufacturer (Type 3).\r
-\r
-  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
-\r
-  @retval EFI_SUCCESS                All parameters were valid.\r
-  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
-\r
-**/\r
-MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer)\r
-{\r
-  CHAR8                           *OptionalStrStart;\r
-  UINTN                           ManuStrLen;\r
-  UINTN                           VerStrLen;\r
-  UINTN                           AssertTagStrLen;\r
-  UINTN                           SerialNumStrLen;\r
-  EFI_STATUS                      Status;\r
-  EFI_STRING                      Manufacturer;\r
-  EFI_STRING                      Version;\r
-  EFI_STRING                      SerialNumber;\r
-  EFI_STRING                      AssertTag;\r
-  STRING_REF                      TokenToGet;\r
-  EFI_SMBIOS_HANDLE               SmbiosHandle;\r
-  SMBIOS_TABLE_TYPE3              *SmbiosRecord;\r
-  EFI_MISC_CHASSIS_MANUFACTURER   *ForType3InputData;\r
-\r
-  ForType3InputData = (EFI_MISC_CHASSIS_MANUFACTURER *)RecordData;\r
-\r
-  //\r
-  // First check for invalid parameters.\r
-  //\r
-  if (RecordData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_MANUFACTURER);\r
-  Manufacturer = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  ManuStrLen = StrLen(Manufacturer);\r
-  if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_VERSION);\r
-  Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  VerStrLen = StrLen(Version);\r
-  if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_SERIAL_NUMBER);\r
-  SerialNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  SerialNumStrLen = StrLen(SerialNumber);\r
-  if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_ASSET_TAG);\r
-  AssertTag = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  AssertTagStrLen = StrLen(AssertTag);\r
-  if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Two zeros following the last string.\r
-  //\r
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1  + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1);\r
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1  + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1);\r
-\r
-  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE3);\r
-  //\r
-  // Make handle chosen by smbios protocol.add automatically.\r
-  //\r
-  SmbiosRecord->Hdr.Handle = 0;  \r
-  //\r
-  // Manu will be the 1st optional string following the formatted structure.\r
-  // \r
-  SmbiosRecord->Manufacturer = 1;  \r
-  SmbiosRecord->Type = (UINT8)ForType3InputData->ChassisType.ChassisType;\r
-  //\r
-  // Version will be the 2nd optional string following the formatted structure.\r
-  //\r
-  SmbiosRecord->Version = 2;  \r
-  //\r
-  // SerialNumber will be the 3rd optional string following the formatted structure.\r
-  //\r
-  SmbiosRecord->SerialNumber = 3;  \r
-  //\r
-  // AssertTag will be the 4th optional string following the formatted structure.\r
-  //\r
-  SmbiosRecord->AssetTag = 4;  \r
-  SmbiosRecord->BootupState = (UINT8)ForType3InputData->ChassisBootupState;\r
-  SmbiosRecord->PowerSupplyState = (UINT8)ForType3InputData->ChassisPowerSupplyState;\r
-  SmbiosRecord->ThermalState = (UINT8)ForType3InputData->ChassisThermalState;\r
-  SmbiosRecord->SecurityStatus = (UINT8)ForType3InputData->ChassisSecurityState;\r
-  CopyMem (SmbiosRecord->OemDefined,(UINT8*)&ForType3InputData->ChassisOemDefined, 4);\r
-\r
-  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
-  UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);\r
-  UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1);\r
-  UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1);\r
-  UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);\r
-\r
-  //\r
-  // Now we have got the full smbios record, call smbios protocol to add this record.\r
-  //\r
-  SmbiosHandle = 0;\r
-  Status = Smbios-> Add(\r
-                      Smbios, \r
-                      NULL,\r
-                      &SmbiosHandle, \r
-                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
-                      );\r
-\r
-  FreePool(SmbiosRecord);\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscDevicePath.h b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscDevicePath.h
deleted file mode 100644 (file)
index b1a9acf..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/*++\r
\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MiscDevicePath.h\r
-\r
-Abstract:\r
-\r
-  Misc class required EFI Device Path definitions (Ports, slots & \r
-  onboard devices)\r
-\r
-**/\r
-\r
-#ifndef _MISC_DEVICE_PATH_H\r
-#define _MISC_DEVICE_PATH_H\r
-\r
-\r
-#pragma pack(1)\r
-//\r
-// USB\r
-//\r
-\r
-/* For reference:\r
-#define USB1_1_STR  "ACPI(PNP0A03,0)/PCI(1D,0)."\r
-#define USB1_2_STR  "ACPI(PNP0A03,0)/PCI(1D,1)."\r
-#define USB1_3_STR  "ACPI(PNP0A03,0)/PCI(1D,2)."\r
-#define USB2_1_STR  "ACPI(PNP0A03,0)/PCI(1D,7)." \r
-*/\r
-\r
-//\r
-// #define acpi { 0x02, 0x01, 0x00, 0x0C, 0x0a0341d0, 0x00000000 }\r
-// #define pci( device,function)  { 0x01, 0x01, 0x00, 0x06, device, function }\r
-// #define end  { 0xFF, 0xFF, 0x00, 0x04 }\r
-//\r
-#define DP_ACPI \\r
-  { \\r
-      {ACPI_DEVICE_PATH, ACPI_DP, {(UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), (UINT8) \\r
-      ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)}}, EISA_PNP_ID (0x0A03), 0 \\r
-  }\r
-#define DP_PCI(device, function) \\r
-  { \\r
-      {HARDWARE_DEVICE_PATH, HW_PCI_DP, {(UINT8) (sizeof (PCI_DEVICE_PATH)), (UINT8) \\r
-       ((sizeof (PCI_DEVICE_PATH)) >> 8)}}, function, device \\r
-  }\r
-#define DP_END \\r
-  { \\r
-    END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, {END_DEVICE_PATH_LENGTH, 0} \\r
-  }\r
-\r
-#define DP_LPC(eisaid, function) \\r
-  { \\r
-    {ACPI_DEVICE_PATH, ACPI_DP, {(UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), (UINT8) \\r
-     ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)}}, EISA_PNP_ID (eisaid), function \\r
-  }\r
-\r
-//\r
-// Shanmu >> moved to TianoDevicePath.h\r
-//\r
-\r
-/*\r
-typedef struct _USB_PORT_DEVICE_PATH\r
-{\r
-  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
-  PCI_DEVICE_PATH      PciBusDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
-} USB_PORT_DEVICE_PATH;\r
-\r
-\r
-//IDE ??I am not sure. Should this be ATAPI_DEVICE_PATH\r
-typedef struct _IDE_DEVICE_PATH\r
-{\r
-  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
-  PCI_DEVICE_PATH      PciBusDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
-} IDE_DEVICE_PATH;\r
-\r
-//RMC Connector\r
-typedef struct _RMC_CONN_DEVICE_PATH\r
-{\r
-  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
-  PCI_DEVICE_PATH      PciBridgeDevicePath;\r
-  PCI_DEVICE_PATH      PciBusDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
-} RMC_CONN_DEVICE_PATH;\r
-\r
-//static RMC_CONN_DEVICE_PATH mRmcConnDevicePath = { acpi, pci( 0x1E,0x00 ),pci( 0x0A,0x00 ), end };\r
-\r
-//RIDE\r
-typedef struct _RIDE_DEVICE_PATH\r
-{\r
-  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
-  PCI_DEVICE_PATH      PciBridgeDevicePath;\r
-  PCI_DEVICE_PATH      PciBusDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
-} RIDE_DEVICE_PATH;\r
-\r
-//static RIDE_DEVICE_PATH mRideDevicePath = { acpi, pci( 0x1E,0x00 ),pci( 0x02,0x00 ), end };\r
-\r
-//Gigabit NIC\r
-//typedef struct _GB_NIC_DEVICE_PATH\r
-//{\r
-//  ACPI_HID_DEVICE_PATH      PciRootBridgeDevicePath;\r
-//  PCI_DEVICE_PATH            PciBridgeDevicePath;\r
-//  PCI_DEVICE_PATH            PciXBridgeDevicePath;\r
-//  PCI_DEVICE_PATH            PciXBusDevicePath;\r
-//  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
-//} GB_NIC_DEVICE_PATH;\r
-\r
-//static GB_NIC_DEVICE_PATH mGbNicDevicePath = { acpi, pci( 0x03,0x00 ),pci( 0x1F,0x00 ),pci( 0x07,0x00 ), end };\r
-\r
-\r
-//P/S2 Connector\r
-typedef struct _PS2_CONN_DEVICE_PATH\r
-{\r
-  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
-  PCI_DEVICE_PATH      LpcBridgeDevicePath;\r
-  ACPI_HID_DEVICE_PATH    LpcBusDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
-} PS2_CONN_DEVICE_PATH;\r
-\r
-//static PS2_CONN_DEVICE_PATH mPs2KeyboardDevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0303,0 ), end };\r
-//static PS2_CONN_DEVICE_PATH mPs2MouseDevicePath      = { acpi, pci( 0x1F,0x00 ),lpc( 0x0303,1 ), end };\r
-\r
-//Serial Port Connector\r
-typedef struct _SERIAL_CONN_DEVICE_PATH\r
-{\r
-  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
-  PCI_DEVICE_PATH      LpcBridgeDevicePath;\r
-  ACPI_HID_DEVICE_PATH    LpcBusDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
-} SERIAL_CONN_DEVICE_PATH;\r
-\r
-//static SERIAL_CONN_DEVICE_PATH mCom1DevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0501,0 ), end };\r
-//static SERIAL_CONN_DEVICE_PATH mCom2DevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0501,1 ), end };\r
-\r
-//Parallel Port Connector\r
-typedef struct _PARALLEL_CONN_DEVICE_PATH\r
-{\r
-  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
-  PCI_DEVICE_PATH      LpcBridgeDevicePath;\r
-  ACPI_HID_DEVICE_PATH    LpcBusDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
-} PARALLEL_CONN_DEVICE_PATH;\r
-\r
-//static PARALLEL_CONN_DEVICE_PATH mLpt1DevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0401,0 ), end };\r
-\r
-//Floopy Connector\r
-typedef struct _FLOOPY_CONN_DEVICE_PATH\r
-{\r
-  ACPI_HID_DEVICE_PATH    PciRootBridgeDevicePath;\r
-  PCI_DEVICE_PATH      LpcBridgeDevicePath;\r
-  ACPI_HID_DEVICE_PATH    LpcBusDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
-} FLOOPY_CONN_DEVICE_PATH;\r
-\r
-//static FLOOPY_CONN_DEVICE_PATH mFloopyADevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0604,0 ), end };\r
-//static FLOOPY_CONN_DEVICE_PATH mFloopyBDevicePath   = { acpi, pci( 0x1F,0x00 ),lpc( 0x0604,1 ), end };\r
-\r
-*/\r
-\r
-//\r
-// End Shanmu\r
-//\r
-#pragma pack()\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesData.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesData.c
deleted file mode 100644 (file)
index 88d9d0f..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MiscNumberOfInstallableLanguagesData.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-//\r
-// Static (possibly build generated) Bios Vendor data.\r
-//\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA, NumberOfInstallableLanguages)\r
-= {\r
-  1,    // NumberOfInstallableLanguages\r
-  {     // LanguageFlags\r
-    0,  // AbbreviatedLanguageFormat\r
-    0   // Reserved\r
-  },\r
-  0,    // CurrentLanguageNumber\r
-};\r
-\r
-/* eof - MiscNumberOfInstallableLanguagesData.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesFunction.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesFunction.c
deleted file mode 100644 (file)
index 9bd7f4d..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-/** @file\r
-  This driver parses the mSmbiosMiscDataTable structure and reports\r
-  any generated data.\r
-\r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-/*++\r
-  Check whether the language is supported for given HII handle\r
-\r
-  @param   HiiHandle     The HII package list handle.\r
-  @param   Offset        The offest of current lanague in the supported languages.\r
-  @param   CurrentLang   The language code.\r
-\r
-  @retval  TRUE          Supported.\r
-  @retval  FALSE         Not Supported.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-CurrentLanguageMatch (\r
-  IN  EFI_HII_HANDLE                   HiiHandle,\r
-  OUT UINT16                           *Offset,\r
-  OUT CHAR8                            *CurrentLang\r
-  )\r
-{\r
-  CHAR8     *DefaultLang;\r
-  CHAR8     *BestLanguage;\r
-  CHAR8     *Languages;\r
-  CHAR8     *MatchLang;\r
-  CHAR8     *EndMatchLang;\r
-  UINTN     CompareLength;\r
-  \r
-  Languages = HiiGetSupportedLanguages (HiiHandle);\r
-  if (Languages == NULL) {\r
-    return;\r
-  }\r
-\r
-  CurrentLang  = GetEfiGlobalVariable (L"PlatformLang");\r
-  DefaultLang  = (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang);\r
-  BestLanguage = GetBestLanguage (\r
-                   Languages,\r
-                   FALSE,\r
-                   (CurrentLang != NULL) ? CurrentLang : "",\r
-                   DefaultLang,\r
-                   NULL\r
-                   );\r
-  if (BestLanguage != NULL) {\r
-    //\r
-    // Find the best matching RFC 4646 language, compute the offset.\r
-    //\r
-    CompareLength = AsciiStrLen (BestLanguage);\r
-    for (MatchLang = Languages, (*Offset) = 0; MatchLang != '\0'; (*Offset)++) {\r
-      //\r
-      // Seek to the end of current match language. \r
-      //\r
-      for (EndMatchLang = MatchLang; *EndMatchLang != '\0' && *EndMatchLang != ';'; EndMatchLang++);\r
-  \r
-      if ((EndMatchLang == MatchLang + CompareLength) && AsciiStrnCmp(MatchLang, BestLanguage, CompareLength) == 0) {\r
-        //\r
-        // Find the current best Language in the supported languages\r
-        //\r
-        break;\r
-      }\r
-      //\r
-      // best language match be in the supported language.\r
-      //\r
-      ASSERT (*EndMatchLang == ';');\r
-      MatchLang = EndMatchLang + 1;\r
-    }\r
-    FreePool (BestLanguage);\r
-  }\r
-\r
-  FreePool (Languages);\r
-  if (CurrentLang != NULL) {\r
-    FreePool (CurrentLang);\r
-  }\r
-  return ;\r
-}\r
-\r
-\r
-/**\r
-  Get next language from language code list (with separator ';').\r
-\r
-  @param  LangCode       Input: point to first language in the list. On\r
-                         Otput: point to next language in the list, or\r
-                                NULL if no more language in the list.\r
-  @param  Lang           The first language in the list.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-GetNextLanguage (\r
-  IN OUT CHAR8      **LangCode,\r
-  OUT CHAR8         *Lang\r
-  )\r
-{\r
-  UINTN  Index;\r
-  CHAR8  *StringPtr;\r
-\r
-  ASSERT (LangCode != NULL);\r
-  ASSERT (*LangCode != NULL);\r
-  ASSERT (Lang != NULL);\r
-\r
-  Index     = 0;\r
-  StringPtr = *LangCode;\r
-  while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {\r
-    Index++;\r
-  }\r
-\r
-  CopyMem (Lang, StringPtr, Index);\r
-  Lang[Index] = 0;\r
-\r
-  if (StringPtr[Index] == ';') {\r
-    Index++;\r
-  }\r
-  *LangCode = StringPtr + Index;\r
-}\r
-\r
-/**\r
-  This function returns the number of supported languages on HiiHandle.\r
-\r
-  @param   HiiHandle    The HII package list handle.\r
-\r
-  @retval  The number of supported languages.\r
-\r
-**/\r
-UINT16\r
-EFIAPI\r
-GetSupportedLanguageNumber (\r
-  IN EFI_HII_HANDLE    HiiHandle\r
-  )\r
-{\r
-  CHAR8   *Lang;\r
-  CHAR8   *Languages;\r
-  CHAR8   *LanguageString;\r
-  UINT16  LangNumber;\r
-  \r
-  Languages = HiiGetSupportedLanguages (HiiHandle);\r
-  if (Languages == NULL) {\r
-    return 0;\r
-  }\r
-\r
-  LangNumber = 0;\r
-  Lang = AllocatePool (AsciiStrSize (Languages));\r
-  if (Lang != NULL) {\r
-    LanguageString = Languages;\r
-    while (*LanguageString != 0) {\r
-      GetNextLanguage (&LanguageString, Lang);\r
-      LangNumber++;\r
-    }\r
-    FreePool (Lang);\r
-  }\r
-  FreePool (Languages);\r
-  return LangNumber;\r
-}\r
-\r
-\r
-/**\r
-  This function makes boot time changes to the contents of the\r
-  MiscNumberOfInstallableLanguages (Type 13).\r
-\r
-  @param  RecordData                 Pointer to copy of RecordData from the Data Table.\r
-\r
-  @retval EFI_SUCCESS                All parameters were valid.\r
-  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
-\r
-**/\r
-MISC_SMBIOS_TABLE_FUNCTION(NumberOfInstallableLanguages)\r
-{\r
-  UINTN                                     LangStrLen;\r
-  CHAR8                                     CurrentLang[SMBIOS_STRING_MAX_LENGTH + 1];\r
-  CHAR8                                     *OptionalStrStart;\r
-  UINT16                                    Offset;\r
-  EFI_STATUS                                Status;\r
-  EFI_SMBIOS_HANDLE                         SmbiosHandle;\r
-  SMBIOS_TABLE_TYPE13                       *SmbiosRecord;\r
-  EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES  *ForType13InputData;\r
\r
-  ForType13InputData = (EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES *)RecordData;\r
-\r
-  //\r
-  // First check for invalid parameters.\r
-  //\r
-  if (RecordData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  ForType13InputData->NumberOfInstallableLanguages = GetSupportedLanguageNumber (mHiiHandle);\r
-\r
-  //\r
-  // Try to check if current langcode matches with the langcodes in installed languages\r
-  //\r
-  ZeroMem(CurrentLang, SMBIOS_STRING_MAX_LENGTH + 1);\r
-  CurrentLanguageMatch (mHiiHandle, &Offset, CurrentLang);\r
-  LangStrLen = AsciiStrLen(CurrentLang);\r
-\r
-  //\r
-  // Two zeros following the last string.\r
-  //\r
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE13) + LangStrLen + 1 + 1);\r
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE13) + LangStrLen + 1 + 1);\r
-\r
-  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE13);\r
-  //\r
-  // Make handle chosen by smbios protocol.add automatically.\r
-  //\r
-  SmbiosRecord->Hdr.Handle = 0;  \r
-\r
-  SmbiosRecord->InstallableLanguages = (UINT8)ForType13InputData->NumberOfInstallableLanguages;\r
-  SmbiosRecord->Flags = (UINT8)ForType13InputData->LanguageFlags.AbbreviatedLanguageFormat;\r
-  SmbiosRecord->CurrentLanguages = 1;\r
-  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
-  AsciiStrCpy(OptionalStrStart, CurrentLang);\r
-  //\r
-  // Now we have got the full smbios record, call smbios protocol to add this record.\r
-  //\r
-  SmbiosHandle = 0;\r
-  Status = Smbios-> Add(\r
-                      Smbios, \r
-                      NULL,\r
-                      &SmbiosHandle, \r
-                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
-                      );\r
-  FreePool(SmbiosRecord);\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscOemString.uni b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscOemString.uni
deleted file mode 100644 (file)
index 782a83b..0000000
Binary files a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscOemString.uni and /dev/null differ
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscOemStringData.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscOemStringData.c
deleted file mode 100644 (file)
index 1d07815..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-  \r
-    MiscOemStringData.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-//\r
-// Static (possibly build generated) Bios Vendor data.\r
-//\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_OEM_STRING_DATA, OemString) = {\r
-  { STRING_TOKEN(STR_MISC_OEM_STRING) }\r
-};\r
-\r
-/* eof - MiscOemStringData.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c
deleted file mode 100644 (file)
index 94fc71c..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/** @file\r
-  boot information boot time changes.\r
-  SMBIOS type 11.\r
-\r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-/**\r
-  This function makes boot time changes to the contents of the\r
-  MiscOemString (Type 11).\r
-\r
-  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
-\r
-  @retval EFI_SUCCESS                All parameters were valid.\r
-  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
-\r
-**/\r
-MISC_SMBIOS_TABLE_FUNCTION(OemString)\r
-{\r
-  UINTN                    OemStrLen;\r
-  CHAR8                    *OptionalStrStart;\r
-  EFI_STATUS               Status;\r
-  EFI_STRING               OemStr;\r
-  STRING_REF               TokenToGet;\r
-  EFI_SMBIOS_HANDLE        SmbiosHandle;\r
-  SMBIOS_TABLE_TYPE11      *SmbiosRecord;\r
-\r
-  //\r
-  // First check for invalid parameters.\r
-  //\r
-  if (RecordData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_OEM_STRING);\r
-  OemStr = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  OemStrLen = StrLen(OemStr);\r
-  if (OemStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Two zeros following the last string.\r
-  //\r
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1);\r
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE11) + OemStrLen + 1 + 1);\r
-\r
-  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_OEM_STRINGS;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE11);\r
-  //\r
-  // Make handle chosen by smbios protocol.add automatically.\r
-  // \r
-  SmbiosRecord->Hdr.Handle = 0;  \r
-  SmbiosRecord->StringCount = 1;\r
-  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
-  UnicodeStrToAsciiStr(OemStr, OptionalStrStart);\r
-\r
-  //\r
-  // Now we have got the full smbios record, call smbios protocol to add this record.\r
-  //\r
-  SmbiosHandle = 0;\r
-  Status = Smbios-> Add(\r
-                      Smbios, \r
-                      NULL,\r
-                      &SmbiosHandle, \r
-                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
-                      );\r
-  FreePool(SmbiosRecord);\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignator.uni b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignator.uni
deleted file mode 100644 (file)
index 87c5a81..0000000
Binary files a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignator.uni and /dev/null differ
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorData.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorData.c
deleted file mode 100644 (file)
index 7d511e1..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MiscPortInternalConnectorDesignatorData.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-//\r
-// Static (possibly build generated) Bios Vendor data.\r
-//\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortInternalConnectorDesignator) = {\r
-  STRING_TOKEN(STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR),  // PortInternalConnectorDesignator\r
-  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_CONNECTOR_DESIGNATOR),  // PortExternalConnectorDesignator\r
-  EfiPortConnectorTypeOther,  // PortInternalConnectorType\r
-  EfiPortConnectorTypeOther,  // PortExternalConnectorType\r
-  EfiPortTypeNone,            // PortType\r
-  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
-};\r
-\r
-//\r
-// Static (possibly build generated) Bios Vendor data.\r
-//\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortKeyboard) = {\r
-  STRING_TOKEN (STR_MISC_PORT_INTERNAL_KEYBOARD),   // PortInternalConnectorDesignator\r
-  STRING_TOKEN (STR_MISC_PORT_EXTERNAL_KEYBOARD),   // PortExternalConnectorDesignator\r
-  EfiPortConnectorTypeNone, // PortInternalConnectorType\r
-  EfiPortConnectorTypePS2,  // PortExternalConnectorType\r
-  EfiPortTypeKeyboard,      // PortType\r
-  // mPs2KbyboardDevicePath                          // PortPath\r
-  //\r
-  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
-};\r
-\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortMouse) = {\r
-  STRING_TOKEN (STR_MISC_PORT_INTERNAL_MOUSE),      // PortInternalConnectorDesignator\r
-  STRING_TOKEN (STR_MISC_PORT_EXTERNAL_MOUSE),      // PortExternalConnectorDesignator\r
-  EfiPortConnectorTypeNone, // PortInternalConnectorType\r
-  EfiPortConnectorTypePS2,  // PortExternalConnectorType\r
-  EfiPortTypeMouse,         // PortType\r
-  // mPs2MouseDevicePath                // PortPath\r
-  //\r
-  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
-};\r
-\r
-\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom1) = {\r
-  STRING_TOKEN(STR_MISC_PORT_INTERNAL_COM1),\r
-  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM1),\r
-  EfiPortConnectorTypeNone,\r
-  EfiPortConnectorTypeDB9Female,\r
-  EfiPortTypeSerial16550ACompatible,\r
-  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
-};\r
-\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom2) = {\r
-  STRING_TOKEN(STR_MISC_PORT_INTERNAL_COM2),\r
-  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM2),\r
-  EfiPortConnectorTypeNone,\r
-  EfiPortConnectorTypeDB9Female,\r
-  EfiPortTypeSerial16550ACompatible,\r
-  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
-};\r
-\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortExtensionPower) = {\r
-  STRING_TOKEN(STR_MISC_PORT_INTERNAL_EXTENSION_POWER),\r
-  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_EXTENSION_POWER),\r
-  EfiPortConnectorTypeOther,\r
-  EfiPortConnectorTypeNone,\r
-  EfiPortTypeOther,\r
-  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
-};\r
-\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortFloppy) = {\r
-  STRING_TOKEN(STR_MISC_PORT_INTERNAL_FLOPPY),\r
-  STRING_TOKEN(STR_MISC_PORT_EXTERNAL_FLOPPY),\r
-  EfiPortConnectorTypeOnboardFloppy,\r
-  EfiPortConnectorTypeNone,\r
-  EfiPortTypeOther,\r
-  {{{{0, 0, {0, 0}}, 0, 0}, {{0, 0, {0, 0}}, 0, 0}, {0, 0, {0, 0}}}} // PortPath\r
-};\r
-\r
-/* eof - MiscPortInternalConnectorDesignatorData.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c
deleted file mode 100644 (file)
index 89c8815..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/*++\r
\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MiscPortInternalConnectorDesignatorFunction.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-\r
-MISC_SMBIOS_TABLE_FUNCTION (\r
-  MiscPortInternalConnectorDesignator\r
-  )\r
-/*++\r
-Description:\r
-\r
-  This function makes boot time changes to the contents of the\r
-  MiscPortConnectorInformation (Type 8).\r
-\r
-Parameters:\r
-\r
-  RecordType\r
-    Type of record to be processed from the Data Table.\r
-    mMiscSubclassDataTable[].RecordType\r
-\r
-  RecordLen\r
-    Size of static RecordData from the Data Table.\r
-    mMiscSubclassDataTable[].RecordLen\r
-\r
-  RecordData\r
-    Pointer to copy of RecordData from the Data Table.  Changes made\r
-    to this copy will be written to the Data Hub but will not alter\r
-    the contents of the static Data Table.\r
-\r
-  LogRecordData\r
-    Set *LogRecordData to TRUE to log RecordData to Data Hub.\r
-    Set *LogRecordData to FALSE when there is no more data to log.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS\r
-    All parameters were valid and *RecordData and *LogRecordData have\r
-    been set.\r
-\r
-  EFI_UNSUPPORTED\r
-    Unexpected RecordType value.\r
-\r
-  EFI_INVALID_PARAMETER\r
-    One of the following parameter conditions was true:\r
-      RecordLen was zero.\r
-      RecordData was NULL.\r
-      LogRecordData was NULL.\r
-**/\r
-{\r
-  CHAR8                                        *OptionalStrStart;\r
-  UINTN                                        InternalRefStrLen;\r
-  UINTN                                        ExternalRefStrLen;  \r
-  EFI_STRING                                   InternalRef;\r
-  EFI_STRING                                   ExternalRef;\r
-  STRING_REF                                   TokenForInternal;\r
-  STRING_REF                                   TokenForExternal;\r
-  EFI_STATUS                                   Status;\r
-  SMBIOS_TABLE_TYPE8                           *SmbiosRecord;\r
-  EFI_SMBIOS_HANDLE                            SmbiosHandle;\r
-  EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR  *ForType8InputData;\r
-  \r
-  ForType8InputData = (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *)RecordData;\r
-  //\r
-  // First check for invalid parameters.\r
-  //\r
-  if (RecordData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  TokenForInternal = 0;\r
-  TokenForExternal = 0;\r
-  \r
-  switch (ForType8InputData->PortInternalConnectorDesignator) { \r
-\r
-    case STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR:\r
-      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR);\r
-      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_CONNECTOR_DESIGNATOR);\r
-      break;\r
-    case STR_MISC_PORT_INTERNAL_KEYBOARD:\r
-      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_KEYBOARD);\r
-      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_KEYBOARD);\r
-      break;\r
-    case STR_MISC_PORT_INTERNAL_MOUSE:\r
-      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_MOUSE);\r
-      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_MOUSE);\r
-      break;\r
-    case STR_MISC_PORT_INTERNAL_COM1:\r
-      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM1);\r
-      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM1);\r
-      break;\r
-    case STR_MISC_PORT_INTERNAL_COM2:\r
-      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM2);\r
-      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM2);\r
-      break;\r
-    case STR_MISC_PORT_INTERNAL_EXTENSION_POWER:\r
-      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_EXTENSION_POWER);\r
-      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_EXTENSION_POWER);\r
-      break;\r
-    case STR_MISC_PORT_INTERNAL_FLOPPY:\r
-      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_FLOPPY);\r
-      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_FLOPPY);\r
-      break;\r
-    default:\r
-      break;\r
-  }\r
-\r
-  InternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForInternal, NULL);\r
-  InternalRefStrLen = StrLen(InternalRef);\r
-  if (InternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  ExternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForExternal, NULL);\r
-  ExternalRefStrLen = StrLen(ExternalRef);\r
-  if (ExternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Two zeros following the last string.\r
-  //\r
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);\r
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);\r
-\r
-  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE8);\r
-  //\r
-  // Make handle chosen by smbios protocol.add automatically.\r
-  //\r
-  SmbiosRecord->Hdr.Handle = 0;  \r
-  SmbiosRecord->InternalReferenceDesignator = 1;\r
-  SmbiosRecord->InternalConnectorType = (UINT8)ForType8InputData->PortInternalConnectorType;\r
-  SmbiosRecord->ExternalReferenceDesignator = 2;\r
-  SmbiosRecord->ExternalConnectorType = (UINT8)ForType8InputData->PortExternalConnectorType;\r
-  SmbiosRecord->PortType = (UINT8)ForType8InputData->PortType;\r
-  \r
-  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
-  UnicodeStrToAsciiStr(InternalRef, OptionalStrStart);\r
-  UnicodeStrToAsciiStr(ExternalRef, OptionalStrStart + InternalRefStrLen + 1);\r
-\r
-  //\r
-  // Now we have got the full smbios record, call smbios protocol to add this record.\r
-  //\r
-  SmbiosHandle = 0;\r
-  Status = Smbios-> Add(\r
-                      Smbios, \r
-                      NULL,\r
-                      &SmbiosHandle, \r
-                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
-                      );\r
-  FreePool(SmbiosRecord);\r
-  return Status;\r
-}\r
-\r
-\r
-\r
-/* eof - MiscSystemManufacturerFunction.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesData.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesData.c
deleted file mode 100644 (file)
index f591a2e..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-  \r
-    MiscResetCapabilitiesData.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-//\r
-// Static (possibly build generated) Bios Vendor data.\r
-//\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_RESET_CAPABILITIES, MiscResetCapabilities) = {\r
-  {     // ResetCapabilities\r
-    0,  // Status\r
-    0,  // BootOption\r
-    0,  // BootOptionOnLimit\r
-    0,  // WatchdogTimerPresent\r
-    0   // Reserved\r
-  },\r
-  0,    // ResetCount\r
-  0,    // ResetLimit\r
-  0,    // ResetTimerInterval\r
-  0     // ResetTimeout\r
-};\r
-\r
-/* eof - MiscResetCapabilities.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesFunction.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesFunction.c
deleted file mode 100644 (file)
index 8303c5a..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/** @file\r
-  ResetCapabilities.\r
-  SMBIOS type 23.\r
-\r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-/**\r
-  This function makes boot time changes to the contents of the\r
-  MiscOemString (Type 11).\r
-\r
-  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
-\r
-  @retval EFI_SUCCESS                All parameters were valid.\r
-  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
-\r
-**/\r
-MISC_SMBIOS_TABLE_FUNCTION(MiscResetCapabilities)\r
-{\r
-  EFI_STATUS               Status;\r
-  EFI_SMBIOS_HANDLE        SmbiosHandle;\r
-  SMBIOS_TABLE_TYPE23      *SmbiosRecord;\r
-  EFI_MISC_RESET_CAPABILITIES   *ForType23InputData;\r
-  \r
-  ForType23InputData = (EFI_MISC_RESET_CAPABILITIES *)RecordData;\r
-\r
-  //\r
-  // First check for invalid parameters.\r
-  //\r
-  if (RecordData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-\r
-  //\r
-  // Two zeros following the last string.\r
-  //\r
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE23) + 1 + 1);\r
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE23) + 1 + 1);\r
-\r
-  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_RESET;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE23);\r
-  //\r
-  // Make handle chosen by smbios protocol.add automatically.\r
-  // \r
-  SmbiosRecord->Hdr.Handle    = 0;  \r
-  SmbiosRecord->Capabilities  = *(UINT8*)&(ForType23InputData->ResetCapabilities);\r
-  SmbiosRecord->ResetCount    = (UINT16)ForType23InputData->ResetCount;\r
-  SmbiosRecord->ResetLimit    = (UINT16)ForType23InputData->ResetLimit;  \r
-  SmbiosRecord->TimerInterval = (UINT16)ForType23InputData->ResetTimerInterval;\r
-  SmbiosRecord->Timeout       = (UINT16)ForType23InputData->ResetTimeout;\r
-\r
-  //\r
-  // Now we have got the full smbios record, call smbios protocol to add this record.\r
-  //\r
-  SmbiosHandle = 0;\r
-  Status = Smbios-> Add(\r
-                      Smbios, \r
-                      NULL,\r
-                      &SmbiosHandle, \r
-                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
-                      );\r
-  FreePool(SmbiosRecord);\r
-  return Status;\r
-}\r
-\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.h b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.h
deleted file mode 100644 (file)
index 7e5be7e..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  MiscSubclassDriver.h\r
-\r
-Abstract:\r
-\r
-  Header file for MiscSubclass Driver.\r
-\r
-**/\r
-\r
-#ifndef _MISC_SUBCLASS_DRIVER_H\r
-#define _MISC_SUBCLASS_DRIVER_H\r
-\r
-#include <FrameworkDxe.h>\r
-\r
-#include <Guid/DataHubRecords.h>\r
-#include <IndustryStandard/SmBios.h>\r
-#include <Protocol/Smbios.h>\r
-#include <Protocol/EmuIoThunk.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-\r
-#include <MiscDevicePath.h>\r
-#include <Protocol/FrameworkHii.h>\r
-#include <Library/HiiLib.h>\r
-\r
-//\r
-// Data table entry update function.\r
-//\r
-typedef EFI_STATUS (EFIAPI EFI_MISC_SMBIOS_DATA_FUNCTION) (\r
-  IN  VOID                 *RecordData,\r
-  IN  EFI_SMBIOS_PROTOCOL  *Smbios\r
-  );\r
-\r
-//\r
-// Data table entry definition.\r
-//\r
-typedef struct {\r
-  //\r
-  // intermediat input data for SMBIOS record\r
-  //\r
-  VOID                              *RecordData;\r
-  EFI_MISC_SMBIOS_DATA_FUNCTION     *Function;\r
-} EFI_MISC_SMBIOS_DATA_TABLE;\r
-\r
-//\r
-// Data Table extern definitions.\r
-//\r
-#define MISC_SMBIOS_TABLE_EXTERNS(NAME1, NAME2, NAME3) \\r
-extern NAME1 NAME2 ## Data; \\r
-extern EFI_MISC_SMBIOS_DATA_FUNCTION NAME3 ## Function\r
-\r
-\r
-//\r
-// Data Table entries\r
-//\r
-#define MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION(NAME1, NAME2) \\r
-{ \\r
-  & NAME1 ## Data, \\r
-  & NAME2 ## Function \\r
-}\r
-\r
-//\r
-// Global definition macros.\r
-//\r
-#define MISC_SMBIOS_TABLE_DATA(NAME1, NAME2) \\r
-  NAME1 NAME2 ## Data\r
-\r
-#define MISC_SMBIOS_TABLE_FUNCTION(NAME2) \\r
-  EFI_STATUS EFIAPI NAME2 ## Function( \\r
-  IN  VOID                  *RecordData, \\r
-  IN  EFI_SMBIOS_PROTOCOL   *Smbios \\r
-  )\r
-\r
-\r
-//\r
-// Data Table Array\r
-//\r
-extern EFI_MISC_SMBIOS_DATA_TABLE mMiscSubclassDataTable[];\r
-\r
-//\r
-// Data Table Array Entries\r
-//\r
-extern UINTN                        mMiscSubclassDataTableEntries;\r
-extern UINT8                        MiscSubclassStrings[];\r
-extern EFI_HII_HANDLE               mHiiHandle;\r
-\r
-//\r
-// Prototypes\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-MiscSubclassDriverEntryPoint (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  );\r
-\r
-\r
-#endif /* _MISC_SUBCLASS_DRIVER_H */\r
-\r
-/* eof - MiscSubclassDriver.h */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.inf b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.inf
deleted file mode 100644 (file)
index aed93f5..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-## @file\r
-# Misc Sub class driver\r
-#\r
-# Parses the MiscSubclassDataTable and reports any generated data to the DataHub.\r
-#  All .uni file who tagged with "ToolCode="DUMMY"" in following file list is included by\r
-#  MiscSubclassDriver.uni file, the StrGather tool will expand MiscSubclassDriver.uni file \r
-#  and parse all .uni file.\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = MiscSubclass\r
-  FILE_GUID                      = f2fbd108-8985-11db-b06a-0040d02b1835\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  ENTRY_POINT                    = MiscSubclassDriverEntryPoint\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  MiscBaseBoardManufacturer.uni\r
-  MiscBaseBoardManufacturerData.c\r
-  MiscBaseBoardManufacturerFunction.c\r
-  MiscBiosVendor.uni\r
-  MiscBiosVendorData.c\r
-  MiscBiosVendorFunction.c\r
-  MiscBootInformationData.c  \r
-  MiscBootInformationFunction.c\r
-  MiscChassisManufacturer.uni\r
-  MiscChassisManufacturerData.c\r
-  MiscChassisManufacturerFunction.c\r
-  MiscNumberOfInstallableLanguagesData.c\r
-  MiscNumberOfInstallableLanguagesFunction.c\r
-  MiscOemString.uni  \r
-  MiscOemStringData.c  \r
-  MiscOemStringFunction.c  \r
-  MiscPortInternalConnectorDesignator.uni\r
-  MiscPortInternalConnectorDesignatorData.c  \r
-  MiscPortInternalConnectorDesignatorFunction.c\r
-  MiscResetCapabilitiesData.c\r
-  MiscResetCapabilitiesFunction.c\r
-  MiscSystemLanguageString.uni\r
-  MiscSystemLanguageStringData.c\r
-  MiscSystemLanguageStringFunction.c\r
-  MiscSystemManufacturer.uni\r
-  MiscSystemManufacturerData.c\r
-  MiscSystemManufacturerFunction.c\r
-  MiscSystemOptionString.uni\r
-  MiscSystemOptionStringData.c\r
-  MiscSystemOptionStringFunction.c\r
-  MiscSystemSlotDesignation.uni\r
-  MiscSystemSlotDesignationData.c\r
-  MiscSystemSlotDesignationFunction.c\r
-  MiscDevicePath.h\r
-  MiscSubClassDriver.h\r
-  MiscSubClassDriver.uni\r
-  MiscSubclassDriverDataTable.c\r
-  MiscSubclassDriverEntryPoint.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  DevicePathLib\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  UefiDriverEntryPoint\r
-  UefiLib\r
-  HiiLib\r
-  DebugLib\r
-  BaseLib\r
-  PcdLib\r
-\r
-[Protocols]\r
-  gEfiSmbiosProtocolGuid                        # PROTOCOL ALWAYS_CONSUMED\r
-\r
-[Pcd]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString\r
-  gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang  \r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuMemorySize\r
-\r
-\r
-[Depex]\r
-  gEfiSmbiosProtocolGuid\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.uni b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.uni
deleted file mode 100644 (file)
index 7a4e8a2..0000000
Binary files a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.uni and /dev/null differ
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubclassDriverDataTable.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubclassDriverDataTable.c
deleted file mode 100644 (file)
index cb71f7d..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MiscSubclassDriverDataTable.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-\r
-//\r
-// External definitions referenced by Data Table entries.\r
-//\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_BASE_BOARD_MANUFACTURER_DATA, MiscBaseBoardManufacturer, MiscBaseBoardManufacturer);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_BIOS_VENDOR_DATA, MiscBiosVendor,MiscBiosVendor );\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_BOOT_INFORMATION_STATUS_DATA, BootInformationStatus, BootInformationStatus);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_CHASSIS_MANUFACTURER_DATA, MiscChassisManufacturer, MiscChassisManufacturer);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA,NumberOfInstallableLanguages, NumberOfInstallableLanguages);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_OEM_STRING_DATA,OemString, OemString);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortInternalConnectorDesignator, MiscPortInternalConnectorDesignator);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortKeyboard, MiscPortInternalConnectorDesignator);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortMouse, MiscPortInternalConnectorDesignator);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom1, MiscPortInternalConnectorDesignator);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortCom2, MiscPortInternalConnectorDesignator);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortExtensionPower, MiscPortInternalConnectorDesignator);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA, MiscPortFloppy, MiscPortInternalConnectorDesignator);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_RESET_CAPABILITIES, MiscResetCapabilities, MiscResetCapabilities);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA,SystemLanguageString, SystemLanguageString);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_SYSTEM_MANUFACTURER_DATA, MiscSystemManufacturer, MiscSystemManufacturer);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_SYSTEM_OPTION_STRING_DATA, SystemOptionString, SystemOptionString);\r
-MISC_SMBIOS_TABLE_EXTERNS ( EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA, MiscSystemSlotDesignation, MiscSystemSlotDesignation);\r
-\r
-\r
-//\r
-// Data Table.\r
-//\r
-EFI_MISC_SMBIOS_DATA_TABLE  mMiscSubclassDataTable[] = {\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscBaseBoardManufacturer, MiscBaseBoardManufacturer),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscBiosVendor,MiscBiosVendor ),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( BootInformationStatus, BootInformationStatus),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscChassisManufacturer, MiscChassisManufacturer),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION(NumberOfInstallableLanguages, NumberOfInstallableLanguages),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION(OemString, OemString),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortInternalConnectorDesignator, MiscPortInternalConnectorDesignator),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortKeyboard, MiscPortInternalConnectorDesignator),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortMouse, MiscPortInternalConnectorDesignator),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortCom1, MiscPortInternalConnectorDesignator),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortCom2, MiscPortInternalConnectorDesignator),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortExtensionPower, MiscPortInternalConnectorDesignator),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscPortFloppy, MiscPortInternalConnectorDesignator),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscResetCapabilities, MiscResetCapabilities),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION(SystemLanguageString, SystemLanguageString),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscSystemManufacturer, MiscSystemManufacturer),\r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( SystemOptionString, SystemOptionString),  \r
-  MISC_SMBIOS_TABLE_ENTRY_DATA_AND_FUNCTION( MiscSystemSlotDesignation, MiscSystemSlotDesignation),  \r
-  };\r
\r
-//\r
-// Number of Data Table entries.\r
-//\r
-UINTN mMiscSubclassDataTableEntries = (sizeof mMiscSubclassDataTable) / sizeof (EFI_MISC_SMBIOS_DATA_TABLE);\r
-\r
-/* eof - MiscSubclassDriverDataTable.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c
deleted file mode 100644 (file)
index 065ab6f..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  MiscSubclassDriverEntryPoint.c\r
-\r
-Abstract:\r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-EFI_HII_HANDLE  mHiiHandle;\r
-\r
-/**\r
-  This is the standard EFI driver point that detects whether there is a\r
-  MemoryConfigurationData Variable and, if so, reports memory configuration info\r
-  to the DataHub.\r
-\r
-  @param  ImageHandle  Handle for the image of this driver\r
-  @param  SystemTable  Pointer to the EFI System Table\r
-\r
-  @return EFI_SUCCESS if the data is successfully reported\r
-  @return EFI_NOT_FOUND if the HOB list could not be located.\r
-\r
-**/\r
-EFI_STATUS\r
-LogMemorySmbiosRecord (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  UINT64                          TotalMemorySize;\r
-  UINT8                           NumSlots;\r
-  SMBIOS_TABLE_TYPE19             *Type19Record;\r
-  EFI_SMBIOS_HANDLE               MemArrayMappedAddrSmbiosHandle;\r
-  EFI_SMBIOS_PROTOCOL             *Smbios;\r
-  CHAR16                          *MemString;\r
-\r
-  Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  NumSlots        = 1;\r
-\r
-  //\r
-  // Process Memory String in form size!size ...\r
-  // So 64!64 is 128 MB\r
-  //\r
-  MemString   = (CHAR16 *)PcdGetPtr (PcdEmuMemorySize);\r
-  for (TotalMemorySize = 0; *MemString != '\0';) {\r
-    TotalMemorySize += StrDecimalToUint64 (MemString);\r
-    while (*MemString != '\0') {\r
-      if (*MemString == '!') {\r
-        MemString++;       \r
-        break;\r
-      }\r
-      MemString++;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Convert Total Memory Size to based on KiloByte\r
-  //\r
-  TotalMemorySize = LShiftU64 (TotalMemorySize, 20);\r
-  //\r
-  // Generate Memory Array Mapped Address info\r
-  //\r
-  Type19Record = AllocatePool(sizeof (SMBIOS_TABLE_TYPE19));\r
-  ZeroMem(Type19Record, sizeof(SMBIOS_TABLE_TYPE19));\r
-  Type19Record->Hdr.Type = EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS;\r
-  Type19Record->Hdr.Length = sizeof(SMBIOS_TABLE_TYPE19);\r
-  Type19Record->Hdr.Handle = 0;\r
-  Type19Record->StartingAddress = 0;\r
-  Type19Record->EndingAddress =  (UINT32)RShiftU64(TotalMemorySize, 10) - 1;\r
-  Type19Record->MemoryArrayHandle = 0;\r
-  Type19Record->PartitionWidth = (UINT8)(NumSlots); \r
-\r
-  //\r
-  // Generate Memory Array Mapped Address info (TYPE 19)\r
-  //\r
-  MemArrayMappedAddrSmbiosHandle = 0;\r
-  Status = Smbios->Add (Smbios, NULL, &MemArrayMappedAddrSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type19Record);\r
-  FreePool(Type19Record);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-MiscSubclassDriverEntryPoint (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-/*++\r
-Description:\r
-\r
-  Standard EFI driver point.  This driver parses the mMiscSubclassDataTable\r
-  structure and reports any generated data to the DataHub.\r
-\r
-Arguments:\r
-\r
-  ImageHandle\r
-    Handle for the image of this driver\r
-\r
-  SystemTable\r
-    Pointer to the EFI System Table\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS\r
-    The data was successfully reported to the Data Hub.\r
-\r
-**/\r
-{\r
-  UINTN                Index;\r
-  EFI_STATUS           EfiStatus;\r
-  EFI_SMBIOS_PROTOCOL  *Smbios;  \r
-\r
-  EfiStatus = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
-\r
-  if (EFI_ERROR(EfiStatus)) {\r
-    DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol.  %r\n", EfiStatus));\r
-    return EfiStatus;\r
-  }\r
-\r
-  mHiiHandle = HiiAddPackages (\r
-                 &gEfiCallerIdGuid,\r
-                 NULL,\r
-                 MiscSubclassStrings,\r
-                 NULL\r
-                 );\r
-  ASSERT (mHiiHandle != NULL);\r
-\r
-  for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {\r
-    //\r
-    // If the entry have a function pointer, just log the data.\r
-    //\r
-    if (mMiscSubclassDataTable[Index].Function != NULL) {\r
-      EfiStatus = (*mMiscSubclassDataTable[Index].Function)(\r
-        mMiscSubclassDataTable[Index].RecordData,\r
-        Smbios\r
-        );\r
-\r
-      if (EFI_ERROR(EfiStatus)) {\r
-        DEBUG((EFI_D_ERROR, "Misc smbios store error.  Index=%d, ReturnStatus=%r\n", Index, EfiStatus));\r
-        return EfiStatus;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Log Memory SMBIOS Record\r
-  //\r
-  EfiStatus = LogMemorySmbiosRecord();\r
-  return EfiStatus;\r
-}\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemLanguageString.uni b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemLanguageString.uni
deleted file mode 100644 (file)
index 709c53a..0000000
Binary files a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemLanguageString.uni and /dev/null differ
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringData.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringData.c
deleted file mode 100644 (file)
index 0dc706e..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MiscSystemLanguageStringData.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-//\r
-// Static (possibly build generated) Bios Vendor data.\r
-//\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA, SystemLanguageString) = {\r
-  0,\r
-  STRING_TOKEN(STR_MISC_SYSTEM_LANGUAGE_STRING)\r
-};\r
-\r
-/* eof - MiscSystemLanguageStringData.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c
deleted file mode 100644 (file)
index 3e10c63..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/** @file\r
-  ResetCapabilities.\r
-  SMBIOS type 23.\r
-\r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-/**\r
-  This function makes boot time changes to the contents of the\r
-  MiscOemString (Type 11).\r
-\r
-  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
-\r
-  @retval EFI_SUCCESS                All parameters were valid.\r
-  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
-\r
-**/\r
-MISC_SMBIOS_TABLE_FUNCTION(SystemLanguageString)\r
-{\r
-  EFI_STATUS               Status;\r
-  EFI_SMBIOS_HANDLE        SmbiosHandle;\r
-  SMBIOS_TABLE_TYPE13      *SmbiosRecord;\r
-  UINTN                    StrLeng;\r
-  CHAR8                    *OptionalStrStart;\r
-  EFI_STRING               Str;\r
-  STRING_REF               TokenToGet;\r
-  \r
-\r
-  //\r
-  // First check for invalid parameters.\r
-  //\r
-  if (RecordData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_LANGUAGE_STRING);\r
-  Str = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  StrLeng = StrLen(Str);\r
-  if (StrLeng > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Two zeros following the last string.\r
-  //\r
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE13) + StrLeng + 1 + 1);\r
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE13) + StrLeng + 1 + 1);\r
-\r
-  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE13);\r
-  //\r
-  // Make handle chosen by smbios protocol.add automatically.\r
-  // \r
-  SmbiosRecord->Hdr.Handle    = 0;\r
-  SmbiosRecord->InstallableLanguages = 1;\r
-  SmbiosRecord->Flags   = 1;\r
-  SmbiosRecord->CurrentLanguages = 1;\r
-  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
-  UnicodeStrToAsciiStr(Str, OptionalStrStart);\r
-  \r
-\r
-  //\r
-  // Now we have got the full smbios record, call smbios protocol to add this record.\r
-  //\r
-  SmbiosHandle = 0;\r
-  Status = Smbios-> Add(\r
-                      Smbios, \r
-                      NULL,\r
-                      &SmbiosHandle, \r
-                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
-                      );\r
-  FreePool(SmbiosRecord);\r
-  return Status;\r
-}\r
-\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemManufacturer.uni b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemManufacturer.uni
deleted file mode 100644 (file)
index 3ff890b..0000000
Binary files a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemManufacturer.uni and /dev/null differ
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerData.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerData.c
deleted file mode 100644 (file)
index 13befc4..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MiscSystemManufacturerData.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-//\r
-// Static (possibly build generated) System Manufacturer data.\r
-//\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_SYSTEM_MANUFACTURER_DATA, MiscSystemManufacturer)\r
-= {\r
-  STRING_TOKEN(STR_MISC_SYSTEM_MANUFACTURER),\r
-  // SystemManufactrurer\r
-  STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME),\r
-  // SystemProductName\r
-  STRING_TOKEN(STR_MISC_SYSTEM_VERSION),\r
-  // SystemVersion\r
-  STRING_TOKEN(STR_MISC_SYSTEM_SERIAL_NUMBER),\r
-  // SystemSerialNumber\r
-  {\r
-    0xbadfaced,\r
-    0xdead,\r
-    0xbeef,\r
-    {\r
-      0x13,\r
-      0x13,\r
-      0x13,\r
-      0x13,\r
-      0x13,\r
-      0x13,\r
-      0x13,\r
-      0x13\r
-    }\r
-  },\r
-  // SystemUuid\r
-  EfiSystemWakeupTypePowerSwitch  // SystemWakeupType\r
-};\r
-\r
-/* eof - MiscSystemManufacturerData.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c
deleted file mode 100644 (file)
index 9d2a3cb..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MiscSystemManufacturerFunction.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-/**\r
-  This function makes boot time changes to the contents of the\r
-  MiscSystemManufacturer (Type 1).\r
-\r
-  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
-\r
-  @retval EFI_SUCCESS                All parameters were valid.\r
-  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
-\r
-**/\r
-MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)\r
-{\r
-  CHAR8                             *OptionalStrStart;\r
-  UINTN                             ManuStrLen;\r
-  UINTN                             VerStrLen;\r
-  UINTN                             PdNameStrLen;\r
-  UINTN                             SerialNumStrLen;\r
-  EFI_STATUS                        Status;\r
-  EFI_STRING                        Manufacturer;\r
-  EFI_STRING                        ProductName;\r
-  EFI_STRING                        Version;\r
-  EFI_STRING                        SerialNumber;\r
-  STRING_REF                        TokenToGet;\r
-  EFI_SMBIOS_HANDLE                 SmbiosHandle;\r
-  SMBIOS_TABLE_TYPE1                *SmbiosRecord;\r
-  EFI_MISC_SYSTEM_MANUFACTURER      *ForType1InputData;\r
-\r
-  ForType1InputData = (EFI_MISC_SYSTEM_MANUFACTURER *)RecordData;\r
-\r
-  //\r
-  // First check for invalid parameters.\r
-  //\r
-  if (RecordData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER);\r
-  Manufacturer = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  ManuStrLen = StrLen(Manufacturer);\r
-  if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME);\r
-  ProductName = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  PdNameStrLen = StrLen(ProductName);\r
-  if (PdNameStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_VERSION);\r
-  Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  VerStrLen = StrLen(Version);\r
-  if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SERIAL_NUMBER);\r
-  SerialNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  SerialNumStrLen = StrLen(SerialNumber);\r
-  if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Two zeros following the last string.\r
-  //\r
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 1);\r
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 1);\r
-\r
-  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_INFORMATION;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1);\r
-  //\r
-  // Make handle chosen by smbios protocol.add automatically.\r
-  // \r
-  SmbiosRecord->Hdr.Handle = 0;  \r
-  //\r
-  // Manu will be the 1st optional string following the formatted structure.\r
-  //\r
-  SmbiosRecord->Manufacturer = 1;\r
-  //\r
-  // ProductName will be the 2nd optional string following the formatted structure.\r
-  //\r
-  SmbiosRecord->ProductName = 2;  \r
-  //\r
-  // Version will be the 3rd optional string following the formatted structure.  \r
-  //\r
-  SmbiosRecord->Version = 3;  \r
-  //\r
-  // Version will be the 4th optional string following the formatted structure.\r
-  //\r
-  SmbiosRecord->SerialNumber = 4;\r
-  CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,16);\r
-  SmbiosRecord->WakeUpType = (UINT8)ForType1InputData->SystemWakeupType;\r
-\r
-  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
-  UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);\r
-  UnicodeStrToAsciiStr(ProductName, OptionalStrStart + ManuStrLen + 1);\r
-  UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1);\r
-  UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1);\r
-\r
-  //\r
-  // Now we have got the full smbios record, call smbios protocol to add this record.\r
-  //\r
-  SmbiosHandle = 0;\r
-  Status = Smbios-> Add(\r
-                      Smbios, \r
-                      NULL,\r
-                      &SmbiosHandle, \r
-                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
-                      );\r
-  FreePool(SmbiosRecord);\r
-  return Status;\r
-}\r
-\r
-/* eof - MiscSystemManufacturerFunction.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemOptionString.uni b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemOptionString.uni
deleted file mode 100644 (file)
index abf2da7..0000000
Binary files a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemOptionString.uni and /dev/null differ
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringData.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringData.c
deleted file mode 100644 (file)
index 581586b..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-\r
-  MiscSystemOptionStringData.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-//\r
-// Static (possibly build generated) Bios Vendor data.\r
-//\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_SYSTEM_OPTION_STRING_DATA, SystemOptionString) = {\r
-  {STRING_TOKEN(STR_MISC_SYSTEM_OPTION_STRING)}\r
-};\r
-\r
-/* eof - MiscSystemOptionStringData.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c
deleted file mode 100644 (file)
index a910634..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/** @file\r
-  BIOS system option string boot time changes.\r
-  SMBIOS type 12.\r
-\r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-\r
-/**\r
-  This function makes boot time changes to the contents of the\r
-  MiscSystemOptionString (Type 12).\r
-\r
-  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
-\r
-  @retval EFI_SUCCESS                All parameters were valid.\r
-  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
-\r
-**/\r
-MISC_SMBIOS_TABLE_FUNCTION(SystemOptionString)\r
-{\r
-  CHAR8                             *OptionalStrStart;\r
-  UINTN                             OptStrLen;\r
-  EFI_STRING                        OptionString;\r
-  EFI_STATUS                        Status;\r
-  STRING_REF                        TokenToGet;\r
-  EFI_SMBIOS_HANDLE                 SmbiosHandle;\r
-  SMBIOS_TABLE_TYPE12               *SmbiosRecord;\r
-\r
-  //\r
-  // First check for invalid parameters.\r
-  //\r
-  if (RecordData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_OPTION_STRING);\r
-  OptionString = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  OptStrLen = StrLen(OptionString);\r
-  if (OptStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
\r
-  //\r
-  // Two zeros following the last string.\r
-  //\r
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1);\r
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE12) + OptStrLen + 1 + 1);\r
-\r
-  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE12);\r
-  //\r
-  // Make handle chosen by smbios protocol.add automatically.\r
-  //\r
-  SmbiosRecord->Hdr.Handle = 0;  \r
-\r
-  SmbiosRecord->StringCount = 1;\r
-  OptionalStrStart = (CHAR8*) (SmbiosRecord + 1);\r
-  UnicodeStrToAsciiStr(OptionString, OptionalStrStart);\r
-  //\r
-  // Now we have got the full smbios record, call smbios protocol to add this record.\r
-  //\r
-  SmbiosHandle = 0;\r
-  Status = Smbios-> Add(\r
-                      Smbios, \r
-                      NULL,\r
-                      &SmbiosHandle, \r
-                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
-                      );\r
-\r
-  FreePool(SmbiosRecord);\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignation.uni b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignation.uni
deleted file mode 100644 (file)
index 45e9ce3..0000000
Binary files a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignation.uni and /dev/null differ
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationData.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationData.c
deleted file mode 100644 (file)
index 11b2339..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-Module Name:\r
-  \r
-    MiscSystemSlotDesignationData.c\r
-  \r
-Abstract: \r
-\r
-  This driver parses the mMiscSubclassDataTable structure and reports\r
-  any generated data to the DataHub.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-\r
-//\r
-// Static (possibly build generated) Bios Vendor data.\r
-//\r
-MISC_SMBIOS_TABLE_DATA(EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA, MiscSystemSlotDesignation) = {\r
-  STRING_TOKEN(STR_MISC_SYSTEM_SLOT_DESIGNATION),   // SlotDesignation\r
-  EfiSlotTypeOther,         // SlotType\r
-  EfiSlotDataBusWidthOther, // SlotDataBusWidth\r
-  EfiSlotUsageOther,        // SlotUsage\r
-  EfiSlotLengthOther,       // SlotLength\r
-  0,                        // SlotId\r
-  {                         // SlotCharacteristics\r
-    0,                      // CharacteristicsUnknown  :1;\r
-    0,                      // Provides50Volts         :1;\r
-    0,                      // Provides33Volts         :1;\r
-    0,                      // SharedSlot              :1;\r
-    0,                      // PcCard16Supported       :1;\r
-    0,                      // CardBusSupported        :1;\r
-    0,                      // ZoomVideoSupported      :1;\r
-    0,                      // ModemRingResumeSupported:1;\r
-    0,                      // PmeSignalSupported      :1;\r
-    0,                      // HotPlugDevicesSupported :1;\r
-    0,                      // SmbusSignalSupported    :1;\r
-    0                       // Reserved                :21;\r
-  },\r
-  {0, 0, {0, 0}}            // SlotDevicePath\r
-};\r
-\r
-/* eof - MiscSystemSlotsData.c */\r
diff --git a/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c b/InOsEmuPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c
deleted file mode 100644 (file)
index 72c4137..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/** @file\r
-  BIOS system slot designator information boot time changes.\r
-  SMBIOS type 9.\r
-\r
-  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "MiscSubClassDriver.h"\r
-/**\r
-  This function makes boot time changes to the contents of the\r
-  MiscSystemSlotDesignator structure (Type 9).\r
-\r
-  @param  RecordData                 Pointer to copy of RecordData from the Data Table.  \r
-\r
-  @retval EFI_SUCCESS                All parameters were valid.\r
-  @retval EFI_UNSUPPORTED            Unexpected RecordType value.\r
-  @retval EFI_INVALID_PARAMETER      Invalid parameter was found.\r
-\r
-**/\r
-MISC_SMBIOS_TABLE_FUNCTION(MiscSystemSlotDesignation)\r
-{\r
-  CHAR8                              *OptionalStrStart;\r
-  UINTN                              SlotDesignationStrLen;\r
-  EFI_STATUS                         Status;\r
-  EFI_STRING                         SlotDesignation;\r
-  STRING_REF                         TokenToGet;\r
-  SMBIOS_TABLE_TYPE9                 *SmbiosRecord;\r
-  EFI_SMBIOS_HANDLE                  SmbiosHandle;\r
-  EFI_MISC_SYSTEM_SLOT_DESIGNATION*  ForType9InputData;\r
-\r
-  ForType9InputData = (EFI_MISC_SYSTEM_SLOT_DESIGNATION *)RecordData;\r
-\r
-  //\r
-  // First check for invalid parameters.\r
-  //\r
-  if (RecordData == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  TokenToGet = 0;\r
-  switch (ForType9InputData->SlotDesignation) {\r
-    case STR_MISC_SYSTEM_SLOT_DESIGNATION: \r
-      TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_DESIGNATION);\r
-      break;\r
-    default:\r
-      break;\r
-  }\r
-\r
-  SlotDesignation = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  SlotDesignationStrLen = StrLen(SlotDesignation);\r
-  if (SlotDesignationStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  \r
-  //\r
-  // Two zeros following the last string.\r
-  //\r
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE9) + SlotDesignationStrLen + 1 + 1);\r
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE9) +SlotDesignationStrLen + 1 + 1);\r
-\r
-  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_SLOTS;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE9);\r
-  SmbiosRecord->Hdr.Handle = 0; \r
-  SmbiosRecord->SlotDesignation = 1;\r
-  SmbiosRecord->SlotType = ForType9InputData->SlotType;\r
-  SmbiosRecord->SlotDataBusWidth = ForType9InputData->SlotDataBusWidth;\r
-  SmbiosRecord->CurrentUsage = ForType9InputData->SlotUsage;\r
-  SmbiosRecord->SlotLength = ForType9InputData->SlotLength;\r
-  SmbiosRecord->SlotID = ForType9InputData->SlotId;\r
-  \r
-  //\r
-  // Slot Characteristics\r
-  //\r
-  CopyMem ((UINT8 *) &SmbiosRecord->SlotCharacteristics1,(UINT8 *) &ForType9InputData->SlotCharacteristics,2);\r
-  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
-  UnicodeStrToAsciiStr(SlotDesignation, OptionalStrStart);\r
-  //  \r
-  // Now we have got the full smbios record, call smbios protocol to add this record.\r
-  //\r
-  SmbiosHandle = 0;\r
-  Status = Smbios-> Add(\r
-                      Smbios, \r
-                      NULL,\r
-                      &SmbiosHandle, \r
-                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
-                      );\r
-  FreePool(SmbiosRecord);\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/RealTimeClockRuntimeDxe/RealTimeClock.c b/InOsEmuPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
deleted file mode 100644 (file)
index 05c34bd..0000000
+++ /dev/null
@@ -1,305 +0,0 @@
-/*++\r
-  Emu RTC Architectural Protocol Driver as defined in PI\r
-\r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-#include <PiDxe.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/EmuThunkLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-#include <Protocol/RealTimeClock.h>\r
-\r
-BOOLEAN\r
-DayValid (\r
-  IN  EFI_TIME  *Time\r
-  );\r
-\r
-BOOLEAN\r
-IsLeapYear (\r
-  IN EFI_TIME   *Time\r
-  );\r
-\r
-EFI_STATUS\r
-RtcTimeFieldsValid (\r
-  IN EFI_TIME *Time\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeRealTimeClock (\r
-  IN EFI_HANDLE                          ImageHandle,\r
-  IN EFI_SYSTEM_TABLE                    *SystemTable\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGetTime (\r
-  OUT EFI_TIME                                 * Time,\r
-  OUT EFI_TIME_CAPABILITIES                    * Capabilities OPTIONAL\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Service routine for RealTimeClockInstance->GetTime \r
-\r
-Arguments:\r
-\r
-  Time          - A pointer to storage that will receive a snapshot of the current time.\r
-\r
-  Capabilities  - A pointer to storage that will receive the capabilities of the real time clock\r
-                  in the platform. This includes the real time clock's resolution and accuracy.  \r
-                  All reported device capabilities are rounded up.  This is an OPTIONAL argument.\r
-\r
-Returns:\r
-\r
-  EFI_SUCEESS   - The underlying GetSystemTime call occurred and returned\r
-                  Note that in the NT32 emulation, the GetSystemTime call has no return value\r
-                  thus you will always receive a EFI_SUCCESS on this.\r
-\r
-**/\r
-{\r
-\r
-  //\r
-  // Check parameter for null pointer\r
-  //\r
-  if (Time == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-\r
-  }\r
-\r
-  gEmuThunk->GetTime (Time, Capabilities);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSetTime (\r
-  IN EFI_TIME   *Time\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Service routine for RealTimeClockInstance->SetTime \r
-\r
-Arguments:\r
-\r
-  Time          - A pointer to storage containing the time and date information to\r
-                  program into the real time clock.\r
-\r
-Returns:\r
-\r
-  EFI_SUCEESS           - The operation completed successfully.\r
-                  \r
-  EFI_INVALID_PARAMETER - One of the fields in Time is out of range.\r
-\r
-  EFI_DEVICE_ERROR      - The operation could not be complete due to a device error.\r
-\r
-**/\r
-{\r
-  EFI_STATUS            Status;\r
-\r
-  if (Time == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Make sure that the time fields are valid\r
-  //\r
-  Status = RtcTimeFieldsValid (Time);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuGetWakeupTime (\r
-  OUT BOOLEAN        *Enabled,\r
-  OUT BOOLEAN        *Pending,\r
-  OUT EFI_TIME       *Time\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Service routine for RealTimeClockInstance->GetWakeupTime\r
-\r
-Arguments:\r
-  This          - Indicates the protocol instance structure.\r
-\r
-  Enabled       - Indicates if the alarm is currently enabled or disabled.\r
-\r
-  Pending       - Indicates if the alarm signal is pending and requires\r
-                  acknowledgement.\r
-\r
-  Time          - The current alarm setting.\r
-\r
-Returns:\r
-\r
-  EFI_SUCEESS           - The operation completed successfully.\r
-                  \r
-  EFI_DEVICE_ERROR      - The operation could not be complete due to a device error.\r
-\r
-  EFI_UNSUPPORTED       - The operation is not supported on this platform.\r
-\r
-**/\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuSetWakeupTime (\r
-  IN BOOLEAN      Enable,\r
-  OUT EFI_TIME    *Time\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Service routine for RealTimeClockInstance->SetWakeupTime\r
-\r
-Arguments:\r
-\r
-  Enabled       - Enable or disable the wakeup alarm.\r
-\r
-  Time          - If enable is TRUE, the time to set the wakup alarm for.\r
-                  If enable is FALSE, then this parameter is optional, and\r
-                  may be NULL.\r
-\r
-Returns:\r
-\r
-  EFI_SUCEESS           - The operation completed successfully.\r
-                  \r
-  EFI_DEVICE_ERROR      - The operation could not be complete due to a device error.\r
-\r
-  EFI_INVALID_PARAMETER - A field in Time is out of range.\r
-\r
-  EFI_UNSUPPORTED       - The operation is not supported on this platform.\r
-\r
-**/\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeRealTimeClock (\r
-  IN EFI_HANDLE                            ImageHandle,\r
-  IN EFI_SYSTEM_TABLE                      *SystemTable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Install Real Time Clock Protocol \r
-\r
-Arguments:\r
-  ImageHandle - Image Handle\r
-  SystemTable - Pointer to system table\r
-\r
-Returns:\r
-\r
-  EFI_SUCEESS - Real Time Clock Services are installed into the Runtime Services Table\r
-\r
-**/\r
-{\r
-  EFI_STATUS  Status;\r
-  EFI_HANDLE  Handle;\r
-\r
-  SystemTable->RuntimeServices->GetTime       = EmuGetTime;\r
-  SystemTable->RuntimeServices->SetTime       = EmuSetTime;\r
-  SystemTable->RuntimeServices->GetWakeupTime = EmuGetWakeupTime;\r
-  SystemTable->RuntimeServices->SetWakeupTime = EmuSetWakeupTime;\r
-\r
-  Handle = NULL;\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Handle,\r
-                  &gEfiRealTimeClockArchProtocolGuid,\r
-                  NULL,\r
-                  NULL\r
-                  );\r
-  return Status;\r
-}\r
-\r
-EFI_STATUS\r
-RtcTimeFieldsValid (\r
-  IN EFI_TIME *Time\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Arguments:\r
\r
-  Returns: \r
-**/\r
-{\r
-  if (Time->Year < 1998 ||\r
-      Time->Year > 2099 ||\r
-      Time->Month < 1 ||\r
-      Time->Month > 12 ||\r
-      (!DayValid (Time)) ||\r
-      Time->Hour > 23 ||\r
-      Time->Minute > 59 ||\r
-      Time->Second > 59 ||\r
-      Time->Nanosecond > 999999999 ||\r
-      (!(Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE || (Time->TimeZone >= -1440 && Time->TimeZone <= 1440))) ||\r
-      (Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT)))\r
-      ) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-BOOLEAN\r
-DayValid (\r
-  IN  EFI_TIME  *Time\r
-  )\r
-{\r
-\r
-  STATIC const INTN  DayOfMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };\r
-\r
-  if (Time->Day < 1 ||\r
-      Time->Day > DayOfMonth[Time->Month - 1] ||\r
-      (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))\r
-      ) {\r
-    return FALSE;\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-\r
-BOOLEAN\r
-IsLeapYear (\r
-  IN EFI_TIME   *Time\r
-  )\r
-{\r
-  if (Time->Year % 4 == 0) {\r
-    if (Time->Year % 100 == 0) {\r
-      if (Time->Year % 400 == 0) {\r
-        return TRUE;\r
-      } else {\r
-        return FALSE;\r
-      }\r
-    } else {\r
-      return TRUE;\r
-    }\r
-  } else {\r
-    return FALSE;\r
-  }\r
-}\r
diff --git a/InOsEmuPkg/RealTimeClockRuntimeDxe/RealTimeClock.inf b/InOsEmuPkg/RealTimeClockRuntimeDxe/RealTimeClock.inf
deleted file mode 100644 (file)
index 8aa4903..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-## @file\r
-# Emu Real time clock Architectural Protocol Driver as defined in PI\r
-#\r
-# This real time clock module simulates virtual device by time WinAPI.\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = RealTimeClock\r
-  FILE_GUID                      = f3552032-8985-11db-8429-0040d02b1835\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = InitializeRealTimeClock\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  RealTimeClock.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  EmuThunkLib\r
-  UefiDriverEntryPoint\r
-  UefiLib\r
-  DebugLib\r
-  BaseLib\r
-\r
-\r
-[Protocols]\r
-  gEfiRealTimeClockArchProtocolGuid             # PROTOCOL ALWAYS_PRODUCED\r
-\r
-\r
-[Depex]\r
-  TRUE\r
-\r
diff --git a/InOsEmuPkg/ResetRuntimeDxe/Reset.c b/InOsEmuPkg/ResetRuntimeDxe/Reset.c
deleted file mode 100644 (file)
index 14594c7..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*++ @file\r
-  Reset Architectural Protocol as defined in UEFI/PI under Emulation\r
-\r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/EmuThunkLib.h>\r
-\r
-#include <Protocol/Reset.h>\r
-\r
-\r
-VOID\r
-EFIAPI\r
-EmuResetSystem (\r
-  IN EFI_RESET_TYPE   ResetType,\r
-  IN EFI_STATUS       ResetStatus,\r
-  IN UINTN            DataSize,\r
-  IN VOID             *ResetData OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       HandleCount;\r
-  EFI_HANDLE  *HandleBuffer;\r
-  UINTN       Index;\r
-\r
-  //\r
-  // Disconnect all\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  AllHandles,\r
-                  NULL,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    for (Index = 0; Index < HandleCount; Index++) {\r
-      Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
-    }\r
-  \r
-    gBS->FreePool (HandleBuffer);\r
-  }\r
-\r
-\r
-  //\r
-  // Discard ResetType, always return 0 as exit code\r
-  //\r
-  gEmuThunk->Exit (0);\r
-\r
-  //\r
-  // Should never go here\r
-  //\r
-  ASSERT (FALSE);\r
-\r
-  return;\r
-}\r
-\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeEmuReset (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-\r
-Arguments:\r
-\r
-  ImageHandle of the loaded driver\r
-  Pointer to the System Table\r
-\r
-Returns:\r
-\r
-  Status\r
-**/\r
-{\r
-  EFI_STATUS  Status;\r
-  EFI_HANDLE  Handle;\r
-\r
-  SystemTable->RuntimeServices->ResetSystem = EmuResetSystem;\r
-\r
-  Handle = NULL;\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &Handle,\r
-                  &gEfiResetArchProtocolGuid,\r
-                  NULL,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/InOsEmuPkg/ResetRuntimeDxe/Reset.inf b/InOsEmuPkg/ResetRuntimeDxe/Reset.inf
deleted file mode 100644 (file)
index 93eb5ca..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-## @file\r
-# Emu Emulation Reset Architectural Protocol Driver as defined in PI\r
-#\r
-# This Reset module simulates system reset by process exit on Emulator.\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuReset\r
-  FILE_GUID                      = 50A18017-37AD-8743-BCF2-DF1A8FF12FAB\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = InitializeEmuReset\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  Reset.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  EmuThunkLib\r
-  UefiDriverEntryPoint\r
-  UefiLib\r
-  DebugLib\r
-  BaseLib\r
-\r
-\r
-[Protocols]\r
-  gEfiResetArchProtocolGuid                     # PROTOCOL ALWAYS_PRODUCED\r
-\r
-\r
-[Depex]\r
-  TRUE\r
-\r
diff --git a/InOsEmuPkg/Sec/Ia32/SwitchRam.S b/InOsEmuPkg/Sec/Ia32/SwitchRam.S
deleted file mode 100644 (file)
index 81e478b..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-#------------------------------------------------------------------------------\r
-#\r
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution.  The full text of the license may be found at\r
-# http:#opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-# Module Name:\r
-#\r
-#   Stack.asm\r
-#\r
-# Abstract:\r
-#\r
-#   Switch the stack from temporary memory to permenent memory.\r
-#\r
-#------------------------------------------------------------------------------\r
-\r
- .text\r
\r
-\r
-//------------------------------------------------------------------------------\r
-// VOID\r
-// EFIAPI\r
-// SecSwitchStack (\r
-//   UINT32   TemporaryMemoryBase,\r
-//   UINT32   PermenentMemoryBase\r
-//   )//\r
-//------------------------------------------------------------------------------    \r
-ASM_GLOBAL ASM_PFX(SecSwitchStack)\r
-ASM_PFX(SecSwitchStack):\r
-#\r
-# Save three register: eax, ebx, ecx\r
-#    \r
-    push  %eax\r
-    push  %ebx\r
-    push  %ecx\r
-    push  %edx\r
-    \r
-#\r
-# !!CAUTION!! this function address's is pushed into stack after\r
-# migration of whole temporary memory, so need save it to permenent\r
-# memory at first!\r
-#    \r
-    \r
-    movl  20(%esp), %ebx            # Save the first parameter\r
-    movl  24(%esp), %ecx            # Save the second parameter\r
-    \r
-#\r
-# Save this function's return address into permenent memory at first.\r
-# Then, Fixup the esp point to permenent memory\r
-#\r
-\r
-    movl  %esp, %eax\r
-    subl  %ebx, %eax\r
-    addl  %ecx, %eax\r
-    movl  (%esp), %edx                 # copy pushed register's value to permenent memory\r
-    movl  %edx, (%eax)\r
-    movl  4(%esp), %edx\r
-    movl  %edx, 4(%eax)\r
-    movl  8(%esp), %edx\r
-    movl  %edx, 8(%eax)\r
-    movl  12(%esp), %edx\r
-    movl  %edx, 12(%eax)\r
-    movl  16(%esp), %edx\r
-    movl  %edx, 16(%eax)\r
-    movl  %eax, %esp                   # From now, esp is pointed to permenent memory\r
-\r
-#\r
-# Fixup the ebp point to permenent memory\r
-#\r
-#ifndef __APPLE__\r
-    movl   %ebp, %eax\r
-    subl   %ebx, %eax\r
-    addl   %ecx, %eax\r
-    movl   %eax, %ebp                  # From now, ebp is pointed to permenent memory\r
-    \r
-#\r
-# Fixup callee's ebp point for PeiDispatch\r
-#    \r
-    movl   (%ebp), %eax\r
-    subl   %ebx, %eax\r
-    addl   %ecx, %eax\r
-    movl   %eax, (%ebp)                # From now, Temporary's PPI caller's stack is in permenent memory\r
-#endif    \r
-    \r
-    pop   %edx\r
-    pop   %ecx\r
-    pop   %ebx\r
-    pop   %eax\r
-    ret\r
-\r
diff --git a/InOsEmuPkg/Sec/Ia32/TempRam.c b/InOsEmuPkg/Sec/Ia32/TempRam.c
deleted file mode 100644 (file)
index 525fb95..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*++ @file
-  Temp RAM PPI
-
-Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
-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 <PiPei.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-
-#include <Ppi/TemporaryRamSupport.h>
-
-VOID
-EFIAPI
-SecSwitchStack (
-  UINT32   TemporaryMemoryBase,
-  UINT32   PermenentMemoryBase
-  );
-
-
-EFI_STATUS
-EFIAPI
-SecTemporaryRamSupport (
-  IN CONST EFI_PEI_SERVICES   **PeiServices,
-  IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,
-  IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,
-  IN UINTN                    CopySize
-  )
-{
-  //
-  // Migrate the whole temporary memory to permenent memory.
-  //
-  CopyMem (
-    (VOID*)(UINTN)PermanentMemoryBase,
-    (VOID*)(UINTN)TemporaryMemoryBase,
-    CopySize
-    );
-
-  //
-  // SecSwitchStack function must be invoked after the memory migration
-  // immediatly, also we need fixup the stack change caused by new call into
-  // permenent memory.
-  //
-  SecSwitchStack ((UINT32) TemporaryMemoryBase, (UINT32) PermanentMemoryBase);
-
-  //
-  // We need *not* fix the return address because currently,
-  // The PeiCore is excuted in flash.
-  //
-
-  //
-  // Simulate to invalid temporary memory, terminate temporary memory
-  //
-  //ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize);
-
-  return EFI_SUCCESS;
-}
diff --git a/InOsEmuPkg/Sec/Sec.c b/InOsEmuPkg/Sec/Sec.c
deleted file mode 100644 (file)
index 4468d6f..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*++ @file
-  Stub SEC that is called from the OS appliation that is the root of the emulator.
-  
-  The OS application will call the SEC with the PEI Entry Point API.  
-
-Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
-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 "Sec.h"
-
-
-
-EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = { 
-  SecTemporaryRamSupport
-};
-
-
-EFI_PEI_PPI_DESCRIPTOR  gPrivateDispatchTable[] = {
-  {
-    EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
-    &gEfiTemporaryRamSupportPpiGuid,
-    &mSecTemporaryRamSupportPpi
-  }
-};
-
-
-
-/**
-  The entry point of PE/COFF Image for the PEI Core, that has been hijacked by this
-  SEC that sits on top of an OS application. So the entry and exit of this module 
-  has the same API. 
-
-  This function is the entry point for the PEI Foundation, which allows the SEC phase
-  to pass information about the stack, temporary RAM and the Boot Firmware Volume.
-  In addition, it also allows the SEC phase to pass services and data forward for use
-  during the PEI phase in the form of one or more PPIs.
-  There is no limit to the number of additional PPIs that can be passed from SEC into
-  the PEI Foundation. As part of its initialization phase, the PEI Foundation will add
-  these SEC-hosted PPIs to its PPI database such that both the PEI Foundation and any
-  modules can leverage the associated service calls and/or code in these early PPIs.
-  This function is required to call ProcessModuleEntryPointList() with the Context
-  parameter set to NULL.  ProcessModuleEntryPoint() is never expected to return.
-  The PEI Core is responsible for calling ProcessLibraryConstructorList() as soon as
-  the PEI Services Table and the file handle for the PEI Core itself have been established.
-  If ProcessModuleEntryPointList() returns, then ASSERT() and halt the system.
-
-  @param SecCoreData  Points to a data structure containing information about the PEI
-                      core's operating environment, such as the size and location of
-                      temporary RAM, the stack location and the BFV location. 
-
-  @param PpiList      Points to a list of one or more PPI descriptors to be installed
-                      initially by the PEI core. An empty PPI list consists of a single
-                      descriptor with the end-tag EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST.
-                      As part of its initialization phase, the PEI Foundation will add
-                      these SEC-hosted PPIs to its PPI database such that both the PEI
-                      Foundation and any modules can leverage the associated service calls
-                      and/or code in these early PPIs.
-
-**/
-VOID 
-EFIAPI
-_ModuleEntryPoint (
-  IN EFI_SEC_PEI_HAND_OFF   *SecCoreData,
-  IN EFI_PEI_PPI_DESCRIPTOR *PpiList 
-  )
-{
-  EFI_STATUS                Status;
-  EFI_PEI_FV_HANDLE         VolumeHandle;
-  EFI_PEI_FILE_HANDLE       FileHandle;
-  VOID                      *PeCoffImage;
-  EFI_PEI_CORE_ENTRY_POINT  EntryPoint;
-  EFI_PEI_PPI_DESCRIPTOR    *Ppi;
-  EFI_PEI_PPI_DESCRIPTOR    *SecPpiList;
-  UINTN                     SecReseveredMemorySize;
-  UINTN                     Index;
-  
-  EMU_MAGIC_PAGE()->PpiList = PpiList;
-  ProcessLibraryConstructorList ();
-  
-  DEBUG ((EFI_D_ERROR, "SEC Has Started\n"));
-  
-  //
-  // Add Our PPIs to the list
-  //
-  SecReseveredMemorySize = sizeof (gPrivateDispatchTable);
-  for (Ppi = PpiList, Index = 1; ; Ppi++, Index++) {
-    SecReseveredMemorySize += sizeof (EFI_PEI_PPI_DESCRIPTOR);
-  
-    if ((Ppi->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {
-      // Since we are appending, need to clear out privious list terminator.
-      Ppi->Flags &= ~EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST; 
-      break;
-    }
-  }
-  
-  // Keep everything on a good alignment
-  SecReseveredMemorySize = ALIGN_VALUE (SecReseveredMemorySize, CPU_STACK_ALIGNMENT);
-  
-#if 0
-  // Tell the PEI Core to not use our buffer in temp RAM
-  SecPpiList = (EFI_PEI_PPI_DESCRIPTOR *)SecCoreData->PeiTemporaryRamBase;
-  SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + SecReseveredMemorySize);
-  SecCoreData->PeiTemporaryRamSize -= SecReseveredMemorySize;
-#else
-  {
-    //
-    // When I subtrack from SecCoreData->PeiTemporaryRamBase PEI Core crashes? Either there is a bug
-    // or I don't understand temp RAM correctly?
-    //
-    EFI_PEI_PPI_DESCRIPTOR    PpiArray[10];
-    
-    SecPpiList = &PpiArray[0];
-    ASSERT (sizeof (PpiArray) >= SecReseveredMemorySize);
-  }
-#endif
-  // Copy existing list, and append our entries. 
-  CopyMem (SecPpiList, PpiList, sizeof (EFI_PEI_PPI_DESCRIPTOR) * Index);
-  CopyMem (&SecPpiList[Index], gPrivateDispatchTable, sizeof (gPrivateDispatchTable));
-
-  // Find PEI Core and transfer control
-  VolumeHandle = (EFI_PEI_FV_HANDLE)(UINTN)SecCoreData->BootFirmwareVolumeBase;
-  FileHandle   = NULL;
-  Status = PeiServicesFfsFindNextFile (EFI_FV_FILETYPE_PEI_CORE, VolumeHandle, &FileHandle);
-  ASSERT_EFI_ERROR (Status);
-  
-  Status = PeiServicesFfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffImage);
-  ASSERT_EFI_ERROR (Status);
-
-  Status = PeCoffLoaderGetEntryPoint (PeCoffImage, (VOID **)&EntryPoint);
-  ASSERT_EFI_ERROR (Status);
-  
-  // Transfer control to PEI Core
-  EntryPoint (SecCoreData, SecPpiList);
-  
-  // PEI Core never returns
-  ASSERT (FALSE);
-  return;
-}
-
-
-
diff --git a/InOsEmuPkg/Sec/Sec.h b/InOsEmuPkg/Sec/Sec.h
deleted file mode 100644 (file)
index 0076012..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*++ @file
-  Stub SEC that is called from the OS appliation that is the root of the emulator.
-  
-  The OS application will call the SEC with the PEI Entry Point API.  
-
-Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
-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 __SEC_H___
-#define __SEC_H___
-
-
-#include <PiPei.h>
-#include <Library/EmuMagicPageLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PeiServicesLib.h>
-#include <Library/PeCoffGetEntryPointLib.h>
-#include <Library/BaseMemoryLib.h>
-
-#include <Ppi/TemporaryRamSupport.h>
-
-
-//
-// I think this shold be defined in a MdePkg include file?
-//
-VOID
-EFIAPI
-ProcessLibraryConstructorList (
-  VOID
-  );
-
-EFI_STATUS
-EFIAPI
-SecTemporaryRamSupport (
-  IN CONST EFI_PEI_SERVICES   **PeiServices,
-  IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,
-  IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,
-  IN UINTN                    CopySize
-  );
-
-
-#endif
-
diff --git a/InOsEmuPkg/Sec/Sec.inf b/InOsEmuPkg/Sec/Sec.inf
deleted file mode 100644 (file)
index 8b9d604..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-## @file\r
-# Entry Point of Emu Emulator\r
-#\r
-# Main executable file of Unix Emulator that loads PEI core after initialization finished.\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuSec\r
-  FILE_GUID                      = BCAF98C9-22B0-3B4F-9CBD-C8A6B4DBCEE9\r
-  MODULE_TYPE                    = SEC\r
-  VERSION_STRING                 = 1.0\r
-\r
-\r
-[Sources]\r
-  Sec.c\r
-\r
-[Sources.X64]\r
-  X64/SwitchRam.S\r
-\r
-[Sources.IA32]\r
-  Ia32/TempRam.c\r
-  Ia32/SwitchRam.S\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  DebugLib\r
-  PeCoffGetEntryPointLib\r
-  PeiServicesLib\r
-  PpiListLib\r
-  BaseMemoryLib\r
-\r
-[Ppis]\r
-  gEfiTemporaryRamSupportPpiGuid\r
-  \r
-[Pcd]\r
-  gInOsEmuPkgTokenSpaceGuid.PcdPeiServicesTablePage\r
diff --git a/InOsEmuPkg/Sec/X64/SwitchRam.S b/InOsEmuPkg/Sec/X64/SwitchRam.S
deleted file mode 100644 (file)
index a7219bf..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#------------------------------------------------------------------------------\r
-#\r
-# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-# Portitions copyright (c) 2011, Apple Inc. All rights reserved.\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution.  The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php.\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#------------------------------------------------------------------------------\r
-\r
-\r
-\r
-//  EFI_STATUS\r
-//  EFIAPI\r
-//  SecTemporaryRamSupport (\r
-//    IN CONST EFI_PEI_SERVICES   **PeiServices,         // %rcx\r
-//    IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,   // %rdx\r
-//    IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,   // %r8 \r
-//    IN UINTN                    CopySize               // %r9\r
-//    )\r
-//\r
-ASM_GLOBAL ASM_PFX(SecTemporaryRamSupport)\r
-ASM_PFX(SecTemporaryRamSupport):\r
-  // Adjust callers %rbp to account for stack move\r
-  subq    %rdx, %rbp     // Calc offset of %rbp in Temp Memory\r
-  addq    %r8,  %rbp     // add in permanent base to offset\r
-  \r
-  pushq   %rbp           // stack frame is for the debugger\r
-  movq    %rsp, %rbp\r
-\r
-  pushq   %rdx          // Save TemporaryMemoryBase\r
-  pushq   %r8           // Save PermanentMemoryBase\r
-  pushq   %r9           // Save CopySize\r
-\r
-  //\r
-  // Copy all of temp RAM to permanent memory, including stack\r
-  //\r
-  // CopyMem (PermanentMemoryBase, TemporaryMemoryBase, CopySize);\r
-  //          %rcx,                %rdx,                %r8\r
-  movq    %r8,  %rcx    // Shift arguments\r
-  movq    %r9,  %r8\r
-  subq    $0x28, %rsp   // Allocate register spill area & 16-byte align stack\r
-  call    ASM_PFX(CopyMem)\r
-  // Temp mem stack now copied to permanent location. %esp still in temp memory\r
-  addq    $0x28, %rsp\r
-\r
-  popq    %r9           // CopySize (old stack)\r
-  popq    %r8           // PermanentMemoryBase (old stack)\r
-  popq    %rdx          // TemporaryMemoryBase (old stack)\r
-    \r
-  movq    %rsp, %rcx    // Move to new stack\r
-  subq    %rdx, %rcx    // Calc offset of stack in Temp Memory\r
-  addq    %r8,  %rcx    // Calc PermanentMemoryBase address\r
-  movq    %rcx, %rsp    // Update stack \r
-  // Stack now points to permanent memory\r
-  \r
-  // ZeroMem (TemporaryMemoryBase /* rcx */, CopySize /* rdx */);\r
-  movq    %rdx, %rcx\r
-  movq    %r9,  %rdx\r
-  subq    $0x28, %rsp   // Allocate register spill area & 16-byte align stack\r
-  call    ASM_PFX(ZeroMem)\r
-  addq    $0x28, %rsp\r
-\r
-  // This data comes off the NEW stack\r
-  popq    %rbp\r
-  ret\r
-\r
-\r
diff --git a/InOsEmuPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.c b/InOsEmuPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.c
deleted file mode 100644 (file)
index b2b7801..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*++ @file\r
-  UEFI/PI PEIM to abstract construction of firmware volume in a Unix environment.\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#include <PiPei.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/PeimEntryPoint.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/PeiServicesTablePointerLib.h>\r
-\r
-#include <Ppi/EmuThunk.h>\r
-#include <Protocol/EmuThunk.h>\r
-\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-PeiInitialzeThunkPpiToProtocolPei (\r
-  IN       EFI_PEI_FILE_HANDLE       FileHandle,\r
-  IN CONST EFI_PEI_SERVICES          **PeiServices\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Perform a call-back into the SEC simulator to get Unix Stuff\r
-\r
-Arguments:\r
-\r
-  PeiServices - General purpose services available to every PEIM.\r
-    \r
-Returns:\r
-\r
-  None\r
-\r
-**/\r
-{\r
-  EFI_STATUS              Status;\r
-  EFI_PEI_PPI_DESCRIPTOR  *PpiDescriptor;\r
-  EMU_THUNK_PPI           *Thunk;\r
-  VOID                    *Ptr;\r
-\r
-  DEBUG ((EFI_D_ERROR, "Emu Thunk PEIM Loaded\n"));\r
-\r
-  Status = PeiServicesLocatePpi (\r
-              &gEmuThunkPpiGuid,        // GUID\r
-              0,                        // INSTANCE\r
-              &PpiDescriptor,           // EFI_PEI_PPI_DESCRIPTOR\r
-              (VOID **)&Thunk           // PPI\r
-              );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Ptr = Thunk->Thunk ();\r
-\r
-  BuildGuidDataHob (\r
-    &gEmuThunkProtocolGuid,              // Guid\r
-    &Ptr,                                // Buffer\r
-    sizeof (VOID *)                      // Sizeof Buffer\r
-    );\r
-  return Status;\r
-}\r
diff --git a/InOsEmuPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.inf b/InOsEmuPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.inf
deleted file mode 100644 (file)
index 470568f..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-## @file\r
-# Stuff driver\r
-#\r
-# Tiano PEIM to abstract construction of firmware volume in a Emu environment.\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = ThunkPpiToProtocolPei\r
-  FILE_GUID                      = C32A66D5-D8B7-2640-B768-082C8F083C37\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = PeiInitialzeThunkPpiToProtocolPei\r
-\r
-\r
-[Sources]\r
-  ThunkPpiToProtocolPei.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  PeiServicesTablePointerLib\r
-  PeiServicesLib\r
-  HobLib\r
-  PeimEntryPoint\r
-  DebugLib\r
-\r
-\r
-[Protocols]\r
-  gEmuThunkProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED\r
-\r
-\r
-[Ppis]\r
-  gEmuThunkPpiGuid                          # PPI ALWAYS_CONSUMED\r
-\r
-\r
-[Depex]\r
-  gEmuThunkPpiGuid AND gEfiPeiMemoryDiscoveredPpiGuid\r
-\r
diff --git a/InOsEmuPkg/TimerDxe/Timer.c b/InOsEmuPkg/TimerDxe/Timer.c
deleted file mode 100644 (file)
index d19ced7..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-/*++ @file\r
-  Emu Emulation Timer Architectural Protocol Driver as defined in DXE CIS\r
-\r
-  This Timer module uses an Emu Thread to simulate the timer-tick driven\r
-  timer service.  In the future, the Thread creation should possibly be\r
-  abstracted by the CPU architectural protocol\r
-\r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-**/\r
-\r
-#include "PiDxe.h"\r
-#include <Protocol/Timer.h>\r
-#include <Protocol/Cpu.h>\r
-#include "Timer.h"\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/EmuThunkLib.h>\r
-\r
-//\r
-// Pointer to the CPU Architectural Protocol instance\r
-//\r
-EFI_CPU_ARCH_PROTOCOL   *mCpu;\r
-\r
-//\r
-// The Timer Architectural Protocol that this driver produces\r
-//\r
-EFI_TIMER_ARCH_PROTOCOL mTimer = {\r
-  EmuTimerDriverRegisterHandler,\r
-  EmuTimerDriverSetTimerPeriod,\r
-  EmuTimerDriverGetTimerPeriod,\r
-  EmuTimerDriverGenerateSoftInterrupt\r
-};\r
-\r
-//\r
-// The notification function to call on every timer interrupt\r
-//\r
-EFI_TIMER_NOTIFY        mTimerNotifyFunction = NULL;\r
-\r
-//\r
-// The current period of the timer interrupt\r
-//\r
-UINT64                  mTimerPeriodMs;\r
-\r
-\r
-VOID\r
-EFIAPI\r
-TimerCallback (UINT64 DeltaMs)\r
-{\r
-  EFI_TPL           OriginalTPL;\r
-  EFI_TIMER_NOTIFY  CallbackFunction;\r
-\r
-\r
-  OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
-\r
-  if (OriginalTPL < TPL_HIGH_LEVEL) {\r
-    CallbackFunction = mTimerNotifyFunction;\r
-\r
-    //\r
-    // Only invoke the callback function if a Non-NULL handler has been\r
-    // registered. Assume all other handlers are legal.\r
-    //\r
-    if (CallbackFunction != NULL) {\r
-      CallbackFunction ((UINT64) (DeltaMs * 10000));\r
-    }\r
-  }\r
-\r
-  gBS->RestoreTPL (OriginalTPL);\r
-\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuTimerDriverRegisterHandler (\r
-  IN EFI_TIMER_ARCH_PROTOCOL           *This,\r
-  IN EFI_TIMER_NOTIFY                  NotifyFunction\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function registers the handler NotifyFunction so it is called every time\r
-  the timer interrupt fires.  It also passes the amount of time since the last\r
-  handler call to the NotifyFunction.  If NotifyFunction is NULL, then the\r
-  handler is unregistered.  If the handler is registered, then EFI_SUCCESS is\r
-  returned.  If the CPU does not support registering a timer interrupt handler,\r
-  then EFI_UNSUPPORTED is returned.  If an attempt is made to register a handler\r
-  when a handler is already registered, then EFI_ALREADY_STARTED is returned.\r
-  If an attempt is made to unregister a handler when a handler is not registered,\r
-  then EFI_INVALID_PARAMETER is returned.  If an error occurs attempting to\r
-  register the NotifyFunction with the timer interrupt, then EFI_DEVICE_ERROR\r
-  is returned.\r
-\r
-Arguments:\r
-\r
-  This           - The EFI_TIMER_ARCH_PROTOCOL instance.\r
-\r
-  NotifyFunction - The function to call when a timer interrupt fires.  This\r
-                   function executes at TPL_HIGH_LEVEL.  The DXE Core will\r
-                   register a handler for the timer interrupt, so it can know\r
-                   how much time has passed.  This information is used to\r
-                   signal timer based events.  NULL will unregister the handler.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The timer handler was registered.\r
-\r
-  EFI_UNSUPPORTED       - The platform does not support timer interrupts.\r
-\r
-  EFI_ALREADY_STARTED   - NotifyFunction is not NULL, and a handler is already\r
-                          registered.\r
-\r
-  EFI_INVALID_PARAMETER - NotifyFunction is NULL, and a handler was not\r
-                          previously registered.\r
-\r
-  EFI_DEVICE_ERROR      - The timer handler could not be registered.\r
-\r
-**/\r
-{\r
-  //\r
-  // Check for invalid parameters\r
-  //\r
-  if (NotifyFunction == NULL && mTimerNotifyFunction == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (NotifyFunction != NULL && mTimerNotifyFunction != NULL) {\r
-    return EFI_ALREADY_STARTED;\r
-  }\r
-\r
-  if (NotifyFunction == NULL) {\r
-    /* Disable timer.  */\r
-    gEmuThunk->SetTimer (0, TimerCallback);\r
-  } else if (mTimerNotifyFunction == NULL) {\r
-    /* Enable Timer.  */\r
-    gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);\r
-  }\r
-  mTimerNotifyFunction = NotifyFunction;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuTimerDriverSetTimerPeriod (\r
-  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
-  IN UINT64                   TimerPeriod\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function adjusts the period of timer interrupts to the value specified\r
-  by TimerPeriod.  If the timer period is updated, then the selected timer\r
-  period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned.  If\r
-  the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.\r
-  If an error occurs while attempting to update the timer period, then the\r
-  timer hardware will be put back in its state prior to this call, and\r
-  EFI_DEVICE_ERROR is returned.  If TimerPeriod is 0, then the timer interrupt\r
-  is disabled.  This is not the same as disabling the CPU's interrupts.\r
-  Instead, it must either turn off the timer hardware, or it must adjust the\r
-  interrupt controller so that a CPU interrupt is not generated when the timer\r
-  interrupt fires.\r
-\r
-Arguments:\r
-\r
-  This        - The EFI_TIMER_ARCH_PROTOCOL instance.\r
-\r
-  TimerPeriod - The rate to program the timer interrupt in 100 nS units.  If\r
-                the timer hardware is not programmable, then EFI_UNSUPPORTED is\r
-                returned.  If the timer is programmable, then the timer period\r
-                will be rounded up to the nearest timer period that is supported\r
-                by the timer hardware.  If TimerPeriod is set to 0, then the\r
-                timer interrupts will be disabled.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS      - The timer period was changed.\r
-\r
-  EFI_UNSUPPORTED  - The platform cannot change the period of the timer interrupt.\r
-\r
-  EFI_DEVICE_ERROR - The timer period could not be changed due to a device error.\r
-\r
-**/\r
-{\r
-\r
-  //\r
-  // If TimerPeriod is 0, then the timer thread should be canceled\r
-  // If the TimerPeriod is valid, then create and/or adjust the period of the timer thread\r
-  //\r
-  if (TimerPeriod == 0\r
-      || ((TimerPeriod > TIMER_MINIMUM_VALUE)\r
-    && (TimerPeriod < TIMER_MAXIMUM_VALUE))) {\r
-    mTimerPeriodMs = DivU64x32 (TimerPeriod + 5000, 10000);\r
-\r
-    gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuTimerDriverGetTimerPeriod (\r
-  IN EFI_TIMER_ARCH_PROTOCOL            *This,\r
-  OUT UINT64                            *TimerPeriod\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function retrieves the period of timer interrupts in 100 ns units,\r
-  returns that value in TimerPeriod, and returns EFI_SUCCESS.  If TimerPeriod\r
-  is NULL, then EFI_INVALID_PARAMETER is returned.  If a TimerPeriod of 0 is\r
-  returned, then the timer is currently disabled.\r
-\r
-Arguments:\r
-\r
-  This        - The EFI_TIMER_ARCH_PROTOCOL instance.\r
-\r
-  TimerPeriod - A pointer to the timer period to retrieve in 100 ns units.  If\r
-                0 is returned, then the timer is currently disabled.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The timer period was returned in TimerPeriod.\r
-\r
-  EFI_INVALID_PARAMETER - TimerPeriod is NULL.\r
-\r
-**/\r
-{\r
-  if (TimerPeriod == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *TimerPeriod = mTimerPeriodMs * 10000;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuTimerDriverGenerateSoftInterrupt (\r
-  IN EFI_TIMER_ARCH_PROTOCOL  *This\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This function generates a soft timer interrupt. If the platform does not support soft\r
-  timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned.\r
-  If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler()\r
-  service, then a soft timer interrupt will be generated. If the timer interrupt is\r
-  enabled when this service is called, then the registered handler will be invoked. The\r
-  registered handler should not be able to distinguish a hardware-generated timer\r
-  interrupt from a software-generated timer interrupt.\r
-\r
-Arguments:\r
-\r
-  This  -  The EFI_TIMER_ARCH_PROTOCOL instance.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS       - The soft timer interrupt was generated.\r
-\r
-  EFI_UNSUPPORTEDT  - The platform does not support the generation of soft timer interrupts.\r
-\r
-**/\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuTimerDriverInitialize (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Initialize the Timer Architectural Protocol driver\r
-\r
-Arguments:\r
-\r
-  ImageHandle - ImageHandle of the loaded driver\r
-\r
-  SystemTable - Pointer to the System Table\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Timer Architectural Protocol created\r
-\r
-  EFI_OUT_OF_RESOURCES  - Not enough resources available to initialize driver.\r
-\r
-  EFI_DEVICE_ERROR      - A device error occured attempting to initialize the driver.\r
-\r
-**/\r
-{\r
-  EFI_STATUS  Status;\r
-  EFI_HANDLE  Handle;\r
-\r
-  //\r
-  // Make sure the Timer Architectural Protocol is not already installed in the system\r
-  //\r
-  ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiTimerArchProtocolGuid);\r
-\r
-  //\r
-  // Get the CPU Architectural Protocol instance\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (void *)&mCpu);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Start the timer thread at the default timer period\r
-  //\r
-  Status = mTimer.SetTimerPeriod (&mTimer, DEFAULT_TIMER_TICK_DURATION);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Install the Timer Architectural Protocol onto a new handle\r
-  //\r
-  Handle = NULL;\r
-  Status = gBS->InstallProtocolInterface (\r
-                  &Handle,\r
-                  &gEfiTimerArchProtocolGuid,\r
-                  EFI_NATIVE_INTERFACE,\r
-                  &mTimer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/InOsEmuPkg/TimerDxe/Timer.h b/InOsEmuPkg/TimerDxe/Timer.h
deleted file mode 100644 (file)
index 27fc676..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*++ @file\r
-  Emu Emulation Architectural Protocol Driver as defined in UEFI/PI.\r
-  This Timer module uses an UNIX Thread to simulate the timer-tick driven\r
-  timer service.\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-\r
-**/\r
-\r
-#ifndef _TIMER_H_\r
-#define _TIMER_H_\r
-\r
-\r
-\r
-\r
-//\r
-// Legal timer value range in 100 ns units\r
-//\r
-#define TIMER_MINIMUM_VALUE 0\r
-#define TIMER_MAXIMUM_VALUE (0x100000000ULL - 1)\r
-\r
-//\r
-// Default timer value in 100 ns units (50 ms)\r
-//\r
-#define DEFAULT_TIMER_TICK_DURATION 500000\r
-\r
-//\r
-// Function Prototypes\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-EmuTimerDriverInitialize (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuTimerDriverRegisterHandler (\r
-  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
-  IN EFI_TIMER_NOTIFY         NotifyFunction\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuTimerDriverSetTimerPeriod (\r
-  IN EFI_TIMER_ARCH_PROTOCOL  *This,\r
-  IN UINT64                   TimerPeriod\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuTimerDriverGetTimerPeriod (\r
-  IN EFI_TIMER_ARCH_PROTOCOL   *This,\r
-  OUT UINT64                   *TimerPeriod\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-EmuTimerDriverGenerateSoftInterrupt (\r
-  IN EFI_TIMER_ARCH_PROTOCOL  *This\r
-  );\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/TimerDxe/Timer.inf b/InOsEmuPkg/TimerDxe/Timer.inf
deleted file mode 100644 (file)
index 9282fae..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-## @file\r
-# Emu Emulation Timer Architectural Protocol Driver as defined in DXE CIS\r
-#\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EmuTimer\r
-  FILE_GUID                      = 87E1BB14-4D5C-7C4E-A90E-E1415687D062\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = EmuTimerDriverInitialize\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  Timer.c\r
-  Timer.h\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  EmuThunkLib\r
-  UefiDriverEntryPoint\r
-  UefiLib\r
-  DebugLib\r
-  BaseLib\r
-\r
-\r
-[Protocols]\r
-  gEfiCpuArchProtocolGuid                       # PROTOCOL ALWAYS_CONSUMED\r
-  gEfiTimerArchProtocolGuid                     # PROTOCOL ALWAYS_PRODUCED\r
-\r
-\r
-[Depex]\r
-  gEfiCpuArchProtocolGuid\r
-\r
diff --git a/InOsEmuPkg/Unix/.gdbinit b/InOsEmuPkg/Unix/.gdbinit
deleted file mode 100644 (file)
index 173818c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-set confirm off
-set output-radix 16
-b SecGdbScriptBreak
-command
-silent
-source SecMain.gdb
-c
-end
diff --git a/InOsEmuPkg/Unix/GdbRun b/InOsEmuPkg/Unix/GdbRun
deleted file mode 100644 (file)
index 428e655..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-## @file
-# GDB startup script
-#
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-##
-
-#
-# Gdb will set $_exitcode when the program exits.  Pre-init it to an unlikely
-# return value.
-#
-set $_exitcode = 42
-
-#
-# Gdb will call hook-stop on each break.  Check to see if $_exitcode was
-# changed from the value we pre-initialized it to.  If so, the program
-# had exited, so gdb should now quit.
-#
-define hook-stop
-  if $_exitcode != 42
-    quit
-  else
-    source SecMain.gdb
-  end
-end
-
-#
-# We keep track of the number of symbol files we have loaded via gdb
-# scripts in the $SymbolFilesAdded variable
-#
-set $SymbolFileChangesCount = 0
-
-#
-# This macro adds a symbols file for gdb
-#
-# @param  $arg0 - Symbol file changes number
-# @param  $arg1 - Symbol file name
-# @param  $arg2 - Image address
-#
-define AddFirmwareSymbolFile
-  if $SymbolFileChangesCount < $arg0
-    add-symbol-file $arg1 $arg2
-    set $SymbolFileChangesCount = $arg0
-  end
-end
-
-#
-# This macro removes a symbols file for gdb
-#
-# @param  $arg0 - Symbol file changes number
-# @param  $arg1 - Symbol file name
-#
-define RemoveFirmwareSymbolFile
-  if $SymbolFileChangesCount < $arg0
-    #
-    # Currently there is not a method to remove a single symbol file
-    #
-    set $SymbolFileChangesCount = $arg0
-  end
-end
-
-if gInXcode == 1
-  # in Xcode the program is already runing. Issuing a run command 
-  # will cause a fatal debugger error. The break point sciprt that
-  # is used to source this script sets gInCode to 1. 
-else
-  #
-  # Start the program running
-  #
-  run
-end
diff --git a/InOsEmuPkg/Unix/Sec/BerkeleyPacketFilter.c b/InOsEmuPkg/Unix/Sec/BerkeleyPacketFilter.c
deleted file mode 100644 (file)
index 519d394..0000000
+++ /dev/null
@@ -1,1111 +0,0 @@
-/**@file\r
- Berkeley Packet Filter implementation of the EMU_SNP_PROTOCOL that allows the \r
- emulator to get on real networks.\r
-\r
- Tested on Mac OS X. \r
-\r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portitions copyright (c) 2011, Apple Inc. All rights reserved.\r
-\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-\r
-#include "SecMain.h"\r
-\r
-#ifdef __APPLE__\r
-\r
-\r
-#include <Library/NetLib.h>\r
-\r
-\r
-#define EMU_SNP_PRIVATE_SIGNATURE SIGNATURE_32('E', 'M', 's', 'n')\r
-typedef struct {\r
-  UINTN                       Signature;\r
-\r
-  EMU_IO_THUNK_PROTOCOL       *Thunk;\r
-  EMU_SNP_PROTOCOL            EmuSnp;\r
-  EFI_SIMPLE_NETWORK_MODE     *Mode;\r
-\r
-  int                         BpfFd;\r
-  char                        *InterfaceName;\r
-  EFI_MAC_ADDRESS             MacAddress;\r
-  u_int                       ReadBufferSize;\r
-  VOID                        *ReadBuffer;\r
-\r
-  //\r
-  // Two walking pointers to manage the multiple packets that can be returned\r
-  // in a single read.\r
-  //\r
-  VOID                        *CurrentReadPointer;\r
-  VOID                        *EndReadPointer;\r
-\r
-       UINT32                                                                      ReceivedPackets;\r
-       UINT32                                                                      DroppedPackets;\r
-\r
-} EMU_SNP_PRIVATE;\r
-\r
-#define EMU_SNP_PRIVATE_DATA_FROM_THIS(a) \\r
-         CR(a, EMU_SNP_PRIVATE, EmuSnp, EMU_SNP_PRIVATE_SIGNATURE)\r
-\r
-\r
-//\r
-// Strange, but there doesn't appear to be any structure for the Ethernet header in edk2...\r
-//\r
-\r
-typedef struct {\r
-  UINT8   DstAddr[NET_ETHER_ADDR_LEN];\r
-  UINT8   SrcAddr[NET_ETHER_ADDR_LEN];\r
-  UINT16  Type;\r
-} ETHERNET_HEADER;\r
-\r
-/**\r
-  Register storage for SNP Mode.\r
-\r
-  @param  This Protocol instance pointer.\r
-  @param  Mode SimpleNetworkProtocol Mode structure passed into driver.\r
-\r
-  @retval EFI_SUCCESS           The network interface was started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpCreateMapping (\r
-  IN     EMU_SNP_PROTOCOL         *This,\r
-  IN     EFI_SIMPLE_NETWORK_MODE  *Mode\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Private->Mode = Mode;\r
-  \r
-  //\r
-  // Set the broadcast address.\r
-  //\r
-  SetMem (&Mode->BroadcastAddress, sizeof (EFI_MAC_ADDRESS), 0xFF);\r
-\r
-  CopyMem (&Mode->CurrentAddress, &Private->MacAddress, sizeof (EFI_MAC_ADDRESS));\r
-  CopyMem (&Mode->PermanentAddress, &Private->MacAddress, sizeof (EFI_MAC_ADDRESS));\r
-\r
-  //\r
-  // Since the fake SNP is based on a real NIC, to avoid conflict with the host NIC\r
-  // network stack, we use a different MAC address.\r
-  // So just change the last byte of the MAC address for the real NIC.\r
-  //\r
-  Mode->CurrentAddress.Addr[NET_ETHER_ADDR_LEN - 1]++;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-static struct bpf_insn mFilterInstructionTemplate[] = {\r
-  // Load 4 bytes from the destination MAC address.\r
-  BPF_STMT (BPF_LD + BPF_W + BPF_ABS, OFFSET_OF (ETHERNET_HEADER, DstAddr[0])),\r
-\r
-  // Compare to first 4 bytes of fake MAC address.\r
-  BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0x12345678, 0, 3 ),\r
-\r
-  // Load remaining 2 bytes from the destination MAC address.\r
-  BPF_STMT (BPF_LD + BPF_H + BPF_ABS, OFFSET_OF( ETHERNET_HEADER, DstAddr[4])),\r
-\r
-  // Compare to remaining 2 bytes of fake MAC address.\r
-  BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0x9ABC, 5, 0 ),\r
-\r
-  // Load 4 bytes from the destination MAC address.\r
-  BPF_STMT (BPF_LD + BPF_W + BPF_ABS, OFFSET_OF (ETHERNET_HEADER, DstAddr[0])),\r
-\r
-  // Compare to first 4 bytes of broadcast MAC address.\r
-  BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0xFFFFFFFF, 0, 2),\r
-\r
-  // Load remaining 2 bytes from the destination MAC address.\r
-  BPF_STMT (BPF_LD + BPF_H + BPF_ABS, OFFSET_OF( ETHERNET_HEADER, DstAddr[4])),\r
-\r
-  // Compare to remaining 2 bytes of broadcast MAC address.\r
-  BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0xFFFF, 1, 0),\r
-\r
-  // Reject packet.\r
-  BPF_STMT (BPF_RET + BPF_K, 0),\r
-\r
-  // Receive entire packet.\r
-  BPF_STMT (BPF_RET + BPF_K, -1)\r
-};\r
-\r
-\r
-EFI_STATUS\r
-OpenBpfFileDescriptor (\r
-  IN EMU_SNP_PRIVATE  *Private,\r
-  OUT int             *Fd\r
-  )\r
-{\r
-  char  BfpDeviceName[256];\r
-  int   Index;\r
-\r
-  //\r
-  // Open a Berkeley Packet Filter device.  This must be done as root, so this is probably\r
-  // the place which is most likely to fail...\r
-  //\r
-  for (Index = 0; TRUE; Index++ ) {\r
-    snprintf (BfpDeviceName, sizeof (BfpDeviceName), "/dev/bpf%d", Index);\r
-\r
-    *Fd = open (BfpDeviceName, O_RDWR, 0);\r
-    if ( *Fd >= 0 ) {\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    if (errno == EACCES) {\r
-      printf (\r
-        "SNP: Permissions on '%s' are incorrect.  Fix with 'sudo chmod 666 %s'.\n",\r
-        BfpDeviceName, \r
-        BfpDeviceName \r
-        );\r
-    }\r
-    \r
-    if (errno != EBUSY) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  return EFI_OUT_OF_RESOURCES;\r
-}\r
-\r
-\r
-/**\r
-  Changes the state of a network interface from "stopped" to "started".\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           The network interface was started.\r
-  @retval EFI_ALREADY_STARTED   The network interface is already in the started state.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpStart (\r
-  IN EMU_SNP_PROTOCOL  *This\r
-  )\r
-{\r
-  EFI_STATUS         Status;\r
-  EMU_SNP_PRIVATE    *Private;\r
-  struct ifreq       BoundIf;\r
-  struct bpf_program BpfProgram;\r
-  struct bpf_insn    *FilterProgram;\r
-       u_int                                                    Value;\r
-       u_int                                            ReadBufferSize;\r
-  UINT16             Temp16;\r
-  UINT32             Temp32;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  switch (Private->Mode->State) {\r
-    case EfiSimpleNetworkStopped:\r
-      break;\r
-\r
-    case EfiSimpleNetworkStarted:\r
-    case EfiSimpleNetworkInitialized:\r
-      return EFI_ALREADY_STARTED;\r
-      break;\r
-\r
-    default:\r
-      return EFI_DEVICE_ERROR;\r
-      break;\r
-  }\r
-\r
-  Status = EFI_SUCCESS;\r
-  if (Private->BpfFd == 0) {\r
-    Status = OpenBpfFileDescriptor (Private, &Private->BpfFd);\r
-    if (EFI_ERROR (Status)) {\r
-      goto DeviceErrorExit;\r
-    }\r
-\r
-    //\r
-               // Get the read buffer size.\r
-               //\r
-               if (ioctl (Private->BpfFd, BIOCGBLEN, &ReadBufferSize) < 0) {\r
-                       goto DeviceErrorExit;\r
-               }\r
-               \r
-               //\r
-               // Default value from BIOCGBLEN is usually too small, so use a much larger size, if necessary.\r
-               //\r
-               if (ReadBufferSize < FixedPcdGet32 (PcdNetworkPacketFilterSize)) {\r
-                       ReadBufferSize = FixedPcdGet32 (PcdNetworkPacketFilterSize);\r
-                       if (ioctl (Private->BpfFd, BIOCSBLEN, &ReadBufferSize) < 0) {\r
-                               goto DeviceErrorExit;\r
-                       }\r
-               }\r
-               \r
-               //\r
-    // Associate our interface with this BPF file descriptor.\r
-    //\r
-    AsciiStrCpy (BoundIf.ifr_name, Private->InterfaceName);\r
-    if (ioctl (Private->BpfFd, BIOCSETIF, &BoundIf) < 0) {\r
-      goto DeviceErrorExit;\r
-    }\r
-\r
-    //\r
-               // Enable immediate mode.\r
-    //\r
-    Value = 1;\r
-    if (ioctl (Private->BpfFd, BIOCIMMEDIATE, &Value) < 0) {\r
-      goto DeviceErrorExit;\r
-    }\r
-\r
-    //\r
-    // Enable non-blocking I/O.\r
-    //\r
-    if (fcntl (Private->BpfFd, F_GETFL, 0) == -1) {\r
-      goto DeviceErrorExit;\r
-    }\r
-\r
-    Value |= O_NONBLOCK;\r
-\r
-    if (fcntl (Private->BpfFd, F_SETFL, Value) == -1) {\r
-      goto DeviceErrorExit;\r
-    }\r
-\r
-    //\r
-    // Disable "header complete" flag.  This means the supplied source MAC address is\r
-    // what goes on the wire.\r
-    //\r
-    Value = 1;\r
-    if (ioctl (Private->BpfFd, BIOCSHDRCMPLT, &Value) < 0) {\r
-      goto DeviceErrorExit;\r
-    }\r
-\r
-    //\r
-    // Allocate read buffer.\r
-    //\r
-               Private->ReadBufferSize = ReadBufferSize;\r
-               Private->ReadBuffer = malloc (Private->ReadBufferSize);\r
-    if (Private->ReadBuffer == NULL) {\r
-      goto ErrorExit;\r
-    }\r
-\r
-    Private->CurrentReadPointer = Private->EndReadPointer = Private->ReadBuffer;\r
-\r
-    //\r
-               // Install our packet filter: successful reads should only produce broadcast or unicast\r
-    // packets directed to our fake MAC address.\r
-    //\r
-    FilterProgram = malloc (sizeof (mFilterInstructionTemplate)) ;\r
-    if ( FilterProgram == NULL ) {\r
-      goto ErrorExit;\r
-    }\r
-    \r
-    CopyMem (FilterProgram, &mFilterInstructionTemplate, sizeof (mFilterInstructionTemplate));\r
-\r
-    //\r
-    // Insert out fake MAC address into the filter.  The data has to be host endian.\r
-    //\r
-    CopyMem (&Temp32, &Private->Mode->CurrentAddress.Addr[0], sizeof (UINT32));\r
-    FilterProgram[1].k = NTOHL (Temp32);\r
-    CopyMem (&Temp16, &Private->Mode->CurrentAddress.Addr[4], sizeof (UINT16));\r
-    FilterProgram[3].k = NTOHS (Temp16);\r
-\r
-    BpfProgram.bf_len = sizeof (mFilterInstructionTemplate) / sizeof (struct bpf_insn);\r
-    BpfProgram.bf_insns = FilterProgram;\r
-\r
-    if (ioctl (Private->BpfFd, BIOCSETF, &BpfProgram) < 0) {\r
-      goto DeviceErrorExit;\r
-    }\r
-\r
-    free (FilterProgram);\r
-\r
-    //\r
-    // Enable promiscuous mode.\r
-    //\r
-    if (ioctl (Private->BpfFd, BIOCPROMISC, 0) < 0) {\r
-      goto DeviceErrorExit;\r
-    }\r
-\r
-\r
-    Private->Mode->State = EfiSimpleNetworkStarted;      \r
-  }\r
-\r
-  return Status;\r
-\r
-DeviceErrorExit:\r
-  Status = EFI_DEVICE_ERROR;\r
-ErrorExit:\r
-  if (Private->ReadBuffer != NULL) {\r
-    free (Private->ReadBuffer);\r
-    Private->ReadBuffer = NULL;\r
-  }\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Changes the state of a network interface from "started" to "stopped".\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           The network interface was stopped.\r
-  @retval EFI_ALREADY_STARTED   The network interface is already in the stopped state.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpStop (\r
-  IN EMU_SNP_PROTOCOL  *This\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  switch ( Private->Mode->State ) {\r
-    case EfiSimpleNetworkStarted:\r
-      break;\r
-\r
-    case EfiSimpleNetworkStopped:\r
-      return EFI_NOT_STARTED;\r
-      break;\r
-\r
-    default:\r
-      return EFI_DEVICE_ERROR;\r
-      break;\r
-  }\r
-\r
-  if (Private->BpfFd != 0) {\r
-    close (Private->BpfFd);\r
-    Private->BpfFd = 0;\r
-  }\r
-\r
-  if (Private->ReadBuffer != NULL) {\r
-    free (Private->ReadBuffer );\r
-    Private->CurrentReadPointer = Private->EndReadPointer = Private->ReadBuffer = NULL;\r
-  }\r
-\r
-  Private->Mode->State = EfiSimpleNetworkStopped;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Resets a network adapter and allocates the transmit and receive buffers \r
-  required by the network interface; optionally, also requests allocation \r
-  of additional transmit and receive buffers.\r
-\r
-  @param  This              The protocol instance pointer.\r
-  @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
-                            that the driver should allocate for the network interface.\r
-                            Some network interfaces will not be able to use the extra\r
-                            buffer, and the caller will not know if it is actually\r
-                            being used.\r
-  @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
-                            that the driver should allocate for the network interface.\r
-                            Some network interfaces will not be able to use the extra\r
-                            buffer, and the caller will not know if it is actually\r
-                            being used.\r
-\r
-  @retval EFI_SUCCESS           The network interface was initialized.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_OUT_OF_RESOURCES  There was not enough memory for the transmit and\r
-                                receive buffers.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpInitialize (\r
-  IN EMU_SNP_PROTOCOL                    *This,\r
-  IN UINTN                               ExtraRxBufferSize  OPTIONAL,\r
-  IN UINTN                               ExtraTxBufferSize  OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  switch ( Private->Mode->State ) {\r
-    case EfiSimpleNetworkStarted:\r
-      break;\r
-\r
-    case EfiSimpleNetworkStopped:\r
-      return EFI_NOT_STARTED;\r
-      break;\r
-\r
-    default:\r
-      return EFI_DEVICE_ERROR;\r
-      break;\r
-  }\r
-\r
-  Private->Mode->MCastFilterCount = 0;\r
-  Private->Mode->ReceiveFilterSetting = 0;\r
-  ZeroMem (Private->Mode->MCastFilter, sizeof (Private->Mode->MCastFilter));\r
-\r
-  Private->Mode->State = EfiSimpleNetworkInitialized;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Resets a network adapter and re-initializes it with the parameters that were \r
-  provided in the previous call to Initialize().  \r
-\r
-  @param  This                 The protocol instance pointer.\r
-  @param  ExtendedVerification Indicates that the driver may perform a more\r
-                               exhaustive verification operation of the device\r
-                               during reset.\r
-\r
-  @retval EFI_SUCCESS           The network interface was reset.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpReset (\r
-  IN EMU_SNP_PROTOCOL   *This,\r
-  IN BOOLEAN            ExtendedVerification\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  switch ( Private->Mode->State ) {\r
-    case EfiSimpleNetworkInitialized:\r
-      break;\r
-\r
-    case EfiSimpleNetworkStopped:\r
-      return EFI_NOT_STARTED;\r
-      break;\r
-\r
-    default:\r
-      return EFI_DEVICE_ERROR;\r
-      break;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Resets a network adapter and leaves it in a state that is safe for \r
-  another driver to initialize.\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           The network interface was shutdown.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpShutdown (\r
-  IN EMU_SNP_PROTOCOL  *This\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  switch ( Private->Mode->State ) {\r
-    case EfiSimpleNetworkInitialized:\r
-      break;\r
-\r
-    case EfiSimpleNetworkStopped:\r
-      return EFI_NOT_STARTED;\r
-      break;\r
-\r
-    default:\r
-      return EFI_DEVICE_ERROR;\r
-      break;\r
-  }\r
-\r
-  Private->Mode->State = EfiSimpleNetworkStarted;\r
-\r
-  Private->Mode->ReceiveFilterSetting = 0;\r
-  Private->Mode->MCastFilterCount = 0;\r
-  ZeroMem (Private->Mode->MCastFilter, sizeof (Private->Mode->MCastFilter));\r
-\r
-  if (Private->BpfFd != 0) {\r
-    close (Private->BpfFd);\r
-    Private->BpfFd = 0;\r
-  }\r
-\r
-  if (Private->ReadBuffer != NULL) {\r
-    free (Private->ReadBuffer);\r
-    Private->CurrentReadPointer = Private->EndReadPointer = Private->ReadBuffer = NULL;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Manages the multicast receive filters of a network interface.\r
-\r
-  @param  This             The protocol instance pointer.\r
-  @param  Enable           A bit mask of receive filters to enable on the network interface.\r
-  @param  Disable          A bit mask of receive filters to disable on the network interface.\r
-  @param  ResetMCastFilter Set to TRUE to reset the contents of the multicast receive\r
-                           filters on the network interface to their default values.\r
-  @param  McastFilterCnt   Number of multicast HW MAC addresses in the new\r
-                           MCastFilter list. This value must be less than or equal to\r
-                           the MCastFilterCnt field of EMU_SNP_MODE. This\r
-                           field is optional if ResetMCastFilter is TRUE.\r
-  @param  MCastFilter      A pointer to a list of new multicast receive filter HW MAC\r
-                           addresses. This list will replace any existing multicast\r
-                           HW MAC address list. This field is optional if\r
-                           ResetMCastFilter is TRUE.\r
-\r
-  @retval EFI_SUCCESS           The multicast receive filter list was updated.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpReceiveFilters (\r
-  IN EMU_SNP_PROTOCOL                             *This,\r
-  IN UINT32                                       Enable,\r
-  IN UINT32                                       Disable,\r
-  IN BOOLEAN                                      ResetMCastFilter,\r
-  IN UINTN                                        MCastFilterCnt     OPTIONAL,\r
-  IN EFI_MAC_ADDRESS                              *MCastFilter OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  // For now, just succeed...\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Modifies or resets the current station address, if supported.\r
-\r
-  @param  This  The protocol instance pointer.\r
-  @param  Reset Flag used to reset the station address to the network interfaces\r
-                permanent address.\r
-  @param  New   The new station address to be used for the network interface.\r
-\r
-  @retval EFI_SUCCESS           The network interfaces station address was updated.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpStationAddress (\r
-  IN EMU_SNP_PROTOCOL            *This,\r
-  IN BOOLEAN                     Reset,\r
-  IN EFI_MAC_ADDRESS             *New OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-\r
-/**\r
-  Resets or collects the statistics on a network interface.\r
-\r
-  @param  This            Protocol instance pointer.\r
-  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
-  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
-                          output the size, in bytes, of the resulting table of\r
-                          statistics.\r
-  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
-                          contains the statistics.\r
-\r
-  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
-                                size needed to hold the statistics is returned in\r
-                                StatisticsSize.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpStatistics (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN BOOLEAN                              Reset,\r
-  IN OUT UINTN                            *StatisticsSize   OPTIONAL,\r
-  OUT EFI_NETWORK_STATISTICS              *StatisticsTable  OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-\r
-/**\r
-  Converts a multicast IP address to a multicast HW MAC address.\r
-\r
-  @param  This The protocol instance pointer.\r
-  @param  IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
-               to FALSE if the multicast IP address is IPv4 [RFC 791].\r
-  @param  IP   The multicast IP address that is to be converted to a multicast\r
-               HW MAC address.\r
-  @param  MAC  The multicast HW MAC address that is to be generated from IP.\r
-\r
-  @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast\r
-                                HW MAC address.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
-                                size needed to hold the statistics is returned in\r
-                                StatisticsSize.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpMCastIpToMac (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN BOOLEAN                              IPv6,\r
-  IN EFI_IP_ADDRESS                       *IP,\r
-  OUT EFI_MAC_ADDRESS                     *MAC\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-\r
-/**\r
-  Performs read and write operations on the NVRAM device attached to a \r
-  network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  ReadWrite  TRUE for read operations, FALSE for write operations.\r
-  @param  Offset     Byte offset in the NVRAM device at which to start the read or\r
-                     write operation. This must be a multiple of NvRamAccessSize and\r
-                     less than NvRamSize.\r
-  @param  BufferSize The number of bytes to read or write from the NVRAM device.\r
-                     This must also be a multiple of NvramAccessSize.\r
-  @param  Buffer     A pointer to the data buffer.\r
-\r
-  @retval EFI_SUCCESS           The NVRAM access was performed.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpNvData (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN BOOLEAN                              ReadWrite,\r
-  IN UINTN                                Offset,\r
-  IN UINTN                                BufferSize,\r
-  IN OUT VOID                             *Buffer\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Reads the current interrupt status and recycled transmit buffer status from \r
-  a network interface.\r
-\r
-  @param  This            The protocol instance pointer.\r
-  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
-                          If this is NULL, the interrupt status will not be read from\r
-                          the device. If this is not NULL, the interrupt status will\r
-                          be read from the device. When the  interrupt status is read,\r
-                          it will also be cleared. Clearing the transmit  interrupt\r
-                          does not empty the recycled transmit buffer array.\r
-  @param  TxBuf           Recycled transmit buffer address. The network interface will\r
-                          not transmit if its internal recycled transmit buffer array\r
-                          is full. Reading the transmit buffer does not clear the\r
-                          transmit interrupt. If this is NULL, then the transmit buffer\r
-                          status will not be read. If there are no transmit buffers to\r
-                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
-\r
-  @retval EFI_SUCCESS           The status of the network interface was retrieved.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpGetStatus (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  OUT UINT32                              *InterruptStatus OPTIONAL,\r
-  OUT VOID                                **TxBuf OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  if (TxBuf != NULL) {\r
-    *((UINT8 **)TxBuf) =  (UINT8 *)1;\r
-  }\r
-\r
-  if ( InterruptStatus != NULL ) {\r
-    *InterruptStatus = EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Places a packet in the transmit queue of a network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
-                     the Transmit() function. If HeaderSize is non-zero, then it\r
-                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
-                     and Protocol parameters must not be NULL.\r
-  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
-                     data) to be transmitted through the network interface.\r
-  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
-                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
-                     then the media header in Buffer must already be filled in by the\r
-                     caller. If HeaderSize is non-zero, then the media header will be\r
-                     filled in by the Transmit() function.\r
-  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
-                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
-                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
-  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
-                     parameter is ignored.\r
-  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
-                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
-                     examples.\r
-\r
-  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_NOT_READY         The network interface is too busy to accept this transmit request.                      \r
-  @retval EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpTransmit (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN UINTN                                HeaderSize,\r
-  IN UINTN                                BufferSize,\r
-  IN VOID                                 *Buffer,\r
-  IN EFI_MAC_ADDRESS                      *SrcAddr  OPTIONAL,\r
-  IN EFI_MAC_ADDRESS                      *DestAddr OPTIONAL,\r
-  IN UINT16                               *Protocol OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-  ETHERNET_HEADER    *EnetHeader;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  if (Private->Mode->State < EfiSimpleNetworkStarted) {\r
-    return EFI_NOT_STARTED;\r
-  }\r
-\r
-  if ( HeaderSize != 0 ) {\r
-    if ((DestAddr == NULL) || (Protocol == NULL) || (HeaderSize != Private->Mode->MediaHeaderSize)) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    if (SrcAddr == NULL) {\r
-      SrcAddr = &Private->Mode->CurrentAddress;\r
-    }\r
-\r
-    EnetHeader = (ETHERNET_HEADER *) Buffer;\r
-\r
-    CopyMem (EnetHeader->DstAddr, DestAddr, NET_ETHER_ADDR_LEN);\r
-    CopyMem (EnetHeader->SrcAddr, SrcAddr, NET_ETHER_ADDR_LEN);\r
-\r
-    EnetHeader->Type = HTONS(*Protocol);\r
-  }\r
-\r
-  if (write  (Private->BpfFd, Buffer, BufferSize) < 0) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Receives a packet from a network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  HeaderSize The size, in bytes, of the media header received on the network\r
-                     interface. If this parameter is NULL, then the media header size\r
-                     will not be returned.\r
-  @param  BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
-                     bytes, of the packet that was received on the network interface.\r
-  @param  Buffer     A pointer to the data buffer to receive both the media header and\r
-                     the data.\r
-  @param  SrcAddr    The source HW MAC address. If this parameter is NULL, the\r
-                     HW MAC source address will not be extracted from the media\r
-                     header.\r
-  @param  DestAddr   The destination HW MAC address. If this parameter is NULL,\r
-                     the HW MAC destination address will not be extracted from the\r
-                     media header.\r
-  @param  Protocol   The media header type. If this parameter is NULL, then the\r
-                     protocol will not be extracted from the media header. See\r
-                     RFC 1700 section "Ether Types" for examples.\r
-\r
-  @retval  EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
-                                 been updated to the number of bytes received.\r
-  @retval  EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
-                                 request.\r
-  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval  EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval  EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpReceive (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  OUT UINTN                               *HeaderSize OPTIONAL,\r
-  IN OUT UINTN                            *BufferSize,\r
-  OUT VOID                                *Buffer,\r
-  OUT EFI_MAC_ADDRESS                     *SrcAddr    OPTIONAL,\r
-  OUT EFI_MAC_ADDRESS                     *DestAddr   OPTIONAL,\r
-  OUT UINT16                              *Protocol   OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-  struct bpf_hdr     *BpfHeader;\r
-       struct bpf_stat    BpfStats;\r
-  ETHERNET_HEADER    *EnetHeader;\r
-  ssize_t            Result;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  if (Private->Mode->State < EfiSimpleNetworkStarted) {\r
-    return EFI_NOT_STARTED;\r
-  }\r
-\r
-       ZeroMem (&BpfStats, sizeof( BpfStats));\r
-       \r
-       if (ioctl (Private->BpfFd, BIOCGSTATS, &BpfStats) == 0) {\r
-               Private->ReceivedPackets += BpfStats.bs_recv;\r
-               if (BpfStats.bs_drop > Private->DroppedPackets) {\r
-                       printf (\r
-                         "SNP: STATS: RCVD = %d DROPPED = %d.  Probably need to increase BPF PcdNetworkPacketFilterSize?\n",\r
-                               BpfStats.bs_recv, \r
-                               BpfStats.bs_drop - Private->DroppedPackets\r
-                               );\r
-                       Private->DroppedPackets = BpfStats.bs_drop;\r
-               }\r
-       }\r
-\r
-  //\r
-  // Do we have any remaining packets from the previous read?\r
-  //\r
-  if (Private->CurrentReadPointer >= Private->EndReadPointer) {\r
-    Result = read (Private->BpfFd, Private->ReadBuffer, Private->ReadBufferSize);\r
-    if (Result < 0) {\r
-      // EAGAIN means that there's no I/O outstanding against this file descriptor.\r
-      return (errno == EAGAIN) ? EFI_NOT_READY : EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    if (Result == 0) {\r
-      return EFI_NOT_READY;\r
-    }\r
-\r
-    Private->CurrentReadPointer = Private->ReadBuffer;\r
-    Private->EndReadPointer = Private->CurrentReadPointer + Result;\r
-  }\r
-\r
-  BpfHeader = Private->CurrentReadPointer;\r
-  EnetHeader = Private->CurrentReadPointer + BpfHeader->bh_hdrlen;\r
-\r
-  if (BpfHeader->bh_caplen > *BufferSize) {\r
-    *BufferSize = BpfHeader->bh_caplen;\r
-    return EFI_BUFFER_TOO_SMALL;\r
-  }\r
-\r
-  CopyMem (Buffer, EnetHeader, BpfHeader->bh_caplen);\r
-  *BufferSize = BpfHeader->bh_caplen;\r
-\r
-  if (HeaderSize != NULL) {\r
-    *HeaderSize = sizeof (ETHERNET_HEADER);\r
-  }\r
-\r
-  if (DestAddr != NULL) {\r
-    ZeroMem (DestAddr, sizeof (EFI_MAC_ADDRESS));\r
-    CopyMem (DestAddr, EnetHeader->DstAddr, NET_ETHER_ADDR_LEN);\r
-  }\r
-\r
-  if (SrcAddr != NULL) {\r
-    ZeroMem (SrcAddr, sizeof (EFI_MAC_ADDRESS));\r
-    CopyMem (SrcAddr, EnetHeader->SrcAddr, NET_ETHER_ADDR_LEN);\r
-  }\r
-\r
-  if (Protocol != NULL) {\r
-    *Protocol = NTOHS (EnetHeader->Type);\r
-  }\r
-\r
-  Private->CurrentReadPointer += BPF_WORDALIGN (BpfHeader->bh_hdrlen + BpfHeader->bh_caplen);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-EMU_SNP_PROTOCOL gEmuSnpProtocol = {\r
-  GasketSnpCreateMapping,\r
-  GasketSnpStart,\r
-  GasketSnpStop,\r
-  GasketSnpInitialize,\r
-  GasketSnpReset,\r
-  GasketSnpShutdown,\r
-  GasketSnpReceiveFilters,\r
-  GasketSnpStationAddress,\r
-  GasketSnpStatistics,\r
-  GasketSnpMCastIpToMac,\r
-  GasketSnpNvData,\r
-  GasketSnpGetStatus,\r
-  GasketSnpTransmit,\r
-  GasketSnpReceive\r
-};\r
-\r
-EFI_STATUS\r
-GetInterfaceMacAddr (\r
-  EMU_SNP_PRIVATE    *Private\r
-  )\r
-{\r
-       EFI_STATUS                                Status;\r
-  struct ifaddrs      *IfAddrs;\r
-  struct ifaddrs      *If;\r
-  struct sockaddr_dl  *IfSdl;\r
-\r
-  if (getifaddrs (&IfAddrs) != 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Convert the interface name to ASCII so we can find it.\r
-  //\r
-  Private->InterfaceName = malloc (StrSize (Private->Thunk->ConfigString));\r
-  if (Private->InterfaceName == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Exit;\r
-  }\r
-\r
-  UnicodeStrToAsciiStr (Private->Thunk->ConfigString, Private->InterfaceName);\r
-\r
-  Status = EFI_NOT_FOUND;\r
-  If = IfAddrs;\r
-  while (If != NULL) {\r
-    IfSdl = (struct sockaddr_dl *)If->ifa_addr;\r
-\r
-    if (IfSdl->sdl_family == AF_LINK) {\r
-      if (!AsciiStrCmp( Private->InterfaceName, If->ifa_name)) {\r
-        CopyMem (&Private->MacAddress, LLADDR (IfSdl), NET_ETHER_ADDR_LEN);\r
-\r
-        Status = EFI_SUCCESS;\r
-        break;\r
-      }\r
-    }\r
-\r
-    If = If->ifa_next;\r
-  }\r
-\r
-Exit:\r
-  freeifaddrs (IfAddrs);\r
-  return Status;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EmuSnpThunkOpen (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE  *Private;\r
-  \r
-  if (This->Private != NULL) {\r
-    return EFI_ALREADY_STARTED;\r
-  }\r
-  \r
-  if (!CompareGuid (This->Protocol, &gEmuSnpProtocolGuid)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  \r
-  Private = malloc (sizeof (EMU_SNP_PRIVATE));\r
-  if (Private == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  \r
-  Private->Signature = EMU_SNP_PRIVATE_SIGNATURE;\r
-  Private->Thunk     = This;\r
-  CopyMem (&Private->EmuSnp, &gEmuSnpProtocol, sizeof (gEmuSnpProtocol));\r
-  GetInterfaceMacAddr (Private);\r
-  \r
-  This->Interface = &Private->EmuSnp;\r
-  This->Private   = Private;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EmuSnpThunkClose (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE  *Private;\r
-\r
-  if (!CompareGuid (This->Protocol, &gEmuSnpProtocolGuid)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  \r
-  Private = This->Private;\r
-  free (Private);\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
-EMU_IO_THUNK_PROTOCOL gSnpThunkIo = {\r
-  &gEmuSnpProtocolGuid,\r
-  NULL,\r
-  NULL,\r
-  0,\r
-  GasketSnpThunkOpen,\r
-  GasketSnpThunkClose,\r
-  NULL\r
-};\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/Unix/Sec/BlockIo.c b/InOsEmuPkg/Unix/Sec/BlockIo.c
deleted file mode 100644 (file)
index bb2da24..0000000
+++ /dev/null
@@ -1,706 +0,0 @@
-/**@file\r
-\r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-#include "SecMain.h"\r
-\r
-#define EMU_BLOCK_IO_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'M', 'b', 'k')\r
-typedef struct {\r
-  UINTN                       Signature;\r
-\r
-  EMU_IO_THUNK_PROTOCOL       *Thunk;\r
-\r
-  char                        *Filename;\r
-  UINTN                       ReadMode;\r
-  UINTN                       Mode;\r
-\r
-  int                         fd;\r
-\r
-  BOOLEAN                     RemovableMedia;\r
-  BOOLEAN                     WriteProtected;\r
-\r
-  UINT64                      NumberOfBlocks;\r
-  UINT32                      BlockSize;\r
-\r
-  EMU_BLOCK_IO_PROTOCOL       EmuBlockIo;\r
-  EFI_BLOCK_IO_MEDIA          *Media;\r
-\r
-} EMU_BLOCK_IO_PRIVATE;\r
-\r
-#define EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \\r
-         CR(a, EMU_BLOCK_IO_PRIVATE, EmuBlockIo, EMU_BLOCK_IO_PRIVATE_SIGNATURE)\r
-\r
-\r
-\r
-EFI_STATUS\r
-EmuBlockIoReset (\r
-  IN EMU_BLOCK_IO_PROTOCOL    *This,\r
-  IN BOOLEAN                  ExtendedVerification\r
-  );\r
-\r
-\r
-/*++\r
-\r
-This function extends the capability of SetFilePointer to accept 64 bit parameters\r
-\r
-**/\r
-EFI_STATUS\r
-SetFilePointer64 (\r
-  IN  EMU_BLOCK_IO_PRIVATE        *Private,\r
-  IN  INT64                      DistanceToMove,\r
-  OUT UINT64                     *NewFilePointer,\r
-  IN  INT32                      MoveMethod\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  off_t         res;\r
-  off_t         offset = DistanceToMove;\r
-\r
-  Status = EFI_SUCCESS;\r
-  res = lseek (Private->fd, offset, (int)MoveMethod);\r
-  if (res == -1) {\r
-    Status = EFI_INVALID_PARAMETER;\r
-  } \r
-\r
-  if (NewFilePointer != NULL) {\r
-    *NewFilePointer = res;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EmuBlockIoOpenDevice (\r
-  IN EMU_BLOCK_IO_PRIVATE   *Private\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  UINT64                FileSize;\r
-  struct statfs         buf;\r
-\r
-\r
-  //\r
-  // If the device is already opened, close it\r
-  //\r
-  if (Private->fd >= 0) {\r
-    EmuBlockIoReset (&Private->EmuBlockIo, FALSE);\r
-  }\r
-\r
-  //\r
-  // Open the device\r
-  //\r
-  Private->fd = open (Private->Filename, Private->Mode, 0644);\r
-  if (Private->fd < 0) {\r
-    printf ("EmuOpenBlock: Could not open %s: %s\n", Private->Filename, strerror(errno));\r
-    Private->Media->MediaPresent  = FALSE;\r
-    Status                        = EFI_NO_MEDIA;\r
-    goto Done;\r
-  }\r
-\r
-  if (!Private->Media->MediaPresent) {\r
-    //\r
-    // BugBug: try to emulate if a CD appears - notify drivers to check it out\r
-    //\r
-    Private->Media->MediaPresent = TRUE;\r
-  }\r
-\r
-  //\r
-  // get the size of the file\r
-  //\r
-  Status = SetFilePointer64 (Private, 0, &FileSize, SEEK_END);\r
-  if (EFI_ERROR (Status)) {\r
-    printf ("EmuOpenBlock: Could not get filesize of %s\n", Private->Filename);\r
-    Status = EFI_UNSUPPORTED;\r
-    goto Done;\r
-  }\r
-  \r
-  if (FileSize == 0) {\r
-    // lseek fails on a real device. ioctl calls are OS specific\r
-#if __APPLE__\r
-    {\r
-      UINT32 BlockSize;\r
-     \r
-      if (ioctl (Private->fd, DKIOCGETBLOCKSIZE, &BlockSize) == 0) {\r
-        Private->Media->BlockSize = BlockSize;\r
-      }\r
-      if (ioctl (Private->fd, DKIOCGETBLOCKCOUNT, &Private->NumberOfBlocks) == 0) {\r
-        if ((Private->NumberOfBlocks == 0) && (BlockSize == 0x800)) {\r
-          // A DVD is ~ 4.37 GB so make up a number\r
-          Private->Media->LastBlock = (0x100000000ULL/0x800) - 1;\r
-        } else {\r
-          Private->Media->LastBlock = Private->NumberOfBlocks - 1;\r
-        }\r
-      }\r
-      ioctl (Private->fd, DKIOCGETMAXBLOCKCOUNTWRITE, &Private->Media->OptimalTransferLengthGranularity);  \r
-    }\r
-#else \r
-    {\r
-      size_t BlockSize;\r
-      UINT64 DiskSize;\r
-      \r
-      if (ioctl (Private->fd, BLKSSZGET, &BlockSize) == 0) {\r
-        Private->Media->BlockSize = BlockSize;\r
-      }\r
-      if (ioctl (Private->fd, BLKGETSIZE64, &DiskSize) == 0) {\r
-        Private->NumberOfBlocks = DivU64x32 (DiskSize, (UINT32)BlockSize);\r
-        Private->Media->LastBlock = Private->NumberOfBlocks - 1;\r
-      }\r
-    }\r
-#endif\r
-    \r
-  } else {\r
-    Private->Media->BlockSize = Private->BlockSize;\r
-    Private->NumberOfBlocks = DivU64x32 (FileSize, Private->Media->BlockSize);\r
-    Private->Media->LastBlock = Private->NumberOfBlocks - 1;\r
-    \r
-    if (fstatfs (Private->fd, &buf) == 0) {\r
-#if __APPLE__\r
-      Private->Media->OptimalTransferLengthGranularity = buf.f_iosize/buf.f_bsize;\r
-#else\r
-      Private->Media->OptimalTransferLengthGranularity = buf.f_bsize/buf.f_bsize;\r
-#endif\r
-    }\r
-  } \r
-\r
-  DEBUG ((EFI_D_INIT, "%HEmuOpenBlock: opened %a%N\n", Private->Filename));\r
-  Status = EFI_SUCCESS;\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-    if (Private->fd >= 0) {\r
-      EmuBlockIoReset (&Private->EmuBlockIo, FALSE);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EmuBlockIoCreateMapping (\r
-  IN     EMU_BLOCK_IO_PROTOCOL    *This,\r
-  IN     EFI_BLOCK_IO_MEDIA       *Media\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_BLOCK_IO_PRIVATE    *Private;\r
-\r
-  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Private->Media = Media;\r
-  \r
-  Media->MediaId          = 0;\r
-  Media->RemovableMedia   = Private->RemovableMedia;\r
-  Media->MediaPresent     = TRUE;\r
-  Media->LogicalPartition = FALSE;\r
-  Media->ReadOnly         = Private->WriteProtected;\r
-  Media->WriteCaching     = FALSE;\r
-  Media->IoAlign          = 1;\r
-  Media->LastBlock        = 0; // Filled in by OpenDevice\r
-  \r
-  // EFI_BLOCK_IO_PROTOCOL_REVISION2\r
-  Media->LowestAlignedLba              = 0;\r
-  Media->LogicalBlocksPerPhysicalBlock = 0; \r
-    \r
-\r
-  // EFI_BLOCK_IO_PROTOCOL_REVISION3\r
-  Media->OptimalTransferLengthGranularity = 0;\r
-    \r
-  Status = EmuBlockIoOpenDevice (Private);\r
-\r
-  \r
-  return Status;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EmuBlockIoError (\r
-  IN EMU_BLOCK_IO_PRIVATE      *Private\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  BOOLEAN               ReinstallBlockIoFlag;\r
-\r
-\r
-  switch (errno) {\r
-\r
-  case EAGAIN:\r
-    Status                        = EFI_NO_MEDIA;\r
-    Private->Media->ReadOnly      = FALSE;\r
-    Private->Media->MediaPresent  = FALSE;\r
-    ReinstallBlockIoFlag          = FALSE;\r
-    break;\r
-\r
-  case EACCES:\r
-    Private->Media->ReadOnly      = FALSE;\r
-    Private->Media->MediaPresent  = TRUE;\r
-    Private->Media->MediaId += 1;\r
-    ReinstallBlockIoFlag  = TRUE;\r
-    Status                = EFI_MEDIA_CHANGED;\r
-    break;\r
-\r
-  case EROFS:\r
-    Private->Media->ReadOnly  = TRUE;\r
-    ReinstallBlockIoFlag      = FALSE;\r
-    Status                    = EFI_WRITE_PROTECTED;\r
-    break;\r
-\r
-  default:\r
-    ReinstallBlockIoFlag  = FALSE;\r
-    Status                = EFI_DEVICE_ERROR;\r
-    break;\r
-  }\r
-  return Status;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EmuBlockIoReadWriteCommon (\r
-  IN  EMU_BLOCK_IO_PRIVATE        *Private,\r
-  IN UINT32                       MediaId,\r
-  IN EFI_LBA                      Lba,\r
-  IN UINTN                        BufferSize,\r
-  IN VOID                         *Buffer,\r
-  IN CHAR8                        *CallerName\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  UINTN       BlockSize;\r
-  UINT64      LastBlock;\r
-  INT64       DistanceToMove;\r
-  UINT64      DistanceMoved;\r
-\r
-  if (Private->fd < 0) {\r
-    Status = EmuBlockIoOpenDevice (Private);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  if (!Private->Media->MediaPresent) {\r
-    DEBUG ((EFI_D_INIT, "%s: No Media\n", CallerName));\r
-    return EFI_NO_MEDIA;\r
-  }\r
-\r
-  if (Private->Media->MediaId != MediaId) {\r
-    return EFI_MEDIA_CHANGED;\r
-  }\r
-\r
-  if ((UINTN) Buffer % Private->Media->IoAlign != 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  //\r
-  // Verify buffer size\r
-  //\r
-  BlockSize = Private->Media->BlockSize;\r
-  if (BufferSize == 0) {\r
-    DEBUG ((EFI_D_INIT, "%s: Zero length read\n", CallerName));\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if ((BufferSize % BlockSize) != 0) {\r
-    DEBUG ((EFI_D_INIT, "%s: Invalid read size\n", CallerName));\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  LastBlock = Lba + (BufferSize / BlockSize) - 1;\r
-  if (LastBlock > Private->Media->LastBlock) {\r
-    DEBUG ((EFI_D_INIT, "ReadBlocks: Attempted to read off end of device\n"));\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Seek to End of File\r
-  //\r
-  DistanceToMove = MultU64x32 (Lba, BlockSize);\r
-  Status = SetFilePointer64 (Private, DistanceToMove, &DistanceMoved, SEEK_SET);\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_INIT, "WriteBlocks: SetFilePointer failed\n"));\r
-    return EmuBlockIoError (Private);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Read BufferSize bytes from Lba into Buffer.\r
-  \r
-  This function reads the requested number of blocks from the device. All the\r
-  blocks are read, or an error is returned.\r
-  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and\r
-  non-blocking I/O is being used, the Event associated with this request will\r
-  not be signaled.\r
-\r
-  @param[in]       This       Indicates a pointer to the calling context.\r
-  @param[in]       MediaId    Id of the media, changes every time the media is \r
-                              replaced.\r
-  @param[in]       Lba        The starting Logical Block Address to read from.\r
-  @param[in, out]  Token           A pointer to the token associated with the transaction.\r
-  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.  \r
-  @param[out]      Buffer     A pointer to the destination buffer for the data. The \r
-                              caller is responsible for either having implicit or \r
-                              explicit ownership of the buffer.\r
-\r
-  @retval EFI_SUCCESS           The read request was queued if Token->Event is\r
-                                not NULL.The data was read correctly from the\r
-                                device if the Token->Event is NULL.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing\r
-                                the read.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED     The MediaId is not for the current media.\r
-  @retval EFI_BAD_BUFFER_SIZE   The BufferSize parameter is not a multiple of the\r
-                                intrinsic block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
-                                or the buffer is not on proper alignment.\r
-  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack\r
-                                of resources.\r
-**/\r
-EFI_STATUS\r
-EmuBlockIoReadBlocks (\r
-  IN     EMU_BLOCK_IO_PROTOCOL  *This,\r
-  IN     UINT32                 MediaId,\r
-  IN     EFI_LBA                LBA,\r
-  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
-  IN     UINTN                  BufferSize,\r
-     OUT VOID                   *Buffer\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  EMU_BLOCK_IO_PRIVATE    *Private;\r
-  ssize_t                 len;\r
-\r
-  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Status  = EmuBlockIoReadWriteCommon (Private, MediaId, LBA, BufferSize, Buffer, "UnixReadBlocks");\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  len = read (Private->fd, Buffer, BufferSize);\r
-  if (len != BufferSize) {\r
-    DEBUG ((EFI_D_INIT, "ReadBlocks: ReadFile failed.\n"));\r
-    Status = EmuBlockIoError (Private);\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // If we read then media is present.\r
-  //\r
-  Private->Media->MediaPresent = TRUE;\r
-  Status = EFI_SUCCESS;\r
-\r
-Done:\r
-  if (Token != NULL) {\r
-    if (Token->Event != NULL) {\r
-      // Caller is responcible for signaling EFI Event\r
-      Token->TransactionStatus = Status;\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Write BufferSize bytes from Lba into Buffer.\r
-\r
-  This function writes the requested number of blocks to the device. All blocks\r
-  are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,\r
-  EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is\r
-  being used, the Event associated with this request will not be signaled.\r
-\r
-  @param[in]       This       Indicates a pointer to the calling context.\r
-  @param[in]       MediaId    The media ID that the write request is for.\r
-  @param[in]       Lba        The starting logical block address to be written. The\r
-                              caller is responsible for writing to only legitimate\r
-                              locations.\r
-  @param[in, out]  Token      A pointer to the token associated with the transaction.\r
-  @param[in]       BufferSize Size of Buffer, must be a multiple of device block size.\r
-  @param[in]       Buffer     A pointer to the source buffer for the data.\r
-\r
-  @retval EFI_SUCCESS           The write request was queued if Event is not NULL.\r
-                                The data was written correctly to the device if\r
-                                the Event is NULL.\r
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
-  @retval EFI_NO_MEDIA          There is no media in the device.\r
-  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current device.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing the write.\r
-  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
-  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
-                                or the buffer is not on proper alignment.\r
-  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack\r
-                                of resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuBlockIoWriteBlocks (\r
-  IN     EMU_BLOCK_IO_PROTOCOL  *This,\r
-  IN     UINT32                 MediaId,\r
-  IN     EFI_LBA                LBA,\r
-  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
-  IN     UINTN                  BufferSize,\r
-  IN     VOID                   *Buffer\r
-  )\r
-{\r
-  EMU_BLOCK_IO_PRIVATE    *Private;\r
-  ssize_t                 len;\r
-  EFI_STATUS              Status;\r
-\r
-\r
-  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Status  = EmuBlockIoReadWriteCommon (Private, MediaId, LBA, BufferSize, Buffer, "UnixWriteBlocks");\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  len = write (Private->fd, Buffer, BufferSize);\r
-  if (len != BufferSize) {\r
-    DEBUG ((EFI_D_INIT, "ReadBlocks: WriteFile failed.\n"));\r
-    Status = EmuBlockIoError (Private);\r
-    goto Done;\r
-  }\r
-\r
-  //\r
-  // If the write succeeded, we are not write protected and media is present.\r
-  //\r
-  Private->Media->MediaPresent = TRUE;\r
-  Private->Media->ReadOnly     = FALSE;\r
-  Status = EFI_SUCCESS;\r
-\r
-Done:\r
-  if (Token != NULL) {\r
-    if (Token->Event != NULL) {\r
-      // Caller is responcible for signaling EFI Event\r
-      Token->TransactionStatus = Status;\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Flush the Block Device.\r
\r
-  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED\r
-  is returned and non-blocking I/O is being used, the Event associated with\r
-  this request will not be signaled.  \r
-\r
-  @param[in]      This     Indicates a pointer to the calling context.\r
-  @param[in,out]  Token    A pointer to the token associated with the transaction\r
-\r
-  @retval EFI_SUCCESS          The flush request was queued if Event is not NULL.\r
-                               All outstanding data was written correctly to the\r
-                               device if the Event is NULL.\r
-  @retval EFI_DEVICE_ERROR     The device reported an error while writting back\r
-                               the data.\r
-  @retval EFI_WRITE_PROTECTED  The device cannot be written to.\r
-  @retval EFI_NO_MEDIA         There is no media in the device.\r
-  @retval EFI_MEDIA_CHANGED    The MediaId is not for the current media.\r
-  @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
-                               of resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuBlockIoFlushBlocks (\r
-  IN     EMU_BLOCK_IO_PROTOCOL    *This,\r
-  IN OUT EFI_BLOCK_IO2_TOKEN      *Token\r
-  )\r
-{\r
-  EMU_BLOCK_IO_PRIVATE *Private;\r
-\r
-  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  if (Private->fd >= 0) {\r
-    fsync (Private->fd);\r
-#if __APPLE__\r
-    fcntl (Private->fd, F_FULLFSYNC);\r
-#endif\r
-  }\r
-  \r
-  \r
-  if (Token != NULL) {\r
-    if (Token->Event != NULL) {\r
-      // Caller is responcible for signaling EFI Event\r
-      Token->TransactionStatus = EFI_SUCCESS;\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  Reset the block device hardware.\r
-\r
-  @param[in]  This                 Indicates a pointer to the calling context.\r
-  @param[in]  ExtendedVerification Indicates that the driver may perform a more\r
-                                   exhausive verfication operation of the device\r
-                                   during reset.\r
-\r
-  @retval EFI_SUCCESS          The device was reset.\r
-  @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
-                               not be reset.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuBlockIoReset (\r
-  IN EMU_BLOCK_IO_PROTOCOL    *This,\r
-  IN BOOLEAN                  ExtendedVerification\r
-  )\r
-{\r
-  EMU_BLOCK_IO_PRIVATE *Private;\r
-\r
-  Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  if (Private->fd >= 0) {\r
-    close (Private->fd);\r
-    Private->fd = -1;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-char *\r
-StdDupUnicodeToAscii (\r
-  IN  CHAR16 *Str\r
-  )\r
-{\r
-  UINTN   Size;\r
-  char    *Ascii;\r
-  char    *Ptr;\r
-  \r
-  Size = StrLen (Str) + 1;\r
-  Ascii = malloc (Size);\r
-  if (Ascii == NULL) {\r
-    return NULL;\r
-  }\r
-  \r
-  for (Ptr = Ascii; *Str != '\0'; Ptr++, Str++) {\r
-    *Ptr = *Str;\r
-  }\r
-  *Ptr = 0;\r
-  \r
-  return Ascii;\r
-}\r
-\r
-\r
-EMU_BLOCK_IO_PROTOCOL gEmuBlockIoProtocol = {\r
-  GasketEmuBlockIoReset,\r
-  GasketEmuBlockIoReadBlocks,\r
-  GasketEmuBlockIoWriteBlocks,\r
-  GasketEmuBlockIoFlushBlocks,\r
-  GasketEmuBlockIoCreateMapping\r
-};\r
-\r
-EFI_STATUS\r
-EmuBlockIoThunkOpen (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  )\r
-{\r
-  EMU_BLOCK_IO_PRIVATE  *Private;\r
-  char                  *Str;\r
-  \r
-  if (This->Private != NULL) {\r
-    return EFI_ALREADY_STARTED;\r
-  }\r
-  \r
-  if (!CompareGuid (This->Protocol, &gEmuBlockIoProtocolGuid)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  \r
-  Private = malloc (sizeof (EMU_BLOCK_IO_PRIVATE));\r
-  if (Private == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  \r
-  Private->Signature = EMU_BLOCK_IO_PRIVATE_SIGNATURE;\r
-  Private->Thunk     = This;\r
-  CopyMem (&Private->EmuBlockIo, &gEmuBlockIoProtocol, sizeof (gEmuBlockIoProtocol));\r
-  Private->fd        = -1;\r
-  Private->BlockSize = 512;\r
\r
-  Private->Filename = StdDupUnicodeToAscii (This->ConfigString);\r
-  if (Private->Filename == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
\r
-  Str = strstr (Private->Filename, ":");\r
-  if (Str == NULL) {\r
-    Private->RemovableMedia = FALSE;\r
-    Private->WriteProtected = FALSE;\r
-  } else {\r
-    for (*Str++ = '\0'; *Str != 0; Str++) {\r
-      if (*Str == 'R' || *Str == 'F') {\r
-        Private->RemovableMedia = (BOOLEAN) (*Str == 'R');\r
-      }\r
-      if (*Str == 'O' || *Str == 'W') {\r
-        Private->WriteProtected  = (BOOLEAN) (*Str == 'O');\r
-      }\r
-      if (*Str == ':') {\r
-        Private->BlockSize = strtol (++Str, NULL, 0);\r
-        break;\r
-      }\r
-    }\r
-  }\r
-  \r
-  This->Interface = &Private->EmuBlockIo;\r
-  This->Private   = Private;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EmuBlockIoThunkClose (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  )\r
-{\r
-  EMU_BLOCK_IO_PRIVATE  *Private;\r
-\r
-  if (!CompareGuid (This->Protocol, &gEmuBlockIoProtocolGuid)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  \r
-  Private = This->Private;\r
-  \r
-  if (This->Private != NULL) {\r
-    if (Private->Filename != NULL) {\r
-      free (Private->Filename);\r
-    }   \r
-    free (This->Private);\r
-    This->Private = NULL;\r
-  }\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
-EMU_IO_THUNK_PROTOCOL gBlockIoThunkIo = {\r
-  &gEmuBlockIoProtocolGuid,\r
-  NULL,\r
-  NULL,\r
-  0,\r
-  GasketBlockIoThunkOpen,\r
-  GasketBlockIoThunkClose,\r
-  NULL\r
-};\r
-\r
-\r
diff --git a/InOsEmuPkg/Unix/Sec/EmuThunk.c b/InOsEmuPkg/Unix/Sec/EmuThunk.c
deleted file mode 100644 (file)
index fe68603..0000000
+++ /dev/null
@@ -1,432 +0,0 @@
-/*++ @file
-  Since the SEC is the only program in our emulation we 
-  must use a UEFI/PI mechanism to export APIs to other modules.
-  This is the role of the EFI_EMU_THUNK_PROTOCOL.
-
-  The mUnixThunkTable exists so that a change to EFI_EMU_THUNK_PROTOCOL
-  will cause an error in initializing the array if all the member functions
-  are not added. It looks like adding a element to end and not initializing
-  it may cause the table to be initaliized with the members at the end being
-  set to zero. This is bad as jumping to zero will crash.
-
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
-Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
-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 "SecMain.h"
-
-#ifdef __APPLE__
-#define DebugAssert _Mangle__DebugAssert
-
-#include <assert.h>
-#include <CoreServices/CoreServices.h>
-#include <mach/mach.h>
-#include <mach/mach_time.h>
-
-#undef DebugAssert
-#endif
-
-int settimer_initialized;
-struct timeval settimer_timeval;
-void (*settimer_callback)(UINT64 delta);
-
-BOOLEAN gEmulatorInterruptEnabled = FALSE;
-
-
-UINTN
-SecWriteStdErr (
-  IN UINT8     *Buffer,
-  IN UINTN     NumberOfBytes
-  )
-{
-  ssize_t Return;
-  
-  Return = write (STDERR_FILENO, (const void *)Buffer, (size_t)NumberOfBytes);
-  
-  return (Return == -1) ? 0 : Return;
-}
-
-
-EFI_STATUS
-SecConfigStdIn (
-  VOID
-  )
-{
-  struct termios tty;
-  
-  //
-  // Need to turn off line buffering, ECHO, and make it unbuffered.
-  //
-  tcgetattr (STDIN_FILENO, &tty);
-  tty.c_lflag &= ~(ICANON | ECHO);
-  tcsetattr (STDIN_FILENO, TCSANOW, &tty);
-  
-//  setvbuf (STDIN_FILENO, NULL, _IONBF, 0);
-  
-  // now ioctl FIONREAD will do what we need
-  return EFI_SUCCESS;
-}
-
-UINTN
-SecWriteStdOut (
-  IN UINT8     *Buffer,
-  IN UINTN     NumberOfBytes
-  )
-{
-  ssize_t Return;
-  
-  Return = write (STDOUT_FILENO, (const void *)Buffer, (size_t)NumberOfBytes);
-  
-  return (Return == -1) ? 0 : Return;
-}
-
-UINTN
-SecReadStdIn (
-  IN UINT8     *Buffer,
-  IN UINTN     NumberOfBytes
-  )
-{
-  ssize_t Return;
-  
-  Return = read (STDIN_FILENO, Buffer, (size_t)NumberOfBytes);
-  
-  return (Return == -1) ? 0 : Return;
-}
-
-BOOLEAN
-SecPollStdIn (
-  VOID
-  )
-{
-  int Result;
-  int Bytes;
-  
-  Result = ioctl (STDIN_FILENO, FIONREAD, &Bytes);
-  if (Result == -1) {
-    return FALSE;
-  }
-  
-  return (BOOLEAN)(Bytes > 0);
-}
-
-
-VOID *
-SecMalloc (
-  IN  UINTN Size
-  )
-{
-  return malloc ((size_t)Size);
-}
-
-VOID *
-SecValloc (
-  IN  UINTN Size
-  )
-{
-  return valloc ((size_t)Size);
-}
-
-BOOLEAN
-SecFree (
-  IN  VOID *Ptr
-  )
-{
-  if (EfiSystemMemoryRange (Ptr)) {
-    // If an address range is in the EFI memory map it was alloced via EFI.
-    // So don't free those ranges and let the caller know.
-    return FALSE;
-  }
-  
-  free (Ptr);
-  return TRUE;
-}
-
-
-void
-settimer_handler (int sig)
-{
-  struct timeval timeval;
-  UINT64 delta;
-
-  gettimeofday (&timeval, NULL);
-  delta = ((UINT64)timeval.tv_sec * 1000) + (timeval.tv_usec / 1000)
-    - ((UINT64)settimer_timeval.tv_sec * 1000) 
-    - (settimer_timeval.tv_usec / 1000);
-  settimer_timeval = timeval;
-  
-  if (settimer_callback) {
-    ReverseGasketUint64 (settimer_callback, delta);
-  }
-}
-
-VOID
-SecSetTimer (
-  IN  UINT64                  PeriodMs,
-  IN  EMU_SET_TIMER_CALLBACK  CallBack
-  )
-{
-  struct itimerval timerval;
-  UINT32 remainder;
-
-  if (!settimer_initialized) {
-    struct sigaction act;
-
-    settimer_initialized = 1;
-    act.sa_handler = settimer_handler;
-    act.sa_flags = 0;
-    sigemptyset (&act.sa_mask);
-    gEmulatorInterruptEnabled = TRUE;
-    if (sigaction (SIGALRM, &act, NULL) != 0) {
-      printf ("SetTimer: sigaction error %s\n", strerror (errno));
-    }
-    if (gettimeofday (&settimer_timeval, NULL) != 0) {
-      printf ("SetTimer: gettimeofday error %s\n", strerror (errno));
-    }
-  }
-  timerval.it_value.tv_sec = DivU64x32(PeriodMs, 1000);
-  DivU64x32Remainder(PeriodMs, 1000, &remainder);
-  timerval.it_value.tv_usec = remainder * 1000;
-  timerval.it_value.tv_sec = DivU64x32(PeriodMs, 1000);
-  timerval.it_interval = timerval.it_value;
-  
-  if (setitimer (ITIMER_REAL, &timerval, NULL) != 0) {
-    printf ("SetTimer: setitimer error %s\n", strerror (errno));
-  }
-  settimer_callback = CallBack;
-}
-
-
-VOID
-SecEnableInterrupt (
-  VOID
-  )
-{
-  sigset_t  sigset;
-
-  gEmulatorInterruptEnabled = TRUE;
-  // Since SetTimer() uses SIGALRM we emulate turning on and off interrupts 
-  // by enabling/disabling SIGALRM.
-  sigemptyset (&sigset);
-  sigaddset (&sigset, SIGALRM);
-  pthread_sigmask (SIG_UNBLOCK, &sigset, NULL);
-}
-
-
-VOID
-SecDisableInterrupt (
-  VOID
-  )
-{
-  sigset_t  sigset;
-
-  // Since SetTimer() uses SIGALRM we emulate turning on and off interrupts 
-  // by enabling/disabling SIGALRM.
-  sigemptyset (&sigset);
-  sigaddset (&sigset, SIGALRM);
-  pthread_sigmask (SIG_BLOCK, &sigset, NULL);
-  gEmulatorInterruptEnabled = FALSE;
-}
-
-
-BOOLEAN
-SecInterruptEanbled (void)
-{
-  return gEmulatorInterruptEnabled;
-}
-
-
-UINT64
-QueryPerformanceFrequency (
-  VOID
-  )
-{
-  // Hard code to nanoseconds
-  return 1000000000ULL;
-}
-
-UINT64
-QueryPerformanceCounter (
-  VOID
-  )
-{
-#if __APPLE__
-  UINT64          Start;
-  Nanoseconds     elapsedNano;
-
-  Start = mach_absolute_time ();
-  
-  // Convert to nanoseconds.
-
-  // Have to do some pointer fun because AbsoluteToNanoseconds 
-  // works in terms of UnsignedWide, which is a structure rather 
-    // than a proper 64-bit integer.
-  elapsedNano = AbsoluteToNanoseconds (*(AbsoluteTime *) &Start);
-
-  return *(uint64_t *) &elapsedNano;
-#else
-  // Need to figure out what to do for Linux?
-  return 0;
-#endif
-}
-  
-
-
-VOID
-SecSleep (
-  IN  UINT64 Nanoseconds
-  )
-{
-  struct timespec rq, rm;
-  struct timeval  start, end;
-  unsigned long  MicroSec;
-  
-  rq.tv_sec  = DivU64x32 (Nanoseconds, 1000000000);
-  rq.tv_nsec = ModU64x32 (Nanoseconds, 1000000000);
-
-  //
-  // nanosleep gets interrupted by our timer tic. 
-  // we need to track wall clock time or we will stall for way too long
-  //
-  gettimeofday (&start, NULL);
-  end.tv_sec  = start.tv_sec + rq.tv_sec;
-  MicroSec = (start.tv_usec + rq.tv_nsec/1000);
-  end.tv_usec = MicroSec % 1000000;
-  if (MicroSec > 1000000) {
-    end.tv_sec++;
-  }
-
-  while (nanosleep (&rq, &rm) == -1) {
-    if (errno != EINTR) {
-      break;
-    }
-    gettimeofday (&start, NULL);
-    if (start.tv_sec > end.tv_sec) {
-      break;
-    } if ((start.tv_sec == end.tv_sec) && (start.tv_usec > end.tv_usec)) {
-      break;
-    }
-    rq = rm;
-  } 
-}
-
-
-VOID
-SecCpuSleep (
-  VOID
-  )
-{
-  struct timespec rq, rm;
-
-  // nanosleep gets interrupted by the timer tic
-  rq.tv_sec  = 1;
-  rq.tv_nsec = 0;
-  
-  nanosleep (&rq, &rm);
-}
-
-
-VOID
-SecExit (
-  UINTN   Status
-  )
-{
-  exit (Status);
-}
-
-
-VOID
-SecGetTime (
-  OUT  EFI_TIME               *Time,
-  OUT EFI_TIME_CAPABILITIES   *Capabilities OPTIONAL
-  )
-{
-  struct tm *tm;
-  time_t t;
-
-  t = time (NULL);
-  tm = localtime (&t);
-
-  Time->Year = 1900 + tm->tm_year;
-  Time->Month = tm->tm_mon + 1;
-  Time->Day = tm->tm_mday;
-  Time->Hour = tm->tm_hour;
-  Time->Minute = tm->tm_min;
-  Time->Second = tm->tm_sec;
-  Time->Nanosecond = 0;
-  Time->TimeZone = timezone;
-  Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0)
-    | (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
-    
-  if (Capabilities != NULL) {
-    Capabilities->Resolution  = 1;
-    Capabilities->Accuracy    = 50000000;
-    Capabilities->SetsToZero  = FALSE;
-  }
-}
-
-
-
-VOID
-SecSetTime (
-  IN  EFI_TIME               *Time
-  )
-{
-  // Don't change the time on the system
-  // We could save delta to localtime() and have SecGetTime adjust return values?
-  return;
-}
-
-
-EFI_STATUS
-SecGetNextProtocol (
-  IN  BOOLEAN                 EmuBusDriver,
-  OUT EMU_IO_THUNK_PROTOCOL   **Instance   OPTIONAL
-  )
-{
-  return GetNextThunkProtocol (EmuBusDriver, Instance);
-}
-
-
-EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
-  GasketSecWriteStdErr,
-  GasketSecConfigStdIn,
-  GasketSecWriteStdOut,
-  GasketSecReadStdIn,
-  GasketSecPollStdIn,
-  GasketSecMalloc,
-  GasketSecValloc,
-  GasketSecFree,
-  GasketSecPeCoffGetEntryPoint,
-  GasketSecPeCoffRelocateImageExtraAction,
-  GasketSecPeCoffUnloadImageExtraAction,
-  GasketSecEnableInterrupt,
-  GasketSecDisableInterrupt,
-  GasketQueryPerformanceFrequency,
-  GasketQueryPerformanceCounter,
-  GasketSecSleep,
-  GasketSecCpuSleep,
-  GasketSecExit,
-  GasketSecGetTime,                
-  GasketSecSetTime,
-  GasketSecSetTimer,  
-  GasketSecGetNextProtocol
-};
-
-
-VOID
-SecInitThunkProtocol (
-  VOID
-  )
-{
-  // timezone and daylight lib globals depend on tzset be called 1st.
-  tzset ();
-}
-
diff --git a/InOsEmuPkg/Unix/Sec/Gasket.h b/InOsEmuPkg/Unix/Sec/Gasket.h
deleted file mode 100644 (file)
index 2c59a56..0000000
+++ /dev/null
@@ -1,651 +0,0 @@
-/** @file\r
-\r
-  Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _GASKET_H_\r
-#define _GASKET_H_\r
-\r
-//\r
-// EMU_THUNK_PROTOCOL gaskets (EFIAPI to UNIX ABI)\r
-//\r
-\r
-UINTN\r
-EFIAPI\r
-GasketSecWriteStdErr (\r
-  IN UINT8     *Buffer,\r
-  IN UINTN     NumberOfBytes\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSecConfigStdIn (\r
-  VOID\r
-  );\r
-\r
-UINTN\r
-EFIAPI\r
-GasketSecWriteStdOut (\r
-  IN UINT8     *Buffer,\r
-  IN UINTN     NumberOfBytes\r
-  );\r
-  \r
-UINTN\r
-EFIAPI\r
-GasketSecReadStdIn (\r
-  IN UINT8     *Buffer,\r
-  IN UINTN     NumberOfBytes\r
-  );\r
-\r
-BOOLEAN\r
-EFIAPI\r
-GasketSecPollStdIn (\r
-  VOID\r
-  );\r
-\r
-VOID *\r
-EFIAPI\r
-GasketSecMalloc (\r
-  IN  UINTN Size\r
-  );\r
-\r
-VOID *\r
-EFIAPI\r
-GasketSecValloc (\r
-  IN  UINTN Size\r
-  );\r
-  \r
-BOOLEAN\r
-EFIAPI\r
-GasketSecFree (\r
-  IN  VOID *Ptr\r
-  );\r
-\r
-\r
-RETURN_STATUS\r
-EFIAPI\r
-GasketSecPeCoffGetEntryPoint (\r
-  IN     VOID  *Pe32Data,\r
-  IN OUT VOID  **EntryPoint\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-GasketSecPeCoffRelocateImageExtraAction (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-GasketSecPeCoffUnloadImageExtraAction (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-GasketSecSetTimer (\r
-  IN  UINT64                  PeriodMs,\r
-  IN  EMU_SET_TIMER_CALLBACK  CallBack\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-GasketSecEnableInterrupt (\r
-  VOID\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-GasketSecDisableInterrupt (\r
-  VOID\r
-  );\r
-  \r
-UINT64  \r
-EFIAPI\r
-GasketQueryPerformanceFrequency (\r
-  VOID\r
-  );\r
-\r
-UINT64\r
-EFIAPI\r
-GasketQueryPerformanceCounter (\r
-  VOID\r
-  );\r
-\r
-\r
-VOID\r
-EFIAPI\r
-GasketSecSleep (\r
-  IN  UINT64 Nanoseconds\r
-  );\r
-  \r
-VOID\r
-EFIAPI\r
-GasketSecCpuSleep (\r
-  VOID\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-GasketSecExit (\r
-  UINTN   Status\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-GasketSecGetTime (\r
-  OUT  EFI_TIME               *Time,\r
-  OUT EFI_TIME_CAPABILITIES   *Capabilities OPTIONAL\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-GasketSecSetTime (\r
-  IN  EFI_TIME               *Time\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSecGetNextProtocol (\r
-  IN  BOOLEAN                 EmuBusDriver,\r
-  OUT EMU_IO_THUNK_PROTOCOL   **Instance  OPTIONAL\r
-  );\r
-\r
-\r
-// PPIs produced by SEC  \r
-\r
-  \r
-EFI_STATUS\r
-EFIAPI\r
-GasketSecUnixPeiAutoScan (\r
-  IN  UINTN                 Index,\r
-  OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,\r
-  OUT UINT64                *MemorySize\r
-  );\r
-  \r
-VOID *\r
-EFIAPI\r
-GasketSecEmuThunkAddress (\r
-  VOID\r
-  );\r
-\r
\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSecUnixUnixFwhAddress (\r
-  IN OUT UINT64                *FwhSize,\r
-  IN OUT EFI_PHYSICAL_ADDRESS  *FwhBase\r
-  );\r
-  \r
-\r
-\r
-//\r
-// Reverse (UNIX to EFIAPI) gaskets\r
-//\r
-\r
-typedef\r
-void\r
-(EFIAPI *CALL_BACK) (\r
-  UINT64 Delta\r
-  );\r
-\r
-UINTN\r
-ReverseGasketUint64 (\r
-  CALL_BACK CallBack,\r
-  UINT64 a\r
-  );\r
-\r
-UINTN\r
-ReverseGasketUint64Uint64 (\r
-  VOID      *CallBack,\r
-  VOID      *Context,\r
-  VOID      *Key\r
-  );\r
-\r
-//\r
-// Gasket functions for EFI_EMU_UGA_IO_PROTOCOL\r
-//\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketX11Size (\r
-  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo,\r
-  UINT32 Width,\r
-  UINT32 Height\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketX11CheckKey (\r
-  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketX11GetKey (\r
-  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo,\r
-  EFI_KEY_DATA                 *key\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketX11KeySetState (\r
-  EMU_GRAPHICS_WINDOW_PROTOCOL  *GraphicsWindowsIo,\r
-  EFI_KEY_TOGGLE_STATE          *KeyToggleState\r
-  );\r
-  \r
-EFI_STATUS\r
-EFIAPI  \r
-GasketX11RegisterKeyNotify ( \r
-  IN EMU_GRAPHICS_WINDOW_PROTOCOL                         *GraphicsWindowsIo, \r
-  IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK     MakeCallBack,\r
-  IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK     BreakCallBack,\r
-  IN VOID                                                 *Context\r
-  );\r
-\r
-  \r
-EFI_STATUS\r
-EFIAPI\r
-GasketX11Blt (\r
-  IN  EMU_GRAPHICS_WINDOW_PROTOCOL            *GraphicsWindows,\r
-  IN  EFI_UGA_PIXEL                           *BltBuffer OPTIONAL,\r
-  IN  EFI_UGA_BLT_OPERATION                   BltOperation,\r
-  IN  EMU_GRAPHICS_WINDOWS__BLT_ARGS          *Args\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketX11CheckPointer (\r
-  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo\r
-  );\r
-\r
-EFI_STATUS \r
-EFIAPI \r
-GasketX11GetPointerState (\r
-  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo, \r
-  EFI_SIMPLE_POINTER_STATE *state\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketX11GraphicsWindowOpen (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  );\r
\r
-EFI_STATUS\r
-EFIAPI\r
-GasketX11GraphicsWindowClose (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  );\r
-\r
-// Pthreads\r
-\r
-UINTN\r
-EFIAPI\r
-GasketPthreadMutexLock (\r
-  IN VOID *Mutex\r
-  );            \r
-\r
-\r
-\r
-UINTN\r
-EFIAPI\r
-GasketPthreadMutexUnLock (\r
-  IN VOID *Mutex\r
-  );                        \r
-\r
\r
-UINTN\r
-EFIAPI\r
-GasketPthreadMutexTryLock (\r
-  IN VOID *Mutex\r
-  );                      \r
-\r
\r
-VOID *\r
-EFIAPI\r
-GasketPthreadMutexInit (\r
-  IN VOID\r
-  );                     \r
-\r
\r
-UINTN\r
-EFIAPI\r
-GasketPthreadMutexDestroy (\r
-  IN VOID *Mutex\r
-  );                            \r
-\r
\r
-UINTN\r
-EFIAPI\r
-GasketPthreadCreate (\r
-  IN  VOID                      *Thread,\r
-  IN  VOID                      *Attribute,\r
-  IN  THREAD_THUNK_THREAD_ENTRY Start,\r
-  IN  VOID                      *Context\r
-  );\r
\r
-VOID\r
-EFIAPI\r
-GasketPthreadExit (\r
-  IN VOID *ValuePtr\r
-  );                            \r
-\r
-   \r
-UINTN\r
-EFIAPI\r
-GasketPthreadSelf (\r
-  VOID\r
-  );                              \r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketPthreadOpen (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketPthreadClose (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  );\r
-\r
-\r
-// PosixFileSystem\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketPosixOpenVolume (\r
-  IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL    *This,\r
-  OUT EFI_FILE_PROTOCOL                 **Root\r
-  );\r
-  \r
-EFI_STATUS\r
-EFIAPI\r
-GasketPosixFileOpen (\r
-  IN EFI_FILE_PROTOCOL        *This,\r
-  OUT EFI_FILE_PROTOCOL       **NewHandle,\r
-  IN CHAR16                   *FileName,\r
-  IN UINT64                   OpenMode,\r
-  IN UINT64                   Attributes\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketPosixFileCLose (\r
-  IN EFI_FILE_PROTOCOL  *This\r
-  );\r
-  \r
-EFI_STATUS\r
-EFIAPI\r
-GasketPosixFileDelete (\r
-  IN EFI_FILE_PROTOCOL  *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketPosixFileRead (\r
-  IN EFI_FILE_PROTOCOL        *This,\r
-  IN OUT UINTN                *BufferSize,\r
-  OUT VOID                    *Buffer\r
-  );\r
-  \r
-EFI_STATUS\r
-EFIAPI\r
-GasketPosixFileWrite (\r
-  IN EFI_FILE_PROTOCOL        *This,\r
-  IN OUT UINTN                *BufferSize,\r
-  IN VOID                     *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketPosixFileSetPossition (\r
-  IN EFI_FILE_PROTOCOL        *This,\r
-  IN UINT64                   Position\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketPosixFileGetPossition (\r
-  IN EFI_FILE_PROTOCOL        *This,\r
-  OUT UINT64                  *Position\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketPosixFileGetInfo (\r
-  IN EFI_FILE_PROTOCOL        *This,\r
-  IN EFI_GUID                 *InformationType,\r
-  IN OUT UINTN                *BufferSize,\r
-  OUT VOID                    *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketPosixFileSetInfo (\r
-  IN EFI_FILE_PROTOCOL        *This,\r
-  IN EFI_GUID                 *InformationType,\r
-  IN UINTN                    BufferSize,\r
-  IN VOID                     *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketPosixFileFlush (\r
-  IN EFI_FILE_PROTOCOL  *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketPosixFileSystmeThunkOpen (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketPosixFileSystmeThunkClose (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketEmuBlockIoReset (\r
-  IN EMU_BLOCK_IO_PROTOCOL    *This,\r
-  IN BOOLEAN                  ExtendedVerification\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketEmuBlockIoReadBlocks (\r
-  IN     EMU_BLOCK_IO_PROTOCOL  *This,\r
-  IN     UINT32                 MediaId,\r
-  IN     EFI_LBA                LBA,\r
-  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
-  IN     UINTN                  BufferSize,\r
-     OUT VOID                   *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketEmuBlockIoWriteBlocks (\r
-  IN     EMU_BLOCK_IO_PROTOCOL  *This,\r
-  IN     UINT32                 MediaId,\r
-  IN     EFI_LBA                LBA,\r
-  IN OUT EFI_BLOCK_IO2_TOKEN    *Token,\r
-  IN     UINTN                  BufferSize,\r
-  IN     VOID                   *Buffer\r
-  );\r
-  \r
-EFI_STATUS\r
-EFIAPI\r
-GasketEmuBlockIoFlushBlocks (\r
-  IN     EMU_BLOCK_IO_PROTOCOL    *This,\r
-  IN OUT EFI_BLOCK_IO2_TOKEN      *Token\r
-  );\r
-  \r
-EFI_STATUS\r
-EFIAPI\r
-GasketEmuBlockIoCreateMapping (\r
-  IN     EMU_BLOCK_IO_PROTOCOL    *This,\r
-  IN     EFI_BLOCK_IO_MEDIA       *Media\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketBlockIoThunkOpen (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketBlockIoThunkClose (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpThunkOpen (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpThunkClose (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpCreateMapping (\r
-  IN     EMU_SNP_PROTOCOL         *This,\r
-  IN     EFI_SIMPLE_NETWORK_MODE  *Media\r
-  );\r
\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpStart (\r
-  IN EMU_SNP_PROTOCOL  *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpStop (\r
-  IN EMU_SNP_PROTOCOL  *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpInitialize (\r
-  IN EMU_SNP_PROTOCOL                    *This,\r
-  IN UINTN                               ExtraRxBufferSize  OPTIONAL,\r
-  IN UINTN                               ExtraTxBufferSize  OPTIONAL\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpReset (\r
-  IN EMU_SNP_PROTOCOL   *This,\r
-  IN BOOLEAN            ExtendedVerification\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpShutdown (\r
-  IN EMU_SNP_PROTOCOL  *This\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpReceiveFilters (\r
-  IN EMU_SNP_PROTOCOL                             *This,\r
-  IN UINT32                                       Enable,\r
-  IN UINT32                                       Disable,\r
-  IN BOOLEAN                                      ResetMCastFilter,\r
-  IN UINTN                                        MCastFilterCnt     OPTIONAL,\r
-  IN EFI_MAC_ADDRESS                              *MCastFilter OPTIONAL\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpStationAddress (\r
-  IN EMU_SNP_PROTOCOL            *This,\r
-  IN BOOLEAN                     Reset,\r
-  IN EFI_MAC_ADDRESS             *New OPTIONAL\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpStatistics (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN BOOLEAN                              Reset,\r
-  IN OUT UINTN                            *StatisticsSize   OPTIONAL,\r
-  OUT EFI_NETWORK_STATISTICS              *StatisticsTable  OPTIONAL\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpMCastIpToMac (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN BOOLEAN                              IPv6,\r
-  IN EFI_IP_ADDRESS                       *IP,\r
-  OUT EFI_MAC_ADDRESS                     *MAC\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpNvData (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN BOOLEAN                              ReadWrite,\r
-  IN UINTN                                Offset,\r
-  IN UINTN                                BufferSize,\r
-  IN OUT VOID                             *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpGetStatus (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  OUT UINT32                              *InterruptStatus OPTIONAL,\r
-  OUT VOID                                **TxBuf OPTIONAL\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpTransmit (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN UINTN                                HeaderSize,\r
-  IN UINTN                                BufferSize,\r
-  IN VOID                                 *Buffer,\r
-  IN EFI_MAC_ADDRESS                      *SrcAddr  OPTIONAL,\r
-  IN EFI_MAC_ADDRESS                      *DestAddr OPTIONAL,\r
-  IN UINT16                               *Protocol OPTIONAL\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSnpReceive (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  OUT UINTN                               *HeaderSize OPTIONAL,\r
-  IN OUT UINTN                            *BufferSize,\r
-  OUT VOID                                *Buffer,\r
-  OUT EFI_MAC_ADDRESS                     *SrcAddr    OPTIONAL,\r
-  OUT EFI_MAC_ADDRESS                     *DestAddr   OPTIONAL,\r
-  OUT UINT16                              *Protocol   OPTIONAL\r
-  );\r
-\r
\r
-#endif\r
-\r
-\r
diff --git a/InOsEmuPkg/Unix/Sec/Ia32/Gasket.S b/InOsEmuPkg/Unix/Sec/Ia32/Gasket.S
deleted file mode 100644 (file)
index aa031ec..0000000
+++ /dev/null
@@ -1,1492 +0,0 @@
-#------------------------------------------------------------------------------
-#
-# Manage differenced between UNIX ABI and EFI/Windows ABI
-#
-# For IA-32 the only difference is Mac OS X requires a 16-byte aligned stack.
-# For Linux this stack adjustment is a no-op, but we may as well make the 
-# the code common. 
-#
-# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
-# 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.
-#
-#------------------------------------------------------------------------------
-
-
-  .text
-  
-//
-// EMU_THUNK_PROTOCOL gaskets (EFIAPI to UNIX ABI)
-//
-
-
-ASM_GLOBAL ASM_PFX(GasketSecWriteStdErr) 
-ASM_PFX(GasketSecWriteStdErr):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call  ASM_PFX(SecWriteStdErr)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecConfigStdIn) 
-ASM_PFX(GasketSecConfigStdIn):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call  ASM_PFX(SecConfigStdIn)
-  
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecWriteStdOut) 
-ASM_PFX(GasketSecWriteStdOut):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call  ASM_PFX(SecWriteStdOut)
-  
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecReadStdIn)  
-ASM_PFX(GasketSecReadStdIn):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call  ASM_PFX(SecReadStdIn)
-  
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecPollStdIn)  
-ASM_PFX(GasketSecPollStdIn):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call  ASM_PFX(SecPollStdIn)
-  
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecMalloc) 
-ASM_PFX(GasketSecMalloc):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(SecMalloc)
-  
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecValloc) 
-ASM_PFX(GasketSecValloc):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(SecValloc)
-  
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecFree) 
-ASM_PFX(GasketSecFree):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(SecFree)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecSetTimer) 
-ASM_PFX(GasketSecSetTimer):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl 16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    8(%ebp), %eax
-       movl    12(%ebp), %edx
-       movl    %edx, 4(%esp)
-       movl    %eax, (%esp)
-
-  call  ASM_PFX(SecSetTimer)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecEnableInterrupt) 
-ASM_PFX(GasketSecEnableInterrupt):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-
-  call    ASM_PFX(SecEnableInterrupt)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecDisableInterrupt) 
-ASM_PFX(GasketSecDisableInterrupt):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-
-  call    ASM_PFX(SecDisableInterrupt)
-  
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketQueryPerformanceFrequency) 
-ASM_PFX(GasketQueryPerformanceFrequency):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-
-  call    ASM_PFX(QueryPerformanceFrequency)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketQueryPerformanceCounter) 
-ASM_PFX(GasketQueryPerformanceCounter):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-
-  call    ASM_PFX(QueryPerformanceCounter)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecSleep) 
-ASM_PFX(GasketSecSleep):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    8(%ebp), %eax
-       movl    12(%ebp), %ecx
-       movl    %ecx, 4(%esp)
-       movl    %eax, (%esp)
-
-  call  ASM_PFX(SecSleep)
-  
-  leave
-  ret
-  
-   
-ASM_GLOBAL ASM_PFX(GasketSecCpuSleep) 
-ASM_PFX(GasketSecCpuSleep):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-
-  call  ASM_PFX(SecCpuSleep)
-  
-  leave
-  ret
-  
-  
-ASM_GLOBAL ASM_PFX(GasketSecExit) 
-ASM_PFX(GasketSecExit):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(SecExit)     // Less to do as we will never return to EFI ABI world
-LDEAD_LOOP:
-  jmp  LDEAD_LOOP              // _exit should never return
-
-  
-ASM_GLOBAL ASM_PFX(GasketSecGetTime) 
-ASM_PFX(GasketSecGetTime):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call  ASM_PFX(SecGetTime)
-
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecSetTime) 
-ASM_PFX(GasketSecSetTime):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call  ASM_PFX(SecSetTime)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecGetNextProtocol) 
-ASM_PFX(GasketSecGetNextProtocol):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(SecGetNextProtocol)
-  
-  leave
-  ret
-
-// PPIs produced by SEC
-
-ASM_GLOBAL ASM_PFX(GasketSecPeCoffGetEntryPoint) 
-ASM_PFX(GasketSecPeCoffGetEntryPoint):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(SecPeCoffGetEntryPoint)
-  
-  leave
-  ret
-ASM_GLOBAL ASM_PFX(GasketSecPeCoffRelocateImageExtraAction) 
-ASM_PFX(GasketSecPeCoffRelocateImageExtraAction):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(SecPeCoffRelocateImageExtraAction)
-  
-  leave
-  ret
-ASM_GLOBAL ASM_PFX(GasketSecPeCoffUnloadImageExtraAction) 
-ASM_PFX(GasketSecPeCoffUnloadImageExtraAction):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(SecPeCoffUnloadImageExtraAction)
-  
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecEmuThunkAddress) 
-ASM_PFX(GasketSecEmuThunkAddress):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-
-  call    ASM_PFX(SecEmuThunkAddress)
-  
-  leave
-  ret
-
-//
-// Gasket functions for EFI_EMU_UGA_IO_PROTOCOL
-//
-
-ASM_GLOBAL ASM_PFX(GasketX11Size) 
-ASM_PFX(GasketX11Size):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(X11Size)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketX11CheckKey) 
-ASM_PFX(GasketX11CheckKey):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(X11CheckKey)
-  
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketX11GetKey) 
-ASM_PFX(GasketX11GetKey):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(X11GetKey)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketX11KeySetState) 
-ASM_PFX(GasketX11KeySetState):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(X11KeySetState)
-  
-  leave
-  ret
-
-  
-ASM_GLOBAL ASM_PFX(GasketX11RegisterKeyNotify) 
-ASM_PFX(GasketX11RegisterKeyNotify):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(X11RegisterKeyNotify)
-  
-  leave
-  ret
-
-  
-ASM_GLOBAL ASM_PFX(GasketX11Blt) 
-ASM_PFX(GasketX11Blt):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(X11Blt)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketX11CheckPointer) 
-ASM_PFX(GasketX11CheckPointer):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(X11CheckPointer)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketX11GetPointerState) 
-ASM_PFX(GasketX11GetPointerState):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(X11GetPointerState)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowOpen) 
-ASM_PFX(GasketX11GraphicsWindowOpen):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(X11GraphicsWindowOpen)
-  
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowClose) 
-ASM_PFX(GasketX11GraphicsWindowClose):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(X11GraphicsWindowClose)
-  
-  leave
-  ret
-
-
-// Pthreads
-
-ASM_GLOBAL ASM_PFX(GasketPthreadMutexLock) 
-ASM_PFX(GasketPthreadMutexLock):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(PthreadMutexLock)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPthreadMutexUnLock) 
-ASM_PFX(GasketPthreadMutexUnLock):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(PthreadMutexUnLock)
-  
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketPthreadMutexTryLock) 
-ASM_PFX(GasketPthreadMutexTryLock):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(PthreadMutexTryLock)
-  
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketPthreadMutexInit) 
-ASM_PFX(GasketPthreadMutexInit):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-
-  call    ASM_PFX(PthreadMutexInit)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPthreadMutexDestroy) 
-ASM_PFX(GasketPthreadMutexDestroy):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(PthreadMutexDestroy)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPthreadCreate)  
-ASM_PFX(GasketPthreadCreate):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(PthreadCreate)
-  
-  leave
-  ret
-
-                          
-ASM_GLOBAL ASM_PFX(GasketPthreadExit) 
-ASM_PFX(GasketPthreadExit):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(PthreadExit)
-  
-  leave
-  ret
-
-
-                             
-ASM_GLOBAL ASM_PFX(GasketPthreadSelf) 
-ASM_PFX(GasketPthreadSelf):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-
-  call    ASM_PFX(PthreadSelf)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPthreadOpen) 
-ASM_PFX(GasketPthreadOpen):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(PthreadOpen)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPthreadClose)  
-ASM_PFX(GasketPthreadClose):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(PthreadClose)
-  
-  leave
-  ret
-
-
-
-
-//
-// UNIX ABI to EFI ABI call
-//
-// UINTN
-// ReverseGasketUint64 (
-//   void *Api,
-//   UINTN Arg1
-//   );
-ASM_GLOBAL ASM_PFX(ReverseGasketUint64)
-ASM_PFX(ReverseGasketUint64):
-       pushl   %ebp
-       movl    %esp, %ebp
-       subl    $8, %esp
-       movl    16(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, (%esp)
-       calll   *8(%ebp)
-       addl    $8, %esp
-       popl    %ebp
-       ret
-
-
-
-//
-// UNIX ABI to EFI ABI call
-//
-// UINTN
-// ReverseGasketUint64Uint64 (
-//   void *Api,
-//   UINTN Arg1
-//   UINTN Arg2
-//   );
-ASM_GLOBAL ASM_PFX(ReverseGasketUint64Uint64)
-ASM_PFX(ReverseGasketUint64Uint64):
-       pushl   %ebp
-       movl    %esp, %ebp
-       subl    $24, %esp
-       movl    24(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    20(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, (%esp)
-       calll   *8(%ebp)
-       addl    $24, %esp
-       popl    %ebp
-       ret
-  
-
-ASM_GLOBAL ASM_PFX(GasketSecUnixPeiAutoScan)  
-ASM_PFX(GasketSecUnixPeiAutoScan):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(SecUnixPeiAutoScan)
-  
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecUnixFdAddress) 
-ASM_PFX(GasketSecUnixFdAddress):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(SecUnixFdAddress)
-
-  leave
-  ret
-
-
-// EmuIoThunk SimpleFileSystem
-
-ASM_GLOBAL ASM_PFX(GasketPosixOpenVolume) 
-ASM_PFX(GasketPosixOpenVolume):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(PosixOpenVolume)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileOpen) 
-ASM_PFX(GasketPosixFileOpen):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $56, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    28(%ebp), %eax
-       movl    32(%ebp), %ecx
-       movl    %ecx, 24(%esp)
-       movl    %eax, 20(%esp)
-       movl    20(%ebp), %eax
-       movl    24(%ebp), %ecx
-       movl    %ecx, 16(%esp)
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-  call    ASM_PFX(PosixFileOpen)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileCLose) 
-ASM_PFX(GasketPosixFileCLose):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(PosixFileCLose)
-
-  leave
-  ret
-
-   
-ASM_GLOBAL ASM_PFX(GasketPosixFileDelete) 
-ASM_PFX(GasketPosixFileDelete):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(PosixFileDelete)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileRead) 
-ASM_PFX(GasketPosixFileRead):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(PosixFileRead)
-
-  leave
-  ret
-
-  
-ASM_GLOBAL ASM_PFX(GasketPosixFileWrite) 
-ASM_PFX(GasketPosixFileWrite):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(PosixFileWrite)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileSetPossition) 
-ASM_PFX(GasketPosixFileSetPossition):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    12(%ebp), %eax
-       movl    16(%ebp), %ecx
-       movl    %ecx, 8(%esp)
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(PosixFileSetPossition)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileGetPossition) 
-ASM_PFX(GasketPosixFileGetPossition):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(PosixFileGetPossition)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileGetInfo) 
-ASM_PFX(GasketPosixFileGetInfo):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(PosixFileGetInfo)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileSetInfo) 
-ASM_PFX(GasketPosixFileSetInfo):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(PosixFileSetInfo)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileFlush) 
-ASM_PFX(GasketPosixFileFlush):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(PosixFileFlush)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkOpen) 
-ASM_PFX(GasketPosixFileSystmeThunkOpen):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(PosixFileSystmeThunkOpen)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkClose) 
-ASM_PFX(GasketPosixFileSystmeThunkClose):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(PosixFileSystmeThunkClose)
-
-  leave
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReset) 
-ASM_PFX(GasketEmuBlockIoReset):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(EmuBlockIoReset)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReadBlocks) 
-ASM_PFX(GasketEmuBlockIoReadBlocks):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $56, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    32(%ebp), %eax
-       movl    %eax, 24(%esp)
-       movl    28(%ebp), %eax
-       movl    %eax, 20(%esp)
-       movl    24(%ebp), %eax
-       movl    %eax, 16(%esp)
-       movl    16(%ebp), %eax
-       movl    20(%ebp), %edx
-       movl    %edx, 12(%esp)
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(EmuBlockIoReadBlocks)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketEmuBlockIoWriteBlocks)  
-ASM_PFX(GasketEmuBlockIoWriteBlocks):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $56, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    32(%ebp), %eax
-       movl    %eax, 24(%esp)
-       movl    28(%ebp), %eax
-       movl    %eax, 20(%esp)
-       movl    24(%ebp), %eax
-       movl    %eax, 16(%esp)
-       movl    16(%ebp), %eax
-       movl    20(%ebp), %edx
-       movl    %edx, 12(%esp)
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(EmuBlockIoWriteBlocks)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketEmuBlockIoFlushBlocks)  
-ASM_PFX(GasketEmuBlockIoFlushBlocks):  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-
-  call    ASM_PFX(EmuBlockIoFlushBlocks)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketEmuBlockIoCreateMapping) 
-ASM_PFX(GasketEmuBlockIoCreateMapping):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(EmuBlockIoCreateMapping)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketBlockIoThunkOpen)  
-ASM_PFX(GasketBlockIoThunkOpen):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(EmuBlockIoThunkOpen)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketBlockIoThunkClose)  
-ASM_PFX(GasketBlockIoThunkClose):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(EmuBlockIoThunkClose)
-
-  leave
-  ret
-
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpCreateMapping) 
-ASM_PFX(GasketSnpCreateMapping):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpCreateMapping)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpStart) 
-ASM_PFX(GasketSnpStart):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpStart)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpStop) 
-ASM_PFX(GasketSnpStop):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpStop)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpInitialize) 
-ASM_PFX(GasketSnpInitialize):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpInitialize)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpReset)  
-ASM_PFX(GasketSnpReset):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  12(%ebp), %eax
-  movl  %eax, 4(%esp)
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpReset)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpShutdown) 
-ASM_PFX(GasketSnpShutdown):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpShutdown)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpReceiveFilters)  
-ASM_PFX(GasketSnpReceiveFilters):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    28(%ebp), %eax
-       movl    %eax, 20(%esp)
-       movl    24(%ebp), %eax
-       movl    %eax, 16(%esp)
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpReceiveFilters)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpStationAddress)  
-ASM_PFX(GasketSnpStationAddress):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  leave
-  ret
-
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpStatistics) 
-ASM_PFX(GasketSnpStatistics):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpStatistics)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpMCastIpToMac) 
-ASM_PFX(GasketSnpMCastIpToMac):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpMCastIpToMac)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpNvData) 
-ASM_PFX(GasketSnpNvData):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    24(%ebp), %eax
-       movl    %eax, 16(%esp)
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpNvData)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpGetStatus) 
-ASM_PFX(GasketSnpGetStatus):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $40, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpGetStatus)
-
-  leave
-  ret
-
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpTransmit) 
-ASM_PFX(GasketSnpTransmit):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $56, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    32(%ebp), %eax
-       movl    %eax, 24(%esp)
-       movl    28(%ebp), %eax
-       movl    %eax, 20(%esp)
-       movl    24(%ebp), %eax
-       movl    %eax, 16(%esp)
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpTransmit)
-
-  leave
-  ret
-
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpReceive) 
-ASM_PFX(GasketSnpReceive):
-       pushl   %ebp
-       movl    %esp, %ebp
-  subl  $56, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-       movl    32(%ebp), %eax
-       movl    %eax, 24(%esp)
-       movl    28(%ebp), %eax
-       movl    %eax, 20(%esp)
-       movl    24(%ebp), %eax
-       movl    %eax, 16(%esp)
-       movl    20(%ebp), %eax
-       movl    %eax, 12(%esp)
-       movl    16(%ebp), %eax
-       movl    %eax, 8(%esp)
-       movl    12(%ebp), %eax
-       movl    %eax, 4(%esp)
-       movl    8(%ebp), %eax
-       movl    %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpReceive)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpThunkOpen) 
-ASM_PFX(GasketSnpThunkOpen):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpThunkOpen)
-
-  leave
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpThunkClose) 
-ASM_PFX(GasketSnpThunkClose):
-  pushl %ebp
-  movl  %esp, %ebp
-  subl  $24, %esp      // sub extra 16 from the stack for alignment
-  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
-  movl  8(%ebp), %eax
-  movl  %eax, (%esp)
-
-  call    ASM_PFX(EmuSnpThunkClose)
-
-  leave
-  ret
-
-
diff --git a/InOsEmuPkg/Unix/Sec/Ia32/SwitchStack.c b/InOsEmuPkg/Unix/Sec/Ia32/SwitchStack.c
deleted file mode 100644 (file)
index c75073a..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*++
-
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
-Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-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 "SecMain.h"
-
-
-/**
-  Transfers control to a function starting with a new stack.
-
-  Transfers control to the function specified by EntryPoint using the new stack
-  specified by NewStack and passing in the parameters specified by Context1 and
-  Context2. Context1 and Context2 are optional and may be NULL. The function
-  EntryPoint must never return.
-
-  If EntryPoint is NULL, then ASSERT().
-  If NewStack is NULL, then ASSERT().
-
-  @param  EntryPoint  A pointer to function to call with the new stack.
-  @param  Context1    A pointer to the context to pass into the EntryPoint
-                      function.
-  @param  Context2    A pointer to the context to pass into the EntryPoint
-                      function.
-  @param  NewStack    A pointer to the new stack to use for the EntryPoint
-                      function.
-
-**/
-VOID
-EFIAPI
-PeiSwitchStacks (
-  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,
-  IN      VOID                      *Context1,  OPTIONAL
-  IN      VOID                      *Context2,  OPTIONAL
-  IN      VOID                      *NewStack
-  )
-{
-  BASE_LIBRARY_JUMP_BUFFER  JumpBuffer;
-  
-  ASSERT (EntryPoint != NULL);
-  ASSERT (NewStack != NULL);
-
-  //
-  // Stack should be aligned with CPU_STACK_ALIGNMENT
-  //
-  ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);
-
-  JumpBuffer.Eip = (UINTN)EntryPoint;
-  JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);
-  JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2);
-  ((VOID**)JumpBuffer.Esp)[1] = Context1;
-  ((VOID**)JumpBuffer.Esp)[2] = Context2;
-
-  LongJump (&JumpBuffer, (UINTN)-1);
-  
-
-  //
-  // PeiSwitchStacks () will never return
-  //
-  ASSERT (FALSE);  
-}
-
-
-
diff --git a/InOsEmuPkg/Unix/Sec/LinuxPacketFilter.c b/InOsEmuPkg/Unix/Sec/LinuxPacketFilter.c
deleted file mode 100644 (file)
index 20a08c9..0000000
+++ /dev/null
@@ -1,604 +0,0 @@
-/**@file\r
- Linux Packet Filter implementation of the EMU_SNP_PROTOCOL that allows the \r
- emulator to get on real networks.\r
-\r
- Currently only the Berkeley Packet Filter is fully implemented and this file\r
- is just a template that needs to get filled in. \r
-\r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portitions copyright (c) 2011, Apple Inc. All rights reserved.\r
-\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
-\r
-**/\r
-\r
-\r
-#include "SecMain.h"\r
-\r
-#ifndef __APPLE__\r
-\r
-#define EMU_SNP_PRIVATE_SIGNATURE SIGNATURE_32('E', 'M', 's', 'n')\r
-typedef struct {\r
-  UINTN                       Signature;\r
-\r
-  EMU_IO_THUNK_PROTOCOL       *Thunk;\r
-\r
-\r
-  EMU_SNP_PROTOCOL            EmuSnp;\r
-  EFI_SIMPLE_NETWORK_MODE     *Mode;\r
-\r
-} EMU_SNP_PRIVATE;\r
-\r
-#define EMU_SNP_PRIVATE_DATA_FROM_THIS(a) \\r
-         CR(a, EMU_SNP_PRIVATE, EmuSnp, EMU_SNP_PRIVATE_SIGNATURE)\r
-\r
-/**\r
-  Register storage for SNP Mode.\r
-\r
-  @param  This Protocol instance pointer.\r
-  @param  Mode SimpleNetworkProtocol Mode structure passed into driver.\r
-\r
-  @retval EFI_SUCCESS           The network interface was started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpCreateMapping (\r
-  IN     EMU_SNP_PROTOCOL         *This,\r
-  IN     EFI_SIMPLE_NETWORK_MODE  *Mode\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  Private->Mode = Mode;\r
-    \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Changes the state of a network interface from "stopped" to "started".\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           The network interface was started.\r
-  @retval EFI_ALREADY_STARTED   The network interface is already in the started state.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpStart (\r
-  IN EMU_SNP_PROTOCOL  *This\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Changes the state of a network interface from "started" to "stopped".\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           The network interface was stopped.\r
-  @retval EFI_ALREADY_STARTED   The network interface is already in the stopped state.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpStop (\r
-  IN EMU_SNP_PROTOCOL  *This\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Resets a network adapter and allocates the transmit and receive buffers \r
-  required by the network interface; optionally, also requests allocation \r
-  of additional transmit and receive buffers.\r
-\r
-  @param  This              The protocol instance pointer.\r
-  @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
-                            that the driver should allocate for the network interface.\r
-                            Some network interfaces will not be able to use the extra\r
-                            buffer, and the caller will not know if it is actually\r
-                            being used.\r
-  @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
-                            that the driver should allocate for the network interface.\r
-                            Some network interfaces will not be able to use the extra\r
-                            buffer, and the caller will not know if it is actually\r
-                            being used.\r
-\r
-  @retval EFI_SUCCESS           The network interface was initialized.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_OUT_OF_RESOURCES  There was not enough memory for the transmit and\r
-                                receive buffers.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpInitialize (\r
-  IN EMU_SNP_PROTOCOL                    *This,\r
-  IN UINTN                               ExtraRxBufferSize  OPTIONAL,\r
-  IN UINTN                               ExtraTxBufferSize  OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Resets a network adapter and re-initializes it with the parameters that were \r
-  provided in the previous call to Initialize().  \r
-\r
-  @param  This                 The protocol instance pointer.\r
-  @param  ExtendedVerification Indicates that the driver may perform a more\r
-                               exhaustive verification operation of the device\r
-                               during reset.\r
-\r
-  @retval EFI_SUCCESS           The network interface was reset.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpReset (\r
-  IN EMU_SNP_PROTOCOL   *This,\r
-  IN BOOLEAN            ExtendedVerification\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Resets a network adapter and leaves it in a state that is safe for \r
-  another driver to initialize.\r
-\r
-  @param  This Protocol instance pointer.\r
-\r
-  @retval EFI_SUCCESS           The network interface was shutdown.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpShutdown (\r
-  IN EMU_SNP_PROTOCOL  *This\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Manages the multicast receive filters of a network interface.\r
-\r
-  @param  This             The protocol instance pointer.\r
-  @param  Enable           A bit mask of receive filters to enable on the network interface.\r
-  @param  Disable          A bit mask of receive filters to disable on the network interface.\r
-  @param  ResetMCastFilter Set to TRUE to reset the contents of the multicast receive\r
-                           filters on the network interface to their default values.\r
-  @param  McastFilterCnt   Number of multicast HW MAC addresses in the new\r
-                           MCastFilter list. This value must be less than or equal to\r
-                           the MCastFilterCnt field of EMU_SNP_MODE. This\r
-                           field is optional if ResetMCastFilter is TRUE.\r
-  @param  MCastFilter      A pointer to a list of new multicast receive filter HW MAC\r
-                           addresses. This list will replace any existing multicast\r
-                           HW MAC address list. This field is optional if\r
-                           ResetMCastFilter is TRUE.\r
-\r
-  @retval EFI_SUCCESS           The multicast receive filter list was updated.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpReceiveFilters (\r
-  IN EMU_SNP_PROTOCOL                             *This,\r
-  IN UINT32                                       Enable,\r
-  IN UINT32                                       Disable,\r
-  IN BOOLEAN                                      ResetMCastFilter,\r
-  IN UINTN                                        MCastFilterCnt     OPTIONAL,\r
-  IN EFI_MAC_ADDRESS                              *MCastFilter OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Modifies or resets the current station address, if supported.\r
-\r
-  @param  This  The protocol instance pointer.\r
-  @param  Reset Flag used to reset the station address to the network interfaces\r
-                permanent address.\r
-  @param  New   The new station address to be used for the network interface.\r
-\r
-  @retval EFI_SUCCESS           The network interfaces station address was updated.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpStationAddress (\r
-  IN EMU_SNP_PROTOCOL            *This,\r
-  IN BOOLEAN                     Reset,\r
-  IN EFI_MAC_ADDRESS             *New OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Resets or collects the statistics on a network interface.\r
-\r
-  @param  This            Protocol instance pointer.\r
-  @param  Reset           Set to TRUE to reset the statistics for the network interface.\r
-  @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On\r
-                          output the size, in bytes, of the resulting table of\r
-                          statistics.\r
-  @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
-                          contains the statistics.\r
-\r
-  @retval EFI_SUCCESS           The statistics were collected from the network interface.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
-                                size needed to hold the statistics is returned in\r
-                                StatisticsSize.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpStatistics (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN BOOLEAN                              Reset,\r
-  IN OUT UINTN                            *StatisticsSize   OPTIONAL,\r
-  OUT EFI_NETWORK_STATISTICS              *StatisticsTable  OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Converts a multicast IP address to a multicast HW MAC address.\r
-\r
-  @param  This The protocol instance pointer.\r
-  @param  IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
-               to FALSE if the multicast IP address is IPv4 [RFC 791].\r
-  @param  IP   The multicast IP address that is to be converted to a multicast\r
-               HW MAC address.\r
-  @param  MAC  The multicast HW MAC address that is to be generated from IP.\r
-\r
-  @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast\r
-                                HW MAC address.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer\r
-                                size needed to hold the statistics is returned in\r
-                                StatisticsSize.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpMCastIpToMac (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN BOOLEAN                              IPv6,\r
-  IN EFI_IP_ADDRESS                       *IP,\r
-  OUT EFI_MAC_ADDRESS                     *MAC\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Performs read and write operations on the NVRAM device attached to a \r
-  network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  ReadWrite  TRUE for read operations, FALSE for write operations.\r
-  @param  Offset     Byte offset in the NVRAM device at which to start the read or\r
-                     write operation. This must be a multiple of NvRamAccessSize and\r
-                     less than NvRamSize.\r
-  @param  BufferSize The number of bytes to read or write from the NVRAM device.\r
-                     This must also be a multiple of NvramAccessSize.\r
-  @param  Buffer     A pointer to the data buffer.\r
-\r
-  @retval EFI_SUCCESS           The NVRAM access was performed.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpNvData (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN BOOLEAN                              ReadWrite,\r
-  IN UINTN                                Offset,\r
-  IN UINTN                                BufferSize,\r
-  IN OUT VOID                             *Buffer\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Reads the current interrupt status and recycled transmit buffer status from \r
-  a network interface.\r
-\r
-  @param  This            The protocol instance pointer.\r
-  @param  InterruptStatus A pointer to the bit mask of the currently active interrupts\r
-                          If this is NULL, the interrupt status will not be read from\r
-                          the device. If this is not NULL, the interrupt status will\r
-                          be read from the device. When the  interrupt status is read,\r
-                          it will also be cleared. Clearing the transmit  interrupt\r
-                          does not empty the recycled transmit buffer array.\r
-  @param  TxBuf           Recycled transmit buffer address. The network interface will\r
-                          not transmit if its internal recycled transmit buffer array\r
-                          is full. Reading the transmit buffer does not clear the\r
-                          transmit interrupt. If this is NULL, then the transmit buffer\r
-                          status will not be read. If there are no transmit buffers to\r
-                          recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
-\r
-  @retval EFI_SUCCESS           The status of the network interface was retrieved.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpGetStatus (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  OUT UINT32                              *InterruptStatus OPTIONAL,\r
-  OUT VOID                                **TxBuf OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Places a packet in the transmit queue of a network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  HeaderSize The size, in bytes, of the media header to be filled in by\r
-                     the Transmit() function. If HeaderSize is non-zero, then it\r
-                     must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
-                     and Protocol parameters must not be NULL.\r
-  @param  BufferSize The size, in bytes, of the entire packet (media header and\r
-                     data) to be transmitted through the network interface.\r
-  @param  Buffer     A pointer to the packet (media header followed by data) to be\r
-                     transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
-                     then the media header in Buffer must already be filled in by the\r
-                     caller. If HeaderSize is non-zero, then the media header will be\r
-                     filled in by the Transmit() function.\r
-  @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter\r
-                     is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
-                     This->Mode->CurrentAddress is used for the source HW MAC address.\r
-  @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this\r
-                     parameter is ignored.\r
-  @param  Protocol   The type of header to build. If HeaderSize is zero, then this\r
-                     parameter is ignored. See RFC 1700, section "Ether Types", for\r
-                     examples.\r
-\r
-  @retval EFI_SUCCESS           The packet was placed on the transmit queue.\r
-  @retval EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval EFI_NOT_READY         The network interface is too busy to accept this transmit request.                      \r
-  @retval EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpTransmit (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  IN UINTN                                HeaderSize,\r
-  IN UINTN                                BufferSize,\r
-  IN VOID                                 *Buffer,\r
-  IN EFI_MAC_ADDRESS                      *SrcAddr  OPTIONAL,\r
-  IN EFI_MAC_ADDRESS                      *DestAddr OPTIONAL,\r
-  IN UINT16                               *Protocol OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Receives a packet from a network interface.\r
-\r
-  @param  This       The protocol instance pointer.\r
-  @param  HeaderSize The size, in bytes, of the media header received on the network\r
-                     interface. If this parameter is NULL, then the media header size\r
-                     will not be returned.\r
-  @param  BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
-                     bytes, of the packet that was received on the network interface.\r
-  @param  Buffer     A pointer to the data buffer to receive both the media header and\r
-                     the data.\r
-  @param  SrcAddr    The source HW MAC address. If this parameter is NULL, the\r
-                     HW MAC source address will not be extracted from the media\r
-                     header.\r
-  @param  DestAddr   The destination HW MAC address. If this parameter is NULL,\r
-                     the HW MAC destination address will not be extracted from the\r
-                     media header.\r
-  @param  Protocol   The media header type. If this parameter is NULL, then the\r
-                     protocol will not be extracted from the media header. See\r
-                     RFC 1700 section "Ether Types" for examples.\r
-\r
-  @retval  EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has\r
-                                 been updated to the number of bytes received.\r
-  @retval  EFI_NOT_STARTED       The network interface has not been started.\r
-  @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit\r
-                                 request.\r
-  @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.\r
-  @retval  EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
-  @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.\r
-  @retval  EFI_UNSUPPORTED       This function is not supported by the network interface.\r
-\r
-**/\r
-EFI_STATUS\r
-EmuSnpReceive (\r
-  IN EMU_SNP_PROTOCOL                     *This,\r
-  OUT UINTN                               *HeaderSize OPTIONAL,\r
-  IN OUT UINTN                            *BufferSize,\r
-  OUT VOID                                *Buffer,\r
-  OUT EFI_MAC_ADDRESS                     *SrcAddr    OPTIONAL,\r
-  OUT EFI_MAC_ADDRESS                     *DestAddr   OPTIONAL,\r
-  OUT UINT16                              *Protocol   OPTIONAL\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE    *Private;\r
-\r
-  Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-\r
-EMU_SNP_PROTOCOL gEmuSnpProtocol = {\r
-  GasketSnpCreateMapping,\r
-  GasketSnpStart,\r
-  GasketSnpStop,\r
-  GasketSnpInitialize,\r
-  GasketSnpReset,\r
-  GasketSnpShutdown,\r
-  GasketSnpReceiveFilters,\r
-  GasketSnpStationAddress,\r
-  GasketSnpStatistics,\r
-  GasketSnpMCastIpToMac,\r
-  GasketSnpNvData,\r
-  GasketSnpGetStatus,\r
-  GasketSnpTransmit,\r
-  GasketSnpReceive\r
-};\r
-\r
-EFI_STATUS\r
-EmuSnpThunkOpen (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE  *Private;\r
-  \r
-  if (This->Private != NULL) {\r
-    return EFI_ALREADY_STARTED;\r
-  }\r
-  \r
-  if (!CompareGuid (This->Protocol, &gEmuSnpProtocolGuid)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  \r
-  Private = malloc (sizeof (EMU_SNP_PRIVATE));\r
-  if (Private == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  \r
-  Private->Signature = EMU_SNP_PRIVATE_SIGNATURE;\r
-  Private->Thunk     = This;\r
-  CopyMem (&Private->EmuSnp, &gEmuSnpProtocol, sizeof (gEmuSnpProtocol));\r
-  \r
-  This->Interface = &Private->EmuSnp;\r
-  This->Private   = Private;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EmuSnpThunkClose (\r
-  IN  EMU_IO_THUNK_PROTOCOL   *This\r
-  )\r
-{\r
-  EMU_SNP_PRIVATE  *Private;\r
-\r
-  if (!CompareGuid (This->Protocol, &gEmuSnpProtocolGuid)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  \r
-  Private = This->Private;\r
-  free (Private);\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
-EMU_IO_THUNK_PROTOCOL gSnpThunkIo = {\r
-  &gEmuSnpProtocolGuid,\r
-  NULL,\r
-  NULL,\r
-  0,\r
-  GasketSnpThunkOpen,\r
-  GasketSnpThunkClose,\r
-  NULL\r
-};\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/Unix/Sec/MemoryAllocationLib.c b/InOsEmuPkg/Unix/Sec/MemoryAllocationLib.c
deleted file mode 100644 (file)
index 76b7271..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*++ @file
-
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
-
-  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 "Base.h"
-#include "Library/BaseMemoryLib.h"
-#include "Library/MemoryAllocationLib.h"
-
-#include <stdlib.h>
-
-/**
-  Allocates a buffer of type EfiBootServicesData.
-
-  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
-  pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is
-  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.
-
-  @param  AllocationSize        The number of bytes to allocate.
-
-  @return A pointer to the allocated buffer or NULL if allocation fails.
-
-**/
-VOID *
-EFIAPI
-AllocatePool (
-  IN UINTN  AllocationSize
-  )
-{
-  return (VOID*) malloc (AllocationSize);
-}
-
-
-/**
-  Allocates and zeros a buffer of type EfiBootServicesData.
-
-  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
-  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a
-  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the
-  request, then NULL is returned.
-
-  @param  AllocationSize        The number of bytes to allocate and zero.
-
-  @return A pointer to the allocated buffer or NULL if allocation fails.
-
-**/
-VOID *
-EFIAPI
-AllocateZeroPool (
-  IN UINTN  AllocationSize
-  )
-{
-  VOID *Buffer;
-
-  Buffer = AllocatePool (AllocationSize);
-  if (Buffer == NULL) {
-    return NULL;
-  }
-
-  ZeroMem (Buffer, AllocationSize);
-
-  return Buffer;
-}
-
-
-/**
-  Reallocates a buffer of type EfiBootServicesData.
-
-  Allocates and zeros the number bytes specified by NewSize from memory of type
-  EfiBootServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and 
-  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and 
-  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.  
-  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not 
-  enough memory remaining to satisfy the request, then NULL is returned.
-  
-  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
-  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
-
-  @param  OldSize        The size, in bytes, of OldBuffer.
-  @param  NewSize        The size, in bytes, of the buffer to reallocate.
-  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional 
-                         parameter that may be NULL.
-
-  @return A pointer to the allocated buffer or NULL if allocation fails.
-
-**/
-VOID *
-EFIAPI
-ReallocatePool (
-  IN UINTN  OldSize,
-  IN UINTN  NewSize,
-  IN VOID   *OldBuffer  OPTIONAL
-  )
-{
-  VOID *NewBuffer;
-
-  NewBuffer = AllocatePool (NewSize);
-  if (NewBuffer == NULL) {
-    return NULL;
-  }
-
-  if (OldBuffer != NULL) {
-    if (OldSize > 0) {
-      CopyMem (NewBuffer, OldBuffer, OldSize);
-    }
-
-    FreePool (OldBuffer);
-  }
-
-  return NewBuffer;
-}
-
-
-/**
-  Frees a buffer that was previously allocated with one of the pool allocation functions in the
-  Memory Allocation Library.
-
-  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the
-  pool allocation services of the Memory Allocation Library.  If it is not possible to free pool
-  resources, then this function will perform no actions.
-  
-  If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
-  then ASSERT().
-
-  @param  Buffer                Pointer to the buffer to free.
-
-**/
-VOID
-EFIAPI
-FreePool (
-  IN VOID   *Buffer
-  )
-{
-  free ((void *) Buffer);
-}
-
diff --git a/InOsEmuPkg/Unix/Sec/PosixFileSystem.c b/InOsEmuPkg/Unix/Sec/PosixFileSystem.c
deleted file mode 100644 (file)
index 3141a3c..0000000
+++ /dev/null
@@ -1,1556 +0,0 @@
-/*++ @file
- POSIX Pthreads to emulate APs and implement threads
-
-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 "SecMain.h"
-
-
-#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'P', 'f', 's')
-
-typedef struct {
-  UINTN                           Signature;
-  EMU_IO_THUNK_PROTOCOL           *Thunk;
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;
-  CHAR8                           *FilePath;
-  CHAR16                          *VolumeLabel;
-  BOOLEAN                         FileHandlesOpen;
-} EMU_SIMPLE_FILE_SYSTEM_PRIVATE;
-
-#define EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \
-  CR (a, \
-      EMU_SIMPLE_FILE_SYSTEM_PRIVATE, \
-      SimpleFileSystem, \
-      EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \
-      )
-
-
-#define EMU_EFI_FILE_PRIVATE_SIGNATURE SIGNATURE_32 ('E', 'P', 'f', 'i')
-
-typedef struct {
-  UINTN                           Signature;
-  EMU_IO_THUNK_PROTOCOL           *Thunk;
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
-  EFI_FILE_PROTOCOL               EfiFile;
-  int                             fd;
-  DIR                             *Dir;
-  BOOLEAN                         IsRootDirectory;
-  BOOLEAN                         IsDirectoryPath;
-  BOOLEAN                         IsOpenedByRead;
-  char                            *FileName;
-  struct dirent                   *Dirent;
-} EMU_EFI_FILE_PRIVATE;
-
-#define EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \
-  CR (a, \
-      EMU_EFI_FILE_PRIVATE, \
-      EfiFile, \
-      EMU_EFI_FILE_PRIVATE_SIGNATURE \
-      )
-
-EFI_STATUS
-PosixFileGetInfo (
-  IN EFI_FILE_PROTOCOL        *This,
-  IN EFI_GUID                 *InformationType,
-  IN OUT UINTN                *BufferSize,
-  OUT VOID                    *Buffer
-  );
-
-EFI_STATUS
-PosixFileSetInfo (
-  IN EFI_FILE_PROTOCOL        *This,
-  IN EFI_GUID                 *InformationType,
-  IN UINTN                    BufferSize,
-  IN VOID                     *Buffer
-  );
-
-
-EFI_FILE_PROTOCOL gPosixFileProtocol = {
-  EFI_FILE_REVISION,
-  GasketPosixFileOpen,
-  GasketPosixFileCLose,
-  GasketPosixFileDelete,
-  GasketPosixFileRead,
-  GasketPosixFileWrite,
-  GasketPosixFileGetPossition,
-  GasketPosixFileSetPossition,
-  GasketPosixFileGetInfo,
-  GasketPosixFileSetInfo,
-  GasketPosixFileFlush
-};
-
-EFI_SIMPLE_FILE_SYSTEM_PROTOCOL gPosixFileSystemProtocol = {
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION,
-  GasketPosixOpenVolume,
-};
-
-
-/**
-  Open the root directory on a volume.
-
-  @param  This Protocol instance pointer.
-  @param  Root Returns an Open file handle for the root directory
-
-  @retval EFI_SUCCESS          The device was opened.
-  @retval EFI_UNSUPPORTED      This volume does not support the file system.
-  @retval EFI_NO_MEDIA         The device has no media.
-  @retval EFI_DEVICE_ERROR     The device reported an error.
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
-  @retval EFI_ACCESS_DENIED    The service denied access to the file.
-  @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
-
-**/
-EFI_STATUS
-PosixOpenVolume (
-  IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL    *This,
-  OUT EFI_FILE_PROTOCOL                 **Root
-  )
-{
-  EFI_STATUS                        Status;
-  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *Private;
-  EMU_EFI_FILE_PRIVATE              *PrivateFile;
-
-  Private     = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (This);
-
-  Status = EFI_OUT_OF_RESOURCES;
-  PrivateFile = malloc (sizeof (EMU_EFI_FILE_PRIVATE));
-  if (PrivateFile == NULL) {
-    goto Done;
-  }
-  
-  PrivateFile->FileName = malloc (AsciiStrSize (Private->FilePath));
-  if (PrivateFile->FileName == NULL) {
-    goto Done;
-  }
-  AsciiStrCpy (PrivateFile->FileName, Private->FilePath);
-  
-  PrivateFile->Signature            = EMU_EFI_FILE_PRIVATE_SIGNATURE;
-  PrivateFile->Thunk                = Private->Thunk;
-  PrivateFile->SimpleFileSystem     = This;
-  PrivateFile->IsRootDirectory      = TRUE;
-  PrivateFile->IsDirectoryPath      = TRUE;
-  PrivateFile->IsOpenedByRead       = TRUE;
-  
-  CopyMem (&PrivateFile->EfiFile, &gPosixFileProtocol, sizeof (EFI_FILE_PROTOCOL));
-
-  PrivateFile->fd                   = -1;
-  PrivateFile->Dir                  = NULL;
-  PrivateFile->Dirent               = NULL;
-  
-  *Root = &PrivateFile->EfiFile;
-
-  PrivateFile->Dir = opendir (PrivateFile->FileName);
-  if (PrivateFile->Dir == NULL) {
-    Status = EFI_ACCESS_DENIED;
-  } else {
-    Status = EFI_SUCCESS;
-  }
-
-Done:
-  if (EFI_ERROR (Status)) {
-    if (PrivateFile != NULL) {
-      if (PrivateFile->FileName != NULL) {
-        free (PrivateFile->FileName);
-      }
-
-      free (PrivateFile);
-    }
-    
-    *Root = NULL;
-  }
-  
-  return Status;
-}
-
-
-EFI_STATUS
-ErrnoToEfiStatus ()
-{
-  switch (errno) {
-  case EACCES:
-    return EFI_ACCESS_DENIED;
-    
-  case EDQUOT:
-  case ENOSPC:
-    return EFI_VOLUME_FULL;
-     
-  default:
-    return EFI_DEVICE_ERROR;      
-  }
-}
-
-VOID
-CutPrefix (
-  IN  CHAR8  *Str,
-  IN  UINTN   Count
-  )
-{
-  CHAR8  *Pointer;
-
-  if (AsciiStrLen (Str) < Count) {
-    ASSERT (0);
-  }
-
-  for (Pointer = Str; *(Pointer + Count); Pointer++) {
-    *Pointer = *(Pointer + Count);
-  }
-
-  *Pointer = *(Pointer + Count);
-}
-
-
-VOID
-PosixSystemTimeToEfiTime (
-  IN  time_t                SystemTime,
-  OUT EFI_TIME              *Time
-  )
-{
-  struct tm *tm;
-
-  tm           = gmtime (&SystemTime);
-  Time->Year   = tm->tm_year;
-  Time->Month  = tm->tm_mon + 1;
-  Time->Day    = tm->tm_mday;
-  Time->Hour   = tm->tm_hour;
-  Time->Minute = tm->tm_min;
-  Time->Second = tm->tm_sec;
-  Time->Nanosecond = 0;
-  
-  Time->TimeZone = timezone;
-  Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0) | (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
-}
-
-
-EFI_STATUS
-UnixSimpleFileSystemFileInfo (
-  EMU_EFI_FILE_PRIVATE            *PrivateFile,
-  IN     CHAR8                    *FileName,
-  IN OUT UINTN                    *BufferSize,
-  OUT    VOID                     *Buffer
-  )
-{
-  EFI_STATUS                  Status;
-  UINTN                       Size;
-  UINTN                       NameSize;
-  UINTN                       ResultSize;
-  EFI_FILE_INFO               *Info;
-  CHAR8                       *RealFileName;
-  CHAR8                       *TempPointer;
-  CHAR16                      *BufferFileName;
-  struct stat                 buf;
-
-  if (FileName != NULL) {
-    RealFileName = FileName;
-  } else if (PrivateFile->IsRootDirectory) {
-    RealFileName = "";
-  } else {
-    RealFileName  = PrivateFile->FileName;
-  }
-
-  TempPointer = RealFileName;
-  while (*TempPointer) {
-    if (*TempPointer == '/') {
-      RealFileName = TempPointer + 1;
-    }
-
-    TempPointer++;
-  }
-
-  Size        = SIZE_OF_EFI_FILE_INFO;
-  NameSize    = AsciiStrSize (RealFileName) * 2;
-  ResultSize  = Size + NameSize;
-
-  if (*BufferSize < ResultSize) {
-    *BufferSize = ResultSize;
-    return EFI_BUFFER_TOO_SMALL;
-  }
-  if (stat (FileName == NULL ? PrivateFile->FileName : FileName, &buf) < 0) {
-    return EFI_DEVICE_ERROR;
-  }
-
-  Status  = EFI_SUCCESS;
-
-  Info    = Buffer;
-  ZeroMem (Info, ResultSize);
-
-  Info->Size          = ResultSize;
-  Info->FileSize      = buf.st_size;
-  Info->PhysicalSize  = MultU64x32 (buf.st_blocks, buf.st_blksize);
-
-  PosixSystemTimeToEfiTime (buf.st_ctime, &Info->CreateTime);
-  PosixSystemTimeToEfiTime (buf.st_atime, &Info->LastAccessTime);
-  PosixSystemTimeToEfiTime (buf.st_mtime, &Info->ModificationTime);
-
-  if (!(buf.st_mode & S_IWUSR)) {
-    Info->Attribute |= EFI_FILE_READ_ONLY;
-  }
-
-  if (S_ISDIR(buf.st_mode)) {
-    Info->Attribute |= EFI_FILE_DIRECTORY;
-  }
-
-
-  BufferFileName = (CHAR16 *)((CHAR8 *) Buffer + Size);
-  while (*RealFileName) {
-    *BufferFileName++ = *RealFileName++;
-  }
-  *BufferFileName = 0;
-
-  *BufferSize = ResultSize;
-  return Status;
-}
-
-BOOLEAN
-IsZero (
-  IN VOID   *Buffer,
-  IN UINTN  Length
-  )
-{
-  if (Buffer == NULL || Length == 0) {
-    return FALSE;
-  }
-
-  if (*(UINT8 *) Buffer != 0) {
-    return FALSE;
-  }
-
-  if (Length > 1) {
-    if (!CompareMem (Buffer, (UINT8 *) Buffer + 1, Length - 1)) {
-      return FALSE;
-    }
-  }
-
-  return TRUE;
-}
-
-
-
-/**
-  Opens a new file relative to the source file's location.
-
-  @param  This       The protocol instance pointer.
-  @param  NewHandle  Returns File Handle for FileName.
-  @param  FileName   Null terminated string. "\", ".", and ".." are supported.
-  @param  OpenMode   Open mode for file.
-  @param  Attributes Only used for EFI_FILE_MODE_CREATE.
-
-  @retval EFI_SUCCESS          The device was opened.
-  @retval EFI_NOT_FOUND        The specified file could not be found on the device.
-  @retval EFI_NO_MEDIA         The device has no media.
-  @retval EFI_MEDIA_CHANGED    The media has changed.
-  @retval EFI_DEVICE_ERROR     The device reported an error.
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
-  @retval EFI_ACCESS_DENIED    The service denied access to the file.
-  @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
-  @retval EFI_VOLUME_FULL      The volume is full.
-
-**/
-EFI_STATUS
-PosixFileOpen (
-  IN EFI_FILE_PROTOCOL        *This,
-  OUT EFI_FILE_PROTOCOL       **NewHandle,
-  IN CHAR16                   *FileName,
-  IN UINT64                   OpenMode,
-  IN UINT64                   Attributes
-  )
-{
-  EFI_FILE_PROTOCOL                 *Root;
-  EMU_EFI_FILE_PRIVATE              *PrivateFile;
-  EMU_EFI_FILE_PRIVATE              *NewPrivateFile;
-  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *PrivateRoot;
-  EFI_STATUS                        Status;
-  CHAR16                            *Src;
-  char                              *Dst;
-  CHAR8                             *RealFileName;
-  char                              *ParseFileName;
-  char                              *GuardPointer;
-  CHAR8                             TempChar;
-  UINTN                             Count;
-  BOOLEAN                           TrailingDash;
-  BOOLEAN                           LoopFinish;
-  UINTN                             InfoSize;
-  EFI_FILE_INFO                     *Info;
-  struct stat                       finfo;
-  int                               res;
-  
-
-  PrivateFile     = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
-  PrivateRoot     = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
-  NewPrivateFile  = NULL;
-  Status          = EFI_OUT_OF_RESOURCES;
-
-  //
-  // BUGBUG: assume an open of root
-  // if current location, return current data
-  //
-  if ((StrCmp (FileName, L"\\") == 0) || 
-      (StrCmp (FileName, L".") == 0 && PrivateFile->IsRootDirectory)) {
-OpenRoot:
-    Status          = PosixOpenVolume (PrivateFile->SimpleFileSystem, &Root);
-    NewPrivateFile  = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (Root);
-    goto Done;
-  }
-
-  TrailingDash = FALSE;
-  if (FileName[StrLen (FileName) - 1] == L'\\') {
-    TrailingDash = TRUE;
-    FileName[StrLen (FileName) - 1]  = 0;
-  }
-
-  //
-  // Attempt to open the file
-  //
-  NewPrivateFile = malloc (sizeof (EMU_EFI_FILE_PRIVATE));
-  if (NewPrivateFile == NULL) {
-    goto Done;
-  }
-
-  CopyMem (NewPrivateFile, PrivateFile, sizeof (EMU_EFI_FILE_PRIVATE));
-
-  NewPrivateFile->FileName = malloc (AsciiStrSize (PrivateFile->FileName) + 1 + StrLen (FileName) + 1);
-  if (NewPrivateFile->FileName == NULL) {
-    goto Done;
-  }
-
-  if (*FileName == L'\\') {
-    AsciiStrCpy (NewPrivateFile->FileName, PrivateRoot->FilePath);
-    // Skip first '\'.
-    Src = FileName + 1;
-  } else {
-    AsciiStrCpy (NewPrivateFile->FileName, PrivateFile->FileName);
-    Src = FileName;
-  }
-  Dst = NewPrivateFile->FileName + AsciiStrLen (NewPrivateFile->FileName);
-  GuardPointer = NewPrivateFile->FileName + AsciiStrLen (PrivateRoot->FilePath);
-  *Dst++ = '/';
-  // Convert unicode to ascii and '\' to '/'
-  while (*Src) {
-    if (*Src == '\\') {
-      *Dst++ = '/';
-    } else {
-      *Dst++ = *Src;
-    }
-    Src++;
-  }
-  *Dst = 0;
-      
-
-  //
-  // Get rid of . and .., except leading . or ..
-  //
-
-  //
-  // GuardPointer protect simplefilesystem root path not be destroyed
-  //
-
-  LoopFinish    = FALSE;
-  while (!LoopFinish) {
-    LoopFinish = TRUE;
-
-    for (ParseFileName = GuardPointer; *ParseFileName; ParseFileName++) {
-      if (*ParseFileName == '.' &&
-          (*(ParseFileName + 1) == 0 || *(ParseFileName + 1) == '/') &&
-          *(ParseFileName - 1) == '/'
-          ) {
-
-        //
-        // cut /.
-        //
-        CutPrefix (ParseFileName - 1, 2);
-        LoopFinish = FALSE;
-        break;
-      }
-
-      if (*ParseFileName == '.' &&
-          *(ParseFileName + 1) == '.' &&
-          (*(ParseFileName + 2) == 0 || *(ParseFileName + 2) == '/') &&
-          *(ParseFileName - 1) == '/'
-          ) {
-
-        ParseFileName--;
-        Count = 3;
-
-        while (ParseFileName != GuardPointer) {
-          ParseFileName--;
-          Count++;
-          if (*ParseFileName == '/') {
-            break;
-          }
-        }
-
-        //
-        // cut /.. and its left directory
-        //
-        CutPrefix (ParseFileName, Count);
-        LoopFinish = FALSE;
-        break;
-      }
-    }
-  }
-
-  if (AsciiStrCmp (NewPrivateFile->FileName, PrivateRoot->FilePath) == 0) {
-    NewPrivateFile->IsRootDirectory = TRUE;
-    free (NewPrivateFile->FileName);
-    free (NewPrivateFile);
-    goto OpenRoot;
-  }
-
-  RealFileName = NewPrivateFile->FileName + AsciiStrLen(NewPrivateFile->FileName) - 1;
-  while (RealFileName > NewPrivateFile->FileName && *RealFileName != '/') {
-    RealFileName--;
-  }
-  
-  TempChar            = *(RealFileName - 1);
-  *(RealFileName - 1) = 0;
-  *(RealFileName - 1) = TempChar;
-
-
-  //
-  // Test whether file or directory
-  //
-  NewPrivateFile->IsRootDirectory = FALSE;
-  NewPrivateFile->fd = -1;
-  NewPrivateFile->Dir = NULL;
-  if (OpenMode & EFI_FILE_MODE_CREATE) {
-    if (Attributes & EFI_FILE_DIRECTORY) {
-      NewPrivateFile->IsDirectoryPath = TRUE;
-    } else {
-      NewPrivateFile->IsDirectoryPath = FALSE;
-    }
-  } else {
-    res = stat (NewPrivateFile->FileName, &finfo);
-    if (res == 0 && S_ISDIR(finfo.st_mode)) {
-      NewPrivateFile->IsDirectoryPath = TRUE;
-    } else {
-      NewPrivateFile->IsDirectoryPath = FALSE;
-    }
-  }
-
-  if (OpenMode & EFI_FILE_MODE_WRITE) {
-    NewPrivateFile->IsOpenedByRead = FALSE;
-  } else {
-    NewPrivateFile->IsOpenedByRead = TRUE;
-  }
-
-  Status = EFI_SUCCESS;
-
-  //
-  // deal with directory
-  //
-  if (NewPrivateFile->IsDirectoryPath) {
-    if ((OpenMode & EFI_FILE_MODE_CREATE)) {
-      //
-      // Create a directory
-      //
-      if (mkdir (NewPrivateFile->FileName, 0777) != 0) {
-        if (errno != EEXIST) {
-          //free (TempFileName);
-          Status = EFI_ACCESS_DENIED;
-          goto Done;
-        }
-      }
-    }
-
-    NewPrivateFile->Dir = opendir (NewPrivateFile->FileName);
-    if (NewPrivateFile->Dir == NULL) {
-      if (errno == EACCES) {
-        Status = EFI_ACCESS_DENIED;
-      } else {
-        Status = EFI_NOT_FOUND;
-      }
-
-      goto Done;
-    }
-
-  } else {
-    //
-    // deal with file
-    //
-    NewPrivateFile->fd = open (
-                          NewPrivateFile->FileName,
-                          ((OpenMode & EFI_FILE_MODE_CREATE) ? O_CREAT : 0) | (NewPrivateFile->IsOpenedByRead ? O_RDONLY : O_RDWR),
-                          0666
-                          );
-    if (NewPrivateFile->fd < 0) {
-      if (errno == ENOENT) {
-        Status = EFI_NOT_FOUND;
-      } else {
-        Status = EFI_ACCESS_DENIED;
-      }
-    }
-  }
-
-  if ((OpenMode & EFI_FILE_MODE_CREATE) && Status == EFI_SUCCESS) {
-    //
-    // Set the attribute
-    //
-    InfoSize  = 0;
-    Info      = NULL;
-    Status    = PosixFileGetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, &InfoSize, Info);
-    if (Status != EFI_BUFFER_TOO_SMALL) {
-      Status = EFI_DEVICE_ERROR;
-      goto Done;
-    }
-    
-    Info = malloc (InfoSize);
-    if (Info == NULL) {
-      goto Done;
-    }
-
-    Status = PosixFileGetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, &InfoSize, Info);
-    if (EFI_ERROR (Status)) {
-      goto Done;
-    }
-
-    Info->Attribute = Attributes;
-    PosixFileSetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, InfoSize, Info);
-    
-    free (Info);
-  }
-
-Done: ;
-  if (TrailingDash) {
-    FileName[StrLen (FileName) + 1]  = 0;
-    FileName[StrLen (FileName)]      = L'\\';
-  }
-
-  if (EFI_ERROR (Status)) {
-    if (NewPrivateFile) {
-      if (NewPrivateFile->FileName) {
-        free (NewPrivateFile->FileName);
-      }
-
-      free (NewPrivateFile);
-    }
-  } else {
-    *NewHandle = &NewPrivateFile->EfiFile;
-  }
-
-  return Status;
-}
-
-
-
-/**
-  Close the file handle
-
-  @param  This          Protocol instance pointer.
-
-  @retval EFI_SUCCESS   The device was opened.
-
-**/
-EFI_STATUS
-PosixFileCLose (
-  IN EFI_FILE_PROTOCOL  *This
-  )
-{
-  EMU_EFI_FILE_PRIVATE *PrivateFile;
-
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
-
-  if (PrivateFile->fd >= 0) {
-    close (PrivateFile->fd);
-  }
-  if (PrivateFile->Dir != NULL) {
-    closedir (PrivateFile->Dir);
-  }
-
-  PrivateFile->fd = -1;
-  PrivateFile->Dir = NULL;
-
-  if (PrivateFile->FileName) {
-    free (PrivateFile->FileName);
-  }
-
-  free (PrivateFile);
-
-  return EFI_SUCCESS;
-}
-
-
-/**
-  Close and delete the file handle.
-
-  @param  This                     Protocol instance pointer.
-                                   
-  @retval EFI_SUCCESS              The device was opened.
-  @retval EFI_WARN_DELETE_FAILURE  The handle was closed but the file was not deleted.
-
-**/
-EFI_STATUS
-PosixFileDelete (
-  IN EFI_FILE_PROTOCOL  *This
-  )
-{
-  EFI_STATUS              Status;
-  EMU_EFI_FILE_PRIVATE   *PrivateFile;
-  
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
-  Status      = EFI_WARN_DELETE_FAILURE;
-
-  if (PrivateFile->IsDirectoryPath) {
-    if (PrivateFile->Dir != NULL) {
-      closedir (PrivateFile->Dir);
-      PrivateFile->Dir = NULL;
-    }
-
-    if (rmdir (PrivateFile->FileName) == 0) {
-      Status = EFI_SUCCESS;
-    }
-  } else {
-    close (PrivateFile->fd);
-    PrivateFile->fd = -1;
-
-    if (!PrivateFile->IsOpenedByRead) {
-      if (!unlink (PrivateFile->FileName)) {
-        Status = EFI_SUCCESS;
-      }
-    }
-  }
-
-  free (PrivateFile->FileName);
-  free (PrivateFile);
-
-  return Status;
-}
-
-
-/**
-  Read data from the file.
-
-  @param  This       Protocol instance pointer.
-  @param  BufferSize On input size of buffer, on output amount of data in buffer.
-  @param  Buffer     The buffer in which data is read.
-
-  @retval EFI_SUCCESS          Data was read.
-  @retval EFI_NO_MEDIA         The device has no media.
-  @retval EFI_DEVICE_ERROR     The device reported an error.
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
-  @retval EFI_BUFFER_TO_SMALL  BufferSize is too small. BufferSize contains required size.
-
-**/
-EFI_STATUS
-PosixFileRead (
-  IN EFI_FILE_PROTOCOL        *This,
-  IN OUT UINTN                *BufferSize,
-  OUT VOID                    *Buffer
-  )
-{
-  EMU_EFI_FILE_PRIVATE    *PrivateFile;
-  EFI_STATUS              Status;
-  int                     Res;
-  UINTN                   Size;
-  UINTN                   NameSize;
-  UINTN                   ResultSize;
-  CHAR8                   *FullFileName;
-
-
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
-
-  if (!PrivateFile->IsDirectoryPath) {
-    if (PrivateFile->fd < 0) {
-      Status = EFI_DEVICE_ERROR;
-      goto Done;
-    }
-
-    Res = read (PrivateFile->fd, Buffer, *BufferSize);
-    if (Res < 0) {
-      Status = EFI_DEVICE_ERROR;
-      goto Done;
-    }
-    *BufferSize = Res;
-    Status = EFI_SUCCESS;
-    goto Done;
-  }
-
-  //
-  // Read on a directory.
-  //
-  if (PrivateFile->Dir == NULL) {
-    Status = EFI_DEVICE_ERROR;
-    goto Done;
-  }
-
-  if (PrivateFile->Dirent == NULL) {
-    PrivateFile->Dirent = readdir (PrivateFile->Dir);
-    if (PrivateFile->Dirent == NULL) {
-      *BufferSize = 0;
-      Status = EFI_SUCCESS;
-      goto Done;
-    }
-  }
-
-  Size        = SIZE_OF_EFI_FILE_INFO;
-  NameSize    = AsciiStrLen (PrivateFile->Dirent->d_name) + 1;
-  ResultSize  = Size + 2 * NameSize;
-
-  if (*BufferSize < ResultSize) {
-    *BufferSize = ResultSize;
-    Status = EFI_BUFFER_TOO_SMALL;
-    goto Done;
-  }
-  Status  = EFI_SUCCESS;
-
-  *BufferSize = ResultSize;
-
-  FullFileName = malloc (AsciiStrLen(PrivateFile->FileName) + 1 + NameSize);
-  if (FullFileName == NULL) {
-    Status = EFI_OUT_OF_RESOURCES;
-    goto Done;  
-  }
-         
-  AsciiStrCpy (FullFileName, PrivateFile->FileName);
-  AsciiStrCat (FullFileName, "/");
-  AsciiStrCat (FullFileName, PrivateFile->Dirent->d_name);
-  Status = UnixSimpleFileSystemFileInfo (
-            PrivateFile,
-            FullFileName,
-            BufferSize,
-            Buffer
-            );
-  free (FullFileName);
-
-  PrivateFile->Dirent = NULL;
-
-Done:
-  return Status;
-}
-
-
-
-/**
-  Write data to a file.
-
-  @param  This       Protocol instance pointer.
-  @param  BufferSize On input size of buffer, on output amount of data in buffer.
-  @param  Buffer     The buffer in which data to write.
-
-  @retval EFI_SUCCESS          Data was written.
-  @retval EFI_UNSUPPORTED      Writes to Open directory are not supported.
-  @retval EFI_NO_MEDIA         The device has no media.
-  @retval EFI_DEVICE_ERROR     The device reported an error.
-  @retval EFI_DEVICE_ERROR     An attempt was made to write to a deleted file.
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
-  @retval EFI_WRITE_PROTECTED  The device is write protected.
-  @retval EFI_ACCESS_DENIED    The file was open for read only.
-  @retval EFI_VOLUME_FULL      The volume is full.
-
-**/
-EFI_STATUS
-PosixFileWrite (
-  IN EFI_FILE_PROTOCOL        *This,
-  IN OUT UINTN                *BufferSize,
-  IN VOID                     *Buffer
-  )
-{
-  EMU_EFI_FILE_PRIVATE  *PrivateFile;
-  int                   Res;
-
-
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
-
-  if (PrivateFile->fd < 0) {
-    return EFI_DEVICE_ERROR;
-  }
-
-  if (PrivateFile->IsDirectoryPath) {
-    return EFI_UNSUPPORTED;
-  }
-
-  if (PrivateFile->IsOpenedByRead) {
-    return EFI_ACCESS_DENIED;
-  }
-
-  Res = write (PrivateFile->fd, Buffer, *BufferSize);
-  if (Res == (UINTN)-1) {
-    return ErrnoToEfiStatus ();
-  }
-  
-  *BufferSize = Res;
-  return EFI_SUCCESS;
-}
-
-
-
-/**
-  Set a files current position
-
-  @param  This            Protocol instance pointer.
-  @param  Position        Byte position from the start of the file.
-                          
-  @retval EFI_SUCCESS     Data was written.
-  @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.
-
-**/
-EFI_STATUS
-PosixFileSetPossition (
-  IN EFI_FILE_PROTOCOL        *This,
-  IN UINT64                   Position
-  )
-{
-  EMU_EFI_FILE_PRIVATE    *PrivateFile;
-  off_t                   Pos;
-
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
-
-  if (PrivateFile->IsDirectoryPath) {
-    if (Position != 0) {
-      return EFI_UNSUPPORTED;
-    }
-
-    if (PrivateFile->Dir == NULL) {
-      return EFI_DEVICE_ERROR;
-    }
-    rewinddir (PrivateFile->Dir);
-    return EFI_SUCCESS;
-  } else {
-    if (Position == (UINT64) -1) {
-      Pos = lseek (PrivateFile->fd, 0, SEEK_END);
-    } else {
-      Pos = lseek (PrivateFile->fd, Position, SEEK_SET);
-    }
-    if (Pos == (off_t)-1) {
-      return ErrnoToEfiStatus ();
-    }
-    return EFI_SUCCESS;
-  }
-}
-
-
-
-/**
-  Get a file's current position
-
-  @param  This            Protocol instance pointer.
-  @param  Position        Byte position from the start of the file.
-                          
-  @retval EFI_SUCCESS     Data was written.
-  @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open..
-
-**/
-EFI_STATUS
-PosixFileGetPossition (
-  IN EFI_FILE_PROTOCOL        *This,
-  OUT UINT64                  *Position
-  )
-{
-  EFI_STATUS            Status;
-  EMU_EFI_FILE_PRIVATE  *PrivateFile;
-  
-  PrivateFile   = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
-
-  if (PrivateFile->IsDirectoryPath) {
-    Status = EFI_UNSUPPORTED;
-  } else {
-    *Position = (UINT64)lseek (PrivateFile->fd, 0, SEEK_CUR);
-    Status = (*Position == (UINT64) -1) ? ErrnoToEfiStatus () : EFI_SUCCESS;
-  }
-
-  return Status;
-}
-
-
-/**
-  Get information about a file.
-
-  @param  This            Protocol instance pointer.
-  @param  InformationType Type of information to return in Buffer.
-  @param  BufferSize      On input size of buffer, on output amount of data in buffer.
-  @param  Buffer          The buffer to return data.
-
-  @retval EFI_SUCCESS          Data was returned.
-  @retval EFI_UNSUPPORTED      InformationType is not supported.
-  @retval EFI_NO_MEDIA         The device has no media.
-  @retval EFI_DEVICE_ERROR     The device reported an error.
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
-  @retval EFI_WRITE_PROTECTED  The device is write protected.
-  @retval EFI_ACCESS_DENIED    The file was open for read only.
-  @retval EFI_BUFFER_TOO_SMALL Buffer was too small; required size returned in BufferSize.
-
-**/
-EFI_STATUS
-PosixFileGetInfo (
-  IN EFI_FILE_PROTOCOL        *This,
-  IN EFI_GUID                 *InformationType,
-  IN OUT UINTN                *BufferSize,
-  OUT VOID                    *Buffer
-  )
-{
-  EFI_STATUS                        Status;
-  EMU_EFI_FILE_PRIVATE              *PrivateFile;
-  EFI_FILE_SYSTEM_INFO              *FileSystemInfoBuffer;
-  int                               UnixStatus;
-  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *PrivateRoot;
-  struct statfs                     buf;
-
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
-  PrivateRoot = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
-
-  Status = EFI_SUCCESS;
-  if (CompareGuid (InformationType, &gEfiFileInfoGuid)) {
-    Status = UnixSimpleFileSystemFileInfo (PrivateFile, NULL, BufferSize, Buffer);
-  } else if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
-    if (*BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel)) {
-      *BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
-      return EFI_BUFFER_TOO_SMALL;
-    }
-
-    UnixStatus = statfs (PrivateFile->FileName, &buf);
-    if (UnixStatus < 0) {
-      return EFI_DEVICE_ERROR;
-    }
-
-    FileSystemInfoBuffer            = (EFI_FILE_SYSTEM_INFO *) Buffer;
-    FileSystemInfoBuffer->Size      = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
-    FileSystemInfoBuffer->ReadOnly  = FALSE;
-
-    //
-    // Succeeded
-    //
-    FileSystemInfoBuffer->VolumeSize  = MultU64x32 (buf.f_blocks, buf.f_bsize);
-    FileSystemInfoBuffer->FreeSpace   = MultU64x32 (buf.f_bavail, buf.f_bsize);
-    FileSystemInfoBuffer->BlockSize   = buf.f_bsize;
-
-
-    StrCpy ((CHAR16 *) FileSystemInfoBuffer->VolumeLabel, PrivateRoot->VolumeLabel);
-    *BufferSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel);
-    
-  } else if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
-    if (*BufferSize < StrSize (PrivateRoot->VolumeLabel)) {
-      *BufferSize = StrSize (PrivateRoot->VolumeLabel);
-      return EFI_BUFFER_TOO_SMALL;
-    }
-
-    StrCpy ((CHAR16 *) Buffer, PrivateRoot->VolumeLabel);
-    *BufferSize = StrSize (PrivateRoot->VolumeLabel);
-
-  }
-
-  return Status;
-}
-
-
-/**
-  Set information about a file
-
-  @param  File            Protocol instance pointer.
-  @param  InformationType Type of information in Buffer.
-  @param  BufferSize      Size of buffer.
-  @param  Buffer          The data to write.
-
-  @retval EFI_SUCCESS          Data was returned.
-  @retval EFI_UNSUPPORTED      InformationType is not supported.
-  @retval EFI_NO_MEDIA         The device has no media.
-  @retval EFI_DEVICE_ERROR     The device reported an error.
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
-  @retval EFI_WRITE_PROTECTED  The device is write protected.
-  @retval EFI_ACCESS_DENIED    The file was open for read only.
-
-**/
-EFI_STATUS
-PosixFileSetInfo (
-  IN EFI_FILE_PROTOCOL        *This,
-  IN EFI_GUID                 *InformationType,
-  IN UINTN                    BufferSize,
-  IN VOID                     *Buffer
-  )
-{
-  EMU_SIMPLE_FILE_SYSTEM_PRIVATE    *PrivateRoot;
-  EMU_EFI_FILE_PRIVATE              *PrivateFile;
-  EFI_FILE_INFO                     *OldFileInfo;
-  EFI_FILE_INFO                     *NewFileInfo;
-  EFI_STATUS                        Status;
-  UINTN                             OldInfoSize;
-  mode_t                            NewAttr;
-  struct stat                       OldAttr;
-  CHAR8                             *OldFileName;
-  CHAR8                             *NewFileName;
-  CHAR8                             *CharPointer;
-  BOOLEAN                           AttrChangeFlag;
-  BOOLEAN                           NameChangeFlag;
-  BOOLEAN                           SizeChangeFlag;
-  BOOLEAN                           TimeChangeFlag;
-  struct tm                         NewLastAccessSystemTime;
-  struct tm                         NewLastWriteSystemTime;
-  EFI_FILE_SYSTEM_INFO              *NewFileSystemInfo;
-  CHAR8                             *AsciiFilePtr;
-  CHAR16                            *UnicodeFilePtr;
-  int                               UnixStatus;
-  struct utimbuf                    Utime;
-  
-
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
-  PrivateRoot = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (PrivateFile->SimpleFileSystem);
-  errno       = 0;
-  Status      = EFI_UNSUPPORTED;
-  OldFileInfo = NewFileInfo = NULL;
-  OldFileName = NewFileName = NULL;
-  AttrChangeFlag = NameChangeFlag = SizeChangeFlag = TimeChangeFlag = FALSE;
-
-  //
-  // Set file system information.
-  //
-  if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
-    if (BufferSize < (SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel))) {
-      Status = EFI_BAD_BUFFER_SIZE;
-      goto Done;
-    }
-
-    NewFileSystemInfo = (EFI_FILE_SYSTEM_INFO *) Buffer;
-
-    free (PrivateRoot->VolumeLabel);
-
-    PrivateRoot->VolumeLabel = malloc (StrSize (NewFileSystemInfo->VolumeLabel));
-    if (PrivateRoot->VolumeLabel == NULL) {
-      goto Done;
-    }
-
-    StrCpy (PrivateRoot->VolumeLabel, NewFileSystemInfo->VolumeLabel);
-
-    Status = EFI_SUCCESS;
-    goto Done;
-  }
-
-  //
-  // Set volume label information.
-  //
-  if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
-    if (BufferSize < StrSize (PrivateRoot->VolumeLabel)) {
-      Status = EFI_BAD_BUFFER_SIZE;
-      goto Done;
-    }
-
-    StrCpy (PrivateRoot->VolumeLabel, (CHAR16 *) Buffer);
-
-    Status = EFI_SUCCESS;
-    goto Done;
-  }
-
-  if (!CompareGuid (InformationType, &gEfiFileInfoGuid)) {
-    Status = EFI_UNSUPPORTED;
-    goto Done;
-  }
-
-  if (BufferSize < SIZE_OF_EFI_FILE_INFO) {
-    Status = EFI_BAD_BUFFER_SIZE;
-    goto Done;
-  }
-
-  //
-  // Set file/directory information.
-  //
-
-  //
-  // Check for invalid set file information parameters.
-  //
-  NewFileInfo = (EFI_FILE_INFO *) Buffer;
-  if (NewFileInfo->Size <= sizeof (EFI_FILE_INFO) ||
-      (NewFileInfo->Attribute &~(EFI_FILE_VALID_ATTR)) ||
-      (sizeof (UINTN) == 4 && NewFileInfo->Size > 0xFFFFFFFF)
-      ) {
-    Status = EFI_INVALID_PARAMETER;
-    goto Done;
-  }
-
-  //
-  // Get current file information so we can determine what kind
-  // of change request this is.
-  //
-  OldInfoSize = 0;
-  Status = UnixSimpleFileSystemFileInfo (PrivateFile, NULL, &OldInfoSize, NULL);
-  if (Status != EFI_BUFFER_TOO_SMALL) {
-    Status = EFI_DEVICE_ERROR;
-    goto Done;
-  }
-
-  OldFileInfo = malloc (OldInfoSize);
-  if (OldFileInfo == NULL) {
-    goto Done;
-  }
-
-  Status = UnixSimpleFileSystemFileInfo (PrivateFile, NULL, &OldInfoSize, OldFileInfo);
-  if (EFI_ERROR (Status)) {
-    goto Done;
-  }
-
-  OldFileName = malloc (AsciiStrSize (PrivateFile->FileName));
-  if (OldFileInfo == NULL) {
-    goto Done;
-  }
-
-  AsciiStrCpy (OldFileName, PrivateFile->FileName);
-
-  //
-  // Make full pathname from new filename and rootpath.
-  //
-  if (NewFileInfo->FileName[0] == '\\') {
-    NewFileName = malloc (AsciiStrLen (PrivateRoot->FilePath) + 1 + StrLen (NewFileInfo->FileName) + 1);
-    if (NewFileName == NULL) {
-      goto Done;
-    }
-
-    AsciiStrCpy (NewFileName, PrivateRoot->FilePath);
-    AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName);
-    UnicodeFilePtr = NewFileInfo->FileName + 1;
-    *AsciiFilePtr++ ='/';
-  } else {
-    NewFileName = malloc (AsciiStrLen (PrivateFile->FileName) + 2 + StrLen (NewFileInfo->FileName) + 1);
-    if (NewFileName == NULL) {
-      goto Done;
-    }
-
-    AsciiStrCpy (NewFileName, PrivateRoot->FilePath);
-    AsciiFilePtr = NewFileName + AsciiStrLen(NewFileName);
-    if ((AsciiFilePtr[-1] != '/') && (NewFileInfo->FileName[0] != '/')) {
-      // make sure there is a / between Root FilePath and NewFileInfo Filename
-      AsciiFilePtr[0] = '/';      
-      AsciiFilePtr[1] = '\0';
-      AsciiFilePtr++;
-    }
-    UnicodeFilePtr = NewFileInfo->FileName;
-  }
-  // Convert to ascii.
-  while (*UnicodeFilePtr) {
-    *AsciiFilePtr++ = *UnicodeFilePtr++;
-  }
-  *AsciiFilePtr = 0;
-
-  //
-  // Is there an attribute change request?
-  //
-  if (NewFileInfo->Attribute != OldFileInfo->Attribute) {
-    if ((NewFileInfo->Attribute & EFI_FILE_DIRECTORY) != (OldFileInfo->Attribute & EFI_FILE_DIRECTORY)) {
-      Status = EFI_INVALID_PARAMETER;
-      goto Done;
-    }
-
-    AttrChangeFlag = TRUE;
-  }
-
-  //
-  // Is there a name change request?
-  // bugbug: - Should really use EFI_UNICODE_COLLATION_PROTOCOL
-  //
-  if (StrCmp (NewFileInfo->FileName, OldFileInfo->FileName)) {
-    NameChangeFlag = TRUE;
-  }
-
-  //
-  // Is there a size change request?
-  //
-  if (NewFileInfo->FileSize != OldFileInfo->FileSize) {
-    SizeChangeFlag = TRUE;
-  }
-
-  //
-  // Is there a time stamp change request?
-  //
-  if (!IsZero (&NewFileInfo->CreateTime, sizeof (EFI_TIME)) &&
-      CompareMem (&NewFileInfo->CreateTime, &OldFileInfo->CreateTime, sizeof (EFI_TIME))
-      ) {
-    TimeChangeFlag = TRUE;
-  } else if (!IsZero (&NewFileInfo->LastAccessTime, sizeof (EFI_TIME)) &&
-             CompareMem (&NewFileInfo->LastAccessTime, &OldFileInfo->LastAccessTime, sizeof (EFI_TIME))
-             ) {
-    TimeChangeFlag = TRUE;
-  } else if (!IsZero (&NewFileInfo->ModificationTime, sizeof (EFI_TIME)) &&
-             CompareMem (&NewFileInfo->ModificationTime, &OldFileInfo->ModificationTime, sizeof (EFI_TIME))
-             ) {
-    TimeChangeFlag = TRUE;
-  }
-
-  //
-  // All done if there are no change requests being made.
-  //
-  if (!(AttrChangeFlag || NameChangeFlag || SizeChangeFlag || TimeChangeFlag)) {
-    Status = EFI_SUCCESS;
-    goto Done;
-  }
-
-  //
-  // Set file or directory information.
-  //
-  if (stat (OldFileName, &OldAttr) != 0) {
-    Status = ErrnoToEfiStatus ();
-    goto Done;
-  }
-
-  //
-  // Name change.
-  //
-  if (NameChangeFlag) {
-    //
-    // Close the handles first
-    //
-    if (PrivateFile->IsOpenedByRead) {
-      Status = EFI_ACCESS_DENIED;
-      goto Done;
-    }
-
-    for (CharPointer = NewFileName; *CharPointer != 0 && *CharPointer != L'/'; CharPointer++) {
-    }
-
-    if (*CharPointer != 0) {
-      Status = EFI_ACCESS_DENIED;
-      goto Done;
-    }
-
-    UnixStatus = rename (OldFileName, NewFileName);
-    if (UnixStatus == 0) {
-      //
-      // modify file name
-      //
-      free (PrivateFile->FileName);
-
-      PrivateFile->FileName = malloc (AsciiStrSize (NewFileName));
-      if (PrivateFile->FileName == NULL) {
-        goto Done;
-      }
-
-      AsciiStrCpy (PrivateFile->FileName, NewFileName);
-    } else {
-      Status    = EFI_DEVICE_ERROR;
-      goto Done;
-    }
-  }
-
-  //
-  //  Size change
-  //
-  if (SizeChangeFlag) {
-    if (PrivateFile->IsDirectoryPath) {
-      Status = EFI_UNSUPPORTED;
-      goto Done;
-    }
-
-    if (PrivateFile->IsOpenedByRead || OldFileInfo->Attribute & EFI_FILE_READ_ONLY) {
-      Status = EFI_ACCESS_DENIED;
-      goto Done;
-    }
-
-    if (ftruncate (PrivateFile->fd, NewFileInfo->FileSize) != 0) {
-      Status = ErrnoToEfiStatus ();
-      goto Done;
-    }
-
-  }
-
-  //
-  // Time change
-  //
-  if (TimeChangeFlag) {
-    NewLastAccessSystemTime.tm_year    = NewFileInfo->LastAccessTime.Year;
-    NewLastAccessSystemTime.tm_mon     = NewFileInfo->LastAccessTime.Month;
-    NewLastAccessSystemTime.tm_mday    = NewFileInfo->LastAccessTime.Day;
-    NewLastAccessSystemTime.tm_hour    = NewFileInfo->LastAccessTime.Hour;
-    NewLastAccessSystemTime.tm_min     = NewFileInfo->LastAccessTime.Minute;
-    NewLastAccessSystemTime.tm_sec     = NewFileInfo->LastAccessTime.Second;
-    NewLastAccessSystemTime.tm_isdst   = 0;
-
-    Utime.actime = mktime (&NewLastAccessSystemTime);
-
-    NewLastWriteSystemTime.tm_year    = NewFileInfo->ModificationTime.Year;
-    NewLastWriteSystemTime.tm_mon     = NewFileInfo->ModificationTime.Month;
-    NewLastWriteSystemTime.tm_mday    = NewFileInfo->ModificationTime.Day;
-    NewLastWriteSystemTime.tm_hour    = NewFileInfo->ModificationTime.Hour;
-    NewLastWriteSystemTime.tm_min     = NewFileInfo->ModificationTime.Minute;
-    NewLastWriteSystemTime.tm_sec     = NewFileInfo->ModificationTime.Second;
-    NewLastWriteSystemTime.tm_isdst   = 0;
-
-    Utime.modtime = mktime (&NewLastWriteSystemTime);
-
-    if (Utime.actime == (time_t)-1 || Utime.modtime == (time_t)-1) {
-      goto Done;
-    }
-
-    if (utime (PrivateFile->FileName, &Utime) == -1) {
-      Status = ErrnoToEfiStatus ();
-      goto Done;
-    }
-  }
-
-  //
-  // No matter about AttrChangeFlag, Attribute must be set.
-  // Because operation before may cause attribute change.
-  //
-  NewAttr = OldAttr.st_mode;
-
-  if (NewFileInfo->Attribute & EFI_FILE_READ_ONLY) {
-    NewAttr &= ~(S_IRUSR | S_IRGRP | S_IROTH);
-  } else {
-    NewAttr |= S_IRUSR;
-  }
-
-  if (chmod (NewFileName, NewAttr) != 0) {
-    Status = ErrnoToEfiStatus ();
-  }
-
-Done:
-  if (OldFileInfo != NULL) {
-    free (OldFileInfo);
-  }
-
-  if (OldFileName != NULL) {
-    free (OldFileName);
-  }
-
-  if (NewFileName != NULL) {
-    free (NewFileName);
-  }
-
-  return Status;
-}
-
-
-/**
-  Flush data back for the file handle.
-
-  @param  This Protocol instance pointer.
-
-  @retval EFI_SUCCESS          Data was written.
-  @retval EFI_UNSUPPORTED      Writes to Open directory are not supported.
-  @retval EFI_NO_MEDIA         The device has no media.
-  @retval EFI_DEVICE_ERROR     The device reported an error.
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
-  @retval EFI_WRITE_PROTECTED  The device is write protected.
-  @retval EFI_ACCESS_DENIED    The file was open for read only.
-  @retval EFI_VOLUME_FULL      The volume is full.
-
-**/
-EFI_STATUS
-PosixFileFlush (
-  IN EFI_FILE_PROTOCOL  *This
-  )
-{
-  EMU_EFI_FILE_PRIVATE     *PrivateFile;
-
-  
-  PrivateFile = EMU_EFI_FILE_PRIVATE_DATA_FROM_THIS (This);
-
-  if (PrivateFile->IsDirectoryPath) {
-    return EFI_UNSUPPORTED;
-  }
-
-  if (PrivateFile->IsOpenedByRead) {
-    return EFI_ACCESS_DENIED;
-  }
-
-  if (PrivateFile->fd < 0) {
-    return EFI_DEVICE_ERROR;
-  }
-
-  if (fsync (PrivateFile->fd) != 0) {
-    return ErrnoToEfiStatus ();
-  }
-
-  return EFI_SUCCESS;
-}
-
-
-
-EFI_STATUS
-PosixFileSystmeThunkOpen (
-  IN  EMU_IO_THUNK_PROTOCOL   *This
-  )
-{
-  EMU_SIMPLE_FILE_SYSTEM_PRIVATE  *Private;
-  UINTN                           i;
-  
-  if (This->Private != NULL) {
-    return EFI_ALREADY_STARTED;
-  }
-  
-  if (!CompareGuid (This->Protocol, &gEfiSimpleFileSystemProtocolGuid)) {
-    return EFI_UNSUPPORTED;
-  }
-  
-  Private = malloc (sizeof (EMU_SIMPLE_FILE_SYSTEM_PRIVATE));
-  if (Private == NULL) {
-    return EFI_OUT_OF_RESOURCES;
-  }
-
-  Private->FilePath = malloc (StrLen (This->ConfigString) + 1);
-  if (Private->FilePath == NULL) {
-    free (Private);
-    return EFI_OUT_OF_RESOURCES;    
-  }
-  
-  // Convert Unicode to Ascii
-  for (i = 0; This->ConfigString[i] != 0; i++) {
-    Private->FilePath[i] = This->ConfigString[i];
-  }
-  Private->FilePath[i] = 0;
-
-
-  Private->VolumeLabel = malloc (StrSize (L"EFI_EMULATED"));
-  if (Private->VolumeLabel == NULL) {
-    free (Private->FilePath);
-    free (Private);
-    return EFI_OUT_OF_RESOURCES;
-  }
-  StrCpy (Private->VolumeLabel, L"EFI_EMULATED");
-  
-  Private->Signature = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE;
-  Private->Thunk     = This;
-  CopyMem (&Private->SimpleFileSystem, &gPosixFileSystemProtocol, sizeof (Private->SimpleFileSystem));
-  Private->FileHandlesOpen = FALSE;
-  This->Interface = &Private->SimpleFileSystem;
-  This->Private   = Private;
-  return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-PosixFileSystmeThunkClose (
-  IN  EMU_IO_THUNK_PROTOCOL   *This
-  )
-{
-  EMU_SIMPLE_FILE_SYSTEM_PRIVATE  *Private;
-
-  if (!CompareGuid (This->Protocol, &gEfiSimpleFileSystemProtocolGuid)) {
-    return EFI_UNSUPPORTED;
-  }
-  
-  Private = This->Private;
-  
-  if (Private->FileHandlesOpen) {
-    //
-    // Close only supported if all the EFI_FILE_HANDLEs have been closed.
-    //
-    return EFI_NOT_READY;
-  }
-
-  if (This->Private != NULL) {
-    if (Private->VolumeLabel != NULL) {
-      free (Private->VolumeLabel);
-    }   
-    free (This->Private);
-    This->Private = NULL;
-  }
-  
-  return EFI_SUCCESS;
-}
-
-
-EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo = {
-  &gEfiSimpleFileSystemProtocolGuid,
-  NULL,
-  NULL,
-  0,
-  GasketPosixFileSystmeThunkOpen,
-  GasketPosixFileSystmeThunkClose,
-  NULL
-};
-
-
diff --git a/InOsEmuPkg/Unix/Sec/Pthreads.c b/InOsEmuPkg/Unix/Sec/Pthreads.c
deleted file mode 100644 (file)
index b6b6ae8..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/*++ @file
- POSIX Pthreads to emulate APs and implement threads
-
-Copyright (c) 2011, Apple Inc. All rights reserved.
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
-
-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 "SecMain.h"
-#include <pthread.h>
-
-
-UINTN
-EFIAPI
-PthreadMutexLock (
-  IN VOID *Mutex
-  )
-{
-  return (UINTN)pthread_mutex_lock ((pthread_mutex_t *)Mutex);
-}
-
-
-
-UINTN
-EFIAPI
-PthreadMutexUnLock (
-  IN VOID *Mutex
-  )                        
-{
-  return (UINTN)pthread_mutex_unlock ((pthread_mutex_t *)Mutex);
-}
-
-UINTN
-EFIAPI
-PthreadMutexTryLock (
-  IN VOID *Mutex
-  )                      
-{
-  return (UINTN)pthread_mutex_trylock ((pthread_mutex_t *)Mutex);
-}
-
-
-VOID *
-PthreadMutexInit (
-  IN VOID
-  )
-{
-  pthread_mutex_t *Mutex;
-  int             err;
-  
-  Mutex = malloc (sizeof (pthread_mutex_t));
-  err = pthread_mutex_init (Mutex, NULL);
-  if (err == 0) {
-    return Mutex;
-  }
-  
-  return NULL;
-}
-
-
-UINTN
-PthreadMutexDestroy (
-  IN VOID *Mutex
-  )
-{
-  if (Mutex != NULL) {
-    return pthread_mutex_destroy ((pthread_mutex_t *)Mutex);
-  }
-  
-  return -1;
-}
-
-// Can't store this data on PthreadCreate stack so we need a global
-typedef struct {
-  pthread_mutex_t             Mutex;
-  THREAD_THUNK_THREAD_ENTRY   Start;
-} THREAD_MANGLE;
-
-THREAD_MANGLE mThreadMangle = {
-  PTHREAD_MUTEX_INITIALIZER,
-  NULL
-};
-
-VOID *
-SecFakePthreadStart (
-  VOID  *Context
-  )
-{
-  THREAD_THUNK_THREAD_ENTRY Start;
-  sigset_t                  SigMask;
-  
-  // Save global on the stack before we unlock
-  Start   = mThreadMangle.Start;
-  pthread_mutex_unlock (&mThreadMangle.Mutex);
-  
-  // Mask all signals to the APs
-  sigfillset (&SigMask); 
-  pthread_sigmask (SIG_BLOCK, &SigMask, NULL);
-  
-  //
-  // We have to start the thread in SEC as we need to follow
-  // OS X calling conventions. We can then call back into 
-  // to the callers Start.
-  //
-  // This is a great example of how all problems in computer 
-  // science can be solved by adding another level of indirection
-  //
- return  (VOID *)ReverseGasketUint64 ((CALL_BACK)Start, (UINTN)Context);
-}
-  
-UINTN
-PthreadCreate (
-  IN  VOID                      *Thread,
-  IN  VOID                      *Attribute,
-  IN  THREAD_THUNK_THREAD_ENTRY Start,
-  IN  VOID                      *Context
-  )
-{
-  int         err;
-  BOOLEAN     EnabledOnEntry;    
-  
-  //
-  // Threads inherit interrupt state so disable interrupts before we start thread
-  //
-  if (SecInterruptEanbled ()) {
-    SecDisableInterrupt ();
-    EnabledOnEntry = TRUE;
-  } else {
-    EnabledOnEntry = FALSE;
-  }
-  
-  // Aquire lock for global, SecFakePthreadStart runs in a different thread.
-  pthread_mutex_lock (&mThreadMangle.Mutex);
-  mThreadMangle.Start   = Start;
-  
-  err = pthread_create (Thread, Attribute, SecFakePthreadStart, Context);
-  if (err != 0) {
-    // Thread failed to launch so release the lock;
-    pthread_mutex_unlock (&mThreadMangle.Mutex);
-  }
-  
-  if (EnabledOnEntry) {
-    // Restore interrupt state
-    SecEnableInterrupt ();
-  }    
-
-  return err;
-}
-
-
-VOID
-PthreadExit (
-  IN VOID *ValuePtr
-  )
-{ 
-  pthread_exit (ValuePtr);
-  return;
-}
-
-   
-UINTN
-PthreadSelf (
-  VOID
-  )
-{
-  // POSIX currently allows pthread_t to be a structure or arithmetic type.
-  // Check out sys/types.h to make sure this will work if you are porting. 
-  // On OS X (Darwin) pthread_t is a pointer to a structure so this code works.
-  return (UINTN)pthread_self (); 
-}
-
-
-EMU_THREAD_THUNK_PROTOCOL gPthreadThunk = {
-  GasketPthreadMutexLock,
-  GasketPthreadMutexUnLock,
-  GasketPthreadMutexTryLock,
-  GasketPthreadMutexInit,
-  GasketPthreadMutexDestroy,
-  GasketPthreadCreate,
-  GasketPthreadExit,
-  GasketPthreadSelf
-};
-
-
-EFI_STATUS
-PthreadOpen (
-  IN  EMU_IO_THUNK_PROTOCOL   *This
-  )
-{
-  if (This->Instance != 0) {
-    // Only single instance is supported
-    return EFI_NOT_FOUND;
-  }
-  
-  if (This->ConfigString[0] == L'0') {
-    // If AP count is zero no need for threads
-    return EFI_NOT_FOUND;
-  }
-  
-  This->Interface = &gPthreadThunk;
-  
-  return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-PthreadClose (
-  IN  EMU_IO_THUNK_PROTOCOL   *This
-  )
-{
-  return EFI_SUCCESS;
-}
-
-
-EMU_IO_THUNK_PROTOCOL gPthreadThunkIo = {
-  &gEmuThreadThunkProtocolGuid,
-  NULL,
-  NULL,
-  0,
-  GasketPthreadOpen,
-  GasketPthreadClose,
-  NULL
-};
-
-
diff --git a/InOsEmuPkg/Unix/Sec/SecMain.c b/InOsEmuPkg/Unix/Sec/SecMain.c
deleted file mode 100644 (file)
index 2806347..0000000
+++ /dev/null
@@ -1,1226 +0,0 @@
-/*++ @file
-
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
-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 "SecMain.h"
-
-#ifdef __APPLE__
-#define MAP_ANONYMOUS MAP_ANON
-#endif
-
-
-//
-// Globals
-//
-
-EMU_THUNK_PPI mSecEmuThunkPpi = {
-  GasketSecUnixPeiAutoScan,
-  GasketSecUnixFdAddress,
-  GasketSecEmuThunkAddress
-};
-
-char *gGdbWorkingFileName = NULL;
-unsigned int mScriptSymbolChangesCount = 0;
-
-
-//
-// Default information about where the FD is located.
-//  This array gets filled in with information from EFI_FIRMWARE_VOLUMES
-//  EFI_FIRMWARE_VOLUMES is a host environment variable set by system.cmd.
-//  The number of array elements is allocated base on parsing
-//  EFI_FIRMWARE_VOLUMES and the memory is never freed.
-//
-UINTN       gFdInfoCount = 0;
-EMU_FD_INFO *gFdInfo;
-
-//
-// Array that supports seperate memory rantes.
-//  The memory ranges are set in system.cmd via the EFI_MEMORY_SIZE variable.
-//  The number of array elements is allocated base on parsing
-//  EFI_MEMORY_SIZE and the memory is never freed.
-//
-UINTN              gSystemMemoryCount = 0;
-EMU_SYSTEM_MEMORY  *gSystemMemory;
-
-
-
-UINTN                        mImageContextModHandleArraySize = 0;
-IMAGE_CONTEXT_TO_MOD_HANDLE  *mImageContextModHandleArray = NULL;
-
-EFI_PEI_PPI_DESCRIPTOR  *gPpiList;
-
-
-int gInXcode = 0;
-
-
-/*++
-  Breakpoint target for Xcode project. Set in the Xcode XML
-  
-  Xcode breakpoint will 'source SecMain.gdb'
-  gGdbWorkingFileName is set to SecMain.gdb
-
-**/
-VOID
-SecGdbConfigBreak (
-  VOID
-  )
-{
-}
-
-
-
-/*++
-
-Routine Description:
-  Main entry point to SEC for Unix. This is a unix program
-
-Arguments:
-  Argc - Number of command line arguments
-  Argv - Array of command line argument strings
-  Envp - Array of environmemt variable strings
-
-Returns:
-  0 - Normal exit
-  1 - Abnormal exit
-
-**/
-int
-main (
-  IN  int   Argc,
-  IN  char  **Argv,
-  IN  char  **Envp
-  )
-{
-  EFI_STATUS            Status;
-  EFI_PHYSICAL_ADDRESS  InitialStackMemory;
-  UINT64                InitialStackMemorySize;
-  UINTN                 Index;
-  UINTN                 Index1;
-  UINTN                 Index2;
-  UINTN                 PeiIndex;
-  CHAR8                 *FileName;
-  BOOLEAN               Done;
-  EFI_PEI_FILE_HANDLE   FileHandle;
-  VOID                  *SecFile;
-  CHAR16                *MemorySizeStr;
-  CHAR16                *FirmwareVolumesStr;
-  UINTN                 *StackPointer;
-  FILE                  *GdbTempFile;
-  
-  //
-  // Xcode does not support sourcing gdb scripts directly, so the Xcode XML 
-  // has a break point script to source the GdbRun script.
-  //
-  SecGdbConfigBreak ();
-  
-  //
-  // If dlopen doesn't work, then we build a gdb script to allow the
-  // symbols to be loaded.
-  //
-  Index = strlen (*Argv);
-  gGdbWorkingFileName = AllocatePool (Index + strlen(".gdb") + 1);
-  strcpy (gGdbWorkingFileName, *Argv);
-  strcat (gGdbWorkingFileName, ".gdb");
-
-  //
-  // Empty out the gdb symbols script file.
-  //
-  GdbTempFile = fopen (gGdbWorkingFileName, "w");
-  if (GdbTempFile != NULL) {
-    fclose (GdbTempFile);
-  }
-
-  printf ("\nEDK II UNIX Host Emulation Environment from edk2.sourceforge.net\n");
-  
-  setbuf (stdout, 0);
-  setbuf (stderr, 0);
-
-  MemorySizeStr      = (CHAR16 *) PcdGetPtr (PcdEmuMemorySize);
-  FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdEmuFirmwareVolume);
-
-  //
-  // PPIs pased into PEI_CORE
-  //
-  AddThunkPpi (EFI_PEI_PPI_DESCRIPTOR_PPI, &gEmuThunkPpiGuid, &mSecEmuThunkPpi);
-
-  SecInitThunkProtocol ();
-  
-  //
-  // Emulator Bus Driver Thunks
-  //
-  AddThunkProtocol (&gX11ThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuGop), TRUE); 
-  AddThunkProtocol (&gPosixFileSystemThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuFileSystem), TRUE); 
-  AddThunkProtocol (&gBlockIoThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuVirtualDisk), TRUE); 
-  AddThunkProtocol (&gSnpThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuNetworkInterface), TRUE); 
-
-  //
-  // Emulator other Thunks
-  //
-  AddThunkProtocol (&gPthreadThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuApCount), FALSE); 
-
-  // EmuSecLibConstructor ();
-  
-  gPpiList = GetThunkPpiList (); 
-
-  //
-  // Allocate space for gSystemMemory Array
-  //
-  gSystemMemoryCount  = CountSeperatorsInString (MemorySizeStr, '!') + 1;
-  gSystemMemory       = AllocateZeroPool (gSystemMemoryCount * sizeof (EMU_SYSTEM_MEMORY));
-  if (gSystemMemory == NULL) {
-    printf ("ERROR : Can not allocate memory for system.  Exiting.\n");
-    exit (1);
-  }
-  //
-  // Allocate space for gSystemMemory Array
-  //
-  gFdInfoCount  = CountSeperatorsInString (FirmwareVolumesStr, '!') + 1;
-  gFdInfo       = AllocateZeroPool (gFdInfoCount * sizeof (EMU_FD_INFO));
-  if (gFdInfo == NULL) {
-    printf ("ERROR : Can not allocate memory for fd info.  Exiting.\n");
-    exit (1);
-  }
-
-  printf ("  BootMode 0x%02x\n", (unsigned int)PcdGet32 (PcdEmuBootMode));
-
-  //
-  // Open up a 128K file to emulate temp memory for SEC.
-  //  on a real platform this would be SRAM, or using the cache as RAM.
-  //  Set InitialStackMemory to zero so UnixOpenFile will allocate a new mapping
-  //
-  InitialStackMemorySize  = STACK_SIZE;
-  InitialStackMemory = (UINTN)MapMemory (
-                                0, (UINT32) InitialStackMemorySize,
-                                PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE
-                                );
-  if (InitialStackMemory == 0) {
-    printf ("ERROR : Can not open SecStack Exiting\n");
-    exit (1);
-  }
-
-  printf ("  OS Emulator passing in %u KB of temp RAM at 0x%08lx to SEC\n",
-    (unsigned int)(InitialStackMemorySize / 1024),
-    (unsigned long)InitialStackMemory
-    );
-
-  for (StackPointer = (UINTN*) (UINTN) InitialStackMemory;
-     StackPointer < (UINTN*)(UINTN)((UINTN) InitialStackMemory + (UINT64) InitialStackMemorySize);
-     StackPointer ++) {
-    *StackPointer = 0x5AA55AA5;
-  }
-
-  //
-  // Open All the firmware volumes and remember the info in the gFdInfo global
-  //
-  FileName = (CHAR8 *) AllocatePool (StrLen (FirmwareVolumesStr) + 1);
-  if (FileName == NULL) {
-    printf ("ERROR : Can not allocate memory for firmware volume string\n");
-    exit (1);
-  }
-
-  Index2 = 0;
-  for (Done = FALSE, Index = 0, PeiIndex = 0, SecFile = NULL;
-       FirmwareVolumesStr[Index2] != 0;
-       Index++) {
-    for (Index1 = 0; (FirmwareVolumesStr[Index2] != '!') && (FirmwareVolumesStr[Index2] != 0); Index2++) {
-      FileName[Index1++] = FirmwareVolumesStr[Index2];
-    }
-    if (FirmwareVolumesStr[Index2] == '!') {
-      Index2++;
-    }
-    FileName[Index1]  = '\0';
-
-    if (Index == 0) {
-      // Map FV Recovery Read Only and other areas Read/Write
-      Status = MapFd0 (
-                FileName,
-                &gFdInfo[0].Address,
-                &gFdInfo[0].Size
-                );
-    } else {
-      //
-      // Open the FD and remmeber where it got mapped into our processes address space
-      // Maps Read Only
-      //
-      Status = MapFile (
-                FileName,
-                &gFdInfo[Index].Address,
-                &gFdInfo[Index].Size
-                );
-    }
-    if (EFI_ERROR (Status)) {
-      printf ("ERROR : Can not open Firmware Device File %s (%x).  Exiting.\n", FileName, (unsigned int)Status);
-      exit (1);
-    }
-
-    printf ("  FD loaded from %s at 0x%08lx",FileName, (unsigned long)gFdInfo[Index].Address);
-
-    if (SecFile == NULL) {
-      //
-      // Assume the beginning of the FD is an FV and look for the SEC Core.
-      // Load the first one we find.
-      //
-      FileHandle = NULL;
-      Status = PeiServicesFfsFindNextFile (
-                  EFI_FV_FILETYPE_SECURITY_CORE, 
-                  (EFI_PEI_FV_HANDLE)(UINTN)gFdInfo[Index].Address, 
-                  &FileHandle
-                  );
-      if (!EFI_ERROR (Status)) {
-        Status = PeiServicesFfsFindSectionData (EFI_SECTION_PE32, FileHandle, &SecFile);
-        if (!EFI_ERROR (Status)) {
-          PeiIndex = Index;
-          printf (" contains SEC Core");
-        }
-      }
-    }
-
-    printf ("\n");
-  }
-  //
-  // Calculate memory regions and store the information in the gSystemMemory
-  //  global for later use. The autosizing code will use this data to
-  //  map this memory into the SEC process memory space.
-  //
-  Index1 = 0;
-  Index = 0;
-  while (1) {
-    UINTN val = 0;
-    //
-    // Save the size of the memory.
-    //
-    while (MemorySizeStr[Index1] >= '0' && MemorySizeStr[Index1] <= '9') {
-      val = val * 10 + MemorySizeStr[Index1] - '0';
-      Index1++;
-    }
-    gSystemMemory[Index++].Size = val * 0x100000;
-    if (MemorySizeStr[Index1] == 0) {
-      break;
-    }
-    Index1++;
-  }
-
-  printf ("\n");
-
-  //
-  // Hand off to SEC
-  //
-  SecLoadFromCore ((UINTN) InitialStackMemory, (UINTN) InitialStackMemorySize, (UINTN) gFdInfo[0].Address, SecFile);
-
-  //
-  // If we get here, then the SEC Core returned. This is an error as SEC should
-  //  always hand off to PEI Core and then on to DXE Core.
-  //
-  printf ("ERROR : SEC returned\n");
-  exit (1);
-}
-
-
-EFI_PHYSICAL_ADDRESS *
-MapMemory (
-  IN INTN   fd,
-  IN UINT64 length,
-  IN INTN   prot,
-  IN INTN   flags
-  )
-{
-  STATIC UINTN base  = 0x40000000;
-  CONST UINTN  align = (1 << 24);
-  VOID         *res  = NULL;
-  BOOLEAN      isAligned = 0;
-
-  //
-  // Try to get an aligned block somewhere in the address space of this
-  // process.
-  //
-  while((!isAligned) && (base != 0)) {
-    res = mmap ((void *)base, length, prot, flags, fd, 0);
-    if (res == MAP_FAILED) {
-      return NULL;
-    }
-    if ((((UINTN)res) & ~(align-1)) == (UINTN)res) {
-      isAligned=1;
-    } else {
-      munmap(res, length);
-      base += align;
-    }
-  }
-  return res;
-}
-
-
-/*++
-
-Routine Description:
-  Opens and memory maps a file using Unix services. If BaseAddress is non zero
-  the process will try and allocate the memory starting at BaseAddress.
-
-Arguments:
-  FileName            - The name of the file to open and map
-  MapSize             - The amount of the file to map in bytes
-  CreationDisposition - The flags to pass to CreateFile().  Use to create new files for
-                        memory emulation, and exiting files for firmware volume emulation
-  BaseAddress         - The base address of the mapped file in the user address space.
-                         If passed in as NULL the a new memory region is used.
-                         If passed in as non NULL the request memory region is used for
-                          the mapping of the file into the process space.
-  Length              - The size of the mapped region in bytes
-
-Returns:
-  EFI_SUCCESS      - The file was opened and mapped.
-  EFI_NOT_FOUND    - FileName was not found in the current directory
-  EFI_DEVICE_ERROR - An error occured attempting to map the opened file
-
-**/
-EFI_STATUS
-MapFile (
-  IN  CHAR8                     *FileName,
-  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,
-  OUT UINT64                    *Length
-  )
-{
-  int     fd;
-  VOID    *res;
-  UINTN   FileSize;
-
-  fd = open (FileName, O_RDWR);
-  if (fd < 0) {
-    return EFI_NOT_FOUND;
-  }
-  FileSize = lseek (fd, 0, SEEK_END);
-
-
-  res = MapMemory (fd, FileSize, PROT_READ | PROT_EXEC, MAP_PRIVATE);
-
-  close (fd);
-
-  if (res == NULL) {
-    perror ("MapFile() Failed");
-    return EFI_DEVICE_ERROR;
-  }
-      
-  *Length = (UINT64) FileSize;
-  *BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) res;
-
-  return EFI_SUCCESS;
-}
-
-EFI_STATUS
-MapFd0 (
-  IN  CHAR8                     *FileName,
-  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,
-  OUT UINT64                    *Length
-  )
-{
-  int     fd;
-  void    *res, *res2, *res3;
-  UINTN   FileSize;
-  UINTN   FvSize;
-  void    *EmuMagicPage;
-
-  fd = open (FileName, O_RDWR);
-  if (fd < 0) {
-    return EFI_NOT_FOUND;
-  }
-  FileSize = lseek (fd, 0, SEEK_END);
-  FvSize = FixedPcdGet64 (PcdEmuFlashFvRecoverySize);
-
-  // Assume start of FD is Recovery FV, and make it write protected
-  res = mmap (
-          (void *)(UINTN)FixedPcdGet64 (PcdEmuFlashFvRecoveryBase), 
-          FvSize, 
-          PROT_READ | PROT_EXEC, 
-          MAP_PRIVATE, 
-          fd, 
-          0
-          );
-  if (res == MAP_FAILED) {
-    perror ("MapFd0() Failed res =");
-    close (fd);
-    return EFI_DEVICE_ERROR;
-  } else if (res != (void *)(UINTN)FixedPcdGet64 (PcdEmuFlashFvRecoveryBase)) {
-    // We could not load at the build address, so we need to allow writes
-    munmap (res, FvSize);
-    res = mmap (
-            (void *)(UINTN)FixedPcdGet64 (PcdEmuFlashFvRecoveryBase), 
-            FvSize, 
-            PROT_READ | PROT_WRITE | PROT_EXEC, 
-            MAP_PRIVATE, 
-            fd, 
-            0
-            );
-    if (res == MAP_FAILED) {
-      perror ("MapFd0() Failed res =");
-      close (fd);
-      return EFI_DEVICE_ERROR;
-    }
-  }
-  
-  // Map the rest of the FD as read/write
-  res2 = mmap (
-          (void *)(UINTN)(FixedPcdGet64 (PcdEmuFlashFvRecoveryBase) + FvSize), 
-          FileSize - FvSize, 
-          PROT_READ | PROT_WRITE | PROT_EXEC, 
-          MAP_SHARED,
-          fd, 
-          FvSize
-          );
-  close (fd);
-  if (res2 == MAP_FAILED) {
-    perror ("MapFd0() Failed res2 =");
-    return EFI_DEVICE_ERROR;
-  }
-
-  //
-  // If enabled use the magic page to communicate between modules 
-  // This replaces the PI PeiServicesTable pointer mechanism that
-  // deos not work in the emulator. It also allows the removal of
-  // writable globals from SEC, PEI_CORE (libraries), PEIMs
-  //
-  EmuMagicPage = (void *)(UINTN)FixedPcdGet64 (PcdPeiServicesTablePage);
-  if (EmuMagicPage != NULL) {
-    res3 =  mmap (
-              (void *)EmuMagicPage, 
-              4096, 
-              PROT_READ | PROT_WRITE, 
-              MAP_PRIVATE | MAP_ANONYMOUS,
-              0, 
-              0
-              );
-    if (res3 != EmuMagicPage) {
-      printf ("MapFd0(): Could not allocate PeiServicesTablePage @ %lx\n", (long unsigned int)EmuMagicPage);
-      return EFI_DEVICE_ERROR;
-    }
-  }
-  
-  *Length = (UINT64) FileSize;
-  *BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) res;
-
-  return EFI_SUCCESS;  
-}
-
-
-/*++
-
-Routine Description:
-  This is the service to load the SEC Core from the Firmware Volume
-
-Arguments:
-  LargestRegion           - Memory to use for SEC.
-  LargestRegionSize       - Size of Memory to use for PEI
-  BootFirmwareVolumeBase  - Start of the Boot FV
-  PeiCorePe32File         - SEC PE32
-
-Returns:
-  Success means control is transfered and thus we should never return
-
-**/
-VOID
-SecLoadFromCore (
-  IN  UINTN   LargestRegion,
-  IN  UINTN   LargestRegionSize,
-  IN  UINTN   BootFirmwareVolumeBase,
-  IN  VOID    *PeiCorePe32File
-  )
-{
-  EFI_STATUS                  Status;
-  EFI_PHYSICAL_ADDRESS        TopOfMemory;
-  VOID                        *TopOfStack;
-  EFI_PHYSICAL_ADDRESS        PeiCoreEntryPoint;
-  EFI_SEC_PEI_HAND_OFF        *SecCoreData;
-  UINTN                       PeiStackSize;
-
-  //
-  // Compute Top Of Memory for Stack and PEI Core Allocations
-  //
-  TopOfMemory  = LargestRegion + LargestRegionSize;
-  PeiStackSize = (UINTN)RShiftU64((UINT64)STACK_SIZE,1);
-
-  //
-  // |-----------| <---- TemporaryRamBase + TemporaryRamSize
-  // |   Heap    |
-  // |           |
-  // |-----------| <---- StackBase / PeiTemporaryMemoryBase
-  // |           |
-  // |  Stack    |
-  // |-----------| <---- TemporaryRamBase
-  //
-  TopOfStack  = (VOID *)(LargestRegion + PeiStackSize);
-  TopOfMemory = LargestRegion + PeiStackSize;
-
-  //
-  // Reservet space for storing PeiCore's parament in stack.
-  //
-  TopOfStack  = (VOID *)((UINTN)TopOfStack - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT);
-  TopOfStack  = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
-
-
-  //
-  // Bind this information into the SEC hand-off state
-  //
-  SecCoreData                         = (EFI_SEC_PEI_HAND_OFF*)(UINTN) TopOfStack;
-  SecCoreData->DataSize               = sizeof(EFI_SEC_PEI_HAND_OFF);
-  SecCoreData->BootFirmwareVolumeBase = (VOID*)BootFirmwareVolumeBase;
-  SecCoreData->BootFirmwareVolumeSize = PcdGet32 (PcdEmuFirmwareFdSize);
-  SecCoreData->TemporaryRamBase       = (VOID*)(UINTN)LargestRegion;
-  SecCoreData->TemporaryRamSize       = STACK_SIZE;
-  SecCoreData->StackBase              = SecCoreData->TemporaryRamBase;
-  SecCoreData->StackSize              = PeiStackSize;
-  SecCoreData->PeiTemporaryRamBase    = (VOID*) ((UINTN) SecCoreData->TemporaryRamBase + PeiStackSize);
-  SecCoreData->PeiTemporaryRamSize    = STACK_SIZE - PeiStackSize;
-
-  //
-  // Find the SEC Core Entry Point
-  //
-  Status = SecPeCoffGetEntryPoint (PeiCorePe32File, (VOID **)&PeiCoreEntryPoint);
-  if (EFI_ERROR (Status)) {
-    return ;
-  }
-
-  //
-  // Transfer control to the SEC Core
-  //
-  PeiSwitchStacks (
-    (SWITCH_STACK_ENTRY_POINT) (UINTN) PeiCoreEntryPoint,
-    SecCoreData,
-    (VOID *)gPpiList,
-    TopOfStack
-    );
-  //
-  // If we get here, then the SEC Core returned.  This is an error
-  //
-  return ;
-}
-
-
-/*++
-
-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.
-  It uses gSystemMemory[] and gSystemMemoryCount that were created by
-  parsing the host environment variable EFI_MEMORY_SIZE.
-  The size comes from the varaible and the address comes from the call to
-  UnixOpenFile.
-
-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
-
-**/
-EFI_STATUS
-SecUnixPeiAutoScan (
-  IN  UINTN                 Index,
-  OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,
-  OUT UINT64                *MemorySize
-  )
-{
-  void *res;
-
-  if (Index >= gSystemMemoryCount) {
-    return EFI_UNSUPPORTED;
-  }
-
-  *MemoryBase = 0;
-  res = MapMemory (
-          0, gSystemMemory[Index].Size,
-          PROT_READ | PROT_WRITE | PROT_EXEC,
-          MAP_PRIVATE | MAP_ANONYMOUS
-          );
-  if (res == MAP_FAILED) {
-    return EFI_DEVICE_ERROR;
-  }
-  *MemorySize = gSystemMemory[Index].Size;
-  *MemoryBase = (UINTN)res;
-  gSystemMemory[Index].Memory = *MemoryBase;
-
-  return EFI_SUCCESS;
-}
-
-
-/*++
-
-Routine Description:
- Check to see if an address range is in the EFI GCD memory map.
- This is all of GCD for system memory passed to DXE Core. FV 
- mapping and other device mapped into system memory are not
- inlcuded in the check. 
-
-Arguments:
-  Index      - Which memory region to use
-  MemoryBase - Return Base address of memory region
-  MemorySize - Return size in bytes of the memory region
-
-Returns:
-  TRUE -  Address is in the EFI GCD memory map
-  FALSE - Address is NOT in memory map
-
-**/
-BOOLEAN
-EfiSystemMemoryRange (
-  IN  VOID *MemoryAddress
-  )
-{
-  UINTN                 Index;
-  EFI_PHYSICAL_ADDRESS  MemoryBase;
-  
-  MemoryBase = (EFI_PHYSICAL_ADDRESS)(UINTN)MemoryAddress;
-  for (Index = 0; Index < gSystemMemoryCount; Index++) {
-    if ((MemoryBase >= gSystemMemory[Index].Memory) &&
-        (MemoryBase < (gSystemMemory[Index].Memory + gSystemMemory[Index].Size)) ) {
-      return TRUE;
-    }
-  }
-  
-  return FALSE;
-}
-
-
-/*++
-
-Routine Description:
-  Since the SEC is the only Unix program in stack it must export
-  an interface to do POSIX calls.  gUnix is initailized in UnixThunk.c.
-
-Arguments:
-  InterfaceSize - sizeof (EFI_WIN_NT_THUNK_PROTOCOL);
-  InterfaceBase - Address of the gUnix global
-
-Returns:
-  EFI_SUCCESS - Data returned
-
-**/
-VOID *
-SecEmuThunkAddress (
-  VOID
-  )
-{
-  return &gEmuThunkProtocol;
-}
-
-
-
-RETURN_STATUS
-EFIAPI
-SecPeCoffGetEntryPoint (
-  IN     VOID  *Pe32Data,
-  IN OUT VOID  **EntryPoint
-  )
-{
-  EFI_STATUS                    Status;
-  PE_COFF_LOADER_IMAGE_CONTEXT  ImageContext;
-
-  ZeroMem (&ImageContext, sizeof (ImageContext));
-  ImageContext.Handle     = Pe32Data;
-  ImageContext.ImageRead  = (PE_COFF_LOADER_READ_FILE) SecImageRead;
-
-  Status                  = PeCoffLoaderGetImageInfo (&ImageContext);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  if (ImageContext.ImageAddress != (UINTN)Pe32Data) {
-    //
-    // Relocate image to match the address where it resides
-    //
-    ImageContext.ImageAddress = (UINTN)Pe32Data;
-    Status = PeCoffLoaderLoadImage (&ImageContext);
-    if (EFI_ERROR (Status)) {
-      return Status;
-    }
-
-    Status = PeCoffLoaderRelocateImage (&ImageContext);
-    if (EFI_ERROR (Status)) {
-      return Status;
-    }
-  } else {
-    //
-    // Or just return image entry point
-    //
-    ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer (Pe32Data);
-    Status = PeCoffLoaderGetEntryPoint (Pe32Data, EntryPoint);
-    if (EFI_ERROR (Status)) {
-      return Status;
-    }
-    ImageContext.EntryPoint = (UINTN)*EntryPoint;
-  }
-
-  // On Unix a dlopen is done that will change the entry point
-  SecPeCoffRelocateImageExtraAction (&ImageContext);
-  *EntryPoint = (VOID *)(UINTN)ImageContext.EntryPoint;
-  
-  return Status;
-}
-
-
-
-/*++
-
-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
-
-**/
-EFI_STATUS
-SecUnixFdAddress (
-  IN     UINTN                 Index,
-  IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,
-  IN OUT UINT64                *FdSize,
-  IN OUT EFI_PHYSICAL_ADDRESS  *FixUp
-  )
-{
-  if (Index >= gFdInfoCount) {
-    return EFI_UNSUPPORTED;
-  }
-
-  *FdBase = gFdInfo[Index].Address;
-  *FdSize = gFdInfo[Index].Size;
-  *FixUp  = 0;
-
-  if (*FdBase == 0 && *FdSize == 0) {
-    return EFI_UNSUPPORTED;
-  }
-
-  if (Index == 0) {
-    //
-    // FD 0 has XIP code and well known PCD values
-    // If the memory buffer could not be allocated at the FD build address
-    // the Fixup is the difference.
-    //
-    *FixUp = *FdBase - PcdGet64 (PcdEmuFdBaseAddress);
-  }
-
-  return EFI_SUCCESS;
-}
-
-
-/*++
-
-Routine Description:
-  Count the number of seperators in String
-
-Arguments:
-  String    - String to process
-  Seperator - Item to count
-
-Returns:
-  Number of Seperator in String
-
-**/
-UINTN
-CountSeperatorsInString (
-  IN  const CHAR16   *String,
-  IN  CHAR16         Seperator
-  )
-{
-  UINTN Count;
-
-  for (Count = 0; *String != '\0'; String++) {
-    if (*String == Seperator) {
-      Count++;
-    }
-  }
-
-  return Count;
-}
-
-
-EFI_STATUS
-EFIAPI
-SecImageRead (
-  IN     VOID    *FileHandle,
-  IN     UINTN   FileOffset,
-  IN OUT UINTN   *ReadSize,
-  OUT    VOID    *Buffer
-  )
-/*++
-
-Routine Description:
-  Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file
-
-Arguments:
-  FileHandle - The handle to the PE/COFF file
-  FileOffset - The offset, in bytes, into the file to read
-  ReadSize   - The number of bytes to read from the file starting at FileOffset
-  Buffer     - A pointer to the buffer to read the data into.
-
-Returns:
-  EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset
-
-**/
-{
-  CHAR8 *Destination8;
-  CHAR8 *Source8;
-  UINTN Length;
-
-  Destination8  = Buffer;
-  Source8       = (CHAR8 *) ((UINTN) FileHandle + FileOffset);
-  Length        = *ReadSize;
-  while (Length--) {
-    *(Destination8++) = *(Source8++);
-  }
-
-  return EFI_SUCCESS;
-}
-
-
-/*++
-
-Routine Description:
-  Store the ModHandle in an array indexed by the Pdb File name.
-  The ModHandle is needed to unload the image.
-
-Arguments:
-  ImageContext - Input data returned from PE Laoder Library. Used to find the
-                 .PDB file name of the PE Image.
-  ModHandle    - Returned from LoadLibraryEx() and stored for call to
-                 FreeLibrary().
-
-Returns:
-  EFI_SUCCESS - ModHandle was stored.
-
-**/
-EFI_STATUS
-AddHandle (
-  IN  PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext,
-  IN  VOID                                 *ModHandle
-  )
-{
-  UINTN                       Index;
-  IMAGE_CONTEXT_TO_MOD_HANDLE *Array;
-  UINTN                       PreviousSize;
-
-
-  Array = mImageContextModHandleArray;
-  for (Index = 0; Index < mImageContextModHandleArraySize; Index++, Array++) {
-    if (Array->ImageContext == NULL) {
-      //
-      // Make a copy of the stirng and store the ModHandle
-      //
-      Array->ImageContext = ImageContext;
-      Array->ModHandle    = ModHandle;
-      return EFI_SUCCESS;
-    }
-  }
-
-  //
-  // No free space in mImageContextModHandleArray so grow it by
-  // IMAGE_CONTEXT_TO_MOD_HANDLE entires. realloc will
-  // copy the old values to the new locaiton. But it does
-  // not zero the new memory area.
-  //
-  PreviousSize = mImageContextModHandleArraySize * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE);
-  mImageContextModHandleArraySize += MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE;
-
-  mImageContextModHandleArray = ReallocatePool (
-                                  (mImageContextModHandleArraySize - 1) * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE),
-                                  mImageContextModHandleArraySize * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE),
-                                  mImageContextModHandleArray
-                                  );
-  if (mImageContextModHandleArray == NULL) {
-    ASSERT (FALSE);
-    return EFI_OUT_OF_RESOURCES;
-  }
-
-  memset (mImageContextModHandleArray + PreviousSize, 0, MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE));
-
-  return AddHandle (ImageContext, ModHandle);
-}
-
-
-/*++
-
-Routine Description:
-  Return the ModHandle and delete the entry in the array.
-
-Arguments:
-  ImageContext - Input data returned from PE Laoder Library. Used to find the
-                 .PDB file name of the PE Image.
-
-Returns:
-  ModHandle - ModHandle assoicated with ImageContext is returned
-  NULL      - No ModHandle associated with ImageContext
-
-**/
-VOID *
-RemoveHandle (
-  IN  PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
-  )
-{
-  UINTN                        Index;
-  IMAGE_CONTEXT_TO_MOD_HANDLE  *Array;
-
-  if (ImageContext->PdbPointer == NULL) {
-    //
-    // If no PDB pointer there is no ModHandle so return NULL
-    //
-    return NULL;
-  }
-
-  Array = mImageContextModHandleArray;
-  for (Index = 0; Index < mImageContextModHandleArraySize; Index++, Array++) {
-    if (Array->ImageContext == ImageContext) {
-      //
-      // If you find a match return it and delete the entry
-      //
-      Array->ImageContext = NULL;
-      return Array->ModHandle;
-    }
-  }
-
-  return NULL;
-}
-
-
-
-BOOLEAN
-IsPdbFile (
-  IN  CHAR8   *PdbFileName
-  )
-{
-  UINTN Len;
-
-  if (PdbFileName == NULL) {
-    return FALSE;
-  }
-
-  Len = strlen (PdbFileName);
-  if ((Len < 5)|| (PdbFileName[Len - 4] != '.')) {
-    return FALSE;
-  }
-
-  if ((PdbFileName[Len - 3] == 'P' || PdbFileName[Len - 3] == 'p') &&
-      (PdbFileName[Len - 2] == 'D' || PdbFileName[Len - 2] == 'd') &&
-      (PdbFileName[Len - 1] == 'B' || PdbFileName[Len - 1] == 'b')) {
-    return TRUE;
-  }
-
-  return FALSE;
-}
-
-
-#define MAX_SPRINT_BUFFER_SIZE 0x200
-
-void
-PrintLoadAddress (
-  IN PE_COFF_LOADER_IMAGE_CONTEXT          *ImageContext
-  )
-{
-  if (ImageContext->PdbPointer == NULL) {
-    fprintf (stderr,
-      "0x%08lx Loading NO DEBUG with entry point 0x%08lx\n",
-      (unsigned long)(ImageContext->ImageAddress),
-      (unsigned long)ImageContext->EntryPoint
-      );
-  } else {
-    fprintf (stderr,
-      "0x%08lx Loading %s with entry point 0x%08lx\n",
-      (unsigned long)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders),
-      ImageContext->PdbPointer,
-      (unsigned long)ImageContext->EntryPoint
-      );
-  }
-  // Keep output synced up
-  fflush (stderr);
-}
-
-
-/**
-  Loads the image using dlopen so symbols will be automatically
-  loaded by gdb.
-
-  @param  ImageContext  The PE/COFF image context
-
-  @retval TRUE - The image was successfully loaded
-  @retval FALSE - The image was successfully loaded
-
-**/
-BOOLEAN
-DlLoadImage (
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
-  )
-{
-
-#ifdef __APPLE__
-
-  return FALSE;
-
-#else
-
-  void        *Handle = NULL;
-  void        *Entry = NULL;
-
-  if (ImageContext->PdbPointer == NULL) {
-    return FALSE;
-  }
-
-  if (!IsPdbFile (ImageContext->PdbPointer)) {
-    return FALSE;
-  }
-
-  fprintf (
-     stderr,
-     "Loading %s 0x%08lx - entry point 0x%08lx\n",
-     ImageContext->PdbPointer,
-     (unsigned long)ImageContext->ImageAddress,
-     (unsigned long)ImageContext->EntryPoint
-     );
-
-  Handle = dlopen (ImageContext->PdbPointer, RTLD_NOW);
-  if (Handle != NULL) {
-    Entry = dlsym (Handle, "_ModuleEntryPoint");
-    AddHandle (ImageContext, Handle);
-  } else {
-    printf("%s\n", dlerror());
-  }
-
-  if (Entry != NULL) {
-    ImageContext->EntryPoint = (UINTN)Entry;
-    printf ("Change %s Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, (unsigned long)Entry);
-    return TRUE;
-  } else {
-    return FALSE;
-  }
-
-#endif
-}
-
-
-/**
-  Adds the image to a gdb script so it's symbols can be loaded.
-  The AddFirmwareSymbolFile helper macro is used.
-
-  @param  ImageContext  The PE/COFF image context
-
-**/
-VOID
-GdbScriptAddImage (
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
-  )
-{
-
-  PrintLoadAddress (ImageContext);
-
-  if (ImageContext->PdbPointer != NULL && !IsPdbFile (ImageContext->PdbPointer)) {
-    FILE  *GdbTempFile;
-    GdbTempFile = fopen (gGdbWorkingFileName, "a");
-    if (GdbTempFile != NULL) {
-      long unsigned int SymbolsAddr = (long unsigned int)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders);
-      mScriptSymbolChangesCount++;
-      fprintf (
-        GdbTempFile,
-        "AddFirmwareSymbolFile 0x%x %s 0x%08lx\n",
-        mScriptSymbolChangesCount,
-        ImageContext->PdbPointer,
-        SymbolsAddr
-        );
-      fclose (GdbTempFile);
-    } else {
-      ASSERT (FALSE);
-    }
-  }
-}
-
-
-VOID
-EFIAPI
-SecPeCoffRelocateImageExtraAction (
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
-  )
-{
-  if (!DlLoadImage (ImageContext)) {
-    GdbScriptAddImage (ImageContext);
-  }
-}
-
-
-/**
-  Adds the image to a gdb script so it's symbols can be unloaded.
-  The RemoveFirmwareSymbolFile helper macro is used.
-
-  @param  ImageContext  The PE/COFF image context
-
-**/
-VOID
-GdbScriptRemoveImage (
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
-  )
-{
-  FILE  *GdbTempFile;
-
-  //
-  // Need to skip .PDB files created from VC++
-  //
-  if (IsPdbFile (ImageContext->PdbPointer)) {
-    return;
-  }
-
-  //
-  // Write the file we need for the gdb script
-  //
-  GdbTempFile = fopen (gGdbWorkingFileName, "a");
-  if (GdbTempFile != NULL) {
-    mScriptSymbolChangesCount++;
-    fprintf (
-      GdbTempFile,
-      "RemoveFirmwareSymbolFile 0x%x %s\n",
-      mScriptSymbolChangesCount,
-      ImageContext->PdbPointer
-      );
-    fclose (GdbTempFile);
-  } else {
-    ASSERT (FALSE);
-  }
-}
-
-
-VOID
-EFIAPI
-SecPeCoffUnloadImageExtraAction (
-  IN PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext
-  )
-{
-  VOID *Handle;
-
-  //
-  // Check to see if the image symbols were loaded with gdb script, or dlopen
-  //
-  Handle = RemoveHandle (ImageContext);
-  if (Handle != NULL) {
-#ifndef __APPLE__
-    dlclose (Handle);
-#endif
-    return;
-  }
-
-  GdbScriptRemoveImage (ImageContext);
-}
-
-
diff --git a/InOsEmuPkg/Unix/Sec/SecMain.h b/InOsEmuPkg/Unix/Sec/SecMain.h
deleted file mode 100644 (file)
index 5cd7178..0000000
+++ /dev/null
@@ -1,356 +0,0 @@
-/*++ @file\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _SEC_MAIN_H__\r
-#define _SEC_MAIN_H__\r
-\r
-//\r
-// Name mangle to prevent build errors. I.e conflicts between EFI and OS\r
-//\r
-#define NTOHL   _UNIX_EFI_NAME_MANGLE_NTOHL_\r
-#define HTONL   _UNIX_EFI_NAME_MANGLE_HTONL_\r
-#define NTOHS   _UNIX_EFI_NAME_MANGLE_NTOHS_\r
-#define HTONS   _UNIX_EFI_NAME_MANGLE_HTOHS_\r
-#define B0      _UNIX_EFI_NAME_MANGLE_B0_\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-\r
-#include <sys/types.h>\r
-#include <sys/stat.h>\r
-#include <sys/termios.h>\r
-#include <sys/time.h>\r
-\r
-#if __CYGWIN__\r
-#include <sys/dirent.h>\r
-#else\r
-#include <sys/dir.h>\r
-#endif\r
-\r
-#include <sys/mman.h>\r
-#include <dlfcn.h>\r
-\r
-#include <unistd.h>\r
-#include <poll.h>\r
-#include <fcntl.h>\r
-#include <time.h>\r
-#include <signal.h>\r
-#include <errno.h>\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <sys/ioctl.h>\r
-#include <sys/statvfs.h>\r
-\r
-#include <sys/socket.h>\r
-#include <netdb.h>\r
-#include <netinet/in.h>\r
-#include <net/if.h>\r
-#include <ifaddrs.h>\r
-\r
-#ifdef __APPLE__\r
-#include <net/if_dl.h>\r
-#include <net/bpf.h>\r
-#include <sys/param.h>\r
-#include <sys/mount.h>\r
-#include <sys/disk.h>\r
-#define _XOPEN_SOURCE\r
-#ifndef _Bool\r
-  #define _Bool char // for clang debug\r
-#endif\r
-#else\r
-#include <termio.h>\r
-#include <sys/vfs.h>\r
-#include <linux/fs.h>\r
-#endif \r
-\r
-#include <utime.h>\r
-\r
-#undef NTOHL\r
-#undef HTONL\r
-#undef NTOHS\r
-#undef HTONS\r
-#undef B0\r
-\r
-\r
-#include <PiPei.h>\r
-#include <Uefi.h>\r
-\r
-#include <Library/PeCoffLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/ReportStatusCodeLib.h>\r
-\r
-#include <Library/ThunkPpiList.h>\r
-#include <Library/ThunkProtocolList.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/PeCoffGetEntryPointLib.h>\r
-#include <Library/EmuMagicPageLib.h>\r
-\r
-#include <Ppi/EmuThunk.h>\r
-#include <Ppi/StatusCode.h>\r
-\r
-#include <Protocol/SimplePointer.h>\r
-#include <Protocol/SimpleTextIn.h>\r
-#include <Protocol/SimpleTextInEx.h>\r
-#include <Protocol/UgaDraw.h>\r
-#include <Protocol/SimpleFileSystem.h>\r
-\r
-#include <Protocol/EmuThunk.h>\r
-#include <Protocol/EmuIoThunk.h>\r
-#include <Protocol/EmuGraphicsWindow.h>\r
-#include <Protocol/EmuThread.h>\r
-#include <Protocol/EmuBlockIo.h>\r
-#include <Protocol/EmuSnp.h>\r
-\r
-#include <Guid/FileInfo.h>\r
-#include <Guid/FileSystemInfo.h>\r
-#include <Guid/FileSystemVolumeLabelInfo.h>\r
-\r
-\r
-#include "Gasket.h"\r
-\r
-\r
-#define STACK_SIZE                0x20000      \r
-\r
-typedef struct {\r
-  EFI_PHYSICAL_ADDRESS  Address;\r
-  UINT64                Size;\r
-} EMU_FD_INFO;\r
-\r
-typedef struct {\r
-  EFI_PHYSICAL_ADDRESS  Memory;\r
-  UINT64                Size;\r
-} EMU_SYSTEM_MEMORY;\r
-\r
-\r
-#define MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE 0x100\r
-\r
-typedef struct {\r
-  PE_COFF_LOADER_IMAGE_CONTEXT   *ImageContext;\r
-  VOID                           *ModHandle;\r
-} IMAGE_CONTEXT_TO_MOD_HANDLE;\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SecUnixPeiLoadFile (\r
-  VOID                  *Pe32Data,  \r
-  EFI_PHYSICAL_ADDRESS  *ImageAddress,  \r
-  UINT64                *ImageSize,  \r
-  EFI_PHYSICAL_ADDRESS  *EntryPoint  \r
-  );\r
-\r
-int\r
-main (\r
-  IN  int   Argc,\r
-  IN  char  **Argv,\r
-  IN  char  **Envp\r
-  );\r
-\r
-VOID\r
-SecLoadFromCore (\r
-  IN  UINTN   LargestRegion,\r
-  IN  UINTN   LargestRegionSize,\r
-  IN  UINTN   BootFirmwareVolumeBase,\r
-  IN  VOID    *PeiCoreFile\r
-  );\r
-\r
-EFI_STATUS\r
-SecLoadFile (\r
-  IN  VOID                    *Pe32Data,\r
-  IN  EFI_PHYSICAL_ADDRESS    *ImageAddress,\r
-  IN  UINT64                  *ImageSize,\r
-  IN  EFI_PHYSICAL_ADDRESS    *EntryPoint\r
-  );\r
-\r
-EFI_STATUS\r
-SecFfsFindPeiCore (\r
-  IN  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader,\r
-  OUT VOID                        **Pe32Data\r
-  );\r
-\r
-EFI_STATUS\r
-SecFfsFindNextFile (\r
-  IN EFI_FV_FILETYPE             SearchType,\r
-  IN EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader,\r
-  IN OUT EFI_FFS_FILE_HEADER     **FileHeader\r
-  );\r
-\r
-EFI_STATUS\r
-SecFfsFindSectionData (\r
-  IN EFI_SECTION_TYPE      SectionType,\r
-  IN EFI_FFS_FILE_HEADER   *FfsFileHeader,\r
-  IN OUT VOID              **SectionData\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SecUnixPeCoffLoaderLoadAsDll (\r
-  IN CHAR8    *PdbFileName,\r
-  IN VOID     **ImageEntryPoint,\r
-  OUT VOID    **ModHandle\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SecUnixPeCoffLoaderFreeLibrary (\r
-  OUT VOID    *ModHandle\r
-  );\r
-\r
-EFI_STATUS\r
-SecUnixFdAddress (\r
-  IN     UINTN                 Index,\r
-  IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,\r
-  IN OUT UINT64                *FdSize,\r
-  IN OUT EFI_PHYSICAL_ADDRESS  *FixUp\r
-  )\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-GasketSecUnixFdAddress (\r
-  IN     UINTN                 Index,\r
-  IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,\r
-  IN OUT UINT64                *FdSize,\r
-  IN OUT EFI_PHYSICAL_ADDRESS  *FixUp\r
-  )\r
-;\r
-\r
-\r
-EFI_STATUS\r
-GetImageReadFunction (\r
-  IN PE_COFF_LOADER_IMAGE_CONTEXT          *ImageContext,\r
-  IN EFI_PHYSICAL_ADDRESS                  *TopOfMemory\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SecImageRead (\r
-  IN     VOID    *FileHandle,\r
-  IN     UINTN   FileOffset,\r
-  IN OUT UINTN   *ReadSize,\r
-  OUT    VOID    *Buffer\r
-  );\r
-\r
-CHAR16                            *\r
-AsciiToUnicode (\r
-  IN  CHAR8   *Ascii,\r
-  IN  UINTN   *StrLen OPTIONAL\r
-  );\r
-\r
-UINTN\r
-CountSeperatorsInString (\r
-  IN  const CHAR16   *String,\r
-  IN  CHAR16   Seperator\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SecTemporaryRamSupport (\r
-  IN CONST EFI_PEI_SERVICES   **PeiServices,\r
-  IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,\r
-  IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,\r
-  IN UINTN                    CopySize\r
-  );\r
-  \r
-EFI_STATUS\r
-EFIAPI\r
-GasketSecTemporaryRamSupport (\r
-  IN CONST EFI_PEI_SERVICES   **PeiServices,\r
-  IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,\r
-  IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,\r
-  IN UINTN                    CopySize\r
-  );\r
-\r
-\r
-RETURN_STATUS\r
-EFIAPI\r
-SecPeCoffGetEntryPoint (\r
-  IN     VOID  *Pe32Data,\r
-  IN OUT VOID  **EntryPoint\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-SecPeCoffRelocateImageExtraAction (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-SecPeCoffLoaderUnloadImageExtraAction (\r
-  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
-  );\r
-\r
-\r
-VOID\r
-PeiSwitchStacks (\r
-  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,\r
-  IN      VOID                      *Context1,  OPTIONAL\r
-  IN      VOID                      *Context2,  OPTIONAL\r
-  IN      VOID                      *NewStack\r
-  );\r
-\r
-VOID\r
-SecInitThunkProtocol (\r
-  VOID\r
-  );\r
\r
-  \r
-EFI_PHYSICAL_ADDRESS *\r
-MapMemory (\r
-  INTN fd,\r
-  UINT64 length,\r
-  INTN   prot,\r
-  INTN   flags);\r
-\r
-EFI_STATUS\r
-MapFile (\r
-  IN  CHAR8                     *FileName,\r
-  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,\r
-  OUT UINT64                    *Length\r
-  );\r
-\r
-EFI_STATUS\r
-MapFd0 (\r
-  IN  CHAR8                     *FileName,\r
-  IN OUT  EFI_PHYSICAL_ADDRESS  *BaseAddress,\r
-  OUT UINT64                    *Length\r
-  );\r
-\r
-BOOLEAN\r
-EfiSystemMemoryRange (\r
-  IN  VOID *MemoryAddress\r
-  );\r
-\r
-\r
-VOID SecSleep (UINT64 Nanoseconds);\r
-VOID SecEnableInterrupt (VOID);\r
-VOID SecDisableInterrupt (VOID);\r
-BOOLEAN SecInterruptEanbled (VOID);\r
-\r
-\r
-extern EMU_THUNK_PROTOCOL    gEmuThunkProtocol;\r
-extern EMU_IO_THUNK_PROTOCOL gX11ThunkIo;\r
-extern EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo;\r
-extern EMU_IO_THUNK_PROTOCOL gPthreadThunkIo;\r
-extern EMU_IO_THUNK_PROTOCOL gBlockIoThunkIo;\r
-extern EMU_IO_THUNK_PROTOCOL gSnpThunkIo;\r
-\r
-#endif\r
diff --git a/InOsEmuPkg/Unix/Sec/SecMain.inf b/InOsEmuPkg/Unix/Sec/SecMain.inf
deleted file mode 100644 (file)
index f5ed27d..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-## @file\r
-# Entry Point of Emu Emulator\r
-#\r
-# Main executable file of Unix Emulator that loads PEI core after initialization finished.\r
-# Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = SecMain\r
-  FILE_GUID                      = 8863C0AD-7724-C84B-88E5-A33B116D1485\r
-  MODULE_TYPE                    = USER_DEFINED\r
-  VERSION_STRING                 = 1.0\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
-  SecMain.c\r
-  EmuThunk.c\r
-  X11GraphicsWindow.c\r
-  Pthreads.c\r
-  PosixFileSystem.c\r
-  BlockIo.c\r
-  LinuxPacketFilter.c\r
-  BerkeleyPacketFilter.c\r
-  MemoryAllocationLib.c\r
-  \r
-[Sources.X64]\r
-  X64/Gasket.S        # convert between Emu x86_64 ABI and EFI X64 ABI\r
-  X64/SwitchStack.S\r
-\r
-[Sources.IA32]\r
-  Ia32/Gasket.S       # enforce 16-byte stack alignment for Mac OS X\r
-  Ia32/SwitchStack.c\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  InOsEmuPkg/InOsEmuPkg.dec\r
-\r
-[LibraryClasses]\r
-  DebugLib\r
-  PcdLib\r
-  PrintLib\r
-  BaseMemoryLib\r
-  BaseLib\r
-  PeCoffLib\r
-  ThunkPpiList\r
-  ThunkProtocolList\r
-  PpiListLib\r
-  PeiServicesLib\r
-  PeCoffGetEntryPointLib\r
-\r
-[Ppis]\r
-  gEfiPeiStatusCodePpiGuid                      # PPI ALWAYS_PRODUCED\r
-  gEmuThunkPpiGuid\r
-\r
-[Protocols]\r
-  gEmuIoThunkProtocolGuid\r
-  gEmuIoThunkProtocolGuid\r
-  gEmuGraphicsWindowProtocolGuid\r
-  gEmuThreadThunkProtocolGuid\r
-  gEmuBlockIoProtocolGuid\r
-  gEmuSnpProtocolGuid\r
-  gEfiSimpleFileSystemProtocolGuid\r
-\r
-[Guids]\r
-  gEfiFileSystemVolumeLabelInfoIdGuid           # SOMETIMES_CONSUMED\r
-  gEfiFileInfoGuid                              # SOMETIMES_CONSUMED\r
-  gEfiFileSystemInfoGuid                        # SOMETIMES_CONSUMED\r
-\r
-[Pcd]\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuBootMode\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFirmwareVolume\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuMemorySize\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFdBaseAddress\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFirmwareFdSize\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFirmwareBlockSize\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuApCount\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuVirtualDisk\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuGop|L"GOP Window"\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFileSystem\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuSerialPort\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuNetworkInterface\r
-  gInOsEmuPkgTokenSpaceGuid.PcdNetworkPacketFilterSize\r
-\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashFvRecoveryBase\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashFvRecoverySize\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogBase\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogSize\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwWorkingBase\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
-  gInOsEmuPkgTokenSpaceGuid.PcdPeiServicesTablePage\r
-\r
-\r
-[BuildOptions]\r
-   GCC:*_*_IA32_DLINK_FLAGS == -o $(BIN_DIR)/SecMain -m elf_i386 -dynamic-linker /lib$(LIB_ARCH_SFX)/ld-linux.so.2 /usr/lib$(LIB_ARCH_SFX)/crt1.o /usr/lib$(LIB_ARCH_SFX)/crti.o -L/usr/X11R6/lib -lXext -lX11 /usr/lib$(LIB_ARCH_SFX)/crtn.o\r
-   GCC:*_*_*_DLINK2_FLAGS == -lpthread -lc\r
-   GCC:*_*_IA32_CC_FLAGS == -m32 -g -fshort-wchar -fno-strict-aliasing -Wall -malign-double -idirafter/usr/include -c -include $(DEST_DIR_DEBUG)/AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings\r
-   GCC:*_*_IA32_PP_FLAGS == -m32 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h\r
-   GCC:*_*_IA32_ASM_FLAGS == -m32 -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h\r
-\r
-   GCC:*_*_X64_DLINK_FLAGS == -o $(BIN_DIR)/SecMain -m elf_x86_64 -dynamic-linker /lib$(LIB_ARCH_SFX)/ld-linux-x86-64.so.2 /usr/lib$(LIB_ARCH_SFX)/crt1.o /usr/lib$(LIB_ARCH_SFX)/crti.o -L/usr/X11R6/lib -lXext -lX11 /usr/lib$(LIB_ARCH_SFX)/crtn.o\r
-   GCC:*_*_X64_CC_FLAGS == -m64 -g -fshort-wchar -fno-strict-aliasing -Wall -malign-double -idirafter/usr/include -c -include $(DEST_DIR_DEBUG)/AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings\r
-   GCC:*_GCC44_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))"\r
-   GCC:*_GCC45_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))"\r
-   GCC:*_*_X64_PP_FLAGS == -m64 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h\r
-   GCC:*_*_X64_ASM_FLAGS == -m64 -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h\r
-\r
-#\r
-# Need to do this link via gcc and not ld as the pathing to libraries changes from OS version to OS version\r
-#\r
-   XCODE:*_*_IA32_DLINK_PATH == gcc\r
-   XCODE:*_*_IA32_CC_FLAGS == -arch i386 -O0 -g -include $(DEST_DIR_DEBUG)/AutoGen.h -c -fshort-wchar -fno-strict-aliasing\r
-   XCODE:*_*_IA32_DLINK_FLAGS == -arch i386 -o $(BIN_DIR)/SecMain -L/usr/X11R6/lib -lXext -lX11 -framework Carbon\r
-   XCODE:*_*_IA32_ASM_FLAGS == -arch i386 -g\r
-\r
-   XCODE:*_*_X64_DLINK_PATH == gcc\r
-   XCODE:*_*_X64_DLINK_FLAGS == -o $(BIN_DIR)/SecMain -L/usr/X11R6/lib -lXext -lX11 -framework Carbon\r
-   XCODE:*_*_X64_ASM_FLAGS == -g\r
-\r
diff --git a/InOsEmuPkg/Unix/Sec/X11GraphicsWindow.c b/InOsEmuPkg/Unix/Sec/X11GraphicsWindow.c
deleted file mode 100644 (file)
index ddcf1e7..0000000
+++ /dev/null
@@ -1,1028 +0,0 @@
-/*++ @file
-
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
-Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
-
-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 "SecMain.h"
-
-#include <sys/ipc.h>
-#include <sys/shm.h>
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xos.h>
-#include <X11/extensions/XShm.h>
-#include <X11/keysym.h>
-#include <X11/cursorfont.h>
-
-#define KEYSYM_LOWER  0
-#define KEYSYM_UPPER  1
-
-
-struct uga_drv_shift_mask {
-  unsigned char shift;
-  unsigned char size;
-  unsigned char csize;
-};
-
-#define NBR_KEYS 32
-typedef struct {
-  EMU_GRAPHICS_WINDOW_PROTOCOL GraphicsIo;
-
-  Display     *display;
-  int         screen;      // values for window_size in main 
-  Window      win;
-  GC          gc;
-  Visual      *visual;
-
-  int           depth;
-  unsigned int  width;
-  unsigned int  height;
-  unsigned int  line_bytes;
-  unsigned int  pixel_shift;
-  unsigned char *image_data;
-
-  struct uga_drv_shift_mask r, g, b;
-
-  int             use_shm;
-  XShmSegmentInfo xshm_info;
-  XImage          *image;
-  char            *Title;
-
-  unsigned int key_rd;
-  unsigned int key_wr;
-  unsigned int key_count;
-  EFI_KEY_DATA keys[NBR_KEYS];
-
-  EFI_KEY_STATE KeyState;
-  
-  EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK    MakeRegisterdKeyCallback;
-  EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK    BreakRegisterdKeyCallback;
-  VOID                                                *RegisterdKeyCallbackContext;
-  
-  int                        previous_x;
-  int                        previous_y;
-  EFI_SIMPLE_POINTER_STATE   pointer_state;
-  int                        pointer_state_changed;
-} GRAPHICS_IO_PRIVATE;
-
-void
-HandleEvents(
-  IN GRAPHICS_IO_PRIVATE *Drv
-  );
-
-void
-fill_shift_mask (
-  IN  struct uga_drv_shift_mask *sm, 
-  IN  unsigned long             mask
-  )
-{
-  sm->shift = 0;
-  sm->size = 0;
-  while ((mask & 1) == 0) {
-    mask >>= 1;
-    sm->shift++;
-  }
-  while (mask & 1) {
-    sm->size++;
-    mask >>= 1;
-  }
-  sm->csize = 8 - sm->size;
-}
-
-int
-TryCreateShmImage (
-  IN  GRAPHICS_IO_PRIVATE *Drv
-  )
-{
-  Drv->image = XShmCreateImage (
-                 Drv->display, Drv->visual,
-                 Drv->depth, ZPixmap, NULL, &Drv->xshm_info,
-                 Drv->width, Drv->height
-                 );
-  if (Drv->image == NULL) {
-    return 0;
-  }
-
-  switch (Drv->image->bitmap_unit) {
-  case 32:
-    Drv->pixel_shift = 2;
-    break;
-  case 16:
-    Drv->pixel_shift = 1;
-    break;
-  case 8:
-    Drv->pixel_shift = 0;
-    break;
-  }
-
-  Drv->xshm_info.shmid = shmget (
-                          IPC_PRIVATE, Drv->image->bytes_per_line * Drv->image->height,
-                          IPC_CREAT | 0777
-                          );
-  if (Drv->xshm_info.shmid < 0) {
-    XDestroyImage(Drv->image);
-    return 0;
-  }
-      
-  Drv->image_data = shmat (Drv->xshm_info.shmid, NULL, 0);
-  if(!Drv->image_data) {
-    shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL);
-    XDestroyImage(Drv->image);
-    return 0;
-  }
-  
-#ifndef __APPLE__  
-  //
-  // This closes shared memory in real time on OS X. Only closes after folks quit using
-  // it on Linux. 
-  //
-  shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL);
-#endif
-
-  Drv->xshm_info.shmaddr = (char*)Drv->image_data;
-  Drv->image->data = (char*)Drv->image_data;
-
-  if (!XShmAttach (Drv->display, &Drv->xshm_info)) {
-    shmdt (Drv->image_data);
-    XDestroyImage(Drv->image);
-    return 0;
-  }
-  return 1;
-}
-
-
-EFI_STATUS
-X11Size (
-  IN  EMU_GRAPHICS_WINDOW_PROTOCOL  *GraphicsIo, 
-  IN  UINT32                        Width, 
-  IN  UINT32                        Height
-  )
-{
-  GRAPHICS_IO_PRIVATE *Drv;
-  XSizeHints          size_hints;
-
-  // Destroy current buffer if created. 
-  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
-  if (Drv->image != NULL) {
-    // Before destroy buffer, need to make sure the buffer available for access. 
-    XDestroyImage (Drv->image);
-
-    if (Drv->use_shm) {
-      shmdt (Drv->image_data);
-    }
-
-    Drv->image_data = NULL;
-    Drv->image = NULL;
-  }
-
-  Drv->width = Width;
-  Drv->height = Height;
-  XResizeWindow (Drv->display, Drv->win, Width, Height);
-
-  // Allocate image. 
-  if (XShmQueryExtension(Drv->display) && TryCreateShmImage(Drv)) {
-    Drv->use_shm = 1;
-  } else {
-    Drv->use_shm = 0;
-    if (Drv->depth > 16) {
-      Drv->pixel_shift = 2;
-    } else if (Drv->depth > 8) {
-      Drv->pixel_shift = 1;
-    } else {
-      Drv->pixel_shift = 0;
-    }
-      
-    Drv->image_data = malloc ((Drv->width * Drv->height) << Drv->pixel_shift);
-    Drv->image = XCreateImage (
-                    Drv->display, Drv->visual, Drv->depth,
-                    ZPixmap, 0, (char *)Drv->image_data,
-                    Drv->width, Drv->height,
-                    8 << Drv->pixel_shift, 0
-                    );
-  }
-  
-  Drv->line_bytes = Drv->image->bytes_per_line;
-
-  fill_shift_mask (&Drv->r, Drv->image->red_mask);
-  fill_shift_mask (&Drv->g, Drv->image->green_mask);
-  fill_shift_mask (&Drv->b, Drv->image->blue_mask);
-
-  // Set WM hints.  
-  size_hints.flags = PSize | PMinSize | PMaxSize;
-  size_hints.min_width = size_hints.max_width = size_hints.base_width = Width;
-  size_hints.min_height = size_hints.max_height = size_hints.base_height = Height;
-  XSetWMNormalHints (Drv->display, Drv->win, &size_hints);
-
-  XMapWindow (Drv->display, Drv->win);
-  HandleEvents (Drv);
-  return EFI_SUCCESS;
-}
-
-void
-handleKeyEvent (
-  IN  GRAPHICS_IO_PRIVATE *Drv, 
-  IN  XEvent              *ev, 
-  IN  BOOLEAN             Make
-  )
-{
-  KeySym        *KeySym;
-  EFI_KEY_DATA  KeyData;
-  int           KeySymArraySize;
-  if (Make) {
-    if (Drv->key_count == NBR_KEYS) {
-      return;
-    }
-  }
-
-  // keycode is a physical key on the keyboard
-  // KeySym is a mapping of a physical key
-  // KeyboardMapping is the array of KeySym for a given keycode. key, shifted key, option key, command key, ...
-  //
-  // Returns an array of KeySymArraySize of KeySym for the keycode. [0] is lower case, [1] is upper case,
-  // [2] and [3] are based on option and command modifiers. The problem we have is command V
-  // could be mapped to a crazy Unicode character so the old scheme of returning a string. 
-  //
-  KeySym = XGetKeyboardMapping (Drv->display, ev->xkey.keycode, 1, &KeySymArraySize);
-   
-  KeyData.Key.ScanCode = 0;
-  KeyData.Key.UnicodeChar = 0;
-  KeyData.KeyState.KeyShiftState = 0;
-
-  //
-  // Skipping EFI_SCROLL_LOCK_ACTIVE & EFI_NUM_LOCK_ACTIVE since they are not on Macs  
-  //
-  if ((ev->xkey.state & LockMask) == 0) {
-    Drv->KeyState.KeyToggleState &= ~EFI_CAPS_LOCK_ACTIVE;
-  } else {
-    if (Make) {
-      Drv->KeyState.KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;
-    }
-  }
-  
-  // Skipping EFI_MENU_KEY_PRESSED and EFI_SYS_REQ_PRESSED
-  
-  switch (*KeySym) {
-  case XK_Control_R:
-    if (Make) {
-      Drv->KeyState.KeyShiftState |=  EFI_RIGHT_CONTROL_PRESSED;
-    } else {
-      Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_CONTROL_PRESSED;
-    }
-   break;
-  case XK_Control_L:
-    if (Make) {    
-      Drv->KeyState.KeyShiftState |=  EFI_LEFT_CONTROL_PRESSED;
-    } else {
-      Drv->KeyState.KeyShiftState &= ~EFI_LEFT_CONTROL_PRESSED;
-    }
-    break;
-
-  case XK_Shift_R:
-    if (Make) {
-      Drv->KeyState.KeyShiftState |=  EFI_RIGHT_SHIFT_PRESSED;
-    } else {
-      Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_SHIFT_PRESSED;
-    }
-    break;
-  case XK_Shift_L:
-    if (Make) {
-      Drv->KeyState.KeyShiftState |=  EFI_LEFT_SHIFT_PRESSED;
-    } else {
-      Drv->KeyState.KeyShiftState &= ~EFI_LEFT_SHIFT_PRESSED;
-    }
-    break;
-  
-  case XK_Mode_switch:
-    if (Make) {
-      Drv->KeyState.KeyShiftState |=  EFI_LEFT_ALT_PRESSED;
-    } else {
-      Drv->KeyState.KeyShiftState &= ~EFI_LEFT_ALT_PRESSED;
-    }
-    break;
-
-  case XK_Meta_R:
-    if (Make) {
-      Drv->KeyState.KeyShiftState |=  EFI_RIGHT_LOGO_PRESSED;
-    } else {
-      Drv->KeyState.KeyShiftState &= ~EFI_RIGHT_LOGO_PRESSED;
-    }
-    break;
-  case XK_Meta_L:
-    if (Make) {
-      Drv->KeyState.KeyShiftState |=  EFI_LEFT_LOGO_PRESSED;
-    } else {
-      Drv->KeyState.KeyShiftState &= ~EFI_LEFT_LOGO_PRESSED;
-    }
-    break;
-  
-  case XK_KP_Home:
-  case XK_Home:       KeyData.Key.ScanCode = SCAN_HOME;       break;
-  
-  case XK_KP_End:
-  case XK_End:        KeyData.Key.ScanCode = SCAN_END;        break;
-  
-  case XK_KP_Left: 
-  case XK_Left:       KeyData.Key.ScanCode = SCAN_LEFT;       break;
-  
-  case XK_KP_Right:
-  case XK_Right:      KeyData.Key.ScanCode = SCAN_RIGHT;      break;
-  
-  case XK_KP_Up:
-  case XK_Up:         KeyData.Key.ScanCode = SCAN_UP;         break;
-  
-  case XK_KP_Down:
-  case XK_Down:       KeyData.Key.ScanCode = SCAN_DOWN;       break;
-  
-  case XK_KP_Delete:
-  case XK_Delete:       KeyData.Key.ScanCode = SCAN_DELETE;     break;
-  
-  case XK_KP_Insert:  
-  case XK_Insert:     KeyData.Key.ScanCode = SCAN_INSERT;     break;
-  
-  case XK_KP_Page_Up:
-  case XK_Page_Up:    KeyData.Key.ScanCode = SCAN_PAGE_UP;    break;
-  
-  case XK_KP_Page_Down:
-  case XK_Page_Down:  KeyData.Key.ScanCode = SCAN_PAGE_DOWN;  break;
-  
-  case XK_Escape:     KeyData.Key.ScanCode = SCAN_ESC;        break;
-
-  case XK_Pause:      KeyData.Key.ScanCode = SCAN_PAUSE;      break;
-
-  case XK_KP_F1:
-  case XK_F1:   KeyData.Key.ScanCode = SCAN_F1;   break;
-  
-  case XK_KP_F2:
-  case XK_F2:   KeyData.Key.ScanCode = SCAN_F2;   break;
-
-  case XK_KP_F3:
-  case XK_F3:   KeyData.Key.ScanCode = SCAN_F3;   break;
-
-  case XK_KP_F4:
-  case XK_F4:   KeyData.Key.ScanCode = SCAN_F4;   break;
-
-  case XK_F5:   KeyData.Key.ScanCode = SCAN_F5;   break;
-  case XK_F6:   KeyData.Key.ScanCode = SCAN_F6;   break;
-  case XK_F7:   KeyData.Key.ScanCode = SCAN_F7;   break;
-  
-  // Don't map into X11 by default on a Mac
-  // System Preferences->Keyboard->Keyboard Shortcuts can be configured 
-  // to not use higher function keys as shortcuts and the will show up
-  // in X11. 
-  case XK_F8:   KeyData.Key.ScanCode = SCAN_F8;   break;
-  case XK_F9:   KeyData.Key.ScanCode = SCAN_F9;   break;
-  case XK_F10:  KeyData.Key.ScanCode = SCAN_F10;  break;
-  
-  case XK_F11:  KeyData.Key.ScanCode = SCAN_F11;  break;
-  case XK_F12:  KeyData.Key.ScanCode = SCAN_F12;  break;
-  
-  case XK_F13:  KeyData.Key.ScanCode = SCAN_F13;  break;
-  case XK_F14:  KeyData.Key.ScanCode = SCAN_F14;  break;
-  case XK_F15:  KeyData.Key.ScanCode = SCAN_F15;  break;
-  case XK_F16:  KeyData.Key.ScanCode = SCAN_F16;  break;
-  case XK_F17:  KeyData.Key.ScanCode = SCAN_F17;  break;
-  case XK_F18:  KeyData.Key.ScanCode = SCAN_F18;  break;
-  case XK_F19:  KeyData.Key.ScanCode = SCAN_F19;  break;
-  case XK_F20:  KeyData.Key.ScanCode = SCAN_F20;  break;
-  case XK_F21:  KeyData.Key.ScanCode = SCAN_F21;  break;
-  case XK_F22:  KeyData.Key.ScanCode = SCAN_F22;  break;
-  case XK_F23:  KeyData.Key.ScanCode = SCAN_F23;  break;
-  case XK_F24:  KeyData.Key.ScanCode = SCAN_F24;  break;
-
-  // No mapping in X11
-  //case XK_:   KeyData.Key.ScanCode = SCAN_MUTE;            break;             
-  //case XK_:   KeyData.Key.ScanCode = SCAN_VOLUME_UP;       break;            
-  //case XK_:   KeyData.Key.ScanCode = SCAN_VOLUME_DOWN;     break;       
-  //case XK_:   KeyData.Key.ScanCode = SCAN_BRIGHTNESS_UP;   break;      
-  //case XK_:   KeyData.Key.ScanCode = SCAN_BRIGHTNESS_DOWN; break;    
-  //case XK_:   KeyData.Key.ScanCode = SCAN_SUSPEND;         break; 
-  //case XK_:   KeyData.Key.ScanCode = SCAN_HIBERNATE;       break; 
-  //case XK_:   KeyData.Key.ScanCode = SCAN_TOGGLE_DISPLAY;  break;       
-  //case XK_:   KeyData.Key.ScanCode = SCAN_RECOVERY;        break;      
-  //case XK_:   KeyData.Key.ScanCode = SCAN_EJECT;           break;     
-
-  case XK_BackSpace:  KeyData.Key.UnicodeChar = 0x0008; break;
-
-  case XK_KP_Tab:
-  case XK_Tab:        KeyData.Key.UnicodeChar = 0x0009; break;
-
-  case XK_Linefeed:   KeyData.Key.UnicodeChar = 0x000a; break;
-  
-  case XK_KP_Enter:
-  case XK_Return:     KeyData.Key.UnicodeChar = 0x000d; break;
-
-  case XK_KP_Equal      : KeyData.Key.UnicodeChar = L'='; break;                     
-  case XK_KP_Multiply   : KeyData.Key.UnicodeChar = L'*'; break;                  
-  case XK_KP_Add        : KeyData.Key.UnicodeChar = L'+'; break;                       
-  case XK_KP_Separator  : KeyData.Key.UnicodeChar = L'~'; break;                  
-  case XK_KP_Subtract   : KeyData.Key.UnicodeChar = L'-'; break;                  
-  case XK_KP_Decimal    : KeyData.Key.UnicodeChar = L'.'; break;                   
-  case XK_KP_Divide     : KeyData.Key.UnicodeChar = L'/'; break;                    
-
-  case XK_KP_0    : KeyData.Key.UnicodeChar = L'0'; break;                         
-  case XK_KP_1    : KeyData.Key.UnicodeChar = L'1'; break;                         
-  case XK_KP_2    : KeyData.Key.UnicodeChar = L'2'; break;                         
-  case XK_KP_3    : KeyData.Key.UnicodeChar = L'3'; break;                         
-  case XK_KP_4    : KeyData.Key.UnicodeChar = L'4'; break;                        
-  case XK_KP_5    : KeyData.Key.UnicodeChar = L'5'; break;                         
-  case XK_KP_6    : KeyData.Key.UnicodeChar = L'6'; break;                         
-  case XK_KP_7    : KeyData.Key.UnicodeChar = L'7'; break;                         
-  case XK_KP_8    : KeyData.Key.UnicodeChar = L'8'; break;                        
-  case XK_KP_9    : KeyData.Key.UnicodeChar = L'9'; break;                         
-
-  default:
-    ;
-  }
-
-  // The global state is our state
-  KeyData.KeyState.KeyShiftState = Drv->KeyState.KeyShiftState;
-  KeyData.KeyState.KeyToggleState = Drv->KeyState.KeyToggleState;
-
-  if (*KeySym < XK_BackSpace) {
-    if (((Drv->KeyState.KeyShiftState & (EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED)) != 0) ||
-        ((Drv->KeyState.KeyToggleState & EFI_CAPS_LOCK_ACTIVE) != 0) ) {
-      
-      KeyData.Key.UnicodeChar = (CHAR16)KeySym[KEYSYM_UPPER];
-
-      // Per UEFI spec since we converted the Unicode clear the shift bits we pass up 
-      KeyData.KeyState.KeyShiftState &= ~(EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED);
-    } else {
-      KeyData.Key.UnicodeChar = (CHAR16)KeySym[KEYSYM_LOWER];
-    }
-  } else {
-    // XK_BackSpace is the start of XK_MISCELLANY. These are the XK_? keys we process in this file 
-    ; 
-  }
-  
-  if (Make) {
-    memcpy (&Drv->keys[Drv->key_wr], &KeyData, sizeof (EFI_KEY_DATA));
-    Drv->key_wr = (Drv->key_wr + 1) % NBR_KEYS;
-    Drv->key_count++; 
-    if (Drv->MakeRegisterdKeyCallback != NULL) {
-      ReverseGasketUint64Uint64 (Drv->MakeRegisterdKeyCallback ,Drv->RegisterdKeyCallbackContext, &KeyData);
-    }
-  } else {
-    if (Drv->BreakRegisterdKeyCallback != NULL) {
-      ReverseGasketUint64Uint64 (Drv->BreakRegisterdKeyCallback ,Drv->RegisterdKeyCallbackContext, &KeyData);
-    }
-  }
-}
-
-
-void
-handleMouseMoved(
-  IN  GRAPHICS_IO_PRIVATE   *Drv, 
-  IN  XEvent                *ev
-  )
-{
-  if (ev->xmotion.x != Drv->previous_x) {
-    Drv->pointer_state.RelativeMovementX += ( ev->xmotion.x - Drv->previous_x );
-    Drv->previous_x = ev->xmotion.x;
-    Drv->pointer_state_changed = 1;
-  }
-
-  if (ev->xmotion.y != Drv->previous_y) {
-    Drv->pointer_state.RelativeMovementY += ( ev->xmotion.y - Drv->previous_y );
-    Drv->previous_y = ev->xmotion.y;
-    Drv->pointer_state_changed = 1;
-  }
-
-  Drv->pointer_state.RelativeMovementZ = 0;
-}
-
-void
-handleMouseDown (
-  IN  GRAPHICS_IO_PRIVATE *Drv, 
-  IN  XEvent              *ev, 
-  IN  BOOLEAN             Pressed
-  )
-{
-  if (ev->xbutton.button == Button1) {
-    Drv->pointer_state_changed = (Drv->pointer_state.LeftButton != Pressed);
-    Drv->pointer_state.LeftButton = Pressed;
-  }
-  if ( ev->xbutton.button == Button2 ) {
-    Drv->pointer_state_changed = (Drv->pointer_state.RightButton != Pressed);
-    Drv->pointer_state.RightButton = Pressed;
-  }
-}
-
-void
-Redraw (
-  IN  GRAPHICS_IO_PRIVATE *Drv, 
-  IN  UINTN               X, 
-  IN  UINTN               Y, 
-  IN  UINTN               Width, 
-  IN  UINTN               Height
-  )
-{
-  if (Drv->use_shm) {
-    XShmPutImage (
-      Drv->display, Drv->win, Drv->gc, Drv->image, X, Y, X, Y, Width, Height, False
-      );
-  } else {
-    XPutImage (
-      Drv->display, Drv->win, Drv->gc, Drv->image, X, Y, X, Y, Width, Height
-      );
-  }
-  XFlush(Drv->display);
-}
-
-void
-HandleEvent(GRAPHICS_IO_PRIVATE *Drv, XEvent *ev)
-{
-  switch (ev->type) {
-  case Expose:
-    Redraw (Drv, ev->xexpose.x, ev->xexpose.y,
-      ev->xexpose.width, ev->xexpose.height);
-    break;
-  case GraphicsExpose:
-    Redraw (Drv, ev->xgraphicsexpose.x, ev->xgraphicsexpose.y,
-      ev->xgraphicsexpose.width, ev->xgraphicsexpose.height);
-    break;
-  case KeyPress:
-    handleKeyEvent (Drv, ev, TRUE);
-    break;
-  case KeyRelease:
-    handleKeyEvent (Drv, ev, FALSE);
-    break;
-  case MappingNotify:
-    XRefreshKeyboardMapping (&ev->xmapping);
-    break;
-  case MotionNotify:
-    handleMouseMoved (Drv, ev);
-    break;
-  case ButtonPress:
-    handleMouseDown (Drv, ev, TRUE);
-  break;
-  case ButtonRelease:
-    handleMouseDown (Drv, ev, FALSE);
-  break;
-#if 0
-  case DestroyNotify:
-    XCloseDisplay (Drv->display);
-    exit (1);
-    break;
-#endif
-  case NoExpose:
-  default:
-    break;
-  }
-}
-
-void
-HandleEvents (
-  IN  GRAPHICS_IO_PRIVATE *Drv
-  )
-{
-  XEvent ev;
-
-  while (XPending (Drv->display) != 0) {
-    XNextEvent (Drv->display, &ev);
-    HandleEvent (Drv, &ev);
-  }
-}
-
-unsigned long
-X11PixelToColor (
-  IN  GRAPHICS_IO_PRIVATE *Drv, 
-  IN  EFI_UGA_PIXEL       pixel
-  )
-{
-  return ((pixel.Red   >> Drv->r.csize) << Drv->r.shift)
-       | ((pixel.Green >> Drv->g.csize) << Drv->g.shift)
-       | ((pixel.Blue  >> Drv->b.csize) << Drv->b.shift);
-}
-
-EFI_UGA_PIXEL
-X11ColorToPixel (
-  IN  GRAPHICS_IO_PRIVATE *Drv, 
-  IN  unsigned long       val
-  )
-{
-  EFI_UGA_PIXEL Pixel;
-
-  memset (&Pixel, 0, sizeof (EFI_UGA_PIXEL));
-  
-  // Truncation not an issue since X11 and EFI are both using 8 bits per color
-  Pixel.Red =   (val >> Drv->r.shift) << Drv->r.csize;
-  Pixel.Green = (val >> Drv->g.shift) << Drv->g.csize;
-  Pixel.Blue =  (val >> Drv->b.shift) << Drv->b.csize;
-
-  return Pixel;
-}
-
-
-EFI_STATUS
-X11CheckKey (
-  IN  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
-  )
-{
-  GRAPHICS_IO_PRIVATE  *Drv;
-  
-  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
-  
-  HandleEvents (Drv);
-  
-  if (Drv->key_count != 0) {
-    return EFI_SUCCESS;
-  }
-  
-  return EFI_NOT_READY;
-}
-
-EFI_STATUS
-X11GetKey (
-  IN  EMU_GRAPHICS_WINDOW_PROTOCOL  *GraphicsIo, 
-  IN  EFI_KEY_DATA                  *KeyData
-  )
-{
-  EFI_STATUS          EfiStatus;
-  GRAPHICS_IO_PRIVATE *Drv;
-  
-  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
-
-  EfiStatus = X11CheckKey (GraphicsIo);
-  if (EFI_ERROR (EfiStatus)) {
-    return EfiStatus;
-  }
-  
-  CopyMem (KeyData, &Drv->keys[Drv->key_rd], sizeof (EFI_KEY_DATA));
-  Drv->key_rd = (Drv->key_rd + 1) % NBR_KEYS;
-  Drv->key_count--;
-  
-  return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-X11KeySetState (
-  IN EMU_GRAPHICS_WINDOW_PROTOCOL   *GraphicsIo, 
-  IN EFI_KEY_TOGGLE_STATE           *KeyToggleState
-  )
-{
-  GRAPHICS_IO_PRIVATE  *Drv;
-  
-  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;  
-  
-  if (*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) {
-    if ((Drv->KeyState.KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == 0) {
-      //
-      // We could create an XKeyEvent and send a XK_Caps_Lock to
-      // the UGA/GOP Window
-      //
-    }
-  }
-    
-  Drv->KeyState.KeyToggleState = *KeyToggleState;
-  return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-X11RegisterKeyNotify (
-  IN EMU_GRAPHICS_WINDOW_PROTOCOL                        *GraphicsIo, 
-  IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK    MakeCallBack,
-  IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK    BreakCallBack,
-  IN VOID                                                *Context
-  )
-{
-  GRAPHICS_IO_PRIVATE  *Drv;
-
-  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;  
-
-  Drv->MakeRegisterdKeyCallback    = MakeCallBack;
-  Drv->BreakRegisterdKeyCallback   = BreakCallBack;
-  Drv->RegisterdKeyCallbackContext = Context;
-
-  return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-X11Blt (
-  IN EMU_GRAPHICS_WINDOW_PROTOCOL             *GraphicsIo,
-  IN  EFI_UGA_PIXEL                           *BltBuffer OPTIONAL,
-  IN  EFI_UGA_BLT_OPERATION                   BltOperation,
-  IN  EMU_GRAPHICS_WINDOWS__BLT_ARGS          *Args
-  )
-{
-  GRAPHICS_IO_PRIVATE *Private;
-  UINTN             DstY;
-  UINTN             SrcY;
-  UINTN             DstX;
-  UINTN             SrcX;
-  UINTN             Index;
-  EFI_UGA_PIXEL     *Blt;
-  UINT8             *Dst;
-  UINT8             *Src;
-  UINTN             Nbr;
-  unsigned long     Color;
-  XEvent            ev;
-
-  Private = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
-
-
-  //
-  //  Check bounds
-  //
-  if (BltOperation == EfiUgaVideoToBltBuffer
-      || BltOperation == EfiUgaVideoToVideo) {
-    //
-    // Source is Video.
-    //
-    if (Args->SourceY + Args->Height > Private->height) {
-      return EFI_INVALID_PARAMETER;
-    }
-
-    if (Args->SourceX + Args->Width > Private->width) {
-      return EFI_INVALID_PARAMETER;
-    }
-  }
-
-  if (BltOperation == EfiUgaBltBufferToVideo
-      || BltOperation == EfiUgaVideoToVideo
-      || BltOperation == EfiUgaVideoFill) {
-    //
-    // Destination is Video
-    //
-    if (Args->DestinationY + Args->Height > Private->height) {
-      return EFI_INVALID_PARAMETER;
-    }
-
-    if (Args->DestinationX + Args->Width > Private->width) {
-      return EFI_INVALID_PARAMETER;
-    }
-  }
-
-  switch (BltOperation) {
-  case EfiUgaVideoToBltBuffer:
-    Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (Args->DestinationY * Args->Delta) + Args->DestinationX * sizeof (EFI_UGA_PIXEL));
-    Args->Delta -= Args->Width * sizeof (EFI_UGA_PIXEL);
-    for (SrcY = Args->SourceY; SrcY < (Args->Height + Args->SourceY); SrcY++) {
-      for (SrcX = Args->SourceX; SrcX < (Args->Width + Args->SourceX); SrcX++) {
-        *Blt++ = X11ColorToPixel (Private, XGetPixel (Private->image, SrcX, SrcY));
-      }
-      Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Args->Delta);
-    }
-    break;
-  case EfiUgaBltBufferToVideo:
-    Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (Args->SourceY * Args->Delta) + Args->SourceX * sizeof (EFI_UGA_PIXEL));
-    Args->Delta -= Args->Width * sizeof (EFI_UGA_PIXEL);
-    for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) {
-      for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) {
-        XPutPixel(Private->image, DstX, DstY, X11PixelToColor(Private, *Blt));
-        Blt++;
-      }
-      Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Args->Delta);
-    }
-    break;
-  case EfiUgaVideoToVideo:
-    Dst = Private->image_data + (Args->DestinationX << Private->pixel_shift)
-          + Args->DestinationY * Private->line_bytes;
-    Src = Private->image_data + (Args->SourceX << Private->pixel_shift)
-          + Args->SourceY * Private->line_bytes;
-    Nbr = Args->Width << Private->pixel_shift;
-    if (Args->DestinationY < Args->SourceY) {
-      for (Index = 0; Index < Args->Height; Index++) {
-        memcpy (Dst, Src, Nbr);
-        Dst += Private->line_bytes;
-        Src += Private->line_bytes;
-      }
-    } else {
-      Dst += (Args->Height - 1) * Private->line_bytes;
-      Src += (Args->Height - 1) * Private->line_bytes;
-      for (Index = 0; Index < Args->Height; Index++) {
-      //
-      // Source and Destination Y may be equal, therefore Dst and Src may
-      // overlap.
-      //
-      memmove (Dst, Src, Nbr);
-      Dst -= Private->line_bytes;
-      Src -= Private->line_bytes;
-      }
-    }
-    break;
-  case EfiUgaVideoFill:
-    Color = X11PixelToColor(Private, *BltBuffer);
-    for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) {
-      for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) {
-        XPutPixel(Private->image, DstX, DstY, Color);
-      }
-    }
-    break;
-  default:
-    return EFI_INVALID_PARAMETER;
-  }
-
-  //
-  //  Refresh screen.
-  //
-  switch (BltOperation) {
-  case EfiUgaVideoToVideo:
-    XCopyArea(
-      Private->display, Private->win, Private->win, Private->gc,
-      Args->SourceX, Args->SourceY, Args->Width, Args->Height, 
-      Args->DestinationX, Args->DestinationY
-      );
-      
-    while (1) {
-      XNextEvent (Private->display, &ev);
-      HandleEvent (Private, &ev);
-      if (ev.type == NoExpose || ev.type == GraphicsExpose) {
-        break;
-      }
-    }
-    break;
-  case EfiUgaVideoFill:
-    Color = X11PixelToColor (Private, *BltBuffer);
-    XSetForeground (Private->display, Private->gc, Color);
-    XFillRectangle (
-      Private->display, Private->win, Private->gc,
-      Args->DestinationX, Args->DestinationY, Args->Width, Args->Height
-      );
-    XFlush (Private->display);
-    break;
-  case EfiUgaBltBufferToVideo:
-    Redraw (Private, Args->DestinationX, Args->DestinationY, Args->Width, Args->Height);
-    break;
-  default:
-    break;
-  }
-  return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-X11CheckPointer (
-  IN  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
-  )
-{
-  GRAPHICS_IO_PRIVATE  *Drv;
-
-  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
-
-  HandleEvents (Drv);
-  if (Drv->pointer_state_changed != 0) {
-    return EFI_SUCCESS;
-  }
-  
-  return EFI_NOT_READY;
-}
-
-
-EFI_STATUS
-X11GetPointerState (
-  IN  EMU_GRAPHICS_WINDOW_PROTOCOL  *GraphicsIo, 
-  IN  EFI_SIMPLE_POINTER_STATE      *State
-  )
-{
-  EFI_STATUS          EfiStatus;
-  GRAPHICS_IO_PRIVATE *Drv;
-
-  Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo;
-
-  EfiStatus = X11CheckPointer (GraphicsIo);
-  if (EfiStatus != EFI_SUCCESS) {
-    return EfiStatus;
-  }
-  
-  memcpy (State, &Drv->pointer_state, sizeof (EFI_SIMPLE_POINTER_STATE));
-
-  Drv->pointer_state.RelativeMovementX = 0;
-  Drv->pointer_state.RelativeMovementY = 0;
-  Drv->pointer_state.RelativeMovementZ = 0;
-  Drv->pointer_state_changed = 0;
-  return EFI_SUCCESS;
-}
-
-
-
-EFI_STATUS
-X11GraphicsWindowOpen (
-  IN  EMU_IO_THUNK_PROTOCOL   *This
-  )
-{
-  GRAPHICS_IO_PRIVATE *Drv;
-  unsigned int        border_width = 0;
-  char                *display_name = NULL;
-
-  Drv = (GRAPHICS_IO_PRIVATE *)calloc (1, sizeof (GRAPHICS_IO_PRIVATE));
-  if (Drv == NULL) {
-    return EFI_OUT_OF_RESOURCES;
-  }
-
-  Drv->GraphicsIo.Size                = GasketX11Size;
-  Drv->GraphicsIo.CheckKey            = GasketX11CheckKey;
-  Drv->GraphicsIo.GetKey              = GasketX11GetKey;
-  Drv->GraphicsIo.KeySetState         = GasketX11KeySetState;
-  Drv->GraphicsIo.RegisterKeyNotify   = GasketX11RegisterKeyNotify;
-  Drv->GraphicsIo.Blt                 = GasketX11Blt;
-  Drv->GraphicsIo.CheckPointer        = GasketX11CheckPointer;
-  Drv->GraphicsIo.GetPointerState     = GasketX11GetPointerState;
-  
-
-  Drv->key_count = 0;
-  Drv->key_rd = 0;
-  Drv->key_wr = 0;
-  Drv->KeyState.KeyShiftState      = EFI_SHIFT_STATE_VALID;
-  Drv->KeyState.KeyToggleState     = EFI_TOGGLE_STATE_VALID;
-  Drv->MakeRegisterdKeyCallback    = NULL;
-  Drv->BreakRegisterdKeyCallback   = NULL;
-  Drv->RegisterdKeyCallbackContext = NULL;
-  
-  
-  Drv->display = XOpenDisplay (display_name);
-  if (Drv->display == NULL) {
-    fprintf (stderr, "uga: cannot connect to X server %s\n", XDisplayName (display_name));
-    free (Drv);
-    return EFI_DEVICE_ERROR;
-  }
-  Drv->screen = DefaultScreen (Drv->display);
-  Drv->visual = DefaultVisual (Drv->display, Drv->screen);
-  Drv->win = XCreateSimpleWindow (
-                Drv->display, RootWindow (Drv->display, Drv->screen),
-                0, 0, 4, 4, border_width,
-                WhitePixel (Drv->display, Drv->screen),
-                BlackPixel (Drv->display, Drv->screen)
-                );
-
-  Drv->depth = DefaultDepth (Drv->display, Drv->screen);
-  XDefineCursor (Drv->display, Drv->win, XCreateFontCursor (Drv->display, XC_pirate)); 
-
-  Drv->Title = malloc (StrSize (This->ConfigString));  
-  UnicodeStrToAsciiStr (This->ConfigString, Drv->Title);
-  XStoreName (Drv->display, Drv->win, Drv->Title);
-
-//  XAutoRepeatOff (Drv->display);
-  XSelectInput (
-    Drv->display, Drv->win,
-    ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask 
-    );
-  Drv->gc = DefaultGC (Drv->display, Drv->screen);
-
-  This->Private   = (VOID *)Drv;
-  This->Interface = (VOID *)Drv;
-  return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-X11GraphicsWindowClose (
-  IN  EMU_IO_THUNK_PROTOCOL   *This
-  )
-{
-  GRAPHICS_IO_PRIVATE *Drv;
-
-  Drv = (GRAPHICS_IO_PRIVATE *)This->Private;
-
-  if (Drv == NULL) {
-    return EFI_SUCCESS;
-  }
-  
-  if (Drv->image != NULL) {
-    XDestroyImage(Drv->image);
-
-    if (Drv->use_shm) {
-      shmdt (Drv->image_data);
-    }
-
-    Drv->image_data = NULL;
-    Drv->image = NULL;
-  }
-  XDestroyWindow (Drv->display, Drv->win);
-  XCloseDisplay (Drv->display);
-  
-#ifdef __APPLE__
-  // Free up the shared memory
-  shmctl (Drv->xshm_info.shmid, IPC_RMID, NULL);
-#endif
-  
-  free (Drv);
-  return EFI_SUCCESS;
-}
-
-
-EMU_IO_THUNK_PROTOCOL gX11ThunkIo = {
-  &gEmuGraphicsWindowProtocolGuid,
-  NULL,
-  NULL,
-  0,
-  GasketX11GraphicsWindowOpen,
-  GasketX11GraphicsWindowClose,
-  NULL
-};
-
-
diff --git a/InOsEmuPkg/Unix/Sec/X64/Gasket.S b/InOsEmuPkg/Unix/Sec/X64/Gasket.S
deleted file mode 100644 (file)
index 7ea49bb..0000000
+++ /dev/null
@@ -1,1631 +0,0 @@
-#------------------------------------------------------------------------------
-#
-# Manage differenced between UNIX ABI and EFI/Windows ABI
-#
-# EFI  Arg passing: RCX, RDX, R8,  R9
-#                   Callee allocates 32 bytes on stack to spill registers
-# UNIX Arg passing: RDI, RSI, RDX, RCX, R8, R9
-# RSI, RDI calle-save on EFI, scatch on UNIX callign
-#
-# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
-# 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.
-#
-#------------------------------------------------------------------------------
-
-//
-// Gaskets are EFI ABI to UNIX ABI calls
-// EFI ABI code will sub 40 (0x28) from %rsp before calling a function
-//  This is the 32 (0x20) byte to spill registers and 8 bytes to align stack on 16 byte boundry.
-//
-  .text
-
-// 32 byte shadow to spill rcx-r9, 8 bytes to align stack on 16 byte boundry
-// Any call with 0 - 4 arguments allocates 40 bytes on the stack.
-// For more than 4 args you always have to increase in quanta of 16 so 5 or 6 args is 56, 
-// 7 or 8 args is 72, and 9 or 10 args is 88
-
-
-
-  .text
-  
-//
-// EMU_THUNK_PROTOCOL gaskets (EFIAPI to UNIX ABI)
-//
-
-
-
-
-ASM_GLOBAL ASM_PFX(GasketSecWriteStdErr)
-ASM_PFX(GasketSecWriteStdErr):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq    %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call  ASM_PFX(SecWriteStdErr)
-  
-  popq  %rdi            // restore state
-  popq  %rsi
-  popq  %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecConfigStdIn)
-ASM_PFX(GasketSecConfigStdIn):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq    %rdi
-
-  call  ASM_PFX(SecConfigStdIn)
-  
-  popq  %rdi            // restore state
-  popq  %rsi
-  popq  %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecWriteStdOut)
-ASM_PFX(GasketSecWriteStdOut):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq    %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call  ASM_PFX(SecWriteStdOut)
-  
-  popq  %rdi            // restore state
-  popq  %rsi
-  popq  %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecReadStdIn)
-ASM_PFX(GasketSecReadStdIn):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq    %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call  ASM_PFX(SecReadStdIn)
-  
-  popq  %rdi            // restore state
-  popq  %rsi
-  popq  %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecPollStdIn)
-ASM_PFX(GasketSecPollStdIn):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq    %rdi
-
-  call  ASM_PFX(SecPollStdIn)
-  
-  popq  %rdi            // restore state
-  popq  %rsi
-  popq  %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecMalloc)
-ASM_PFX(GasketSecMalloc):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq    %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call  ASM_PFX(SecMalloc)
-  
-  popq  %rdi            // restore state
-  popq  %rsi
-  popq  %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecValloc)
-ASM_PFX(GasketSecValloc):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq    %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call  ASM_PFX(SecValloc)
-  
-  popq  %rdi            // restore state
-  popq  %rsi
-  popq  %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecFree)
-ASM_PFX(GasketSecFree):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq    %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call  ASM_PFX(SecFree)
-  
-  popq  %rdi            // restore state
-  popq  %rsi
-  popq  %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecSetTimer)
-ASM_PFX(GasketSecSetTimer):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq    %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call  ASM_PFX(SecSetTimer)
-  
-  popq  %rdi            // restore state
-  popq  %rsi
-  popq  %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecEnableInterrupt)
-ASM_PFX(GasketSecEnableInterrupt):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  call    ASM_PFX(SecEnableInterrupt)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecDisableInterrupt)
-ASM_PFX(GasketSecDisableInterrupt):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  call    ASM_PFX(SecDisableInterrupt)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketQueryPerformanceFrequency)
-ASM_PFX(GasketQueryPerformanceFrequency):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  call    ASM_PFX(QueryPerformanceFrequency)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketQueryPerformanceCounter)
-ASM_PFX(GasketQueryPerformanceCounter):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  call    ASM_PFX(QueryPerformanceCounter)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecSleep)
-ASM_PFX(GasketSecSleep):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq    %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call  ASM_PFX(SecSleep)
-  
-  popq  %rdi            // restore state
-  popq  %rsi
-  popq  %rbp
-  ret
-  
-  
-ASM_GLOBAL ASM_PFX(GasketSecCpuSleep)
-ASM_PFX(GasketSecCpuSleep):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq    %rdi
-
-  call  ASM_PFX(SecCpuSleep)
-  
-  popq  %rdi            // restore state
-  popq  %rsi
-  popq  %rbp
-  ret
-  
-  
-ASM_GLOBAL ASM_PFX(GasketSecExit)
-ASM_PFX(GasketSecExit):
-  pushq   %rbp                 // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  movq    %rcx, %rdi           // Swizzle args 
-  call    ASM_PFX(SecExit)     // Less to do as we will never return to EFI ABI world
-LDEAD_LOOP:
-  jmp  LDEAD_LOOP              // _exit should never return
-
-  
-ASM_GLOBAL ASM_PFX(GasketSecGetTime)
-ASM_PFX(GasketSecGetTime):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call  ASM_PFX(SecGetTime)
-
-  popq  %rdi            // restore state
-  popq  %rsi
-  popq  %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecSetTime)
-ASM_PFX(GasketSecSetTime):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call  ASM_PFX(SecSetTime)
-
-  popq  %rdi            // restore state
-  popq  %rsi
-  popq  %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecGetNextProtocol)
-ASM_PFX(GasketSecGetNextProtocol):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-
-  call    ASM_PFX(SecGetNextProtocol)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-// PPIs produced by SEC
-
-ASM_GLOBAL ASM_PFX(GasketSecPeCoffGetEntryPoint)
-ASM_PFX(GasketSecPeCoffGetEntryPoint):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call    ASM_PFX(SecPeCoffGetEntryPoint)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-ASM_GLOBAL ASM_PFX(GasketSecPeCoffRelocateImageExtraAction)
-ASM_PFX(GasketSecPeCoffRelocateImageExtraAction):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(SecPeCoffRelocateImageExtraAction)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-ASM_GLOBAL ASM_PFX(GasketSecPeCoffUnloadImageExtraAction)
-ASM_PFX(GasketSecPeCoffUnloadImageExtraAction):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(SecPeCoffUnloadImageExtraAction)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketSecEmuThunkAddress)
-ASM_PFX(GasketSecEmuThunkAddress):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  call    ASM_PFX(SecEmuThunkAddress)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-//
-// Gasket functions for EFI_EMU_UGA_IO_PROTOCOL
-//
-
-ASM_GLOBAL ASM_PFX(GasketX11Size)
-ASM_PFX(GasketX11Size):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-
-  call    ASM_PFX(X11Size)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketX11CheckKey)
-ASM_PFX(GasketX11CheckKey):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(X11CheckKey)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketX11GetKey)
-ASM_PFX(GasketX11GetKey):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call    ASM_PFX(X11GetKey)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketX11KeySetState)
-ASM_PFX(GasketX11KeySetState):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call    ASM_PFX(X11KeySetState)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-  
-ASM_GLOBAL ASM_PFX(GasketX11RegisterKeyNotify)
-ASM_PFX(GasketX11RegisterKeyNotify):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-
-  call    ASM_PFX(X11RegisterKeyNotify)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-  
-ASM_GLOBAL ASM_PFX(GasketX11Blt)
-ASM_PFX(GasketX11Blt):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-
-  call    ASM_PFX(X11Blt)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketX11CheckPointer)
-ASM_PFX(GasketX11CheckPointer):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(X11CheckPointer)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketX11GetPointerState)
-ASM_PFX(GasketX11GetPointerState):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call    ASM_PFX(X11GetPointerState)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowOpen)
-ASM_PFX(GasketX11GraphicsWindowOpen):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(X11GraphicsWindowOpen)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowClose)
-ASM_PFX(GasketX11GraphicsWindowClose):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %r9,  %rcx
-
-  call    ASM_PFX(X11GraphicsWindowClose)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-// Pthreads
-
-ASM_GLOBAL ASM_PFX(GasketPthreadMutexLock)
-ASM_PFX(GasketPthreadMutexLock):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(PthreadMutexLock)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPthreadMutexUnLock)
-ASM_PFX(GasketPthreadMutexUnLock):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(PthreadMutexUnLock)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketPthreadMutexTryLock)
-ASM_PFX(GasketPthreadMutexTryLock):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(PthreadMutexTryLock)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketPthreadMutexInit)
-ASM_PFX(GasketPthreadMutexInit):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-
-  call    ASM_PFX(PthreadMutexInit)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPthreadMutexDestroy)
-ASM_PFX(GasketPthreadMutexDestroy):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(PthreadMutexDestroy)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPthreadCreate)
-ASM_PFX(GasketPthreadCreate):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-
-  call    ASM_PFX(PthreadCreate)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-                          
-ASM_GLOBAL ASM_PFX(GasketPthreadExit)
-ASM_PFX(GasketPthreadExit):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(PthreadExit)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-                            
-ASM_GLOBAL ASM_PFX(GasketPthreadSelf)
-ASM_PFX(GasketPthreadSelf):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-
-  call    ASM_PFX(PthreadSelf)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPthreadOpen)
-ASM_PFX(GasketPthreadOpen):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(PthreadOpen)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPthreadClose)
-ASM_PFX(GasketPthreadClose):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(PthreadClose)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-
-
-//
-// UNIX ABI to EFI ABI call
-//
-// UINTN
-// ReverseGasketUint64 (
-//   void *Api,
-//   UINTN Arg1
-//   );
-ASM_GLOBAL ASM_PFX(ReverseGasketUint64)
-ASM_PFX(ReverseGasketUint64):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  movq    %rdi, %rax    // Swizzle args 
-  movq    %rsi, %rcx     
-
-  subq  $32, %rsp        // 32-byte shadow space
-  call  *%rax
-  addq  $32, %rsp
-
-  popq   %rbp          
-  ret
-
-//
-// UNIX ABI to EFI ABI call
-//
-// UINTN
-// ReverseGasketUint64Uint64 (
-//   void *Api,
-//   UINTN Arg1
-//   UINTN Arg2
-//   );
-ASM_GLOBAL ASM_PFX(ReverseGasketUint64Uint64)
-ASM_PFX(ReverseGasketUint64Uint64):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  movq    %rdi, %rax    // Swizzle args 
-  movq    %rsi, %rcx     
-
-  subq  $32, %rsp        // 32-byte shadow space
-  call  *%rax
-  addq  $32, %rsp
-
-  popq   %rbp          
-  ret
-  
-
-ASM_GLOBAL ASM_PFX(GasketSecUnixPeiAutoScan)
-ASM_PFX(GasketSecUnixPeiAutoScan):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-
-  call    ASM_PFX(SecUnixPeiAutoScan)
-  
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSecUnixFdAddress)
-ASM_PFX(GasketSecUnixFdAddress):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-
-  call    ASM_PFX(SecUnixFdAddress)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-// EmuIoThunk SimpleFileSystem
-
-ASM_GLOBAL ASM_PFX(GasketPosixOpenVolume)
-ASM_PFX(GasketPosixOpenVolume):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-
-  call    ASM_PFX(PosixOpenVolume)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileOpen)
-ASM_PFX(GasketPosixFileOpen):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-  movq    48(%rbp), %r8 
-  call    ASM_PFX(PosixFileOpen)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileCLose)
-ASM_PFX(GasketPosixFileCLose):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(PosixFileCLose)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-  
-ASM_GLOBAL ASM_PFX(GasketPosixFileDelete)
-ASM_PFX(GasketPosixFileDelete):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(PosixFileDelete)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileRead)
-ASM_PFX(GasketPosixFileRead):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-
-  call    ASM_PFX(PosixFileRead)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-  
-ASM_GLOBAL ASM_PFX(GasketPosixFileWrite)
-ASM_PFX(GasketPosixFileWrite):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-
-  call    ASM_PFX(PosixFileWrite)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileSetPossition)
-ASM_PFX(GasketPosixFileSetPossition):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call    ASM_PFX(PosixFileSetPossition)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileGetPossition)
-ASM_PFX(GasketPosixFileGetPossition):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call    ASM_PFX(PosixFileGetPossition)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileGetInfo)
-ASM_PFX(GasketPosixFileGetInfo):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-
-  call    ASM_PFX(PosixFileGetInfo)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileSetInfo)
-ASM_PFX(GasketPosixFileSetInfo):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-
-  call    ASM_PFX(PosixFileSetInfo)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileFlush)
-ASM_PFX(GasketPosixFileFlush):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(PosixFileFlush)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkOpen)
-ASM_PFX(GasketPosixFileSystmeThunkOpen):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(PosixFileSystmeThunkOpen)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkClose)
-ASM_PFX(GasketPosixFileSystmeThunkClose):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(PosixFileSystmeThunkClose)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReset)
-ASM_PFX(GasketEmuBlockIoReset):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call    ASM_PFX(EmuBlockIoReset)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReadBlocks)
-ASM_PFX(GasketEmuBlockIoReadBlocks):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-  movq    48(%rbp), %r8   
-  movq    56(%rbp), %r9   
-
-  call    ASM_PFX(EmuBlockIoReadBlocks)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketEmuBlockIoWriteBlocks)
-ASM_PFX(GasketEmuBlockIoWriteBlocks):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-  movq    48(%rbp), %r8   
-  movq    56(%rbp), %r9   
-
-  call    ASM_PFX(EmuBlockIoWriteBlocks)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketEmuBlockIoFlushBlocks)
-ASM_PFX(GasketEmuBlockIoFlushBlocks):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi    
-
-  call    ASM_PFX(EmuBlockIoFlushBlocks)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketEmuBlockIoCreateMapping)
-ASM_PFX(GasketEmuBlockIoCreateMapping):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call    ASM_PFX(EmuBlockIoCreateMapping)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketBlockIoThunkOpen)
-ASM_PFX(GasketBlockIoThunkOpen):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(EmuBlockIoThunkOpen)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketBlockIoThunkClose)
-ASM_PFX(GasketBlockIoThunkClose):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(EmuBlockIoThunkClose)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpCreateMapping)
-ASM_PFX(GasketSnpCreateMapping):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call    ASM_PFX(EmuSnpCreateMapping)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpStart)
-ASM_PFX(GasketSnpStart):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(EmuSnpStart)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpStop)
-ASM_PFX(GasketSnpStop):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(EmuSnpStop)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpInitialize)
-ASM_PFX(GasketSnpInitialize):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-
-  call    ASM_PFX(EmuSnpInitialize)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpReset)
-ASM_PFX(GasketSnpReset):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-
-  call    ASM_PFX(EmuSnpReset)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpShutdown)
-ASM_PFX(GasketSnpShutdown):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(EmuSnpShutdown)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpReceiveFilters)
-ASM_PFX(GasketSnpReceiveFilters):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-  movq    48(%rbp), %r8   
-  movq    56(%rbp), %r9   
-
-  call    ASM_PFX(EmuSnpReceiveFilters)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpStationAddress)
-ASM_PFX(GasketSnpStationAddress):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-
-  call    ASM_PFX(EmuSnpStationAddress)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpStatistics)
-ASM_PFX(GasketSnpStatistics):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-
-  call    ASM_PFX(EmuSnpStatistics)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpMCastIpToMac)
-ASM_PFX(GasketSnpMCastIpToMac):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-
-  call    ASM_PFX(EmuSnpMCastIpToMac)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpNvData)
-ASM_PFX(GasketSnpNvData):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-  movq    48(%rbp), %r8   
-
-  call    ASM_PFX(EmuSnpNvData)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpGetStatus)
-ASM_PFX(GasketSnpGetStatus):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-
-  call    ASM_PFX(EmuSnpGetStatus)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpTransmit)
-ASM_PFX(GasketSnpTransmit):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-       subq    $16, %rsp       // Allocate space for args on the stack 
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-  movq    48(%rbp), %r8   
-  movq    56(%rbp), %r9   
-  movq    64(%rbp), %rax
-  movq    %rax,     (%rsp)
-
-  call    ASM_PFX(EmuSnpTransmit)
-       addq    $16, %rsp
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpReceive)
-ASM_PFX(GasketSnpReceive):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-       subq    $16, %rsp       // Allocate space for args on the stack
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-  movq    %rdx, %rsi     
-  movq    %r8,  %rdx
-  movq    %r9,  %rcx
-  movq    48(%rbp), %r8   
-  movq    56(%rbp), %r9   
-  movq    64(%rbp), %rax
-  movq    %rax,     (%rsp)
-
-  call    ASM_PFX(EmuSnpReceive)
-       addq    $16, %rsp
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpThunkOpen)
-ASM_PFX(GasketSnpThunkOpen):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(EmuSnpThunkOpen)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
-ASM_GLOBAL ASM_PFX(GasketSnpThunkClose)
-ASM_PFX(GasketSnpThunkClose):
-  pushq   %rbp            // stack frame is for the debugger
-  movq    %rsp, %rbp
-
-  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
-  pushq   %rdi
-
-  movq    %rcx, %rdi    // Swizzle args 
-
-  call    ASM_PFX(EmuSnpThunkClose)
-
-  popq    %rdi          // restore state
-  popq    %rsi
-  popq    %rbp
-  ret
-
-
diff --git a/InOsEmuPkg/Unix/Sec/X64/SwitchStack.S b/InOsEmuPkg/Unix/Sec/X64/SwitchStack.S
deleted file mode 100644 (file)
index 8a57b78..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#------------------------------------------------------------------------------\r
-#\r
-# Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
-# Portitions copyright (c) 2011, Apple Inc. All rights reserved.\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution.  The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php.\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#------------------------------------------------------------------------------\r
-\r
-\r
-#------------------------------------------------------------------------------\r
-# Routine Description:\r
-#\r
-#   Routine for switching stacks with 2 parameters EFI ABI\r
-#   Convert UNIX to EFI ABI\r
-#\r
-# Arguments:\r
-#\r
-#   (rdi) EntryPoint    - Entry point with new stack.\r
-#   (rsi) Context1      - Parameter1 for entry point. (rcx)\r
-#   (rdx) Context2      - Parameter2 for entry point. (rdx) \r
-#   (rcx) NewStack      - The pointer to new stack.\r
-#\r
-# Returns:\r
-#\r
-#   None\r
-#\r
-#------------------------------------------------------------------------------\r
-ASM_GLOBAL ASM_PFX(PeiSwitchStacks)\r
-ASM_PFX(PeiSwitchStacks):\r
-    pushq   $0            // tells gdb to stop unwinding frame\r
-    movq    %rsp, %rbp\r
-\r
-    movq    %rcx, %rsp    // update stack pointer\r
-    \r
-    movq    %rdi, %rax    // entry point to %rax\r
-    movq    %rsi, %rcx    // Adjust Context1\r
-                          // Context2 already in the rigth spot\r
-    \r
-    #\r
-    # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,\r
-    # in case the callee wishes to spill them.\r
-    #\r
-    subq    $32, %rsp  // 32-byte shadow space plus alignment pad\r
-    call    *%rax\r
-\r
-  \r
-\r
diff --git a/InOsEmuPkg/Unix/UnixX64.dsc b/InOsEmuPkg/Unix/UnixX64.dsc
deleted file mode 100644 (file)
index 50ad39d..0000000
+++ /dev/null
@@ -1,455 +0,0 @@
-## @file\r
-#\r
-# UEFI/PI Emulation Platform with UEFI HII interface supported.\r
-#\r
-# The Emulation Platform can be used to debug individual modules, prior to creating\r
-#       a real platform. This also provides an example for how an DSC is created.\r
-# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.<BR>\r
-#\r
-#    This program and the accompanying materials\r
-#    are licensed and made available under the terms and conditions of the BSD License\r
-#    which accompanies this distribution. The full text of the license may be found at\r
-#    http://opensource.org/licenses/bsd-license.php\r
-#\r
-#    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-##\r
-\r
-################################################################################\r
-#\r
-# Defines Section - statements that will be processed to create a Makefile.\r
-#\r
-################################################################################\r
-[Defines]\r
-  PLATFORM_NAME                  = EmuUnix\r
-  PLATFORM_GUID                  = 05FD064D-1073-E844-936C-A0E16317107D\r
-  PLATFORM_VERSION               = 0.3\r
-  DSC_ SPECIFICATION             = 0x00010005\r
-!if $(BUILD_32)\r
-  OUTPUT_DIRECTORY               = Build/EmuUnixIa32\r
-!else\r
-  OUTPUT_DIRECTORY               = Build/EmuUnixX64\r
-!endif\r
-\r
-  SUPPORTED_ARCHITECTURES        = X64|IA32\r
-  BUILD_TARGETS                  = DEBUG|RELEASE\r
-  SKUID_IDENTIFIER               = DEFAULT\r
-  FLASH_DEFINITION               = InOsEmuPkg/Unix/UnixX64.fdf\r
-\r
-################################################################################\r
-#\r
-# SKU Identification section - list of all SKU IDs supported by this Platform.\r
-#\r
-################################################################################\r
-[SkuIds]\r
-  0|DEFAULT\r
-\r
-################################################################################\r
-#\r
-# Library Class section - list of all Library Classes needed by this Platform.\r
-#\r
-################################################################################\r
-[LibraryClasses]\r
-  #\r
-  # Entry point\r
-  #\r
-  PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf\r
-  PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf\r
-  DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf\r
-  UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf\r
-  UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
-  #\r
-  # Basic\r
-  #\r
-  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf\r
-  SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf\r
-  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
-  CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf\r
-  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
-  PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf\r
-  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
-\r
-  #\r
-  # UEFI & PI\r
-  #\r
-  UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf\r
-  UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
-  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf\r
-  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf\r
-  UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf\r
-  HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf\r
-  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf\r
-  UefiDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf\r
-\r
-  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
-  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf\r
-  DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
-  #\r
-  # Generic Modules\r
-  #\r
-  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
-  NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf\r
-  IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf\r
-  UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf\r
-  DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf\r
-  OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf\r
-  GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
-  SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf\r
-  TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf\r
-  SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf\r
-  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
-  #\r
-  # Platform\r
-  #\r
-  PlatformBdsLib|InOsEmuPkg/Library/EmuBdsLib/EmuBdsLib.inf\r
-  KeyMapLib|InOsEmuPkg/Library/KeyMapLibNull/KeyMapLibNull.inf\r
-  \r
-  #\r
-  # Misc\r
-  #\r
-  DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf\r
-  PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf\r
-  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf\r
-  PeiServicesTablePointerLib|InOsEmuPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointerLibMagicPage.inf\r
-  DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
-\r
-\r
-[LibraryClasses.common.SEC]\r
-  PeiServicesLib|InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf\r
-  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
-  PeCoffGetEntryPointLib|InOsEmuPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.inf\r
-  PeCoffExtraActionLib|InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf\r
-  SerialPortLib|InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf\r
-  PpiListLib|InOsEmuPkg/Library/SecPpiListLib/SecPpiListLib.inf\r
-  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
-  TimerLib|InOsEmuPkg/Library/PeiTimerLib/PeiTimerLib.inf\r
-\r
-[LibraryClasses.common.USER_DEFINED, LibraryClasses.common.BASE]\r
-  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
-  PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf\r
-  MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r
-  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
-  PpiListLib|InOsEmuPkg/Library/SecPpiListLib/SecPpiListLib.inf\r
-  ThunkPpiList|InOsEmuPkg/Library/ThunkPpiList/ThunkPpiList.inf\r
-  ThunkProtocolList|InOsEmuPkg/Library/ThunkProtocolList/ThunkProtocolList.inf\r
-  PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf\r
-  PpiListLib|InOsEmuPkg/Library/SecPpiListLib/SecPpiListLib.inf\r
-  PeiServicesLib|InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf\r
-\r
-\r
-[LibraryClasses.common.PEIM, LibraryClasses.common.PEI_CORE]\r
-  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
-  MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r
-  ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf\r
-  PeCoffGetEntryPointLib|InOsEmuPkg/Library/PeiEmuPeCoffGetEntryPointLib/PeiEmuPeCoffGetEntryPointLib.inf\r
-  PeCoffExtraActionLib|InOsEmuPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf\r
-  ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf\r
-  SerialPortLib|InOsEmuPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.inf\r
-  ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf\r
-  TimerLib|InOsEmuPkg/Library/PeiTimerLib/PeiTimerLib.inf\r
-\r
-[LibraryClasses.common.PEI_CORE]\r
-  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
-\r
-[LibraryClasses.common.PEIM]\r
-  PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf\r
-\r
-[LibraryClasses.common.DXE_CORE]\r
-  HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf\r
-  MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf\r
-  ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf\r
-  PeCoffExtraActionLib|InOsEmuPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf\r
-  ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf\r
-  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
-  TimerLib|InOsEmuPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.inf\r
-  EmuThunkLib|InOsEmuPkg/Library/DxeEmuLib/DxeEmuLib.inf\r
-\r
-[LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.DXE_DRIVER, LibraryClasses.common.UEFI_APPLICATION]\r
-  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
-  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
-  MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
-  ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf\r
-  EmuThunkLib|InOsEmuPkg/Library/DxeEmuLib/DxeEmuLib.inf\r
-  PeCoffExtraActionLib|InOsEmuPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf\r
-  ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf\r
-  TimerLib|InOsEmuPkg/Library/DxeTimerLib/DxeTimerLib.inf\r
-\r
-[LibraryClasses.common.UEFI_DRIVER]\r
-  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
\r
-[LibraryClasses.common.UEFI_APPLICATION]\r
-  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
-\r
-\r
-################################################################################\r
-#\r
-# Pcd Section - list of all EDK II PCD Entries defined by this Platform.\r
-#\r
-################################################################################\r
-[PcdsFeatureFlag]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|TRUE\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst|FALSE\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE\r
-\r
-[PcdsFixedAtBuild]\r
-  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000040\r
-  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x0f\r
-  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x1f\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0x0\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x0\r
-\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFirmwareFdSize|0x002a0000\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFirmwareBlockSize|0x10000\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFirmwareVolume|L"../FV/FV_RECOVERY.fd"\r
-  \r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuMemorySizeForSecMain|L"64!64"\r
-\r
-!if $(BUILD_NEW_SHELL)\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }\r
-!else\r
-!if $(USE_NEW_SHELL)\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }\r
-!endif\r
-!endif\r
-\r
-#define BOOT_WITH_FULL_CONFIGURATION                  0x00\r
-#define BOOT_WITH_MINIMAL_CONFIGURATION               0x01\r
-#define BOOT_ASSUMING_NO_CONFIGURATION_CHANGES        0x02\r
-#define BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS 0x03\r
-#define BOOT_WITH_DEFAULT_SETTINGS                    0x04\r
-#define BOOT_ON_S4_RESUME                             0x05\r
-#define BOOT_ON_S5_RESUME                             0x06\r
-#define BOOT_ON_S2_RESUME                             0x10\r
-#define BOOT_ON_S3_RESUME                             0x11\r
-#define BOOT_ON_FLASH_UPDATE                          0x12\r
-#define BOOT_IN_RECOVERY_MODE                         0x20\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuBootMode|0\r
-  \r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuApCount|L"1"\r
-\r
-  # For a CD-ROM/DVD use L"diag.dmg:RO:2048"\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"disk.dmg:FW"\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuGop|L"GOP Window"\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuFileSystem|L".!../../../../EdkShellBinPkg/Bin"\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuSerialPort|L"/dev/ttyS0"\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuNetworkInterface|L"en0"\r
-\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuCpuModel|L"Intel(R) Processor Model"\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuCpuSpeed|L"3000"\r
-\r
-  #  0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8\r
-  gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|1\r
-\r
-################################################################################\r
-#\r
-# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform\r
-#\r
-################################################################################\r
-\r
-[PcdsDynamicDefault.common.DEFAULT]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0\r
-\r
-[PcdsDynamicHii.common.DEFAULT]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Setup"|gEmuSystemConfigGuid|0x0|80\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|L"Setup"|gEmuSystemConfigGuid|0x4|25\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|10\r
-\r
-\r
-###################################################################################################\r
-#\r
-# Components Section - list of the modules and components that will be processed by compilation\r
-#                      tools and the EDK II tools to generate PE32/PE32+/Coff image files.\r
-#\r
-# Note: The EDK II DSC file is not used to specify how compiled binary images get placed\r
-#       into firmware volume images. This section is just a list of modules to compile from\r
-#       source into UEFI-compliant binaries.\r
-#       It is the FDF file that contains information on combining binary files into firmware\r
-#       volume images, whose concept is beyond UEFI and is described in PI specification.\r
-#       Binary modules do not need to be listed in this section, as they should be\r
-#       specified in the FDF file. For example: Shell binary (Shell_Full.efi), FAT binary (Fat.efi),\r
-#       Logo (Logo.bmp), and etc.\r
-#       There may also be modules listed in this section that are not required in the FDF file,\r
-#       When a module listed here is excluded from FDF file, then UEFI-compliant binary will be\r
-#       generated for it, but the binary will not be put into any firmware volume.\r
-#\r
-###################################################################################################\r
-\r
-!ifndef $(SKIP_MAIN_BUILD)\r
-[Components.X64]\r
-  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf {\r
-    <LibraryClasses>\r
-      # turn off CR3 write so that DXE IPL will not crash emulator\r
-      BaseLib|UnixPkg/Library/UnixBaseLib/UnixBaseLib.inf\r
-  }\r
-\r
-[Components.IA32]\r
-  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf \r
-!endif\r
-\r
-[Components]\r
-!ifdef $(UNIX_SEC_BUILD)\r
-  ##\r
-  #  Emulator, OS POSIX application\r
-  ##\r
-  InOsEmuPkg/Unix/Sec/SecMain.inf\r
-!endif\r
-\r
-!ifndef $(SKIP_MAIN_BUILD)\r
-  #\r
-  # Generic SEC\r
-  #\r
-  InOsEmuPkg/Sec/Sec.inf\r
-\r
-  ##\r
-  #  PEI Phase modules\r
-  ##\r
-  MdeModulePkg/Core/Pei/PeiMain.inf\r
-  MdeModulePkg/Universal/PCD/Pei/Pcd.inf  {\r
-   <LibraryClasses>\r
-      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
-  }\r
-  MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf\r
-  MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf \r
-  \r
-  IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf\r
-  InOsEmuPkg/BootModePei/BootModePei.inf\r
-  MdeModulePkg/Universal/Variable/Pei/VariablePei.inf\r
-  InOsEmuPkg/AutoScanPei/AutoScanPei.inf\r
-  InOsEmuPkg/FirmwareVolumePei/FirmwareVolumePei.inf\r
-  InOsEmuPkg/FlashMapPei/FlashMapPei.inf\r
-  InOsEmuPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.inf\r
-\r
-  ##\r
-  #  DXE Phase modules\r
-  ##\r
-  MdeModulePkg/Core/Dxe/DxeMain.inf {\r
-    <LibraryClasses>\r
-      DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
-      NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf\r
-      NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
-  }\r
-  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {\r
-    <LibraryClasses>\r
-      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
-  }\r
-\r
-  MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf\r
-  MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf {\r
-   <LibraryClasses>\r
-      DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
-      SerialPortLib|InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf    \r
-  }\r
-\r
-  MdeModulePkg/Universal/Metronome/Metronome.inf\r
-  InOsEmuPkg/RealTimeClockRuntimeDxe/RealTimeClock.inf\r
-  InOsEmuPkg/ResetRuntimeDxe/Reset.inf\r
-  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
-  InOsEmuPkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf\r
-  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
-  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
-  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
-  InOsEmuPkg/EmuThunkDxe/EmuThunk.inf\r
-  InOsEmuPkg/CpuRuntimeDxe/Cpu.inf\r
-  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf\r
-  InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.inf\r
-  InOsEmuPkg/TimerDxe/Timer.inf\r
-\r
-\r
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf\r
-  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
-  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
-  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
-  MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
-  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
-  MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
-  EmbeddedPkg/SerialDxe/SerialDxe.inf {\r
-   <LibraryClasses>\r
-      DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
-      SerialPortLib|InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf    \r
-  }\r
-  \r
-  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
-  IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf\r
-  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf \r
-  #{\r
-  #  <LibraryClasses>  \r
-  #    NULL|InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf\r
-  #}\r
-  \r
-  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
-  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
-  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
-  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf\r
-  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
-  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
-  IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf\r
-\r
-  InOsEmuPkg/EmuBusDriverDxe/EmuBusDriverDxe.inf\r
-  InOsEmuPkg/EmuGopDxe/EmuGopDxe.inf\r
-  InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf\r
-  InOsEmuPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf\r
-  InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf\r
-\r
-  MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
-\r
-  #\r
-  # Network stack drivers\r
-  #\r
-  MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf\r
-  MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf\r
-  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf\r
-  MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf\r
-  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf\r
-  MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf\r
-  MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf\r
-  MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf\r
-  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf\r
-  MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf\r
-\r
-  MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf\r
-  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf\r
-  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
-  MdeModulePkg/Universal/PrintDxe/PrintDxe.inf\r
-  MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf {\r
-    <LibraryClasses>\r
-      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
-  }\r
-\r
-!if $(BUILD_FAT)\r
-  FatPkg/EnhancedFatDxe/Fat.inf\r
-!endif\r
-\r
-!if $(BUILD_NEW_SHELL)\r
-  ShellPkg/Application/Shell/Shell.inf {\r
-    <LibraryClasses>\r
-      ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf\r
-      NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf\r
-      NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf\r
-      NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf\r
-      NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf\r
-      NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf\r
-      NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf\r
-      NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf\r
-      HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf\r
-      FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
-      ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf\r
-      SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf\r
-      PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
-      MemoryAllocationLib|InOsEmuPkg/Library/GuardUefiMemoryAllocationLib/GuardUefiMemoryAllocationLib.inf\r
-      SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf\r
-      SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf\r
-\r
-    <PcdsFixedAtBuild>\r
-      gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF\r
-      gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE\r
-      gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000\r
-  }\r
-!endif\r
-\r
-!endif\r
-\r
diff --git a/InOsEmuPkg/Unix/UnixX64.fdf b/InOsEmuPkg/Unix/UnixX64.fdf
deleted file mode 100644 (file)
index 4ded05f..0000000
+++ /dev/null
@@ -1,395 +0,0 @@
-## @file\r
-# This is Unix FDF file with UEFI HII features enabled\r
-#\r
-# Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
-# Portions copyright (c) 2009 - 2011, Apple Inc. All rights reserved.<BR>\r
-#\r
-#    This program and the accompanying materials\r
-#    are licensed and made available under the terms and conditions of the BSD License\r
-#    which accompanies this distribution. The full text of the license may be found at\r
-#    http://opensource.org/licenses/bsd-license.php\r
-#\r
-#    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-\r
-################################################################################\r
-#\r
-# FD Section\r
-# The [FD] Section is made up of the definition statements and a\r
-# description of what goes into  the Flash Device Image.  Each FD section\r
-# defines one flash "device" image.  A flash device image may be one of\r
-# the following: Removable media bootable image (like a boot floppy\r
-# image,) an Option ROM image (that would be "flashed" into an add-in\r
-# card,) a System "Flash"  image (that would be burned into a system's\r
-# flash) or an Update ("Capsule") image that will be used to update and\r
-# existing system flash.\r
-#\r
-################################################################################\r
-[FD.Fv_Recovery]\r
-#\r
-# In OS X PEIMs are really XIP, so we need to make this address match the malloced \r
-# buffer for the FD (0x41000000). If this address does not match the FV will get\r
-# relocated in place (works, but not a great idea).\r
-#\r
-BaseAddress   = 0x102000000|gInOsEmuPkgTokenSpaceGuid.PcdEmuFdBaseAddress   #The base address of the FLASH Device.\r
-Size          = 0x005a0000|gInOsEmuPkgTokenSpaceGuid.PcdEmuFirmwareFdSize  #The size in bytes of the FLASH Device\r
-ErasePolarity = 1\r
-BlockSize     = 0x10000\r
-NumBlocks     = 0x5a\r
-\r
-################################################################################\r
-#\r
-# Following are lists of FD Region layout which correspond to the locations of different\r
-# images within the flash device.\r
-#\r
-# Regions must be defined in ascending order and may not overlap.\r
-#\r
-# A Layout Region start with a eight digit hex offset (leading "0x" required) followed by\r
-# the pipe "|" character, followed by the size of the region, also in hex with the leading\r
-# "0x" characters. Like:\r
-# Offset|Size\r
-# PcdOffsetCName|PcdSizeCName\r
-# RegionType <FV, DATA, or FILE>\r
-#\r
-################################################################################\r
-0x00000000|0x00580000\r
-gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashFvRecoveryBase|gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashFvRecoverySize\r
-FV = FvRecovery\r
-\r
-0x00580000|0x0000c000\r
-gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
-#NV_VARIABLE_STORE\r
-DATA = {\r
-  ## This is the EFI_FIRMWARE_VOLUME_HEADER\r
-  # ZeroVector []\r
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
-  # FileSystemGuid: gEfiSystemNvDataFvGuid         =\r
-  #  { 0xFFF12B8D, 0x7696, 0x4C8B, { 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50 }}\r
-  0x8D, 0x2B, 0xF1, 0xFF, 0x96, 0x76, 0x8B, 0x4C,\r
-  0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50,\r
-  # FvLength: 0x20000\r
-  0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\r
-  # Signature "_FVH"       #Attributes\r
-  0x5f, 0x46, 0x56, 0x48, 0xff, 0xfe, 0x04, 0x00,\r
-  # HeaderLength #CheckSum #ExtHeaderOffset #Reserved #Revision\r
-  0x48, 0x00, 0x36, 0x09, 0x00, 0x00, 0x00, 0x02,\r
-  # Blockmap[0]: 2 Blocks * 0x10000 Bytes / Block\r
-  0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,\r
-  # Blockmap[1]: End\r
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\r
-  ## This is the VARIABLE_STORE_HEADER\r
-  #Signature: gEfiVariableGuid =\r
-  #  { 0xddcf3616, 0x3275, 0x4164, { 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d }}\r
-  0x16, 0x36, 0xcf, 0xdd, 0x75, 0x32, 0x64, 0x41,\r
-  0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d,\r
-  #Size: 0xc000 (gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize) - 0x48 (size of EFI_FIRMWARE_VOLUME_HEADER) = 0xBFB8\r
-  # This can speed up the Variable Dispatch a bit.\r
-  0xB8, 0xBF, 0x00, 0x00,\r
-  #FORMATTED: 0x5A #HEALTHY: 0xFE #Reserved: UINT16 #Reserved1: UINT32\r
-  0x5A, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r
-}\r
-\r
-0x0058c000|0x00002000\r
-#NV_EVENT_LOG\r
-gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogBase|gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageEventLogSize\r
-\r
-0x0058e000|0x00002000\r
-gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize\r
-#NV_FTW_WORKING\r
-DATA = {\r
-  # EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER->Signature = gEfiSystemNvDataFvGuid         =\r
-  #  { 0xFFF12B8D, 0x7696, 0x4C8B, { 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50 }}\r
-  0x8D, 0x2B, 0xF1, 0xFF, 0x96, 0x76, 0x8B, 0x4C,\r
-  0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50,\r
-  # Crc:UINT32            #WorkingBlockValid:1, WorkingBlockInvalid:1, Reserved\r
-  0x77, 0x13, 0x9B, 0xD7, 0xFE, 0xFF, 0xFF, 0xFF,\r
-  # WriteQueueSize: UINT64\r
-  0xE0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r
-}\r
-\r
-0x00590000|0x00010000\r
-#NV_FTW_SPARE\r
-gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
-\r
-################################################################################\r
-#\r
-# FV Section\r
-#\r
-# [FV] section is used to define what components or modules are placed within a flash\r
-# device file.  This section also defines order the components and modules are positioned\r
-# within the image.  The [FV] section consists of define statements, set statements and\r
-# module statements.\r
-#\r
-################################################################################\r
-[FV.FvRecovery]\r
-FvAlignment        = 16         #FV alignment and FV attributes setting.\r
-ERASE_POLARITY     = 1\r
-MEMORY_MAPPED      = TRUE\r
-STICKY_WRITE       = TRUE\r
-LOCK_CAP           = TRUE\r
-LOCK_STATUS        = TRUE\r
-WRITE_DISABLED_CAP = TRUE\r
-WRITE_ENABLED_CAP  = TRUE\r
-WRITE_STATUS       = TRUE\r
-WRITE_LOCK_CAP     = TRUE\r
-WRITE_LOCK_STATUS  = TRUE\r
-READ_DISABLED_CAP  = TRUE\r
-READ_ENABLED_CAP   = TRUE\r
-READ_STATUS        = TRUE\r
-READ_LOCK_CAP      = TRUE\r
-READ_LOCK_STATUS   = TRUE\r
-\r
-################################################################################\r
-#\r
-# The INF statements point to EDK component and EDK II module INF files, which will be placed into this FV image.\r
-# Parsing tools will scan the INF file to determine the type of component or module.\r
-# The component or module type is used to reference the standard rules\r
-# defined elsewhere in the FDF file.\r
-#\r
-# The format for INF statements is:\r
-# INF $(PathAndInfFileName)\r
-#\r
-################################################################################\r
-##\r
-#  PEI Phase modules\r
-##\r
-##\r
-#  PEI Apriori file example, more PEIM module added later.\r
-##\r
-APRIORI PEI {\r
-  INF  MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf\r
-  INF  MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf\r
-  INF  MdeModulePkg/Universal/PCD/Pei/Pcd.inf\r
-  }\r
-APRIORI DXE {\r
-  INF  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
-  INF  MdeModulePkg/Universal/Metronome/Metronome.inf\r
-  }\r
-INF  InOsEmuPkg/Sec/Sec.inf\r
-INF  MdeModulePkg/Core/Pei/PeiMain.inf\r
-INF  MdeModulePkg/Universal/PCD/Pei/Pcd.inf\r
-INF  MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf\r
-INF  MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf\r
-INF  InOsEmuPkg/BootModePei/BootModePei.inf\r
-INF  InOsEmuPkg/AutoScanPei/AutoScanPei.inf\r
-INF  InOsEmuPkg/FirmwareVolumePei/FirmwareVolumePei.inf\r
-INF  InOsEmuPkg/FlashMapPei/FlashMapPei.inf\r
-INF  InOsEmuPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.inf\r
-INF  MdeModulePkg/Universal/Variable/Pei/VariablePei.inf\r
-INF  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf\r
-\r
-##\r
-#  DXE Phase modules\r
-##\r
-INF  MdeModulePkg/Core/Dxe/DxeMain.inf\r
-INF  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf  \r
-INF  MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf\r
-INF  MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf\r
-INF  MdeModulePkg/Universal/Metronome/Metronome.inf\r
-INF  InOsEmuPkg/RealTimeClockRuntimeDxe/RealTimeClock.inf\r
-INF  InOsEmuPkg/ResetRuntimeDxe/Reset.inf\r
-INF  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
-INF  InOsEmuPkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf\r
-INF  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
-INF  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf\r
-INF  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
-INF  InOsEmuPkg/EmuThunkDxe/EmuThunk.inf\r
-INF  InOsEmuPkg/CpuRuntimeDxe/Cpu.inf\r
-INF  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf\r
-INF  InOsEmuPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.inf\r
-INF  InOsEmuPkg/TimerDxe/Timer.inf\r
-INF  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf\r
-INF  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
-INF  MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
-INF  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
-INF  MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
-INF  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
-INF  MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
-\r
-INF  EmbeddedPkg/SerialDxe/SerialDxe.inf\r
-INF  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
-INF  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
-INF  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
-INF  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
-INF  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
-INF  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf\r
-INF  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
-INF  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
-INF  IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf\r
-INF  MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf\r
-\r
-INF  InOsEmuPkg/EmuBusDriverDxe/EmuBusDriverDxe.inf \r
-INF  InOsEmuPkg/EmuGopDxe/EmuGopDxe.inf\r
-INF  InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf\r
-INF  InOsEmuPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf\r
-INF  InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf\r
-\r
-INF  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf\r
-INF  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
-INF  MdeModulePkg/Universal/PrintDxe/PrintDxe.inf\r
-INF  IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf \r
-INF  MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf\r
-INF  MdeModulePkg/Application/HelloWorld/HelloWorld.inf\r
-\r
-#\r
-# Network stack drivers\r
-#\r
-!if $(NETWORK_SUPPORT)\r
-INF  InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf\r
-!endif\r
-INF  MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf\r
-INF  MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf\r
-INF  MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf\r
-INF  MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf\r
-INF  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf\r
-INF  MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf\r
-INF  MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf\r
-INF  MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf\r
-INF  MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf\r
-INF  MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf\r
-\r
\r
-!if $(BUILD_FAT)\r
-INF FatPkg/EnhancedFatDxe/Fat.inf\r
-!else\r
-INF  RuleOverride = BINARY FatBinPkg/EnhancedFatDxe/Fat.inf\r
-!endif\r
-\r
-!if $(BUILD_NEW_SHELL)\r
-INF  ShellPkg/Application/Shell/Shell.inf\r
-!else\r
-!if $(USE_NEW_SHELL)\r
-INF  RuleOverride = BINARY ShellBinPkg/UefiShell/UefiShell.inf\r
-!else\r
-INF  RuleOverride = BINARY EdkShellBinPkg/FullShell/FullShell.inf\r
-!endif\r
-!endif\r
-\r
-FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {\r
-  SECTION RAW = MdeModulePkg/Logo/Logo.bmp\r
-}\r
-   \r
-   \r
-################################################################################\r
-#  \r
-# Rules are use with the [FV] section's module INF type to define\r
-# how an FFS file is created for a given INF file. The following Rule are the default\r
-# rules for the different module type. User can add the customized rules to define the\r
-# content of the FFS file.\r
-#  \r
-################################################################################\r
-   \r
-   \r
-############################################################################\r
-# Example of a DXE_DRIVER FFS file with a Checksum encapsulation section   # \r
-############################################################################\r
-#  \r
-#[Rule.Common.DXE_DRIVER]\r
-#  FILE DRIVER = $(NAMED_GUID) {\r
-#    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex\r
-#    COMPRESS PI_STD {\r
-#      GUIDED {\r
-#        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-#        UI       STRING="$(MODULE_NAME)" Optional\r
-#        VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
-#      }\r
-#    }\r
-#  }\r
-#\r
-############################################################################\r
-[Rule.Common.SEC]\r
-  FILE SEC = $(NAMED_GUID)  {\r
-    PE32     PE32    Align=32       $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-    UI       STRING ="$(MODULE_NAME)" Optional         \r
-    VERSION  STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)    \r
-  }\r
-\r
-\r
-[Rule.Common.PEI_CORE]\r
-  FILE PEI_CORE = $(NAMED_GUID) {\r
-    PE32     PE32    Align=32       $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-    UI       STRING ="$(MODULE_NAME)" Optional         \r
-    VERSION  STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)    \r
-  }\r
-\r
-[Rule.Common.PEIM]\r
-  FILE PEIM = $(NAMED_GUID) {\r
-     PEI_DEPEX PEI_DEPEX Optional        $(INF_OUTPUT)/$(MODULE_NAME).depex\r
-     PE32      PE32   Align=32       $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-     UI       STRING="$(MODULE_NAME)" Optional         \r
-     VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)   \r
-  }\r
-\r
-[Rule.Common.DXE_CORE]\r
-  FILE DXE_CORE = $(NAMED_GUID) {\r
-    COMPRESS PI_STD {\r
-      PE32     PE32           $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-      UI       STRING="$(MODULE_NAME)" Optional\r
-      VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
-    }\r
-  }\r
-\r
-[Rule.Common.UEFI_DRIVER]\r
-  FILE DRIVER = $(NAMED_GUID) {\r
-    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex\r
-    COMPRESS PI_STD {\r
-      GUIDED {\r
-        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-        UI       STRING="$(MODULE_NAME)" Optional\r
-        VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
-      }\r
-    }\r
-  }\r
-\r
-[Rule.Common.DXE_DRIVER]\r
-  FILE DRIVER = $(NAMED_GUID) {\r
-    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex\r
-    COMPRESS PI_STD {\r
-      GUIDED {\r
-        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-        UI       STRING="$(MODULE_NAME)" Optional\r
-        VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
-      }\r
-    }\r
-  }\r
-\r
-[Rule.Common.DXE_RUNTIME_DRIVER]\r
-  FILE DRIVER = $(NAMED_GUID) {\r
-    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex\r
-    COMPRESS PI_STD {\r
-      GUIDED {\r
-        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-        UI       STRING="$(MODULE_NAME)" Optional\r
-        VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
-      }\r
-    }\r
-  }\r
-\r
-[Rule.Common.UEFI_APPLICATION]\r
-  FILE APPLICATION = $(NAMED_GUID) {\r
-    COMPRESS PI_STD {\r
-      GUIDED {\r
-        PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi\r
-        UI       STRING="$(MODULE_NAME)" Optional\r
-        VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
-      }\r
-    }\r
-  }\r
-\r
-[Rule.Common.UEFI_DRIVER.BINARY]\r
-  FILE DRIVER = $(NAMED_GUID) {\r
-    DXE_DEPEX DXE_DEPEX Optional      |.depex\r
-    PE32      PE32                    |.efi\r
-    UI        STRING="$(MODULE_NAME)" Optional\r
-    VERSION   STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
-  }\r
-\r
-[Rule.Common.UEFI_APPLICATION.BINARY]\r
-  FILE APPLICATION = $(NAMED_GUID) {\r
-    PE32      PE32                    |.efi\r
-    UI        STRING="$(MODULE_NAME)" Optional\r
-    VERSION   STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
-  }\r
-\r
diff --git a/InOsEmuPkg/Unix/Xcode/xcode_project32/XcodeBuild.sh b/InOsEmuPkg/Unix/Xcode/xcode_project32/XcodeBuild.sh
deleted file mode 100755 (executable)
index 09d1a28..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-#
-# External makefile Xcode project project uses this script to build and clean from the Xcode GUI
-#
-# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
-#
-# 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.
-#
-
-# force exit on error
-set -e
-
-#
-# Source the workspace and set up the environment variables we need
-#
-cd ../..
-echo `pwd`
-./build.sh $1 $2 $3 $4 $5 $6 $8
diff --git a/InOsEmuPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/default.pbxuser b/InOsEmuPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/default.pbxuser
deleted file mode 100644 (file)
index 5a2dfe8..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-// !$*UTF8*$!
-{
-       08FB7793FE84155DC02AAC07 /* Project object */ = {
-               activeBuildConfigurationName = Debug;
-               activeExecutable = BA11A1010FB10BCE00D06FEC /* SecMain.dll */;
-               activeTarget = D28A88AD04BDD90700651E21 /* xcode_project */;
-               breakpoints = (
-                       BA11A11A0FB10E0700D06FEC /* SecGdbConfigBreak */,
-               );
-               codeSenseManager = BA11A0FE0FB10B4800D06FEC /* Code sense */;
-               executables = (
-                       BA11A1010FB10BCE00D06FEC /* SecMain.dll */,
-               );
-               perUserDictionary = {
-                       "PBXConfiguration.PBXBreakpointsDataSource.v1:1CA1AED706398EBD00589147" = {
-                               PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
-                               PBXFileTableDataSourceColumnSortingKey = PBXBreakpointsDataSource_BreakpointID;
-                               PBXFileTableDataSourceColumnWidthsKey = (
-                                       20,
-                                       20,
-                                       198,
-                                       20,
-                                       99,
-                                       99,
-                                       29,
-                                       20,
-                               );
-                               PBXFileTableDataSourceColumnsKey = (
-                                       PBXBreakpointsDataSource_ActionID,
-                                       PBXBreakpointsDataSource_TypeID,
-                                       PBXBreakpointsDataSource_BreakpointID,
-                                       PBXBreakpointsDataSource_UseID,
-                                       PBXBreakpointsDataSource_LocationID,
-                                       PBXBreakpointsDataSource_ConditionID,
-                                       PBXBreakpointsDataSource_IgnoreCountID,
-                                       PBXBreakpointsDataSource_ContinueID,
-                               );
-                       };
-                       PBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = {
-                               PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
-                               PBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID;
-                               PBXFileTableDataSourceColumnWidthsKey = (
-                                       22,
-                                       300,
-                                       229,
-                               );
-                               PBXFileTableDataSourceColumnsKey = (
-                                       PBXExecutablesDataSource_ActiveFlagID,
-                                       PBXExecutablesDataSource_NameID,
-                                       PBXExecutablesDataSource_CommentsID,
-                               );
-                       };
-                       PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = {
-                               PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
-                               PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
-                               PBXFileTableDataSourceColumnWidthsKey = (
-                                       20,
-                                       341,
-                                       20,
-                                       48,
-                                       43,
-                                       43,
-                                       20,
-                               );
-                               PBXFileTableDataSourceColumnsKey = (
-                                       PBXFileDataSource_FiletypeID,
-                                       PBXFileDataSource_Filename_ColumnID,
-                                       PBXFileDataSource_Built_ColumnID,
-                                       PBXFileDataSource_ObjectSize_ColumnID,
-                                       PBXFileDataSource_Errors_ColumnID,
-                                       PBXFileDataSource_Warnings_ColumnID,
-                                       PBXFileDataSource_Target_ColumnID,
-                               );
-                       };
-                       PBXPerProjectTemplateStateSaveDate = 263260969;
-                       PBXWorkspaceStateSaveDate = 263260969;
-               };
-               sourceControlManager = BA11A0FD0FB10B4800D06FEC /* Source Control */;
-               userBuildSettings = {
-               };
-       };
-       BA11A0FD0FB10B4800D06FEC /* Source Control */ = {
-               isa = PBXSourceControlManager;
-               fallbackIsa = XCSourceControlManager;
-               isSCMEnabled = 0;
-               repositoryNamesForRoots = {
-               };
-               scmConfiguration = {
-               };
-       };
-       BA11A0FE0FB10B4800D06FEC /* Code sense */ = {
-               isa = PBXCodeSenseManager;
-               indexTemplatePath = "";
-       };
-       BA11A1010FB10BCE00D06FEC /* SecMain.dll */ = {
-               isa = PBXExecutable;
-               activeArgIndices = (
-               );
-               argumentStrings = (
-               );
-               autoAttachOnCrash = 1;
-               breakpointsEnabled = 1;
-               configStateDict = {
-                       "PBXLSLaunchAction-0" = {
-                               PBXLSLaunchAction = 0;
-                               PBXLSLaunchStartAction = 1;
-                               PBXLSLaunchStdioStyle = 2;
-                               PBXLSLaunchStyle = 0;
-                               class = PBXLSRunLaunchConfig;
-                               commandLineArgs = (
-                               );
-                               displayName = "Executable Runner";
-                               environment = {
-                               };
-                               identifier = com.apple.Xcode.launch.runConfig;
-                               remoteHostInfo = "";
-                               startActionInfo = "";
-                       };
-                       "PBXLSLaunchAction-1" = {
-                               PBXLSLaunchAction = 1;
-                               PBXLSLaunchStartAction = 1;
-                               PBXLSLaunchStdioStyle = 2;
-                               PBXLSLaunchStyle = 0;
-                               class = PBXGDB_LaunchConfig;
-                               commandLineArgs = (
-                               );
-                               displayName = GDB;
-                               environment = {
-                               };
-                               identifier = com.apple.Xcode.launch.GDBMI_Config;
-                               remoteHostInfo = "";
-                               startActionInfo = "";
-                       };
-               };
-               customDataFormattersEnabled = 0;
-               dataTipCustomDataFormattersEnabled = 1;
-               dataTipShowTypeColumn = 1;
-               dataTipSortType = 0;
-               debuggerPlugin = GDBDebugging;
-               disassemblyDisplayState = 0;
-               dylibVariantSuffix = "";
-               enableDebugStr = 1;
-               environmentEntries = (
-               );
-               executableSystemSymbolLevel = 0;
-               executableUserSymbolLevel = 0;
-               launchableReference = BA11A1020FB10BCE00D06FEC /* SecMain.dll */;
-               libgmallocEnabled = 0;
-               name = SecMain.dll;
-               savedGlobals = {
-               };
-               showTypeColumn = 0;
-               sourceDirectories = (
-               );
-               startupPath = ../../../../Build/EmuUnixIa32/DEBUG_XCLANG/IA32;
-       };
-       BA11A1020FB10BCE00D06FEC /* SecMain.dll */ = {
-               isa = PBXFileReference;
-               lastKnownFileType = "compiled.mach-o.executable";
-               name = SecMain.dll;
-               path = ../../../../Build/EmuUnixIa32/DEBUG_XCLANG/IA32/SecMain;
-               sourceTree = SOURCE_ROOT;
-       };
-       BA11A11A0FB10E0700D06FEC /* SecGdbConfigBreak */ = {
-               isa = PBXSymbolicBreakpoint;
-               actions = (
-                       BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */,
-               );
-               breakpointStyle = 1;
-               continueAfterActions = 1;
-               countType = 0;
-               delayBeforeContinue = 0;
-               hitCount = 0;
-               ignoreCount = 0;
-               location = SecMain;
-               modificationTime = 263261853.260195;
-               originalNumberOfMultipleMatches = 1;
-               state = 1;
-               symbolName = SecGdbConfigBreak;
-       };
-       BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */ = {
-               isa = XCBreakpointCommandAction;
-               command = "set gInXcode=1\nsource ../../../../InOsEmuPkg/Unix/GdbRun";
-               fallbackIsa = XCBreakpointAction;
-               logCommand = 0;
-               useDebuggerSideImplementation = 1;
-       };
-       D28A88AD04BDD90700651E21 /* xcode_project */ = {
-               activeExec = 0;
-       };
-}
diff --git a/InOsEmuPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/project.pbxproj b/InOsEmuPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj/project.pbxproj
deleted file mode 100644 (file)
index 8ff531e..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-// !$*UTF8*$!
-{
-       archiveVersion = 1;
-       classes = {
-       };
-       objectVersion = 45;
-       objects = {
-
-/* Begin PBXGroup section */
-               08FB7794FE84155DC02AAC07 /* xcode_project */ = {
-                       isa = PBXGroup;
-                       children = (
-                       );
-                       name = xcode_project;
-                       sourceTree = "<group>";
-               };
-/* End PBXGroup section */
-
-/* Begin PBXLegacyTarget section */
-               D28A88AD04BDD90700651E21 /* xcode_project */ = {
-                       isa = PBXLegacyTarget;
-                       buildArgumentsString = "$(ACTION)";
-                       buildConfigurationList = 1DEB918F08733D9F0010E9CD /* Build configuration list for PBXLegacyTarget "xcode_project" */;
-                       buildPhases = (
-                       );
-                       buildToolPath = ./XcodeBuild.sh;
-                       buildWorkingDirectory = "";
-                       dependencies = (
-                       );
-                       name = xcode_project;
-                       passBuildSettingsInEnvironment = 1;
-                       productName = xcode_project;
-               };
-/* End PBXLegacyTarget section */
-
-/* Begin PBXProject section */
-               08FB7793FE84155DC02AAC07 /* Project object */ = {
-                       isa = PBXProject;
-                       buildConfigurationList = 1DEB919308733D9F0010E9CD /* Build configuration list for PBXProject "xcode_project" */;
-                       compatibilityVersion = "Xcode 3.1";
-                       developmentRegion = English;
-                       hasScannedForEncodings = 1;
-                       knownRegions = (
-                               English,
-                               Japanese,
-                               French,
-                               German,
-                       );
-                       mainGroup = 08FB7794FE84155DC02AAC07 /* xcode_project */;
-                       projectDirPath = "";
-                       projectRoot = "";
-                       targets = (
-                               D28A88AD04BDD90700651E21 /* xcode_project */,
-                       );
-               };
-/* End PBXProject section */
-
-/* Begin XCBuildConfiguration section */
-               1DEB919008733D9F0010E9CD /* Debug */ = {
-                       isa = XCBuildConfiguration;
-                       buildSettings = {
-                               PRODUCT_NAME = xcode_project;
-                       };
-                       name = Debug;
-               };
-               1DEB919108733D9F0010E9CD /* Release */ = {
-                       isa = XCBuildConfiguration;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = YES;
-                               GCC_ENABLE_FIX_AND_CONTINUE = NO;
-                               OTHER_CFLAGS = "";
-                               OTHER_LDFLAGS = "";
-                               PRODUCT_NAME = xcode_project;
-                       };
-                       name = Release;
-               };
-               1DEB919408733D9F0010E9CD /* Debug */ = {
-                       isa = XCBuildConfiguration;
-                       buildSettings = {
-                               ARCHS = "$(ARCHS_STANDARD_32_BIT)";
-                               GCC_WARN_ABOUT_RETURN_TYPE = YES;
-                               GCC_WARN_UNUSED_VARIABLE = YES;
-                               ONLY_ACTIVE_ARCH = YES;
-                               PREBINDING = NO;
-                               SDKROOT = macosx10.6;
-                       };
-                       name = Debug;
-               };
-               1DEB919508733D9F0010E9CD /* Release */ = {
-                       isa = XCBuildConfiguration;
-                       buildSettings = {
-                               ARCHS = "$(ARCHS_STANDARD_64_BIT)";
-                               GCC_WARN_ABOUT_RETURN_TYPE = YES;
-                               GCC_WARN_UNUSED_VARIABLE = YES;
-                               PREBINDING = NO;
-                               SDKROOT = macosx10.6;
-                       };
-                       name = Release;
-               };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
-               1DEB918F08733D9F0010E9CD /* Build configuration list for PBXLegacyTarget "xcode_project" */ = {
-                       isa = XCConfigurationList;
-                       buildConfigurations = (
-                               1DEB919008733D9F0010E9CD /* Debug */,
-                               1DEB919108733D9F0010E9CD /* Release */,
-                       );
-                       defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Release;
-               };
-               1DEB919308733D9F0010E9CD /* Build configuration list for PBXProject "xcode_project" */ = {
-                       isa = XCConfigurationList;
-                       buildConfigurations = (
-                               1DEB919408733D9F0010E9CD /* Debug */,
-                               1DEB919508733D9F0010E9CD /* Release */,
-                       );
-                       defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Release;
-               };
-/* End XCConfigurationList section */
-       };
-       rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
-}
diff --git a/InOsEmuPkg/Unix/Xcode/xcode_project64/XcodeBuild.sh b/InOsEmuPkg/Unix/Xcode/xcode_project64/XcodeBuild.sh
deleted file mode 100755 (executable)
index 634b1b0..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-#
-# External makefile Xcode project project uses this script to build and clean from the Xcode GUI
-#
-# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
-#
-# 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.
-#
-
-# force exit on error
-set -e
-
-#
-# Source the workspace and set up the environment variables we need
-#
-cd ../..
-echo `pwd`
-./build64.sh $1 $2 $3 $4 $5 $6 $8
diff --git a/InOsEmuPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/default.pbxuser b/InOsEmuPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/default.pbxuser
deleted file mode 100644 (file)
index 1fe821f..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-// !$*UTF8*$!
-{
-       08FB7793FE84155DC02AAC07 /* Project object */ = {
-               activeBuildConfigurationName = Debug;
-               activeExecutable = BA11A1010FB10BCE00D06FEC /* SecMain.dll */;
-               activeTarget = D28A88AD04BDD90700651E21 /* xcode_project */;
-               breakpoints = (
-                       BA11A11A0FB10E0700D06FEC /* SecGdbConfigBreak */,
-               );
-               codeSenseManager = BA11A0FE0FB10B4800D06FEC /* Code sense */;
-               executables = (
-                       BA11A1010FB10BCE00D06FEC /* SecMain.dll */,
-               );
-               perUserDictionary = {
-                       "PBXConfiguration.PBXBreakpointsDataSource.v1:1CA1AED706398EBD00589147" = {
-                               PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
-                               PBXFileTableDataSourceColumnSortingKey = PBXBreakpointsDataSource_BreakpointID;
-                               PBXFileTableDataSourceColumnWidthsKey = (
-                                       20,
-                                       20,
-                                       198,
-                                       20,
-                                       99,
-                                       99,
-                                       29,
-                                       20,
-                               );
-                               PBXFileTableDataSourceColumnsKey = (
-                                       PBXBreakpointsDataSource_ActionID,
-                                       PBXBreakpointsDataSource_TypeID,
-                                       PBXBreakpointsDataSource_BreakpointID,
-                                       PBXBreakpointsDataSource_UseID,
-                                       PBXBreakpointsDataSource_LocationID,
-                                       PBXBreakpointsDataSource_ConditionID,
-                                       PBXBreakpointsDataSource_IgnoreCountID,
-                                       PBXBreakpointsDataSource_ContinueID,
-                               );
-                       };
-                       PBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = {
-                               PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
-                               PBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID;
-                               PBXFileTableDataSourceColumnWidthsKey = (
-                                       22,
-                                       300,
-                                       229,
-                               );
-                               PBXFileTableDataSourceColumnsKey = (
-                                       PBXExecutablesDataSource_ActiveFlagID,
-                                       PBXExecutablesDataSource_NameID,
-                                       PBXExecutablesDataSource_CommentsID,
-                               );
-                       };
-                       PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = {
-                               PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
-                               PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
-                               PBXFileTableDataSourceColumnWidthsKey = (
-                                       20,
-                                       341,
-                                       20,
-                                       48,
-                                       43,
-                                       43,
-                                       20,
-                               );
-                               PBXFileTableDataSourceColumnsKey = (
-                                       PBXFileDataSource_FiletypeID,
-                                       PBXFileDataSource_Filename_ColumnID,
-                                       PBXFileDataSource_Built_ColumnID,
-                                       PBXFileDataSource_ObjectSize_ColumnID,
-                                       PBXFileDataSource_Errors_ColumnID,
-                                       PBXFileDataSource_Warnings_ColumnID,
-                                       PBXFileDataSource_Target_ColumnID,
-                               );
-                       };
-                       PBXPerProjectTemplateStateSaveDate = 263260969;
-                       PBXWorkspaceStateSaveDate = 263260969;
-               };
-               sourceControlManager = BA11A0FD0FB10B4800D06FEC /* Source Control */;
-               userBuildSettings = {
-               };
-       };
-       BA11A0FD0FB10B4800D06FEC /* Source Control */ = {
-               isa = PBXSourceControlManager;
-               fallbackIsa = XCSourceControlManager;
-               isSCMEnabled = 0;
-               repositoryNamesForRoots = {
-               };
-               scmConfiguration = {
-               };
-       };
-       BA11A0FE0FB10B4800D06FEC /* Code sense */ = {
-               isa = PBXCodeSenseManager;
-               indexTemplatePath = "";
-       };
-       BA11A1010FB10BCE00D06FEC /* SecMain.dll */ = {
-               isa = PBXExecutable;
-               activeArgIndices = (
-               );
-               argumentStrings = (
-               );
-               autoAttachOnCrash = 1;
-               breakpointsEnabled = 1;
-               configStateDict = {
-                       "PBXLSLaunchAction-0" = {
-                               PBXLSLaunchAction = 0;
-                               PBXLSLaunchStartAction = 1;
-                               PBXLSLaunchStdioStyle = 2;
-                               PBXLSLaunchStyle = 0;
-                               class = PBXLSRunLaunchConfig;
-                               commandLineArgs = (
-                               );
-                               displayName = "Executable Runner";
-                               environment = {
-                               };
-                               identifier = com.apple.Xcode.launch.runConfig;
-                               remoteHostInfo = "";
-                               startActionInfo = "";
-                       };
-                       "PBXLSLaunchAction-1" = {
-                               PBXLSLaunchAction = 1;
-                               PBXLSLaunchStartAction = 1;
-                               PBXLSLaunchStdioStyle = 2;
-                               PBXLSLaunchStyle = 0;
-                               class = PBXGDB_LaunchConfig;
-                               commandLineArgs = (
-                               );
-                               displayName = GDB;
-                               environment = {
-                               };
-                               identifier = com.apple.Xcode.launch.GDBMI_Config;
-                               remoteHostInfo = "";
-                               startActionInfo = "";
-                       };
-               };
-               customDataFormattersEnabled = 0;
-               dataTipCustomDataFormattersEnabled = 1;
-               dataTipShowTypeColumn = 1;
-               dataTipSortType = 0;
-               debuggerPlugin = GDBDebugging;
-               disassemblyDisplayState = 0;
-               dylibVariantSuffix = "";
-               enableDebugStr = 1;
-               environmentEntries = (
-               );
-               executableSystemSymbolLevel = 0;
-               executableUserSymbolLevel = 0;
-               launchableReference = BA11A1020FB10BCE00D06FEC /* SecMain.dll */;
-               libgmallocEnabled = 0;
-               name = SecMain.dll;
-               savedGlobals = {
-               };
-               showTypeColumn = 0;
-               sourceDirectories = (
-               );
-               startupPath = ../../../../Build/EmuUnixX64/DEBUG_XCLANG/X64;
-       };
-       BA11A1020FB10BCE00D06FEC /* SecMain.dll */ = {
-               isa = PBXFileReference;
-               lastKnownFileType = "compiled.mach-o.executable";
-               name = SecMain.dll;
-               path = ../../../../Build/EmuUnixX64/DEBUG_XCLANG/X64/SecMain;
-               sourceTree = SOURCE_ROOT;
-       };
-       BA11A11A0FB10E0700D06FEC /* SecGdbConfigBreak */ = {
-               isa = PBXSymbolicBreakpoint;
-               actions = (
-                       BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */,
-               );
-               breakpointStyle = 1;
-               continueAfterActions = 1;
-               countType = 0;
-               delayBeforeContinue = 0;
-               hitCount = 0;
-               ignoreCount = 0;
-               location = SecMain;
-               modificationTime = 263261853.260195;
-               originalNumberOfMultipleMatches = 1;
-               state = 1;
-               symbolName = SecGdbConfigBreak;
-       };
-       BA11A11E0FB10E2200D06FEC /* XCBreakpointCommandAction */ = {
-               isa = XCBreakpointCommandAction;
-               command = "set gInXcode=1\nsource ../../../../InOsEmuPkg/Unix/GdbRun";
-               fallbackIsa = XCBreakpointAction;
-               logCommand = 0;
-               useDebuggerSideImplementation = 1;
-       };
-       D28A88AD04BDD90700651E21 /* xcode_project */ = {
-               activeExec = 0;
-       };
-}
diff --git a/InOsEmuPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/project.pbxproj b/InOsEmuPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/project.pbxproj
deleted file mode 100644 (file)
index 9bd13bd..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-// !$*UTF8*$!
-{
-       archiveVersion = 1;
-       classes = {
-       };
-       objectVersion = 45;
-       objects = {
-
-/* Begin PBXGroup section */
-               08FB7794FE84155DC02AAC07 /* xcode_project */ = {
-                       isa = PBXGroup;
-                       children = (
-                       );
-                       name = xcode_project;
-                       sourceTree = "<group>";
-               };
-/* End PBXGroup section */
-
-/* Begin PBXLegacyTarget section */
-               D28A88AD04BDD90700651E21 /* xcode_project */ = {
-                       isa = PBXLegacyTarget;
-                       buildArgumentsString = "$(ACTION)";
-                       buildConfigurationList = 1DEB918F08733D9F0010E9CD /* Build configuration list for PBXLegacyTarget "xcode_project" */;
-                       buildPhases = (
-                       );
-                       buildToolPath = ./XcodeBuild.sh;
-                       buildWorkingDirectory = "";
-                       dependencies = (
-                       );
-                       name = xcode_project;
-                       passBuildSettingsInEnvironment = 1;
-                       productName = xcode_project;
-               };
-/* End PBXLegacyTarget section */
-
-/* Begin PBXProject section */
-               08FB7793FE84155DC02AAC07 /* Project object */ = {
-                       isa = PBXProject;
-                       buildConfigurationList = 1DEB919308733D9F0010E9CD /* Build configuration list for PBXProject "xcode_project" */;
-                       compatibilityVersion = "Xcode 3.1";
-                       developmentRegion = English;
-                       hasScannedForEncodings = 1;
-                       knownRegions = (
-                               English,
-                               Japanese,
-                               French,
-                               German,
-                       );
-                       mainGroup = 08FB7794FE84155DC02AAC07 /* xcode_project */;
-                       projectDirPath = "";
-                       projectRoot = "";
-                       targets = (
-                               D28A88AD04BDD90700651E21 /* xcode_project */,
-                       );
-               };
-/* End PBXProject section */
-
-/* Begin XCBuildConfiguration section */
-               1DEB919008733D9F0010E9CD /* Debug */ = {
-                       isa = XCBuildConfiguration;
-                       buildSettings = {
-                               PRODUCT_NAME = xcode_project;
-                       };
-                       name = Debug;
-               };
-               1DEB919108733D9F0010E9CD /* Release */ = {
-                       isa = XCBuildConfiguration;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = YES;
-                               GCC_ENABLE_FIX_AND_CONTINUE = NO;
-                               OTHER_CFLAGS = "";
-                               OTHER_LDFLAGS = "";
-                               PRODUCT_NAME = xcode_project;
-                       };
-                       name = Release;
-               };
-               1DEB919408733D9F0010E9CD /* Debug */ = {
-                       isa = XCBuildConfiguration;
-                       buildSettings = {
-                               ARCHS = "$(ARCHS_STANDARD_64_BIT)";
-                               GCC_WARN_ABOUT_RETURN_TYPE = YES;
-                               GCC_WARN_UNUSED_VARIABLE = YES;
-                               ONLY_ACTIVE_ARCH = YES;
-                               PREBINDING = NO;
-                               SDKROOT = macosx10.6;
-                       };
-                       name = Debug;
-               };
-               1DEB919508733D9F0010E9CD /* Release */ = {
-                       isa = XCBuildConfiguration;
-                       buildSettings = {
-                               ARCHS = "$(ARCHS_STANDARD_64_BIT)";
-                               GCC_WARN_ABOUT_RETURN_TYPE = YES;
-                               GCC_WARN_UNUSED_VARIABLE = YES;
-                               PREBINDING = NO;
-                               SDKROOT = macosx10.6;
-                       };
-                       name = Release;
-               };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
-               1DEB918F08733D9F0010E9CD /* Build configuration list for PBXLegacyTarget "xcode_project" */ = {
-                       isa = XCConfigurationList;
-                       buildConfigurations = (
-                               1DEB919008733D9F0010E9CD /* Debug */,
-                               1DEB919108733D9F0010E9CD /* Release */,
-                       );
-                       defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Release;
-               };
-               1DEB919308733D9F0010E9CD /* Build configuration list for PBXProject "xcode_project" */ = {
-                       isa = XCConfigurationList;
-                       buildConfigurations = (
-                               1DEB919408733D9F0010E9CD /* Debug */,
-                               1DEB919508733D9F0010E9CD /* Release */,
-                       );
-                       defaultConfigurationIsVisible = 0;
-                       defaultConfigurationName = Release;
-               };
-/* End XCConfigurationList section */
-       };
-       rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
-}
diff --git a/InOsEmuPkg/Unix/build.sh b/InOsEmuPkg/Unix/build.sh
deleted file mode 100755 (executable)
index 1810a69..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
-# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-
-set -e
-shopt -s nocasematch
-
-
-#
-# Setup workspace if it is not set
-#
-if [ -z "$WORKSPACE" ]
-then
-  echo Initializing workspace
-  if [ ! -e `pwd`/edksetup.sh ]
-  then
-    cd ../..
-  fi
-# This version is for the tools in the BaseTools project.
-# this assumes svn pulls have the same root dir
-#  export EDK_TOOLS_PATH=`pwd`/../BaseTools
-# This version is for the tools source in edk2
-  export EDK_TOOLS_PATH=`pwd`/BaseTools
-  echo $EDK_TOOLS_PATH
-  source edksetup.sh BaseTools
-else
-  echo Building from: $WORKSPACE
-fi
-
-#
-# Pick a default tool type for a given OS
-#
-UNIXPKG_TOOLS=GCC44
-NETWORK_SUPPORT=
-BUILD_NEW_SHELL=
-BUILD_FAT=
-case `uname` in
-  CYGWIN*) echo Cygwin not fully supported yet. ;;
-  Darwin*)
-      Major=$(uname -r | cut -f 1 -d '.')
-      if [[ $Major == 9 ]]
-      then
-        echo UnixPkg requires Snow Leopard or later OS
-        exit 1
-      else
-        TARGET_TOOLS=XCODE32
-        UNIXPKG_TOOLS=XCLANG
-      fi
-      BUILD_NEW_SHELL="-D BUILD_NEW_SHELL"
-      BUILD_FAT="-D BUILD_FAT"
-      ;;
-esac
-
-if [ -d /lib32 ]
-then
-  export LIB_ARCH_SFX=32
-fi
-
-if [ -z "$TARGET_TOOLS" ]
-then
-  TARGET_TOOLS=$UNIXPKG_TOOLS
-fi
-
-BUILD_ROOT_ARCH=$WORKSPACE/Build/EmuUnixIa32/DEBUG_"$UNIXPKG_TOOLS"/IA32
-
-if  [[ ! -f `which build` || ! -f `which GenFv` ]];
-then
-  # build the tools if they don't yet exist. Bin scheme
-  echo Building tools as they are not in the path
-  make -C $WORKSPACE/BaseTools
-elif [[ ( -f `which build` ||  -f `which GenFv` )  && ! -d  $EDK_TOOLS_PATH/Source/C/bin ]];
-then
-  # build the tools if they don't yet exist. BinWrapper scheme
-  echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
-  make -C $WORKSPACE/BaseTools
-else
-  echo using prebuilt tools
-fi
-
-
-for arg in "$@"
-do
-  if [[ $arg == run ]]; then
-    case `uname` in
-      Darwin*)
-        #
-        # On Darwin we can't use dlopen, so we have to load the real PE/COFF images.
-        # This .gdbinit script sets a breakpoint that loads symbols for the PE/COFFEE
-        # images that get loaded in SecMain
-        #
-        cp $WORKSPACE/InOsEmuPkg/Unix/.gdbinit $WORKSPACE/Build/EmuUnixIa32/DEBUG_"$UNIXPKG_TOOLS"/IA32
-        ;;
-    esac
-
-    /usr/bin/gdb $BUILD_ROOT_ARCH/SecMain -q -cd=$BUILD_ROOT_ARCH -x $WORKSPACE/InOsEmuPkg/Unix/GdbRun
-    exit
-  fi
-
-  if [[ $arg == cleanall ]]; then
-    make -C $WORKSPACE/BaseTools clean
-    build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc -a IA32 -t $TARGET_TOOLS -D SEC_ONLY -n 3 clean
-    build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc -a IA32 -t $UNIXPKG_TOOLS -n 3 clean
-    build -p $WORKSPACE/ShellPkg/ShellPkg.dsc -a IA32 -t $UNIXPKG_TOOLS -n 3 clean
-    exit $?
-  fi
-
-  if [[ $arg == clean ]]; then
-    build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc -a IA32 -t $TARGET_TOOLS -D SEC_ONLY -n 3 clean
-    build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc -a IA32 -t $UNIXPKG_TOOLS -n 3 clean
-    exit $?
-  fi
-
-done
-
-
-#
-# Build the edk2 UnixPkg
-#
-if [[ $TARGET_TOOLS == $UNIXPKG_TOOLS ]]; then
-  build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc      -a IA32 -t $UNIXPKG_TOOLS -D BUILD_32 -D UNIX_SEC_BUILD $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
-else
-  build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc      -a IA32 -t $TARGET_TOOLS  -D BUILD_32 -D UNIX_SEC_BUILD -D SKIP_MAIN_BUILD -n 3 $1 $2 $3 $4 $5 $6 $7 $8  modules
-  build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc      -a IA32 -t $UNIXPKG_TOOLS -D BUILD_32 $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
-  cp $WORKSPACE/Build/EmuUnixIa32/DEBUG_"$TARGET_TOOLS"/IA32/SecMain $WORKSPACE/Build/EmuUnixIa32/DEBUG_"$UNIXPKG_TOOLS"/IA32
-fi
-exit $?
-
diff --git a/InOsEmuPkg/Unix/build64.sh b/InOsEmuPkg/Unix/build64.sh
deleted file mode 100755 (executable)
index eb0d80b..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
-# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-
-set -e
-shopt -s nocasematch
-
-
-#
-# Setup workspace if it is not set
-#
-if [ -z "$WORKSPACE" ]
-then
-  echo Initializing workspace
-  if [ ! -e `pwd`/edksetup.sh ]
-  then
-    cd ../..
-  fi
-# This version is for the tools in the BaseTools project.
-# this assumes svn pulls have the same root dir
-#  export EDK_TOOLS_PATH=`pwd`/../BaseTools
-# This version is for the tools source in edk2
-  export EDK_TOOLS_PATH=`pwd`/BaseTools
-  echo $EDK_TOOLS_PATH
-  source edksetup.sh BaseTools
-else
-  echo Building from: $WORKSPACE
-fi
-
-#
-# Pick a default tool type for a given OS
-#
-UNIXPKG_TOOLS=GCC44
-NETWORK_SUPPORT=
-BUILD_NEW_SHELL=
-BUILD_FAT=
-case `uname` in
-  CYGWIN*) echo Cygwin not fully supported yet. ;;
-  Darwin*)
-      Major=$(uname -r | cut -f 1 -d '.')
-      if [[ $Major == 9 ]]
-      then
-        echo UnixPkg requires Snow Leopard or later OS
-        exit 1
-      else
-        TARGET_TOOLS=XCODE32
-        UNIXPKG_TOOLS=XCLANG
-      fi
-#      NETWORK_SUPPORT="-D NETWORK_SUPPORT"
-      BUILD_NEW_SHELL="-D BUILD_NEW_SHELL"
-      BUILD_FAT="-D BUILD_FAT"
-      ;;
-esac
-
-if [ -d /lib64 ]
-then
-  export LIB_ARCH_SFX=64
-fi
-
-if [ -z "$TARGET_TOOLS" ]
-then
-  TARGET_TOOLS=$UNIXPKG_TOOLS
-fi
-
-BUILD_ROOT_ARCH=$WORKSPACE/Build/EmuUnixX64/DEBUG_"$UNIXPKG_TOOLS"/X64
-
-if  [[ ! -f `which build` || ! -f `which GenFv` ]];
-then
-  # build the tools if they don't yet exist. Bin scheme
-  echo Building tools as they are not in the path
-  make -C $WORKSPACE/BaseTools
-elif [[ ( -f `which build` ||  -f `which GenFv` )  && ! -d  $EDK_TOOLS_PATH/Source/C/bin ]];
-then
-  # build the tools if they don't yet exist. BinWrapper scheme
-  echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
-  make -C $WORKSPACE/BaseTools
-else
-  echo using prebuilt tools
-fi
-
-
-for arg in "$@"
-do
-  if [[ $arg == run ]]; then
-    case `uname` in
-      Darwin*)
-        #
-        # On Darwin we can't use dlopen, so we have to load the real PE/COFF images.
-        # This .gdbinit script sets a breakpoint that loads symbols for the PE/COFFEE
-        # images that get loaded in SecMain
-        #
-        cp $WORKSPACE/InOsEmuPkg/Unix/.gdbinit $WORKSPACE/Build/EmuUnixX64/DEBUG_"$UNIXPKG_TOOLS"/X64
-        ;;
-    esac
-
-    /usr/bin/gdb $BUILD_ROOT_ARCH/SecMain -q -cd=$BUILD_ROOT_ARCH -x $WORKSPACE/InOsEmuPkg/Unix/GdbRun
-    exit
-  fi
-
-  if [[ $arg == cleanall ]]; then
-    make -C $WORKSPACE/BaseTools clean
-    build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc -a X64 -t $TARGET_TOOLS -D SEC_ONLY -n 3 clean
-    build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc -a X64 -t $UNIXPKG_TOOLS -n 3 clean
-    build -p $WORKSPACE/ShellPkg/ShellPkg.dsc -a X64 -t $UNIXPKG_TOOLS -n 3 clean
-    exit $?
-  fi
-
-  if [[ $arg == clean ]]; then
-    build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc -a X64 -t $TARGET_TOOLS -D SEC_ONLY -n 3 clean
-    build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc -a X64 -t $UNIXPKG_TOOLS -n 3 clean
-    exit $?
-  fi
-
-done
-
-
-#
-# Build the edk2 UnixPkg
-#
-if [[ $TARGET_TOOLS == $UNIXPKG_TOOLS ]]; then
-  build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc      -a X64 -t $UNIXPKG_TOOLS -D UNIX_SEC_BUILD $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
-else
-  build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc      -a X64 -t $TARGET_TOOLS  -D UNIX_SEC_BUILD -D SKIP_MAIN_BUILD -n 3 $1 $2 $3 $4 $5 $6 $7 $8  modules
-  build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc      -a X64 -t $UNIXPKG_TOOLS $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
-  cp $WORKSPACE/Build/EmuUnixX64/DEBUG_"$TARGET_TOOLS"/X64/SecMain $WORKSPACE/Build/EmuUnixX64/DEBUG_"$UNIXPKG_TOOLS"/X64
-fi
-exit $?
-
diff --git a/InOsEmuPkg/build.sh b/InOsEmuPkg/build.sh
deleted file mode 100755 (executable)
index 28de82c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
-#
-# 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.
-#
-
-cd Unix
-. build.sh $1 $2 $3 $4 $5 $6 $7 $8
-
diff --git a/InOsEmuPkg/build64.sh b/InOsEmuPkg/build64.sh
deleted file mode 100755 (executable)
index a1d47b7..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
-#
-# 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.
-#
-
-cd Unix
-. build64.sh $1 $2 $3 $4 $5 $6 $7 $8
-