Get BlockIo mapping interfaces working. Still need to work on detecting block size of devices, but you can map a .dmg file no problem at this point.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11724 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
andrewfish 2011-06-03 03:31:32 +00:00
parent 26fab514ee
commit 033d0e5ff6
14 changed files with 597 additions and 765 deletions

View File

@ -232,7 +232,7 @@ EmuBlockIoReset (
EMU_BLOCK_IO_PRIVATE *Private;
EFI_TPL OldTpl;
Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@ -264,8 +264,7 @@ EmuBlockIoReset (
**/
EFI_STATUS
EFIAPI
EmuBlockIoReadBlocks
(
EmuBlockIoReadBlocks (
IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA Lba,
@ -278,7 +277,7 @@ EmuBlockIoReadBlocks
EFI_TPL OldTpl;
EFI_BLOCK_IO2_TOKEN Token;
Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@ -325,7 +324,7 @@ EmuBlockIoWriteBlocks (
EFI_TPL OldTpl;
EFI_BLOCK_IO2_TOKEN Token;
Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@ -357,7 +356,7 @@ EmuBlockIoFlushBlocks (
EFI_TPL OldTpl;
EFI_BLOCK_IO2_TOKEN Token;
Private = EMU_BLOCK_IO2_PRIVATE_DATA_FROM_THIS (This);
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@ -442,7 +441,7 @@ EmuBlockIoDriverBindingSupported (
// Make sure GUID is for a File System handle.
//
Status = EFI_UNSUPPORTED;
if (CompareGuid (EmuIoThunk->Protocol, &gEmuVirtualDisksGuid)) {
if (CompareGuid (EmuIoThunk->Protocol, &gEmuBlockIoProtocolGuid)) {
Status = EFI_SUCCESS;
}
@ -524,7 +523,7 @@ EmuBlockIoDriverBindingStart (
//
// Set DiskType
//
if (!CompareGuid (EmuIoThunk->Protocol, &gEmuVirtualDisksGuid)) {
if (!CompareGuid (EmuIoThunk->Protocol, &gEmuBlockIoProtocolGuid)) {
Status = EFI_UNSUPPORTED;
goto Done;
}
@ -542,6 +541,7 @@ EmuBlockIoDriverBindingStart (
Private->Signature = EMU_BLOCK_IO_PRIVATE_SIGNATURE;
Private->IoThunk = EmuIoThunk;
Private->Io = EmuIoThunk->Interface;
Private->EfiHandle = Handle;
Private->BlockIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION2;
Private->BlockIo.Media = &Private->Media;

View File

@ -66,4 +66,4 @@
gEfiBlockIoProtocolGuid # PROTOCOL BY_START
gEfiBlockIo2ProtocolGuid # PROTOCOL BY_START
gEmuIoThunkProtocolGuid # PROTOCOL TO_START
gEmuBlockIoProtocolGuid # PROTOCOL BY_START

View File

@ -36,6 +36,7 @@
gEmuIoThunkProtocolGuid = { 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } }
gEmuGraphicsWindowProtocolGuid = { 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 0xC1 } }
gEmuThreadThunkProtocolGuid = { 0x3B1E4B7C, 0x09D8, 0x944F, { 0xA4, 0x08, 0x13, 0x09, 0xEB, 0x8B, 0x44, 0x27 } }
gEmuBlockIoProtocolGuid = { 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }
[Ppis]
gEmuThunkPpiGuid = { 0xE113F896, 0x75CF, 0xF640, { 0x81, 0x7F, 0xC8, 0x5A, 0x79, 0xE8, 0xAE, 0x67 } }

View File

@ -23,7 +23,7 @@
#include <Protocol/BlockIo2.h>
#define EMU_BLOCK_IO_PROTOCOL_GUID \
{ 0x3EC5F7E0, 0x1124, 0xDF45, { 0x9F, 0x96, 0x7D, 0xD6, 0x63, 0xC0, 0xAF, 0xE7 } }
{ 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }
typedef struct _EMU_BLOCK_IO_PROTOCOL EMU_BLOCK_IO_PROTOCOL;
@ -90,7 +90,7 @@ EFI_STATUS
IN EFI_LBA LBA,
IN OUT EFI_BLOCK_IO2_TOKEN *Token,
IN UINTN BufferSize,
OUT VOID *Buffer
OUT VOID *Buffer
);
/**
@ -127,7 +127,7 @@ EFI_STATUS
typedef
EFI_STATUS
(EFIAPI *EMU_BLOCK_WRITE) (
IN EMU_BLOCK_IO_PROTOCOL *This,
IN EMU_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA LBA,
IN OUT EFI_BLOCK_IO2_TOKEN *Token,

File diff suppressed because it is too large Load Diff

View File

@ -405,8 +405,58 @@ GasketPosixFileSystmeThunkClose (
IN EMU_IO_THUNK_PROTOCOL *This
);
EFI_STATUS
EFIAPI
GasketEmuBlockIoReset (
IN EMU_BLOCK_IO_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
);
EFI_STATUS
GasketEmuBlockIoReadBlocks (
IN EMU_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA LBA,
IN OUT EFI_BLOCK_IO2_TOKEN *Token,
IN UINTN BufferSize,
OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
GasketEmuBlockIoWriteBlocks (
IN EMU_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA LBA,
IN OUT EFI_BLOCK_IO2_TOKEN *Token,
IN UINTN BufferSize,
IN VOID *Buffer
);
EFI_STATUS
GasketEmuBlockIoFlushBlocks (
IN EMU_BLOCK_IO_PROTOCOL *This,
IN OUT EFI_BLOCK_IO2_TOKEN *Token
);
EFI_STATUS
GasketEmuBlockIoCreateMapping (
IN EMU_BLOCK_IO_PROTOCOL *This,
IN EFI_BLOCK_IO_MEDIA *Media
);
EFI_STATUS
EFIAPI
GasketBlockIoThunkOpen (
IN EMU_IO_THUNK_PROTOCOL *This
);
EFI_STATUS
EFIAPI
GasketBlockIoThunkClose (
IN EMU_IO_THUNK_PROTOCOL *This
);
#endif

View File

@ -1533,7 +1533,7 @@ PosixFileSystmeThunkClose (
}
if (This->Private != NULL) {
if (Private->VolumeLabel == NULL) {
if (Private->VolumeLabel != NULL) {
free (Private->VolumeLabel);
}
free (This->Private);

View File

@ -116,7 +116,10 @@ main (
//
AddThunkProtocol (&gX11ThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuGop), TRUE);
AddThunkProtocol (&gPosixFileSystemThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuFileSystem), TRUE);
AddThunkProtocol (&gBlockIoThunkIo, (CHAR16 *)PcdGetPtr (PcdEmuVirtualDisk), TRUE);
//
// Emulator other Thunks
//

View File

@ -46,6 +46,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/EmuIoThunk.h>
#include <Protocol/EmuGraphicsWindow.h>
#include <Protocol/EmuThread.h>
#include <Protocol/EmuBlockIo.h>
#include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h>
@ -318,6 +319,6 @@ extern EMU_THUNK_PROTOCOL gEmuThunkProtocol;
extern EMU_IO_THUNK_PROTOCOL gX11ThunkIo;
extern EMU_IO_THUNK_PROTOCOL gPosixFileSystemThunkIo;
extern EMU_IO_THUNK_PROTOCOL gPthreadThunkIo;
extern EMU_IO_THUNK_PROTOCOL gBlockIoThunkIo;
#endif

View File

@ -35,6 +35,7 @@
X11GraphicsWindow.c
Pthreads.c
PosixFileSystem.c
BlockIo.c
[Sources.X64]
X64/Gasket.S # convert between Emu x86_64 ABI and EFI X64 ABI
@ -68,8 +69,8 @@
gEmuIoThunkProtocolGuid
gEmuGraphicsWindowProtocolGuid
gEmuThreadThunkProtocolGuid
gEmuBlockIoProtocolGuid
gEfiSimpleFileSystemProtocolGuid
[Guids]
gEfiFileSystemVolumeLabelInfoIdGuid # SOMETIMES_CONSUMED

View File

@ -1022,9 +1022,143 @@ ASM_PFX(GasketPosixFileSystmeThunkClose):
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 0x30(%rbp), %r8
movq 0x38(%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 0x30(%rbp), %r8
movq 0x38(%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

View File

@ -220,8 +220,7 @@
gInOsEmuPkgTokenSpaceGuid.PcdEmuApCount|L"1"
gInOsEmuPkgTokenSpaceGuid.PcdEmuPhysicalDisk|L"E:RW;245760;512"
gInOsEmuPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"FW;40960;512"
gInOsEmuPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"disk.dmg:FW"
gInOsEmuPkgTokenSpaceGuid.PcdEmuGop|L"GOP Window"
gInOsEmuPkgTokenSpaceGuid.PcdEmuFileSystem|L".!../../../../EdkShellBinPkg/Bin"
gInOsEmuPkgTokenSpaceGuid.PcdEmuSerialPort|L"/dev/ttyS0"
@ -358,20 +357,13 @@
InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf
InOsEmuPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf
!if $(0)
UnixPkg/UnixSerialIoDxe/UnixSerialIo.inf
UnixPkg/UnixConsoleDxe/UnixConsole.inf
UnixPkg/UnixSimpleFileSystemDxe/UnixSimpleFileSystem.inf
!endif
MdeModulePkg/Application/HelloWorld/HelloWorld.inf
#
# Network stack drivers
#
##!if $(NETWORK_SUPPORT) & $(0)
!if $(0)
UnixPkg/UnixSnpDxe/UnixSnpDxe.inf
!if $(NETWORK_SUPPORT)
InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf
!endif
MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf

View File

@ -221,9 +221,8 @@ INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
INF InOsEmuPkg/EmuBusDriverDxe/EmuBusDriverDxe.inf
INF InOsEmuPkg/EmuGopDxe/EmuGopDxe.inf
INF InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystemDxe.inf
INF InOsEmuPkg/EmuBlockIoDxe/EmuBlockIoDxe.inf
#INF UnixPkg/UnixBlockIoDxe/UnixBlockIo.inf
#INF UnixPkg/UnixSerialIoDxe/UnixSerialIo.inf
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
INF MdeModulePkg/Universal/PrintDxe/PrintDxe.inf
@ -235,7 +234,7 @@ INF MdeModulePkg/Application/HelloWorld/HelloWorld.inf
# Network stack drivers
#
!if $(NETWORK_SUPPORT)
#INF UnixPkg/UnixSnpDxe/UnixSnpDxe.inf
INF InOsEmuPkg/EmuSnpDxe/EmuSnpDxe.inf
!endif
INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf

View File

@ -58,8 +58,8 @@ case `uname` in
UNIXPKG_TOOLS=XCLANG
fi
# NETWORK_SUPPORT="-D NETWORK_SUPPORT"
# BUILD_NEW_SHELL="-D BUILD_NEW_SHELL"
# BUILD_FAT="-D BUILD_FAT"
BUILD_NEW_SHELL="-D BUILD_NEW_SHELL"
BUILD_FAT="-D BUILD_FAT"
;;
Linux*) TARGET_TOOLS=ELFGCC ;;