/** @file
Usb Hub Request Support In PEI Phase
Copyright (c) 2006 - 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
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 "UsbPeim.h"
#include "HubPeim.h"
#include "PeiUsbLib.h"
/**
Get a given hub port status.
@param PeiServices General-purpose services that are available to every PEIM.
@param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
@param Port Usb hub port number (starting from 1).
@param PortStatus Current Hub port status and change status.
@retval EFI_SUCCESS Port status is obtained successfully.
@retval EFI_DEVICE_ERROR Cannot get the port status due to a hardware error.
@retval Others Other failure occurs.
**/
)
{
//
// Fill Device request packet
//
return UsbIoPpi->UsbControlTransfer (
sizeof (UINT32)
);
}
/**
Set specified feature to a given hub port.
@param PeiServices General-purpose services that are available to every PEIM.
@param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
@param Port Usb hub port number (starting from 1).
@param Value New feature value.
@retval EFI_SUCCESS Port feature is set successfully.
@retval EFI_DEVICE_ERROR Cannot set the port feature due to a hardware error.
@retval Others Other failure occurs.
**/
)
{
//
// Fill Device request packet
//
return UsbIoPpi->UsbControlTransfer (
NULL,
0
);
}
/**
Clear specified feature on a given hub port.
@param PeiServices General-purpose services that are available to every PEIM.
@param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
@param Port Usb hub port number (starting from 1).
@param Value Feature value that will be cleared from the hub port.
@retval EFI_SUCCESS Port feature is cleared successfully.
@retval EFI_DEVICE_ERROR Cannot clear the port feature due to a hardware error.
@retval Others Other failure occurs.
**/
)
{
//
// Fill Device request packet
//
return UsbIoPpi->UsbControlTransfer (
NULL,
0
);
}
/**
Get a given hub status.
@param PeiServices General-purpose services that are available to every PEIM.
@param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
@param HubStatus Current Hub status and change status.
@retval EFI_SUCCESS Hub status is obtained successfully.
@retval EFI_DEVICE_ERROR Cannot get the hub status due to a hardware error.
@retval Others Other failure occurs.
**/
)
{
//
// Fill Device request packet
//
return UsbIoPpi->UsbControlTransfer (
sizeof (UINT32)
);
}
/**
Set specified feature to a given hub.
@param PeiServices General-purpose services that are available to every PEIM.
@param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
@param Value New feature value.
@retval EFI_SUCCESS Port feature is set successfully.
@retval EFI_DEVICE_ERROR Cannot set the port feature due to a hardware error.
@retval Others Other failure occurs.
**/
)
{
//
// Fill Device request packet
//
return UsbIoPpi->UsbControlTransfer (
NULL,
0
);
}
/**
Clear specified feature on a given hub.
@param PeiServices General-purpose services that are available to every PEIM.
@param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
@param Value Feature value that will be cleared from the hub port.
@retval EFI_SUCCESS Hub feature is cleared successfully.
@retval EFI_DEVICE_ERROR Cannot clear the hub feature due to a hardware error.
@retval Others Other failure occurs.
**/
)
{
//
// Fill Device request packet
//
return UsbIoPpi->UsbControlTransfer (
NULL,
0
);
}
/**
Get a given hub descriptor.
@param PeiServices General-purpose services that are available to every PEIM.
@param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
@param DescriptorSize The length of Hub Descriptor buffer.
@param HubDescriptor Caller allocated buffer to store the hub descriptor if
successfully returned.
@retval EFI_SUCCESS Hub descriptor is obtained successfully.
@retval EFI_DEVICE_ERROR Cannot get the hub descriptor due to a hardware error.
@retval Others Other failure occurs.
**/
)
{
//
// Fill Device request packet
//
return UsbIoPpi->UsbControlTransfer (
&DevReq,
);
}
/**
Configure a given hub.
@param PeiServices General-purpose services that are available to every PEIM.
@param PeiUsbDevice Indicating the hub controller device that will be configured
@retval EFI_SUCCESS Hub configuration is done successfully.
@retval EFI_DEVICE_ERROR Cannot configure the hub due to a hardware error.
**/
)
{
//
// First get the hub descriptor length
//
2,
);
return EFI_DEVICE_ERROR;
}
//
// First get the whole descriptor, then
// get the number of hub ports
//
);
return EFI_DEVICE_ERROR;
}
);
return EFI_DEVICE_ERROR;
}
//
// Get all hub ports status
//
);
continue;
}
}
//
// Power all the hub ports
//
);
continue;
}
}
//
// Clear Hub Status Change
//
);
return EFI_DEVICE_ERROR;
} else {
//
// Hub power supply change happens
//
);
}
//
// Hub change overcurrent happens
//
);
}
}
return EFI_SUCCESS;
}
/**
Send reset signal over the given root hub port.
@param PeiServices General-purpose services that are available to every PEIM.
@param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
@param PortNum Usb hub port number (starting from 1).
**/
)
{
//
// reset root port
//
);
Try = 10;
do {
(UINT32 *) &HubPortStatus
);
Try -= 1;
//
// clear reset root port
//
);
);
//
// Set port enable
//
);
//
// Clear any change status
//
);
return;
}