Пример #1
0
/**
  The user Entry Point for module EmuBlockIo . The user code starts with this function.

  @param[in] ImageHandle    The firmware allocated handle for the EFI image.
  @param[in] SystemTable    A pointer to the EFI System Table.

  @retval EFI_SUCCESS       The entry point is executed successfully.
  @retval other             Some error occurs when executing this entry point.

**/
EFI_STATUS
EFIAPI
InitializeEmuBlockIo (
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  )
{
  EFI_STATUS              Status;

  Status = EfiLibInstallAllDriverProtocols2 (
             ImageHandle,
             SystemTable,
             &gEmuBlockIoDriverBinding,
             ImageHandle,
             &gEmuBlockIoComponentName,
             &gEmuBlockIoComponentName2,
             NULL,
             NULL,
             &gEmuBlockIoDriverDiagnostics,
             &gEmuBlockIoDriverDiagnostics2
             );
  ASSERT_EFI_ERROR (Status);


  return Status;
}
Пример #2
0
/**
  The user Entry Point for module IdeBus. The user code starts with this function.

  @param[in] ImageHandle    The firmware allocated handle for the EFI image.
  @param[in] SystemTable    A pointer to the EFI System Table.

  @retval EFI_SUCCESS       The entry point is executed successfully.
  @retval other             Some error occurs when executing this entry point.

**/
EFI_STATUS
EFIAPI
InitializeIdeBus(
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  )
{
  EFI_STATUS              Status;

  //
  // Install driver model protocol(s).
  //
  Status = EfiLibInstallAllDriverProtocols2 (
             ImageHandle,
             SystemTable,
             &gIDEBusDriverBinding,
             ImageHandle,
             &gIDEBusComponentName,
             &gIDEBusComponentName2,
             NULL,
             NULL,
             &gIDEBusDriverDiagnostics,
             &gIDEBusDriverDiagnostics2
             );
  ASSERT_EFI_ERROR (Status);

  return Status;
}
Пример #3
0
EFI_STATUS
EFIAPI
InitializeTestBlockIo(
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  )
{
  EFI_STATUS              Status;
  EFI_BLOCK_IO_PROTOCOL   *BlockIo;
  //
  // Install driver model protocol(s).
  //
  Status = EfiLibInstallAllDriverProtocols2 (
             ImageHandle,
             SystemTable,
             &gTestBlockIoDriverBinding,
             ImageHandle,
             &gTestBlockIoComponentName,
             &gTestBlockIoComponentName2,
             NULL,
             NULL,
             &gTestBlockIoDriverDiagnostics,
             &gTestBlockIoDriverDiagnostics2
             );
  ASSERT_EFI_ERROR (Status);

  DEBUG ((EFI_D_ERROR, "%a(%d)\n", __FUNCTION__, __LINE__));
  //Print(L"%a(%d)\n", __FUNCTION__, __LINE__);

  // Init Block I/O
  gTstBlkIo.NumberOfBlocks = 0x1000;
  gTstBlkIo.BlockSize = 0x200; 
  BlockIo = &gTstBlkIo.BlockIo;

  BlockIo->Revision = EFI_BLOCK_IO_PROTOCOL_REVISION;
  BlockIo->Reset = TestBlockIoResetBlock;
  BlockIo->ReadBlocks = TestBlockIoReadBlocks;
  BlockIo->WriteBlocks = TestBlockIoWriteBlocks;
  BlockIo->FlushBlocks = TestBlockIoFlushBlocks;
  
  BlockIo->Media = &gTstBlkIo.Media;
  BlockIo->Media->BlockSize = (UINT32)gTstBlkIo.BlockSize;
  BlockIo->Media->LastBlock = gTstBlkIo.NumberOfBlocks - 1;
  BlockIo->Media->MediaId = 0xBABA;
  BlockIo->Media->ReadOnly = FALSE;
  BlockIo->Media->RemovableMedia = FALSE;
  BlockIo->Media->LogicalPartition = FALSE;
  BlockIo->Media->MediaPresent = TRUE;
  BlockIo->Media->WriteCaching = FALSE;
  BlockIo->Media->IoAlign = 0;
 
 

  // Init Device Path
  gTstBlkIo.DevicePath = &TestBlockIoDevicePath;
  
  //Allocate memory for RAMDISK
  gBS->AllocatePool( 
        EfiBootServicesData,
        (UINTN)gTstBlkIo.NumberOfBlocks*gTstBlkIo.BlockSize,
        &gTstBlkIo.Buffer
        );
    
  // Copy MBR
  gBS->CopyMem((VOID*)((UINT8*)gTstBlkIo.Buffer), &Lba0, sizeof Lba0);
  
  
  //Install Block I/O and  Device Path protocols
  Status = gBS->InstallMultipleProtocolInterfaces(
                             &gTstBlkIo.EfiHandle,
														 &gEfiBlockIoProtocolGuid,
                             &gTstBlkIo.BlockIo,
                             &gEfiDevicePathProtocolGuid,
														 gTstBlkIo.DevicePath,
														 NULL);
 
  Status = gBS->ConnectController(gTstBlkIo.EfiHandle, NULL, NULL, TRUE);
 
  return Status;
}