mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-31 01:24:12 +02:00
MdeModulePkg/UsbBotPei: Add RecoveryBlockIo2Ppi support
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Feng Tian <feng.tian@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17480 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
25c80c554b
commit
3fe5862f00
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Pei USB ATATPI command implementations.
|
Pei USB ATATPI command implementations.
|
||||||
|
|
||||||
Copyright (c) 1999 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
|
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions
|
are licensed and made available under the terms and conditions
|
||||||
@ -73,9 +73,15 @@ PeiUsbInquiry (
|
|||||||
if ((Idata.peripheral_type & 0x1f) == 0x05) {
|
if ((Idata.peripheral_type & 0x1f) == 0x05) {
|
||||||
PeiBotDevice->DeviceType = USBCDROM;
|
PeiBotDevice->DeviceType = USBCDROM;
|
||||||
PeiBotDevice->Media.BlockSize = 0x800;
|
PeiBotDevice->Media.BlockSize = 0x800;
|
||||||
|
PeiBotDevice->Media2.ReadOnly = TRUE;
|
||||||
|
PeiBotDevice->Media2.RemovableMedia = TRUE;
|
||||||
|
PeiBotDevice->Media2.BlockSize = 0x800;
|
||||||
} else {
|
} else {
|
||||||
PeiBotDevice->DeviceType = USBFLOPPY;
|
PeiBotDevice->DeviceType = USBFLOPPY;
|
||||||
PeiBotDevice->Media.BlockSize = 0x200;
|
PeiBotDevice->Media.BlockSize = 0x200;
|
||||||
|
PeiBotDevice->Media2.ReadOnly = FALSE;
|
||||||
|
PeiBotDevice->Media2.RemovableMedia = TRUE;
|
||||||
|
PeiBotDevice->Media2.BlockSize = 0x200;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@ -148,10 +154,10 @@ PeiUsbRequestSense (
|
|||||||
IN UINT8 *SenseKeyBuffer
|
IN UINT8 *SenseKeyBuffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
ATAPI_PACKET_COMMAND Packet;
|
ATAPI_PACKET_COMMAND Packet;
|
||||||
UINT8 *Ptr;
|
UINT8 *Ptr;
|
||||||
BOOLEAN SenseReq;
|
BOOLEAN SenseReq;
|
||||||
ATAPI_REQUEST_SENSE_DATA *Sense;
|
ATAPI_REQUEST_SENSE_DATA *Sense;
|
||||||
|
|
||||||
*SenseCounts = 0;
|
*SenseCounts = 0;
|
||||||
@ -241,9 +247,10 @@ PeiUsbReadCapacity (
|
|||||||
IN PEI_BOT_DEVICE *PeiBotDevice
|
IN PEI_BOT_DEVICE *PeiBotDevice
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
ATAPI_PACKET_COMMAND Packet;
|
ATAPI_PACKET_COMMAND Packet;
|
||||||
ATAPI_READ_CAPACITY_DATA Data;
|
ATAPI_READ_CAPACITY_DATA Data;
|
||||||
|
UINT32 LastBlock;
|
||||||
|
|
||||||
ZeroMem (&Data, sizeof (ATAPI_READ_CAPACITY_DATA));
|
ZeroMem (&Data, sizeof (ATAPI_READ_CAPACITY_DATA));
|
||||||
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
|
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
|
||||||
@ -267,10 +274,17 @@ PeiUsbReadCapacity (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
|
LastBlock = (Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0;
|
||||||
|
|
||||||
PeiBotDevice->Media.LastBlock = (Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0;
|
if (LastBlock == 0xFFFFFFFF) {
|
||||||
|
DEBUG ((EFI_D_INFO, "The usb device LBA count is larger than 0xFFFFFFFF!\n"));
|
||||||
|
}
|
||||||
|
|
||||||
PeiBotDevice->Media.MediaPresent = TRUE;
|
PeiBotDevice->Media.LastBlock = LastBlock;
|
||||||
|
PeiBotDevice->Media.MediaPresent = TRUE;
|
||||||
|
|
||||||
|
PeiBotDevice->Media2.LastBlock = LastBlock;
|
||||||
|
PeiBotDevice->Media2.MediaPresent = TRUE;
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -293,9 +307,10 @@ PeiUsbReadFormattedCapacity (
|
|||||||
IN PEI_BOT_DEVICE *PeiBotDevice
|
IN PEI_BOT_DEVICE *PeiBotDevice
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
ATAPI_PACKET_COMMAND Packet;
|
ATAPI_PACKET_COMMAND Packet;
|
||||||
ATAPI_READ_FORMAT_CAPACITY_DATA FormatData;
|
ATAPI_READ_FORMAT_CAPACITY_DATA FormatData;
|
||||||
|
UINT32 LastBlock;
|
||||||
|
|
||||||
ZeroMem (&FormatData, sizeof (ATAPI_READ_FORMAT_CAPACITY_DATA));
|
ZeroMem (&FormatData, sizeof (ATAPI_READ_FORMAT_CAPACITY_DATA));
|
||||||
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
|
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
|
||||||
@ -327,14 +342,23 @@ PeiUsbReadFormattedCapacity (
|
|||||||
//
|
//
|
||||||
PeiBotDevice->Media.MediaPresent = FALSE;
|
PeiBotDevice->Media.MediaPresent = FALSE;
|
||||||
PeiBotDevice->Media.LastBlock = 0;
|
PeiBotDevice->Media.LastBlock = 0;
|
||||||
|
PeiBotDevice->Media2.MediaPresent = FALSE;
|
||||||
|
PeiBotDevice->Media2.LastBlock = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
LastBlock = (FormatData.LastLba3 << 24) | (FormatData.LastLba2 << 16) | (FormatData.LastLba1 << 8) | FormatData.LastLba0;
|
||||||
|
if (LastBlock == 0xFFFFFFFF) {
|
||||||
|
DEBUG ((EFI_D_INFO, "The usb device LBA count is larger than 0xFFFFFFFF!\n"));
|
||||||
|
}
|
||||||
|
|
||||||
PeiBotDevice->Media.LastBlock = (FormatData.LastLba3 << 24) | (FormatData.LastLba2 << 16) | (FormatData.LastLba1 << 8) | FormatData.LastLba0;
|
PeiBotDevice->Media.LastBlock = LastBlock;
|
||||||
|
|
||||||
PeiBotDevice->Media.LastBlock--;
|
PeiBotDevice->Media.LastBlock--;
|
||||||
|
|
||||||
PeiBotDevice->Media.MediaPresent = TRUE;
|
PeiBotDevice->Media.MediaPresent = TRUE;
|
||||||
|
|
||||||
|
PeiBotDevice->Media2.MediaPresent = TRUE;
|
||||||
|
PeiBotDevice->Media2.LastBlock = PeiBotDevice->Media.LastBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@ -468,8 +492,8 @@ IsNoMedia (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
ATAPI_REQUEST_SENSE_DATA *SensePtr;
|
ATAPI_REQUEST_SENSE_DATA *SensePtr;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
BOOLEAN NoMedia;
|
BOOLEAN NoMedia;
|
||||||
|
|
||||||
NoMedia = FALSE;
|
NoMedia = FALSE;
|
||||||
SensePtr = SenseData;
|
SensePtr = SenseData;
|
||||||
@ -515,12 +539,12 @@ IsNoMedia (
|
|||||||
BOOLEAN
|
BOOLEAN
|
||||||
IsMediaError (
|
IsMediaError (
|
||||||
IN ATAPI_REQUEST_SENSE_DATA *SenseData,
|
IN ATAPI_REQUEST_SENSE_DATA *SenseData,
|
||||||
IN UINTN SenseCounts
|
IN UINTN SenseCounts
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ATAPI_REQUEST_SENSE_DATA *SensePtr;
|
ATAPI_REQUEST_SENSE_DATA *SensePtr;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
BOOLEAN Error;
|
BOOLEAN Error;
|
||||||
|
|
||||||
SensePtr = SenseData;
|
SensePtr = SenseData;
|
||||||
Error = FALSE;
|
Error = FALSE;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
## @file
|
## @file
|
||||||
# The Usb mass storage device Peim driver is used to support recovery from USB device.
|
# The Usb mass storage device Peim driver is used to support recovery from USB device.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
#
|
#
|
||||||
# This program and the accompanying materials
|
# This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions
|
# are licensed and made available under the terms and conditions
|
||||||
@ -57,6 +57,7 @@
|
|||||||
|
|
||||||
[Ppis]
|
[Ppis]
|
||||||
gEfiPeiVirtualBlockIoPpiGuid ## PRODUCES
|
gEfiPeiVirtualBlockIoPpiGuid ## PRODUCES
|
||||||
|
gEfiPeiVirtualBlockIo2PpiGuid ## PRODUCES
|
||||||
## CONSUMES
|
## CONSUMES
|
||||||
## NOTIFY
|
## NOTIFY
|
||||||
gPeiUsbIoPpiGuid
|
gPeiUsbIoPpiGuid
|
||||||
|
@ -31,10 +31,24 @@ EFI_PEI_RECOVERY_BLOCK_IO_PPI mRecoveryBlkIoPpi = {
|
|||||||
BotReadBlocks
|
BotReadBlocks
|
||||||
};
|
};
|
||||||
|
|
||||||
EFI_PEI_PPI_DESCRIPTOR mPpiList = {
|
EFI_PEI_RECOVERY_BLOCK_IO2_PPI mRecoveryBlkIo2Ppi = {
|
||||||
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
|
EFI_PEI_RECOVERY_BLOCK_IO2_PPI_REVISION,
|
||||||
&gEfiPeiVirtualBlockIoPpiGuid,
|
BotGetNumberOfBlockDevices2,
|
||||||
NULL
|
BotGetMediaInfo2,
|
||||||
|
BotReadBlocks2
|
||||||
|
};
|
||||||
|
|
||||||
|
EFI_PEI_PPI_DESCRIPTOR mPpiList[2] = {
|
||||||
|
{
|
||||||
|
EFI_PEI_PPI_DESCRIPTOR_PPI,
|
||||||
|
&gEfiPeiVirtualBlockIoPpiGuid,
|
||||||
|
NULL
|
||||||
|
},
|
||||||
|
{
|
||||||
|
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
|
||||||
|
&gEfiPeiVirtualBlockIo2PpiGuid,
|
||||||
|
NULL
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,6 +214,10 @@ InitUsbBot (
|
|||||||
//
|
//
|
||||||
PeiBotDevice->Media.DeviceType = UsbMassStorage;
|
PeiBotDevice->Media.DeviceType = UsbMassStorage;
|
||||||
PeiBotDevice->Media.BlockSize = 0x200;
|
PeiBotDevice->Media.BlockSize = 0x200;
|
||||||
|
PeiBotDevice->Media2.InterfaceType = MSG_USB_DP;
|
||||||
|
PeiBotDevice->Media2.BlockSize = 0x200;
|
||||||
|
PeiBotDevice->Media2.RemovableMedia = FALSE;
|
||||||
|
PeiBotDevice->Media2.ReadOnly = FALSE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check its Bulk-in/Bulk-out endpoint
|
// Check its Bulk-in/Bulk-out endpoint
|
||||||
@ -228,12 +246,23 @@ InitUsbBot (
|
|||||||
&mRecoveryBlkIoPpi,
|
&mRecoveryBlkIoPpi,
|
||||||
sizeof (EFI_PEI_RECOVERY_BLOCK_IO_PPI)
|
sizeof (EFI_PEI_RECOVERY_BLOCK_IO_PPI)
|
||||||
);
|
);
|
||||||
|
CopyMem (
|
||||||
|
&(PeiBotDevice->BlkIo2Ppi),
|
||||||
|
&mRecoveryBlkIo2Ppi,
|
||||||
|
sizeof (EFI_PEI_RECOVERY_BLOCK_IO2_PPI)
|
||||||
|
);
|
||||||
CopyMem (
|
CopyMem (
|
||||||
&(PeiBotDevice->BlkIoPpiList),
|
&(PeiBotDevice->BlkIoPpiList),
|
||||||
&mPpiList,
|
&mPpiList[0],
|
||||||
|
sizeof (EFI_PEI_PPI_DESCRIPTOR)
|
||||||
|
);
|
||||||
|
CopyMem (
|
||||||
|
&(PeiBotDevice->BlkIo2PpiList),
|
||||||
|
&mPpiList[1],
|
||||||
sizeof (EFI_PEI_PPI_DESCRIPTOR)
|
sizeof (EFI_PEI_PPI_DESCRIPTOR)
|
||||||
);
|
);
|
||||||
PeiBotDevice->BlkIoPpiList.Ppi = &PeiBotDevice->BlkIoPpi;
|
PeiBotDevice->BlkIoPpiList.Ppi = &PeiBotDevice->BlkIoPpi;
|
||||||
|
PeiBotDevice->BlkIo2PpiList.Ppi = &PeiBotDevice->BlkIo2Ppi;
|
||||||
|
|
||||||
Status = PeiUsbInquiry (PeiServices, PeiBotDevice);
|
Status = PeiUsbInquiry (PeiServices, PeiBotDevice);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
@ -435,7 +464,7 @@ BotReadBlocks (
|
|||||||
Status = EFI_BAD_BUFFER_SIZE;
|
Status = EFI_BAD_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StartLBA > PeiBotDev->Media.LastBlock) {
|
if (StartLBA > PeiBotDev->Media2.LastBlock) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,11 +518,11 @@ BotReadBlocks (
|
|||||||
return EFI_BAD_BUFFER_SIZE;
|
return EFI_BAD_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StartLBA > PeiBotDev->Media.LastBlock) {
|
if (StartLBA > PeiBotDev->Media2.LastBlock) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((StartLBA + NumberOfBlocks - 1) > PeiBotDev->Media.LastBlock) {
|
if ((StartLBA + NumberOfBlocks - 1) > PeiBotDev->Media2.LastBlock) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,6 +570,168 @@ BotReadBlocks (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the count of block I/O devices that one specific block driver detects.
|
||||||
|
|
||||||
|
This function is used for getting the count of block I/O devices that one
|
||||||
|
specific block driver detects. To the PEI ATAPI driver, it returns the number
|
||||||
|
of all the detected ATAPI devices it detects during the enumeration process.
|
||||||
|
To the PEI legacy floppy driver, it returns the number of all the legacy
|
||||||
|
devices it finds during its enumeration process. If no device is detected,
|
||||||
|
then the function will return zero.
|
||||||
|
|
||||||
|
@param[in] PeiServices General-purpose services that are available
|
||||||
|
to every PEIM.
|
||||||
|
@param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI
|
||||||
|
instance.
|
||||||
|
@param[out] NumberBlockDevices The number of block I/O devices discovered.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Operation performed successfully.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
BotGetNumberOfBlockDevices2 (
|
||||||
|
IN EFI_PEI_SERVICES **PeiServices,
|
||||||
|
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||||
|
OUT UINTN *NumberBlockDevices
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// For Usb devices, this value should be always 1
|
||||||
|
//
|
||||||
|
*NumberBlockDevices = 1;
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets a block device's media information.
|
||||||
|
|
||||||
|
This function will provide the caller with the specified block device's media
|
||||||
|
information. If the media changes, calling this function will update the media
|
||||||
|
information accordingly.
|
||||||
|
|
||||||
|
@param[in] PeiServices General-purpose services that are available to every
|
||||||
|
PEIM
|
||||||
|
@param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.
|
||||||
|
@param[in] DeviceIndex Specifies the block device to which the function wants
|
||||||
|
to talk. Because the driver that implements Block I/O
|
||||||
|
PPIs will manage multiple block devices, the PPIs that
|
||||||
|
want to talk to a single device must specify the
|
||||||
|
device index that was assigned during the enumeration
|
||||||
|
process. This index is a number from one to
|
||||||
|
NumberBlockDevices.
|
||||||
|
@param[out] MediaInfo The media information of the specified block media.
|
||||||
|
The caller is responsible for the ownership of this
|
||||||
|
data structure.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Media information about the specified block device
|
||||||
|
was obtained successfully.
|
||||||
|
@retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware
|
||||||
|
error.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
BotGetMediaInfo2 (
|
||||||
|
IN EFI_PEI_SERVICES **PeiServices,
|
||||||
|
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||||
|
IN UINTN DeviceIndex,
|
||||||
|
OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PEI_BOT_DEVICE *PeiBotDev;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
PeiBotDev = PEI_BOT_DEVICE2_FROM_THIS (This);
|
||||||
|
|
||||||
|
Status = BotGetMediaInfo (
|
||||||
|
PeiServices,
|
||||||
|
&PeiBotDev->BlkIoPpi,
|
||||||
|
DeviceIndex,
|
||||||
|
&PeiBotDev->Media
|
||||||
|
);
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
CopyMem (
|
||||||
|
MediaInfo,
|
||||||
|
&(PeiBotDev->Media2),
|
||||||
|
sizeof (EFI_PEI_BLOCK_IO2_MEDIA)
|
||||||
|
);
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads the requested number of blocks from the specified block device.
|
||||||
|
|
||||||
|
The function reads the requested number of blocks from the device. All the
|
||||||
|
blocks are read, or an error is returned. If there is no media in the device,
|
||||||
|
the function returns EFI_NO_MEDIA.
|
||||||
|
|
||||||
|
@param[in] PeiServices General-purpose services that are available to
|
||||||
|
every PEIM.
|
||||||
|
@param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.
|
||||||
|
@param[in] DeviceIndex Specifies the block device to which the function wants
|
||||||
|
to talk. Because the driver that implements Block I/O
|
||||||
|
PPIs will manage multiple block devices, the PPIs that
|
||||||
|
want to talk to a single device must specify the device
|
||||||
|
index that was assigned during the enumeration process.
|
||||||
|
This index is a number from one to NumberBlockDevices.
|
||||||
|
@param[in] StartLBA The starting logical block address (LBA) to read from
|
||||||
|
on the device
|
||||||
|
@param[in] BufferSize The size of the Buffer in bytes. This number must be
|
||||||
|
a multiple of the intrinsic block size of the device.
|
||||||
|
@param[out] Buffer A pointer to the destination buffer for the data.
|
||||||
|
The caller is responsible for the ownership of the
|
||||||
|
buffer.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The data was read correctly from the device.
|
||||||
|
@retval EFI_DEVICE_ERROR The device reported an error while attempting
|
||||||
|
to perform the read operation.
|
||||||
|
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not
|
||||||
|
valid, or the buffer is not properly aligned.
|
||||||
|
@retval EFI_NO_MEDIA There is no media in the device.
|
||||||
|
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of
|
||||||
|
the intrinsic block size of the device.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
BotReadBlocks2 (
|
||||||
|
IN EFI_PEI_SERVICES **PeiServices,
|
||||||
|
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||||
|
IN UINTN DeviceIndex,
|
||||||
|
IN EFI_PEI_LBA StartLBA,
|
||||||
|
IN UINTN BufferSize,
|
||||||
|
OUT VOID *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PEI_BOT_DEVICE *PeiBotDev;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
if (This == NULL) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
PeiBotDev = PEI_BOT_DEVICE2_FROM_THIS (This);
|
||||||
|
|
||||||
|
Status = BotReadBlocks (
|
||||||
|
PeiServices,
|
||||||
|
&PeiBotDev->BlkIoPpi,
|
||||||
|
DeviceIndex,
|
||||||
|
StartLBA,
|
||||||
|
BufferSize,
|
||||||
|
Buffer
|
||||||
|
);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Detect whether the removable media is present and whether it has changed.
|
Detect whether the removable media is present and whether it has changed.
|
||||||
|
|
||||||
@ -554,17 +745,17 @@ BotReadBlocks (
|
|||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
PeiBotDetectMedia (
|
PeiBotDetectMedia (
|
||||||
IN EFI_PEI_SERVICES **PeiServices,
|
IN EFI_PEI_SERVICES **PeiServices,
|
||||||
IN PEI_BOT_DEVICE *PeiBotDev
|
IN PEI_BOT_DEVICE *PeiBotDev
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_STATUS FloppyStatus;
|
EFI_STATUS FloppyStatus;
|
||||||
UINTN SenseCounts;
|
UINTN SenseCounts;
|
||||||
BOOLEAN NeedReadCapacity;
|
BOOLEAN NeedReadCapacity;
|
||||||
EFI_PHYSICAL_ADDRESS AllocateAddress;
|
EFI_PHYSICAL_ADDRESS AllocateAddress;
|
||||||
ATAPI_REQUEST_SENSE_DATA *SensePtr;
|
ATAPI_REQUEST_SENSE_DATA *SensePtr;
|
||||||
UINTN Retry;
|
UINTN Retry;
|
||||||
|
|
||||||
//
|
//
|
||||||
// if there is no media present,or media not changed,
|
// if there is no media present,or media not changed,
|
||||||
@ -601,12 +792,15 @@ PeiBotDetectMedia (
|
|||||||
NeedReadCapacity = FALSE;
|
NeedReadCapacity = FALSE;
|
||||||
PeiBotDev->Media.MediaPresent = FALSE;
|
PeiBotDev->Media.MediaPresent = FALSE;
|
||||||
PeiBotDev->Media.LastBlock = 0;
|
PeiBotDev->Media.LastBlock = 0;
|
||||||
|
PeiBotDev->Media2.MediaPresent = FALSE;
|
||||||
|
PeiBotDev->Media2.LastBlock = 0;
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// Media Changed
|
// Media Changed
|
||||||
//
|
//
|
||||||
if (IsMediaChange (SensePtr, SenseCounts)) {
|
if (IsMediaChange (SensePtr, SenseCounts)) {
|
||||||
PeiBotDev->Media.MediaPresent = TRUE;
|
PeiBotDev->Media.MediaPresent = TRUE;
|
||||||
|
PeiBotDev->Media2.MediaPresent = TRUE;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Media Error
|
// Media Error
|
||||||
@ -617,6 +811,8 @@ PeiBotDetectMedia (
|
|||||||
//
|
//
|
||||||
PeiBotDev->Media.MediaPresent = FALSE;
|
PeiBotDev->Media.MediaPresent = FALSE;
|
||||||
PeiBotDev->Media.LastBlock = 0;
|
PeiBotDev->Media.LastBlock = 0;
|
||||||
|
PeiBotDev->Media2.MediaPresent = FALSE;
|
||||||
|
PeiBotDev->Media2.LastBlock = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -647,7 +843,7 @@ PeiBotDetectMedia (
|
|||||||
// retry the ReadCapacity command
|
// retry the ReadCapacity command
|
||||||
//
|
//
|
||||||
PeiBotDev->DeviceType = USBFLOPPY;
|
PeiBotDev->DeviceType = USBFLOPPY;
|
||||||
Status = EFI_DEVICE_ERROR;
|
Status = EFI_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -694,6 +890,8 @@ PeiBotDetectMedia (
|
|||||||
if (IsNoMedia (SensePtr, SenseCounts)) {
|
if (IsNoMedia (SensePtr, SenseCounts)) {
|
||||||
PeiBotDev->Media.MediaPresent = FALSE;
|
PeiBotDev->Media.MediaPresent = FALSE;
|
||||||
PeiBotDev->Media.LastBlock = 0;
|
PeiBotDev->Media.LastBlock = 0;
|
||||||
|
PeiBotDev->Media2.MediaPresent = FALSE;
|
||||||
|
PeiBotDev->Media2.LastBlock = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -703,6 +901,8 @@ PeiBotDetectMedia (
|
|||||||
//
|
//
|
||||||
PeiBotDev->Media.MediaPresent = FALSE;
|
PeiBotDev->Media.MediaPresent = FALSE;
|
||||||
PeiBotDev->Media.LastBlock = 0;
|
PeiBotDev->Media.LastBlock = 0;
|
||||||
|
PeiBotDev->Media2.MediaPresent = FALSE;
|
||||||
|
PeiBotDev->Media2.LastBlock = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Usb BOT Peim definition.
|
Usb BOT Peim definition.
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
|
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions
|
are licensed and made available under the terms and conditions
|
||||||
@ -22,6 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include <Ppi/UsbIo.h>
|
#include <Ppi/UsbIo.h>
|
||||||
#include <Ppi/UsbHostController.h>
|
#include <Ppi/UsbHostController.h>
|
||||||
#include <Ppi/BlockIo.h>
|
#include <Ppi/BlockIo.h>
|
||||||
|
#include <Ppi/BlockIo2.h>
|
||||||
|
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
|
|
||||||
@ -139,8 +140,116 @@ BotReadBlocks (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
UsbIo installation notification function.
|
Gets the count of block I/O devices that one specific block driver detects.
|
||||||
|
|
||||||
|
This function is used for getting the count of block I/O devices that one
|
||||||
|
specific block driver detects. To the PEI ATAPI driver, it returns the number
|
||||||
|
of all the detected ATAPI devices it detects during the enumeration process.
|
||||||
|
To the PEI legacy floppy driver, it returns the number of all the legacy
|
||||||
|
devices it finds during its enumeration process. If no device is detected,
|
||||||
|
then the function will return zero.
|
||||||
|
|
||||||
|
@param[in] PeiServices General-purpose services that are available
|
||||||
|
to every PEIM.
|
||||||
|
@param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI
|
||||||
|
instance.
|
||||||
|
@param[out] NumberBlockDevices The number of block I/O devices discovered.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Operation performed successfully.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
BotGetNumberOfBlockDevices2 (
|
||||||
|
IN EFI_PEI_SERVICES **PeiServices,
|
||||||
|
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||||
|
OUT UINTN *NumberBlockDevices
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets a block device's media information.
|
||||||
|
|
||||||
|
This function will provide the caller with the specified block device's media
|
||||||
|
information. If the media changes, calling this function will update the media
|
||||||
|
information accordingly.
|
||||||
|
|
||||||
|
@param[in] PeiServices General-purpose services that are available to every
|
||||||
|
PEIM
|
||||||
|
@param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.
|
||||||
|
@param[in] DeviceIndex Specifies the block device to which the function wants
|
||||||
|
to talk. Because the driver that implements Block I/O
|
||||||
|
PPIs will manage multiple block devices, the PPIs that
|
||||||
|
want to talk to a single device must specify the
|
||||||
|
device index that was assigned during the enumeration
|
||||||
|
process. This index is a number from one to
|
||||||
|
NumberBlockDevices.
|
||||||
|
@param[out] MediaInfo The media information of the specified block media.
|
||||||
|
The caller is responsible for the ownership of this
|
||||||
|
data structure.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Media information about the specified block device
|
||||||
|
was obtained successfully.
|
||||||
|
@retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware
|
||||||
|
error.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
BotGetMediaInfo2 (
|
||||||
|
IN EFI_PEI_SERVICES **PeiServices,
|
||||||
|
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||||
|
IN UINTN DeviceIndex,
|
||||||
|
OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads the requested number of blocks from the specified block device.
|
||||||
|
|
||||||
|
The function reads the requested number of blocks from the device. All the
|
||||||
|
blocks are read, or an error is returned. If there is no media in the device,
|
||||||
|
the function returns EFI_NO_MEDIA.
|
||||||
|
|
||||||
|
@param[in] PeiServices General-purpose services that are available to
|
||||||
|
every PEIM.
|
||||||
|
@param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.
|
||||||
|
@param[in] DeviceIndex Specifies the block device to which the function wants
|
||||||
|
to talk. Because the driver that implements Block I/O
|
||||||
|
PPIs will manage multiple block devices, the PPIs that
|
||||||
|
want to talk to a single device must specify the device
|
||||||
|
index that was assigned during the enumeration process.
|
||||||
|
This index is a number from one to NumberBlockDevices.
|
||||||
|
@param[in] StartLBA The starting logical block address (LBA) to read from
|
||||||
|
on the device
|
||||||
|
@param[in] BufferSize The size of the Buffer in bytes. This number must be
|
||||||
|
a multiple of the intrinsic block size of the device.
|
||||||
|
@param[out] Buffer A pointer to the destination buffer for the data.
|
||||||
|
The caller is responsible for the ownership of the
|
||||||
|
buffer.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The data was read correctly from the device.
|
||||||
|
@retval EFI_DEVICE_ERROR The device reported an error while attempting
|
||||||
|
to perform the read operation.
|
||||||
|
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not
|
||||||
|
valid, or the buffer is not properly aligned.
|
||||||
|
@retval EFI_NO_MEDIA There is no media in the device.
|
||||||
|
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of
|
||||||
|
the intrinsic block size of the device.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
BotReadBlocks2 (
|
||||||
|
IN EFI_PEI_SERVICES **PeiServices,
|
||||||
|
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||||
|
IN UINTN DeviceIndex,
|
||||||
|
IN EFI_PEI_LBA StartLBA,
|
||||||
|
IN UINTN BufferSize,
|
||||||
|
OUT VOID *Buffer
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
UsbIo installation notification function.
|
||||||
|
|
||||||
This function finds out all the current USB IO PPIs in the system and add them
|
This function finds out all the current USB IO PPIs in the system and add them
|
||||||
into private data.
|
into private data.
|
||||||
|
|
||||||
@ -188,18 +297,22 @@ InitUsbBot (
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
UINTN Signature;
|
UINTN Signature;
|
||||||
EFI_PEI_RECOVERY_BLOCK_IO_PPI BlkIoPpi;
|
EFI_PEI_RECOVERY_BLOCK_IO_PPI BlkIoPpi;
|
||||||
|
EFI_PEI_RECOVERY_BLOCK_IO2_PPI BlkIo2Ppi;
|
||||||
EFI_PEI_PPI_DESCRIPTOR BlkIoPpiList;
|
EFI_PEI_PPI_DESCRIPTOR BlkIoPpiList;
|
||||||
|
EFI_PEI_PPI_DESCRIPTOR BlkIo2PpiList;
|
||||||
EFI_PEI_BLOCK_IO_MEDIA Media;
|
EFI_PEI_BLOCK_IO_MEDIA Media;
|
||||||
|
EFI_PEI_BLOCK_IO2_MEDIA Media2;
|
||||||
PEI_USB_IO_PPI *UsbIoPpi;
|
PEI_USB_IO_PPI *UsbIoPpi;
|
||||||
EFI_USB_INTERFACE_DESCRIPTOR *BotInterface;
|
EFI_USB_INTERFACE_DESCRIPTOR *BotInterface;
|
||||||
EFI_USB_ENDPOINT_DESCRIPTOR *BulkInEndpoint;
|
EFI_USB_ENDPOINT_DESCRIPTOR *BulkInEndpoint;
|
||||||
EFI_USB_ENDPOINT_DESCRIPTOR *BulkOutEndpoint;
|
EFI_USB_ENDPOINT_DESCRIPTOR *BulkOutEndpoint;
|
||||||
UINTN AllocateAddress;
|
UINTN AllocateAddress;
|
||||||
UINTN DeviceType;
|
UINTN DeviceType;
|
||||||
ATAPI_REQUEST_SENSE_DATA *SensePtr;
|
ATAPI_REQUEST_SENSE_DATA *SensePtr;
|
||||||
} PEI_BOT_DEVICE;
|
} PEI_BOT_DEVICE;
|
||||||
|
|
||||||
#define PEI_BOT_DEVICE_FROM_THIS(a) CR (a, PEI_BOT_DEVICE, BlkIoPpi, PEI_BOT_DEVICE_SIGNATURE)
|
#define PEI_BOT_DEVICE_FROM_THIS(a) CR (a, PEI_BOT_DEVICE, BlkIoPpi, PEI_BOT_DEVICE_SIGNATURE)
|
||||||
|
#define PEI_BOT_DEVICE2_FROM_THIS(a) CR (a, PEI_BOT_DEVICE, BlkIo2Ppi, PEI_BOT_DEVICE_SIGNATURE)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Send ATAPI command using BOT protocol.
|
Send ATAPI command using BOT protocol.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Usb Peim definition.
|
Usb Peim definition.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
|
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions
|
are licensed and made available under the terms and conditions
|
||||||
@ -22,6 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
#include <Ppi/UsbIo.h>
|
#include <Ppi/UsbIo.h>
|
||||||
#include <Ppi/BlockIo.h>
|
#include <Ppi/BlockIo.h>
|
||||||
|
#include <Ppi/BlockIo2.h>
|
||||||
|
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user