/** @file
BOT Transportation implementation.
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
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 "UsbBotPeim.h"
#include "BotPeim.h"
#include "PeiUsbLib.h"
/**
Reset the given usb device.
@param PeiServices The pointer of EFI_PEI_SERVICES.
@param PeiBotDev The instance to PEI_BOT_DEVICE.
@retval EFI_INVALID_PARAMETER Can not get usb io ppi.
@retval EFI_SUCCESS Failed to reset the given usb device.
**/
)
{
return EFI_INVALID_PARAMETER;
}
Timeout = 3000;
&DevReq,
NULL,
0
);
//
// clear bulk in endpoint stall feature
//
//
// clear bulk out endpoint stall feature
//
return Status;
}
/**
Send the command to the device using Bulk-Out endpoint.
This function sends the command to the device using Bulk-Out endpoint.
BOT transfer is composed of three phases: Command, Data, and Status.
This is the Command phase.
@param PeiServices The pointer of EFI_PEI_SERVICES.
@param PeiBotDev The instance to PEI_BOT_DEVICE.
@param Command The command to transfer to device.
@param CommandSize The length of the command.
@param DataTransferLength The expected length of the data.
@param Direction The direction of the data.
@param Timeout Indicates the maximum time, in millisecond, which the
transfer is allowed to complete.
@retval EFI_DEVICE_ERROR Successful to send the command to device.
@retval EFI_SUCCESS Failed to send the command to device.
**/
)
{
//
// Fill the command block, detailed see BOT spec
//
&DataSize,
);
//
// Command phase fail, we need to recovery reset this device
//
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
}
/**
Transfer the data between the device and host.
This function transfers the data between the device and host.
BOT transfer is composed of three phases: Command, Data, and Status.
This is the Data phase.
@param PeiServices The pointer of EFI_PEI_SERVICES.
@param PeiBotDev The instance to PEI_BOT_DEVICE.
@param DataSize The length of the data.
@param DataBuffer The pointer to the data.
@param Direction The direction of the data.
@param Timeout Indicates the maximum time, in millisecond, which the
transfer is allowed to complete.
@retval EFI_DEVICE_ERROR Successful to send the data to device.
@retval EFI_SUCCESS Failed to send the data to device.
**/
)
{
TransferredSize = 0;
//
// retrieve the the max packet length of the given endpoint
//
if (Direction == EfiUsbDataIn) {
} else {
}
while (Remain > 0) {
//
// Using 15 packets to avoid Bitstuff error
//
} else {
}
);
return Status;
}
}
return EFI_SUCCESS;
}
/**
Get the command execution status from device.
This function gets the command execution status from device.
BOT transfer is composed of three phases: Command, Data, and Status.
This is the Status phase.
@param PeiServices The pointer of EFI_PEI_SERVICES.
@param PeiBotDev The instance to PEI_BOT_DEVICE.
@param TransferStatus The status of the transaction.
@param Timeout Indicates the maximum time, in millisecond, which the
transfer is allowed to complete.
@retval EFI_DEVICE_ERROR Successful to get the status of device.
@retval EFI_SUCCESS Failed to get the status of device.
**/
)
{
//
// Get the status field from bulk transfer
//
&Csw,
&DataSize,
);
return Status;
}
} else {
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
}
/**
Send ATAPI command using BOT protocol.
@param PeiServices The pointer of EFI_PEI_SERVICES.
@param PeiBotDev The instance to PEI_BOT_DEVICE.
@param Command The command to be sent to ATAPI device.
@param CommandSize The length of the data to be sent.
@param DataBuffer The pointer to the data.
@param BufferLength The length of the data.
@param Direction The direction of the data.
@param TimeOutInMilliSeconds Indicates the maximum time, in millisecond, which the
transfer is allowed to complete.
@retval EFI_DEVICE_ERROR Successful to get the status of device.
@retval EFI_SUCCESS Failed to get the status of device.
**/
)
{
//
// First send ATAPI command through Bot
//
);
return EFI_DEVICE_ERROR;
}
//
//
switch (Direction) {
case EfiUsbDataIn:
case EfiUsbDataOut:
);
break;
case EfiUsbNoData:
break;
}
//
// Status Phase
//
Status = BotStatusPhase (
);
return EFI_DEVICE_ERROR;
}
if (TransferStatus == 0x01) {
return EFI_DEVICE_ERROR;
}
return BotDataStatus;
}