summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Bus/Usb
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:02 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commit1436aea4d5707e672672a11bda72be2c63c936c3 (patch)
tree370c9d5bd8823aa8ea7bce71a0f29bff71feff67 /MdeModulePkg/Bus/Usb
parent7c7184e201a90a1d2376e615e55e3f4074731468 (diff)
downloadedk2-1436aea4d5707e672672a11bda72be2c63c936c3.zip
edk2-1436aea4d5707e672672a11bda72be2c63c936c3.tar.gz
edk2-1436aea4d5707e672672a11bda72be2c63c936c3.tar.bz2
MdeModulePkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the MdeModulePkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Diffstat (limited to 'MdeModulePkg/Bus/Usb')
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBotPei/BotPeim.c216
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBotPei/BotPeim.h37
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c351
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c68
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.h85
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPeim.c366
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPeim.h112
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBotPei/UsbPeim.h1
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/ComponentName.c36
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c541
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h239
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c366
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.h76
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c332
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.h58
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c393
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.h116
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c496
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h36
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c196
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.h117
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c57
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h106
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c215
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c533
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.h123
-rw-r--r--MdeModulePkg/Bus/Usb/UsbKbDxe/ComponentName.c37
-rw-r--r--MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c294
-rw-r--r--MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h231
-rw-r--r--MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c861
-rw-r--r--MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h91
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMassStorageDxe/ComponentName.c23
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMass.h65
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c431
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h217
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c136
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.h74
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.c197
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.h36
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassDiskInfo.c41
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassDiskInfo.h30
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c242
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.h46
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/ComponentName.c38
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/MouseHid.c192
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.c226
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.h139
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMouseDxe/ComponentName.c38
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMouseDxe/MouseHid.c194
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c226
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.h143
51 files changed, 4739 insertions, 4781 deletions
diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/BotPeim.c b/MdeModulePkg/Bus/Usb/UsbBotPei/BotPeim.c
index 2b1ca20..1df799e 100644
--- a/MdeModulePkg/Bus/Usb/UsbBotPei/BotPeim.c
+++ b/MdeModulePkg/Bus/Usb/UsbBotPei/BotPeim.c
@@ -23,8 +23,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
BotRecoveryReset (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_BOT_DEVICE *PeiBotDev
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_BOT_DEVICE *PeiBotDev
)
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -41,23 +41,23 @@ BotRecoveryReset (
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
- DevReq.RequestType = 0x21;
- DevReq.Request = 0xFF;
- DevReq.Value = 0;
- DevReq.Index = 0;
- DevReq.Length = 0;
+ DevReq.RequestType = 0x21;
+ DevReq.Request = 0xFF;
+ DevReq.Value = 0;
+ DevReq.Index = 0;
+ DevReq.Length = 0;
- Timeout = 3000;
+ Timeout = 3000;
Status = UsbIoPpi->UsbControlTransfer (
- PeiServices,
- UsbIoPpi,
- &DevReq,
- EfiUsbNoData,
- Timeout,
- NULL,
- 0
- );
+ PeiServices,
+ UsbIoPpi,
+ &DevReq,
+ EfiUsbNoData,
+ Timeout,
+ NULL,
+ 0
+ );
//
// clear bulk in endpoint stall feature
@@ -96,13 +96,13 @@ BotRecoveryReset (
**/
EFI_STATUS
BotCommandPhase (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_BOT_DEVICE *PeiBotDev,
- IN VOID *Command,
- IN UINT8 CommandSize,
- IN UINT32 DataTransferLength,
- IN EFI_USB_DATA_DIRECTION Direction,
- IN UINT16 Timeout
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_BOT_DEVICE *PeiBotDev,
+ IN VOID *Command,
+ IN UINT8 CommandSize,
+ IN UINT32 DataTransferLength,
+ IN EFI_USB_DATA_DIRECTION Direction,
+ IN UINT16 Timeout
)
{
CBW Cbw;
@@ -117,25 +117,25 @@ BotCommandPhase (
//
// Fill the command block, detailed see BOT spec
//
- Cbw.Signature = CBWSIG;
- Cbw.Tag = 0x01;
- Cbw.DataTransferLength = DataTransferLength;
- Cbw.Flags = (UINT8) ((Direction == EfiUsbDataIn) ? 0x80 : 0);
- Cbw.Lun = 0;
- Cbw.CmdLen = CommandSize;
+ Cbw.Signature = CBWSIG;
+ Cbw.Tag = 0x01;
+ Cbw.DataTransferLength = DataTransferLength;
+ Cbw.Flags = (UINT8)((Direction == EfiUsbDataIn) ? 0x80 : 0);
+ Cbw.Lun = 0;
+ Cbw.CmdLen = CommandSize;
CopyMem (Cbw.CmdBlock, Command, CommandSize);
DataSize = sizeof (CBW);
Status = UsbIoPpi->UsbBulkTransfer (
- PeiServices,
- UsbIoPpi,
- (PeiBotDev->BulkOutEndpoint)->EndpointAddress,
- (UINT8 *) &Cbw,
- &DataSize,
- Timeout
- );
+ PeiServices,
+ UsbIoPpi,
+ (PeiBotDev->BulkOutEndpoint)->EndpointAddress,
+ (UINT8 *)&Cbw,
+ &DataSize,
+ Timeout
+ );
if (EFI_ERROR (Status)) {
//
// Command phase fail, we need to recovery reset this device
@@ -168,12 +168,12 @@ BotCommandPhase (
**/
EFI_STATUS
BotDataPhase (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_BOT_DEVICE *PeiBotDev,
- IN UINT32 *DataSize,
- IN OUT VOID *DataBuffer,
- IN EFI_USB_DATA_DIRECTION Direction,
- IN UINT16 Timeout
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_BOT_DEVICE *PeiBotDev,
+ IN UINT32 *DataSize,
+ IN OUT VOID *DataBuffer,
+ IN EFI_USB_DATA_DIRECTION Direction,
+ IN UINT16 Timeout
)
{
EFI_STATUS Status;
@@ -185,21 +185,21 @@ BotDataPhase (
UINT8 *BufferPtr;
UINTN TransferredSize;
- UsbIoPpi = PeiBotDev->UsbIoPpi;
+ UsbIoPpi = PeiBotDev->UsbIoPpi;
Remain = *DataSize;
- BufferPtr = (UINT8 *) DataBuffer;
+ BufferPtr = (UINT8 *)DataBuffer;
TransferredSize = 0;
//
// retrieve the max packet length of the given endpoint
//
if (Direction == EfiUsbDataIn) {
- MaxPacketLen = (PeiBotDev->BulkInEndpoint)->MaxPacketSize;
- EndpointAddr = (PeiBotDev->BulkInEndpoint)->EndpointAddress;
+ MaxPacketLen = (PeiBotDev->BulkInEndpoint)->MaxPacketSize;
+ EndpointAddr = (PeiBotDev->BulkInEndpoint)->EndpointAddress;
} else {
- MaxPacketLen = (PeiBotDev->BulkOutEndpoint)->MaxPacketSize;
- EndpointAddr = (PeiBotDev->BulkOutEndpoint)->EndpointAddress;
+ MaxPacketLen = (PeiBotDev->BulkOutEndpoint)->MaxPacketSize;
+ EndpointAddr = (PeiBotDev->BulkOutEndpoint)->EndpointAddress;
}
while (Remain > 0) {
@@ -213,13 +213,13 @@ BotDataPhase (
}
Status = UsbIoPpi->UsbBulkTransfer (
- PeiServices,
- UsbIoPpi,
- EndpointAddr,
- BufferPtr,
- &Increment,
- Timeout
- );
+ PeiServices,
+ UsbIoPpi,
+ EndpointAddr,
+ BufferPtr,
+ &Increment,
+ Timeout
+ );
TransferredSize += Increment;
@@ -229,10 +229,10 @@ BotDataPhase (
}
BufferPtr += Increment;
- Remain -= Increment;
+ Remain -= Increment;
}
- *DataSize = (UINT32) TransferredSize;
+ *DataSize = (UINT32)TransferredSize;
return EFI_SUCCESS;
}
@@ -256,10 +256,10 @@ BotDataPhase (
**/
EFI_STATUS
BotStatusPhase (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_BOT_DEVICE *PeiBotDev,
- OUT UINT8 *TransferStatus,
- IN UINT16 Timeout
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_BOT_DEVICE *PeiBotDev,
+ OUT UINT8 *TransferStatus,
+ IN UINT16 Timeout
)
{
CSW Csw;
@@ -272,21 +272,21 @@ BotStatusPhase (
ZeroMem (&Csw, sizeof (CSW));
- EndpointAddr = (PeiBotDev->BulkInEndpoint)->EndpointAddress;
+ EndpointAddr = (PeiBotDev->BulkInEndpoint)->EndpointAddress;
- DataSize = sizeof (CSW);
+ DataSize = sizeof (CSW);
//
// Get the status field from bulk transfer
//
Status = UsbIoPpi->UsbBulkTransfer (
- PeiServices,
- UsbIoPpi,
- EndpointAddr,
- &Csw,
- &DataSize,
- Timeout
- );
+ PeiServices,
+ UsbIoPpi,
+ EndpointAddr,
+ &Csw,
+ &DataSize,
+ Timeout
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -319,14 +319,14 @@ BotStatusPhase (
**/
EFI_STATUS
PeiAtapiCommand (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_BOT_DEVICE *PeiBotDev,
- IN VOID *Command,
- IN UINT8 CommandSize,
- IN VOID *DataBuffer,
- IN UINT32 BufferLength,
- IN EFI_USB_DATA_DIRECTION Direction,
- IN UINT16 TimeOutInMilliSeconds
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_BOT_DEVICE *PeiBotDev,
+ IN VOID *Command,
+ IN UINT8 CommandSize,
+ IN VOID *DataBuffer,
+ IN UINT32 BufferLength,
+ IN EFI_USB_DATA_DIRECTION Direction,
+ IN UINT16 TimeOutInMilliSeconds
)
{
EFI_STATUS Status;
@@ -339,48 +339,50 @@ PeiAtapiCommand (
// First send ATAPI command through Bot
//
Status = BotCommandPhase (
- PeiServices,
- PeiBotDev,
- Command,
- CommandSize,
- BufferLength,
- Direction,
- TimeOutInMilliSeconds
- );
+ PeiServices,
+ PeiBotDev,
+ Command,
+ CommandSize,
+ BufferLength,
+ Direction,
+ TimeOutInMilliSeconds
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
+
//
// Send/Get Data if there is a Data Stage
//
switch (Direction) {
- case EfiUsbDataIn:
- case EfiUsbDataOut:
- BufferSize = BufferLength;
-
- BotDataStatus = BotDataPhase (
- PeiServices,
- PeiBotDev,
- &BufferSize,
- DataBuffer,
- Direction,
- TimeOutInMilliSeconds
- );
- break;
-
- case EfiUsbNoData:
- break;
+ case EfiUsbDataIn:
+ case EfiUsbDataOut:
+ BufferSize = BufferLength;
+
+ BotDataStatus = BotDataPhase (
+ PeiServices,
+ PeiBotDev,
+ &BufferSize,
+ DataBuffer,
+ Direction,
+ TimeOutInMilliSeconds
+ );
+ break;
+
+ case EfiUsbNoData:
+ break;
}
+
//
// Status Phase
//
Status = BotStatusPhase (
- PeiServices,
- PeiBotDev,
- &TransferStatus,
- TimeOutInMilliSeconds
- );
+ PeiServices,
+ PeiBotDev,
+ &TransferStatus,
+ TimeOutInMilliSeconds
+ );
if (EFI_ERROR (Status)) {
BotRecoveryReset (PeiServices, PeiBotDev);
return EFI_DEVICE_ERROR;
diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/BotPeim.h b/MdeModulePkg/Bus/Usb/UsbBotPei/BotPeim.h
index a4ad759..54d149e 100644
--- a/MdeModulePkg/Bus/Usb/UsbBotPei/BotPeim.h
+++ b/MdeModulePkg/Bus/Usb/UsbBotPei/BotPeim.h
@@ -10,14 +10,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _PEI_BOT_PEIM_H_
#define _PEI_BOT_PEIM_H_
-
#include <PiPei.h>
#include <Ppi/UsbIo.h>
#include <Ppi/UsbHostController.h>
#include <Ppi/BlockIo.h>
-//#include <Library/DebugLib.h>
+// #include <Library/DebugLib.h>
#include <Library/PeimEntryPoint.h>
#include <Library/PeiServicesLib.h>
#include <Library/BaseMemoryLib.h>
@@ -29,20 +28,20 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Bulk Only device protocol
//
typedef struct {
- UINT32 Signature;
- UINT32 Tag;
- UINT32 DataTransferLength;
- UINT8 Flags;
- UINT8 Lun;
- UINT8 CmdLen;
- UINT8 CmdBlock[16];
+ UINT32 Signature;
+ UINT32 Tag;
+ UINT32 DataTransferLength;
+ UINT8 Flags;
+ UINT8 Lun;
+ UINT8 CmdLen;
+ UINT8 CmdBlock[16];
} CBW;
typedef struct {
- UINT32 Signature;
- UINT32 Tag;
- UINT32 DataResidue;
- UINT8 Status;
+ UINT32 Signature;
+ UINT32 Tag;
+ UINT32 DataResidue;
+ UINT8 Status;
} CSW;
#pragma pack()
@@ -178,8 +177,8 @@ PeiUsbRead10 (
**/
BOOLEAN
IsNoMedia (
- IN ATAPI_REQUEST_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN ATAPI_REQUEST_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
);
/**
@@ -194,8 +193,8 @@ IsNoMedia (
**/
BOOLEAN
IsMediaError (
- IN ATAPI_REQUEST_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN ATAPI_REQUEST_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
);
/**
@@ -210,8 +209,8 @@ IsMediaError (
**/
BOOLEAN
IsMediaChange (
- IN ATAPI_REQUEST_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN ATAPI_REQUEST_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
);
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c
index c5ba307..422ac5f 100644
--- a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c
+++ b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c
@@ -10,7 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "UsbBotPeim.h"
#include "BotPeim.h"
-#define MAXSENSEKEY 5
+#define MAXSENSEKEY 5
/**
Sends out ATAPI Inquiry Packet Command to the specified device. This command will
@@ -31,7 +31,7 @@ PeiUsbInquiry (
{
ATAPI_PACKET_COMMAND Packet;
EFI_STATUS Status;
- ATAPI_INQUIRY_DATA Idata;
+ ATAPI_INQUIRY_DATA Idata;
//
// fill command packet
@@ -39,9 +39,9 @@ PeiUsbInquiry (
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
ZeroMem (&Idata, sizeof (ATAPI_INQUIRY_DATA));
- Packet.Inquiry.opcode = ATA_CMD_INQUIRY;
- Packet.Inquiry.page_code = 0;
- Packet.Inquiry.allocation_length = 36;
+ Packet.Inquiry.opcode = ATA_CMD_INQUIRY;
+ Packet.Inquiry.page_code = 0;
+ Packet.Inquiry.allocation_length = 36;
//
// Send scsi INQUIRY command packet.
@@ -49,29 +49,29 @@ PeiUsbInquiry (
// retrieve the first 36 bytes for standard INQUIRY data.
//
Status = PeiAtapiCommand (
- PeiServices,
- PeiBotDevice,
- &Packet,
- (UINT8) sizeof (ATAPI_PACKET_COMMAND),
- &Idata,
- 36,
- EfiUsbDataIn,
- 2000
- );
+ PeiServices,
+ PeiBotDevice,
+ &Packet,
+ (UINT8)sizeof (ATAPI_PACKET_COMMAND),
+ &Idata,
+ 36,
+ EfiUsbDataIn,
+ 2000
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
if ((Idata.peripheral_type & 0x1f) == 0x05) {
- PeiBotDevice->DeviceType = USBCDROM;
- PeiBotDevice->Media.BlockSize = 0x800;
+ PeiBotDevice->DeviceType = USBCDROM;
+ PeiBotDevice->Media.BlockSize = 0x800;
PeiBotDevice->Media2.ReadOnly = TRUE;
PeiBotDevice->Media2.RemovableMedia = TRUE;
PeiBotDevice->Media2.BlockSize = 0x800;
} else {
- PeiBotDevice->DeviceType = USBFLOPPY;
- PeiBotDevice->Media.BlockSize = 0x200;
+ PeiBotDevice->DeviceType = USBFLOPPY;
+ PeiBotDevice->Media.BlockSize = 0x200;
PeiBotDevice->Media2.ReadOnly = FALSE;
PeiBotDevice->Media2.RemovableMedia = TRUE;
PeiBotDevice->Media2.BlockSize = 0x200;
@@ -110,15 +110,15 @@ PeiUsbTestUnitReady (
// send command packet
//
Status = PeiAtapiCommand (
- PeiServices,
- PeiBotDevice,
- &Packet,
- (UINT8) sizeof (ATAPI_PACKET_COMMAND),
- NULL,
- 0,
- EfiUsbNoData,
- 2000
- );
+ PeiServices,
+ PeiBotDevice,
+ &Packet,
+ (UINT8)sizeof (ATAPI_PACKET_COMMAND),
+ NULL,
+ 0,
+ EfiUsbNoData,
+ 2000
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
@@ -147,11 +147,11 @@ PeiUsbRequestSense (
IN UINT8 *SenseKeyBuffer
)
{
- EFI_STATUS Status;
- ATAPI_PACKET_COMMAND Packet;
- UINT8 *Ptr;
- BOOLEAN SenseReq;
- ATAPI_REQUEST_SENSE_DATA *Sense;
+ EFI_STATUS Status;
+ ATAPI_PACKET_COMMAND Packet;
+ UINT8 *Ptr;
+ BOOLEAN SenseReq;
+ ATAPI_REQUEST_SENSE_DATA *Sense;
*SenseCounts = 0;
@@ -160,7 +160,7 @@ PeiUsbRequestSense (
//
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
Packet.RequestSence.opcode = ATA_CMD_REQUEST_SENSE;
- Packet.RequestSence.allocation_length = (UINT8) sizeof (ATAPI_REQUEST_SENSE_DATA);
+ Packet.RequestSence.allocation_length = (UINT8)sizeof (ATAPI_REQUEST_SENSE_DATA);
Ptr = SenseKeyBuffer;
@@ -171,22 +171,22 @@ PeiUsbRequestSense (
// until no sense data exists in the device.
//
while (SenseReq) {
- Sense = (ATAPI_REQUEST_SENSE_DATA *) Ptr;
+ Sense = (ATAPI_REQUEST_SENSE_DATA *)Ptr;
//
// send out Request Sense Packet Command and get one Sense
// data form device.
//
Status = PeiAtapiCommand (
- PeiServices,
- PeiBotDevice,
- &Packet,
- (UINT8) sizeof (ATAPI_PACKET_COMMAND),
- (VOID *) Ptr,
- sizeof (ATAPI_REQUEST_SENSE_DATA),
- EfiUsbDataIn,
- 2000
- );
+ PeiServices,
+ PeiBotDevice,
+ &Packet,
+ (UINT8)sizeof (ATAPI_PACKET_COMMAND),
+ (VOID *)Ptr,
+ sizeof (ATAPI_REQUEST_SENSE_DATA),
+ EfiUsbDataIn,
+ 2000
+ );
//
// failed to get Sense data
@@ -200,7 +200,6 @@ PeiUsbRequestSense (
}
if (Sense->sense_key != ATA_SK_NO_SENSE) {
-
Ptr += sizeof (ATAPI_REQUEST_SENSE_DATA);
//
// Ptr is byte based pointer
@@ -210,7 +209,6 @@ PeiUsbRequestSense (
if (*SenseCounts == MAXSENSEKEY) {
break;
}
-
} else {
//
// when no sense key, skip out the loop
@@ -240,10 +238,10 @@ PeiUsbReadCapacity (
IN PEI_BOT_DEVICE *PeiBotDevice
)
{
- EFI_STATUS Status;
- ATAPI_PACKET_COMMAND Packet;
- ATAPI_READ_CAPACITY_DATA Data;
- UINT32 LastBlock;
+ EFI_STATUS Status;
+ ATAPI_PACKET_COMMAND Packet;
+ ATAPI_READ_CAPACITY_DATA Data;
+ UINT32 LastBlock;
ZeroMem (&Data, sizeof (ATAPI_READ_CAPACITY_DATA));
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
@@ -254,20 +252,21 @@ PeiUsbReadCapacity (
// send command packet
//
Status = PeiAtapiCommand (
- PeiServices,
- PeiBotDevice,
- &Packet,
- (UINT8) sizeof (ATAPI_PACKET_COMMAND),
- (VOID *) &Data,
- sizeof (ATAPI_READ_CAPACITY_DATA),
- EfiUsbDataIn,
- 2000
- );
+ PeiServices,
+ PeiBotDevice,
+ &Packet,
+ (UINT8)sizeof (ATAPI_PACKET_COMMAND),
+ (VOID *)&Data,
+ sizeof (ATAPI_READ_CAPACITY_DATA),
+ EfiUsbDataIn,
+ 2000
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
- LastBlock = ((UINT32) Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0;
+
+ LastBlock = ((UINT32)Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0;
if (LastBlock == 0xFFFFFFFF) {
DEBUG ((DEBUG_INFO, "The usb device LBA count is larger than 0xFFFFFFFF!\n"));
@@ -300,30 +299,30 @@ PeiUsbReadFormattedCapacity (
IN PEI_BOT_DEVICE *PeiBotDevice
)
{
- EFI_STATUS Status;
- ATAPI_PACKET_COMMAND Packet;
- ATAPI_READ_FORMAT_CAPACITY_DATA FormatData;
- UINT32 LastBlock;
+ EFI_STATUS Status;
+ ATAPI_PACKET_COMMAND Packet;
+ ATAPI_READ_FORMAT_CAPACITY_DATA FormatData;
+ UINT32 LastBlock;
ZeroMem (&FormatData, sizeof (ATAPI_READ_FORMAT_CAPACITY_DATA));
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
- Packet.ReadFormatCapacity.opcode = ATA_CMD_READ_FORMAT_CAPACITY;
- Packet.ReadFormatCapacity.allocation_length_lo = 12;
+ Packet.ReadFormatCapacity.opcode = ATA_CMD_READ_FORMAT_CAPACITY;
+ Packet.ReadFormatCapacity.allocation_length_lo = 12;
//
// send command packet
//
Status = PeiAtapiCommand (
- PeiServices,
- PeiBotDevice,
- &Packet,
- (UINT8) sizeof (ATAPI_PACKET_COMMAND),
- (VOID *) &FormatData,
- sizeof (ATAPI_READ_FORMAT_CAPACITY_DATA),
- EfiUsbDataIn,
- 2000
- );
+ PeiServices,
+ PeiBotDevice,
+ &Packet,
+ (UINT8)sizeof (ATAPI_PACKET_COMMAND),
+ (VOID *)&FormatData,
+ sizeof (ATAPI_READ_FORMAT_CAPACITY_DATA),
+ EfiUsbDataIn,
+ 2000
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
@@ -335,11 +334,10 @@ PeiUsbReadFormattedCapacity (
//
PeiBotDevice->Media.MediaPresent = FALSE;
PeiBotDevice->Media.LastBlock = 0;
- PeiBotDevice->Media2.MediaPresent = FALSE;
- PeiBotDevice->Media2.LastBlock = 0;
-
+ PeiBotDevice->Media2.MediaPresent = FALSE;
+ PeiBotDevice->Media2.LastBlock = 0;
} else {
- LastBlock = ((UINT32) FormatData.LastLba3 << 24) | (FormatData.LastLba2 << 16) | (FormatData.LastLba1 << 8) | FormatData.LastLba0;
+ LastBlock = ((UINT32)FormatData.LastLba3 << 24) | (FormatData.LastLba2 << 16) | (FormatData.LastLba1 << 8) | FormatData.LastLba0;
if (LastBlock == 0xFFFFFFFF) {
DEBUG ((DEBUG_INFO, "The usb device LBA count is larger than 0xFFFFFFFF!\n"));
}
@@ -397,26 +395,23 @@ PeiUsbRead10 (
// prepare command packet for the Inquiry Packet Command.
//
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
- Read10Packet = &Packet.Read10;
- Lba32 = (UINT32) Lba;
- PtrBuffer = Buffer;
+ Read10Packet = &Packet.Read10;
+ Lba32 = (UINT32)Lba;
+ PtrBuffer = Buffer;
- BlockSize = (UINT32) PeiBotDevice->Media.BlockSize;
+ BlockSize = (UINT32)PeiBotDevice->Media.BlockSize;
- MaxBlock = (UINT16) (65535 / BlockSize);
- BlocksRemaining = (UINT16) NumberOfBlocks;
+ MaxBlock = (UINT16)(65535 / BlockSize);
+ BlocksRemaining = (UINT16)NumberOfBlocks;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
while (BlocksRemaining > 0) {
-
if (BlocksRemaining <= MaxBlock) {
-
SectorCount = BlocksRemaining;
-
} else {
-
SectorCount = MaxBlock;
}
+
//
// fill the Packet data structure
//
@@ -426,43 +421,43 @@ PeiUsbRead10 (
// Lba0 ~ Lba3 specify the start logical block address of the data transfer.
// Lba0 is MSB, Lba3 is LSB
//
- Read10Packet->Lba3 = (UINT8) (Lba32 & 0xff);
- Read10Packet->Lba2 = (UINT8) (Lba32 >> 8);
- Read10Packet->Lba1 = (UINT8) (Lba32 >> 16);
- Read10Packet->Lba0 = (UINT8) (Lba32 >> 24);
+ Read10Packet->Lba3 = (UINT8)(Lba32 & 0xff);
+ Read10Packet->Lba2 = (UINT8)(Lba32 >> 8);
+ Read10Packet->Lba1 = (UINT8)(Lba32 >> 16);
+ Read10Packet->Lba0 = (UINT8)(Lba32 >> 24);
//
// TranLen0 ~ TranLen1 specify the transfer length in block unit.
// TranLen0 is MSB, TranLen is LSB
//
- Read10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);
- Read10Packet->TranLen0 = (UINT8) (SectorCount >> 8);
+ Read10Packet->TranLen1 = (UINT8)(SectorCount & 0xff);
+ Read10Packet->TranLen0 = (UINT8)(SectorCount >> 8);
- ByteCount = SectorCount * BlockSize;
+ ByteCount = SectorCount * BlockSize;
- TimeOut = (UINT16) (SectorCount * 2000);
+ TimeOut = (UINT16)(SectorCount * 2000);
//
// send command packet
//
Status = PeiAtapiCommand (
- PeiServices,
- PeiBotDevice,
- &Packet,
- (UINT8) sizeof (ATAPI_PACKET_COMMAND),
- (VOID *) PtrBuffer,
- ByteCount,
- EfiUsbDataIn,
- TimeOut
- );
+ PeiServices,
+ PeiBotDevice,
+ &Packet,
+ (UINT8)sizeof (ATAPI_PACKET_COMMAND),
+ (VOID *)PtrBuffer,
+ ByteCount,
+ EfiUsbDataIn,
+ TimeOut
+ );
if (Status != EFI_SUCCESS) {
return Status;
}
- Lba32 += SectorCount;
- PtrBuffer = (UINT8 *) PtrBuffer + SectorCount * BlockSize;
- BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount);
+ Lba32 += SectorCount;
+ PtrBuffer = (UINT8 *)PtrBuffer + SectorCount * BlockSize;
+ BlocksRemaining = (UINT16)(BlocksRemaining - SectorCount);
}
return Status;
@@ -480,37 +475,36 @@ PeiUsbRead10 (
**/
BOOLEAN
IsNoMedia (
- IN ATAPI_REQUEST_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN ATAPI_REQUEST_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
)
{
ATAPI_REQUEST_SENSE_DATA *SensePtr;
UINTN Index;
BOOLEAN NoMedia;
- NoMedia = FALSE;
- SensePtr = SenseData;
+ NoMedia = FALSE;
+ SensePtr = SenseData;
for (Index = 0; Index < SenseCounts; Index++) {
-
switch (SensePtr->sense_key) {
+ case ATA_SK_NOT_READY:
+ switch (SensePtr->addnl_sense_code) {
+ //
+ // if no media, fill IdeDev parameter with specific info.
+ //
+ case ATA_ASC_NO_MEDIA:
+ NoMedia = TRUE;
+ break;
+
+ default:
+ break;
+ }
- case ATA_SK_NOT_READY:
- switch (SensePtr->addnl_sense_code) {
- //
- // if no media, fill IdeDev parameter with specific info.
- //
- case ATA_ASC_NO_MEDIA:
- NoMedia = TRUE;
break;
default:
break;
- }
- break;
-
- default:
- break;
}
SensePtr++;
@@ -531,63 +525,63 @@ IsNoMedia (
**/
BOOLEAN
IsMediaError (
- IN ATAPI_REQUEST_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN ATAPI_REQUEST_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
)
{
ATAPI_REQUEST_SENSE_DATA *SensePtr;
UINTN Index;
BOOLEAN Error;
- SensePtr = SenseData;
- Error = FALSE;
+ SensePtr = SenseData;
+ Error = FALSE;
for (Index = 0; Index < SenseCounts; Index++) {
-
switch (SensePtr->sense_key) {
- //
- // Medium error case
- //
- case ATA_SK_MEDIUM_ERROR:
- switch (SensePtr->addnl_sense_code) {
- case ATA_ASC_MEDIA_ERR1:
- //
- // fall through
- //
- case ATA_ASC_MEDIA_ERR2:
- //
- // fall through
- //
- case ATA_ASC_MEDIA_ERR3:
- //
- // fall through
- //
- case ATA_ASC_MEDIA_ERR4:
- Error = TRUE;
- break;
+ //
+ // Medium error case
+ //
+ case ATA_SK_MEDIUM_ERROR:
+ switch (SensePtr->addnl_sense_code) {
+ case ATA_ASC_MEDIA_ERR1:
+ //
+ // fall through
+ //
+ case ATA_ASC_MEDIA_ERR2:
+ //
+ // fall through
+ //
+ case ATA_ASC_MEDIA_ERR3:
+ //
+ // fall through
+ //
+ case ATA_ASC_MEDIA_ERR4:
+ Error = TRUE;
+ break;
+
+ default:
+ break;
+ }
- default:
break;
- }
- break;
+ //
+ // Medium upside-down case
+ //
+ case ATA_SK_NOT_READY:
+ switch (SensePtr->addnl_sense_code) {
+ case ATA_ASC_MEDIA_UPSIDE_DOWN:
+ Error = TRUE;
+ break;
+
+ default:
+ break;
+ }
- //
- // Medium upside-down case
- //
- case ATA_SK_NOT_READY:
- switch (SensePtr->addnl_sense_code) {
- case ATA_ASC_MEDIA_UPSIDE_DOWN:
- Error = TRUE;
break;
default:
break;
- }
- break;
-
- default:
- break;
}
SensePtr++;
@@ -608,8 +602,8 @@ IsMediaError (
**/
BOOLEAN
IsMediaChange (
- IN ATAPI_REQUEST_SENSE_DATA *SenseData,
- IN UINTN SenseCounts
+ IN ATAPI_REQUEST_SENSE_DATA *SenseData,
+ IN UINTN SenseCounts
)
{
ATAPI_REQUEST_SENSE_DATA *SensePtr;
@@ -618,26 +612,27 @@ IsMediaChange (
MediaChange = FALSE;
- SensePtr = SenseData;
+ SensePtr = SenseData;
for (Index = 0; Index < SenseCounts; Index++) {
//
// catch media change sense key and addition sense data
//
switch (SensePtr->sense_key) {
- case ATA_SK_UNIT_ATTENTION:
- switch (SensePtr->addnl_sense_code) {
- case ATA_ASC_MEDIA_CHANGE:
- MediaChange = TRUE;
+ case ATA_SK_UNIT_ATTENTION:
+ switch (SensePtr->addnl_sense_code) {
+ case ATA_ASC_MEDIA_CHANGE:
+ MediaChange = TRUE;
+ break;
+
+ default:
+ break;
+ }
+
break;
default:
break;
- }
- break;
-
- default:
- break;
}
SensePtr++;
diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c
index 292682a..dfc4e40 100644
--- a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c
+++ b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "UsbPeim.h"
#include "PeiUsbLib.h"
-
/**
Clear a given usb feature.
@@ -27,11 +26,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
PeiUsbClearDeviceFeature (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN EFI_USB_RECIPIENT Recipient,
- IN UINT16 Value,
- IN UINT16 Target
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN EFI_USB_RECIPIENT Recipient,
+ IN UINT16 Value,
+ IN UINT16 Target
)
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -39,23 +38,23 @@ PeiUsbClearDeviceFeature (
ASSERT (UsbIoPpi != NULL);
switch (Recipient) {
- case EfiUsbDevice:
- DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_D;
- break;
+ case EfiUsbDevice:
+ DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_D;
+ break;
- case EfiUsbInterface:
- DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_I;
- break;
+ case EfiUsbInterface:
+ DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_I;
+ break;
- case EfiUsbEndpoint:
- DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_E;
- break;
+ case EfiUsbEndpoint:
+ DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_E;
+ break;
}
- DevReq.Request = USB_DEV_CLEAR_FEATURE;
- DevReq.Value = Value;
- DevReq.Index = Target;
- DevReq.Length = 0;
+ DevReq.Request = USB_DEV_CLEAR_FEATURE;
+ DevReq.Value = Value;
+ DevReq.Index = Target;
+ DevReq.Length = 0;
return UsbIoPpi->UsbControlTransfer (
PeiServices,
@@ -68,7 +67,6 @@ PeiUsbClearDeviceFeature (
);
}
-
/**
Clear Endpoint Halt.
@@ -83,9 +81,9 @@ PeiUsbClearDeviceFeature (
**/
EFI_STATUS
PeiUsbClearEndpointHalt (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 EndpointAddress
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT8 EndpointAddress
)
{
EFI_STATUS Status;
@@ -93,18 +91,18 @@ PeiUsbClearEndpointHalt (
EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescriptor;
UINT8 EndpointIndex;
-
//
// Check its interface
//
Status = UsbIoPpi->UsbGetInterfaceDescriptor (
- PeiServices,
- UsbIoPpi,
- &InterfaceDesc
- );
+ PeiServices,
+ UsbIoPpi,
+ &InterfaceDesc
+ );
if (EFI_ERROR (Status)) {
return Status;
}
+
for (EndpointIndex = 0; EndpointIndex < InterfaceDesc->NumEndpoints; EndpointIndex++) {
Status = UsbIoPpi->UsbGetEndpointDescriptor (PeiServices, UsbIoPpi, EndpointIndex, &EndpointDescriptor);
if (EFI_ERROR (Status)) {
@@ -121,14 +119,12 @@ PeiUsbClearEndpointHalt (
}
Status = PeiUsbClearDeviceFeature (
- PeiServices,
- UsbIoPpi,
- EfiUsbEndpoint,
- EfiUsbEndpointHalt,
- EndpointAddress
- );
+ PeiServices,
+ UsbIoPpi,
+ EfiUsbEndpoint,
+ EfiUsbEndpointHalt,
+ EndpointAddress
+ );
return Status;
}
-
-
diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.h b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.h
index e06e253..4189461 100644
--- a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.h
+++ b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.h
@@ -13,29 +13,29 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Standard device request and request type
// By [Spec-USB20/Chapter-9.4]
//
-#define USB_DEV_GET_STATUS 0x00
-#define USB_DEV_GET_STATUS_REQ_TYPE_D 0x80 // Receiver : Device
-#define USB_DEV_GET_STATUS_REQ_TYPE_I 0x81 // Receiver : Interface
-#define USB_DEV_GET_STATUS_REQ_TYPE_E 0x82 // Receiver : Endpoint
+#define USB_DEV_GET_STATUS 0x00
+#define USB_DEV_GET_STATUS_REQ_TYPE_D 0x80 // Receiver : Device
+#define USB_DEV_GET_STATUS_REQ_TYPE_I 0x81 // Receiver : Interface
+#define USB_DEV_GET_STATUS_REQ_TYPE_E 0x82 // Receiver : Endpoint
-#define USB_DEV_CLEAR_FEATURE 0x01
-#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device
-#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface
-#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint
+#define USB_DEV_CLEAR_FEATURE 0x01
+#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device
+#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface
+#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint
-#define USB_DEV_SET_FEATURE 0x03
-#define USB_DEV_SET_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device
-#define USB_DEV_SET_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface
-#define USB_DEV_SET_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint
+#define USB_DEV_SET_FEATURE 0x03
+#define USB_DEV_SET_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device
+#define USB_DEV_SET_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface
+#define USB_DEV_SET_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint
-#define USB_DEV_SET_ADDRESS 0x05
-#define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00
+#define USB_DEV_SET_ADDRESS 0x05
+#define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00
-#define USB_DEV_GET_DESCRIPTOR 0x06
-#define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80
+#define USB_DEV_GET_DESCRIPTOR 0x06
+#define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80
-#define USB_DEV_SET_DESCRIPTOR 0x07
-#define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00
+#define USB_DEV_SET_DESCRIPTOR 0x07
+#define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00
#define USB_DEV_GET_CONFIGURATION 0x08
#define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80
@@ -43,14 +43,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define USB_DEV_SET_CONFIGURATION 0x09
#define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00
-#define USB_DEV_GET_INTERFACE 0x0A
-#define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81
+#define USB_DEV_GET_INTERFACE 0x0A
+#define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81
-#define USB_DEV_SET_INTERFACE 0x0B
-#define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01
+#define USB_DEV_SET_INTERFACE 0x0B
+#define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01
-#define USB_DEV_SYNCH_FRAME 0x0C
-#define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82
+#define USB_DEV_SYNCH_FRAME 0x0C
+#define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82
//
// USB Descriptor types
@@ -66,18 +66,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// USB request type
//
-#define USB_TYPE_STANDARD (0x00 << 5)
-#define USB_TYPE_CLASS (0x01 << 5)
-#define USB_TYPE_VENDOR (0x02 << 5)
-#define USB_TYPE_RESERVED (0x03 << 5)
+#define USB_TYPE_STANDARD (0x00 << 5)
+#define USB_TYPE_CLASS (0x01 << 5)
+#define USB_TYPE_VENDOR (0x02 << 5)
+#define USB_TYPE_RESERVED (0x03 << 5)
//
// USB request targer device
//
-#define USB_RECIP_DEVICE 0x00
-#define USB_RECIP_INTERFACE 0x01
-#define USB_RECIP_ENDPOINT 0x02
-#define USB_RECIP_OTHER 0x03
+#define USB_RECIP_DEVICE 0x00
+#define USB_RECIP_INTERFACE 0x01
+#define USB_RECIP_ENDPOINT 0x02
+#define USB_RECIP_OTHER 0x03
typedef enum {
EfiUsbEndpointHalt,
@@ -93,7 +93,6 @@ typedef enum {
EfiUsbEndpoint
} EFI_USB_RECIPIENT;
-
/**
Clear a given usb feature.
@@ -110,14 +109,13 @@ typedef enum {
**/
EFI_STATUS
PeiUsbClearDeviceFeature (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN EFI_USB_RECIPIENT Recipient,
- IN UINT16 Value,
- IN UINT16 Target
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN EFI_USB_RECIPIENT Recipient,
+ IN UINT16 Value,
+ IN UINT16 Target
);
-
/**
Clear Endpoint Halt.
@@ -132,12 +130,9 @@ PeiUsbClearDeviceFeature (
**/
EFI_STATUS
PeiUsbClearEndpointHalt (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 EndpointAddress
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT8 EndpointAddress
);
-
-
-
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPeim.c b/MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPeim.c
index e110626..ef62f44 100644
--- a/MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPeim.c
+++ b/MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPeim.c
@@ -12,26 +12,26 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Global function
//
-EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {
+EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
&gPeiUsbIoPpiGuid,
NotifyOnUsbIoPpi
};
-EFI_PEI_RECOVERY_BLOCK_IO_PPI mRecoveryBlkIoPpi = {
+EFI_PEI_RECOVERY_BLOCK_IO_PPI mRecoveryBlkIoPpi = {
BotGetNumberOfBlockDevices,
BotGetMediaInfo,
BotReadBlocks
};
-EFI_PEI_RECOVERY_BLOCK_IO2_PPI mRecoveryBlkIo2Ppi = {
+EFI_PEI_RECOVERY_BLOCK_IO2_PPI mRecoveryBlkIo2Ppi = {
EFI_PEI_RECOVERY_BLOCK_IO2_PPI_REVISION,
BotGetNumberOfBlockDevices2,
BotGetMediaInfo2,
BotReadBlocks2
};
-EFI_PEI_PPI_DESCRIPTOR mPpiList[2] = {
+EFI_PEI_PPI_DESCRIPTOR mPpiList[2] = {
{
EFI_PEI_PPI_DESCRIPTOR_PPI,
&gEfiPeiVirtualBlockIoPpiGuid,
@@ -57,8 +57,8 @@ EFI_PEI_PPI_DESCRIPTOR mPpiList[2] = {
**/
EFI_STATUS
PeiBotDetectMedia (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_BOT_DEVICE *PeiBotDev
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_BOT_DEVICE *PeiBotDev
);
/**
@@ -74,14 +74,14 @@ PeiBotDetectMedia (
EFI_STATUS
EFIAPI
PeimInitializeUsbBot (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- EFI_STATUS Status;
- UINTN UsbIoPpiInstance;
- EFI_PEI_PPI_DESCRIPTOR *TempPpiDescriptor;
- PEI_USB_IO_PPI *UsbIoPpi;
+ EFI_STATUS Status;
+ UINTN UsbIoPpiInstance;
+ EFI_PEI_PPI_DESCRIPTOR *TempPpiDescriptor;
+ PEI_USB_IO_PPI *UsbIoPpi;
//
// Shadow this PEIM to run from memory
@@ -94,17 +94,17 @@ PeimInitializeUsbBot (
// locate all usb io PPIs
//
for (UsbIoPpiInstance = 0; UsbIoPpiInstance < PEI_FAT_MAX_USB_IO_PPI; UsbIoPpiInstance++) {
-
Status = PeiServicesLocatePpi (
- &gPeiUsbIoPpiGuid,
- UsbIoPpiInstance,
- &TempPpiDescriptor,
- (VOID **) &UsbIoPpi
- );
+ &gPeiUsbIoPpiGuid,
+ UsbIoPpiInstance,
+ &TempPpiDescriptor,
+ (VOID **)&UsbIoPpi
+ );
if (EFI_ERROR (Status)) {
break;
}
}
+
//
// Register a notify function
//
@@ -127,14 +127,14 @@ PeimInitializeUsbBot (
EFI_STATUS
EFIAPI
NotifyOnUsbIoPpi (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
- IN VOID *InvokePpi
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *InvokePpi
)
{
PEI_USB_IO_PPI *UsbIoPpi;
- UsbIoPpi = (PEI_USB_IO_PPI *) InvokePpi;
+ UsbIoPpi = (PEI_USB_IO_PPI *)InvokePpi;
InitUsbBot (PeiServices, UsbIoPpi);
@@ -154,8 +154,8 @@ NotifyOnUsbIoPpi (
**/
EFI_STATUS
InitUsbBot (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi
)
{
PEI_BOT_DEVICE *PeiBotDevice;
@@ -170,45 +170,45 @@ InitUsbBot (
// Check its interface
//
Status = UsbIoPpi->UsbGetInterfaceDescriptor (
- PeiServices,
- UsbIoPpi,
- &InterfaceDesc
- );
+ PeiServices,
+ UsbIoPpi,
+ &InterfaceDesc
+ );
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Check if it is the BOT device we support
//
if ((InterfaceDesc->InterfaceClass != 0x08) || (InterfaceDesc->InterfaceProtocol != 0x50)) {
-
return EFI_NOT_FOUND;
}
MemPages = sizeof (PEI_BOT_DEVICE) / EFI_PAGE_SIZE + 1;
- Status = PeiServicesAllocatePages (
- EfiBootServicesCode,
- MemPages,
- &AllocateAddress
- );
+ Status = PeiServicesAllocatePages (
+ EfiBootServicesCode,
+ MemPages,
+ &AllocateAddress
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- PeiBotDevice = (PEI_BOT_DEVICE *) ((UINTN) AllocateAddress);
+ PeiBotDevice = (PEI_BOT_DEVICE *)((UINTN)AllocateAddress);
PeiBotDevice->Signature = PEI_BOT_DEVICE_SIGNATURE;
PeiBotDevice->UsbIoPpi = UsbIoPpi;
- PeiBotDevice->AllocateAddress = (UINTN) AllocateAddress;
+ PeiBotDevice->AllocateAddress = (UINTN)AllocateAddress;
PeiBotDevice->BotInterface = InterfaceDesc;
//
// Default value
//
- PeiBotDevice->Media.DeviceType = UsbMassStorage;
- PeiBotDevice->Media.BlockSize = 0x200;
- PeiBotDevice->Media2.InterfaceType = MSG_USB_DP;
- PeiBotDevice->Media2.BlockSize = 0x200;
+ PeiBotDevice->Media.DeviceType = UsbMassStorage;
+ PeiBotDevice->Media.BlockSize = 0x200;
+ PeiBotDevice->Media2.InterfaceType = MSG_USB_DP;
+ PeiBotDevice->Media2.BlockSize = 0x200;
PeiBotDevice->Media2.RemovableMedia = FALSE;
PeiBotDevice->Media2.ReadOnly = FALSE;
@@ -217,11 +217,11 @@ InitUsbBot (
//
for (Index = 0; Index < 2; Index++) {
Status = UsbIoPpi->UsbGetEndpointDescriptor (
- PeiServices,
- UsbIoPpi,
- Index,
- &EndpointDesc
- );
+ PeiServices,
+ UsbIoPpi,
+ Index,
+ &EndpointDesc
+ );
if (EFI_ERROR (Status)) {
return Status;
@@ -257,7 +257,7 @@ InitUsbBot (
PeiBotDevice->BlkIoPpiList.Ppi = &PeiBotDevice->BlkIoPpi;
PeiBotDevice->BlkIo2PpiList.Ppi = &PeiBotDevice->BlkIo2Ppi;
- Status = PeiUsbInquiry (PeiServices, PeiBotDevice);
+ Status = PeiUsbInquiry (PeiServices, PeiBotDevice);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -271,7 +271,7 @@ InitUsbBot (
return Status;
}
- PeiBotDevice->SensePtr = (ATAPI_REQUEST_SENSE_DATA *) ((UINTN) AllocateAddress);
+ PeiBotDevice->SensePtr = (ATAPI_REQUEST_SENSE_DATA *)((UINTN)AllocateAddress);
Status = PeiServicesInstallPpi (&PeiBotDevice->BlkIoPpiList);
@@ -304,9 +304,9 @@ InitUsbBot (
EFI_STATUS
EFIAPI
BotGetNumberOfBlockDevices (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
- OUT UINTN *NumberBlockDevices
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
+ OUT UINTN *NumberBlockDevices
)
{
//
@@ -346,10 +346,10 @@ BotGetNumberOfBlockDevices (
EFI_STATUS
EFIAPI
BotGetMediaInfo (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
- IN UINTN DeviceIndex,
- OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
+ IN UINTN DeviceIndex,
+ OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
)
{
PEI_BOT_DEVICE *PeiBotDev;
@@ -366,9 +366,9 @@ BotGetMediaInfo (
);
Status = PeiBotDetectMedia (
- PeiServices,
- PeiBotDev
- );
+ PeiServices,
+ PeiBotDev
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
@@ -420,12 +420,12 @@ BotGetMediaInfo (
EFI_STATUS
EFIAPI
BotReadBlocks (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
- IN UINTN DeviceIndex,
- IN EFI_PEI_LBA StartLBA,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
+ IN UINTN DeviceIndex,
+ IN EFI_PEI_LBA StartLBA,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
)
{
PEI_BOT_DEVICE *PeiBotDev;
@@ -464,19 +464,18 @@ BotReadBlocks (
NumberOfBlocks = BufferSize / (PeiBotDev->Media.BlockSize);
if (Status == EFI_SUCCESS) {
-
Status = PeiUsbTestUnitReady (
- PeiServices,
- PeiBotDev
- );
+ PeiServices,
+ PeiBotDev
+ );
if (Status == EFI_SUCCESS) {
Status = PeiUsbRead10 (
- PeiServices,
- PeiBotDev,
- Buffer,
- StartLBA,
- 1
- );
+ PeiServices,
+ PeiBotDev,
+ Buffer,
+ StartLBA,
+ 1
+ );
}
} else {
//
@@ -494,9 +493,9 @@ BotReadBlocks (
// update the media info accordingly.
//
Status = PeiBotDetectMedia (
- PeiServices,
- PeiBotDev
- );
+ PeiServices,
+ PeiBotDev
+ );
if (Status != EFI_SUCCESS) {
return EFI_DEVICE_ERROR;
}
@@ -520,45 +519,42 @@ BotReadBlocks (
}
Status = PeiUsbRead10 (
- PeiServices,
- PeiBotDev,
- Buffer,
- StartLBA,
- NumberOfBlocks
- );
+ PeiServices,
+ PeiBotDev,
+ Buffer,
+ StartLBA,
+ NumberOfBlocks
+ );
switch (Status) {
+ case EFI_SUCCESS:
+ return EFI_SUCCESS;
- case EFI_SUCCESS:
- return EFI_SUCCESS;
-
- default:
- return EFI_DEVICE_ERROR;
+ default:
+ return EFI_DEVICE_ERROR;
}
} else {
- StartLBA += 1;
+ StartLBA += 1;
NumberOfBlocks -= 1;
- Buffer = (UINT8 *) Buffer + PeiBotDev->Media.BlockSize;
+ Buffer = (UINT8 *)Buffer + PeiBotDev->Media.BlockSize;
if (NumberOfBlocks == 0) {
return EFI_SUCCESS;
}
Status = PeiUsbRead10 (
- PeiServices,
- PeiBotDev,
- Buffer,
- StartLBA,
- NumberOfBlocks
- );
+ PeiServices,
+ PeiBotDev,
+ Buffer,
+ StartLBA,
+ NumberOfBlocks
+ );
switch (Status) {
+ case EFI_SUCCESS:
+ return EFI_SUCCESS;
- case EFI_SUCCESS:
- return EFI_SUCCESS;
-
- default:
- return EFI_DEVICE_ERROR;
-
+ default:
+ return EFI_DEVICE_ERROR;
}
}
}
@@ -585,9 +581,9 @@ BotReadBlocks (
EFI_STATUS
EFIAPI
BotGetNumberOfBlockDevices2 (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
- OUT UINTN *NumberBlockDevices
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
+ OUT UINTN *NumberBlockDevices
)
{
//
@@ -627,10 +623,10 @@ BotGetNumberOfBlockDevices2 (
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
+ 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;
@@ -695,12 +691,12 @@ BotGetMediaInfo2 (
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
+ 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;
@@ -738,25 +734,25 @@ BotReadBlocks2 (
**/
EFI_STATUS
PeiBotDetectMedia (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_BOT_DEVICE *PeiBotDev
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_BOT_DEVICE *PeiBotDev
)
{
- EFI_STATUS Status;
- EFI_STATUS FloppyStatus;
- UINTN SenseCounts;
- BOOLEAN NeedReadCapacity;
- EFI_PHYSICAL_ADDRESS AllocateAddress;
- ATAPI_REQUEST_SENSE_DATA *SensePtr;
- UINTN Retry;
+ EFI_STATUS Status;
+ EFI_STATUS FloppyStatus;
+ UINTN SenseCounts;
+ BOOLEAN NeedReadCapacity;
+ EFI_PHYSICAL_ADDRESS AllocateAddress;
+ ATAPI_REQUEST_SENSE_DATA *SensePtr;
+ UINTN Retry;
//
// if there is no media present,or media not changed,
// the request sense command will detect faster than read capacity command.
// read capacity command can be bypassed, thus improve performance.
//
- SenseCounts = 0;
- NeedReadCapacity = TRUE;
+ SenseCounts = 0;
+ NeedReadCapacity = TRUE;
Status = PeiServicesAllocatePages (
EfiBootServicesCode,
@@ -771,20 +767,20 @@ PeiBotDetectMedia (
ZeroMem (SensePtr, EFI_PAGE_SIZE);
Status = PeiUsbRequestSense (
- PeiServices,
- PeiBotDev,
- &SenseCounts,
- (UINT8 *) SensePtr
- );
+ PeiServices,
+ PeiBotDev,
+ &SenseCounts,
+ (UINT8 *)SensePtr
+ );
if (Status == EFI_SUCCESS) {
//
// No Media
//
if (IsNoMedia (SensePtr, SenseCounts)) {
- NeedReadCapacity = FALSE;
- PeiBotDev->Media.MediaPresent = FALSE;
- PeiBotDev->Media.LastBlock = 0;
+ NeedReadCapacity = FALSE;
+ PeiBotDev->Media.MediaPresent = FALSE;
+ PeiBotDev->Media.LastBlock = 0;
PeiBotDev->Media2.MediaPresent = FALSE;
PeiBotDev->Media2.LastBlock = 0;
} else {
@@ -795,6 +791,7 @@ PeiBotDetectMedia (
PeiBotDev->Media.MediaPresent = TRUE;
PeiBotDev->Media2.MediaPresent = TRUE;
}
+
//
// Media Error
//
@@ -802,14 +799,12 @@ PeiBotDetectMedia (
//
// if media error encountered, make it look like no media present.
//
- PeiBotDev->Media.MediaPresent = FALSE;
- PeiBotDev->Media.LastBlock = 0;
+ PeiBotDev->Media.MediaPresent = FALSE;
+ PeiBotDev->Media.LastBlock = 0;
PeiBotDev->Media2.MediaPresent = FALSE;
PeiBotDev->Media2.LastBlock = 0;
}
-
}
-
}
if (NeedReadCapacity) {
@@ -818,43 +813,46 @@ PeiBotDetectMedia (
//
for (Retry = 0; Retry < 4; Retry++) {
switch (PeiBotDev->DeviceType) {
- case USBCDROM:
- Status = PeiUsbReadCapacity (
- PeiServices,
- PeiBotDev
- );
- break;
-
- case USBFLOPPY2:
- Status = PeiUsbReadFormattedCapacity (
- PeiServices,
- PeiBotDev
- );
- if (EFI_ERROR(Status)||
- !PeiBotDev->Media.MediaPresent) {
- //
- // retry the ReadCapacity command
- //
- PeiBotDev->DeviceType = USBFLOPPY;
- Status = EFI_DEVICE_ERROR;
- }
- break;
-
- case USBFLOPPY:
- Status = PeiUsbReadCapacity (
- PeiServices,
- PeiBotDev
- );
- if (EFI_ERROR (Status)) {
- //
- // retry the ReadFormatCapacity command
- //
- PeiBotDev->DeviceType = USBFLOPPY2;
- }
- break;
-
- default:
- return EFI_INVALID_PARAMETER;
+ case USBCDROM:
+ Status = PeiUsbReadCapacity (
+ PeiServices,
+ PeiBotDev
+ );
+ break;
+
+ case USBFLOPPY2:
+ Status = PeiUsbReadFormattedCapacity (
+ PeiServices,
+ PeiBotDev
+ );
+ if (EFI_ERROR (Status) ||
+ !PeiBotDev->Media.MediaPresent)
+ {
+ //
+ // retry the ReadCapacity command
+ //
+ PeiBotDev->DeviceType = USBFLOPPY;
+ Status = EFI_DEVICE_ERROR;
+ }
+
+ break;
+
+ case USBFLOPPY:
+ Status = PeiUsbReadCapacity (
+ PeiServices,
+ PeiBotDev
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // retry the ReadFormatCapacity command
+ //
+ PeiBotDev->DeviceType = USBFLOPPY2;
+ }
+
+ break;
+
+ default:
+ return EFI_INVALID_PARAMETER;
}
SenseCounts = 0;
@@ -865,11 +863,11 @@ PeiBotDetectMedia (
}
FloppyStatus = PeiUsbRequestSense (
- PeiServices,
- PeiBotDev,
- &SenseCounts,
- (UINT8 *) SensePtr
- );
+ PeiServices,
+ PeiBotDev,
+ &SenseCounts,
+ (UINT8 *)SensePtr
+ );
//
// If Request Sense data failed,retry.
@@ -877,12 +875,13 @@ PeiBotDetectMedia (
if (EFI_ERROR (FloppyStatus)) {
continue;
}
+
//
// No Media
//
if (IsNoMedia (SensePtr, SenseCounts)) {
- PeiBotDev->Media.MediaPresent = FALSE;
- PeiBotDev->Media.LastBlock = 0;
+ PeiBotDev->Media.MediaPresent = FALSE;
+ PeiBotDev->Media.LastBlock = 0;
PeiBotDev->Media2.MediaPresent = FALSE;
PeiBotDev->Media2.LastBlock = 0;
break;
@@ -892,13 +891,14 @@ PeiBotDetectMedia (
//
// if media error encountered, make it look like no media present.
//
- PeiBotDev->Media.MediaPresent = FALSE;
- PeiBotDev->Media.LastBlock = 0;
+ PeiBotDev->Media.MediaPresent = FALSE;
+ PeiBotDev->Media.LastBlock = 0;
PeiBotDev->Media2.MediaPresent = FALSE;
PeiBotDev->Media2.LastBlock = 0;
break;
}
}
+
//
// ENDFOR
//
diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPeim.h b/MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPeim.h
index 81ca4a2..1819784 100644
--- a/MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPeim.h
+++ b/MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPeim.h
@@ -46,9 +46,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_STATUS
EFIAPI
BotGetNumberOfBlockDevices (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
- OUT UINTN *NumberBlockDevices
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
+ OUT UINTN *NumberBlockDevices
);
/**
@@ -81,10 +81,10 @@ BotGetNumberOfBlockDevices (
EFI_STATUS
EFIAPI
BotGetMediaInfo (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
- IN UINTN DeviceIndex,
- OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
+ IN UINTN DeviceIndex,
+ OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
);
/**
@@ -124,12 +124,12 @@ BotGetMediaInfo (
EFI_STATUS
EFIAPI
BotReadBlocks (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
- IN UINTN DeviceIndex,
- IN EFI_PEI_LBA StartLBA,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
+ IN UINTN DeviceIndex,
+ IN EFI_PEI_LBA StartLBA,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
);
/**
@@ -154,9 +154,9 @@ BotReadBlocks (
EFI_STATUS
EFIAPI
BotGetNumberOfBlockDevices2 (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
- OUT UINTN *NumberBlockDevices
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
+ OUT UINTN *NumberBlockDevices
);
/**
@@ -189,10 +189,10 @@ BotGetNumberOfBlockDevices2 (
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
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
+ IN UINTN DeviceIndex,
+ OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo
);
/**
@@ -232,12 +232,12 @@ BotGetMediaInfo2 (
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
+ 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
);
/**
@@ -256,9 +256,9 @@ BotReadBlocks2 (
EFI_STATUS
EFIAPI
NotifyOnUsbIoPpi (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
- IN VOID *InvokePpi
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *InvokePpi
);
/**
@@ -274,11 +274,11 @@ NotifyOnUsbIoPpi (
**/
EFI_STATUS
InitUsbBot (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi
);
-#define USBCDROM 1 // let the device type value equal to USBCDROM, which is defined by PI spec.
+#define USBCDROM 1 // let the device type value equal to USBCDROM, which is defined by PI spec.
// Therefore the CdExpressPei module can do recovery on UsbCdrom.
#define USBFLOPPY 2 // for those that use ReadCapacity(0x25) command to retrieve media capacity
#define USBFLOPPY2 3 // for those that use ReadFormatCapacity(0x23) command to retrieve media capacity
@@ -288,24 +288,24 @@ InitUsbBot (
//
#define PEI_BOT_DEVICE_SIGNATURE SIGNATURE_32 ('U', 'B', 'O', 'T')
typedef struct {
- UINTN Signature;
- EFI_PEI_RECOVERY_BLOCK_IO_PPI BlkIoPpi;
- EFI_PEI_RECOVERY_BLOCK_IO2_PPI BlkIo2Ppi;
- EFI_PEI_PPI_DESCRIPTOR BlkIoPpiList;
- EFI_PEI_PPI_DESCRIPTOR BlkIo2PpiList;
- EFI_PEI_BLOCK_IO_MEDIA Media;
- EFI_PEI_BLOCK_IO2_MEDIA Media2;
- PEI_USB_IO_PPI *UsbIoPpi;
- EFI_USB_INTERFACE_DESCRIPTOR *BotInterface;
- EFI_USB_ENDPOINT_DESCRIPTOR *BulkInEndpoint;
- EFI_USB_ENDPOINT_DESCRIPTOR *BulkOutEndpoint;
- UINTN AllocateAddress;
- UINTN DeviceType;
- ATAPI_REQUEST_SENSE_DATA *SensePtr;
+ UINTN Signature;
+ EFI_PEI_RECOVERY_BLOCK_IO_PPI BlkIoPpi;
+ EFI_PEI_RECOVERY_BLOCK_IO2_PPI BlkIo2Ppi;
+ EFI_PEI_PPI_DESCRIPTOR BlkIoPpiList;
+ EFI_PEI_PPI_DESCRIPTOR BlkIo2PpiList;
+ EFI_PEI_BLOCK_IO_MEDIA Media;
+ EFI_PEI_BLOCK_IO2_MEDIA Media2;
+ PEI_USB_IO_PPI *UsbIoPpi;
+ EFI_USB_INTERFACE_DESCRIPTOR *BotInterface;
+ EFI_USB_ENDPOINT_DESCRIPTOR *BulkInEndpoint;
+ EFI_USB_ENDPOINT_DESCRIPTOR *BulkOutEndpoint;
+ UINTN AllocateAddress;
+ UINTN DeviceType;
+ ATAPI_REQUEST_SENSE_DATA *SensePtr;
} PEI_BOT_DEVICE;
-#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)
+#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.
@@ -326,14 +326,14 @@ typedef struct {
**/
EFI_STATUS
PeiAtapiCommand (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_BOT_DEVICE *PeiBotDev,
- IN VOID *Command,
- IN UINT8 CommandSize,
- IN VOID *DataBuffer,
- IN UINT32 BufferLength,
- IN EFI_USB_DATA_DIRECTION Direction,
- IN UINT16 TimeOutInMilliSeconds
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_BOT_DEVICE *PeiBotDev,
+ IN VOID *Command,
+ IN UINT8 CommandSize,
+ IN VOID *DataBuffer,
+ IN UINT32 BufferLength,
+ IN EFI_USB_DATA_DIRECTION Direction,
+ IN UINT16 TimeOutInMilliSeconds
);
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/UsbPeim.h b/MdeModulePkg/Bus/Usb/UsbBotPei/UsbPeim.h
index cb93d72..225b6cb 100644
--- a/MdeModulePkg/Bus/Usb/UsbBotPei/UsbPeim.h
+++ b/MdeModulePkg/Bus/Usb/UsbBotPei/UsbPeim.h
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _PEI_USB_PEIM_H_
#define _PEI_USB_PEIM_H_
-
#include <PiPei.h>
#include <Ppi/UsbIo.h>
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/ComponentName.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/ComponentName.c
index 642f936..c644b42 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/ComponentName.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/ComponentName.c
@@ -7,13 +7,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include <Uefi.h>
-
#include <Library/UefiLib.h>
-
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -61,7 +58,6 @@ UsbBusComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -133,14 +129,13 @@ UsbBusComponentNameGetDriverName (
EFI_STATUS
EFIAPI
UsbBusComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
-
//
// EFI Component Name Protocol
//
@@ -153,16 +148,15 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL mUsbBusComponentName
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL mUsbBusComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UsbBusComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UsbBusComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL mUsbBusComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)UsbBusComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)UsbBusComponentNameGetControllerName,
"en"
};
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbBusDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbBusDriverNameTable[] = {
{ "eng;en", L"Usb Bus Driver" },
- { NULL , NULL }
+ { NULL, NULL }
};
/**
@@ -292,11 +286,11 @@ UsbBusComponentNameGetDriverName (
EFI_STATUS
EFIAPI
UsbBusComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
index 7e48a28..6a3ac63 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
@@ -9,7 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "UsbBus.h"
-EFI_USB_IO_PROTOCOL mUsbIoProtocol = {
+EFI_USB_IO_PROTOCOL mUsbIoProtocol = {
UsbIoControlTransfer,
UsbIoBulkTransfer,
UsbIoAsyncInterruptTransfer,
@@ -25,7 +25,7 @@ EFI_USB_IO_PROTOCOL mUsbIoProtocol = {
UsbIoPortReset
};
-EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding = {
UsbBusControllerDriverSupported,
UsbBusControllerDriverStart,
UsbBusControllerDriverStop,
@@ -65,12 +65,12 @@ UsbIoControlTransfer (
OUT UINT32 *UsbStatus
)
{
- USB_DEVICE *Dev;
- USB_INTERFACE *UsbIf;
- USB_ENDPOINT_DESC *EpDesc;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
- UINTN RequestedDataLength;
+ USB_DEVICE *Dev;
+ USB_INTERFACE *UsbIf;
+ USB_ENDPOINT_DESC *EpDesc;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ UINTN RequestedDataLength;
if (UsbStatus == NULL) {
return EFI_INVALID_PARAMETER;
@@ -78,23 +78,23 @@ UsbIoControlTransfer (
OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
- UsbIf = USB_INTERFACE_FROM_USBIO (This);
- Dev = UsbIf->Device;
+ UsbIf = USB_INTERFACE_FROM_USBIO (This);
+ Dev = UsbIf->Device;
RequestedDataLength = DataLength;
- Status = UsbHcControlTransfer (
- Dev->Bus,
- Dev->Address,
- Dev->Speed,
- Dev->MaxPacket0,
- Request,
- Direction,
- Data,
- &DataLength,
- (UINTN) Timeout,
- &Dev->Translator,
- UsbStatus
- );
+ Status = UsbHcControlTransfer (
+ Dev->Bus,
+ Dev->Address,
+ Dev->Speed,
+ Dev->MaxPacket0,
+ Request,
+ Direction,
+ Data,
+ &DataLength,
+ (UINTN)Timeout,
+ &Dev->Translator,
+ UsbStatus
+ );
//
// If the request completed successfully and the Direction of the request is
// EfiUsbDataIn or EfiUsbDataOut, then make sure the actual number of bytes
@@ -102,7 +102,7 @@ UsbIoControlTransfer (
// number of bytes were transferred, then return EFI_DEVICE_ERROR.
//
if (!EFI_ERROR (Status)) {
- if (Direction != EfiUsbNoData && DataLength != RequestedDataLength) {
+ if ((Direction != EfiUsbNoData) && (DataLength != RequestedDataLength)) {
Status = EFI_DEVICE_ERROR;
goto ON_EXIT;
}
@@ -139,11 +139,14 @@ UsbIoControlTransfer (
// Reset the endpoint toggle when endpoint stall is cleared
//
if ((Request->Request == USB_REQ_CLEAR_FEATURE) &&
- (Request->RequestType == USB_REQUEST_TYPE (EfiUsbNoData, USB_REQ_TYPE_STANDARD,
- USB_TARGET_ENDPOINT)) &&
- (Request->Value == USB_FEATURE_ENDPOINT_HALT)) {
-
- EpDesc = UsbGetEndpointDesc (UsbIf, (UINT8) Request->Index);
+ (Request->RequestType == USB_REQUEST_TYPE (
+ EfiUsbNoData,
+ USB_REQ_TYPE_STANDARD,
+ USB_TARGET_ENDPOINT
+ )) &&
+ (Request->Value == USB_FEATURE_ENDPOINT_HALT))
+ {
+ EpDesc = UsbGetEndpointDesc (UsbIf, (UINT8)Request->Index);
if (EpDesc != NULL) {
EpDesc->Toggle = 0;
@@ -158,16 +161,21 @@ UsbIoControlTransfer (
// completely irrelevant.
//
if ((Request->Request == USB_REQ_SET_CONFIG) &&
- (Request->RequestType == USB_REQUEST_TYPE (EfiUsbNoData, USB_REQ_TYPE_STANDARD,
- USB_TARGET_DEVICE))) {
+ (Request->RequestType == USB_REQUEST_TYPE (
+ EfiUsbNoData,
+ USB_REQ_TYPE_STANDARD,
+ USB_TARGET_DEVICE
+ )))
+ {
//
// Don't re-create the USB interfaces if configuration isn't changed.
//
if ((Dev->ActiveConfig != NULL) &&
- (Request->Value == Dev->ActiveConfig->Desc.ConfigurationValue)) {
-
+ (Request->Value == Dev->ActiveConfig->Desc.ConfigurationValue))
+ {
goto ON_EXIT;
}
+
DEBUG ((DEBUG_INFO, "UsbIoControlTransfer: configure changed!!! Do NOT use old UsbIo!!!\n"));
if (Dev->ActiveConfig != NULL) {
@@ -175,7 +183,7 @@ UsbIoControlTransfer (
}
if (Request->Value != 0) {
- Status = UsbSelectConfig (Dev, (UINT8) Request->Value);
+ Status = UsbSelectConfig (Dev, (UINT8)Request->Value);
}
//
@@ -191,11 +199,14 @@ UsbIoControlTransfer (
// should remains the same.
//
if ((Request->Request == USB_REQ_SET_INTERFACE) &&
- (Request->RequestType == USB_REQUEST_TYPE (EfiUsbNoData, USB_REQ_TYPE_STANDARD,
- USB_TARGET_INTERFACE)) &&
- (Request->Index == UsbIf->IfSetting->Desc.InterfaceNumber)) {
-
- Status = UsbSelectSetting (UsbIf->IfDesc, (UINT8) Request->Value);
+ (Request->RequestType == USB_REQUEST_TYPE (
+ EfiUsbNoData,
+ USB_REQ_TYPE_STANDARD,
+ USB_TARGET_INTERFACE
+ )) &&
+ (Request->Index == UsbIf->IfSetting->Desc.InterfaceNumber))
+ {
+ Status = UsbSelectSetting (UsbIf->IfDesc, (UINT8)Request->Value);
if (!EFI_ERROR (Status)) {
ASSERT (UsbIf->IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);
@@ -208,7 +219,6 @@ ON_EXIT:
return Status;
}
-
/**
Execute a bulk transfer to the device endpoint.
@@ -228,56 +238,56 @@ ON_EXIT:
EFI_STATUS
EFIAPI
UsbIoBulkTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 Endpoint,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINTN Timeout,
- OUT UINT32 *UsbStatus
+ IN EFI_USB_IO_PROTOCOL *This,
+ IN UINT8 Endpoint,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN UINTN Timeout,
+ OUT UINT32 *UsbStatus
)
{
- USB_DEVICE *Dev;
- USB_INTERFACE *UsbIf;
- USB_ENDPOINT_DESC *EpDesc;
- UINT8 BufNum;
- UINT8 Toggle;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
-
- if ((USB_ENDPOINT_ADDR (Endpoint) == 0) || (USB_ENDPOINT_ADDR(Endpoint) > 15) ||
- (UsbStatus == NULL)) {
-
+ USB_DEVICE *Dev;
+ USB_INTERFACE *UsbIf;
+ USB_ENDPOINT_DESC *EpDesc;
+ UINT8 BufNum;
+ UINT8 Toggle;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+
+ if ((USB_ENDPOINT_ADDR (Endpoint) == 0) || (USB_ENDPOINT_ADDR (Endpoint) > 15) ||
+ (UsbStatus == NULL))
+ {
return EFI_INVALID_PARAMETER;
}
- OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
+ OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
- UsbIf = USB_INTERFACE_FROM_USBIO (This);
- Dev = UsbIf->Device;
+ UsbIf = USB_INTERFACE_FROM_USBIO (This);
+ Dev = UsbIf->Device;
- EpDesc = UsbGetEndpointDesc (UsbIf, Endpoint);
+ EpDesc = UsbGetEndpointDesc (UsbIf, Endpoint);
if ((EpDesc == NULL) || (USB_ENDPOINT_TYPE (&EpDesc->Desc) != USB_ENDPOINT_BULK)) {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
- BufNum = 1;
- Toggle = EpDesc->Toggle;
- Status = UsbHcBulkTransfer (
- Dev->Bus,
- Dev->Address,
- Endpoint,
- Dev->Speed,
- EpDesc->Desc.MaxPacketSize,
- BufNum,
- &Data,
- DataLength,
- &Toggle,
- Timeout,
- &Dev->Translator,
- UsbStatus
- );
+ BufNum = 1;
+ Toggle = EpDesc->Toggle;
+ Status = UsbHcBulkTransfer (
+ Dev->Bus,
+ Dev->Address,
+ Endpoint,
+ Dev->Speed,
+ EpDesc->Desc.MaxPacketSize,
+ BufNum,
+ &Data,
+ DataLength,
+ &Toggle,
+ Timeout,
+ &Dev->Translator,
+ UsbStatus
+ );
EpDesc->Toggle = Toggle;
@@ -303,7 +313,6 @@ ON_EXIT:
return Status;
}
-
/**
Execute a synchronous interrupt transfer.
@@ -323,33 +332,33 @@ ON_EXIT:
EFI_STATUS
EFIAPI
UsbIoSyncInterruptTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 Endpoint,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINTN Timeout,
- OUT UINT32 *UsbStatus
+ IN EFI_USB_IO_PROTOCOL *This,
+ IN UINT8 Endpoint,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN UINTN Timeout,
+ OUT UINT32 *UsbStatus
)
{
- USB_DEVICE *Dev;
- USB_INTERFACE *UsbIf;
- USB_ENDPOINT_DESC *EpDesc;
- EFI_TPL OldTpl;
- UINT8 Toggle;
- EFI_STATUS Status;
-
- if ((USB_ENDPOINT_ADDR (Endpoint) == 0) || (USB_ENDPOINT_ADDR(Endpoint) > 15) ||
- (UsbStatus == NULL)) {
-
+ USB_DEVICE *Dev;
+ USB_INTERFACE *UsbIf;
+ USB_ENDPOINT_DESC *EpDesc;
+ EFI_TPL OldTpl;
+ UINT8 Toggle;
+ EFI_STATUS Status;
+
+ if ((USB_ENDPOINT_ADDR (Endpoint) == 0) || (USB_ENDPOINT_ADDR (Endpoint) > 15) ||
+ (UsbStatus == NULL))
+ {
return EFI_INVALID_PARAMETER;
}
- OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
+ OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
- UsbIf = USB_INTERFACE_FROM_USBIO (This);
- Dev = UsbIf->Device;
+ UsbIf = USB_INTERFACE_FROM_USBIO (This);
+ Dev = UsbIf->Device;
- EpDesc = UsbGetEndpointDesc (UsbIf, Endpoint);
+ EpDesc = UsbGetEndpointDesc (UsbIf, Endpoint);
if ((EpDesc == NULL) || (USB_ENDPOINT_TYPE (&EpDesc->Desc) != USB_ENDPOINT_INTERRUPT)) {
Status = EFI_INVALID_PARAMETER;
@@ -378,7 +387,6 @@ ON_EXIT:
return Status;
}
-
/**
Queue a new asynchronous interrupt transfer, or remove the old
request if (IsNewTransfer == FALSE).
@@ -411,43 +419,43 @@ UsbIoAsyncInterruptTransfer (
IN VOID *Context OPTIONAL
)
{
- USB_DEVICE *Dev;
- USB_INTERFACE *UsbIf;
- USB_ENDPOINT_DESC *EpDesc;
- EFI_TPL OldTpl;
- UINT8 Toggle;
- EFI_STATUS Status;
+ USB_DEVICE *Dev;
+ USB_INTERFACE *UsbIf;
+ USB_ENDPOINT_DESC *EpDesc;
+ EFI_TPL OldTpl;
+ UINT8 Toggle;
+ EFI_STATUS Status;
if ((USB_ENDPOINT_ADDR (Endpoint) == 0) || (USB_ENDPOINT_ADDR (Endpoint) > 15)) {
return EFI_INVALID_PARAMETER;
}
- OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
- UsbIf = USB_INTERFACE_FROM_USBIO (This);
- Dev = UsbIf->Device;
+ OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
+ UsbIf = USB_INTERFACE_FROM_USBIO (This);
+ Dev = UsbIf->Device;
- EpDesc = UsbGetEndpointDesc (UsbIf, Endpoint);
+ EpDesc = UsbGetEndpointDesc (UsbIf, Endpoint);
if ((EpDesc == NULL) || (USB_ENDPOINT_TYPE (&EpDesc->Desc) != USB_ENDPOINT_INTERRUPT)) {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
- Toggle = EpDesc->Toggle;
- Status = UsbHcAsyncInterruptTransfer (
- Dev->Bus,
- Dev->Address,
- Endpoint,
- Dev->Speed,
- EpDesc->Desc.MaxPacketSize,
- IsNewTransfer,
- &Toggle,
- PollInterval,
- DataLength,
- &Dev->Translator,
- Callback,
- Context
- );
+ Toggle = EpDesc->Toggle;
+ Status = UsbHcAsyncInterruptTransfer (
+ Dev->Bus,
+ Dev->Address,
+ Endpoint,
+ Dev->Speed,
+ EpDesc->Desc.MaxPacketSize,
+ IsNewTransfer,
+ &Toggle,
+ PollInterval,
+ DataLength,
+ &Dev->Translator,
+ Callback,
+ Context
+ );
EpDesc->Toggle = Toggle;
@@ -456,7 +464,6 @@ ON_EXIT:
return Status;
}
-
/**
Execute a synchronous isochronous transfer.
@@ -472,17 +479,16 @@ ON_EXIT:
EFI_STATUS
EFIAPI
UsbIoIsochronousTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 DeviceEndpoint,
- IN OUT VOID *Data,
- IN UINTN DataLength,
- OUT UINT32 *Status
+ IN EFI_USB_IO_PROTOCOL *This,
+ IN UINT8 DeviceEndpoint,
+ IN OUT VOID *Data,
+ IN UINTN DataLength,
+ OUT UINT32 *Status
)
{
return EFI_UNSUPPORTED;
}
-
/**
Queue an asynchronous isochronous transfer.
@@ -511,7 +517,6 @@ UsbIoAsyncIsochronousTransfer (
return EFI_UNSUPPORTED;
}
-
/**
Retrieve the device descriptor of the device.
@@ -525,13 +530,13 @@ UsbIoAsyncIsochronousTransfer (
EFI_STATUS
EFIAPI
UsbIoGetDeviceDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT EFI_USB_DEVICE_DESCRIPTOR *Descriptor
+ IN EFI_USB_IO_PROTOCOL *This,
+ OUT EFI_USB_DEVICE_DESCRIPTOR *Descriptor
)
{
- USB_DEVICE *Dev;
- USB_INTERFACE *UsbIf;
- EFI_TPL OldTpl;
+ USB_DEVICE *Dev;
+ USB_INTERFACE *UsbIf;
+ EFI_TPL OldTpl;
if (Descriptor == NULL) {
return EFI_INVALID_PARAMETER;
@@ -539,8 +544,8 @@ UsbIoGetDeviceDescriptor (
OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
- UsbIf = USB_INTERFACE_FROM_USBIO (This);
- Dev = UsbIf->Device;
+ UsbIf = USB_INTERFACE_FROM_USBIO (This);
+ Dev = UsbIf->Device;
CopyMem (Descriptor, &Dev->DevDesc->Desc, sizeof (EFI_USB_DEVICE_DESCRIPTOR));
@@ -548,7 +553,6 @@ UsbIoGetDeviceDescriptor (
return EFI_SUCCESS;
}
-
/**
Return the configuration descriptor of the current active configuration.
@@ -563,14 +567,14 @@ UsbIoGetDeviceDescriptor (
EFI_STATUS
EFIAPI
UsbIoGetActiveConfigDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT EFI_USB_CONFIG_DESCRIPTOR *Descriptor
+ IN EFI_USB_IO_PROTOCOL *This,
+ OUT EFI_USB_CONFIG_DESCRIPTOR *Descriptor
)
{
- USB_DEVICE *Dev;
- USB_INTERFACE *UsbIf;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ USB_DEVICE *Dev;
+ USB_INTERFACE *UsbIf;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
if (Descriptor == NULL) {
return EFI_INVALID_PARAMETER;
@@ -579,8 +583,8 @@ UsbIoGetActiveConfigDescriptor (
Status = EFI_SUCCESS;
OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
- UsbIf = USB_INTERFACE_FROM_USBIO (This);
- Dev = UsbIf->Device;
+ UsbIf = USB_INTERFACE_FROM_USBIO (This);
+ Dev = UsbIf->Device;
if (Dev->ActiveConfig == NULL) {
Status = EFI_NOT_FOUND;
@@ -594,7 +598,6 @@ ON_EXIT:
return Status;
}
-
/**
Retrieve the active interface setting descriptor for this USB IO instance.
@@ -612,8 +615,8 @@ UsbIoGetInterfaceDescriptor (
OUT EFI_USB_INTERFACE_DESCRIPTOR *Descriptor
)
{
- USB_INTERFACE *UsbIf;
- EFI_TPL OldTpl;
+ USB_INTERFACE *UsbIf;
+ EFI_TPL OldTpl;
if (Descriptor == NULL) {
return EFI_INVALID_PARAMETER;
@@ -621,14 +624,13 @@ UsbIoGetInterfaceDescriptor (
OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
- UsbIf = USB_INTERFACE_FROM_USBIO (This);
+ UsbIf = USB_INTERFACE_FROM_USBIO (This);
CopyMem (Descriptor, &(UsbIf->IfSetting->Desc), sizeof (EFI_USB_INTERFACE_DESCRIPTOR));
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
-
/**
Retrieve the endpoint descriptor from this interface setting.
@@ -644,17 +646,17 @@ UsbIoGetInterfaceDescriptor (
EFI_STATUS
EFIAPI
UsbIoGetEndpointDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 Index,
- OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor
+ IN EFI_USB_IO_PROTOCOL *This,
+ IN UINT8 Index,
+ OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor
)
{
- USB_INTERFACE *UsbIf;
- EFI_TPL OldTpl;
+ USB_INTERFACE *UsbIf;
+ EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
- UsbIf = USB_INTERFACE_FROM_USBIO (This);
+ UsbIf = USB_INTERFACE_FROM_USBIO (This);
if ((Descriptor == NULL) || (Index > 15)) {
gBS->RestoreTPL (OldTpl);
@@ -676,7 +678,6 @@ UsbIoGetEndpointDescriptor (
return EFI_SUCCESS;
}
-
/**
Retrieve the supported language ID table from the device.
@@ -690,28 +691,27 @@ UsbIoGetEndpointDescriptor (
EFI_STATUS
EFIAPI
UsbIoGetSupportedLanguages (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT UINT16 **LangIDTable,
- OUT UINT16 *TableSize
+ IN EFI_USB_IO_PROTOCOL *This,
+ OUT UINT16 **LangIDTable,
+ OUT UINT16 *TableSize
)
{
- USB_DEVICE *Dev;
- USB_INTERFACE *UsbIf;
- EFI_TPL OldTpl;
+ USB_DEVICE *Dev;
+ USB_INTERFACE *UsbIf;
+ EFI_TPL OldTpl;
- OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
+ OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
- UsbIf = USB_INTERFACE_FROM_USBIO (This);
- Dev = UsbIf->Device;
+ UsbIf = USB_INTERFACE_FROM_USBIO (This);
+ Dev = UsbIf->Device;
- *LangIDTable = Dev->LangId;
- *TableSize = (UINT16) (Dev->TotalLangId * sizeof (UINT16));
+ *LangIDTable = Dev->LangId;
+ *TableSize = (UINT16)(Dev->TotalLangId * sizeof (UINT16));
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
-
/**
Retrieve an indexed string in the language of LangID.
@@ -727,19 +727,19 @@ UsbIoGetSupportedLanguages (
EFI_STATUS
EFIAPI
UsbIoGetStringDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT16 LangID,
- IN UINT8 StringIndex,
- OUT CHAR16 **String
+ IN EFI_USB_IO_PROTOCOL *This,
+ IN UINT16 LangID,
+ IN UINT8 StringIndex,
+ OUT CHAR16 **String
)
{
- USB_DEVICE *Dev;
- USB_INTERFACE *UsbIf;
- EFI_USB_STRING_DESCRIPTOR *StrDesc;
- EFI_TPL OldTpl;
- UINT8 *Buf;
- UINT8 Index;
- EFI_STATUS Status;
+ USB_DEVICE *Dev;
+ USB_INTERFACE *UsbIf;
+ EFI_USB_STRING_DESCRIPTOR *StrDesc;
+ EFI_TPL OldTpl;
+ UINT8 *Buf;
+ UINT8 Index;
+ EFI_STATUS Status;
if ((StringIndex == 0) || (LangID == 0)) {
return EFI_NOT_FOUND;
@@ -747,8 +747,8 @@ UsbIoGetStringDescriptor (
OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
- UsbIf = USB_INTERFACE_FROM_USBIO (This);
- Dev = UsbIf->Device;
+ UsbIf = USB_INTERFACE_FROM_USBIO (This);
+ Dev = UsbIf->Device;
//
// Check whether language ID is supported
@@ -788,7 +788,7 @@ UsbIoGetStringDescriptor (
}
CopyMem (Buf, StrDesc->String, StrDesc->Length - 2);
- *String = (CHAR16 *) Buf;
+ *String = (CHAR16 *)Buf;
Status = EFI_SUCCESS;
FREE_STR:
@@ -799,7 +799,6 @@ ON_EXIT:
return Status;
}
-
/**
Reset the device, then if that succeeds, reconfigure the
device with its address and current active configuration.
@@ -816,17 +815,17 @@ UsbIoPortReset (
IN EFI_USB_IO_PROTOCOL *This
)
{
- USB_INTERFACE *UsbIf;
- USB_INTERFACE *HubIf;
- USB_DEVICE *Dev;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
- UINT8 DevAddress;
+ USB_INTERFACE *UsbIf;
+ USB_INTERFACE *HubIf;
+ USB_DEVICE *Dev;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ UINT8 DevAddress;
OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
- UsbIf = USB_INTERFACE_FROM_USBIO (This);
- Dev = UsbIf->Device;
+ UsbIf = USB_INTERFACE_FROM_USBIO (This);
+ Dev = UsbIf->Device;
if (UsbIf->IsHub) {
Status = EFI_INVALID_PARAMETER;
@@ -837,8 +836,13 @@ UsbIoPortReset (
Status = HubIf->HubApi->ResetPort (HubIf, Dev->ParentPort);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "UsbIoPortReset: failed to reset hub port %d@hub %d, %r \n",
- Dev->ParentPort, Dev->ParentAddr, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "UsbIoPortReset: failed to reset hub port %d@hub %d, %r \n",
+ Dev->ParentPort,
+ Dev->ParentAddr,
+ Status
+ ));
goto ON_EXIT;
}
@@ -852,7 +856,7 @@ UsbIoPortReset (
//
DevAddress = Dev->Address;
Dev->Address = 0;
- Status = UsbSetAddress (Dev, DevAddress);
+ Status = UsbSetAddress (Dev, DevAddress);
Dev->Address = DevAddress;
gBS->Stall (USB_SET_DEVICE_ADDRESS_STALL);
@@ -861,13 +865,17 @@ UsbIoPortReset (
//
// It may fail due to device disconnection or other reasons.
//
- DEBUG (( DEBUG_ERROR, "UsbIoPortReset: failed to set address for device %d - %r\n",
- Dev->Address, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "UsbIoPortReset: failed to set address for device %d - %r\n",
+ Dev->Address,
+ Status
+ ));
goto ON_EXIT;
}
- DEBUG (( DEBUG_INFO, "UsbIoPortReset: device is now ADDRESSED at %d\n", Dev->Address));
+ DEBUG ((DEBUG_INFO, "UsbIoPortReset: device is now ADDRESSED at %d\n", Dev->Address));
//
// Reset the current active configure, after this device
@@ -877,8 +885,12 @@ UsbIoPortReset (
Status = UsbSetConfig (Dev, Dev->ActiveConfig->Desc.ConfigurationValue);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "UsbIoPortReset: failed to set configure for device %d - %r\n",
- Dev->Address, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "UsbIoPortReset: failed to set configure for device %d - %r\n",
+ Dev->Address,
+ Status
+ ));
}
}
@@ -887,7 +899,6 @@ ON_EXIT:
return Status;
}
-
/**
Install Usb Bus Protocol on host controller, and start the Usb bus.
@@ -908,11 +919,11 @@ UsbBusBuildProtocol (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- USB_BUS *UsbBus;
- USB_DEVICE *RootHub;
- USB_INTERFACE *RootIf;
- EFI_STATUS Status;
- EFI_STATUS Status2;
+ USB_BUS *UsbBus;
+ USB_DEVICE *RootHub;
+ USB_INTERFACE *RootIf;
+ EFI_STATUS Status;
+ EFI_STATUS Status2;
UsbBus = AllocateZeroPool (sizeof (USB_BUS));
@@ -927,7 +938,7 @@ UsbBusBuildProtocol (
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &UsbBus->DevicePath,
+ (VOID **)&UsbBus->DevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -951,7 +962,7 @@ UsbBusBuildProtocol (
Status = gBS->OpenProtocol (
Controller,
&gEfiUsb2HcProtocolGuid,
- (VOID **) &(UsbBus->Usb2Hc),
+ (VOID **)&(UsbBus->Usb2Hc),
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -960,7 +971,7 @@ UsbBusBuildProtocol (
Status2 = gBS->OpenProtocol (
Controller,
&gEfiUsbHcProtocolGuid,
- (VOID **) &(UsbBus->UsbHc),
+ (VOID **)&(UsbBus->UsbHc),
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -1040,7 +1051,7 @@ UsbBusBuildProtocol (
UsbBus->DevicePath
);
- Status = mUsbRootHubApi.Init (RootIf);
+ Status = mUsbRootHubApi.Init (RootIf);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "UsbBusStart: Failed to init root hub %r\n", Status));
@@ -1056,6 +1067,7 @@ FREE_ROOTHUB:
if (RootIf != NULL) {
FreePool (RootIf);
}
+
if (RootHub != NULL) {
FreePool (RootHub);
}
@@ -1066,20 +1078,22 @@ UNINSTALL_USBBUS:
CLOSE_HC:
if (UsbBus->Usb2Hc != NULL) {
gBS->CloseProtocol (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiUsb2HcProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
}
+
if (UsbBus->UsbHc != NULL) {
gBS->CloseProtocol (
- Controller,
- &gEfiUsbHcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiUsbHcProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
}
+
gBS->CloseProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
@@ -1092,7 +1106,6 @@ CLOSE_HC:
return Status;
}
-
/**
The USB bus driver entry pointer.
@@ -1106,8 +1119,8 @@ CLOSE_HC:
EFI_STATUS
EFIAPI
UsbBusDriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EfiLibInstallDriverBindingComponentName2 (
@@ -1120,7 +1133,6 @@ UsbBusDriverEntryPoint (
);
}
-
/**
Check whether USB bus driver support this device.
@@ -1162,11 +1174,11 @@ UsbBusControllerDriverSupported (
DevicePathNode.DevPath = RemainingDevicePath;
if ((DevicePathNode.DevPath->Type != MESSAGING_DEVICE_PATH) ||
- (DevicePathNode.DevPath->SubType != MSG_USB_DP &&
- DevicePathNode.DevPath->SubType != MSG_USB_CLASS_DP
- && DevicePathNode.DevPath->SubType != MSG_USB_WWID_DP
- )) {
-
+ ( (DevicePathNode.DevPath->SubType != MSG_USB_DP) &&
+ (DevicePathNode.DevPath->SubType != MSG_USB_CLASS_DP)
+ && (DevicePathNode.DevPath->SubType != MSG_USB_WWID_DP)
+ ))
+ {
return EFI_UNSUPPORTED;
}
}
@@ -1178,7 +1190,7 @@ UsbBusControllerDriverSupported (
Status = gBS->OpenProtocol (
Controller,
&gEfiUsb2HcProtocolGuid,
- (VOID **) &Usb2Hc,
+ (VOID **)&Usb2Hc,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -1194,7 +1206,7 @@ UsbBusControllerDriverSupported (
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbHcProtocolGuid,
- (VOID **) &UsbHc,
+ (VOID **)&UsbHc,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -1211,14 +1223,12 @@ UsbBusControllerDriverSupported (
// Close the USB_HC used to perform the supported test
//
gBS->CloseProtocol (
- Controller,
- &gEfiUsbHcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
+ Controller,
+ &gEfiUsbHcProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
} else {
-
//
// Close the USB_HC2 used to perform the supported test
//
@@ -1236,7 +1246,7 @@ UsbBusControllerDriverSupported (
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ (VOID **)&ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -1250,11 +1260,11 @@ UsbBusControllerDriverSupported (
// Close protocol, don't use device path protocol in the Support() function
//
gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_SUCCESS;
}
@@ -1262,7 +1272,6 @@ UsbBusControllerDriverSupported (
return Status;
}
-
/**
Start to process the controller.
@@ -1284,14 +1293,14 @@ UsbBusControllerDriverStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_USB_BUS_PROTOCOL *UsbBusId;
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EFI_USB_BUS_PROTOCOL *UsbBusId;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ (VOID **)&ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1314,7 +1323,7 @@ UsbBusControllerDriverStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiCallerIdGuid,
- (VOID **) &UsbBusId,
+ (VOID **)&UsbBusId,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1329,13 +1338,14 @@ UsbBusControllerDriverStart (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Try get the Usb Bus protocol interface again
//
Status = gBS->OpenProtocol (
Controller,
&gEfiCallerIdGuid,
- (VOID **) &UsbBusId,
+ (VOID **)&UsbBusId,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1370,11 +1380,9 @@ UsbBusControllerDriverStart (
ASSERT (!EFI_ERROR (Status));
}
-
return EFI_SUCCESS;
}
-
/**
Stop handle the controller by this USB bus driver.
@@ -1409,20 +1417,20 @@ UsbBusControllerDriverStop (
EFI_STATUS Status;
EFI_STATUS ReturnStatus;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
if (NumberOfChildren > 0) {
//
// BugBug: Raise TPL to callback level instead of USB_BUS_TPL to avoid TPL conflict
//
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
ReturnStatus = EFI_SUCCESS;
for (Index = 0; Index < NumberOfChildren; Index++) {
Status = gBS->OpenProtocol (
ChildHandleBuffer[Index],
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
+ (VOID **)&UsbIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1438,8 +1446,8 @@ UsbBusControllerDriverStop (
continue;
}
- UsbIf = USB_INTERFACE_FROM_USBIO (UsbIo);
- UsbDev = UsbIf->Device;
+ UsbIf = USB_INTERFACE_FROM_USBIO (UsbIo);
+ UsbDev = UsbIf->Device;
ReturnStatus = UsbRemoveDevice (UsbDev);
}
@@ -1448,7 +1456,7 @@ UsbBusControllerDriverStop (
return ReturnStatus;
}
- DEBUG (( DEBUG_INFO, "UsbBusStop: usb bus stopped on %p\n", Controller));
+ DEBUG ((DEBUG_INFO, "UsbBusStop: usb bus stopped on %p\n", Controller));
//
// Locate USB_BUS for the current host controller
@@ -1456,7 +1464,7 @@ UsbBusControllerDriverStop (
Status = gBS->OpenProtocol (
Controller,
&gEfiCallerIdGuid,
- (VOID **) &BusId,
+ (VOID **)&BusId,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1473,7 +1481,7 @@ UsbBusControllerDriverStop (
//
// BugBug: Raise TPL to callback level instead of USB_BUS_TPL to avoid TPL conflict
//
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
RootHub = Bus->Devices[0];
RootIf = RootHub->Interfaces[0];
@@ -1493,8 +1501,8 @@ UsbBusControllerDriverStop (
if (!EFI_ERROR (ReturnStatus)) {
mUsbRootHubApi.Release (RootIf);
- gBS->FreePool (RootIf);
- gBS->FreePool (RootHub);
+ gBS->FreePool (RootIf);
+ gBS->FreePool (RootHub);
Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);
ASSERT (!EFI_ERROR (Status));
@@ -1533,5 +1541,6 @@ UsbBusControllerDriverStop (
gBS->FreePool (Bus);
}
}
+
return Status;
}
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h
index 40bc5f1..21a2421 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _EFI_USB_BUS_H_
#define _EFI_USB_BUS_H_
-
#include <Uefi.h>
#include <Protocol/Usb2HostController.h>
@@ -28,7 +27,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/MemoryAllocationLib.h>
#include <Library/ReportStatusCodeLib.h>
-
#include <IndustryStandard/Usb.h>
typedef struct _USB_DEVICE USB_DEVICE;
@@ -36,7 +34,6 @@ typedef struct _USB_INTERFACE USB_INTERFACE;
typedef struct _USB_BUS USB_BUS;
typedef struct _USB_HUB_API USB_HUB_API;
-
#include "UsbUtility.h"
#include "UsbDesc.h"
#include "UsbHub.h"
@@ -46,19 +43,19 @@ typedef struct _USB_HUB_API USB_HUB_API;
// USB bus timeout experience values
//
-#define USB_MAX_LANG_ID 16
-#define USB_MAX_INTERFACE 16
-#define USB_MAX_DEVICES 128
+#define USB_MAX_LANG_ID 16
+#define USB_MAX_INTERFACE 16
+#define USB_MAX_DEVICES 128
-#define USB_BUS_1_MILLISECOND 1000
+#define USB_BUS_1_MILLISECOND 1000
//
// Roothub and hub's polling interval, set by experience,
// The unit of roothub is 100us, means 100ms as interval, and
// the unit of hub is 1ms, means 64ms as interval.
//
-#define USB_ROOTHUB_POLL_INTERVAL (100 * 10000U)
-#define USB_HUB_POLL_INTERVAL 64
+#define USB_ROOTHUB_POLL_INTERVAL (100 * 10000U)
+#define USB_HUB_POLL_INTERVAL 64
//
// Wait for port stable to work, refers to specification
@@ -69,13 +66,13 @@ typedef struct _USB_HUB_API USB_HUB_API;
//
// Wait for port statue reg change, set by experience
//
-#define USB_WAIT_PORT_STS_CHANGE_STALL (100)
+#define USB_WAIT_PORT_STS_CHANGE_STALL (100)
//
// Wait for set device address, refers to specification
// [USB20-9.2.6.3, it says 2ms]
//
-#define USB_SET_DEVICE_ADDRESS_STALL (2 * USB_BUS_1_MILLISECOND)
+#define USB_SET_DEVICE_ADDRESS_STALL (2 * USB_BUS_1_MILLISECOND)
//
// Wait for retry max packet size, set by experience
@@ -86,7 +83,7 @@ typedef struct _USB_HUB_API USB_HUB_API;
// Wait for hub port power-on, refers to specification
// [USB20-11.23.2]
//
-#define USB_SET_PORT_POWER_STALL (2 * USB_BUS_1_MILLISECOND)
+#define USB_SET_PORT_POWER_STALL (2 * USB_BUS_1_MILLISECOND)
//
// Wait for port reset, refers to specification
@@ -103,7 +100,7 @@ typedef struct _USB_HUB_API USB_HUB_API;
// Wait for port recovery to accept SetAddress, refers to specification
// [USB20-7.1.7.5, it says 10 ms for TRSTRCY]
//
-#define USB_SET_PORT_RECOVERY_STALL (10 * USB_BUS_1_MILLISECOND)
+#define USB_SET_PORT_RECOVERY_STALL (10 * USB_BUS_1_MILLISECOND)
//
// Wait for clear roothub port reset, set by experience
@@ -113,7 +110,7 @@ typedef struct _USB_HUB_API USB_HUB_API;
//
// Wait for set roothub port enable, set by experience
//
-#define USB_SET_ROOT_PORT_ENABLE_STALL (20 * USB_BUS_1_MILLISECOND)
+#define USB_SET_ROOT_PORT_ENABLE_STALL (20 * USB_BUS_1_MILLISECOND)
//
// Send general device request timeout.
@@ -122,7 +119,7 @@ typedef struct _USB_HUB_API USB_HUB_API;
// 50 milliseconds. We use a value of 500 milliseconds to work
// around slower hubs and devices.
//
-#define USB_GENERAL_DEVICE_REQUEST_TIMEOUT 500
+#define USB_GENERAL_DEVICE_REQUEST_TIMEOUT 500
//
// Send clear feature request timeout, set by experience
@@ -133,13 +130,13 @@ typedef struct _USB_HUB_API USB_HUB_API;
// Bus raises TPL to TPL_NOTIFY to serialize all its operations
// to protect shared data structures.
//
-#define USB_BUS_TPL TPL_NOTIFY
+#define USB_BUS_TPL TPL_NOTIFY
-#define USB_INTERFACE_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'I')
-#define USB_BUS_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'B')
+#define USB_INTERFACE_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'I')
+#define USB_BUS_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'B')
-#define USB_BIT(a) ((UINTN)(1 << (a)))
-#define USB_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
+#define USB_BIT(a) ((UINTN)(1 << (a)))
+#define USB_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
#define USB_INTERFACE_FROM_USBIO(a) \
CR(a, USB_INTERFACE, UsbIo, USB_INTERFACE_SIGNATURE)
@@ -153,113 +150,112 @@ typedef struct _USB_HUB_API USB_HUB_API;
// gEfiCallerIdGuid will be used as its protocol guid.
//
typedef struct _EFI_USB_BUS_PROTOCOL {
- UINT64 Reserved;
+ UINT64 Reserved;
} EFI_USB_BUS_PROTOCOL;
-
//
// Stands for the real USB device. Each device may
// has several separately working interfaces.
//
struct _USB_DEVICE {
- USB_BUS *Bus;
+ USB_BUS *Bus;
//
// Configuration information
//
- UINT8 Speed;
- UINT8 Address;
- UINT32 MaxPacket0;
+ UINT8 Speed;
+ UINT8 Address;
+ UINT32 MaxPacket0;
//
// The device's descriptors and its configuration
//
- USB_DEVICE_DESC *DevDesc;
- USB_CONFIG_DESC *ActiveConfig;
+ USB_DEVICE_DESC *DevDesc;
+ USB_CONFIG_DESC *ActiveConfig;
- UINT16 LangId [USB_MAX_LANG_ID];
- UINT16 TotalLangId;
+ UINT16 LangId[USB_MAX_LANG_ID];
+ UINT16 TotalLangId;
- UINT8 NumOfInterface;
- USB_INTERFACE *Interfaces [USB_MAX_INTERFACE];
+ UINT8 NumOfInterface;
+ USB_INTERFACE *Interfaces[USB_MAX_INTERFACE];
//
// Parent child relationship
//
- EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator;
+ EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator;
- UINT8 ParentAddr;
- USB_INTERFACE *ParentIf;
- UINT8 ParentPort; // Start at 0
- UINT8 Tier;
- BOOLEAN DisconnectFail;
+ UINT8 ParentAddr;
+ USB_INTERFACE *ParentIf;
+ UINT8 ParentPort; // Start at 0
+ UINT8 Tier;
+ BOOLEAN DisconnectFail;
};
//
// Stands for different functions of USB device
//
struct _USB_INTERFACE {
- UINTN Signature;
- USB_DEVICE *Device;
- USB_INTERFACE_DESC *IfDesc;
- USB_INTERFACE_SETTING *IfSetting;
+ UINTN Signature;
+ USB_DEVICE *Device;
+ USB_INTERFACE_DESC *IfDesc;
+ USB_INTERFACE_SETTING *IfSetting;
//
// Handles and protocols
//
- EFI_HANDLE Handle;
- EFI_USB_IO_PROTOCOL UsbIo;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- BOOLEAN IsManaged;
+ EFI_HANDLE Handle;
+ EFI_USB_IO_PROTOCOL UsbIo;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ BOOLEAN IsManaged;
//
// Hub device special data
//
- BOOLEAN IsHub;
- USB_HUB_API *HubApi;
- UINT8 NumOfPort;
- EFI_EVENT HubNotify;
+ BOOLEAN IsHub;
+ USB_HUB_API *HubApi;
+ UINT8 NumOfPort;
+ EFI_EVENT HubNotify;
//
// Data used only by normal hub devices
//
- USB_ENDPOINT_DESC *HubEp;
- UINT8 *ChangeMap;
+ USB_ENDPOINT_DESC *HubEp;
+ UINT8 *ChangeMap;
//
// Data used only by root hub to hand over device to
// companion UHCI driver if low/full speed devices are
// connected to EHCI.
//
- UINT8 MaxSpeed;
+ UINT8 MaxSpeed;
};
//
// Stands for the current USB Bus
//
struct _USB_BUS {
- UINTN Signature;
- EFI_USB_BUS_PROTOCOL BusId;
+ UINTN Signature;
+ EFI_USB_BUS_PROTOCOL BusId;
//
// Managed USB host controller
//
- EFI_HANDLE HostHandle;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_USB2_HC_PROTOCOL *Usb2Hc;
- EFI_USB_HC_PROTOCOL *UsbHc;
+ EFI_HANDLE HostHandle;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_USB2_HC_PROTOCOL *Usb2Hc;
+ EFI_USB_HC_PROTOCOL *UsbHc;
//
// Recorded the max supported usb devices.
// XHCI can support up to 255 devices.
// EHCI/UHCI/OHCI supports up to 127 devices.
//
- UINT32 MaxDevices;
+ UINT32 MaxDevices;
//
// An array of device that is on the bus. Devices[0] is
// for root hub. Device with address i is at Devices[i].
//
- USB_DEVICE *Devices[256];
+ USB_DEVICE *Devices[256];
//
// USB Bus driver need to control the recursive connect policy of the bus, only those wanted
@@ -269,35 +265,34 @@ struct _USB_BUS {
// every wanted child device is stored in a item of the WantedUsbIoDPList, whose structure is
// DEVICE_PATH_LIST_ITEM
//
- LIST_ENTRY WantedUsbIoDPList;
-
+ LIST_ENTRY WantedUsbIoDPList;
};
//
// USB Hub Api
//
-struct _USB_HUB_API{
- USB_HUB_INIT Init;
- USB_HUB_GET_PORT_STATUS GetPortStatus;
- USB_HUB_CLEAR_PORT_CHANGE ClearPortChange;
- USB_HUB_SET_PORT_FEATURE SetPortFeature;
- USB_HUB_CLEAR_PORT_FEATURE ClearPortFeature;
- USB_HUB_RESET_PORT ResetPort;
- USB_HUB_RELEASE Release;
+struct _USB_HUB_API {
+ USB_HUB_INIT Init;
+ USB_HUB_GET_PORT_STATUS GetPortStatus;
+ USB_HUB_CLEAR_PORT_CHANGE ClearPortChange;
+ USB_HUB_SET_PORT_FEATURE SetPortFeature;
+ USB_HUB_CLEAR_PORT_FEATURE ClearPortFeature;
+ USB_HUB_RESET_PORT ResetPort;
+ USB_HUB_RELEASE Release;
};
-#define USB_US_LAND_ID 0x0409
+#define USB_US_LAND_ID 0x0409
-#define DEVICE_PATH_LIST_ITEM_SIGNATURE SIGNATURE_32('d','p','l','i')
-typedef struct _DEVICE_PATH_LIST_ITEM{
- UINTN Signature;
- LIST_ENTRY Link;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+#define DEVICE_PATH_LIST_ITEM_SIGNATURE SIGNATURE_32('d','p','l','i')
+typedef struct _DEVICE_PATH_LIST_ITEM {
+ UINTN Signature;
+ LIST_ENTRY Link;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
} DEVICE_PATH_LIST_ITEM;
typedef struct {
- USB_CLASS_DEVICE_PATH UsbClass;
- EFI_DEVICE_PATH_PROTOCOL End;
+ USB_CLASS_DEVICE_PATH UsbClass;
+ EFI_DEVICE_PATH_PROTOCOL End;
} USB_CLASS_FORMAT_DEVICE_PATH;
/**
@@ -312,7 +307,7 @@ typedef struct {
EFI_STATUS
EFIAPI
UsbBusFreeUsbDPList (
- IN LIST_ENTRY *UsbIoDPList
+ IN LIST_ENTRY *UsbIoDPList
);
/**
@@ -329,8 +324,8 @@ UsbBusFreeUsbDPList (
EFI_STATUS
EFIAPI
UsbBusAddWantedUsbIoDP (
- IN EFI_USB_BUS_PROTOCOL *UsbBusId,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_USB_BUS_PROTOCOL *UsbBusId,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -346,8 +341,8 @@ UsbBusAddWantedUsbIoDP (
BOOLEAN
EFIAPI
UsbBusIsWantedUsbIO (
- IN USB_BUS *Bus,
- IN USB_INTERFACE *UsbIf
+ IN USB_BUS *Bus,
+ IN USB_INTERFACE *UsbIf
);
/**
@@ -363,7 +358,7 @@ UsbBusIsWantedUsbIO (
EFI_STATUS
EFIAPI
UsbBusRecursivelyConnectWantedUsbIo (
- IN EFI_USB_BUS_PROTOCOL *UsbBusId
+ IN EFI_USB_BUS_PROTOCOL *UsbBusId
);
/**
@@ -416,12 +411,12 @@ UsbIoControlTransfer (
EFI_STATUS
EFIAPI
UsbIoBulkTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 Endpoint,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINTN Timeout,
- OUT UINT32 *UsbStatus
+ IN EFI_USB_IO_PROTOCOL *This,
+ IN UINT8 Endpoint,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN UINTN Timeout,
+ OUT UINT32 *UsbStatus
);
/**
@@ -443,12 +438,12 @@ UsbIoBulkTransfer (
EFI_STATUS
EFIAPI
UsbIoSyncInterruptTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 Endpoint,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINTN Timeout,
- OUT UINT32 *UsbStatus
+ IN EFI_USB_IO_PROTOCOL *This,
+ IN UINT8 Endpoint,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN UINTN Timeout,
+ OUT UINT32 *UsbStatus
);
/**
@@ -498,11 +493,11 @@ UsbIoAsyncInterruptTransfer (
EFI_STATUS
EFIAPI
UsbIoIsochronousTransfer (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 DeviceEndpoint,
- IN OUT VOID *Data,
- IN UINTN DataLength,
- OUT UINT32 *Status
+ IN EFI_USB_IO_PROTOCOL *This,
+ IN UINT8 DeviceEndpoint,
+ IN OUT VOID *Data,
+ IN UINTN DataLength,
+ OUT UINT32 *Status
);
/**
@@ -543,8 +538,8 @@ UsbIoAsyncIsochronousTransfer (
EFI_STATUS
EFIAPI
UsbIoGetDeviceDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT EFI_USB_DEVICE_DESCRIPTOR *Descriptor
+ IN EFI_USB_IO_PROTOCOL *This,
+ OUT EFI_USB_DEVICE_DESCRIPTOR *Descriptor
);
/**
@@ -561,8 +556,8 @@ UsbIoGetDeviceDescriptor (
EFI_STATUS
EFIAPI
UsbIoGetActiveConfigDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT EFI_USB_CONFIG_DESCRIPTOR *Descriptor
+ IN EFI_USB_IO_PROTOCOL *This,
+ OUT EFI_USB_CONFIG_DESCRIPTOR *Descriptor
);
/**
@@ -597,9 +592,9 @@ UsbIoGetInterfaceDescriptor (
EFI_STATUS
EFIAPI
UsbIoGetEndpointDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT8 Index,
- OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor
+ IN EFI_USB_IO_PROTOCOL *This,
+ IN UINT8 Index,
+ OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor
);
/**
@@ -615,9 +610,9 @@ UsbIoGetEndpointDescriptor (
EFI_STATUS
EFIAPI
UsbIoGetSupportedLanguages (
- IN EFI_USB_IO_PROTOCOL *This,
- OUT UINT16 **LangIDTable,
- OUT UINT16 *TableSize
+ IN EFI_USB_IO_PROTOCOL *This,
+ OUT UINT16 **LangIDTable,
+ OUT UINT16 *TableSize
);
/**
@@ -635,10 +630,10 @@ UsbIoGetSupportedLanguages (
EFI_STATUS
EFIAPI
UsbIoGetStringDescriptor (
- IN EFI_USB_IO_PROTOCOL *This,
- IN UINT16 LangID,
- IN UINT8 StringIndex,
- OUT CHAR16 **String
+ IN EFI_USB_IO_PROTOCOL *This,
+ IN UINT16 LangID,
+ IN UINT8 StringIndex,
+ OUT CHAR16 **String
);
/**
@@ -690,8 +685,8 @@ UsbBusBuildProtocol (
EFI_STATUS
EFIAPI
UsbBusDriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
);
/**
@@ -756,9 +751,9 @@ UsbBusControllerDriverStop (
IN EFI_HANDLE *ChildHandleBuffer
);
-extern EFI_USB_IO_PROTOCOL mUsbIoProtocol;
-extern EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL mUsbBusComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL mUsbBusComponentName2;
+extern EFI_USB_IO_PROTOCOL mUsbIoProtocol;
+extern EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL mUsbBusComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL mUsbBusComponentName2;
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
index 4e60222..a620a67 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c
@@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "UsbBus.h"
-
/**
Free the interface setting descriptor.
@@ -21,8 +20,8 @@ UsbFreeInterfaceDesc (
IN USB_INTERFACE_SETTING *Setting
)
{
- USB_ENDPOINT_DESC *Ep;
- UINTN Index;
+ USB_ENDPOINT_DESC *Ep;
+ UINTN Index;
if (Setting->Endpoints != NULL) {
//
@@ -47,7 +46,6 @@ UsbFreeInterfaceDesc (
FreePool (Setting);
}
-
/**
Free a configuration descriptor with its interface
descriptors. It may be initialized partially.
@@ -57,12 +55,12 @@ UsbFreeInterfaceDesc (
**/
VOID
UsbFreeConfigDesc (
- IN USB_CONFIG_DESC *Config
+ IN USB_CONFIG_DESC *Config
)
{
- USB_INTERFACE_DESC *Interface;
- UINTN Index;
- UINTN SetIndex;
+ USB_INTERFACE_DESC *Interface;
+ UINTN Index;
+ UINTN SetIndex;
if (Config->Interfaces != NULL) {
//
@@ -91,10 +89,8 @@ UsbFreeConfigDesc (
}
FreePool (Config);
-
}
-
/**
Free a device descriptor with its configurations.
@@ -103,10 +99,10 @@ UsbFreeConfigDesc (
**/
VOID
UsbFreeDevDesc (
- IN USB_DEVICE_DESC *DevDesc
+ IN USB_DEVICE_DESC *DevDesc
)
{
- UINTN Index;
+ UINTN Index;
if (DevDesc->Configs != NULL) {
for (Index = 0; Index < DevDesc->Desc.NumConfigurations; Index++) {
@@ -121,7 +117,6 @@ UsbFreeDevDesc (
FreePool (DevDesc);
}
-
/**
Create a descriptor.
@@ -135,46 +130,46 @@ UsbFreeDevDesc (
**/
VOID *
UsbCreateDesc (
- IN UINT8 *DescBuf,
- IN UINTN Len,
- IN UINT8 Type,
- OUT UINTN *Consumed
+ IN UINT8 *DescBuf,
+ IN UINTN Len,
+ IN UINT8 Type,
+ OUT UINTN *Consumed
)
{
- USB_DESC_HEAD *Head;
- UINTN DescLen;
- UINTN CtrlLen;
- UINTN Offset;
- VOID *Desc;
+ USB_DESC_HEAD *Head;
+ UINTN DescLen;
+ UINTN CtrlLen;
+ UINTN Offset;
+ VOID *Desc;
DescLen = 0;
CtrlLen = 0;
*Consumed = 0;
switch (Type) {
- case USB_DESC_TYPE_DEVICE:
- DescLen = sizeof (EFI_USB_DEVICE_DESCRIPTOR);
- CtrlLen = sizeof (USB_DEVICE_DESC);
- break;
-
- case USB_DESC_TYPE_CONFIG:
- DescLen = sizeof (EFI_USB_CONFIG_DESCRIPTOR);
- CtrlLen = sizeof (USB_CONFIG_DESC);
- break;
-
- case USB_DESC_TYPE_INTERFACE:
- DescLen = sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
- CtrlLen = sizeof (USB_INTERFACE_SETTING);
- break;
-
- case USB_DESC_TYPE_ENDPOINT:
- DescLen = sizeof (EFI_USB_ENDPOINT_DESCRIPTOR);
- CtrlLen = sizeof (USB_ENDPOINT_DESC);
- break;
-
- default:
- ASSERT (FALSE);
- return NULL;
+ case USB_DESC_TYPE_DEVICE:
+ DescLen = sizeof (EFI_USB_DEVICE_DESCRIPTOR);
+ CtrlLen = sizeof (USB_DEVICE_DESC);
+ break;
+
+ case USB_DESC_TYPE_CONFIG:
+ DescLen = sizeof (EFI_USB_CONFIG_DESCRIPTOR);
+ CtrlLen = sizeof (USB_CONFIG_DESC);
+ break;
+
+ case USB_DESC_TYPE_INTERFACE:
+ DescLen = sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
+ CtrlLen = sizeof (USB_INTERFACE_SETTING);
+ break;
+
+ case USB_DESC_TYPE_ENDPOINT:
+ DescLen = sizeof (EFI_USB_ENDPOINT_DESCRIPTOR);
+ CtrlLen = sizeof (USB_ENDPOINT_DESC);
+ break;
+
+ default:
+ ASSERT (FALSE);
+ return NULL;
}
//
@@ -231,19 +226,18 @@ UsbCreateDesc (
return NULL;
}
- Desc = AllocateZeroPool ((UINTN) CtrlLen);
+ Desc = AllocateZeroPool ((UINTN)CtrlLen);
if (Desc == NULL) {
return NULL;
}
- CopyMem (Desc, Head, (UINTN) DescLen);
+ CopyMem (Desc, Head, (UINTN)DescLen);
*Consumed = Offset;
return Desc;
}
-
/**
Parse an interface descriptor and its endpoints.
@@ -256,23 +250,23 @@ UsbCreateDesc (
**/
USB_INTERFACE_SETTING *
UsbParseInterfaceDesc (
- IN UINT8 *DescBuf,
- IN UINTN Len,
- OUT UINTN *Consumed
+ IN UINT8 *DescBuf,
+ IN UINTN Len,
+ OUT UINTN *Consumed
)
{
- USB_INTERFACE_SETTING *Setting;
- USB_ENDPOINT_DESC *Ep;
- UINTN Index;
- UINTN NumEp;
- UINTN Used;
- UINTN Offset;
+ USB_INTERFACE_SETTING *Setting;
+ USB_ENDPOINT_DESC *Ep;
+ UINTN Index;
+ UINTN NumEp;
+ UINTN Used;
+ UINTN Offset;
*Consumed = 0;
Setting = UsbCreateDesc (DescBuf, Len, USB_DESC_TYPE_INTERFACE, &Used);
if (Setting == NULL) {
- DEBUG (( DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create interface descriptor\n"));
+ DEBUG ((DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create interface descriptor\n"));
return NULL;
}
@@ -281,16 +275,21 @@ UsbParseInterfaceDesc (
//
// Create an array to hold the interface's endpoints
//
- NumEp = Setting->Desc.NumEndpoints;
+ NumEp = Setting->Desc.NumEndpoints;
- DEBUG (( DEBUG_INFO, "UsbParseInterfaceDesc: interface %d(setting %d) has %d endpoints\n",
- Setting->Desc.InterfaceNumber, Setting->Desc.AlternateSetting, (UINT32)NumEp));
+ DEBUG ((
+ DEBUG_INFO,
+ "UsbParseInterfaceDesc: interface %d(setting %d) has %d endpoints\n",
+ Setting->Desc.InterfaceNumber,
+ Setting->Desc.AlternateSetting,
+ (UINT32)NumEp
+ ));
if (NumEp == 0) {
goto ON_EXIT;
}
- Setting->Endpoints = AllocateZeroPool (sizeof (USB_ENDPOINT_DESC *) * NumEp);
+ Setting->Endpoints = AllocateZeroPool (sizeof (USB_ENDPOINT_DESC *) * NumEp);
if (Setting->Endpoints == NULL) {
goto ON_ERROR;
@@ -303,15 +302,14 @@ UsbParseInterfaceDesc (
Ep = UsbCreateDesc (DescBuf + Offset, Len - Offset, USB_DESC_TYPE_ENDPOINT, &Used);
if (Ep == NULL) {
- DEBUG (( DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create endpoint(index %d)\n", (UINT32)Index));
+ DEBUG ((DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create endpoint(index %d)\n", (UINT32)Index));
goto ON_ERROR;
}
- Setting->Endpoints[Index] = Ep;
- Offset += Used;
+ Setting->Endpoints[Index] = Ep;
+ Offset += Used;
}
-
ON_EXIT:
*Consumed = Offset;
return Setting;
@@ -321,7 +319,6 @@ ON_ERROR:
return NULL;
}
-
/**
Parse the configuration descriptor and its interfaces.
@@ -333,16 +330,16 @@ ON_ERROR:
**/
USB_CONFIG_DESC *
UsbParseConfigDesc (
- IN UINT8 *DescBuf,
- IN UINTN Len
+ IN UINT8 *DescBuf,
+ IN UINTN Len
)
{
- USB_CONFIG_DESC *Config;
- USB_INTERFACE_SETTING *Setting;
- USB_INTERFACE_DESC *Interface;
- UINTN Index;
- UINTN NumIf;
- UINTN Consumed;
+ USB_CONFIG_DESC *Config;
+ USB_INTERFACE_SETTING *Setting;
+ USB_INTERFACE_DESC *Interface;
+ UINTN Index;
+ UINTN NumIf;
+ UINTN Consumed;
ASSERT (DescBuf != NULL);
@@ -355,15 +352,19 @@ UsbParseConfigDesc (
//
// Initialize an array of setting for the configuration's interfaces.
//
- NumIf = Config->Desc.NumInterfaces;
- Config->Interfaces = AllocateZeroPool (sizeof (USB_INTERFACE_DESC *) * NumIf);
+ NumIf = Config->Desc.NumInterfaces;
+ Config->Interfaces = AllocateZeroPool (sizeof (USB_INTERFACE_DESC *) * NumIf);
if (Config->Interfaces == NULL) {
goto ON_ERROR;
}
- DEBUG (( DEBUG_INFO, "UsbParseConfigDesc: config %d has %d interfaces\n",
- Config->Desc.ConfigurationValue, (UINT32)NumIf));
+ DEBUG ((
+ DEBUG_INFO,
+ "UsbParseConfigDesc: config %d has %d interfaces\n",
+ Config->Desc.ConfigurationValue,
+ (UINT32)NumIf
+ ));
for (Index = 0; Index < NumIf; Index++) {
Interface = AllocateZeroPool (sizeof (USB_INTERFACE_DESC));
@@ -394,11 +395,10 @@ UsbParseConfigDesc (
Setting = UsbParseInterfaceDesc (DescBuf, Len, &Consumed);
if (Setting == NULL) {
- DEBUG (( DEBUG_ERROR, "UsbParseConfigDesc: warning: failed to get interface setting, stop parsing now.\n"));
+ DEBUG ((DEBUG_ERROR, "UsbParseConfigDesc: warning: failed to get interface setting, stop parsing now.\n"));
break;
-
} else if (Setting->Desc.InterfaceNumber >= NumIf) {
- DEBUG (( DEBUG_ERROR, "UsbParseConfigDesc: malformatted interface descriptor\n"));
+ DEBUG ((DEBUG_ERROR, "UsbParseConfigDesc: malformatted interface descriptor\n"));
UsbFreeInterfaceDesc (Setting);
goto ON_ERROR;
@@ -427,7 +427,6 @@ ON_ERROR:
return NULL;
}
-
/**
USB standard control transfer support routine. This
function is used by USB device. It is possible that
@@ -450,15 +449,15 @@ ON_ERROR:
**/
EFI_STATUS
UsbCtrlRequest (
- IN USB_DEVICE *UsbDev,
- IN EFI_USB_DATA_DIRECTION Direction,
- IN UINTN Type,
- IN UINTN Target,
- IN UINTN Request,
- IN UINT16 Value,
- IN UINT16 Index,
- IN OUT VOID *Buf,
- IN UINTN Length
+ IN USB_DEVICE *UsbDev,
+ IN EFI_USB_DATA_DIRECTION Direction,
+ IN UINTN Type,
+ IN UINTN Target,
+ IN UINTN Request,
+ IN UINT16 Value,
+ IN UINT16 Index,
+ IN OUT VOID *Buf,
+ IN UINTN Length
)
{
EFI_USB_DEVICE_REQUEST DevReq;
@@ -468,13 +467,13 @@ UsbCtrlRequest (
ASSERT ((UsbDev != NULL) && (UsbDev->Bus != NULL));
- DevReq.RequestType = USB_REQUEST_TYPE (Direction, Type, Target);
- DevReq.Request = (UINT8) Request;
- DevReq.Value = Value;
- DevReq.Index = Index;
- DevReq.Length = (UINT16) Length;
+ DevReq.RequestType = USB_REQUEST_TYPE (Direction, Type, Target);
+ DevReq.Request = (UINT8)Request;
+ DevReq.Value = Value;
+ DevReq.Index = Index;
+ DevReq.Length = (UINT16)Length;
- Len = Length;
+ Len = Length;
Status = UsbHcControlTransfer (
UsbDev->Bus,
UsbDev->Address,
@@ -492,7 +491,6 @@ UsbCtrlRequest (
return Status;
}
-
/**
Get the standard descriptors.
@@ -510,15 +508,15 @@ UsbCtrlRequest (
**/
EFI_STATUS
UsbCtrlGetDesc (
- IN USB_DEVICE *UsbDev,
- IN UINTN DescType,
- IN UINTN DescIndex,
- IN UINT16 LangId,
- OUT VOID *Buf,
- IN UINTN Length
+ IN USB_DEVICE *UsbDev,
+ IN UINTN DescType,
+ IN UINTN DescIndex,
+ IN UINT16 LangId,
+ OUT VOID *Buf,
+ IN UINTN Length
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = UsbCtrlRequest (
UsbDev,
@@ -526,7 +524,7 @@ UsbCtrlGetDesc (
USB_REQ_TYPE_STANDARD,
USB_TARGET_DEVICE,
USB_REQ_GET_DESCRIPTOR,
- (UINT16) ((DescType << 8) | DescIndex),
+ (UINT16)((DescType << 8) | DescIndex),
LangId,
Buf,
Length
@@ -535,7 +533,6 @@ UsbCtrlGetDesc (
return Status;
}
-
/**
Return the max packet size for endpoint zero. This function
is the first function called to get descriptors during bus
@@ -549,13 +546,12 @@ UsbCtrlGetDesc (
**/
EFI_STATUS
UsbGetMaxPacketSize0 (
- IN USB_DEVICE *UsbDev
+ IN USB_DEVICE *UsbDev
)
{
- EFI_USB_DEVICE_DESCRIPTOR DevDesc;
- EFI_STATUS Status;
- UINTN Index;
-
+ EFI_USB_DEVICE_DESCRIPTOR DevDesc;
+ EFI_STATUS Status;
+ UINTN Index;
//
// Get the first 8 bytes of the device descriptor which contains
@@ -569,6 +565,7 @@ UsbGetMaxPacketSize0 (
UsbDev->MaxPacket0 = 1 << 9;
return EFI_SUCCESS;
}
+
UsbDev->MaxPacket0 = DevDesc.MaxPacketSize0;
return EFI_SUCCESS;
}
@@ -579,7 +576,6 @@ UsbGetMaxPacketSize0 (
return EFI_DEVICE_ERROR;
}
-
/**
Get the device descriptor for the device.
@@ -591,11 +587,11 @@ UsbGetMaxPacketSize0 (
**/
EFI_STATUS
UsbGetDevDesc (
- IN USB_DEVICE *UsbDev
+ IN USB_DEVICE *UsbDev
)
{
- USB_DEVICE_DESC *DevDesc;
- EFI_STATUS Status;
+ USB_DEVICE_DESC *DevDesc;
+ EFI_STATUS Status;
DevDesc = AllocateZeroPool (sizeof (USB_DEVICE_DESC));
@@ -603,14 +599,14 @@ UsbGetDevDesc (
return EFI_OUT_OF_RESOURCES;
}
- Status = UsbCtrlGetDesc (
- UsbDev,
- USB_DESC_TYPE_DEVICE,
- 0,
- 0,
- DevDesc,
- sizeof (EFI_USB_DEVICE_DESCRIPTOR)
- );
+ Status = UsbCtrlGetDesc (
+ UsbDev,
+ USB_DESC_TYPE_DEVICE,
+ 0,
+ 0,
+ DevDesc,
+ sizeof (EFI_USB_DEVICE_DESCRIPTOR)
+ );
if (EFI_ERROR (Status)) {
gBS->FreePool (DevDesc);
@@ -621,7 +617,6 @@ UsbGetDevDesc (
return Status;
}
-
/**
Retrieve the indexed string for the language. It requires two
steps to get a string, first to get the string's length. Then
@@ -636,14 +631,14 @@ UsbGetDevDesc (
**/
EFI_USB_STRING_DESCRIPTOR *
UsbGetOneString (
- IN USB_DEVICE *UsbDev,
- IN UINT8 Index,
- IN UINT16 LangId
+ IN USB_DEVICE *UsbDev,
+ IN UINT8 Index,
+ IN UINT16 LangId
)
{
- EFI_USB_STRING_DESCRIPTOR Desc;
- EFI_STATUS Status;
- UINT8 *Buf;
+ EFI_USB_STRING_DESCRIPTOR Desc;
+ EFI_STATUS Status;
+ UINT8 *Buf;
//
// First get two bytes which contains the string length.
@@ -656,7 +651,8 @@ UsbGetOneString (
if (EFI_ERROR (Status) ||
(Desc.Length < OFFSET_OF (EFI_USB_STRING_DESCRIPTOR, Length) + sizeof (Desc.Length)) ||
(Desc.Length % 2 != 0)
- ) {
+ )
+ {
return NULL;
}
@@ -680,10 +676,9 @@ UsbGetOneString (
return NULL;
}
- return (EFI_USB_STRING_DESCRIPTOR *) Buf;
+ return (EFI_USB_STRING_DESCRIPTOR *)Buf;
}
-
/**
Build the language ID table for string descriptors.
@@ -694,14 +689,14 @@ UsbGetOneString (
**/
EFI_STATUS
UsbBuildLangTable (
- IN USB_DEVICE *UsbDev
+ IN USB_DEVICE *UsbDev
)
{
- EFI_USB_STRING_DESCRIPTOR *Desc;
- EFI_STATUS Status;
- UINTN Index;
- UINTN Max;
- UINT16 *Point;
+ EFI_USB_STRING_DESCRIPTOR *Desc;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN Max;
+ UINT16 *Point;
//
// The string of language ID zero returns the supported languages
@@ -719,8 +714,8 @@ UsbBuildLangTable (
Status = EFI_SUCCESS;
- Max = (Desc->Length - 2) / 2;
- Max = MIN(Max, USB_MAX_LANG_ID);
+ Max = (Desc->Length - 2) / 2;
+ Max = MIN (Max, USB_MAX_LANG_ID);
Point = Desc->String;
for (Index = 0; Index < Max; Index++) {
@@ -735,7 +730,6 @@ ON_EXIT:
return Status;
}
-
/**
Retrieve the indexed configure for the device. USB device
returns the configuration together with the interfaces for
@@ -750,13 +744,13 @@ ON_EXIT:
**/
EFI_USB_CONFIG_DESCRIPTOR *
UsbGetOneConfig (
- IN USB_DEVICE *UsbDev,
- IN UINT8 Index
+ IN USB_DEVICE *UsbDev,
+ IN UINT8 Index
)
{
- EFI_USB_CONFIG_DESCRIPTOR Desc;
- EFI_STATUS Status;
- VOID *Buf;
+ EFI_USB_CONFIG_DESCRIPTOR Desc;
+ EFI_STATUS Status;
+ VOID *Buf;
//
// First get four bytes which contains the total length
@@ -765,13 +759,17 @@ UsbGetOneConfig (
Status = UsbCtrlGetDesc (UsbDev, USB_DESC_TYPE_CONFIG, Index, 0, &Desc, 8);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "UsbGetOneConfig: failed to get descript length(%d) %r\n",
- Desc.TotalLength, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "UsbGetOneConfig: failed to get descript length(%d) %r\n",
+ Desc.TotalLength,
+ Status
+ ));
return NULL;
}
- DEBUG (( DEBUG_INFO, "UsbGetOneConfig: total length is %d\n", Desc.TotalLength));
+ DEBUG ((DEBUG_INFO, "UsbGetOneConfig: total length is %d\n", Desc.TotalLength));
//
// Reject if TotalLength even cannot cover itself.
@@ -789,7 +787,7 @@ UsbGetOneConfig (
Status = UsbCtrlGetDesc (UsbDev, USB_DESC_TYPE_CONFIG, Index, 0, Buf, Desc.TotalLength);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "UsbGetOneConfig: failed to get full descript %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "UsbGetOneConfig: failed to get full descript %r\n", Status));
FreePool (Buf);
return NULL;
@@ -798,7 +796,6 @@ UsbGetOneConfig (
return Buf;
}
-
/**
Build the whole array of descriptors. This function must
be called after UsbGetMaxPacketSize0 returns the max packet
@@ -812,15 +809,15 @@ UsbGetOneConfig (
**/
EFI_STATUS
UsbBuildDescTable (
- IN USB_DEVICE *UsbDev
+ IN USB_DEVICE *UsbDev
)
{
- EFI_USB_CONFIG_DESCRIPTOR *Config;
- USB_DEVICE_DESC *DevDesc;
- USB_CONFIG_DESC *ConfigDesc;
- UINT8 NumConfig;
- EFI_STATUS Status;
- UINT8 Index;
+ EFI_USB_CONFIG_DESCRIPTOR *Config;
+ USB_DEVICE_DESC *DevDesc;
+ USB_CONFIG_DESC *ConfigDesc;
+ UINT8 NumConfig;
+ EFI_STATUS Status;
+ UINT8 Index;
//
// Get the device descriptor, then allocate the configure
@@ -829,7 +826,7 @@ UsbBuildDescTable (
Status = UsbGetDevDesc (UsbDev);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "UsbBuildDescTable: failed to get device descriptor - %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "UsbBuildDescTable: failed to get device descriptor - %r\n", Status));
return Status;
}
@@ -844,7 +841,7 @@ UsbBuildDescTable (
return EFI_OUT_OF_RESOURCES;
}
- DEBUG (( DEBUG_INFO, "UsbBuildDescTable: device has %d configures\n", NumConfig));
+ DEBUG ((DEBUG_INFO, "UsbBuildDescTable: device has %d configures\n", NumConfig));
//
// Read each configurations, then parse them
@@ -853,7 +850,7 @@ UsbBuildDescTable (
Config = UsbGetOneConfig (UsbDev, Index);
if (Config == NULL) {
- DEBUG (( DEBUG_ERROR, "UsbBuildDescTable: failed to get configure (index %d)\n", Index));
+ DEBUG ((DEBUG_ERROR, "UsbBuildDescTable: failed to get configure (index %d)\n", Index));
//
// If we can get the default descriptor, it is likely that the
@@ -866,12 +863,12 @@ UsbBuildDescTable (
break;
}
- ConfigDesc = UsbParseConfigDesc ((UINT8 *) Config, Config->TotalLength);
+ ConfigDesc = UsbParseConfigDesc ((UINT8 *)Config, Config->TotalLength);
FreePool (Config);
if (ConfigDesc == NULL) {
- DEBUG (( DEBUG_ERROR, "UsbBuildDescTable: failed to parse configure (index %d)\n", Index));
+ DEBUG ((DEBUG_ERROR, "UsbBuildDescTable: failed to parse configure (index %d)\n", Index));
//
// If we can get the default descriptor, it is likely that the
@@ -894,13 +891,12 @@ UsbBuildDescTable (
Status = UsbBuildLangTable (UsbDev);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_INFO, "UsbBuildDescTable: get language ID table %r\n", Status));
+ DEBUG ((DEBUG_INFO, "UsbBuildDescTable: get language ID table %r\n", Status));
}
return EFI_SUCCESS;
}
-
/**
Set the device's address.
@@ -913,11 +909,11 @@ UsbBuildDescTable (
**/
EFI_STATUS
UsbSetAddress (
- IN USB_DEVICE *UsbDev,
- IN UINT8 Address
+ IN USB_DEVICE *UsbDev,
+ IN UINT8 Address
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = UsbCtrlRequest (
UsbDev,
@@ -934,7 +930,6 @@ UsbSetAddress (
return Status;
}
-
/**
Set the device's configuration. This function changes
the device's internal state. UsbSelectConfig changes
@@ -949,11 +944,11 @@ UsbSetAddress (
**/
EFI_STATUS
UsbSetConfig (
- IN USB_DEVICE *UsbDev,
- IN UINT8 ConfigIndex
+ IN USB_DEVICE *UsbDev,
+ IN UINT8 ConfigIndex
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = UsbCtrlRequest (
UsbDev,
@@ -965,12 +960,11 @@ UsbSetConfig (
0,
NULL,
0
- );
+ );
return Status;
}
-
/**
Usb UsbIo interface to clear the feature. This is should
only be used by HUB which is considered a device driver
@@ -987,21 +981,21 @@ UsbSetConfig (
**/
EFI_STATUS
UsbIoClearFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINTN Target,
- IN UINT16 Feature,
- IN UINT16 Index
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINTN Target,
+ IN UINT16 Feature,
+ IN UINT16 Index
)
{
EFI_USB_DEVICE_REQUEST DevReq;
UINT32 UsbResult;
EFI_STATUS Status;
- DevReq.RequestType = USB_REQUEST_TYPE (EfiUsbNoData, USB_REQ_TYPE_STANDARD, Target);
- DevReq.Request = USB_REQ_CLEAR_FEATURE;
- DevReq.Value = Feature;
- DevReq.Index = Index;
- DevReq.Length = 0;
+ DevReq.RequestType = USB_REQUEST_TYPE (EfiUsbNoData, USB_REQ_TYPE_STANDARD, Target);
+ DevReq.Request = USB_REQ_CLEAR_FEATURE;
+ DevReq.Value = Feature;
+ DevReq.Index = Index;
+ DevReq.Length = 0;
Status = UsbIo->UsbControlTransfer (
UsbIo,
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.h b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.h
index 7b0c77f..ce205e7 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.h
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.h
@@ -26,12 +26,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
#pragma pack(1)
typedef struct {
- UINT8 Len;
- UINT8 Type;
+ UINT8 Len;
+ UINT8 Type;
} USB_DESC_HEAD;
#pragma pack()
-
//
// Each USB device has a device descriptor. Each device may
// have several configures. Each configure contains several
@@ -42,13 +41,13 @@ typedef struct {
// structure.
//
typedef struct {
- EFI_USB_ENDPOINT_DESCRIPTOR Desc;
- UINT8 Toggle;
+ EFI_USB_ENDPOINT_DESCRIPTOR Desc;
+ UINT8 Toggle;
} USB_ENDPOINT_DESC;
typedef struct {
- EFI_USB_INTERFACE_DESCRIPTOR Desc;
- USB_ENDPOINT_DESC **Endpoints;
+ EFI_USB_INTERFACE_DESCRIPTOR Desc;
+ USB_ENDPOINT_DESC **Endpoints;
} USB_INTERFACE_SETTING;
//
@@ -57,19 +56,19 @@ typedef struct {
// It should sufice in most environments.
//
typedef struct {
- USB_INTERFACE_SETTING* Settings[USB_MAX_INTERFACE_SETTING];
- UINTN NumOfSetting;
- UINTN ActiveIndex; // Index of active setting
+ USB_INTERFACE_SETTING *Settings[USB_MAX_INTERFACE_SETTING];
+ UINTN NumOfSetting;
+ UINTN ActiveIndex; // Index of active setting
} USB_INTERFACE_DESC;
typedef struct {
- EFI_USB_CONFIG_DESCRIPTOR Desc;
- USB_INTERFACE_DESC **Interfaces;
+ EFI_USB_CONFIG_DESCRIPTOR Desc;
+ USB_INTERFACE_DESC **Interfaces;
} USB_CONFIG_DESC;
typedef struct {
- EFI_USB_DEVICE_DESCRIPTOR Desc;
- USB_CONFIG_DESC **Configs;
+ EFI_USB_DEVICE_DESCRIPTOR Desc;
+ USB_CONFIG_DESC **Configs;
} USB_DEVICE_DESC;
/**
@@ -94,15 +93,15 @@ typedef struct {
**/
EFI_STATUS
UsbCtrlRequest (
- IN USB_DEVICE *UsbDev,
- IN EFI_USB_DATA_DIRECTION Direction,
- IN UINTN Type,
- IN UINTN Target,
- IN UINTN Request,
- IN UINT16 Value,
- IN UINT16 Index,
- IN OUT VOID *Buf,
- IN UINTN Length
+ IN USB_DEVICE *UsbDev,
+ IN EFI_USB_DATA_DIRECTION Direction,
+ IN UINTN Type,
+ IN UINTN Target,
+ IN UINTN Request,
+ IN UINT16 Value,
+ IN UINT16 Index,
+ IN OUT VOID *Buf,
+ IN UINTN Length
);
/**
@@ -118,7 +117,7 @@ UsbCtrlRequest (
**/
EFI_STATUS
UsbGetMaxPacketSize0 (
- IN USB_DEVICE *UsbDev
+ IN USB_DEVICE *UsbDev
);
/**
@@ -131,7 +130,7 @@ UsbGetMaxPacketSize0 (
**/
VOID
UsbFreeDevDesc (
- IN USB_DEVICE_DESC *DevDesc
+ IN USB_DEVICE_DESC *DevDesc
);
/**
@@ -146,11 +145,11 @@ UsbFreeDevDesc (
@return The created string descriptor or NULL.
**/
-EFI_USB_STRING_DESCRIPTOR*
+EFI_USB_STRING_DESCRIPTOR *
UsbGetOneString (
- IN USB_DEVICE *UsbDev,
- IN UINT8 StringIndex,
- IN UINT16 LangId
+ IN USB_DEVICE *UsbDev,
+ IN UINT8 StringIndex,
+ IN UINT16 LangId
);
/**
@@ -166,7 +165,7 @@ UsbGetOneString (
**/
EFI_STATUS
UsbBuildDescTable (
- IN USB_DEVICE *UsbDev
+ IN USB_DEVICE *UsbDev
);
/**
@@ -181,8 +180,8 @@ UsbBuildDescTable (
**/
EFI_STATUS
UsbSetAddress (
- IN USB_DEVICE *UsbDev,
- IN UINT8 Address
+ IN USB_DEVICE *UsbDev,
+ IN UINT8 Address
);
/**
@@ -199,8 +198,8 @@ UsbSetAddress (
**/
EFI_STATUS
UsbSetConfig (
- IN USB_DEVICE *UsbDev,
- IN UINT8 ConfigIndex
+ IN USB_DEVICE *UsbDev,
+ IN UINT8 ConfigIndex
);
/**
@@ -219,9 +218,10 @@ UsbSetConfig (
**/
EFI_STATUS
UsbIoClearFeature (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINTN Target,
- IN UINT16 Feature,
- IN UINT16 Index
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINTN Target,
+ IN UINT16 Feature,
+ IN UINT16 Index
);
+
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
index 500978a..5495b32 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
@@ -20,13 +20,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
USB_ENDPOINT_DESC *
UsbGetEndpointDesc (
- IN USB_INTERFACE *UsbIf,
- IN UINT8 EpAddr
+ IN USB_INTERFACE *UsbIf,
+ IN UINT8 EpAddr
)
{
- USB_ENDPOINT_DESC *EpDesc;
- UINT8 Index;
- UINT8 NumEndpoints;
+ USB_ENDPOINT_DESC *EpDesc;
+ UINT8 Index;
+ UINT8 NumEndpoints;
NumEndpoints = UsbIf->IfSetting->Desc.NumEndpoints;
@@ -41,7 +41,6 @@ UsbGetEndpointDesc (
return NULL;
}
-
/**
Free the resource used by USB interface.
@@ -52,31 +51,34 @@ UsbGetEndpointDesc (
**/
EFI_STATUS
UsbFreeInterface (
- IN USB_INTERFACE *UsbIf
+ IN USB_INTERFACE *UsbIf
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
UsbCloseHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle);
Status = gBS->UninstallMultipleProtocolInterfaces (
UsbIf->Handle,
- &gEfiDevicePathProtocolGuid, UsbIf->DevicePath,
- &gEfiUsbIoProtocolGuid, &UsbIf->UsbIo,
+ &gEfiDevicePathProtocolGuid,
+ UsbIf->DevicePath,
+ &gEfiUsbIoProtocolGuid,
+ &UsbIf->UsbIo,
NULL
);
if (!EFI_ERROR (Status)) {
if (UsbIf->DevicePath != NULL) {
FreePool (UsbIf->DevicePath);
}
+
FreePool (UsbIf);
} else {
UsbOpenHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle);
}
+
return Status;
}
-
/**
Create an interface for the descriptor IfDesc. Each
device's configuration can have several interfaces.
@@ -89,14 +91,14 @@ UsbFreeInterface (
**/
USB_INTERFACE *
UsbCreateInterface (
- IN USB_DEVICE *Device,
- IN USB_INTERFACE_DESC *IfDesc
+ IN USB_DEVICE *Device,
+ IN USB_INTERFACE_DESC *IfDesc
)
{
- USB_DEVICE_PATH UsbNode;
- USB_INTERFACE *UsbIf;
- USB_INTERFACE *HubIf;
- EFI_STATUS Status;
+ USB_DEVICE_PATH UsbNode;
+ USB_INTERFACE *UsbIf;
+ USB_INTERFACE *HubIf;
+ EFI_STATUS Status;
UsbIf = AllocateZeroPool (sizeof (USB_INTERFACE));
@@ -104,11 +106,11 @@ UsbCreateInterface (
return NULL;
}
- UsbIf->Signature = USB_INTERFACE_SIGNATURE;
- UsbIf->Device = Device;
- UsbIf->IfDesc = IfDesc;
+ UsbIf->Signature = USB_INTERFACE_SIGNATURE;
+ UsbIf->Device = Device;
+ UsbIf->IfDesc = IfDesc;
ASSERT (IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);
- UsbIf->IfSetting = IfDesc->Settings[IfDesc->ActiveIndex];
+ UsbIf->IfSetting = IfDesc->Settings[IfDesc->ActiveIndex];
CopyMem (
&(UsbIf->UsbIo),
@@ -119,10 +121,10 @@ UsbCreateInterface (
//
// Install protocols for USBIO and device path
//
- UsbNode.Header.Type = MESSAGING_DEVICE_PATH;
- UsbNode.Header.SubType = MSG_USB_DP;
- UsbNode.ParentPortNumber = Device->ParentPort;
- UsbNode.InterfaceNumber = UsbIf->IfSetting->Desc.InterfaceNumber;
+ UsbNode.Header.Type = MESSAGING_DEVICE_PATH;
+ UsbNode.Header.SubType = MSG_USB_DP;
+ UsbNode.ParentPortNumber = Device->ParentPort;
+ UsbNode.InterfaceNumber = UsbIf->IfSetting->Desc.InterfaceNumber;
SetDevicePathNodeLength (&UsbNode.Header, sizeof (UsbNode));
@@ -182,7 +184,6 @@ ON_ERROR:
return NULL;
}
-
/**
Free the resource used by this USB device.
@@ -191,7 +192,7 @@ ON_ERROR:
**/
VOID
UsbFreeDevice (
- IN USB_DEVICE *Device
+ IN USB_DEVICE *Device
)
{
if (Device->DevDesc != NULL) {
@@ -201,7 +202,6 @@ UsbFreeDevice (
gBS->FreePool (Device);
}
-
/**
Create a device which is on the parent's ParentPort port.
@@ -213,11 +213,11 @@ UsbFreeDevice (
**/
USB_DEVICE *
UsbCreateDevice (
- IN USB_INTERFACE *ParentIf,
- IN UINT8 ParentPort
+ IN USB_INTERFACE *ParentIf,
+ IN UINT8 ParentPort
)
{
- USB_DEVICE *Device;
+ USB_DEVICE *Device;
ASSERT (ParentIf != NULL);
@@ -227,16 +227,15 @@ UsbCreateDevice (
return NULL;
}
- Device->Bus = ParentIf->Device->Bus;
- Device->MaxPacket0 = 8;
- Device->ParentAddr = ParentIf->Device->Address;
- Device->ParentIf = ParentIf;
- Device->ParentPort = ParentPort;
- Device->Tier = (UINT8)(ParentIf->Device->Tier + 1);
+ Device->Bus = ParentIf->Device->Bus;
+ Device->MaxPacket0 = 8;
+ Device->ParentAddr = ParentIf->Device->Address;
+ Device->ParentIf = ParentIf;
+ Device->ParentPort = ParentPort;
+ Device->Tier = (UINT8)(ParentIf->Device->Tier + 1);
return Device;
}
-
/**
Connect the USB interface with its driver. EFI USB bus will
create a USB interface for each separate interface descriptor.
@@ -249,11 +248,11 @@ UsbCreateDevice (
**/
EFI_STATUS
UsbConnectDriver (
- IN USB_INTERFACE *UsbIf
+ IN USB_INTERFACE *UsbIf
)
{
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
Status = EFI_SUCCESS;
@@ -264,7 +263,6 @@ UsbConnectDriver (
if (UsbIsHubInterface (UsbIf)) {
DEBUG ((DEBUG_INFO, "UsbConnectDriver: found a hub device\n"));
Status = mUsbHubApi.Init (UsbIf);
-
} else {
//
// This function is called in both UsbIoControlTransfer and
@@ -278,15 +276,15 @@ UsbConnectDriver (
// Only recursively wanted usb child device
//
if (UsbBusIsWantedUsbIO (UsbIf->Device->Bus, UsbIf)) {
- OldTpl = UsbGetCurrentTpl ();
+ OldTpl = UsbGetCurrentTpl ();
DEBUG ((DEBUG_INFO, "UsbConnectDriver: TPL before connect is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle));
gBS->RestoreTPL (TPL_CALLBACK);
- Status = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);
- UsbIf->IsManaged = (BOOLEAN)!EFI_ERROR (Status);
+ Status = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);
+ UsbIf->IsManaged = (BOOLEAN) !EFI_ERROR (Status);
- DEBUG ((DEBUG_INFO, "UsbConnectDriver: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl()));
+ DEBUG ((DEBUG_INFO, "UsbConnectDriver: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl ()));
ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK);
gBS->RaiseTPL (OldTpl);
@@ -296,7 +294,6 @@ UsbConnectDriver (
return Status;
}
-
/**
Select an alternate setting for the interface.
Each interface can have several mutually exclusive
@@ -312,12 +309,12 @@ UsbConnectDriver (
**/
EFI_STATUS
UsbSelectSetting (
- IN USB_INTERFACE_DESC *IfDesc,
- IN UINT8 Alternate
+ IN USB_INTERFACE_DESC *IfDesc,
+ IN UINT8 Alternate
)
{
- USB_INTERFACE_SETTING *Setting;
- UINTN Index;
+ USB_INTERFACE_SETTING *Setting;
+ UINTN Index;
//
// Locate the active alternate setting
@@ -340,8 +337,12 @@ UsbSelectSetting (
IfDesc->ActiveIndex = Index;
ASSERT (Setting != NULL);
- DEBUG ((DEBUG_INFO, "UsbSelectSetting: setting %d selected for interface %d\n",
- Alternate, Setting->Desc.InterfaceNumber));
+ DEBUG ((
+ DEBUG_INFO,
+ "UsbSelectSetting: setting %d selected for interface %d\n",
+ Alternate,
+ Setting->Desc.InterfaceNumber
+ ));
//
// Reset the endpoint toggle to zero
@@ -353,7 +354,6 @@ UsbSelectSetting (
return EFI_SUCCESS;
}
-
/**
Select a new configuration for the device. Each
device may support several configurations.
@@ -368,22 +368,22 @@ UsbSelectSetting (
**/
EFI_STATUS
UsbSelectConfig (
- IN USB_DEVICE *Device,
- IN UINT8 ConfigValue
+ IN USB_DEVICE *Device,
+ IN UINT8 ConfigValue
)
{
- USB_DEVICE_DESC *DevDesc;
- USB_CONFIG_DESC *ConfigDesc;
- USB_INTERFACE_DESC *IfDesc;
- USB_INTERFACE *UsbIf;
- EFI_STATUS Status;
- UINT8 Index;
+ USB_DEVICE_DESC *DevDesc;
+ USB_CONFIG_DESC *ConfigDesc;
+ USB_INTERFACE_DESC *IfDesc;
+ USB_INTERFACE *UsbIf;
+ EFI_STATUS Status;
+ UINT8 Index;
//
// Locate the active config, then set the device's pointer
//
- DevDesc = Device->DevDesc;
- ConfigDesc = NULL;
+ DevDesc = Device->DevDesc;
+ ConfigDesc = NULL;
for (Index = 0; Index < DevDesc->Desc.NumConfigurations; Index++) {
ConfigDesc = DevDesc->Configs[Index];
@@ -399,8 +399,12 @@ UsbSelectConfig (
Device->ActiveConfig = ConfigDesc;
- DEBUG ((DEBUG_INFO, "UsbSelectConfig: config %d selected for device %d\n",
- ConfigValue, Device->Address));
+ DEBUG ((
+ DEBUG_INFO,
+ "UsbSelectConfig: config %d selected for device %d\n",
+ ConfigValue,
+ Device->Address
+ ));
//
// Create interfaces for each USB interface descriptor.
@@ -447,7 +451,6 @@ UsbSelectConfig (
return EFI_SUCCESS;
}
-
/**
Disconnect the USB interface with its driver.
@@ -456,11 +459,11 @@ UsbSelectConfig (
**/
EFI_STATUS
UsbDisconnectDriver (
- IN USB_INTERFACE *UsbIf
+ IN USB_INTERFACE *UsbIf
)
{
- EFI_TPL OldTpl;
- EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
//
// Release the hub if it's a hub controller, otherwise
@@ -469,7 +472,6 @@ UsbDisconnectDriver (
Status = EFI_SUCCESS;
if (UsbIf->IsHub) {
Status = UsbIf->HubApi->Release (UsbIf);
-
} else if (UsbIf->IsManaged) {
//
// This function is called in both UsbIoControlTransfer and
@@ -478,7 +480,7 @@ UsbDisconnectDriver (
// twisted TPL used. It should be no problem for us to connect
// or disconnect at CALLBACK.
//
- OldTpl = UsbGetCurrentTpl ();
+ OldTpl = UsbGetCurrentTpl ();
DEBUG ((DEBUG_INFO, "UsbDisconnectDriver: old TPL is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle));
gBS->RestoreTPL (TPL_CALLBACK);
@@ -488,7 +490,7 @@ UsbDisconnectDriver (
UsbIf->IsManaged = FALSE;
}
- DEBUG (( DEBUG_INFO, "UsbDisconnectDriver: TPL after disconnect is %d, %d\n", (UINT32)UsbGetCurrentTpl(), Status));
+ DEBUG ((DEBUG_INFO, "UsbDisconnectDriver: TPL after disconnect is %d, %d\n", (UINT32)UsbGetCurrentTpl (), Status));
ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK);
gBS->RaiseTPL (OldTpl);
@@ -497,7 +499,6 @@ UsbDisconnectDriver (
return Status;
}
-
/**
Remove the current device configuration.
@@ -506,13 +507,13 @@ UsbDisconnectDriver (
**/
EFI_STATUS
UsbRemoveConfig (
- IN USB_DEVICE *Device
+ IN USB_DEVICE *Device
)
{
- USB_INTERFACE *UsbIf;
- UINTN Index;
- EFI_STATUS Status;
- EFI_STATUS ReturnStatus;
+ USB_INTERFACE *UsbIf;
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_STATUS ReturnStatus;
//
// Remove each interface of the device
@@ -541,11 +542,10 @@ UsbRemoveConfig (
}
}
- Device->ActiveConfig = NULL;
+ Device->ActiveConfig = NULL;
return ReturnStatus;
}
-
/**
Remove the device and all its children from the bus.
@@ -556,14 +556,14 @@ UsbRemoveConfig (
**/
EFI_STATUS
UsbRemoveDevice (
- IN USB_DEVICE *Device
+ IN USB_DEVICE *Device
)
{
- USB_BUS *Bus;
- USB_DEVICE *Child;
- EFI_STATUS Status;
- EFI_STATUS ReturnStatus;
- UINTN Index;
+ USB_BUS *Bus;
+ USB_DEVICE *Child;
+ EFI_STATUS Status;
+ EFI_STATUS ReturnStatus;
+ UINTN Index;
Bus = Device->Bus;
@@ -585,7 +585,7 @@ UsbRemoveDevice (
Bus->Devices[Index] = NULL;
} else {
Bus->Devices[Index]->DisconnectFail = TRUE;
- ReturnStatus = Status;
+ ReturnStatus = Status;
DEBUG ((DEBUG_INFO, "UsbRemoveDevice: failed to remove child %p at parent %p\n", Child, Device));
}
}
@@ -597,7 +597,7 @@ UsbRemoveDevice (
Status = UsbRemoveConfig (Device);
if (!EFI_ERROR (Status)) {
- DEBUG (( DEBUG_INFO, "UsbRemoveDevice: device %d removed\n", Device->Address));
+ DEBUG ((DEBUG_INFO, "UsbRemoveDevice: device %d removed\n", Device->Address));
ASSERT (Device->Address < Bus->MaxDevices);
Bus->Devices[Device->Address] = NULL;
@@ -605,10 +605,10 @@ UsbRemoveDevice (
} else {
Bus->Devices[Device->Address]->DisconnectFail = TRUE;
}
+
return Status;
}
-
/**
Find the child device on the hub's port.
@@ -620,13 +620,13 @@ UsbRemoveDevice (
**/
USB_DEVICE *
UsbFindChild (
- IN USB_INTERFACE *HubIf,
- IN UINT8 Port
+ IN USB_INTERFACE *HubIf,
+ IN UINT8 Port
)
{
- USB_DEVICE *Device;
- USB_BUS *Bus;
- UINTN Index;
+ USB_DEVICE *Device;
+ USB_BUS *Bus;
+ UINTN Index;
Bus = HubIf->Device->Bus;
@@ -637,8 +637,8 @@ UsbFindChild (
Device = Bus->Devices[Index];
if ((Device != NULL) && (Device->ParentAddr == HubIf->Device->Address) &&
- (Device->ParentPort == Port)) {
-
+ (Device->ParentPort == Port))
+ {
return Device;
}
}
@@ -646,7 +646,6 @@ UsbFindChild (
return NULL;
}
-
/**
Enumerate and configure the new device on the port of this HUB interface.
@@ -661,19 +660,19 @@ UsbFindChild (
**/
EFI_STATUS
UsbEnumerateNewDev (
- IN USB_INTERFACE *HubIf,
- IN UINT8 Port,
- IN BOOLEAN ResetIsNeeded
+ IN USB_INTERFACE *HubIf,
+ IN UINT8 Port,
+ IN BOOLEAN ResetIsNeeded
)
{
- USB_BUS *Bus;
- USB_HUB_API *HubApi;
- USB_DEVICE *Child;
- USB_DEVICE *Parent;
- EFI_USB_PORT_STATUS PortState;
- UINTN Address;
- UINT8 Config;
- EFI_STATUS Status;
+ USB_BUS *Bus;
+ USB_HUB_API *HubApi;
+ USB_DEVICE *Child;
+ USB_DEVICE *Parent;
+ EFI_USB_PORT_STATUS PortState;
+ UINTN Address;
+ UINT8 Config;
+ EFI_STATUS Status;
Parent = HubIf->Device;
Bus = Parent->Bus;
@@ -695,9 +694,10 @@ UsbEnumerateNewDev (
return Status;
}
- DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: hub port %d is reset\n", Port));
+
+ DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: hub port %d is reset\n", Port));
} else {
- DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: hub port %d reset is skipped\n", Port));
+ DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: hub port %d reset is skipped\n", Port));
}
Child = UsbCreateDevice (HubIf, Port);
@@ -721,7 +721,7 @@ UsbEnumerateNewDev (
DEBUG ((DEBUG_ERROR, "UsbEnumerateNewDev: No device present at port %d\n", Port));
Status = EFI_NOT_FOUND;
goto ON_ERROR;
- } else if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_SUPER_SPEED)){
+ } else if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_SUPER_SPEED)) {
Child->Speed = EFI_USB_SPEED_SUPER;
Child->MaxPacket0 = 512;
} else if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_HIGH_SPEED)) {
@@ -735,10 +735,11 @@ UsbEnumerateNewDev (
Child->MaxPacket0 = 8;
}
- DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: device is of %d speed\n", Child->Speed));
+ DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: device is of %d speed\n", Child->Speed));
if (((Child->Speed == EFI_USB_SPEED_LOW) || (Child->Speed == EFI_USB_SPEED_FULL)) &&
- (Parent->Speed == EFI_USB_SPEED_HIGH)) {
+ (Parent->Speed == EFI_USB_SPEED_HIGH))
+ {
//
// If the child is a low or full speed device, it is necessary to
// set the transaction translator. Port TT is 1-based.
@@ -746,14 +747,18 @@ UsbEnumerateNewDev (
// 1. if parent is of high speed, then parent is our translator
// 2. otherwise use parent's translator.
//
- Child->Translator.TranslatorHubAddress = Parent->Address;
- Child->Translator.TranslatorPortNumber = (UINT8) (Port + 1);
+ Child->Translator.TranslatorHubAddress = Parent->Address;
+ Child->Translator.TranslatorPortNumber = (UINT8)(Port + 1);
} else {
Child->Translator = Parent->Translator;
}
- DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: device uses translator (%d, %d)\n",
- Child->Translator.TranslatorHubAddress,
- Child->Translator.TranslatorPortNumber));
+
+ DEBUG ((
+ DEBUG_INFO,
+ "UsbEnumerateNewDev: device uses translator (%d, %d)\n",
+ Child->Translator.TranslatorHubAddress,
+ Child->Translator.TranslatorPortNumber
+ ));
//
// After port is reset, hub establishes a signal path between
@@ -805,7 +810,7 @@ UsbEnumerateNewDev (
goto ON_ERROR;
}
- DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: max packet size for EP 0 is %d\n", Child->MaxPacket0));
+ DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: max packet size for EP 0 is %d\n", Child->MaxPacket0));
//
// Host learns about the device's abilities by requesting device's
@@ -830,7 +835,7 @@ UsbEnumerateNewDev (
goto ON_ERROR;
}
- DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: device %d is now in CONFIGED state\n", Address));
+ DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: device %d is now in CONFIGED state\n", Address));
//
// Host assigns and loads a device driver.
@@ -870,7 +875,6 @@ ON_ERROR:
return Status;
}
-
/**
Process the events on the port.
@@ -884,17 +888,17 @@ ON_ERROR:
**/
EFI_STATUS
UsbEnumeratePort (
- IN USB_INTERFACE *HubIf,
- IN UINT8 Port
+ IN USB_INTERFACE *HubIf,
+ IN UINT8 Port
)
{
- USB_HUB_API *HubApi;
- USB_DEVICE *Child;
- EFI_USB_PORT_STATUS PortState;
- EFI_STATUS Status;
+ USB_HUB_API *HubApi;
+ USB_DEVICE *Child;
+ EFI_USB_PORT_STATUS PortState;
+ EFI_STATUS Status;
- Child = NULL;
- HubApi = HubIf->HubApi;
+ Child = NULL;
+ HubApi = HubIf->HubApi;
//
// Host learns of the new device by polling the hub for port changes.
@@ -914,8 +918,14 @@ UsbEnumeratePort (
return EFI_SUCCESS;
}
- DEBUG (( DEBUG_INFO, "UsbEnumeratePort: port %d state - %02x, change - %02x on %p\n",
- Port, PortState.PortStatus, PortState.PortChangeStatus, HubIf));
+ DEBUG ((
+ DEBUG_INFO,
+ "UsbEnumeratePort: port %d state - %02x, change - %02x on %p\n",
+ Port,
+ PortState.PortStatus,
+ PortState.PortChangeStatus,
+ HubIf
+ ));
//
// This driver only process two kinds of events now: over current and
@@ -924,7 +934,6 @@ UsbEnumeratePort (
//
if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_OVERCURRENT)) {
-
if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_OVERCURRENT)) {
//
// Case1:
@@ -932,17 +941,17 @@ UsbEnumeratePort (
// which probably is caused by short circuit. It has to wait system hardware
// to perform recovery.
//
- DEBUG (( DEBUG_ERROR, "UsbEnumeratePort: Critical Over Current\n", Port));
+ DEBUG ((DEBUG_ERROR, "UsbEnumeratePort: Critical Over Current\n", Port));
return EFI_DEVICE_ERROR;
-
}
+
//
// Case2:
// Only OverCurrentChange set, means system has been recoveried from
// over current. As a result, all ports are nearly power-off, so
// it's necessary to detach and enumerate all ports again.
//
- DEBUG (( DEBUG_ERROR, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port));
+ DEBUG ((DEBUG_ERROR, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port));
}
if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_ENABLE)) {
@@ -952,7 +961,7 @@ UsbEnumeratePort (
// on 2.0 roothub does. When over-current has influence on 1.1 device, the port
// would be disabled, so it's also necessary to detach and enumerate again.
//
- DEBUG (( DEBUG_ERROR, "UsbEnumeratePort: 1.1 device Recovery Over Current\n", Port));
+ DEBUG ((DEBUG_ERROR, "UsbEnumeratePort: 1.1 device Recovery Over Current\n", Port));
}
if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_CONNECTION)) {
@@ -969,7 +978,7 @@ UsbEnumeratePort (
Child = UsbFindChild (HubIf, Port);
if (Child != NULL) {
- DEBUG (( DEBUG_INFO, "UsbEnumeratePort: device at port %d removed from root hub %p\n", Port, HubIf));
+ DEBUG ((DEBUG_INFO, "UsbEnumeratePort: device at port %d removed from root hub %p\n", Port, HubIf));
UsbRemoveDevice (Child);
}
@@ -977,22 +986,20 @@ UsbEnumeratePort (
//
// Now, new device connected, enumerate and configure the device
//
- DEBUG (( DEBUG_INFO, "UsbEnumeratePort: new device connected at port %d\n", Port));
+ DEBUG ((DEBUG_INFO, "UsbEnumeratePort: new device connected at port %d\n", Port));
if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_RESET)) {
Status = UsbEnumerateNewDev (HubIf, Port, FALSE);
} else {
Status = UsbEnumerateNewDev (HubIf, Port, TRUE);
}
-
} else {
- DEBUG (( DEBUG_INFO, "UsbEnumeratePort: device disconnected event on port %d\n", Port));
+ DEBUG ((DEBUG_INFO, "UsbEnumeratePort: device disconnected event on port %d\n", Port));
}
HubApi->ClearPortChange (HubIf, Port);
return Status;
}
-
/**
Enumerate all the changed hub ports.
@@ -1003,37 +1010,37 @@ UsbEnumeratePort (
VOID
EFIAPI
UsbHubEnumeration (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- USB_INTERFACE *HubIf;
- UINT8 Byte;
- UINT8 Bit;
- UINT8 Index;
- USB_DEVICE *Child;
+ USB_INTERFACE *HubIf;
+ UINT8 Byte;
+ UINT8 Bit;
+ UINT8 Index;
+ USB_DEVICE *Child;
ASSERT (Context != NULL);
- HubIf = (USB_INTERFACE *) Context;
+ HubIf = (USB_INTERFACE *)Context;
for (Index = 0; Index < HubIf->NumOfPort; Index++) {
Child = UsbFindChild (HubIf, Index);
if ((Child != NULL) && (Child->DisconnectFail == TRUE)) {
- DEBUG (( DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from hub %p, try again\n", Index, HubIf));
+ DEBUG ((DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from hub %p, try again\n", Index, HubIf));
UsbRemoveDevice (Child);
}
}
if (HubIf->ChangeMap == NULL) {
- return ;
+ return;
}
//
// HUB starts its port index with 1.
//
- Byte = 0;
- Bit = 1;
+ Byte = 0;
+ Bit = 1;
for (Index = 0; Index < HubIf->NumOfPort; Index++) {
if (USB_BIT_IS_SET (HubIf->ChangeMap[Byte], USB_BIT (Bit))) {
@@ -1047,10 +1054,9 @@ UsbHubEnumeration (
gBS->FreePool (HubIf->ChangeMap);
HubIf->ChangeMap = NULL;
- return ;
+ return;
}
-
/**
Enumerate all the changed hub ports.
@@ -1061,20 +1067,20 @@ UsbHubEnumeration (
VOID
EFIAPI
UsbRootHubEnumeration (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- USB_INTERFACE *RootHub;
- UINT8 Index;
- USB_DEVICE *Child;
+ USB_INTERFACE *RootHub;
+ UINT8 Index;
+ USB_DEVICE *Child;
- RootHub = (USB_INTERFACE *) Context;
+ RootHub = (USB_INTERFACE *)Context;
for (Index = 0; Index < RootHub->NumOfPort; Index++) {
Child = UsbFindChild (RootHub, Index);
if ((Child != NULL) && (Child->DisconnectFail == TRUE)) {
- DEBUG (( DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from root hub %p, try again\n", Index, RootHub));
+ DEBUG ((DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from root hub %p, try again\n", Index, RootHub));
UsbRemoveDevice (Child);
}
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.h b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.h
index eaba243..51c204b 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.h
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.h
@@ -22,7 +22,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
} \
} while (0)
-
//
// Common interface used by usb bus enumeration process.
// This interface is defined to mask the difference between
@@ -32,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
typedef
EFI_STATUS
(*USB_HUB_INIT) (
- IN USB_INTERFACE *UsbIf
+ IN USB_INTERFACE *UsbIf
);
//
@@ -44,45 +43,45 @@ EFI_STATUS
typedef
EFI_STATUS
(*USB_HUB_GET_PORT_STATUS) (
- IN USB_INTERFACE *UsbIf,
- IN UINT8 Port,
- OUT EFI_USB_PORT_STATUS *PortState
+ IN USB_INTERFACE *UsbIf,
+ IN UINT8 Port,
+ OUT EFI_USB_PORT_STATUS *PortState
);
typedef
VOID
(*USB_HUB_CLEAR_PORT_CHANGE) (
- IN USB_INTERFACE *HubIf,
- IN UINT8 Port
+ IN USB_INTERFACE *HubIf,
+ IN UINT8 Port
);
typedef
EFI_STATUS
(*USB_HUB_SET_PORT_FEATURE) (
- IN USB_INTERFACE *UsbIf,
- IN UINT8 Port,
- IN EFI_USB_PORT_FEATURE Feature
+ IN USB_INTERFACE *UsbIf,
+ IN UINT8 Port,
+ IN EFI_USB_PORT_FEATURE Feature
);
typedef
EFI_STATUS
(*USB_HUB_CLEAR_PORT_FEATURE) (
- IN USB_INTERFACE *UsbIf,
- IN UINT8 Port,
- IN EFI_USB_PORT_FEATURE Feature
+ IN USB_INTERFACE *UsbIf,
+ IN UINT8 Port,
+ IN EFI_USB_PORT_FEATURE Feature
);
typedef
EFI_STATUS
(*USB_HUB_RESET_PORT) (
- IN USB_INTERFACE *UsbIf,
- IN UINT8 Port
+ IN USB_INTERFACE *UsbIf,
+ IN UINT8 Port
);
typedef
EFI_STATUS
(*USB_HUB_RELEASE) (
- IN USB_INTERFACE *UsbIf
+ IN USB_INTERFACE *UsbIf
);
/**
@@ -94,10 +93,10 @@ EFI_STATUS
@return The endpoint descriptor or NULL.
**/
-USB_ENDPOINT_DESC*
+USB_ENDPOINT_DESC *
UsbGetEndpointDesc (
- IN USB_INTERFACE *UsbIf,
- IN UINT8 EpAddr
+ IN USB_INTERFACE *UsbIf,
+ IN UINT8 EpAddr
);
/**
@@ -115,8 +114,8 @@ UsbGetEndpointDesc (
**/
EFI_STATUS
UsbSelectSetting (
- IN USB_INTERFACE_DESC *IfDesc,
- IN UINT8 Alternate
+ IN USB_INTERFACE_DESC *IfDesc,
+ IN UINT8 Alternate
);
/**
@@ -133,8 +132,8 @@ UsbSelectSetting (
**/
EFI_STATUS
UsbSelectConfig (
- IN USB_DEVICE *Device,
- IN UINT8 ConfigIndex
+ IN USB_DEVICE *Device,
+ IN UINT8 ConfigIndex
);
/**
@@ -147,7 +146,7 @@ UsbSelectConfig (
**/
EFI_STATUS
UsbRemoveConfig (
- IN USB_DEVICE *Device
+ IN USB_DEVICE *Device
);
/**
@@ -160,7 +159,7 @@ UsbRemoveConfig (
**/
EFI_STATUS
UsbRemoveDevice (
- IN USB_DEVICE *Device
+ IN USB_DEVICE *Device
);
/**
@@ -175,8 +174,8 @@ UsbRemoveDevice (
VOID
EFIAPI
UsbHubEnumeration (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -191,7 +190,8 @@ UsbHubEnumeration (
VOID
EFIAPI
UsbRootHubEnumeration (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
+
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
index 022bab5..0497a73 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
@@ -17,19 +17,19 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// bit maps.
//
USB_CHANGE_FEATURE_MAP mHubFeatureMap[] = {
- {USB_PORT_STAT_C_CONNECTION, EfiUsbPortConnectChange},
- {USB_PORT_STAT_C_ENABLE, EfiUsbPortEnableChange},
- {USB_PORT_STAT_C_SUSPEND, EfiUsbPortSuspendChange},
- {USB_PORT_STAT_C_OVERCURRENT, EfiUsbPortOverCurrentChange},
- {USB_PORT_STAT_C_RESET, EfiUsbPortResetChange}
+ { USB_PORT_STAT_C_CONNECTION, EfiUsbPortConnectChange },
+ { USB_PORT_STAT_C_ENABLE, EfiUsbPortEnableChange },
+ { USB_PORT_STAT_C_SUSPEND, EfiUsbPortSuspendChange },
+ { USB_PORT_STAT_C_OVERCURRENT, EfiUsbPortOverCurrentChange },
+ { USB_PORT_STAT_C_RESET, EfiUsbPortResetChange }
};
USB_CHANGE_FEATURE_MAP mRootHubFeatureMap[] = {
- {USB_PORT_STAT_C_CONNECTION, EfiUsbPortConnectChange},
- {USB_PORT_STAT_C_ENABLE, EfiUsbPortEnableChange},
- {USB_PORT_STAT_C_SUSPEND, EfiUsbPortSuspendChange},
- {USB_PORT_STAT_C_OVERCURRENT, EfiUsbPortOverCurrentChange},
- {USB_PORT_STAT_C_RESET, EfiUsbPortResetChange},
+ { USB_PORT_STAT_C_CONNECTION, EfiUsbPortConnectChange },
+ { USB_PORT_STAT_C_ENABLE, EfiUsbPortEnableChange },
+ { USB_PORT_STAT_C_SUSPEND, EfiUsbPortSuspendChange },
+ { USB_PORT_STAT_C_OVERCURRENT, EfiUsbPortOverCurrentChange },
+ { USB_PORT_STAT_C_RESET, EfiUsbPortResetChange },
};
//
@@ -37,6 +37,7 @@ USB_CHANGE_FEATURE_MAP mRootHubFeatureMap[] = {
// is related to an interface, these requests are sent
// to the control endpoint of the device.
//
+
/**
USB hub control transfer to set the hub depth.
@@ -49,11 +50,11 @@ USB_CHANGE_FEATURE_MAP mRootHubFeatureMap[] = {
**/
EFI_STATUS
UsbHubCtrlSetHubDepth (
- IN USB_DEVICE *HubDev,
- IN UINT16 Depth
+ IN USB_DEVICE *HubDev,
+ IN UINT16 Depth
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = UsbCtrlRequest (
HubDev,
@@ -82,11 +83,11 @@ UsbHubCtrlSetHubDepth (
**/
EFI_STATUS
UsbHubCtrlClearHubFeature (
- IN USB_DEVICE *HubDev,
- IN UINT16 Feature
+ IN USB_DEVICE *HubDev,
+ IN UINT16 Feature
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = UsbCtrlRequest (
HubDev,
@@ -103,7 +104,6 @@ UsbHubCtrlClearHubFeature (
return Status;
}
-
/**
Clear the feature of the device's port.
@@ -117,12 +117,12 @@ UsbHubCtrlClearHubFeature (
**/
EFI_STATUS
UsbHubCtrlClearPortFeature (
- IN USB_DEVICE *HubDev,
- IN UINT8 Port,
- IN UINT16 Feature
+ IN USB_DEVICE *HubDev,
+ IN UINT8 Port,
+ IN UINT16 Feature
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// In USB bus, all the port index starts from 0. But HUB
@@ -135,7 +135,7 @@ UsbHubCtrlClearPortFeature (
USB_HUB_TARGET_PORT,
USB_HUB_REQ_CLEAR_FEATURE,
Feature,
- (UINT16) (Port + 1),
+ (UINT16)(Port + 1),
NULL,
0
);
@@ -143,7 +143,6 @@ UsbHubCtrlClearPortFeature (
return Status;
}
-
/**
Clear the transaction translate buffer if full/low
speed control/bulk transfer failed and the transfer
@@ -163,21 +162,21 @@ UsbHubCtrlClearPortFeature (
**/
EFI_STATUS
UsbHubCtrlClearTTBuffer (
- IN USB_DEVICE *HubDev,
- IN UINT8 Port,
- IN UINT16 DevAddr,
- IN UINT16 EpNum,
- IN UINT16 EpType
+ IN USB_DEVICE *HubDev,
+ IN UINT8 Port,
+ IN UINT16 DevAddr,
+ IN UINT16 EpNum,
+ IN UINT16 EpType
)
{
- EFI_STATUS Status;
- UINT16 Value;
+ EFI_STATUS Status;
+ UINT16 Value;
//
// Check USB2.0 spec page 424 for wValue's encoding
//
- Value = (UINT16) ((EpNum & 0x0F) | (DevAddr << 4) |
- ((EpType & 0x03) << 11) | ((EpNum & 0x80) << 15));
+ Value = (UINT16)((EpNum & 0x0F) | (DevAddr << 4) |
+ ((EpType & 0x03) << 11) | ((EpNum & 0x80) << 15));
Status = UsbCtrlRequest (
HubDev,
@@ -186,7 +185,7 @@ UsbHubCtrlClearTTBuffer (
USB_HUB_TARGET_PORT,
USB_HUB_REQ_CLEAR_TT,
Value,
- (UINT16) (Port + 1),
+ (UINT16)(Port + 1),
NULL,
0
);
@@ -207,13 +206,13 @@ UsbHubCtrlClearTTBuffer (
**/
EFI_STATUS
UsbHubCtrlGetHubDesc (
- IN USB_DEVICE *HubDev,
- OUT VOID *Buf,
- IN UINTN Len
+ IN USB_DEVICE *HubDev,
+ OUT VOID *Buf,
+ IN UINTN Len
)
{
- EFI_STATUS Status;
- UINT8 DescType;
+ EFI_STATUS Status;
+ UINT8 DescType;
DescType = (HubDev->Speed == EFI_USB_SPEED_SUPER) ?
USB_DESC_TYPE_HUB_SUPER_SPEED :
@@ -225,7 +224,7 @@ UsbHubCtrlGetHubDesc (
USB_REQ_TYPE_CLASS,
USB_HUB_TARGET_HUB,
USB_HUB_REQ_GET_DESC,
- (UINT16) (DescType << 8),
+ (UINT16)(DescType << 8),
0,
Buf,
Len
@@ -234,7 +233,6 @@ UsbHubCtrlGetHubDesc (
return Status;
}
-
/**
Usb hub control transfer to get the hub status.
@@ -247,11 +245,11 @@ UsbHubCtrlGetHubDesc (
**/
EFI_STATUS
UsbHubCtrlGetHubStatus (
- IN USB_DEVICE *HubDev,
- OUT UINT32 *State
+ IN USB_DEVICE *HubDev,
+ OUT UINT32 *State
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = UsbCtrlRequest (
HubDev,
@@ -268,7 +266,6 @@ UsbHubCtrlGetHubStatus (
return Status;
}
-
/**
Usb hub control transfer to get the port status.
@@ -282,12 +279,12 @@ UsbHubCtrlGetHubStatus (
**/
EFI_STATUS
UsbHubCtrlGetPortStatus (
- IN USB_DEVICE *HubDev,
- IN UINT8 Port,
- OUT VOID *State
+ IN USB_DEVICE *HubDev,
+ IN UINT8 Port,
+ OUT VOID *State
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// In USB bus, all the port index starts from 0. But HUB
@@ -302,7 +299,7 @@ UsbHubCtrlGetPortStatus (
USB_HUB_TARGET_PORT,
USB_HUB_REQ_GET_STATUS,
0,
- (UINT16) (Port + 1),
+ (UINT16)(Port + 1),
State,
4
);
@@ -310,7 +307,6 @@ UsbHubCtrlGetPortStatus (
return Status;
}
-
/**
Usb hub control transfer to set the port feature.
@@ -324,12 +320,12 @@ UsbHubCtrlGetPortStatus (
**/
EFI_STATUS
UsbHubCtrlSetPortFeature (
- IN USB_DEVICE *HubDev,
- IN UINT8 Port,
- IN UINT8 Feature
+ IN USB_DEVICE *HubDev,
+ IN UINT8 Port,
+ IN UINT8 Feature
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// In USB bus, all the port index starts from 0. But HUB
@@ -342,7 +338,7 @@ UsbHubCtrlSetPortFeature (
USB_HUB_TARGET_PORT,
USB_HUB_REQ_SET_FEATURE,
Feature,
- (UINT16) (Port + 1),
+ (UINT16)(Port + 1),
NULL,
0
);
@@ -350,7 +346,6 @@ UsbHubCtrlSetPortFeature (
return Status;
}
-
/**
Read the whole usb hub descriptor. It is necessary
to do it in two steps because hub descriptor is of
@@ -369,7 +364,7 @@ UsbHubReadDesc (
OUT EFI_USB_HUB_DESCRIPTOR *HubDesc
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// First get the hub descriptor length
@@ -386,8 +381,6 @@ UsbHubReadDesc (
return UsbHubCtrlGetHubDesc (HubDev, HubDesc, HubDesc->Length);
}
-
-
/**
Ack the hub change bits. If these bits are not ACKed, Hub will
always return changed bit map from its interrupt endpoint.
@@ -400,13 +393,13 @@ UsbHubReadDesc (
**/
EFI_STATUS
UsbHubAckHubStatus (
- IN USB_DEVICE *HubDev
+ IN USB_DEVICE *HubDev
)
{
- EFI_USB_PORT_STATUS HubState;
- EFI_STATUS Status;
+ EFI_USB_PORT_STATUS HubState;
+ EFI_STATUS Status;
- Status = UsbHubCtrlGetHubStatus (HubDev, (UINT32 *) &HubState);
+ Status = UsbHubCtrlGetHubStatus (HubDev, (UINT32 *)&HubState);
if (EFI_ERROR (Status)) {
return Status;
@@ -423,7 +416,6 @@ UsbHubAckHubStatus (
return EFI_SUCCESS;
}
-
/**
Test whether the interface is a hub interface.
@@ -435,7 +427,7 @@ UsbHubAckHubStatus (
**/
BOOLEAN
UsbIsHubInterface (
- IN USB_INTERFACE *UsbIf
+ IN USB_INTERFACE *UsbIf
)
{
EFI_USB_INTERFACE_DESCRIPTOR *Setting;
@@ -447,15 +439,14 @@ UsbIsHubInterface (
Setting = &UsbIf->IfSetting->Desc;
if ((Setting->InterfaceClass == USB_HUB_CLASS_CODE) &&
- (Setting->InterfaceSubClass == USB_HUB_SUBCLASS_CODE)) {
-
+ (Setting->InterfaceSubClass == USB_HUB_SUBCLASS_CODE))
+ {
return TRUE;
}
return FALSE;
}
-
/**
The callback function to the USB hub status change
interrupt endpoint. It is called periodically by
@@ -473,20 +464,20 @@ UsbIsHubInterface (
EFI_STATUS
EFIAPI
UsbOnHubInterrupt (
- IN VOID *Data,
- IN UINTN DataLength,
- IN VOID *Context,
- IN UINT32 Result
+ IN VOID *Data,
+ IN UINTN DataLength,
+ IN VOID *Context,
+ IN UINT32 Result
)
{
- USB_INTERFACE *HubIf;
- EFI_USB_IO_PROTOCOL *UsbIo;
- EFI_USB_ENDPOINT_DESCRIPTOR *EpDesc;
- EFI_STATUS Status;
+ USB_INTERFACE *HubIf;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_USB_ENDPOINT_DESCRIPTOR *EpDesc;
+ EFI_STATUS Status;
- HubIf = (USB_INTERFACE *) Context;
- UsbIo = &(HubIf->UsbIo);
- EpDesc = &(HubIf->HubEp->Desc);
+ HubIf = (USB_INTERFACE *)Context;
+ UsbIo = &(HubIf->UsbIo);
+ EpDesc = &(HubIf->HubEp->Desc);
if (Result != EFI_USB_NOERROR) {
//
@@ -516,7 +507,7 @@ UsbOnHubInterrupt (
);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "UsbOnHubInterrupt: failed to remove async transfer - %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "UsbOnHubInterrupt: failed to remove async transfer - %r\n", Status));
return Status;
}
@@ -531,7 +522,7 @@ UsbOnHubInterrupt (
);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "UsbOnHubInterrupt: failed to submit new async transfer - %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "UsbOnHubInterrupt: failed to submit new async transfer - %r\n", Status));
}
return Status;
@@ -559,9 +550,6 @@ UsbOnHubInterrupt (
return EFI_SUCCESS;
}
-
-
-
/**
Initialize the device for a non-root hub.
@@ -573,7 +561,7 @@ UsbOnHubInterrupt (
**/
EFI_STATUS
UsbHubInit (
- IN USB_INTERFACE *HubIf
+ IN USB_INTERFACE *HubIf
)
{
UINT8 HubDescBuffer[256];
@@ -590,11 +578,11 @@ UsbHubInit (
//
// Locate the interrupt endpoint for port change map
//
- HubIf->IsHub = FALSE;
- Setting = HubIf->IfSetting;
- HubDev = HubIf->Device;
- EpDesc = NULL;
- NumEndpoints = Setting->Desc.NumEndpoints;
+ HubIf->IsHub = FALSE;
+ Setting = HubIf->IfSetting;
+ HubDev = HubIf->Device;
+ EpDesc = NULL;
+ NumEndpoints = Setting->Desc.NumEndpoints;
for (Index = 0; Index < NumEndpoints; Index++) {
ASSERT ((Setting->Endpoints != NULL) && (Setting->Endpoints[Index] != NULL));
@@ -602,13 +590,14 @@ UsbHubInit (
EpDesc = Setting->Endpoints[Index];
if (USB_BIT_IS_SET (EpDesc->Desc.EndpointAddress, USB_ENDPOINT_DIR_IN) &&
- (USB_ENDPOINT_TYPE (&EpDesc->Desc) == USB_ENDPOINT_INTERRUPT)) {
+ (USB_ENDPOINT_TYPE (&EpDesc->Desc) == USB_ENDPOINT_INTERRUPT))
+ {
break;
}
}
if (Index == NumEndpoints) {
- DEBUG (( DEBUG_ERROR, "UsbHubInit: no interrupt endpoint found for hub %d\n", HubDev->Address));
+ DEBUG ((DEBUG_ERROR, "UsbHubInit: no interrupt endpoint found for hub %d\n", HubDev->Address));
return EFI_DEVICE_ERROR;
}
@@ -616,17 +605,17 @@ UsbHubInit (
// The length field of descriptor is UINT8 type, so the buffer
// with 256 bytes is enough to hold the descriptor data.
//
- HubDesc = (EFI_USB_HUB_DESCRIPTOR *) HubDescBuffer;
- Status = UsbHubReadDesc (HubDev, HubDesc);
+ HubDesc = (EFI_USB_HUB_DESCRIPTOR *)HubDescBuffer;
+ Status = UsbHubReadDesc (HubDev, HubDesc);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "UsbHubInit: failed to read HUB descriptor %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "UsbHubInit: failed to read HUB descriptor %r\n", Status));
return Status;
}
HubIf->NumOfPort = HubDesc->NumPorts;
- DEBUG (( DEBUG_INFO, "UsbHubInit: hub %d has %d ports\n", HubDev->Address,HubIf->NumOfPort));
+ DEBUG ((DEBUG_INFO, "UsbHubInit: hub %d has %d ports\n", HubDev->Address, HubIf->NumOfPort));
//
// OK, set IsHub to TRUE. Now usb bus can handle this device
@@ -652,7 +641,7 @@ UsbHubInit (
// for both gang/individual powered hubs.
//
for (Index = 0; Index < HubDesc->NumPorts; Index++) {
- UsbHubCtrlSetPortFeature (HubIf->Device, Index, (EFI_USB_PORT_FEATURE) USB_HUB_PORT_POWER);
+ UsbHubCtrlSetPortFeature (HubIf->Device, Index, (EFI_USB_PORT_FEATURE)USB_HUB_PORT_POWER);
}
//
@@ -661,6 +650,7 @@ UsbHubInit (
if (HubDesc->PwrOn2PwrGood > 0) {
gBS->Stall (HubDesc->PwrOn2PwrGood * USB_SET_PORT_POWER_STALL);
}
+
UsbHubAckHubStatus (HubIf->Device);
}
@@ -676,8 +666,12 @@ UsbHubInit (
);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "UsbHubInit: failed to create signal for hub %d - %r\n",
- HubDev->Address, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "UsbHubInit: failed to create signal for hub %d - %r\n",
+ HubDev->Address,
+ Status
+ ));
return Status;
}
@@ -701,8 +695,12 @@ UsbHubInit (
);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "UsbHubInit: failed to queue interrupt transfer for hub %d - %r\n",
- HubDev->Address, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "UsbHubInit: failed to queue interrupt transfer for hub %d - %r\n",
+ HubDev->Address,
+ Status
+ ));
gBS->CloseEvent (HubIf->HubNotify);
HubIf->HubNotify = NULL;
@@ -710,12 +708,10 @@ UsbHubInit (
return Status;
}
- DEBUG (( DEBUG_INFO, "UsbHubInit: hub %d initialized\n", HubDev->Address));
+ DEBUG ((DEBUG_INFO, "UsbHubInit: hub %d initialized\n", HubDev->Address));
return Status;
}
-
-
/**
Get the port status. This function is required to
ACK the port change bits although it will return
@@ -732,20 +728,18 @@ UsbHubInit (
**/
EFI_STATUS
UsbHubGetPortStatus (
- IN USB_INTERFACE *HubIf,
- IN UINT8 Port,
- OUT EFI_USB_PORT_STATUS *PortState
+ IN USB_INTERFACE *HubIf,
+ IN UINT8 Port,
+ OUT EFI_USB_PORT_STATUS *PortState
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- Status = UsbHubCtrlGetPortStatus (HubIf->Device, Port, PortState);
+ Status = UsbHubCtrlGetPortStatus (HubIf->Device, Port, PortState);
return Status;
}
-
-
/**
Clear the port change status.
@@ -755,8 +749,8 @@ UsbHubGetPortStatus (
**/
VOID
UsbHubClearPortChange (
- IN USB_INTERFACE *HubIf,
- IN UINT8 Port
+ IN USB_INTERFACE *HubIf,
+ IN UINT8 Port
)
{
EFI_USB_PORT_STATUS PortState;
@@ -780,13 +774,11 @@ UsbHubClearPortChange (
Map = &mHubFeatureMap[Index];
if (USB_BIT_IS_SET (PortState.PortChangeStatus, Map->ChangedBit)) {
- UsbHubCtrlClearPortFeature (HubIf->Device, Port, (UINT16) Map->Feature);
+ UsbHubCtrlClearPortFeature (HubIf->Device, Port, (UINT16)Map->Feature);
}
}
}
-
-
/**
Function to set the port feature for non-root hub.
@@ -800,19 +792,18 @@ UsbHubClearPortChange (
**/
EFI_STATUS
UsbHubSetPortFeature (
- IN USB_INTERFACE *HubIf,
- IN UINT8 Port,
- IN EFI_USB_PORT_FEATURE Feature
+ IN USB_INTERFACE *HubIf,
+ IN UINT8 Port,
+ IN EFI_USB_PORT_FEATURE Feature
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- Status = UsbHubCtrlSetPortFeature (HubIf->Device, Port, (UINT8) Feature);
+ Status = UsbHubCtrlSetPortFeature (HubIf->Device, Port, (UINT8)Feature);
return Status;
}
-
/**
Interface function to clear the port feature for non-root hub.
@@ -826,19 +817,18 @@ UsbHubSetPortFeature (
**/
EFI_STATUS
UsbHubClearPortFeature (
- IN USB_INTERFACE *HubIf,
- IN UINT8 Port,
- IN EFI_USB_PORT_FEATURE Feature
+ IN USB_INTERFACE *HubIf,
+ IN UINT8 Port,
+ IN EFI_USB_PORT_FEATURE Feature
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- Status = UsbHubCtrlClearPortFeature (HubIf->Device, Port, (UINT8) Feature);
+ Status = UsbHubCtrlClearPortFeature (HubIf->Device, Port, (UINT8)Feature);
return Status;
}
-
/**
Interface function to reset the port.
@@ -852,15 +842,15 @@ UsbHubClearPortFeature (
**/
EFI_STATUS
UsbHubResetPort (
- IN USB_INTERFACE *HubIf,
- IN UINT8 Port
+ IN USB_INTERFACE *HubIf,
+ IN UINT8 Port
)
{
- EFI_USB_PORT_STATUS PortState;
- UINTN Index;
- EFI_STATUS Status;
+ EFI_USB_PORT_STATUS PortState;
+ UINTN Index;
+ EFI_STATUS Status;
- Status = UsbHubSetPortFeature (HubIf, Port, (EFI_USB_PORT_FEATURE) USB_HUB_PORT_RESET);
+ Status = UsbHubSetPortFeature (HubIf, Port, (EFI_USB_PORT_FEATURE)USB_HUB_PORT_RESET);
if (EFI_ERROR (Status)) {
return Status;
@@ -885,7 +875,8 @@ UsbHubResetPort (
}
if (!EFI_ERROR (Status) &&
- USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_RESET)) {
+ USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_RESET))
+ {
gBS->Stall (USB_SET_PORT_RECOVERY_STALL);
return EFI_SUCCESS;
}
@@ -896,7 +887,6 @@ UsbHubResetPort (
return EFI_TIMEOUT;
}
-
/**
Release the hub's control of the interface.
@@ -907,11 +897,11 @@ UsbHubResetPort (
**/
EFI_STATUS
UsbHubRelease (
- IN USB_INTERFACE *HubIf
+ IN USB_INTERFACE *HubIf
)
{
- EFI_USB_IO_PROTOCOL *UsbIo;
- EFI_STATUS Status;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_STATUS Status;
UsbIo = &HubIf->UsbIo;
Status = UsbIo->UsbAsyncInterruptTransfer (
@@ -930,17 +920,15 @@ UsbHubRelease (
gBS->CloseEvent (HubIf->HubNotify);
- HubIf->IsHub = FALSE;
- HubIf->HubApi = NULL;
- HubIf->HubEp = NULL;
- HubIf->HubNotify = NULL;
+ HubIf->IsHub = FALSE;
+ HubIf->HubApi = NULL;
+ HubIf->HubEp = NULL;
+ HubIf->HubNotify = NULL;
- DEBUG (( DEBUG_INFO, "UsbHubRelease: hub device %d released\n", HubIf->Device->Address));
+ DEBUG ((DEBUG_INFO, "UsbHubRelease: hub device %d released\n", HubIf->Device->Address));
return EFI_SUCCESS;
}
-
-
/**
Initialize the interface for root hub.
@@ -952,13 +940,13 @@ UsbHubRelease (
**/
EFI_STATUS
UsbRootHubInit (
- IN USB_INTERFACE *HubIf
+ IN USB_INTERFACE *HubIf
)
{
- EFI_STATUS Status;
- UINT8 MaxSpeed;
- UINT8 NumOfPort;
- UINT8 Support64;
+ EFI_STATUS Status;
+ UINT8 MaxSpeed;
+ UINT8 NumOfPort;
+ UINT8 Support64;
Status = UsbHcGetCapability (HubIf->Device->Bus, &MaxSpeed, &NumOfPort, &Support64);
@@ -966,15 +954,20 @@ UsbRootHubInit (
return Status;
}
- DEBUG (( DEBUG_INFO, "UsbRootHubInit: root hub %p - max speed %d, %d ports\n",
- HubIf, MaxSpeed, NumOfPort));
-
- HubIf->IsHub = TRUE;
- HubIf->HubApi = &mUsbRootHubApi;
- HubIf->HubEp = NULL;
- HubIf->MaxSpeed = MaxSpeed;
- HubIf->NumOfPort = NumOfPort;
- HubIf->HubNotify = NULL;
+ DEBUG ((
+ DEBUG_INFO,
+ "UsbRootHubInit: root hub %p - max speed %d, %d ports\n",
+ HubIf,
+ MaxSpeed,
+ NumOfPort
+ ));
+
+ HubIf->IsHub = TRUE;
+ HubIf->HubApi = &mUsbRootHubApi;
+ HubIf->HubEp = NULL;
+ HubIf->MaxSpeed = MaxSpeed;
+ HubIf->NumOfPort = NumOfPort;
+ HubIf->HubNotify = NULL;
//
// Create a timer to poll root hub ports periodically
@@ -1010,7 +1003,6 @@ UsbRootHubInit (
return Status;
}
-
/**
Get the port status. This function is required to
ACK the port change bits although it will return
@@ -1027,21 +1019,20 @@ UsbRootHubInit (
**/
EFI_STATUS
UsbRootHubGetPortStatus (
- IN USB_INTERFACE *HubIf,
- IN UINT8 Port,
- OUT EFI_USB_PORT_STATUS *PortState
+ IN USB_INTERFACE *HubIf,
+ IN UINT8 Port,
+ OUT EFI_USB_PORT_STATUS *PortState
)
{
- USB_BUS *Bus;
- EFI_STATUS Status;
+ USB_BUS *Bus;
+ EFI_STATUS Status;
- Bus = HubIf->Device->Bus;
- Status = UsbHcGetRootHubPortStatus (Bus, Port, PortState);
+ Bus = HubIf->Device->Bus;
+ Status = UsbHcGetRootHubPortStatus (Bus, Port, PortState);
return Status;
}
-
/**
Clear the port change status.
@@ -1051,8 +1042,8 @@ UsbRootHubGetPortStatus (
**/
VOID
UsbRootHubClearPortChange (
- IN USB_INTERFACE *HubIf,
- IN UINT8 Port
+ IN USB_INTERFACE *HubIf,
+ IN UINT8 Port
)
{
EFI_USB_PORT_STATUS PortState;
@@ -1076,12 +1067,11 @@ UsbRootHubClearPortChange (
Map = &mRootHubFeatureMap[Index];
if (USB_BIT_IS_SET (PortState.PortChangeStatus, Map->ChangedBit)) {
- UsbHcClearRootHubPortFeature (HubIf->Device->Bus, Port, (EFI_USB_PORT_FEATURE) Map->Feature);
+ UsbHcClearRootHubPortFeature (HubIf->Device->Bus, Port, (EFI_USB_PORT_FEATURE)Map->Feature);
}
}
}
-
/**
Set the root hub port feature.
@@ -1095,19 +1085,18 @@ UsbRootHubClearPortChange (
**/
EFI_STATUS
UsbRootHubSetPortFeature (
- IN USB_INTERFACE *HubIf,
- IN UINT8 Port,
- IN EFI_USB_PORT_FEATURE Feature
+ IN USB_INTERFACE *HubIf,
+ IN UINT8 Port,
+ IN EFI_USB_PORT_FEATURE Feature
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- Status = UsbHcSetRootHubPortFeature (HubIf->Device->Bus, Port, Feature);
+ Status = UsbHcSetRootHubPortFeature (HubIf->Device->Bus, Port, Feature);
return Status;
}
-
/**
Clear the root hub port feature.
@@ -1121,19 +1110,18 @@ UsbRootHubSetPortFeature (
**/
EFI_STATUS
UsbRootHubClearPortFeature (
- IN USB_INTERFACE *HubIf,
- IN UINT8 Port,
- IN EFI_USB_PORT_FEATURE Feature
+ IN USB_INTERFACE *HubIf,
+ IN UINT8 Port,
+ IN EFI_USB_PORT_FEATURE Feature
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- Status = UsbHcClearRootHubPortFeature (HubIf->Device->Bus, Port, Feature);
+ Status = UsbHcClearRootHubPortFeature (HubIf->Device->Bus, Port, Feature);
return Status;
}
-
/**
Interface function to reset the root hub port.
@@ -1149,26 +1137,26 @@ UsbRootHubClearPortFeature (
**/
EFI_STATUS
UsbRootHubResetPort (
- IN USB_INTERFACE *RootIf,
- IN UINT8 Port
+ IN USB_INTERFACE *RootIf,
+ IN UINT8 Port
)
{
- USB_BUS *Bus;
- EFI_STATUS Status;
- EFI_USB_PORT_STATUS PortState;
- UINTN Index;
+ USB_BUS *Bus;
+ EFI_STATUS Status;
+ EFI_USB_PORT_STATUS PortState;
+ UINTN Index;
//
// Notice: although EHCI requires that ENABLED bit be cleared
// when reset the port, we don't need to care that here. It
// should be handled in the EHCI driver.
//
- Bus = RootIf->Device->Bus;
+ Bus = RootIf->Device->Bus;
- Status = UsbHcSetRootHubPortFeature (Bus, Port, EfiUsbPortReset);
+ Status = UsbHcSetRootHubPortFeature (Bus, Port, EfiUsbPortReset);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "UsbRootHubResetPort: failed to start reset on port %d\n", Port));
+ DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: failed to start reset on port %d\n", Port));
return Status;
}
@@ -1181,7 +1169,7 @@ UsbRootHubResetPort (
Status = UsbHcClearRootHubPortFeature (Bus, Port, EfiUsbPortReset);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "UsbRootHubResetPort: failed to clear reset on port %d\n", Port));
+ DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: failed to clear reset on port %d\n", Port));
return Status;
}
@@ -1220,17 +1208,15 @@ UsbRootHubResetPort (
// automatically enable the port, we need to enable it manually.
//
if (RootIf->MaxSpeed == EFI_USB_SPEED_HIGH) {
- DEBUG (( DEBUG_ERROR, "UsbRootHubResetPort: release low/full speed device (%d) to UHCI\n", Port));
+ DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: release low/full speed device (%d) to UHCI\n", Port));
UsbRootHubSetPortFeature (RootIf, Port, EfiUsbPortOwner);
return EFI_NOT_FOUND;
-
} else {
-
Status = UsbRootHubSetPortFeature (RootIf, Port, EfiUsbPortEnable);
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "UsbRootHubResetPort: failed to enable port %d for UHCI\n", Port));
+ DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: failed to enable port %d for UHCI\n", Port));
return Status;
}
@@ -1241,7 +1227,6 @@ UsbRootHubResetPort (
return EFI_SUCCESS;
}
-
/**
Release the root hub's control of the interface.
@@ -1253,10 +1238,10 @@ UsbRootHubResetPort (
**/
EFI_STATUS
UsbRootHubRelease (
- IN USB_INTERFACE *HubIf
+ IN USB_INTERFACE *HubIf
)
{
- DEBUG (( DEBUG_INFO, "UsbRootHubRelease: root hub released for hub %p\n", HubIf));
+ DEBUG ((DEBUG_INFO, "UsbRootHubRelease: root hub released for hub %p\n", HubIf));
gBS->SetTimer (HubIf->HubNotify, TimerCancel, USB_ROOTHUB_POLL_INTERVAL);
gBS->CloseEvent (HubIf->HubNotify);
@@ -1264,7 +1249,7 @@ UsbRootHubRelease (
return EFI_SUCCESS;
}
-USB_HUB_API mUsbHubApi = {
+USB_HUB_API mUsbHubApi = {
UsbHubInit,
UsbHubGetPortStatus,
UsbHubClearPortChange,
@@ -1274,7 +1259,7 @@ USB_HUB_API mUsbHubApi = {
UsbHubRelease
};
-USB_HUB_API mUsbRootHubApi = {
+USB_HUB_API mUsbRootHubApi = {
UsbRootHubInit,
UsbRootHubGetPortStatus,
UsbRootHubClearPortChange,
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.h b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.h
index 6043b5b..8c8583a 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.h
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.h
@@ -12,33 +12,32 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <IndustryStandard/Usb.h>
-#define USB_ENDPOINT_ADDR(EpAddr) ((EpAddr) & 0x7F)
-#define USB_ENDPOINT_TYPE(Desc) ((Desc)->Attributes & USB_ENDPOINT_TYPE_MASK)
+#define USB_ENDPOINT_ADDR(EpAddr) ((EpAddr) & 0x7F)
+#define USB_ENDPOINT_TYPE(Desc) ((Desc)->Attributes & USB_ENDPOINT_TYPE_MASK)
-
-#define USB_DESC_TYPE_HUB 0x29
+#define USB_DESC_TYPE_HUB 0x29
#define USB_DESC_TYPE_HUB_SUPER_SPEED 0x2a
//
// Hub class control transfer target
//
-#define USB_HUB_TARGET_HUB 0
-#define USB_HUB_TARGET_PORT 3
+#define USB_HUB_TARGET_HUB 0
+#define USB_HUB_TARGET_PORT 3
//
// HUB class specific contrl transfer request type
//
-#define USB_HUB_REQ_GET_STATUS 0
-#define USB_HUB_REQ_CLEAR_FEATURE 1
-#define USB_HUB_REQ_SET_FEATURE 3
-#define USB_HUB_REQ_GET_DESC 6
-#define USB_HUB_REQ_SET_DESC 7
-#define USB_HUB_REQ_CLEAR_TT 8
-#define USB_HUB_REQ_RESET_TT 9
-#define USB_HUB_REQ_GET_TT_STATE 10
-#define USB_HUB_REQ_STOP_TT 11
+#define USB_HUB_REQ_GET_STATUS 0
+#define USB_HUB_REQ_CLEAR_FEATURE 1
+#define USB_HUB_REQ_SET_FEATURE 3
+#define USB_HUB_REQ_GET_DESC 6
+#define USB_HUB_REQ_SET_DESC 7
+#define USB_HUB_REQ_CLEAR_TT 8
+#define USB_HUB_REQ_RESET_TT 9
+#define USB_HUB_REQ_GET_TT_STATE 10
+#define USB_HUB_REQ_STOP_TT 11
-#define USB_HUB_REQ_SET_DEPTH 12
+#define USB_HUB_REQ_SET_DEPTH 12
//
// USB hub class feature selector
@@ -51,22 +50,22 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define USB_HUB_PORT_OVER_CURRENT 3
#define USB_HUB_PORT_RESET 4
-#define USB_HUB_PORT_LINK_STATE 5
+#define USB_HUB_PORT_LINK_STATE 5
-#define USB_HUB_PORT_POWER 8
-#define USB_HUB_PORT_LOW_SPEED 9
-#define USB_HUB_C_PORT_CONNECT 16
-#define USB_HUB_C_PORT_ENABLE 17
-#define USB_HUB_C_PORT_SUSPEND 18
-#define USB_HUB_C_PORT_OVER_CURRENT 19
-#define USB_HUB_C_PORT_RESET 20
-#define USB_HUB_PORT_TEST 21
-#define USB_HUB_PORT_INDICATOR 22
+#define USB_HUB_PORT_POWER 8
+#define USB_HUB_PORT_LOW_SPEED 9
+#define USB_HUB_C_PORT_CONNECT 16
+#define USB_HUB_C_PORT_ENABLE 17
+#define USB_HUB_C_PORT_SUSPEND 18
+#define USB_HUB_C_PORT_OVER_CURRENT 19
+#define USB_HUB_C_PORT_RESET 20
+#define USB_HUB_PORT_TEST 21
+#define USB_HUB_PORT_INDICATOR 22
-#define USB_HUB_C_PORT_LINK_STATE 25
-#define USB_HUB_PORT_REMOTE_WAKE_MASK 27
-#define USB_HUB_BH_PORT_RESET 28
-#define USB_HUB_C_BH_PORT_RESET 29
+#define USB_HUB_C_PORT_LINK_STATE 25
+#define USB_HUB_PORT_REMOTE_WAKE_MASK 27
+#define USB_HUB_BH_PORT_RESET 28
+#define USB_HUB_C_BH_PORT_RESET 29
//
// Constant value for Port Status & Port Change Status of SuperSpeed port
@@ -76,18 +75,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// USB hub power control method. In gang power control
//
-#define USB_HUB_GANG_POWER_CTRL 0
-#define USB_HUB_PORT_POWER_CTRL 0x01
+#define USB_HUB_GANG_POWER_CTRL 0
+#define USB_HUB_PORT_POWER_CTRL 0x01
//
// USB hub status bits
//
-#define USB_HUB_STAT_LOCAL_POWER 0x01
-#define USB_HUB_STAT_OVER_CURRENT 0x02
-#define USB_HUB_STAT_C_LOCAL_POWER 0x01
-#define USB_HUB_STAT_C_OVER_CURRENT 0x02
+#define USB_HUB_STAT_LOCAL_POWER 0x01
+#define USB_HUB_STAT_OVER_CURRENT 0x02
+#define USB_HUB_STAT_C_LOCAL_POWER 0x01
+#define USB_HUB_STAT_C_OVER_CURRENT 0x02
-#define USB_HUB_CLASS_CODE 0x09
-#define USB_HUB_SUBCLASS_CODE 0x00
+#define USB_HUB_CLASS_CODE 0x09
+#define USB_HUB_SUBCLASS_CODE 0x00
//
// Host software return timeout if port status doesn't change
@@ -100,24 +99,22 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Hub descriptor, the last two fields are of variable length.
//
typedef struct {
- UINT8 Length;
- UINT8 DescType;
- UINT8 NumPorts;
- UINT16 HubCharacter;
- UINT8 PwrOn2PwrGood;
- UINT8 HubContrCurrent;
- UINT8 Filler[16];
+ UINT8 Length;
+ UINT8 DescType;
+ UINT8 NumPorts;
+ UINT16 HubCharacter;
+ UINT8 PwrOn2PwrGood;
+ UINT8 HubContrCurrent;
+ UINT8 Filler[16];
} EFI_USB_HUB_DESCRIPTOR;
#pragma pack()
-
typedef struct {
- UINT16 ChangedBit;
- EFI_USB_PORT_FEATURE Feature;
+ UINT16 ChangedBit;
+ EFI_USB_PORT_FEATURE Feature;
} USB_CHANGE_FEATURE_MAP;
-
/**
Clear the transaction translate buffer if full/low
speed control/bulk transfer failed and the transfer
@@ -137,14 +134,13 @@ typedef struct {
**/
EFI_STATUS
UsbHubCtrlClearTTBuffer (
- IN USB_DEVICE *UsbDev,
- IN UINT8 Port,
- IN UINT16 DevAddr,
- IN UINT16 EpNum,
- IN UINT16 EpType
+ IN USB_DEVICE *UsbDev,
+ IN UINT8 Port,
+ IN UINT16 DevAddr,
+ IN UINT16 EpNum,
+ IN UINT16 EpType
);
-
/**
Test whether the interface is a hub interface.
@@ -156,10 +152,9 @@ UsbHubCtrlClearTTBuffer (
**/
BOOLEAN
UsbIsHubInterface (
- IN USB_INTERFACE *UsbIf
+ IN USB_INTERFACE *UsbIf
);
-
/**
Ack the hub change bits. If these bits are not ACKed, Hub will
always return changed bit map from its interrupt endpoint.
@@ -172,10 +167,9 @@ UsbIsHubInterface (
**/
EFI_STATUS
UsbHubAckHubStatus (
- IN USB_DEVICE *UsbDev
+ IN USB_DEVICE *UsbDev
);
-extern USB_HUB_API mUsbHubApi;
-extern USB_HUB_API mUsbRootHubApi;
+extern USB_HUB_API mUsbHubApi;
+extern USB_HUB_API mUsbRootHubApi;
#endif
-
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
index 4441466..12d08c0 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "UsbBus.h"
//
@@ -15,14 +14,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Use a shor form Usb class Device Path, which could match any usb device, in WantedUsbIoDPList to indicate all Usb devices
// are wanted Usb devices
//
-USB_CLASS_FORMAT_DEVICE_PATH mAllUsbClassDevicePath = {
+USB_CLASS_FORMAT_DEVICE_PATH mAllUsbClassDevicePath = {
{
{
MESSAGING_DEVICE_PATH,
MSG_USB_CLASS_DP,
{
- (UINT8) (sizeof (USB_CLASS_DEVICE_PATH)),
- (UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (USB_CLASS_DEVICE_PATH)),
+ (UINT8)((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
}
},
0xffff, // VendorId
@@ -42,7 +41,6 @@ USB_CLASS_FORMAT_DEVICE_PATH mAllUsbClassDevicePath = {
}
};
-
/**
Get the capability of the host controller.
@@ -57,41 +55,31 @@ USB_CLASS_FORMAT_DEVICE_PATH mAllUsbClassDevicePath = {
**/
EFI_STATUS
UsbHcGetCapability (
- IN USB_BUS *UsbBus,
- OUT UINT8 *MaxSpeed,
- OUT UINT8 *NumOfPort,
- OUT UINT8 *Is64BitCapable
+ IN USB_BUS *UsbBus,
+ OUT UINT8 *MaxSpeed,
+ OUT UINT8 *NumOfPort,
+ OUT UINT8 *Is64BitCapable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (UsbBus->Usb2Hc != NULL) {
Status = UsbBus->Usb2Hc->GetCapability (
- UsbBus->Usb2Hc,
- MaxSpeed,
- NumOfPort,
- Is64BitCapable
- );
-
+ UsbBus->Usb2Hc,
+ MaxSpeed,
+ NumOfPort,
+ Is64BitCapable
+ );
} else {
Status = UsbBus->UsbHc->GetRootHubPortNumber (UsbBus->UsbHc, NumOfPort);
*MaxSpeed = EFI_USB_SPEED_FULL;
- *Is64BitCapable = (UINT8) FALSE;
+ *Is64BitCapable = (UINT8)FALSE;
}
return Status;
}
-
-
-
-
-
-
-
-
-
/**
Get the root hub port state.
@@ -105,12 +93,12 @@ UsbHcGetCapability (
**/
EFI_STATUS
UsbHcGetRootHubPortStatus (
- IN USB_BUS *UsbBus,
- IN UINT8 PortIndex,
- OUT EFI_USB_PORT_STATUS *PortStatus
+ IN USB_BUS *UsbBus,
+ IN UINT8 PortIndex,
+ OUT EFI_USB_PORT_STATUS *PortStatus
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (UsbBus->Usb2Hc != NULL) {
Status = UsbBus->Usb2Hc->GetRootHubPortStatus (UsbBus->Usb2Hc, PortIndex, PortStatus);
@@ -121,7 +109,6 @@ UsbHcGetRootHubPortStatus (
return Status;
}
-
/**
Set the root hub port feature.
@@ -135,13 +122,12 @@ UsbHcGetRootHubPortStatus (
**/
EFI_STATUS
UsbHcSetRootHubPortFeature (
- IN USB_BUS *UsbBus,
- IN UINT8 PortIndex,
- IN EFI_USB_PORT_FEATURE Feature
+ IN USB_BUS *UsbBus,
+ IN UINT8 PortIndex,
+ IN EFI_USB_PORT_FEATURE Feature
)
{
- EFI_STATUS Status;
-
+ EFI_STATUS Status;
if (UsbBus->Usb2Hc != NULL) {
Status = UsbBus->Usb2Hc->SetRootHubPortFeature (UsbBus->Usb2Hc, PortIndex, Feature);
@@ -152,7 +138,6 @@ UsbHcSetRootHubPortFeature (
return Status;
}
-
/**
Clear the root hub port feature.
@@ -166,12 +151,12 @@ UsbHcSetRootHubPortFeature (
**/
EFI_STATUS
UsbHcClearRootHubPortFeature (
- IN USB_BUS *UsbBus,
- IN UINT8 PortIndex,
- IN EFI_USB_PORT_FEATURE Feature
+ IN USB_BUS *UsbBus,
+ IN UINT8 PortIndex,
+ IN EFI_USB_PORT_FEATURE Feature
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (UsbBus->Usb2Hc != NULL) {
Status = UsbBus->Usb2Hc->ClearRootHubPortFeature (UsbBus->Usb2Hc, PortIndex, Feature);
@@ -182,7 +167,6 @@ UsbHcClearRootHubPortFeature (
return Status;
}
-
/**
Execute a control transfer to the device.
@@ -217,8 +201,8 @@ UsbHcControlTransfer (
OUT UINT32 *UsbResult
)
{
- EFI_STATUS Status;
- BOOLEAN IsSlowDevice;
+ EFI_STATUS Status;
+ BOOLEAN IsSlowDevice;
if (UsbBus->Usb2Hc != NULL) {
Status = UsbBus->Usb2Hc->ControlTransfer (
@@ -234,27 +218,25 @@ UsbHcControlTransfer (
Translator,
UsbResult
);
-
} else {
IsSlowDevice = (BOOLEAN)(EFI_USB_SPEED_LOW == DevSpeed);
- Status = UsbBus->UsbHc->ControlTransfer (
- UsbBus->UsbHc,
- DevAddr,
- IsSlowDevice,
- (UINT8) MaxPacket,
- Request,
- Direction,
- Data,
- DataLength,
- TimeOut,
- UsbResult
- );
+ Status = UsbBus->UsbHc->ControlTransfer (
+ UsbBus->UsbHc,
+ DevAddr,
+ IsSlowDevice,
+ (UINT8)MaxPacket,
+ Request,
+ Direction,
+ Data,
+ DataLength,
+ TimeOut,
+ UsbResult
+ );
}
return Status;
}
-
/**
Execute a bulk transfer to the device's endpoint.
@@ -293,7 +275,7 @@ UsbHcBulkTransfer (
OUT UINT32 *UsbResult
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (UsbBus->Usb2Hc != NULL) {
Status = UsbBus->Usb2Hc->BulkTransfer (
@@ -315,7 +297,7 @@ UsbHcBulkTransfer (
UsbBus->UsbHc,
DevAddr,
EpAddr,
- (UINT8) MaxPacket,
+ (UINT8)MaxPacket,
*Data,
DataLength,
DataToggle,
@@ -327,7 +309,6 @@ UsbHcBulkTransfer (
return Status;
}
-
/**
Queue or cancel an asynchronous interrupt transfer.
@@ -366,8 +347,8 @@ UsbHcAsyncInterruptTransfer (
IN VOID *Context OPTIONAL
)
{
- EFI_STATUS Status;
- BOOLEAN IsSlowDevice;
+ EFI_STATUS Status;
+ BOOLEAN IsSlowDevice;
if (UsbBus->Usb2Hc != NULL) {
Status = UsbBus->Usb2Hc->AsyncInterruptTransfer (
@@ -392,7 +373,7 @@ UsbHcAsyncInterruptTransfer (
DevAddr,
EpAddr,
IsSlowDevice,
- (UINT8) MaxPacket,
+ (UINT8)MaxPacket,
IsNewTransfer,
DataToggle,
PollingInterval,
@@ -405,7 +386,6 @@ UsbHcAsyncInterruptTransfer (
return Status;
}
-
/**
Execute a synchronous interrupt transfer to the target endpoint.
@@ -442,8 +422,8 @@ UsbHcSyncInterruptTransfer (
OUT UINT32 *UsbResult
)
{
- EFI_STATUS Status;
- BOOLEAN IsSlowDevice;
+ EFI_STATUS Status;
+ BOOLEAN IsSlowDevice;
if (UsbBus->Usb2Hc != NULL) {
Status = UsbBus->Usb2Hc->SyncInterruptTransfer (
@@ -460,31 +440,24 @@ UsbHcSyncInterruptTransfer (
UsbResult
);
} else {
- IsSlowDevice = (BOOLEAN) ((EFI_USB_SPEED_LOW == DevSpeed) ? TRUE : FALSE);
- Status = UsbBus->UsbHc->SyncInterruptTransfer (
- UsbBus->UsbHc,
- DevAddr,
- EpAddr,
- IsSlowDevice,
- (UINT8) MaxPacket,
- Data,
- DataLength,
- DataToggle,
- TimeOut,
- UsbResult
- );
+ IsSlowDevice = (BOOLEAN)((EFI_USB_SPEED_LOW == DevSpeed) ? TRUE : FALSE);
+ Status = UsbBus->UsbHc->SyncInterruptTransfer (
+ UsbBus->UsbHc,
+ DevAddr,
+ EpAddr,
+ IsSlowDevice,
+ (UINT8)MaxPacket,
+ Data,
+ DataLength,
+ DataToggle,
+ TimeOut,
+ UsbResult
+ );
}
return Status;
}
-
-
-
-
-
-
-
/**
Open the USB host controller protocol BY_CHILD.
@@ -496,29 +469,28 @@ UsbHcSyncInterruptTransfer (
**/
EFI_STATUS
UsbOpenHostProtoByChild (
- IN USB_BUS *Bus,
- IN EFI_HANDLE Child
+ IN USB_BUS *Bus,
+ IN EFI_HANDLE Child
)
{
- EFI_USB_HC_PROTOCOL *UsbHc;
- EFI_USB2_HC_PROTOCOL *Usb2Hc;
- EFI_STATUS Status;
+ EFI_USB_HC_PROTOCOL *UsbHc;
+ EFI_USB2_HC_PROTOCOL *Usb2Hc;
+ EFI_STATUS Status;
if (Bus->Usb2Hc != NULL) {
Status = gBS->OpenProtocol (
Bus->HostHandle,
&gEfiUsb2HcProtocolGuid,
- (VOID **) &Usb2Hc,
+ (VOID **)&Usb2Hc,
mUsbBusDriverBinding.DriverBindingHandle,
Child,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
-
} else {
Status = gBS->OpenProtocol (
Bus->HostHandle,
&gEfiUsbHcProtocolGuid,
- (VOID **) &UsbHc,
+ (VOID **)&UsbHc,
mUsbBusDriverBinding.DriverBindingHandle,
Child,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -528,7 +500,6 @@ UsbOpenHostProtoByChild (
return Status;
}
-
/**
Close the USB host controller protocol BY_CHILD.
@@ -538,8 +509,8 @@ UsbOpenHostProtoByChild (
**/
VOID
UsbCloseHostProtoByChild (
- IN USB_BUS *Bus,
- IN EFI_HANDLE Child
+ IN USB_BUS *Bus,
+ IN EFI_HANDLE Child
)
{
if (Bus->Usb2Hc != NULL) {
@@ -549,7 +520,6 @@ UsbCloseHostProtoByChild (
mUsbBusDriverBinding.DriverBindingHandle,
Child
);
-
} else {
gBS->CloseProtocol (
Bus->HostHandle,
@@ -560,7 +530,6 @@ UsbCloseHostProtoByChild (
}
}
-
/**
return the current TPL, copied from the EDKII glue lib.
@@ -574,7 +543,7 @@ UsbGetCurrentTpl (
VOID
)
{
- EFI_TPL Tpl;
+ EFI_TPL Tpl;
Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
gBS->RestoreTPL (Tpl);
@@ -593,45 +562,45 @@ UsbGetCurrentTpl (
EFI_DEVICE_PATH_PROTOCOL *
EFIAPI
GetUsbDPFromFullDP (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- EFI_DEVICE_PATH_PROTOCOL *UsbDevicePathPtr;
- EFI_DEVICE_PATH_PROTOCOL *UsbDevicePathBeginPtr;
- EFI_DEVICE_PATH_PROTOCOL *UsbDevicePathEndPtr;
- UINTN Size;
+ EFI_DEVICE_PATH_PROTOCOL *UsbDevicePathPtr;
+ EFI_DEVICE_PATH_PROTOCOL *UsbDevicePathBeginPtr;
+ EFI_DEVICE_PATH_PROTOCOL *UsbDevicePathEndPtr;
+ UINTN Size;
//
// Get the Usb part first Begin node in full device path
//
UsbDevicePathBeginPtr = DevicePath;
- while ( (!IsDevicePathEnd (UsbDevicePathBeginPtr))&&
+ while ((!IsDevicePathEnd (UsbDevicePathBeginPtr)) &&
((UsbDevicePathBeginPtr->Type != MESSAGING_DEVICE_PATH) ||
- (UsbDevicePathBeginPtr->SubType != MSG_USB_DP &&
- UsbDevicePathBeginPtr->SubType != MSG_USB_CLASS_DP
+ ( UsbDevicePathBeginPtr->SubType != MSG_USB_DP &&
+ UsbDevicePathBeginPtr->SubType != MSG_USB_CLASS_DP
&& UsbDevicePathBeginPtr->SubType != MSG_USB_WWID_DP
- ))) {
-
- UsbDevicePathBeginPtr = NextDevicePathNode(UsbDevicePathBeginPtr);
+ )))
+ {
+ UsbDevicePathBeginPtr = NextDevicePathNode (UsbDevicePathBeginPtr);
}
//
// Get the Usb part first End node in full device path
//
UsbDevicePathEndPtr = UsbDevicePathBeginPtr;
- while ((!IsDevicePathEnd (UsbDevicePathEndPtr))&&
+ while ((!IsDevicePathEnd (UsbDevicePathEndPtr)) &&
(UsbDevicePathEndPtr->Type == MESSAGING_DEVICE_PATH) &&
- (UsbDevicePathEndPtr->SubType == MSG_USB_DP ||
- UsbDevicePathEndPtr->SubType == MSG_USB_CLASS_DP
- || UsbDevicePathEndPtr->SubType == MSG_USB_WWID_DP
- )) {
-
- UsbDevicePathEndPtr = NextDevicePathNode(UsbDevicePathEndPtr);
+ ( UsbDevicePathEndPtr->SubType == MSG_USB_DP ||
+ UsbDevicePathEndPtr->SubType == MSG_USB_CLASS_DP
+ || UsbDevicePathEndPtr->SubType == MSG_USB_WWID_DP
+ ))
+ {
+ UsbDevicePathEndPtr = NextDevicePathNode (UsbDevicePathEndPtr);
}
Size = GetDevicePathSize (UsbDevicePathBeginPtr);
Size -= GetDevicePathSize (UsbDevicePathEndPtr);
- if (Size ==0){
+ if (Size == 0) {
//
// The passed in DevicePath does not contain the usb nodes
//
@@ -647,7 +616,7 @@ GetUsbDPFromFullDP (
//
// Append end device path node
//
- UsbDevicePathEndPtr = (EFI_DEVICE_PATH_PROTOCOL *) ((UINTN) UsbDevicePathPtr + Size);
+ UsbDevicePathEndPtr = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)UsbDevicePathPtr + Size);
SetDevicePathEndNode (UsbDevicePathEndPtr);
return UsbDevicePathPtr;
}
@@ -665,14 +634,14 @@ GetUsbDPFromFullDP (
BOOLEAN
EFIAPI
SearchUsbDPInList (
- IN EFI_DEVICE_PATH_PROTOCOL *UsbDP,
- IN LIST_ENTRY *UsbIoDPList
+ IN EFI_DEVICE_PATH_PROTOCOL *UsbDP,
+ IN LIST_ENTRY *UsbIoDPList
)
{
- LIST_ENTRY *ListIndex;
- DEVICE_PATH_LIST_ITEM *ListItem;
- BOOLEAN Found;
- UINTN UsbDpDevicePathSize;
+ LIST_ENTRY *ListIndex;
+ DEVICE_PATH_LIST_ITEM *ListItem;
+ BOOLEAN Found;
+ UINTN UsbDpDevicePathSize;
//
// Check that UsbDP and UsbIoDPList are valid
@@ -681,22 +650,23 @@ SearchUsbDPInList (
return FALSE;
}
- Found = FALSE;
+ Found = FALSE;
ListIndex = UsbIoDPList->ForwardLink;
- while (ListIndex != UsbIoDPList){
- ListItem = CR(ListIndex, DEVICE_PATH_LIST_ITEM, Link, DEVICE_PATH_LIST_ITEM_SIGNATURE);
+ while (ListIndex != UsbIoDPList) {
+ ListItem = CR (ListIndex, DEVICE_PATH_LIST_ITEM, Link, DEVICE_PATH_LIST_ITEM_SIGNATURE);
//
// Compare DEVICE_PATH_LIST_ITEM.DevicePath[]
//
ASSERT (ListItem->DevicePath != NULL);
- UsbDpDevicePathSize = GetDevicePathSize (UsbDP);
+ UsbDpDevicePathSize = GetDevicePathSize (UsbDP);
if (UsbDpDevicePathSize == GetDevicePathSize (ListItem->DevicePath)) {
if ((CompareMem (UsbDP, ListItem->DevicePath, UsbDpDevicePathSize)) == 0) {
Found = TRUE;
break;
}
}
+
ListIndex = ListIndex->ForwardLink;
}
@@ -716,11 +686,11 @@ SearchUsbDPInList (
EFI_STATUS
EFIAPI
AddUsbDPToList (
- IN EFI_DEVICE_PATH_PROTOCOL *UsbDP,
- IN LIST_ENTRY *UsbIoDPList
+ IN EFI_DEVICE_PATH_PROTOCOL *UsbDP,
+ IN LIST_ENTRY *UsbIoDPList
)
{
- DEVICE_PATH_LIST_ITEM *ListItem;
+ DEVICE_PATH_LIST_ITEM *ListItem;
//
// Check that UsbDP and UsbIoDPList are valid
@@ -729,7 +699,7 @@ AddUsbDPToList (
return EFI_INVALID_PARAMETER;
}
- if (SearchUsbDPInList (UsbDP, UsbIoDPList)){
+ if (SearchUsbDPInList (UsbDP, UsbIoDPList)) {
return EFI_SUCCESS;
}
@@ -738,7 +708,7 @@ AddUsbDPToList (
//
ListItem = AllocateZeroPool (sizeof (DEVICE_PATH_LIST_ITEM));
ASSERT (ListItem != NULL);
- ListItem->Signature = DEVICE_PATH_LIST_ITEM_SIGNATURE;
+ ListItem->Signature = DEVICE_PATH_LIST_ITEM_SIGNATURE;
ListItem->DevicePath = DuplicateDevicePath (UsbDP);
InsertTailList (UsbIoDPList, &ListItem->Link);
@@ -760,25 +730,25 @@ AddUsbDPToList (
BOOLEAN
EFIAPI
MatchUsbClass (
- IN USB_CLASS_DEVICE_PATH *UsbClassDevicePathPtr,
- IN USB_INTERFACE *UsbIf
+ IN USB_CLASS_DEVICE_PATH *UsbClassDevicePathPtr,
+ IN USB_INTERFACE *UsbIf
)
{
USB_INTERFACE_DESC *IfDesc;
EFI_USB_INTERFACE_DESCRIPTOR *ActIfDesc;
EFI_USB_DEVICE_DESCRIPTOR *DevDesc;
-
if ((UsbClassDevicePathPtr->Header.Type != MESSAGING_DEVICE_PATH) ||
- (UsbClassDevicePathPtr->Header.SubType != MSG_USB_CLASS_DP)){
+ (UsbClassDevicePathPtr->Header.SubType != MSG_USB_CLASS_DP))
+ {
ASSERT (0);
return FALSE;
}
- IfDesc = UsbIf->IfDesc;
+ IfDesc = UsbIf->IfDesc;
ASSERT (IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);
- ActIfDesc = &(IfDesc->Settings[IfDesc->ActiveIndex]->Desc);
- DevDesc = &(UsbIf->Device->DevDesc->Desc);
+ ActIfDesc = &(IfDesc->Settings[IfDesc->ActiveIndex]->Desc);
+ DevDesc = &(UsbIf->Device->DevDesc->Desc);
//
// If connect class policy, determine whether to create device handle by the five fields
@@ -787,36 +757,37 @@ MatchUsbClass (
// In addition, hub interface is always matched for this policy.
//
if ((ActIfDesc->InterfaceClass == USB_HUB_CLASS_CODE) &&
- (ActIfDesc->InterfaceSubClass == USB_HUB_SUBCLASS_CODE)) {
+ (ActIfDesc->InterfaceSubClass == USB_HUB_SUBCLASS_CODE))
+ {
return TRUE;
}
//
// If vendor id or product id is 0xffff, they will be ignored.
//
- if ((UsbClassDevicePathPtr->VendorId == 0xffff || UsbClassDevicePathPtr->VendorId == DevDesc->IdVendor) &&
- (UsbClassDevicePathPtr->ProductId == 0xffff || UsbClassDevicePathPtr->ProductId == DevDesc->IdProduct)) {
-
+ if (((UsbClassDevicePathPtr->VendorId == 0xffff) || (UsbClassDevicePathPtr->VendorId == DevDesc->IdVendor)) &&
+ ((UsbClassDevicePathPtr->ProductId == 0xffff) || (UsbClassDevicePathPtr->ProductId == DevDesc->IdProduct)))
+ {
//
// If Class in Device Descriptor is set to 0, the counterparts in interface should be checked.
//
if (DevDesc->DeviceClass == 0) {
- if ((UsbClassDevicePathPtr->DeviceClass == ActIfDesc->InterfaceClass ||
- UsbClassDevicePathPtr->DeviceClass == 0xff) &&
- (UsbClassDevicePathPtr->DeviceSubClass == ActIfDesc->InterfaceSubClass ||
- UsbClassDevicePathPtr->DeviceSubClass == 0xff) &&
- (UsbClassDevicePathPtr->DeviceProtocol == ActIfDesc->InterfaceProtocol ||
- UsbClassDevicePathPtr->DeviceProtocol == 0xff)) {
+ if (((UsbClassDevicePathPtr->DeviceClass == ActIfDesc->InterfaceClass) ||
+ (UsbClassDevicePathPtr->DeviceClass == 0xff)) &&
+ ((UsbClassDevicePathPtr->DeviceSubClass == ActIfDesc->InterfaceSubClass) ||
+ (UsbClassDevicePathPtr->DeviceSubClass == 0xff)) &&
+ ((UsbClassDevicePathPtr->DeviceProtocol == ActIfDesc->InterfaceProtocol) ||
+ (UsbClassDevicePathPtr->DeviceProtocol == 0xff)))
+ {
return TRUE;
}
-
- } else if ((UsbClassDevicePathPtr->DeviceClass == DevDesc->DeviceClass ||
- UsbClassDevicePathPtr->DeviceClass == 0xff) &&
- (UsbClassDevicePathPtr->DeviceSubClass == DevDesc->DeviceSubClass ||
- UsbClassDevicePathPtr->DeviceSubClass == 0xff) &&
- (UsbClassDevicePathPtr->DeviceProtocol == DevDesc->DeviceProtocol ||
- UsbClassDevicePathPtr->DeviceProtocol == 0xff)) {
-
+ } else if (((UsbClassDevicePathPtr->DeviceClass == DevDesc->DeviceClass) ||
+ (UsbClassDevicePathPtr->DeviceClass == 0xff)) &&
+ ((UsbClassDevicePathPtr->DeviceSubClass == DevDesc->DeviceSubClass) ||
+ (UsbClassDevicePathPtr->DeviceSubClass == 0xff)) &&
+ ((UsbClassDevicePathPtr->DeviceProtocol == DevDesc->DeviceProtocol) ||
+ (UsbClassDevicePathPtr->DeviceProtocol == 0xff)))
+ {
return TRUE;
}
}
@@ -837,8 +808,8 @@ MatchUsbClass (
**/
BOOLEAN
MatchUsbWwid (
- IN USB_WWID_DEVICE_PATH *UsbWWIDDevicePathPtr,
- IN USB_INTERFACE *UsbIf
+ IN USB_WWID_DEVICE_PATH *UsbWWIDDevicePathPtr,
+ IN USB_INTERFACE *UsbIf
)
{
USB_INTERFACE_DESC *IfDesc;
@@ -851,21 +822,23 @@ MatchUsbWwid (
UINTN Length;
if ((UsbWWIDDevicePathPtr->Header.Type != MESSAGING_DEVICE_PATH) ||
- (UsbWWIDDevicePathPtr->Header.SubType != MSG_USB_WWID_DP )){
+ (UsbWWIDDevicePathPtr->Header.SubType != MSG_USB_WWID_DP))
+ {
ASSERT (0);
return FALSE;
}
- IfDesc = UsbIf->IfDesc;
+ IfDesc = UsbIf->IfDesc;
ASSERT (IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING);
- ActIfDesc = &(IfDesc->Settings[IfDesc->ActiveIndex]->Desc);
- DevDesc = &(UsbIf->Device->DevDesc->Desc);
+ ActIfDesc = &(IfDesc->Settings[IfDesc->ActiveIndex]->Desc);
+ DevDesc = &(UsbIf->Device->DevDesc->Desc);
//
// In addition, Hub interface is always matched for this policy.
//
if ((ActIfDesc->InterfaceClass == USB_HUB_CLASS_CODE) &&
- (ActIfDesc->InterfaceSubClass == USB_HUB_SUBCLASS_CODE)) {
+ (ActIfDesc->InterfaceSubClass == USB_HUB_SUBCLASS_CODE))
+ {
return TRUE;
}
@@ -874,7 +847,8 @@ MatchUsbWwid (
//
if ((DevDesc->IdVendor != UsbWWIDDevicePathPtr->VendorId) ||
(DevDesc->IdProduct != UsbWWIDDevicePathPtr->ProductId) ||
- (ActIfDesc->InterfaceNumber != UsbWWIDDevicePathPtr->InterfaceNumber)) {
+ (ActIfDesc->InterfaceNumber != UsbWWIDDevicePathPtr->InterfaceNumber))
+ {
return FALSE;
}
@@ -888,7 +862,7 @@ MatchUsbWwid (
//
// Serial number in USB WWID device path is the last 64-or-less UTF-16 characters.
//
- CompareStr = (CHAR16 *) (UINTN) (UsbWWIDDevicePathPtr + 1);
+ CompareStr = (CHAR16 *)(UINTN)(UsbWWIDDevicePathPtr + 1);
CompareLen = (DevicePathNodeLength (UsbWWIDDevicePathPtr) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16);
if (CompareStr[CompareLen - 1] == L'\0') {
CompareLen--;
@@ -905,7 +879,8 @@ MatchUsbWwid (
Length = (StrDesc->Length - 2) / sizeof (CHAR16);
if ((Length >= CompareLen) &&
- (CompareMem (StrDesc->String + Length - CompareLen, CompareStr, CompareLen * sizeof (CHAR16)) == 0)) {
+ (CompareMem (StrDesc->String + Length - CompareLen, CompareStr, CompareLen * sizeof (CHAR16)) == 0))
+ {
return TRUE;
}
}
@@ -925,11 +900,11 @@ MatchUsbWwid (
EFI_STATUS
EFIAPI
UsbBusFreeUsbDPList (
- IN LIST_ENTRY *UsbIoDPList
+ IN LIST_ENTRY *UsbIoDPList
)
{
- LIST_ENTRY *ListIndex;
- DEVICE_PATH_LIST_ITEM *ListItem;
+ LIST_ENTRY *ListIndex;
+ DEVICE_PATH_LIST_ITEM *ListItem;
//
// Check that ControllerHandle is a valid handle
@@ -939,14 +914,15 @@ UsbBusFreeUsbDPList (
}
ListIndex = UsbIoDPList->ForwardLink;
- while (ListIndex != UsbIoDPList){
- ListItem = CR(ListIndex, DEVICE_PATH_LIST_ITEM, Link, DEVICE_PATH_LIST_ITEM_SIGNATURE);
+ while (ListIndex != UsbIoDPList) {
+ ListItem = CR (ListIndex, DEVICE_PATH_LIST_ITEM, Link, DEVICE_PATH_LIST_ITEM_SIGNATURE);
//
// Free DEVICE_PATH_LIST_ITEM.DevicePath[]
//
- if (ListItem->DevicePath != NULL){
- FreePool(ListItem->DevicePath);
+ if (ListItem->DevicePath != NULL) {
+ FreePool (ListItem->DevicePath);
}
+
//
// Free DEVICE_PATH_LIST_ITEM itself
//
@@ -973,28 +949,29 @@ UsbBusFreeUsbDPList (
EFI_STATUS
EFIAPI
UsbBusAddWantedUsbIoDP (
- IN EFI_USB_BUS_PROTOCOL *UsbBusId,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_USB_BUS_PROTOCOL *UsbBusId,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- USB_BUS *Bus;
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *DevicePathPtr;
+ USB_BUS *Bus;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathPtr;
//
// Check whether remaining device path is valid
//
- if (RemainingDevicePath != NULL && !IsDevicePathEnd (RemainingDevicePath)) {
+ if ((RemainingDevicePath != NULL) && !IsDevicePathEnd (RemainingDevicePath)) {
if ((RemainingDevicePath->Type != MESSAGING_DEVICE_PATH) ||
- (RemainingDevicePath->SubType != MSG_USB_DP &&
- RemainingDevicePath->SubType != MSG_USB_CLASS_DP
- && RemainingDevicePath->SubType != MSG_USB_WWID_DP
- )) {
+ ( (RemainingDevicePath->SubType != MSG_USB_DP) &&
+ (RemainingDevicePath->SubType != MSG_USB_CLASS_DP)
+ && (RemainingDevicePath->SubType != MSG_USB_WWID_DP)
+ ))
+ {
return EFI_INVALID_PARAMETER;
}
}
- if (UsbBusId == NULL){
+ if (UsbBusId == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -1008,7 +985,7 @@ UsbBusAddWantedUsbIoDP (
//
Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);
ASSERT (!EFI_ERROR (Status));
- DevicePathPtr = DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) &mAllUsbClassDevicePath);
+ DevicePathPtr = DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL *)&mAllUsbClassDevicePath);
} else if (!IsDevicePathEnd (RemainingDevicePath)) {
//
// If RemainingDevicePath isn't the End of Device Path Node,
@@ -1043,16 +1020,16 @@ UsbBusAddWantedUsbIoDP (
BOOLEAN
EFIAPI
UsbBusIsWantedUsbIO (
- IN USB_BUS *Bus,
- IN USB_INTERFACE *UsbIf
+ IN USB_BUS *Bus,
+ IN USB_INTERFACE *UsbIf
)
{
- EFI_DEVICE_PATH_PROTOCOL *DevicePathPtr;
- LIST_ENTRY *WantedUsbIoDPListPtr;
- LIST_ENTRY *WantedListIndex;
- DEVICE_PATH_LIST_ITEM *WantedListItem;
- BOOLEAN DoConvert;
- UINTN FirstDevicePathSize;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathPtr;
+ LIST_ENTRY *WantedUsbIoDPListPtr;
+ LIST_ENTRY *WantedListIndex;
+ DEVICE_PATH_LIST_ITEM *WantedListItem;
+ BOOLEAN DoConvert;
+ UINTN FirstDevicePathSize;
//
// Check whether passed in parameters are valid
@@ -1060,6 +1037,7 @@ UsbBusIsWantedUsbIO (
if ((UsbIf == NULL) || (Bus == NULL)) {
return FALSE;
}
+
//
// Check whether UsbIf is Hub
//
@@ -1070,7 +1048,7 @@ UsbBusIsWantedUsbIO (
//
// Check whether all Usb devices in this bus are wanted
//
- if (SearchUsbDPInList ((EFI_DEVICE_PATH_PROTOCOL *)&mAllUsbClassDevicePath, &Bus->WantedUsbIoDPList)){
+ if (SearchUsbDPInList ((EFI_DEVICE_PATH_PROTOCOL *)&mAllUsbClassDevicePath, &Bus->WantedUsbIoDPList)) {
return TRUE;
}
@@ -1084,37 +1062,42 @@ UsbBusIsWantedUsbIO (
DevicePathPtr = GetUsbDPFromFullDP (UsbIf->DevicePath);
ASSERT (DevicePathPtr != NULL);
- DoConvert = FALSE;
+ DoConvert = FALSE;
WantedListIndex = WantedUsbIoDPListPtr->ForwardLink;
- while (WantedListIndex != WantedUsbIoDPListPtr){
- WantedListItem = CR(WantedListIndex, DEVICE_PATH_LIST_ITEM, Link, DEVICE_PATH_LIST_ITEM_SIGNATURE);
+ while (WantedListIndex != WantedUsbIoDPListPtr) {
+ WantedListItem = CR (WantedListIndex, DEVICE_PATH_LIST_ITEM, Link, DEVICE_PATH_LIST_ITEM_SIGNATURE);
ASSERT (WantedListItem->DevicePath->Type == MESSAGING_DEVICE_PATH);
switch (WantedListItem->DevicePath->SubType) {
- case MSG_USB_DP:
- FirstDevicePathSize = GetDevicePathSize (WantedListItem->DevicePath);
- if (FirstDevicePathSize == GetDevicePathSize (DevicePathPtr)) {
- if (CompareMem (
- WantedListItem->DevicePath,
- DevicePathPtr,
- GetDevicePathSize (DevicePathPtr)) == 0
- ) {
+ case MSG_USB_DP:
+ FirstDevicePathSize = GetDevicePathSize (WantedListItem->DevicePath);
+ if (FirstDevicePathSize == GetDevicePathSize (DevicePathPtr)) {
+ if (CompareMem (
+ WantedListItem->DevicePath,
+ DevicePathPtr,
+ GetDevicePathSize (DevicePathPtr)
+ ) == 0
+ )
+ {
+ DoConvert = TRUE;
+ }
+ }
+
+ break;
+ case MSG_USB_CLASS_DP:
+ if (MatchUsbClass ((USB_CLASS_DEVICE_PATH *)WantedListItem->DevicePath, UsbIf)) {
DoConvert = TRUE;
}
- }
- break;
- case MSG_USB_CLASS_DP:
- if (MatchUsbClass((USB_CLASS_DEVICE_PATH *)WantedListItem->DevicePath, UsbIf)) {
- DoConvert = TRUE;
- }
- break;
- case MSG_USB_WWID_DP:
- if (MatchUsbWwid((USB_WWID_DEVICE_PATH *)WantedListItem->DevicePath, UsbIf)) {
- DoConvert = TRUE;
- }
- break;
- default:
- ASSERT (0);
- break;
+
+ break;
+ case MSG_USB_WWID_DP:
+ if (MatchUsbWwid ((USB_WWID_DEVICE_PATH *)WantedListItem->DevicePath, UsbIf)) {
+ DoConvert = TRUE;
+ }
+
+ break;
+ default:
+ ASSERT (0);
+ break;
}
if (DoConvert) {
@@ -1123,12 +1106,13 @@ UsbBusIsWantedUsbIO (
WantedListIndex = WantedListIndex->ForwardLink;
}
+
gBS->FreePool (DevicePathPtr);
//
// Check whether the new Usb device path is wanted
//
- if (DoConvert){
+ if (DoConvert) {
return TRUE;
} else {
return FALSE;
@@ -1148,19 +1132,19 @@ UsbBusIsWantedUsbIO (
EFI_STATUS
EFIAPI
UsbBusRecursivelyConnectWantedUsbIo (
- IN EFI_USB_BUS_PROTOCOL *UsbBusId
+ IN EFI_USB_BUS_PROTOCOL *UsbBusId
)
{
- USB_BUS *Bus;
- EFI_STATUS Status;
- UINTN Index;
- EFI_USB_IO_PROTOCOL *UsbIo;
- USB_INTERFACE *UsbIf;
- UINTN UsbIoHandleCount;
- EFI_HANDLE *UsbIoBuffer;
- EFI_DEVICE_PATH_PROTOCOL *UsbIoDevicePath;
-
- if (UsbBusId == NULL){
+ USB_BUS *Bus;
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ USB_INTERFACE *UsbIf;
+ UINTN UsbIoHandleCount;
+ EFI_HANDLE *UsbIoBuffer;
+ EFI_DEVICE_PATH_PROTOCOL *UsbIoDevicePath;
+
+ if (UsbBusId == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -1170,10 +1154,11 @@ UsbBusRecursivelyConnectWantedUsbIo (
// Get all Usb IO handles in system
//
UsbIoHandleCount = 0;
- Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiUsbIoProtocolGuid, NULL, &UsbIoHandleCount, &UsbIoBuffer);
- if (Status == EFI_NOT_FOUND || UsbIoHandleCount == 0) {
+ Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiUsbIoProtocolGuid, NULL, &UsbIoHandleCount, &UsbIoBuffer);
+ if ((Status == EFI_NOT_FOUND) || (UsbIoHandleCount == 0)) {
return EFI_SUCCESS;
}
+
ASSERT (!EFI_ERROR (Status));
for (Index = 0; Index < UsbIoHandleCount; Index++) {
@@ -1182,30 +1167,33 @@ UsbBusRecursivelyConnectWantedUsbIo (
// Note: The usb child handle maybe invalid because of hot plugged out during the loop
//
UsbIoDevicePath = NULL;
- Status = gBS->HandleProtocol (UsbIoBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID *) &UsbIoDevicePath);
- if (EFI_ERROR (Status) || UsbIoDevicePath == NULL) {
+ Status = gBS->HandleProtocol (UsbIoBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID *)&UsbIoDevicePath);
+ if (EFI_ERROR (Status) || (UsbIoDevicePath == NULL)) {
continue;
}
+
if (CompareMem (
- UsbIoDevicePath,
- Bus->DevicePath,
- (GetDevicePathSize (Bus->DevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL))
- ) != 0) {
+ UsbIoDevicePath,
+ Bus->DevicePath,
+ (GetDevicePathSize (Bus->DevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL))
+ ) != 0)
+ {
continue;
}
//
// Get the child Usb IO interface
//
- Status = gBS->HandleProtocol(
- UsbIoBuffer[Index],
- &gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo
- );
+ Status = gBS->HandleProtocol (
+ UsbIoBuffer[Index],
+ &gEfiUsbIoProtocolGuid,
+ (VOID **)&UsbIo
+ );
if (EFI_ERROR (Status)) {
continue;
}
- UsbIf = USB_INTERFACE_FROM_USBIO (UsbIo);
+
+ UsbIf = USB_INTERFACE_FROM_USBIO (UsbIo);
if (UsbBusIsWantedUsbIO (Bus, UsbIf)) {
if (!UsbIf->IsManaged) {
@@ -1213,9 +1201,9 @@ UsbBusRecursivelyConnectWantedUsbIo (
// Recursively connect the wanted Usb Io handle
//
DEBUG ((DEBUG_INFO, "UsbBusRecursivelyConnectWantedUsbIo: TPL before connect is %d\n", (UINT32)UsbGetCurrentTpl ()));
- Status = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);
- UsbIf->IsManaged = (BOOLEAN)!EFI_ERROR (Status);
- DEBUG ((DEBUG_INFO, "UsbBusRecursivelyConnectWantedUsbIo: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl()));
+ Status = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);
+ UsbIf->IsManaged = (BOOLEAN) !EFI_ERROR (Status);
+ DEBUG ((DEBUG_INFO, "UsbBusRecursivelyConnectWantedUsbIo: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl ()));
}
}
}
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h
index 1d2b8a6..04cf36d 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h
@@ -24,13 +24,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
UsbHcGetCapability (
- IN USB_BUS *UsbBus,
- OUT UINT8 *MaxSpeed,
- OUT UINT8 *NumOfPort,
- OUT UINT8 *Is64BitCapable
+ IN USB_BUS *UsbBus,
+ OUT UINT8 *MaxSpeed,
+ OUT UINT8 *NumOfPort,
+ OUT UINT8 *Is64BitCapable
);
-
/**
Get the root hub port state.
@@ -44,9 +43,9 @@ UsbHcGetCapability (
**/
EFI_STATUS
UsbHcGetRootHubPortStatus (
- IN USB_BUS *UsbBus,
- IN UINT8 PortIndex,
- OUT EFI_USB_PORT_STATUS *PortStatus
+ IN USB_BUS *UsbBus,
+ IN UINT8 PortIndex,
+ OUT EFI_USB_PORT_STATUS *PortStatus
);
/**
@@ -62,9 +61,9 @@ UsbHcGetRootHubPortStatus (
**/
EFI_STATUS
UsbHcSetRootHubPortFeature (
- IN USB_BUS *UsbBus,
- IN UINT8 PortIndex,
- IN EFI_USB_PORT_FEATURE Feature
+ IN USB_BUS *UsbBus,
+ IN UINT8 PortIndex,
+ IN EFI_USB_PORT_FEATURE Feature
);
/**
@@ -80,9 +79,9 @@ UsbHcSetRootHubPortFeature (
**/
EFI_STATUS
UsbHcClearRootHubPortFeature (
- IN USB_BUS *UsbBus,
- IN UINT8 PortIndex,
- IN EFI_USB_PORT_FEATURE Feature
+ IN USB_BUS *UsbBus,
+ IN UINT8 PortIndex,
+ IN EFI_USB_PORT_FEATURE Feature
);
/**
@@ -231,7 +230,6 @@ UsbHcSyncInterruptTransfer (
OUT UINT32 *UsbResult
);
-
/**
Open the USB host controller protocol BY_CHILD.
@@ -243,8 +241,8 @@ UsbHcSyncInterruptTransfer (
**/
EFI_STATUS
UsbOpenHostProtoByChild (
- IN USB_BUS *Bus,
- IN EFI_HANDLE Child
+ IN USB_BUS *Bus,
+ IN EFI_HANDLE Child
);
/**
@@ -258,8 +256,8 @@ UsbOpenHostProtoByChild (
**/
VOID
UsbCloseHostProtoByChild (
- IN USB_BUS *Bus,
- IN EFI_HANDLE Child
+ IN USB_BUS *Bus,
+ IN EFI_HANDLE Child
);
/**
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c b/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c
index ce6db0b..df38227 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c
@@ -26,10 +26,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
PeiHubGetPortStatus (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 Port,
- OUT UINT32 *PortStatus
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT8 Port,
+ OUT UINT32 *PortStatus
)
{
EFI_USB_DEVICE_REQUEST DeviceRequest;
@@ -42,8 +42,7 @@ PeiHubGetPortStatus (
DeviceRequest.RequestType = USB_HUB_GET_PORT_STATUS_REQ_TYPE;
DeviceRequest.Request = USB_HUB_GET_PORT_STATUS;
DeviceRequest.Index = Port;
- DeviceRequest.Length = (UINT16) sizeof (UINT32);
-
+ DeviceRequest.Length = (UINT16)sizeof (UINT32);
return UsbIoPpi->UsbControlTransfer (
PeiServices,
@@ -54,7 +53,6 @@ PeiHubGetPortStatus (
PortStatus,
sizeof (UINT32)
);
-
}
/**
@@ -72,13 +70,13 @@ PeiHubGetPortStatus (
**/
EFI_STATUS
PeiHubSetPortFeature (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 Port,
- IN UINT8 Value
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT8 Port,
+ IN UINT8 Value
)
{
- EFI_USB_DEVICE_REQUEST DeviceRequest;
+ EFI_USB_DEVICE_REQUEST DeviceRequest;
ZeroMem (&DeviceRequest, sizeof (EFI_USB_DEVICE_REQUEST));
@@ -116,13 +114,13 @@ PeiHubSetPortFeature (
**/
EFI_STATUS
PeiHubClearPortFeature (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 Port,
- IN UINT8 Value
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT8 Port,
+ IN UINT8 Value
)
{
- EFI_USB_DEVICE_REQUEST DeviceRequest;
+ EFI_USB_DEVICE_REQUEST DeviceRequest;
ZeroMem (&DeviceRequest, sizeof (EFI_USB_DEVICE_REQUEST));
@@ -159,9 +157,9 @@ PeiHubClearPortFeature (
**/
EFI_STATUS
PeiHubGetHubStatus (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- OUT UINT32 *HubStatus
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ OUT UINT32 *HubStatus
)
{
EFI_USB_DEVICE_REQUEST DeviceRequest;
@@ -173,7 +171,7 @@ PeiHubGetHubStatus (
//
DeviceRequest.RequestType = USB_HUB_GET_HUB_STATUS_REQ_TYPE;
DeviceRequest.Request = USB_HUB_GET_HUB_STATUS;
- DeviceRequest.Length = (UINT16) sizeof (UINT32);
+ DeviceRequest.Length = (UINT16)sizeof (UINT32);
return UsbIoPpi->UsbControlTransfer (
PeiServices,
@@ -186,8 +184,6 @@ PeiHubGetHubStatus (
);
}
-
-
/**
Clear specified feature on a given hub.
@@ -202,12 +198,12 @@ PeiHubGetHubStatus (
**/
EFI_STATUS
PeiHubClearHubFeature (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 Value
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT8 Value
)
{
- EFI_USB_DEVICE_REQUEST DeviceRequest;
+ EFI_USB_DEVICE_REQUEST DeviceRequest;
ZeroMem (&DeviceRequest, sizeof (EFI_USB_DEVICE_REQUEST));
@@ -218,15 +214,15 @@ PeiHubClearHubFeature (
DeviceRequest.Request = USB_HUB_CLEAR_FEATURE;
DeviceRequest.Value = Value;
- return UsbIoPpi->UsbControlTransfer (
- PeiServices,
- UsbIoPpi,
- &DeviceRequest,
- EfiUsbNoData,
- PcdGet32 (PcdUsbTransferTimeoutValue),
- NULL,
- 0
- );
+ return UsbIoPpi->UsbControlTransfer (
+ PeiServices,
+ UsbIoPpi,
+ &DeviceRequest,
+ EfiUsbNoData,
+ PcdGet32 (PcdUsbTransferTimeoutValue),
+ NULL,
+ 0
+ );
}
/**
@@ -246,15 +242,15 @@ PeiHubClearHubFeature (
**/
EFI_STATUS
PeiGetHubDescriptor (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_DEVICE *PeiUsbDevice,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINTN DescriptorSize,
- OUT EFI_USB_HUB_DESCRIPTOR *HubDescriptor
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_DEVICE *PeiUsbDevice,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINTN DescriptorSize,
+ OUT EFI_USB_HUB_DESCRIPTOR *HubDescriptor
)
{
- EFI_USB_DEVICE_REQUEST DevReq;
- UINT8 DescType;
+ EFI_USB_DEVICE_REQUEST DevReq;
+ UINT8 DescType;
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
@@ -267,18 +263,18 @@ PeiGetHubDescriptor (
//
DevReq.RequestType = USB_RT_HUB | 0x80;
DevReq.Request = USB_HUB_GET_DESCRIPTOR;
- DevReq.Value = (UINT16) (DescType << 8);
- DevReq.Length = (UINT16) DescriptorSize;
-
- return UsbIoPpi->UsbControlTransfer (
- PeiServices,
- UsbIoPpi,
- &DevReq,
- EfiUsbDataIn,
- PcdGet32 (PcdUsbTransferTimeoutValue),
- HubDescriptor,
- (UINT16)DescriptorSize
- );
+ DevReq.Value = (UINT16)(DescType << 8);
+ DevReq.Length = (UINT16)DescriptorSize;
+
+ return UsbIoPpi->UsbControlTransfer (
+ PeiServices,
+ UsbIoPpi,
+ &DevReq,
+ EfiUsbDataIn,
+ PcdGet32 (PcdUsbTransferTimeoutValue),
+ HubDescriptor,
+ (UINT16)DescriptorSize
+ );
}
/**
@@ -299,13 +295,13 @@ PeiGetHubDescriptor (
**/
EFI_STATUS
PeiUsbHubReadDesc (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_DEVICE *PeiUsbDevice,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- OUT EFI_USB_HUB_DESCRIPTOR *HubDescriptor
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_DEVICE *PeiUsbDevice,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ OUT EFI_USB_HUB_DESCRIPTOR *HubDescriptor
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// First get the hub descriptor length
@@ -335,12 +331,13 @@ PeiUsbHubReadDesc (
**/
EFI_STATUS
PeiUsbHubCtrlSetHubDepth (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_DEVICE *PeiUsbDevice,
- IN PEI_USB_IO_PPI *UsbIoPpi
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_DEVICE *PeiUsbDevice,
+ IN PEI_USB_IO_PPI *UsbIoPpi
)
{
- EFI_USB_DEVICE_REQUEST DevReq;
+ EFI_USB_DEVICE_REQUEST DevReq;
+
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
//
@@ -351,15 +348,15 @@ PeiUsbHubCtrlSetHubDepth (
DevReq.Value = PeiUsbDevice->Tier;
DevReq.Length = 0;
- return UsbIoPpi->UsbControlTransfer (
- PeiServices,
- UsbIoPpi,
- &DevReq,
- EfiUsbNoData,
- PcdGet32 (PcdUsbTransferTimeoutValue),
- NULL,
- 0
- );
+ return UsbIoPpi->UsbControlTransfer (
+ PeiServices,
+ UsbIoPpi,
+ &DevReq,
+ EfiUsbNoData,
+ PcdGet32 (PcdUsbTransferTimeoutValue),
+ NULL,
+ 0
+ );
}
/**
@@ -374,8 +371,8 @@ PeiUsbHubCtrlSetHubDepth (
**/
EFI_STATUS
PeiDoHubConfig (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_DEVICE *PeiUsbDevice
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_DEVICE *PeiUsbDevice
)
{
UINT8 HubDescBuffer[256];
@@ -391,17 +388,17 @@ PeiDoHubConfig (
// The length field of descriptor is UINT8 type, so the buffer
// with 256 bytes is enough to hold the descriptor data.
//
- HubDescriptor = (EFI_USB_HUB_DESCRIPTOR *) HubDescBuffer;
+ HubDescriptor = (EFI_USB_HUB_DESCRIPTOR *)HubDescBuffer;
//
// Get the hub descriptor
//
Status = PeiUsbHubReadDesc (
- PeiServices,
- PeiUsbDevice,
- UsbIoPpi,
- HubDescriptor
- );
+ PeiServices,
+ PeiUsbDevice,
+ UsbIoPpi,
+ HubDescriptor
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -421,18 +418,18 @@ PeiDoHubConfig (
//
for (Index = 0; Index < PeiUsbDevice->DownStreamPortNo; Index++) {
Status = PeiHubSetPortFeature (
- PeiServices,
- UsbIoPpi,
- (UINT8) (Index + 1),
- EfiUsbPortPower
- );
+ PeiServices,
+ UsbIoPpi,
+ (UINT8)(Index + 1),
+ EfiUsbPortPower
+ );
if (EFI_ERROR (Status)) {
- DEBUG (( DEBUG_ERROR, "PeiDoHubConfig: PeiHubSetPortFeature EfiUsbPortPower failed %x\n", Index));
+ DEBUG ((DEBUG_ERROR, "PeiDoHubConfig: PeiHubSetPortFeature EfiUsbPortPower failed %x\n", Index));
continue;
}
}
- DEBUG (( DEBUG_INFO, "PeiDoHubConfig: HubDescriptor.PwrOn2PwrGood: 0x%x\n", HubDescriptor->PwrOn2PwrGood));
+ DEBUG ((DEBUG_INFO, "PeiDoHubConfig: HubDescriptor.PwrOn2PwrGood: 0x%x\n", HubDescriptor->PwrOn2PwrGood));
if (HubDescriptor->PwrOn2PwrGood > 0) {
MicroSecondDelay (HubDescriptor->PwrOn2PwrGood * USB_SET_PORT_POWER_STALL);
}
@@ -441,10 +438,10 @@ PeiDoHubConfig (
// Clear Hub Status Change
//
Status = PeiHubGetHubStatus (
- PeiServices,
- UsbIoPpi,
- (UINT32 *) &HubStatus
- );
+ PeiServices,
+ UsbIoPpi,
+ (UINT32 *)&HubStatus
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
} else {
@@ -458,6 +455,7 @@ PeiDoHubConfig (
C_HUB_LOCAL_POWER
);
}
+
//
// Hub change overcurrent happens
//
@@ -484,14 +482,14 @@ PeiDoHubConfig (
**/
VOID
PeiResetHubPort (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 PortNum
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT8 PortNum
)
{
- EFI_STATUS Status;
- UINTN Index;
- EFI_USB_PORT_STATUS HubPortStatus;
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_USB_PORT_STATUS HubPortStatus;
MicroSecondDelay (100 * 1000);
@@ -521,7 +519,7 @@ PeiResetHubPort (
PeiServices,
UsbIoPpi,
PortNum,
- (UINT32 *) &HubPortStatus
+ (UINT32 *)&HubPortStatus
);
if (EFI_ERROR (Status)) {
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.h b/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.h
index 2a6d911..abf5ba7 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.h
+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.h
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _PEI_HUB_PEIM_H_
#define _PEI_HUB_PEIM_H_
-
//
// Hub feature numbers
//
@@ -35,45 +34,45 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Hub Characteristics
//
-#define HUB_CHAR_LPSM 0x0003
-#define HUB_CHAR_COMPOUND 0x0004
-#define HUB_CHAR_OCPM 0x0018
+#define HUB_CHAR_LPSM 0x0003
+#define HUB_CHAR_COMPOUND 0x0004
+#define HUB_CHAR_OCPM 0x0018
//
// Standard hub request and request type
// By [Spec-USB20/Chapter-11.24]
//
-#define USB_HUB_CLEAR_FEATURE 0x01
-#define USB_HUB_CLEAR_FEATURE_REQ_TYPE 0x20
+#define USB_HUB_CLEAR_FEATURE 0x01
+#define USB_HUB_CLEAR_FEATURE_REQ_TYPE 0x20
-#define USB_HUB_CLEAR_FEATURE_PORT 0x01
-#define USB_HUB_CLEAR_FEATURE_PORT_REQ_TYPE 0x23
+#define USB_HUB_CLEAR_FEATURE_PORT 0x01
+#define USB_HUB_CLEAR_FEATURE_PORT_REQ_TYPE 0x23
-#define USB_HUB_GET_BUS_STATE 0x02
-#define USB_HUB_GET_BUS_STATE_REQ_TYPE 0xA3
+#define USB_HUB_GET_BUS_STATE 0x02
+#define USB_HUB_GET_BUS_STATE_REQ_TYPE 0xA3
-#define USB_HUB_GET_DESCRIPTOR 0x06
-#define USB_HUB_GET_DESCRIPTOR_REQ_TYPE 0xA0
+#define USB_HUB_GET_DESCRIPTOR 0x06
+#define USB_HUB_GET_DESCRIPTOR_REQ_TYPE 0xA0
-#define USB_HUB_GET_HUB_STATUS 0x00
-#define USB_HUB_GET_HUB_STATUS_REQ_TYPE 0xA0
+#define USB_HUB_GET_HUB_STATUS 0x00
+#define USB_HUB_GET_HUB_STATUS_REQ_TYPE 0xA0
-#define USB_HUB_GET_PORT_STATUS 0x00
-#define USB_HUB_GET_PORT_STATUS_REQ_TYPE 0xA3
+#define USB_HUB_GET_PORT_STATUS 0x00
+#define USB_HUB_GET_PORT_STATUS_REQ_TYPE 0xA3
-#define USB_HUB_SET_DESCRIPTOR 0x07
-#define USB_HUB_SET_DESCRIPTOR_REQ_TYPE 0x20
+#define USB_HUB_SET_DESCRIPTOR 0x07
+#define USB_HUB_SET_DESCRIPTOR_REQ_TYPE 0x20
-#define USB_HUB_SET_HUB_FEATURE 0x03
-#define USB_HUB_SET_HUB_FEATURE_REQ_TYPE 0x20
+#define USB_HUB_SET_HUB_FEATURE 0x03
+#define USB_HUB_SET_HUB_FEATURE_REQ_TYPE 0x20
-#define USB_HUB_SET_PORT_FEATURE 0x03
-#define USB_HUB_SET_PORT_FEATURE_REQ_TYPE 0x23
+#define USB_HUB_SET_PORT_FEATURE 0x03
+#define USB_HUB_SET_PORT_FEATURE_REQ_TYPE 0x23
-#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
-#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
+#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
+#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
-#define USB_HUB_REQ_SET_DEPTH 12
+#define USB_HUB_REQ_SET_DEPTH 12
#define MAXBYTES 8
#pragma pack(1)
@@ -81,21 +80,22 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Hub descriptor, the last two fields are of variable length.
//
typedef struct {
- UINT8 Length;
- UINT8 DescriptorType;
- UINT8 NbrPorts;
- UINT8 HubCharacteristics[2];
- UINT8 PwrOn2PwrGood;
- UINT8 HubContrCurrent;
- UINT8 Filler[MAXBYTES];
+ UINT8 Length;
+ UINT8 DescriptorType;
+ UINT8 NbrPorts;
+ UINT8 HubCharacteristics[2];
+ UINT8 PwrOn2PwrGood;
+ UINT8 HubContrCurrent;
+ UINT8 Filler[MAXBYTES];
} EFI_USB_HUB_DESCRIPTOR;
typedef struct {
- UINT16 HubStatus;
- UINT16 HubChangeStatus;
+ UINT16 HubStatus;
+ UINT16 HubChangeStatus;
} EFI_USB_HUB_STATUS;
#pragma pack()
+
/**
Get a given hub port status.
@@ -111,10 +111,10 @@ typedef struct {
**/
EFI_STATUS
PeiHubGetPortStatus (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 Port,
- OUT UINT32 *PortStatus
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT8 Port,
+ OUT UINT32 *PortStatus
);
/**
@@ -132,13 +132,12 @@ PeiHubGetPortStatus (
**/
EFI_STATUS
PeiHubSetPortFeature (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 Port,
- IN UINT8 Value
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT8 Port,
+ IN UINT8 Value
);
-
/**
Get a given hub status.
@@ -153,9 +152,9 @@ PeiHubSetPortFeature (
**/
EFI_STATUS
PeiHubGetHubStatus (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- OUT UINT32 *HubStatus
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ OUT UINT32 *HubStatus
);
/**
@@ -173,10 +172,10 @@ PeiHubGetHubStatus (
**/
EFI_STATUS
PeiHubClearPortFeature (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 Port,
- IN UINT8 Value
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT8 Port,
+ IN UINT8 Value
);
/**
@@ -193,9 +192,9 @@ PeiHubClearPortFeature (
**/
EFI_STATUS
PeiHubClearHubFeature (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 Value
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT8 Value
);
/**
@@ -234,8 +233,8 @@ PeiGetHubDescriptor (
**/
EFI_STATUS
PeiDoHubConfig (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_DEVICE *PeiUsbDevice
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_DEVICE *PeiUsbDevice
);
/**
@@ -248,11 +247,9 @@ PeiDoHubConfig (
**/
VOID
PeiResetHubPort (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 PortNum
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT8 PortNum
);
#endif
-
-
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c b/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c
index 1385b0a..8cb205e 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c
@@ -28,23 +28,23 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
PeiUsbGetDescriptor (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT16 Value,
- IN UINT16 Index,
- IN UINT16 DescriptorLength,
- OUT VOID *Descriptor
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT16 Value,
+ IN UINT16 Index,
+ IN UINT16 DescriptorLength,
+ OUT VOID *Descriptor
)
{
EFI_USB_DEVICE_REQUEST DevReq;
ASSERT (UsbIoPpi != NULL);
- DevReq.RequestType = USB_DEV_GET_DESCRIPTOR_REQ_TYPE;
- DevReq.Request = USB_DEV_GET_DESCRIPTOR;
- DevReq.Value = Value;
- DevReq.Index = Index;
- DevReq.Length = DescriptorLength;
+ DevReq.RequestType = USB_DEV_GET_DESCRIPTOR_REQ_TYPE;
+ DevReq.Request = USB_DEV_GET_DESCRIPTOR;
+ DevReq.Value = Value;
+ DevReq.Index = Index;
+ DevReq.Length = DescriptorLength;
return UsbIoPpi->UsbControlTransfer (
PeiServices,
@@ -71,20 +71,20 @@ PeiUsbGetDescriptor (
**/
EFI_STATUS
PeiUsbSetDeviceAddress (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT16 AddressValue
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT16 AddressValue
)
{
EFI_USB_DEVICE_REQUEST DevReq;
ASSERT (UsbIoPpi != NULL);
- DevReq.RequestType = USB_DEV_SET_ADDRESS_REQ_TYPE;
- DevReq.Request = USB_DEV_SET_ADDRESS;
- DevReq.Value = AddressValue;
- DevReq.Index = 0;
- DevReq.Length = 0;
+ DevReq.RequestType = USB_DEV_SET_ADDRESS_REQ_TYPE;
+ DevReq.Request = USB_DEV_SET_ADDRESS;
+ DevReq.Value = AddressValue;
+ DevReq.Index = 0;
+ DevReq.Length = 0;
return UsbIoPpi->UsbControlTransfer (
PeiServices,
@@ -97,8 +97,6 @@ PeiUsbSetDeviceAddress (
);
}
-
-
/**
Configure a usb device to Configuration 1.
@@ -112,16 +110,17 @@ PeiUsbSetDeviceAddress (
**/
EFI_STATUS
PeiUsbSetConfiguration (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi
)
{
EFI_USB_DEVICE_REQUEST DevReq;
+
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
- DevReq.RequestType = USB_DEV_SET_CONFIGURATION_REQ_TYPE;
- DevReq.Request = USB_DEV_SET_CONFIGURATION;
- DevReq.Value = 1;
+ DevReq.RequestType = USB_DEV_SET_CONFIGURATION_REQ_TYPE;
+ DevReq.Request = USB_DEV_SET_CONFIGURATION;
+ DevReq.Value = 1;
return UsbIoPpi->UsbControlTransfer (
PeiServices,
@@ -168,12 +167,12 @@ IsPortConnect (
**/
UINTN
PeiUsbGetDeviceSpeed (
- IN UINT16 PortStatus
+ IN UINT16 PortStatus
)
{
if ((PortStatus & USB_PORT_STAT_LOW_SPEED) != 0) {
return EFI_USB_SPEED_LOW;
- } else if ((PortStatus & USB_PORT_STAT_HIGH_SPEED) != 0){
+ } else if ((PortStatus & USB_PORT_STAT_HIGH_SPEED) != 0) {
return EFI_USB_SPEED_HIGH;
} else if ((PortStatus & USB_PORT_STAT_SUPER_SPEED) != 0) {
return EFI_USB_SPEED_SUPER;
@@ -181,5 +180,3 @@ PeiUsbGetDeviceSpeed (
return EFI_USB_SPEED_FULL;
}
}
-
-
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h b/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h
index 48b8e59..23f531e 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h
+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h
@@ -10,34 +10,33 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _PEI_USB_LIB_H_
#define _PEI_USB_LIB_H_
-
//
// Standard device request and request type
// By [Spec-USB20/Chapter-9.4]
//
-#define USB_DEV_GET_STATUS 0x00
-#define USB_DEV_GET_STATUS_REQ_TYPE_D 0x80 // Receiver : Device
-#define USB_DEV_GET_STATUS_REQ_TYPE_I 0x81 // Receiver : Interface
-#define USB_DEV_GET_STATUS_REQ_TYPE_E 0x82 // Receiver : Endpoint
+#define USB_DEV_GET_STATUS 0x00
+#define USB_DEV_GET_STATUS_REQ_TYPE_D 0x80 // Receiver : Device
+#define USB_DEV_GET_STATUS_REQ_TYPE_I 0x81 // Receiver : Interface
+#define USB_DEV_GET_STATUS_REQ_TYPE_E 0x82 // Receiver : Endpoint
-#define USB_DEV_CLEAR_FEATURE 0x01
-#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device
-#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface
-#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint
+#define USB_DEV_CLEAR_FEATURE 0x01
+#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device
+#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface
+#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint
-#define USB_DEV_SET_FEATURE 0x03
-#define USB_DEV_SET_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device
-#define USB_DEV_SET_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface
-#define USB_DEV_SET_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint
+#define USB_DEV_SET_FEATURE 0x03
+#define USB_DEV_SET_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device
+#define USB_DEV_SET_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface
+#define USB_DEV_SET_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint
-#define USB_DEV_SET_ADDRESS 0x05
-#define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00
+#define USB_DEV_SET_ADDRESS 0x05
+#define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00
-#define USB_DEV_GET_DESCRIPTOR 0x06
-#define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80
+#define USB_DEV_GET_DESCRIPTOR 0x06
+#define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80
-#define USB_DEV_SET_DESCRIPTOR 0x07
-#define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00
+#define USB_DEV_SET_DESCRIPTOR 0x07
+#define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00
#define USB_DEV_GET_CONFIGURATION 0x08
#define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80
@@ -45,42 +44,42 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define USB_DEV_SET_CONFIGURATION 0x09
#define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00
-#define USB_DEV_GET_INTERFACE 0x0A
-#define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81
+#define USB_DEV_GET_INTERFACE 0x0A
+#define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81
-#define USB_DEV_SET_INTERFACE 0x0B
-#define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01
+#define USB_DEV_SET_INTERFACE 0x0B
+#define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01
-#define USB_DEV_SYNCH_FRAME 0x0C
-#define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82
+#define USB_DEV_SYNCH_FRAME 0x0C
+#define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82
//
// USB Descriptor types
//
-#define USB_DT_DEVICE 0x01
-#define USB_DT_CONFIG 0x02
-#define USB_DT_STRING 0x03
-#define USB_DT_INTERFACE 0x04
-#define USB_DT_ENDPOINT 0x05
-#define USB_DT_HUB 0x29
-#define USB_DT_SUPERSPEED_HUB 0x2A
-#define USB_DT_HID 0x21
+#define USB_DT_DEVICE 0x01
+#define USB_DT_CONFIG 0x02
+#define USB_DT_STRING 0x03
+#define USB_DT_INTERFACE 0x04
+#define USB_DT_ENDPOINT 0x05
+#define USB_DT_HUB 0x29
+#define USB_DT_SUPERSPEED_HUB 0x2A
+#define USB_DT_HID 0x21
//
// USB request type
//
-#define USB_TYPE_STANDARD (0x00 << 5)
-#define USB_TYPE_CLASS (0x01 << 5)
-#define USB_TYPE_VENDOR (0x02 << 5)
-#define USB_TYPE_RESERVED (0x03 << 5)
+#define USB_TYPE_STANDARD (0x00 << 5)
+#define USB_TYPE_CLASS (0x01 << 5)
+#define USB_TYPE_VENDOR (0x02 << 5)
+#define USB_TYPE_RESERVED (0x03 << 5)
//
// USB request targer device
//
-#define USB_RECIP_DEVICE 0x00
-#define USB_RECIP_INTERFACE 0x01
-#define USB_RECIP_ENDPOINT 0x02
-#define USB_RECIP_OTHER 0x03
+#define USB_RECIP_DEVICE 0x00
+#define USB_RECIP_INTERFACE 0x01
+#define USB_RECIP_ENDPOINT 0x02
+#define USB_RECIP_OTHER 0x03
typedef enum {
EfiUsbEndpointHalt,
@@ -114,12 +113,12 @@ typedef enum {
**/
EFI_STATUS
PeiUsbGetDescriptor (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT16 Value,
- IN UINT16 Index,
- IN UINT16 DescriptorLength,
- OUT VOID *Descriptor
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT16 Value,
+ IN UINT16 Index,
+ IN UINT16 DescriptorLength,
+ OUT VOID *Descriptor
);
/**
@@ -136,12 +135,11 @@ PeiUsbGetDescriptor (
**/
EFI_STATUS
PeiUsbSetDeviceAddress (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT16 AddressValue
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi,
+ IN UINT16 AddressValue
);
-
/**
Configure a usb device to Configuration 1.
@@ -155,8 +153,8 @@ PeiUsbSetDeviceAddress (
**/
EFI_STATUS
PeiUsbSetConfiguration (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *UsbIoPpi
);
/**
@@ -183,7 +181,7 @@ IsPortConnect (
**/
UINTN
PeiUsbGetDeviceSpeed (
- IN UINT16 PortStatus
+ IN UINT16 PortStatus
);
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c
index 4b292b7..c428352 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c
@@ -33,29 +33,30 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_STATUS
EFIAPI
PeiUsbControlTransfer (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *This,
- IN EFI_USB_DEVICE_REQUEST *Request,
- IN EFI_USB_DATA_DIRECTION Direction,
- IN UINT32 Timeout,
- IN OUT VOID *Data OPTIONAL,
- IN UINTN DataLength OPTIONAL
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *This,
+ IN EFI_USB_DEVICE_REQUEST *Request,
+ IN EFI_USB_DATA_DIRECTION Direction,
+ IN UINT32 Timeout,
+ IN OUT VOID *Data OPTIONAL,
+ IN UINTN DataLength OPTIONAL
)
{
- EFI_STATUS Status;
- PEI_USB_DEVICE *PeiUsbDev;
- UINT32 TransferResult;
- EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescriptor;
- UINT8 EndpointIndex;
+ EFI_STATUS Status;
+ PEI_USB_DEVICE *PeiUsbDev;
+ UINT32 TransferResult;
+ EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescriptor;
+ UINT8 EndpointIndex;
PeiUsbDev = PEI_USB_DEVICE_FROM_THIS (This);
EndpointDescriptor = NULL;
- EndpointIndex = 0;
+ EndpointIndex = 0;
if ((Request->Request == USB_REQ_CLEAR_FEATURE) &&
(Request->RequestType == USB_DEV_CLEAR_FEATURE_REQ_TYPE_E) &&
- (Request->Value == USB_FEATURE_ENDPOINT_HALT)) {
+ (Request->Value == USB_FEATURE_ENDPOINT_HALT))
+ {
//
// Request->Index is the Endpoint Address, use it to get the Endpoint Index.
//
@@ -79,33 +80,33 @@ PeiUsbControlTransfer (
if (PeiUsbDev->Usb2HcPpi != NULL) {
Status = PeiUsbDev->Usb2HcPpi->ControlTransfer (
- PeiServices,
- PeiUsbDev->Usb2HcPpi,
- PeiUsbDev->DeviceAddress,
- PeiUsbDev->DeviceSpeed,
- PeiUsbDev->MaxPacketSize0,
- Request,
- Direction,
- Data,
- &DataLength,
- Timeout,
- &(PeiUsbDev->Translator),
- &TransferResult
- );
+ PeiServices,
+ PeiUsbDev->Usb2HcPpi,
+ PeiUsbDev->DeviceAddress,
+ PeiUsbDev->DeviceSpeed,
+ PeiUsbDev->MaxPacketSize0,
+ Request,
+ Direction,
+ Data,
+ &DataLength,
+ Timeout,
+ &(PeiUsbDev->Translator),
+ &TransferResult
+ );
} else {
Status = PeiUsbDev->UsbHcPpi->ControlTransfer (
- PeiServices,
- PeiUsbDev->UsbHcPpi,
- PeiUsbDev->DeviceAddress,
- PeiUsbDev->DeviceSpeed,
- (UINT8) PeiUsbDev->MaxPacketSize0,
- Request,
- Direction,
- Data,
- &DataLength,
- Timeout,
- &TransferResult
- );
+ PeiServices,
+ PeiUsbDev->UsbHcPpi,
+ PeiUsbDev->DeviceAddress,
+ PeiUsbDev->DeviceSpeed,
+ (UINT8)PeiUsbDev->MaxPacketSize0,
+ Request,
+ Direction,
+ Data,
+ &DataLength,
+ Timeout,
+ &TransferResult
+ );
}
//
@@ -113,9 +114,10 @@ PeiUsbControlTransfer (
//
if ((Request->Request == USB_REQ_CLEAR_FEATURE) &&
(Request->RequestType == USB_DEV_CLEAR_FEATURE_REQ_TYPE_E) &&
- (Request->Value == USB_FEATURE_ENDPOINT_HALT)) {
+ (Request->Value == USB_FEATURE_ENDPOINT_HALT))
+ {
if ((PeiUsbDev->DataToggle & (1 << EndpointIndex)) != 0) {
- PeiUsbDev->DataToggle = (UINT16) (PeiUsbDev->DataToggle ^ (1 << EndpointIndex));
+ PeiUsbDev->DataToggle = (UINT16)(PeiUsbDev->DataToggle ^ (1 << EndpointIndex));
}
}
@@ -147,30 +149,30 @@ PeiUsbControlTransfer (
EFI_STATUS
EFIAPI
PeiUsbBulkTransfer (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *This,
- IN UINT8 DeviceEndpoint,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINTN Timeout
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *This,
+ IN UINT8 DeviceEndpoint,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN UINTN Timeout
)
{
- EFI_STATUS Status;
- PEI_USB_DEVICE *PeiUsbDev;
- UINT32 TransferResult;
- UINTN MaxPacketLength;
- UINT8 DataToggle;
- UINT8 OldToggle;
- EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescriptor;
- UINT8 EndpointIndex;
- VOID *Data2[EFI_USB_MAX_BULK_BUFFER_NUM];
-
- PeiUsbDev = PEI_USB_DEVICE_FROM_THIS (This);
+ EFI_STATUS Status;
+ PEI_USB_DEVICE *PeiUsbDev;
+ UINT32 TransferResult;
+ UINTN MaxPacketLength;
+ UINT8 DataToggle;
+ UINT8 OldToggle;
+ EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescriptor;
+ UINT8 EndpointIndex;
+ VOID *Data2[EFI_USB_MAX_BULK_BUFFER_NUM];
+
+ PeiUsbDev = PEI_USB_DEVICE_FROM_THIS (This);
EndpointDescriptor = NULL;
- EndpointIndex = 0;
- Data2[0] = Data;
- Data2[1] = NULL;
+ EndpointIndex = 0;
+ Data2[0] = Data;
+ Data2[1] = NULL;
while (EndpointIndex < MAX_ENDPOINT) {
Status = PeiUsbGetEndpointDescriptor (PeiServices, This, EndpointIndex, &EndpointDescriptor);
@@ -200,36 +202,36 @@ PeiUsbBulkTransfer (
if (PeiUsbDev->Usb2HcPpi != NULL) {
Status = PeiUsbDev->Usb2HcPpi->BulkTransfer (
- PeiServices,
- PeiUsbDev->Usb2HcPpi,
- PeiUsbDev->DeviceAddress,
- DeviceEndpoint,
- PeiUsbDev->DeviceSpeed,
- MaxPacketLength,
- Data2,
- DataLength,
- &DataToggle,
- Timeout,
- &(PeiUsbDev->Translator),
- &TransferResult
- );
+ PeiServices,
+ PeiUsbDev->Usb2HcPpi,
+ PeiUsbDev->DeviceAddress,
+ DeviceEndpoint,
+ PeiUsbDev->DeviceSpeed,
+ MaxPacketLength,
+ Data2,
+ DataLength,
+ &DataToggle,
+ Timeout,
+ &(PeiUsbDev->Translator),
+ &TransferResult
+ );
} else {
Status = PeiUsbDev->UsbHcPpi->BulkTransfer (
- PeiServices,
- PeiUsbDev->UsbHcPpi,
- PeiUsbDev->DeviceAddress,
- DeviceEndpoint,
- (UINT8) MaxPacketLength,
- Data,
- DataLength,
- &DataToggle,
- Timeout,
- &TransferResult
- );
+ PeiServices,
+ PeiUsbDev->UsbHcPpi,
+ PeiUsbDev->DeviceAddress,
+ DeviceEndpoint,
+ (UINT8)MaxPacketLength,
+ Data,
+ DataLength,
+ &DataToggle,
+ Timeout,
+ &TransferResult
+ );
}
if (OldToggle != DataToggle) {
- PeiUsbDev->DataToggle = (UINT16) (PeiUsbDev->DataToggle ^ (1 << EndpointIndex));
+ PeiUsbDev->DataToggle = (UINT16)(PeiUsbDev->DataToggle ^ (1 << EndpointIndex));
}
DEBUG ((DEBUG_INFO, "PeiUsbBulkTransfer: %r\n", Status));
@@ -250,14 +252,15 @@ PeiUsbBulkTransfer (
EFI_STATUS
EFIAPI
PeiUsbGetInterfaceDescriptor (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *This,
- OUT EFI_USB_INTERFACE_DESCRIPTOR **InterfaceDescriptor
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *This,
+ OUT EFI_USB_INTERFACE_DESCRIPTOR **InterfaceDescriptor
)
{
PEI_USB_DEVICE *PeiUsbDev;
- PeiUsbDev = PEI_USB_DEVICE_FROM_THIS (This);
- *InterfaceDescriptor = PeiUsbDev->InterfaceDesc;
+
+ PeiUsbDev = PEI_USB_DEVICE_FROM_THIS (This);
+ *InterfaceDescriptor = PeiUsbDev->InterfaceDesc;
return EFI_SUCCESS;
}
@@ -276,10 +279,10 @@ PeiUsbGetInterfaceDescriptor (
EFI_STATUS
EFIAPI
PeiUsbGetEndpointDescriptor (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *This,
- IN UINT8 EndpointIndex,
- OUT EFI_USB_ENDPOINT_DESCRIPTOR **EndpointDescriptor
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *This,
+ IN UINT8 EndpointIndex,
+ OUT EFI_USB_ENDPOINT_DESCRIPTOR **EndpointDescriptor
)
{
PEI_USB_DEVICE *PeiUsbDev;
@@ -317,8 +320,8 @@ PeiUsbGetEndpointDescriptor (
EFI_STATUS
EFIAPI
PeiUsbPortReset (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *This
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *This
)
{
PEI_USB_DEVICE *PeiUsbDev;
@@ -338,14 +341,14 @@ PeiUsbPortReset (
//
// Set address
//
- Address = PeiUsbDev->DeviceAddress;
- PeiUsbDev->DeviceAddress = 0;
+ Address = PeiUsbDev->DeviceAddress;
+ PeiUsbDev->DeviceAddress = 0;
Status = PeiUsbSetDeviceAddress (
- PeiServices,
- This,
- Address
- );
+ PeiServices,
+ This,
+ Address
+ );
if (EFI_ERROR (Status)) {
return Status;
@@ -357,9 +360,9 @@ PeiUsbPortReset (
// Set default configuration
//
Status = PeiUsbSetConfiguration (
- PeiServices,
- This
- );
+ PeiServices,
+ This
+ );
return Status;
}
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c
index 12dc975..6ea4495 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c
@@ -14,7 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// UsbIo PPI interface function
//
-PEI_USB_IO_PPI mUsbIoPpi = {
+PEI_USB_IO_PPI mUsbIoPpi = {
PeiUsbControlTransfer,
PeiUsbBulkTransfer,
PeiUsbGetInterfaceDescriptor,
@@ -22,7 +22,7 @@ PEI_USB_IO_PPI mUsbIoPpi = {
PeiUsbPortReset
};
-EFI_PEI_PPI_DESCRIPTOR mUsbIoPpiList = {
+EFI_PEI_PPI_DESCRIPTOR mUsbIoPpiList = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gPeiUsbIoPpiGuid,
NULL
@@ -42,9 +42,9 @@ EFI_PEI_PPI_DESCRIPTOR mUsbIoPpiList = {
**/
EFI_STATUS
PeiUsbEnumeration (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
- IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
+ IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi
);
/**
@@ -62,10 +62,10 @@ PeiUsbEnumeration (
**/
EFI_STATUS
PeiConfigureUsbDevice (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_DEVICE *PeiUsbDevice,
- IN UINT8 Port,
- IN OUT UINT8 *DeviceAddress
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_DEVICE *PeiUsbDevice,
+ IN UINT8 Port,
+ IN OUT UINT8 *DeviceAddress
);
/**
@@ -81,8 +81,8 @@ PeiConfigureUsbDevice (
**/
EFI_STATUS
PeiUsbGetAllConfiguration (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_DEVICE *PeiUsbDevice
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_DEVICE *PeiUsbDevice
);
/**
@@ -100,11 +100,11 @@ PeiUsbGetAllConfiguration (
**/
EFI_STATUS
GetExpectedDescriptor (
- IN UINT8 *Buffer,
- IN UINTN Length,
- IN UINT8 DescType,
- IN UINT8 DescLength,
- OUT UINTN *ParsedBytes
+ IN UINT8 *Buffer,
+ IN UINTN Length,
+ IN UINT8 DescType,
+ IN UINT8 DescLength,
+ OUT UINTN *ParsedBytes
);
/**
@@ -121,14 +121,14 @@ GetExpectedDescriptor (
EFI_STATUS
EFIAPI
PeimInitializeUsb (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- EFI_STATUS Status;
- UINTN Index;
- PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi;
- PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi;
+ EFI_STATUS Status;
+ UINTN Index;
+ PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi;
+ PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi;
if (!EFI_ERROR (PeiServicesRegisterForShadow (FileHandle))) {
return EFI_SUCCESS;
@@ -147,7 +147,7 @@ PeimInitializeUsb (
&gPeiUsbHostControllerPpiGuid,
Index,
NULL,
- (VOID **) &UsbHcPpi
+ (VOID **)&UsbHcPpi
);
if (EFI_ERROR (Status)) {
//
@@ -155,7 +155,8 @@ PeimInitializeUsb (
//
break;
}
- PeiUsbEnumeration ((EFI_PEI_SERVICES **) PeiServices, UsbHcPpi, NULL);
+
+ PeiUsbEnumeration ((EFI_PEI_SERVICES **)PeiServices, UsbHcPpi, NULL);
Index++;
}
@@ -168,7 +169,7 @@ PeimInitializeUsb (
&gPeiUsb2HostControllerPpiGuid,
Index,
NULL,
- (VOID **) &Usb2HcPpi
+ (VOID **)&Usb2HcPpi
);
if (EFI_ERROR (Status)) {
//
@@ -176,7 +177,8 @@ PeimInitializeUsb (
//
break;
}
- PeiUsbEnumeration ((EFI_PEI_SERVICES **) PeiServices, NULL, Usb2HcPpi);
+
+ PeiUsbEnumeration ((EFI_PEI_SERVICES **)PeiServices, NULL, Usb2HcPpi);
Index++;
}
}
@@ -203,9 +205,9 @@ PeimInitializeUsb (
**/
EFI_STATUS
PeiHubEnumeration (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_DEVICE *PeiUsbDevice,
- IN UINT8 *CurrentAddress
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_DEVICE *PeiUsbDevice,
+ IN UINT8 *CurrentAddress
)
{
UINTN Index;
@@ -218,19 +220,17 @@ PeiHubEnumeration (
UINTN InterfaceIndex;
UINTN EndpointIndex;
-
- UsbIoPpi = &PeiUsbDevice->UsbIoPpi;
+ UsbIoPpi = &PeiUsbDevice->UsbIoPpi;
DEBUG ((DEBUG_INFO, "PeiHubEnumeration: DownStreamPortNo: %x\n", PeiUsbDevice->DownStreamPortNo));
for (Index = 0; Index < PeiUsbDevice->DownStreamPortNo; Index++) {
-
Status = PeiHubGetPortStatus (
- PeiServices,
- UsbIoPpi,
- (UINT8) (Index + 1),
- (UINT32 *) &PortStatus
- );
+ PeiServices,
+ UsbIoPpi,
+ (UINT8)(Index + 1),
+ (UINT32 *)&PortStatus
+ );
if (EFI_ERROR (Status)) {
continue;
@@ -248,22 +248,22 @@ PeiHubEnumeration (
// Begin to deal with the new device
//
MemPages = sizeof (PEI_USB_DEVICE) / EFI_PAGE_SIZE + 1;
- Status = PeiServicesAllocatePages (
- EfiBootServicesCode,
- MemPages,
- &AllocateAddress
- );
+ Status = PeiServicesAllocatePages (
+ EfiBootServicesCode,
+ MemPages,
+ &AllocateAddress
+ );
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
- NewPeiUsbDevice = (PEI_USB_DEVICE *) ((UINTN) AllocateAddress);
+ NewPeiUsbDevice = (PEI_USB_DEVICE *)((UINTN)AllocateAddress);
ZeroMem (NewPeiUsbDevice, sizeof (PEI_USB_DEVICE));
- NewPeiUsbDevice->Signature = PEI_USB_DEVICE_SIGNATURE;
- NewPeiUsbDevice->DeviceAddress = 0;
- NewPeiUsbDevice->MaxPacketSize0 = 8;
- NewPeiUsbDevice->DataToggle = 0;
+ NewPeiUsbDevice->Signature = PEI_USB_DEVICE_SIGNATURE;
+ NewPeiUsbDevice->DeviceAddress = 0;
+ NewPeiUsbDevice->MaxPacketSize0 = 8;
+ NewPeiUsbDevice->DataToggle = 0;
CopyMem (
&(NewPeiUsbDevice->UsbIoPpi),
&mUsbIoPpi,
@@ -275,39 +275,40 @@ PeiHubEnumeration (
sizeof (EFI_PEI_PPI_DESCRIPTOR)
);
NewPeiUsbDevice->UsbIoPpiList.Ppi = &NewPeiUsbDevice->UsbIoPpi;
- NewPeiUsbDevice->AllocateAddress = (UINTN) AllocateAddress;
+ NewPeiUsbDevice->AllocateAddress = (UINTN)AllocateAddress;
NewPeiUsbDevice->UsbHcPpi = PeiUsbDevice->UsbHcPpi;
NewPeiUsbDevice->Usb2HcPpi = PeiUsbDevice->Usb2HcPpi;
- NewPeiUsbDevice->Tier = (UINT8) (PeiUsbDevice->Tier + 1);
+ NewPeiUsbDevice->Tier = (UINT8)(PeiUsbDevice->Tier + 1);
NewPeiUsbDevice->IsHub = 0x0;
NewPeiUsbDevice->DownStreamPortNo = 0x0;
if (((PortStatus.PortChangeStatus & USB_PORT_STAT_C_RESET) == 0) ||
- ((PortStatus.PortStatus & (USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE)) == 0)) {
+ ((PortStatus.PortStatus & (USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE)) == 0))
+ {
//
// If the port already has reset change flag and is connected and enabled, skip the port reset logic.
//
PeiResetHubPort (PeiServices, UsbIoPpi, (UINT8)(Index + 1));
PeiHubGetPortStatus (
- PeiServices,
- UsbIoPpi,
- (UINT8) (Index + 1),
- (UINT32 *) &PortStatus
- );
+ PeiServices,
+ UsbIoPpi,
+ (UINT8)(Index + 1),
+ (UINT32 *)&PortStatus
+ );
} else {
PeiHubClearPortFeature (
PeiServices,
UsbIoPpi,
- (UINT8) (Index + 1),
+ (UINT8)(Index + 1),
EfiUsbPortResetChange
);
}
- NewPeiUsbDevice->DeviceSpeed = (UINT8) PeiUsbGetDeviceSpeed (PortStatus.PortStatus);
+ NewPeiUsbDevice->DeviceSpeed = (UINT8)PeiUsbGetDeviceSpeed (PortStatus.PortStatus);
DEBUG ((DEBUG_INFO, "Device Speed =%d\n", PeiUsbDevice->DeviceSpeed));
- if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_SUPER_SPEED)){
+ if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_SUPER_SPEED)) {
NewPeiUsbDevice->MaxPacketSize0 = 512;
} else if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_HIGH_SPEED)) {
NewPeiUsbDevice->MaxPacketSize0 = 64;
@@ -317,12 +318,12 @@ PeiHubEnumeration (
NewPeiUsbDevice->MaxPacketSize0 = 8;
}
- if(NewPeiUsbDevice->DeviceSpeed != EFI_USB_SPEED_HIGH) {
+ if (NewPeiUsbDevice->DeviceSpeed != EFI_USB_SPEED_HIGH) {
if (PeiUsbDevice->DeviceSpeed == EFI_USB_SPEED_HIGH) {
NewPeiUsbDevice->Translator.TranslatorPortNumber = (UINT8)Index;
NewPeiUsbDevice->Translator.TranslatorHubAddress = *CurrentAddress;
} else {
- CopyMem(&(NewPeiUsbDevice->Translator), &(PeiUsbDevice->Translator), sizeof(EFI_USB2_HC_TRANSACTION_TRANSLATOR));
+ CopyMem (&(NewPeiUsbDevice->Translator), &(PeiUsbDevice->Translator), sizeof (EFI_USB2_HC_TRANSACTION_TRANSLATOR));
}
}
@@ -330,21 +331,22 @@ PeiHubEnumeration (
// Configure that Usb Device
//
Status = PeiConfigureUsbDevice (
- PeiServices,
- NewPeiUsbDevice,
- (UINT8) (Index + 1),
- CurrentAddress
- );
+ PeiServices,
+ NewPeiUsbDevice,
+ (UINT8)(Index + 1),
+ CurrentAddress
+ );
if (EFI_ERROR (Status)) {
continue;
}
+
DEBUG ((DEBUG_INFO, "PeiHubEnumeration: PeiConfigureUsbDevice Success\n"));
Status = PeiServicesInstallPpi (&NewPeiUsbDevice->UsbIoPpiList);
if (NewPeiUsbDevice->InterfaceDesc->InterfaceClass == 0x09) {
- NewPeiUsbDevice->IsHub = 0x1;
+ NewPeiUsbDevice->IsHub = 0x1;
Status = PeiDoHubConfig (PeiServices, NewPeiUsbDevice);
if (EFI_ERROR (Status)) {
@@ -359,19 +361,20 @@ PeiHubEnumeration (
// Begin to deal with the new device
//
MemPages = sizeof (PEI_USB_DEVICE) / EFI_PAGE_SIZE + 1;
- Status = PeiServicesAllocatePages (
- EfiBootServicesCode,
- MemPages,
- &AllocateAddress
- );
+ Status = PeiServicesAllocatePages (
+ EfiBootServicesCode,
+ MemPages,
+ &AllocateAddress
+ );
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem ((VOID *)(UINTN)AllocateAddress, NewPeiUsbDevice, sizeof (PEI_USB_DEVICE));
- NewPeiUsbDevice = (PEI_USB_DEVICE *) ((UINTN) AllocateAddress);
- NewPeiUsbDevice->AllocateAddress = (UINTN) AllocateAddress;
+ NewPeiUsbDevice = (PEI_USB_DEVICE *)((UINTN)AllocateAddress);
+ NewPeiUsbDevice->AllocateAddress = (UINTN)AllocateAddress;
NewPeiUsbDevice->UsbIoPpiList.Ppi = &NewPeiUsbDevice->UsbIoPpi;
- NewPeiUsbDevice->InterfaceDesc = NewPeiUsbDevice->InterfaceDescList[InterfaceIndex];
+ NewPeiUsbDevice->InterfaceDesc = NewPeiUsbDevice->InterfaceDescList[InterfaceIndex];
for (EndpointIndex = 0; EndpointIndex < NewPeiUsbDevice->InterfaceDesc->NumEndpoints; EndpointIndex++) {
NewPeiUsbDevice->EndpointDesc[EndpointIndex] = NewPeiUsbDevice->EndpointDescList[InterfaceIndex][EndpointIndex];
}
@@ -379,7 +382,7 @@ PeiHubEnumeration (
Status = PeiServicesInstallPpi (&NewPeiUsbDevice->UsbIoPpiList);
if (NewPeiUsbDevice->InterfaceDesc->InterfaceClass == 0x09) {
- NewPeiUsbDevice->IsHub = 0x1;
+ NewPeiUsbDevice->IsHub = 0x1;
Status = PeiDoHubConfig (PeiServices, NewPeiUsbDevice);
if (EFI_ERROR (Status)) {
@@ -393,7 +396,6 @@ PeiHubEnumeration (
}
}
-
return EFI_SUCCESS;
}
@@ -411,9 +413,9 @@ PeiHubEnumeration (
**/
EFI_STATUS
PeiUsbEnumeration (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
- IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
+ IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi
)
{
UINT8 NumOfRootPort;
@@ -430,15 +432,15 @@ PeiUsbEnumeration (
CurrentAddress = 0;
if (Usb2HcPpi != NULL) {
Usb2HcPpi->GetRootHubPortNumber (
- PeiServices,
- Usb2HcPpi,
- (UINT8 *) &NumOfRootPort
- );
+ PeiServices,
+ Usb2HcPpi,
+ (UINT8 *)&NumOfRootPort
+ );
} else if (UsbHcPpi != NULL) {
UsbHcPpi->GetRootHubPortNumber (
PeiServices,
UsbHcPpi,
- (UINT8 *) &NumOfRootPort
+ (UINT8 *)&NumOfRootPort
);
} else {
ASSERT (FALSE);
@@ -453,19 +455,20 @@ PeiUsbEnumeration (
//
if (Usb2HcPpi != NULL) {
Usb2HcPpi->GetRootHubPortStatus (
- PeiServices,
- Usb2HcPpi,
- (UINT8) Index,
- &PortStatus
- );
+ PeiServices,
+ Usb2HcPpi,
+ (UINT8)Index,
+ &PortStatus
+ );
} else {
UsbHcPpi->GetRootHubPortStatus (
PeiServices,
UsbHcPpi,
- (UINT8) Index,
+ (UINT8)Index,
&PortStatus
);
}
+
DEBUG ((DEBUG_INFO, "USB Status --- Port: %x ConnectChange[%04x] Status[%04x]\n", Index, PortStatus.PortChangeStatus, PortStatus.PortStatus));
//
// Only handle connection/enable/overcurrent/reset change.
@@ -475,22 +478,22 @@ PeiUsbEnumeration (
} else {
if (IsPortConnect (PortStatus.PortStatus)) {
MemPages = sizeof (PEI_USB_DEVICE) / EFI_PAGE_SIZE + 1;
- Status = PeiServicesAllocatePages (
- EfiBootServicesCode,
- MemPages,
- &AllocateAddress
- );
+ Status = PeiServicesAllocatePages (
+ EfiBootServicesCode,
+ MemPages,
+ &AllocateAddress
+ );
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
- PeiUsbDevice = (PEI_USB_DEVICE *) ((UINTN) AllocateAddress);
+ PeiUsbDevice = (PEI_USB_DEVICE *)((UINTN)AllocateAddress);
ZeroMem (PeiUsbDevice, sizeof (PEI_USB_DEVICE));
- PeiUsbDevice->Signature = PEI_USB_DEVICE_SIGNATURE;
- PeiUsbDevice->DeviceAddress = 0;
- PeiUsbDevice->MaxPacketSize0 = 8;
- PeiUsbDevice->DataToggle = 0;
+ PeiUsbDevice->Signature = PEI_USB_DEVICE_SIGNATURE;
+ PeiUsbDevice->DeviceAddress = 0;
+ PeiUsbDevice->MaxPacketSize0 = 8;
+ PeiUsbDevice->DataToggle = 0;
CopyMem (
&(PeiUsbDevice->UsbIoPpi),
&mUsbIoPpi,
@@ -501,15 +504,16 @@ PeiUsbEnumeration (
&mUsbIoPpiList,
sizeof (EFI_PEI_PPI_DESCRIPTOR)
);
- PeiUsbDevice->UsbIoPpiList.Ppi = &PeiUsbDevice->UsbIoPpi;
- PeiUsbDevice->AllocateAddress = (UINTN) AllocateAddress;
- PeiUsbDevice->UsbHcPpi = UsbHcPpi;
- PeiUsbDevice->Usb2HcPpi = Usb2HcPpi;
- PeiUsbDevice->IsHub = 0x0;
- PeiUsbDevice->DownStreamPortNo = 0x0;
+ PeiUsbDevice->UsbIoPpiList.Ppi = &PeiUsbDevice->UsbIoPpi;
+ PeiUsbDevice->AllocateAddress = (UINTN)AllocateAddress;
+ PeiUsbDevice->UsbHcPpi = UsbHcPpi;
+ PeiUsbDevice->Usb2HcPpi = Usb2HcPpi;
+ PeiUsbDevice->IsHub = 0x0;
+ PeiUsbDevice->DownStreamPortNo = 0x0;
if (((PortStatus.PortChangeStatus & USB_PORT_STAT_C_RESET) == 0) ||
- ((PortStatus.PortStatus & (USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE)) == 0)) {
+ ((PortStatus.PortStatus & (USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE)) == 0))
+ {
//
// If the port already has reset change flag and is connected and enabled, skip the port reset logic.
//
@@ -525,39 +529,39 @@ PeiUsbEnumeration (
Usb2HcPpi->GetRootHubPortStatus (
PeiServices,
Usb2HcPpi,
- (UINT8) Index,
+ (UINT8)Index,
&PortStatus
);
} else {
UsbHcPpi->GetRootHubPortStatus (
PeiServices,
UsbHcPpi,
- (UINT8) Index,
+ (UINT8)Index,
&PortStatus
);
}
} else {
if (Usb2HcPpi != NULL) {
Usb2HcPpi->ClearRootHubPortFeature (
- PeiServices,
- Usb2HcPpi,
- (UINT8) Index,
- EfiUsbPortResetChange
- );
+ PeiServices,
+ Usb2HcPpi,
+ (UINT8)Index,
+ EfiUsbPortResetChange
+ );
} else {
UsbHcPpi->ClearRootHubPortFeature (
PeiServices,
UsbHcPpi,
- (UINT8) Index,
+ (UINT8)Index,
EfiUsbPortResetChange
);
}
}
- PeiUsbDevice->DeviceSpeed = (UINT8) PeiUsbGetDeviceSpeed (PortStatus.PortStatus);
+ PeiUsbDevice->DeviceSpeed = (UINT8)PeiUsbGetDeviceSpeed (PortStatus.PortStatus);
DEBUG ((DEBUG_INFO, "Device Speed =%d\n", PeiUsbDevice->DeviceSpeed));
- if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_SUPER_SPEED)){
+ if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_SUPER_SPEED)) {
PeiUsbDevice->MaxPacketSize0 = 512;
} else if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_HIGH_SPEED)) {
PeiUsbDevice->MaxPacketSize0 = 64;
@@ -571,15 +575,16 @@ PeiUsbEnumeration (
// Configure that Usb Device
//
Status = PeiConfigureUsbDevice (
- PeiServices,
- PeiUsbDevice,
- Index,
- &CurrentAddress
- );
+ PeiServices,
+ PeiUsbDevice,
+ Index,
+ &CurrentAddress
+ );
if (EFI_ERROR (Status)) {
continue;
}
+
DEBUG ((DEBUG_INFO, "PeiUsbEnumeration: PeiConfigureUsbDevice Success\n"));
Status = PeiServicesInstallPpi (&PeiUsbDevice->UsbIoPpiList);
@@ -600,19 +605,20 @@ PeiUsbEnumeration (
// Begin to deal with the new device
//
MemPages = sizeof (PEI_USB_DEVICE) / EFI_PAGE_SIZE + 1;
- Status = PeiServicesAllocatePages (
- EfiBootServicesCode,
- MemPages,
- &AllocateAddress
- );
+ Status = PeiServicesAllocatePages (
+ EfiBootServicesCode,
+ MemPages,
+ &AllocateAddress
+ );
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
+
CopyMem ((VOID *)(UINTN)AllocateAddress, PeiUsbDevice, sizeof (PEI_USB_DEVICE));
- PeiUsbDevice = (PEI_USB_DEVICE *) ((UINTN) AllocateAddress);
- PeiUsbDevice->AllocateAddress = (UINTN) AllocateAddress;
+ PeiUsbDevice = (PEI_USB_DEVICE *)((UINTN)AllocateAddress);
+ PeiUsbDevice->AllocateAddress = (UINTN)AllocateAddress;
PeiUsbDevice->UsbIoPpiList.Ppi = &PeiUsbDevice->UsbIoPpi;
- PeiUsbDevice->InterfaceDesc = PeiUsbDevice->InterfaceDescList[InterfaceIndex];
+ PeiUsbDevice->InterfaceDesc = PeiUsbDevice->InterfaceDescList[InterfaceIndex];
for (EndpointIndex = 0; EndpointIndex < PeiUsbDevice->InterfaceDesc->NumEndpoints; EndpointIndex++) {
PeiUsbDevice->EndpointDesc[EndpointIndex] = PeiUsbDevice->EndpointDescList[InterfaceIndex][EndpointIndex];
}
@@ -656,16 +662,16 @@ PeiUsbEnumeration (
**/
EFI_STATUS
PeiConfigureUsbDevice (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_DEVICE *PeiUsbDevice,
- IN UINT8 Port,
- IN OUT UINT8 *DeviceAddress
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_DEVICE *PeiUsbDevice,
+ IN UINT8 Port,
+ IN OUT UINT8 *DeviceAddress
)
{
- EFI_USB_DEVICE_DESCRIPTOR DeviceDescriptor;
- EFI_STATUS Status;
- PEI_USB_IO_PPI *UsbIoPpi;
- UINT8 Retry;
+ EFI_USB_DEVICE_DESCRIPTOR DeviceDescriptor;
+ EFI_STATUS Status;
+ PEI_USB_IO_PPI *UsbIoPpi;
+ UINT8 Retry;
UsbIoPpi = &PeiUsbDevice->UsbIoPpi;
Status = EFI_SUCCESS;
@@ -674,7 +680,7 @@ PeiConfigureUsbDevice (
// Get USB device descriptor
//
- for (Retry = 0; Retry < 3; Retry ++) {
+ for (Retry = 0; Retry < 3; Retry++) {
Status = PeiUsbGetDescriptor (
PeiServices,
UsbIoPpi,
@@ -701,18 +707,19 @@ PeiConfigureUsbDevice (
PeiUsbDevice->MaxPacketSize0 = DeviceDescriptor.MaxPacketSize0;
}
- (*DeviceAddress) ++;
+ (*DeviceAddress)++;
Status = PeiUsbSetDeviceAddress (
- PeiServices,
- UsbIoPpi,
- *DeviceAddress
- );
+ PeiServices,
+ UsbIoPpi,
+ *DeviceAddress
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "PeiUsbSetDeviceAddress Failed: %r\n", Status));
return Status;
}
+
MicroSecondDelay (USB_SET_DEVICE_ADDRESS_STALL);
PeiUsbDevice->DeviceAddress = *DeviceAddress;
@@ -721,13 +728,13 @@ PeiConfigureUsbDevice (
// Get whole USB device descriptor
//
Status = PeiUsbGetDescriptor (
- PeiServices,
- UsbIoPpi,
- (USB_DT_DEVICE << 8),
- 0,
- (UINT16) sizeof (EFI_USB_DEVICE_DESCRIPTOR),
- &DeviceDescriptor
- );
+ PeiServices,
+ UsbIoPpi,
+ (USB_DT_DEVICE << 8),
+ 0,
+ (UINT16)sizeof (EFI_USB_DEVICE_DESCRIPTOR),
+ &DeviceDescriptor
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "PeiUsbGetDescriptor First Failed\n"));
@@ -738,18 +745,19 @@ PeiConfigureUsbDevice (
// Get its default configuration and its first interface
//
Status = PeiUsbGetAllConfiguration (
- PeiServices,
- PeiUsbDevice
- );
+ PeiServices,
+ PeiUsbDevice
+ );
if (EFI_ERROR (Status)) {
return Status;
}
+
MicroSecondDelay (USB_GET_CONFIG_DESCRIPTOR_STALL);
Status = PeiUsbSetConfiguration (
- PeiServices,
- UsbIoPpi
- );
+ PeiServices,
+ UsbIoPpi
+ );
if (EFI_ERROR (Status)) {
return Status;
@@ -771,20 +779,20 @@ PeiConfigureUsbDevice (
**/
EFI_STATUS
PeiUsbGetAllConfiguration (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_DEVICE *PeiUsbDevice
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_DEVICE *PeiUsbDevice
)
{
- EFI_STATUS Status;
- EFI_USB_CONFIG_DESCRIPTOR *ConfigDesc;
- PEI_USB_IO_PPI *UsbIoPpi;
- UINT16 ConfigDescLength;
- UINT8 *Ptr;
- UINTN SkipBytes;
- UINTN LengthLeft;
- UINTN InterfaceIndex;
- UINTN Index;
- UINTN NumOfEndpoint;
+ EFI_STATUS Status;
+ EFI_USB_CONFIG_DESCRIPTOR *ConfigDesc;
+ PEI_USB_IO_PPI *UsbIoPpi;
+ UINT16 ConfigDescLength;
+ UINT8 *Ptr;
+ UINTN SkipBytes;
+ UINTN LengthLeft;
+ UINTN InterfaceIndex;
+ UINTN Index;
+ UINTN NumOfEndpoint;
UsbIoPpi = &PeiUsbDevice->UsbIoPpi;
@@ -792,22 +800,23 @@ PeiUsbGetAllConfiguration (
// First get its 4-byte configuration descriptor
//
Status = PeiUsbGetDescriptor (
- PeiServices,
- UsbIoPpi,
- (USB_DT_CONFIG << 8), // Value
- 0, // Index
- 4, // Length
- PeiUsbDevice->ConfigurationData
- );
+ PeiServices,
+ UsbIoPpi,
+ (USB_DT_CONFIG << 8), // Value
+ 0, // Index
+ 4, // Length
+ PeiUsbDevice->ConfigurationData
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "PeiUsbGet Config Descriptor First Failed\n"));
return Status;
}
+
MicroSecondDelay (USB_GET_CONFIG_DESCRIPTOR_STALL);
- ConfigDesc = (EFI_USB_CONFIG_DESCRIPTOR *) PeiUsbDevice->ConfigurationData;
- ConfigDescLength = ConfigDesc->TotalLength;
+ ConfigDesc = (EFI_USB_CONFIG_DESCRIPTOR *)PeiUsbDevice->ConfigurationData;
+ ConfigDescLength = ConfigDesc->TotalLength;
//
// Reject if TotalLength even cannot cover itself.
@@ -827,52 +836,52 @@ PeiUsbGetAllConfiguration (
// Then we get the total descriptors for this configuration
//
Status = PeiUsbGetDescriptor (
- PeiServices,
- UsbIoPpi,
- (USB_DT_CONFIG << 8),
- 0,
- ConfigDescLength,
- PeiUsbDevice->ConfigurationData
- );
+ PeiServices,
+ UsbIoPpi,
+ (USB_DT_CONFIG << 8),
+ 0,
+ ConfigDescLength,
+ PeiUsbDevice->ConfigurationData
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "PeiUsbGet Config Descriptor all Failed\n"));
return Status;
}
+
//
// Parse this configuration descriptor
// First get the current config descriptor;
//
Status = GetExpectedDescriptor (
- PeiUsbDevice->ConfigurationData,
- ConfigDescLength,
- USB_DT_CONFIG,
- (UINT8) sizeof (EFI_USB_CONFIG_DESCRIPTOR),
- &SkipBytes
- );
+ PeiUsbDevice->ConfigurationData,
+ ConfigDescLength,
+ USB_DT_CONFIG,
+ (UINT8)sizeof (EFI_USB_CONFIG_DESCRIPTOR),
+ &SkipBytes
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- Ptr = PeiUsbDevice->ConfigurationData + SkipBytes;
- PeiUsbDevice->ConfigDesc = (EFI_USB_CONFIG_DESCRIPTOR *) Ptr;
+ Ptr = PeiUsbDevice->ConfigurationData + SkipBytes;
+ PeiUsbDevice->ConfigDesc = (EFI_USB_CONFIG_DESCRIPTOR *)Ptr;
- Ptr += sizeof (EFI_USB_CONFIG_DESCRIPTOR);
+ Ptr += sizeof (EFI_USB_CONFIG_DESCRIPTOR);
LengthLeft = ConfigDescLength - SkipBytes - sizeof (EFI_USB_CONFIG_DESCRIPTOR);
for (InterfaceIndex = 0; InterfaceIndex < PeiUsbDevice->ConfigDesc->NumInterfaces; InterfaceIndex++) {
-
//
// Get the interface descriptor
//
Status = GetExpectedDescriptor (
- Ptr,
- LengthLeft,
- USB_DT_INTERFACE,
- (UINT8) sizeof (EFI_USB_INTERFACE_DESCRIPTOR),
- &SkipBytes
- );
+ Ptr,
+ LengthLeft,
+ USB_DT_INTERFACE,
+ (UINT8)sizeof (EFI_USB_INTERFACE_DESCRIPTOR),
+ &SkipBytes
+ );
if (EFI_ERROR (Status)) {
return Status;
@@ -880,11 +889,12 @@ PeiUsbGetAllConfiguration (
Ptr += SkipBytes;
if (InterfaceIndex == 0) {
- PeiUsbDevice->InterfaceDesc = (EFI_USB_INTERFACE_DESCRIPTOR *) Ptr;
+ PeiUsbDevice->InterfaceDesc = (EFI_USB_INTERFACE_DESCRIPTOR *)Ptr;
}
- PeiUsbDevice->InterfaceDescList[InterfaceIndex] = (EFI_USB_INTERFACE_DESCRIPTOR *) Ptr;
- Ptr += sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
+ PeiUsbDevice->InterfaceDescList[InterfaceIndex] = (EFI_USB_INTERFACE_DESCRIPTOR *)Ptr;
+
+ Ptr += sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
LengthLeft -= SkipBytes;
LengthLeft -= sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
@@ -899,12 +909,12 @@ PeiUsbGetAllConfiguration (
// Get the endpoint descriptor
//
Status = GetExpectedDescriptor (
- Ptr,
- LengthLeft,
- USB_DT_ENDPOINT,
- (UINT8) sizeof (EFI_USB_ENDPOINT_DESCRIPTOR),
- &SkipBytes
- );
+ Ptr,
+ LengthLeft,
+ USB_DT_ENDPOINT,
+ (UINT8)sizeof (EFI_USB_ENDPOINT_DESCRIPTOR),
+ &SkipBytes
+ );
if (EFI_ERROR (Status)) {
return Status;
@@ -912,11 +922,12 @@ PeiUsbGetAllConfiguration (
Ptr += SkipBytes;
if (InterfaceIndex == 0) {
- PeiUsbDevice->EndpointDesc[Index] = (EFI_USB_ENDPOINT_DESCRIPTOR *) Ptr;
+ PeiUsbDevice->EndpointDesc[Index] = (EFI_USB_ENDPOINT_DESCRIPTOR *)Ptr;
}
- PeiUsbDevice->EndpointDescList[InterfaceIndex][Index] = (EFI_USB_ENDPOINT_DESCRIPTOR *) Ptr;
- Ptr += sizeof (EFI_USB_ENDPOINT_DESCRIPTOR);
+ PeiUsbDevice->EndpointDescList[InterfaceIndex][Index] = (EFI_USB_ENDPOINT_DESCRIPTOR *)Ptr;
+
+ Ptr += sizeof (EFI_USB_ENDPOINT_DESCRIPTOR);
LengthLeft -= SkipBytes;
LengthLeft -= sizeof (EFI_USB_ENDPOINT_DESCRIPTOR);
}
@@ -940,15 +951,15 @@ PeiUsbGetAllConfiguration (
**/
EFI_STATUS
GetExpectedDescriptor (
- IN UINT8 *Buffer,
- IN UINTN Length,
- IN UINT8 DescType,
- IN UINT8 DescLength,
- OUT UINTN *ParsedBytes
+ IN UINT8 *Buffer,
+ IN UINTN Length,
+ IN UINT8 DescType,
+ IN UINT8 DescLength,
+ OUT UINTN *ParsedBytes
)
{
- USB_DESC_HEAD *Head;
- UINTN Offset;
+ USB_DESC_HEAD *Head;
+ UINTN Offset;
//
// Total length is too small that cannot hold the single descriptor header plus data.
@@ -1020,17 +1031,16 @@ GetExpectedDescriptor (
**/
VOID
ResetRootPort (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
- IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi,
- IN UINT8 PortNum,
- IN UINT8 RetryIndex
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
+ IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi,
+ IN UINT8 PortNum,
+ IN UINT8 RetryIndex
)
{
- EFI_STATUS Status;
- UINTN Index;
- EFI_USB_PORT_STATUS PortStatus;
-
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_USB_PORT_STATUS PortStatus;
if (Usb2HcPpi != NULL) {
MicroSecondDelay (200 * 1000);
@@ -1039,11 +1049,11 @@ ResetRootPort (
// reset root port
//
Status = Usb2HcPpi->SetRootHubPortFeature (
- PeiServices,
- Usb2HcPpi,
- PortNum,
- EfiUsbPortReset
- );
+ PeiServices,
+ Usb2HcPpi,
+ PortNum,
+ EfiUsbPortReset
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "SetRootHubPortFeature EfiUsbPortReset Failed\n"));
@@ -1060,11 +1070,11 @@ ResetRootPort (
// clear reset root port
//
Status = Usb2HcPpi->ClearRootHubPortFeature (
- PeiServices,
- Usb2HcPpi,
- PortNum,
- EfiUsbPortReset
- );
+ PeiServices,
+ Usb2HcPpi,
+ PortNum,
+ EfiUsbPortReset
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "ClearRootHubPortFeature EfiUsbPortReset Failed\n"));
@@ -1103,35 +1113,35 @@ ResetRootPort (
}
Usb2HcPpi->ClearRootHubPortFeature (
- PeiServices,
- Usb2HcPpi,
- PortNum,
- EfiUsbPortResetChange
- );
+ PeiServices,
+ Usb2HcPpi,
+ PortNum,
+ EfiUsbPortResetChange
+ );
Usb2HcPpi->ClearRootHubPortFeature (
- PeiServices,
- Usb2HcPpi,
- PortNum,
- EfiUsbPortConnectChange
- );
+ PeiServices,
+ Usb2HcPpi,
+ PortNum,
+ EfiUsbPortConnectChange
+ );
//
// Set port enable
//
- Usb2HcPpi->SetRootHubPortFeature(
- PeiServices,
- Usb2HcPpi,
- PortNum,
- EfiUsbPortEnable
- );
+ Usb2HcPpi->SetRootHubPortFeature (
+ PeiServices,
+ Usb2HcPpi,
+ PortNum,
+ EfiUsbPortEnable
+ );
Usb2HcPpi->ClearRootHubPortFeature (
- PeiServices,
- Usb2HcPpi,
- PortNum,
- EfiUsbPortEnableChange
- );
+ PeiServices,
+ Usb2HcPpi,
+ PortNum,
+ EfiUsbPortEnableChange
+ );
MicroSecondDelay ((RetryIndex + 1) * 50 * 1000);
} else {
@@ -1221,7 +1231,7 @@ ResetRootPort (
//
// Set port enable
//
- UsbHcPpi->SetRootHubPortFeature(
+ UsbHcPpi->SetRootHubPortFeature (
PeiServices,
UsbHcPpi,
PortNum,
@@ -1237,5 +1247,6 @@ ResetRootPort (
MicroSecondDelay ((RetryIndex + 1) * 50 * 1000);
}
+
return;
}
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.h b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.h
index 776edba..69d1126 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.h
+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.h
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _PEI_USB_PEIM_H_
#define _PEI_USB_PEIM_H_
-
#include <PiPei.h>
#include <Ppi/UsbHostController.h>
@@ -32,43 +31,43 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
#pragma pack(1)
typedef struct {
- UINT8 Len;
- UINT8 Type;
+ UINT8 Len;
+ UINT8 Type;
} USB_DESC_HEAD;
#pragma pack()
-#define MAX_INTERFACE 8
-#define MAX_ENDPOINT 16
+#define MAX_INTERFACE 8
+#define MAX_ENDPOINT 16
#define PEI_USB_DEVICE_SIGNATURE SIGNATURE_32 ('U', 's', 'b', 'D')
typedef struct {
- UINTN Signature;
- PEI_USB_IO_PPI UsbIoPpi;
- EFI_PEI_PPI_DESCRIPTOR UsbIoPpiList;
- UINT16 MaxPacketSize0;
- UINT16 DataToggle;
- UINT8 DeviceAddress;
- UINT8 DeviceSpeed;
- UINT8 IsHub;
- UINT8 DownStreamPortNo;
- UINTN AllocateAddress;
- PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi;
- PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi;
- UINT8 ConfigurationData[1024];
- EFI_USB_CONFIG_DESCRIPTOR *ConfigDesc;
- EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDesc;
- EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDescList[MAX_INTERFACE];
- EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDesc[MAX_ENDPOINT];
- EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescList[MAX_INTERFACE][MAX_ENDPOINT];
- EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator;
- UINT8 Tier;
+ UINTN Signature;
+ PEI_USB_IO_PPI UsbIoPpi;
+ EFI_PEI_PPI_DESCRIPTOR UsbIoPpiList;
+ UINT16 MaxPacketSize0;
+ UINT16 DataToggle;
+ UINT8 DeviceAddress;
+ UINT8 DeviceSpeed;
+ UINT8 IsHub;
+ UINT8 DownStreamPortNo;
+ UINTN AllocateAddress;
+ PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi;
+ PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi;
+ UINT8 ConfigurationData[1024];
+ EFI_USB_CONFIG_DESCRIPTOR *ConfigDesc;
+ EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDesc;
+ EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDescList[MAX_INTERFACE];
+ EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDesc[MAX_ENDPOINT];
+ EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescList[MAX_INTERFACE][MAX_ENDPOINT];
+ EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator;
+ UINT8 Tier;
} PEI_USB_DEVICE;
-#define PEI_USB_DEVICE_FROM_THIS(a) CR (a, PEI_USB_DEVICE, UsbIoPpi, PEI_USB_DEVICE_SIGNATURE)
+#define PEI_USB_DEVICE_FROM_THIS(a) CR (a, PEI_USB_DEVICE, UsbIoPpi, PEI_USB_DEVICE_SIGNATURE)
-#define USB_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
+#define USB_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
-#define USB_BUS_1_MILLISECOND 1000
+#define USB_BUS_1_MILLISECOND 1000
//
// Wait for port reset, refers to specification
@@ -78,13 +77,13 @@ typedef struct {
// According to USB2.0, Chapter 11.5.1.5 Resetting,
// the worst case for TDRST is 20ms
//
-#define USB_SET_PORT_RESET_STALL (20 * USB_BUS_1_MILLISECOND)
-#define USB_SET_ROOT_PORT_RESET_STALL (50 * USB_BUS_1_MILLISECOND)
+#define USB_SET_PORT_RESET_STALL (20 * USB_BUS_1_MILLISECOND)
+#define USB_SET_ROOT_PORT_RESET_STALL (50 * USB_BUS_1_MILLISECOND)
//
// Wait for clear roothub port reset, set by experience
//
-#define USB_CLR_ROOT_PORT_RESET_STALL (20 * USB_BUS_1_MILLISECOND)
+#define USB_CLR_ROOT_PORT_RESET_STALL (20 * USB_BUS_1_MILLISECOND)
//
// Wait for port statue reg change, set by experience
@@ -95,24 +94,24 @@ typedef struct {
// Host software return timeout if port status doesn't change
// after 500ms(LOOP * STALL = 5000 * 0.1ms), set by experience
//
-#define USB_WAIT_PORT_STS_CHANGE_LOOP 5000
+#define USB_WAIT_PORT_STS_CHANGE_LOOP 5000
//
// Wait for hub port power-on, refers to specification
// [USB20-11.23.2]
//
-#define USB_SET_PORT_POWER_STALL (2 * USB_BUS_1_MILLISECOND)
+#define USB_SET_PORT_POWER_STALL (2 * USB_BUS_1_MILLISECOND)
//
// Wait for set device address, refers to specification
// [USB20-9.2.6.3, it says 2ms]
//
-#define USB_SET_DEVICE_ADDRESS_STALL (2 * USB_BUS_1_MILLISECOND)
+#define USB_SET_DEVICE_ADDRESS_STALL (2 * USB_BUS_1_MILLISECOND)
//
// Wait for get configuration descriptor, set by experience
//
-#define USB_GET_CONFIG_DESCRIPTOR_STALL (1 * USB_BUS_1_MILLISECOND)
+#define USB_GET_CONFIG_DESCRIPTOR_STALL (1 * USB_BUS_1_MILLISECOND)
/**
Submits control transfer to a target USB device.
@@ -137,13 +136,13 @@ typedef struct {
EFI_STATUS
EFIAPI
PeiUsbControlTransfer (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *This,
- IN EFI_USB_DEVICE_REQUEST *Request,
- IN EFI_USB_DATA_DIRECTION Direction,
- IN UINT32 Timeout,
- IN OUT VOID *Data OPTIONAL,
- IN UINTN DataLength OPTIONAL
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *This,
+ IN EFI_USB_DEVICE_REQUEST *Request,
+ IN EFI_USB_DATA_DIRECTION Direction,
+ IN UINT32 Timeout,
+ IN OUT VOID *Data OPTIONAL,
+ IN UINTN DataLength OPTIONAL
);
/**
@@ -170,12 +169,12 @@ PeiUsbControlTransfer (
EFI_STATUS
EFIAPI
PeiUsbBulkTransfer (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *This,
- IN UINT8 DeviceEndpoint,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINTN Timeout
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *This,
+ IN UINT8 DeviceEndpoint,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN UINTN Timeout
);
/**
@@ -192,9 +191,9 @@ PeiUsbBulkTransfer (
EFI_STATUS
EFIAPI
PeiUsbGetInterfaceDescriptor (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *This,
- OUT EFI_USB_INTERFACE_DESCRIPTOR **InterfaceDescriptor
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *This,
+ OUT EFI_USB_INTERFACE_DESCRIPTOR **InterfaceDescriptor
);
/**
@@ -212,10 +211,10 @@ PeiUsbGetInterfaceDescriptor (
EFI_STATUS
EFIAPI
PeiUsbGetEndpointDescriptor (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *This,
- IN UINT8 EndpointIndex,
- OUT EFI_USB_ENDPOINT_DESCRIPTOR **EndpointDescriptor
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *This,
+ IN UINT8 EndpointIndex,
+ OUT EFI_USB_ENDPOINT_DESCRIPTOR **EndpointDescriptor
);
/**
@@ -231,8 +230,8 @@ PeiUsbGetEndpointDescriptor (
EFI_STATUS
EFIAPI
PeiUsbPortReset (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *This
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_IO_PPI *This
);
/**
@@ -247,11 +246,11 @@ PeiUsbPortReset (
**/
VOID
ResetRootPort (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
- IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi,
- IN UINT8 PortNum,
- IN UINT8 RetryIndex
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
+ IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi,
+ IN UINT8 PortNum,
+ IN UINT8 RetryIndex
);
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/ComponentName.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/ComponentName.c
index 6af1d78..536a11b 100644
--- a/MdeModulePkg/Bus/Usb/UsbKbDxe/ComponentName.c
+++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/ComponentName.c
@@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "KeyBoard.h"
//
@@ -21,16 +20,15 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbKeyboardComponent
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UsbKeyboardComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UsbKeyboardComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)UsbKeyboardComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)UsbKeyboardComponentNameGetControllerName,
"en"
};
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbKeyboardDriverNameTable[] = {
{ "eng;en", L"Usb Keyboard Driver" },
- { NULL , NULL }
+ { NULL, NULL }
};
/**
@@ -145,17 +143,18 @@ UsbKeyboardComponentNameGetDriverName (
EFI_STATUS
EFIAPI
UsbKeyboardComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
- EFI_STATUS Status;
- USB_KB_DEV *UsbKbDev;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTxtIn;
- EFI_USB_IO_PROTOCOL *UsbIoProtocol;
+ EFI_STATUS Status;
+ USB_KB_DEV *UsbKbDev;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTxtIn;
+ EFI_USB_IO_PROTOCOL *UsbIoProtocol;
+
//
// This is a device driver, so ChildHandle must be NULL.
//
@@ -169,7 +168,7 @@ UsbKeyboardComponentNameGetControllerName (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIoProtocol,
+ (VOID **)&UsbIoProtocol,
gUsbKeyboardDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -188,13 +187,14 @@ UsbKeyboardComponentNameGetControllerName (
if (Status != EFI_ALREADY_STARTED) {
return EFI_UNSUPPORTED;
}
+
//
// Get the device context
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiSimpleTextInProtocolGuid,
- (VOID **) &SimpleTxtIn,
+ (VOID **)&SimpleTxtIn,
gUsbKeyboardDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -213,5 +213,4 @@ UsbKeyboardComponentNameGetControllerName (
ControllerName,
(BOOLEAN)(This == &gUsbKeyboardComponentName)
);
-
}
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c
index 9d17982..e889f42 100644
--- a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c
+++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c
@@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// USB Keyboard Driver Global Variables
//
-EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding = {
USBKeyboardDriverBindingSupported,
USBKeyboardDriverBindingStart,
USBKeyboardDriverBindingStop,
@@ -37,11 +37,11 @@ EFI_DRIVER_BINDING_PROTOCOL gUsbKeyboardDriverBinding = {
EFI_STATUS
EFIAPI
USBKeyboardDriverBindingEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
@@ -70,13 +70,13 @@ USBKeyboardDriverBindingEntryPoint (
EFI_STATUS
EFIAPI
USBKeyboardDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_STATUS Status;
+ EFI_USB_IO_PROTOCOL *UsbIo;
//
// Check if USB I/O Protocol is attached on the controller handle.
@@ -84,7 +84,7 @@ USBKeyboardDriverBindingSupported (
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
+ (VOID **)&UsbIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -133,22 +133,22 @@ USBKeyboardDriverBindingSupported (
EFI_STATUS
EFIAPI
USBKeyboardDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_USB_IO_PROTOCOL *UsbIo;
- USB_KB_DEV *UsbKeyboardDevice;
- UINT8 EndpointNumber;
- EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
- UINT8 Index;
- UINT8 EndpointAddr;
- UINT8 PollingInterval;
- UINT8 PacketSize;
- BOOLEAN Found;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ USB_KB_DEV *UsbKeyboardDevice;
+ UINT8 EndpointNumber;
+ EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
+ UINT8 Index;
+ UINT8 EndpointAddr;
+ UINT8 PollingInterval;
+ UINT8 PacketSize;
+ BOOLEAN Found;
+ EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
@@ -157,7 +157,7 @@ USBKeyboardDriverBindingStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
+ (VOID **)&UsbIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -175,7 +175,7 @@ USBKeyboardDriverBindingStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &UsbKeyboardDevice->DevicePath,
+ (VOID **)&UsbKeyboardDevice->DevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -184,6 +184,7 @@ USBKeyboardDriverBindingStart (
if (EFI_ERROR (Status)) {
goto ErrorExit;
}
+
//
// Report that the USB keyboard is being enabled
//
@@ -219,7 +220,6 @@ USBKeyboardDriverBindingStart (
//
Found = FALSE;
for (Index = 0; Index < EndpointNumber; Index++) {
-
UsbIo->UsbGetEndpointDescriptor (
UsbIo,
Index,
@@ -227,11 +227,12 @@ USBKeyboardDriverBindingStart (
);
if (((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) &&
- ((EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) != 0)) {
+ ((EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) != 0))
+ {
//
// We only care interrupt endpoint here
//
- CopyMem(&UsbKeyboardDevice->IntEndpointDescriptor, &EndpointDescriptor, sizeof(EndpointDescriptor));
+ CopyMem (&UsbKeyboardDevice->IntEndpointDescriptor, &EndpointDescriptor, sizeof (EndpointDescriptor));
Found = TRUE;
break;
}
@@ -258,9 +259,9 @@ USBKeyboardDriverBindingStart (
UsbKeyboardDevice->DevicePath
);
- UsbKeyboardDevice->Signature = USB_KB_DEV_SIGNATURE;
- UsbKeyboardDevice->SimpleInput.Reset = USBKeyboardReset;
- UsbKeyboardDevice->SimpleInput.ReadKeyStroke = USBKeyboardReadKeyStroke;
+ UsbKeyboardDevice->Signature = USB_KB_DEV_SIGNATURE;
+ UsbKeyboardDevice->SimpleInput.Reset = USBKeyboardReset;
+ UsbKeyboardDevice->SimpleInput.ReadKeyStroke = USBKeyboardReadKeyStroke;
UsbKeyboardDevice->SimpleInputEx.Reset = USBKeyboardResetEx;
UsbKeyboardDevice->SimpleInputEx.ReadKeyStrokeEx = USBKeyboardReadKeyStrokeEx;
@@ -280,6 +281,7 @@ USBKeyboardDriverBindingStart (
if (!EFI_ERROR (Status)) {
Status = gBS->SetTimer (UsbKeyboardDevice->TimerEvent, TimerPeriodic, KEYBOARD_TIMER_INTERVAL);
}
+
if (EFI_ERROR (Status)) {
goto ErrorExit;
}
@@ -338,27 +340,26 @@ USBKeyboardDriverBindingStart (
}
UsbKeyboardDevice->ControllerHandle = Controller;
- Status = InitKeyboardLayout (UsbKeyboardDevice);
+ Status = InitKeyboardLayout (UsbKeyboardDevice);
if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- &gEfiSimpleTextInProtocolGuid,
- &UsbKeyboardDevice->SimpleInput,
- &gEfiSimpleTextInputExProtocolGuid,
- &UsbKeyboardDevice->SimpleInputEx,
- NULL
- );
+ Controller,
+ &gEfiSimpleTextInProtocolGuid,
+ &UsbKeyboardDevice->SimpleInput,
+ &gEfiSimpleTextInputExProtocolGuid,
+ &UsbKeyboardDevice->SimpleInputEx,
+ NULL
+ );
goto ErrorExit;
}
-
//
// Reset USB Keyboard Device exhaustively.
//
Status = UsbKeyboardDevice->SimpleInputEx.Reset (
- &UsbKeyboardDevice->SimpleInputEx,
- TRUE
- );
+ &UsbKeyboardDevice->SimpleInputEx,
+ TRUE
+ );
if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces (
Controller,
@@ -376,7 +377,7 @@ USBKeyboardDriverBindingStart (
//
EndpointAddr = UsbKeyboardDevice->IntEndpointDescriptor.EndpointAddress;
PollingInterval = UsbKeyboardDevice->IntEndpointDescriptor.Interval;
- PacketSize = (UINT8) (UsbKeyboardDevice->IntEndpointDescriptor.MaxPacketSize);
+ PacketSize = (UINT8)(UsbKeyboardDevice->IntEndpointDescriptor.MaxPacketSize);
Status = UsbIo->UsbAsyncInterruptTransfer (
UsbIo,
@@ -419,30 +420,36 @@ USBKeyboardDriverBindingStart (
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
-//
-// Error handler
-//
+ //
+ // Error handler
+ //
ErrorExit:
if (UsbKeyboardDevice != NULL) {
if (UsbKeyboardDevice->TimerEvent != NULL) {
gBS->CloseEvent (UsbKeyboardDevice->TimerEvent);
}
+
if (UsbKeyboardDevice->SimpleInput.WaitForKey != NULL) {
gBS->CloseEvent (UsbKeyboardDevice->SimpleInput.WaitForKey);
}
+
if (UsbKeyboardDevice->SimpleInputEx.WaitForKeyEx != NULL) {
gBS->CloseEvent (UsbKeyboardDevice->SimpleInputEx.WaitForKeyEx);
}
+
if (UsbKeyboardDevice->KeyNotifyProcessEvent != NULL) {
gBS->CloseEvent (UsbKeyboardDevice->KeyNotifyProcessEvent);
}
+
if (UsbKeyboardDevice->KeyboardLayoutEvent != NULL) {
ReleaseKeyboardLayoutResources (UsbKeyboardDevice);
gBS->CloseEvent (UsbKeyboardDevice->KeyboardLayoutEvent);
}
+
FreePool (UsbKeyboardDevice);
UsbKeyboardDevice = NULL;
}
+
gBS->CloseProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
@@ -454,10 +461,8 @@ ErrorExit1:
gBS->RestoreTPL (OldTpl);
return Status;
-
}
-
/**
Stop the USB keyboard device handled by this driver.
@@ -476,20 +481,20 @@ ErrorExit1:
EFI_STATUS
EFIAPI
USBKeyboardDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_STATUS Status;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleInput;
- USB_KB_DEV *UsbKeyboardDevice;
+ EFI_STATUS Status;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleInput;
+ USB_KB_DEV *UsbKeyboardDevice;
Status = gBS->OpenProtocol (
Controller,
&gEfiSimpleTextInProtocolGuid,
- (VOID **) &SimpleInput,
+ (VOID **)&SimpleInput,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -593,8 +598,8 @@ USBKeyboardDriverBindingStop (
**/
EFI_STATUS
USBKeyboardReadKeyStrokeWorker (
- IN OUT USB_KB_DEV *UsbKeyboardDevice,
- OUT EFI_KEY_DATA *KeyData
+ IN OUT USB_KB_DEV *UsbKeyboardDevice,
+ OUT EFI_KEY_DATA *KeyData
)
{
if (KeyData == NULL) {
@@ -630,12 +635,12 @@ USBKeyboardReadKeyStrokeWorker (
EFI_STATUS
EFIAPI
USBKeyboardReset (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- EFI_STATUS Status;
- USB_KB_DEV *UsbKeyboardDevice;
+ EFI_STATUS Status;
+ USB_KB_DEV *UsbKeyboardDevice;
UsbKeyboardDevice = USB_KB_DEV_FROM_THIS (This);
@@ -676,7 +681,6 @@ USBKeyboardReset (
return EFI_SUCCESS;
}
-
/**
Reads the next keystroke from the input device.
@@ -693,13 +697,13 @@ USBKeyboardReset (
EFI_STATUS
EFIAPI
USBKeyboardReadKeyStroke (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- OUT EFI_INPUT_KEY *Key
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ OUT EFI_INPUT_KEY *Key
)
{
- USB_KB_DEV *UsbKeyboardDevice;
- EFI_STATUS Status;
- EFI_KEY_DATA KeyData;
+ USB_KB_DEV *UsbKeyboardDevice;
+ EFI_STATUS Status;
+ EFI_KEY_DATA KeyData;
UsbKeyboardDevice = USB_KB_DEV_FROM_THIS (This);
@@ -713,21 +717,23 @@ USBKeyboardReadKeyStroke (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// SimpleTextIn Protocol doesn't support partial keystroke;
//
- if (KeyData.Key.ScanCode == CHAR_NULL && KeyData.Key.UnicodeChar == SCAN_NULL) {
+ if ((KeyData.Key.ScanCode == CHAR_NULL) && (KeyData.Key.UnicodeChar == SCAN_NULL)) {
continue;
}
+
//
// Translate the CTRL-Alpha characters to their corresponding control value
// (ctrl-a = 0x0001 through ctrl-Z = 0x001A)
//
if ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) {
- if (KeyData.Key.UnicodeChar >= L'a' && KeyData.Key.UnicodeChar <= L'z') {
- KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'a' + 1);
- } else if (KeyData.Key.UnicodeChar >= L'A' && KeyData.Key.UnicodeChar <= L'Z') {
- KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'A' + 1);
+ if ((KeyData.Key.UnicodeChar >= L'a') && (KeyData.Key.UnicodeChar <= L'z')) {
+ KeyData.Key.UnicodeChar = (CHAR16)(KeyData.Key.UnicodeChar - L'a' + 1);
+ } else if ((KeyData.Key.UnicodeChar >= L'A') && (KeyData.Key.UnicodeChar <= L'Z')) {
+ KeyData.Key.UnicodeChar = (CHAR16)(KeyData.Key.UnicodeChar - L'A' + 1);
}
}
@@ -736,7 +742,6 @@ USBKeyboardReadKeyStroke (
}
}
-
/**
Event notification function registered for EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx
and EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey.
@@ -748,15 +753,15 @@ USBKeyboardReadKeyStroke (
VOID
EFIAPI
USBKeyboardWaitForKey (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- USB_KB_DEV *UsbKeyboardDevice;
- EFI_KEY_DATA KeyData;
- EFI_TPL OldTpl;
+ USB_KB_DEV *UsbKeyboardDevice;
+ EFI_KEY_DATA KeyData;
+ EFI_TPL OldTpl;
- UsbKeyboardDevice = (USB_KB_DEV *) Context;
+ UsbKeyboardDevice = (USB_KB_DEV *)Context;
//
// Enter critical section
@@ -778,13 +783,15 @@ USBKeyboardWaitForKey (
UsbKeyboardDevice->EfiKeyQueue.Buffer[UsbKeyboardDevice->EfiKeyQueue.Head],
sizeof (EFI_KEY_DATA)
);
- if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {
+ if ((KeyData.Key.ScanCode == SCAN_NULL) && (KeyData.Key.UnicodeChar == CHAR_NULL)) {
Dequeue (&UsbKeyboardDevice->EfiKeyQueue, &KeyData, sizeof (EFI_KEY_DATA));
continue;
}
+
gBS->SignalEvent (Event);
break;
}
+
//
// Leave critical section and return
//
@@ -800,16 +807,16 @@ USBKeyboardWaitForKey (
VOID
EFIAPI
USBKeyboardTimerHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_STATUS Status;
- USB_KB_DEV *UsbKeyboardDevice;
- UINT8 KeyCode;
- EFI_KEY_DATA KeyData;
+ EFI_STATUS Status;
+ USB_KB_DEV *UsbKeyboardDevice;
+ UINT8 KeyCode;
+ EFI_KEY_DATA KeyData;
- UsbKeyboardDevice = (USB_KB_DEV *) Context;
+ UsbKeyboardDevice = (USB_KB_DEV *)Context;
//
// Fetch raw data from the USB keyboard buffer,
@@ -817,7 +824,7 @@ USBKeyboardTimerHandler (
//
Status = USBParseKey (UsbKeyboardDevice, &KeyCode);
if (EFI_ERROR (Status)) {
- return ;
+ return;
}
//
@@ -825,7 +832,7 @@ USBKeyboardTimerHandler (
//
Status = UsbKeyCodeToEfiInputKey (UsbKeyboardDevice, KeyCode, &KeyData);
if (EFI_ERROR (Status)) {
- return ;
+ return;
}
//
@@ -845,17 +852,18 @@ USBKeyboardTimerHandler (
**/
EFI_STATUS
KbdFreeNotifyList (
- IN OUT LIST_ENTRY *NotifyList
+ IN OUT LIST_ENTRY *NotifyList
)
{
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode;
- LIST_ENTRY *Link;
+ KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode;
+ LIST_ENTRY *Link;
if (NotifyList == NULL) {
return EFI_INVALID_PARAMETER;
}
+
while (!IsListEmpty (NotifyList)) {
- Link = GetFirstNode (NotifyList);
+ Link = GetFirstNode (NotifyList);
NotifyNode = CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
RemoveEntryList (Link);
FreePool (NotifyNode);
@@ -883,19 +891,23 @@ IsKeyRegistered (
ASSERT (RegsiteredData != NULL && InputData != NULL);
if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
- (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {
+ (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar))
+ {
return FALSE;
}
//
// Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
//
- if (RegsiteredData->KeyState.KeyShiftState != 0 &&
- RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {
+ if ((RegsiteredData->KeyState.KeyShiftState != 0) &&
+ (RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState))
+ {
return FALSE;
}
- if (RegsiteredData->KeyState.KeyToggleState != 0 &&
- RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {
+
+ if ((RegsiteredData->KeyState.KeyToggleState != 0) &&
+ (RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState))
+ {
return FALSE;
}
@@ -905,6 +917,7 @@ IsKeyRegistered (
//
// Simple Text Input Ex protocol functions
//
+
/**
Resets the input device hardware.
@@ -934,8 +947,8 @@ USBKeyboardResetEx (
IN BOOLEAN ExtendedVerification
)
{
- EFI_STATUS Status;
- USB_KB_DEV *UsbKeyboardDevice;
+ EFI_STATUS Status;
+ USB_KB_DEV *UsbKeyboardDevice;
UsbKeyboardDevice = TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS (This);
@@ -948,7 +961,6 @@ USBKeyboardResetEx (
UsbKeyboardDevice->KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;
return EFI_SUCCESS;
-
}
/**
@@ -968,11 +980,11 @@ USBKeyboardResetEx (
EFI_STATUS
EFIAPI
USBKeyboardReadKeyStrokeEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- OUT EFI_KEY_DATA *KeyData
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ OUT EFI_KEY_DATA *KeyData
)
{
- USB_KB_DEV *UsbKeyboardDevice;
+ USB_KB_DEV *UsbKeyboardDevice;
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
@@ -981,7 +993,6 @@ USBKeyboardReadKeyStrokeEx (
UsbKeyboardDevice = TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS (This);
return USBKeyboardReadKeyStrokeWorker (UsbKeyboardDevice, KeyData);
-
}
/**
@@ -1005,7 +1016,7 @@ USBKeyboardSetState (
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
)
{
- USB_KB_DEV *UsbKeyboardDevice;
+ USB_KB_DEV *UsbKeyboardDevice;
if (KeyToggleState == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1014,7 +1025,8 @@ USBKeyboardSetState (
UsbKeyboardDevice = TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS (This);
if (((UsbKeyboardDevice->KeyState.KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID) ||
- ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID)) {
+ ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID))
+ {
return EFI_UNSUPPORTED;
}
@@ -1022,20 +1034,23 @@ USBKeyboardSetState (
// Update the status light
//
- UsbKeyboardDevice->ScrollOn = FALSE;
- UsbKeyboardDevice->NumLockOn = FALSE;
- UsbKeyboardDevice->CapsOn = FALSE;
+ UsbKeyboardDevice->ScrollOn = FALSE;
+ UsbKeyboardDevice->NumLockOn = FALSE;
+ UsbKeyboardDevice->CapsOn = FALSE;
UsbKeyboardDevice->IsSupportPartialKey = FALSE;
if ((*KeyToggleState & EFI_SCROLL_LOCK_ACTIVE) == EFI_SCROLL_LOCK_ACTIVE) {
UsbKeyboardDevice->ScrollOn = TRUE;
}
+
if ((*KeyToggleState & EFI_NUM_LOCK_ACTIVE) == EFI_NUM_LOCK_ACTIVE) {
UsbKeyboardDevice->NumLockOn = TRUE;
}
+
if ((*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == EFI_CAPS_LOCK_ACTIVE) {
UsbKeyboardDevice->CapsOn = TRUE;
}
+
if ((*KeyToggleState & EFI_KEY_STATE_EXPOSED) == EFI_KEY_STATE_EXPOSED) {
UsbKeyboardDevice->IsSupportPartialKey = TRUE;
}
@@ -1045,7 +1060,6 @@ USBKeyboardSetState (
UsbKeyboardDevice->KeyState.KeyToggleState = *KeyToggleState;
return EFI_SUCCESS;
-
}
/**
@@ -1076,13 +1090,13 @@ USBKeyboardRegisterKeyNotify (
OUT VOID **NotifyHandle
)
{
- USB_KB_DEV *UsbKeyboardDevice;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *NewNotify;
- LIST_ENTRY *Link;
- LIST_ENTRY *NotifyList;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ USB_KB_DEV *UsbKeyboardDevice;
+ KEYBOARD_CONSOLE_IN_EX_NOTIFY *NewNotify;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *NotifyList;
+ KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {
+ if ((KeyData == NULL) || (NotifyHandle == NULL) || (KeyNotificationFunction == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1095,7 +1109,8 @@ USBKeyboardRegisterKeyNotify (
for (Link = GetFirstNode (NotifyList);
!IsNull (NotifyList, Link);
- Link = GetNextNode (NotifyList, Link)) {
+ Link = GetNextNode (NotifyList, Link))
+ {
CurrentNotify = CR (
Link,
KEYBOARD_CONSOLE_IN_EX_NOTIFY,
@@ -1113,7 +1128,7 @@ USBKeyboardRegisterKeyNotify (
//
// Allocate resource to save the notification function
//
- NewNotify = (KEYBOARD_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_EX_NOTIFY));
+ NewNotify = (KEYBOARD_CONSOLE_IN_EX_NOTIFY *)AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_EX_NOTIFY));
if (NewNotify == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1123,11 +1138,9 @@ USBKeyboardRegisterKeyNotify (
CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA));
InsertTailList (&UsbKeyboardDevice->NotifyList, &NewNotify->NotifyEntry);
-
*NotifyHandle = NewNotify;
return EFI_SUCCESS;
-
}
/**
@@ -1147,10 +1160,10 @@ USBKeyboardUnregisterKeyNotify (
IN VOID *NotificationHandle
)
{
- USB_KB_DEV *UsbKeyboardDevice;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- LIST_ENTRY *Link;
- LIST_ENTRY *NotifyList;
+ USB_KB_DEV *UsbKeyboardDevice;
+ KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *NotifyList;
if (NotificationHandle == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1164,7 +1177,8 @@ USBKeyboardUnregisterKeyNotify (
NotifyList = &UsbKeyboardDevice->NotifyList;
for (Link = GetFirstNode (NotifyList);
!IsNull (NotifyList, Link);
- Link = GetNextNode (NotifyList, Link)) {
+ Link = GetNextNode (NotifyList, Link))
+ {
CurrentNotify = CR (
Link,
KEYBOARD_CONSOLE_IN_EX_NOTIFY,
@@ -1197,19 +1211,19 @@ USBKeyboardUnregisterKeyNotify (
VOID
EFIAPI
KeyNotifyProcessHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_STATUS Status;
- USB_KB_DEV *UsbKeyboardDevice;
- EFI_KEY_DATA KeyData;
- LIST_ENTRY *Link;
- LIST_ENTRY *NotifyList;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ USB_KB_DEV *UsbKeyboardDevice;
+ EFI_KEY_DATA KeyData;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *NotifyList;
+ KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ EFI_TPL OldTpl;
- UsbKeyboardDevice = (USB_KB_DEV *) Context;
+ UsbKeyboardDevice = (USB_KB_DEV *)Context;
//
// Invoke notification functions.
@@ -1228,6 +1242,7 @@ KeyNotifyProcessHandler (
if (EFI_ERROR (Status)) {
break;
}
+
for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {
CurrentNotify = CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) {
@@ -1236,4 +1251,3 @@ KeyNotifyProcessHandler (
}
}
}
-
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h
index 852e433..a9dfeaf 100644
--- a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h
+++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h
@@ -5,10 +5,10 @@ Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+
#ifndef _EFI_USB_KB_H_
#define _EFI_USB_KB_H_
-
#include <Uefi.h>
#include <Protocol/SimpleTextIn.h>
@@ -34,59 +34,59 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <IndustryStandard/Usb.h>
-#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
+#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
-#define MAX_KEY_ALLOWED 32
+#define MAX_KEY_ALLOWED 32
-#define HZ 1000 * 1000 * 10
-#define USBKBD_REPEAT_DELAY ((HZ) / 2)
-#define USBKBD_REPEAT_RATE ((HZ) / 50)
+#define HZ 1000 * 1000 * 10
+#define USBKBD_REPEAT_DELAY ((HZ) / 2)
+#define USBKBD_REPEAT_RATE ((HZ) / 50)
-#define CLASS_HID 3
-#define SUBCLASS_BOOT 1
-#define PROTOCOL_KEYBOARD 1
+#define CLASS_HID 3
+#define SUBCLASS_BOOT 1
+#define PROTOCOL_KEYBOARD 1
-#define BOOT_PROTOCOL 0
-#define REPORT_PROTOCOL 1
+#define BOOT_PROTOCOL 0
+#define REPORT_PROTOCOL 1
typedef struct {
- BOOLEAN Down;
- UINT8 KeyCode;
+ BOOLEAN Down;
+ UINT8 KeyCode;
} USB_KEY;
typedef struct {
- VOID *Buffer[MAX_KEY_ALLOWED + 1];
- UINTN Head;
- UINTN Tail;
- UINTN ItemSize;
+ VOID *Buffer[MAX_KEY_ALLOWED + 1];
+ UINTN Head;
+ UINTN Tail;
+ UINTN ItemSize;
} USB_SIMPLE_QUEUE;
-#define USB_KB_DEV_SIGNATURE SIGNATURE_32 ('u', 'k', 'b', 'd')
-#define USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('u', 'k', 'b', 'x')
+#define USB_KB_DEV_SIGNATURE SIGNATURE_32 ('u', 'k', 'b', 'd')
+#define USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('u', 'k', 'b', 'x')
typedef struct _KEYBOARD_CONSOLE_IN_EX_NOTIFY {
- UINTN Signature;
- EFI_KEY_DATA KeyData;
- EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
- LIST_ENTRY NotifyEntry;
+ UINTN Signature;
+ EFI_KEY_DATA KeyData;
+ EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
+ LIST_ENTRY NotifyEntry;
} KEYBOARD_CONSOLE_IN_EX_NOTIFY;
#define USB_NS_KEY_SIGNATURE SIGNATURE_32 ('u', 'n', 's', 'k')
typedef struct {
- UINTN Signature;
- LIST_ENTRY Link;
+ UINTN Signature;
+ LIST_ENTRY Link;
//
// The number of EFI_NS_KEY_MODIFIER children definitions
//
- UINTN KeyCount;
+ UINTN KeyCount;
//
// NsKey[0] : Non-spacing key
// NsKey[1] ~ NsKey[KeyCount] : Physical keys
//
- EFI_KEY_DESCRIPTOR *NsKey;
+ EFI_KEY_DESCRIPTOR *NsKey;
} USB_NS_KEY;
#define USB_NS_KEY_FORM_FROM_LINK(a) CR (a, USB_NS_KEY, Link, USB_NS_KEY_SIGNATURE)
@@ -95,64 +95,64 @@ typedef struct {
/// Structure to describe USB keyboard device
///
typedef struct {
- UINTN Signature;
- EFI_HANDLE ControllerHandle;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_EVENT DelayedRecoveryEvent;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;
- EFI_USB_IO_PROTOCOL *UsbIo;
-
- EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
- EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;
-
- USB_SIMPLE_QUEUE UsbKeyQueue;
- USB_SIMPLE_QUEUE EfiKeyQueue;
- USB_SIMPLE_QUEUE EfiKeyQueueForNotify;
- BOOLEAN CtrlOn;
- BOOLEAN AltOn;
- BOOLEAN ShiftOn;
- BOOLEAN NumLockOn;
- BOOLEAN CapsOn;
- BOOLEAN ScrollOn;
- UINT8 LastKeyCodeArray[8];
- UINT8 CurKeyCode;
-
- EFI_EVENT TimerEvent;
-
- UINT8 RepeatKey;
- EFI_EVENT RepeatTimer;
-
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
-
- BOOLEAN LeftCtrlOn;
- BOOLEAN LeftAltOn;
- BOOLEAN LeftShiftOn;
- BOOLEAN LeftLogoOn;
- BOOLEAN RightCtrlOn;
- BOOLEAN RightAltOn;
- BOOLEAN RightShiftOn;
- BOOLEAN RightLogoOn;
- BOOLEAN MenuKeyOn;
- BOOLEAN SysReqOn;
- BOOLEAN AltGrOn;
-
- BOOLEAN IsSupportPartialKey;
-
- EFI_KEY_STATE KeyState;
+ UINTN Signature;
+ EFI_HANDLE ControllerHandle;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_EVENT DelayedRecoveryEvent;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput;
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+
+ EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
+ EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;
+
+ USB_SIMPLE_QUEUE UsbKeyQueue;
+ USB_SIMPLE_QUEUE EfiKeyQueue;
+ USB_SIMPLE_QUEUE EfiKeyQueueForNotify;
+ BOOLEAN CtrlOn;
+ BOOLEAN AltOn;
+ BOOLEAN ShiftOn;
+ BOOLEAN NumLockOn;
+ BOOLEAN CapsOn;
+ BOOLEAN ScrollOn;
+ UINT8 LastKeyCodeArray[8];
+ UINT8 CurKeyCode;
+
+ EFI_EVENT TimerEvent;
+
+ UINT8 RepeatKey;
+ EFI_EVENT RepeatTimer;
+
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+
+ BOOLEAN LeftCtrlOn;
+ BOOLEAN LeftAltOn;
+ BOOLEAN LeftShiftOn;
+ BOOLEAN LeftLogoOn;
+ BOOLEAN RightCtrlOn;
+ BOOLEAN RightAltOn;
+ BOOLEAN RightShiftOn;
+ BOOLEAN RightLogoOn;
+ BOOLEAN MenuKeyOn;
+ BOOLEAN SysReqOn;
+ BOOLEAN AltGrOn;
+
+ BOOLEAN IsSupportPartialKey;
+
+ EFI_KEY_STATE KeyState;
//
// Notification function list
//
- LIST_ENTRY NotifyList;
- EFI_EVENT KeyNotifyProcessEvent;
+ LIST_ENTRY NotifyList;
+ EFI_EVENT KeyNotifyProcessEvent;
//
// Non-spacing key list
//
- LIST_ENTRY NsKeyList;
- USB_NS_KEY *CurrentNsKey;
- EFI_KEY_DESCRIPTOR *KeyConvertionTable;
- EFI_EVENT KeyboardLayoutEvent;
+ LIST_ENTRY NsKeyList;
+ USB_NS_KEY *CurrentNsKey;
+ EFI_KEY_DESCRIPTOR *KeyConvertionTable;
+ EFI_EVENT KeyboardLayoutEvent;
} USB_KB_DEV;
//
@@ -175,23 +175,24 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gUsbKeyboardComponentName2;
// So the number of valid non-modifier USB keycodes is 0x62, and the number of
// valid keycodes is 0x6A.
//
-#define NUMBER_OF_VALID_NON_MODIFIER_USB_KEYCODE 0x62
-#define NUMBER_OF_VALID_USB_KEYCODE 0x6A
+#define NUMBER_OF_VALID_NON_MODIFIER_USB_KEYCODE 0x62
+#define NUMBER_OF_VALID_USB_KEYCODE 0x6A
//
// 0x0 to 0x3 are reserved for typical keyboard status or keyboard errors.
//
-#define USBKBD_VALID_KEYCODE(Key) ((UINT8) (Key) > 3)
+#define USBKBD_VALID_KEYCODE(Key) ((UINT8) (Key) > 3)
typedef struct {
- UINT8 NumLock : 1;
- UINT8 CapsLock : 1;
- UINT8 ScrollLock : 1;
- UINT8 Resrvd : 5;
+ UINT8 NumLock : 1;
+ UINT8 CapsLock : 1;
+ UINT8 ScrollLock : 1;
+ UINT8 Resrvd : 5;
} LED_MAP;
//
// Functions of Driver Binding Protocol
//
+
/**
Check whether USB keyboard driver supports this device.
@@ -206,9 +207,9 @@ typedef struct {
EFI_STATUS
EFIAPI
USBKeyboardDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -231,9 +232,9 @@ USBKeyboardDriverBindingSupported (
EFI_STATUS
EFIAPI
USBKeyboardDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -254,15 +255,16 @@ USBKeyboardDriverBindingStart (
EFI_STATUS
EFIAPI
USBKeyboardDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
);
//
// EFI Component Name Functions
//
+
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -366,16 +368,17 @@ UsbKeyboardComponentNameGetDriverName (
EFI_STATUS
EFIAPI
UsbKeyboardComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
//
// Functions of Simple Text Input Protocol
//
+
/**
Reset the input device and optionally run diagnostics
@@ -394,8 +397,8 @@ UsbKeyboardComponentNameGetControllerName (
EFI_STATUS
EFIAPI
USBKeyboardReset (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
/**
@@ -414,13 +417,14 @@ USBKeyboardReset (
EFI_STATUS
EFIAPI
USBKeyboardReadKeyStroke (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- OUT EFI_INPUT_KEY *Key
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ OUT EFI_INPUT_KEY *Key
);
//
// Simple Text Input Ex protocol functions
//
+
/**
Resets the input device hardware.
@@ -467,8 +471,8 @@ USBKeyboardResetEx (
EFI_STATUS
EFIAPI
USBKeyboardReadKeyStrokeEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- OUT EFI_KEY_DATA *KeyData
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ OUT EFI_KEY_DATA *KeyData
);
/**
@@ -549,8 +553,8 @@ USBKeyboardUnregisterKeyNotify (
VOID
EFIAPI
USBKeyboardWaitForKey (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -564,7 +568,7 @@ USBKeyboardWaitForKey (
**/
EFI_STATUS
KbdFreeNotifyList (
- IN OUT LIST_ENTRY *NotifyList
+ IN OUT LIST_ENTRY *NotifyList
);
/**
@@ -592,8 +596,8 @@ IsKeyRegistered (
VOID
EFIAPI
USBKeyboardTimerHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -605,9 +609,8 @@ USBKeyboardTimerHandler (
VOID
EFIAPI
KeyNotifyProcessHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
#endif
-
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c
index 5faf82e..5a94a4d 100644
--- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c
+++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c
@@ -18,125 +18,125 @@ USB_KEYBOARD_LAYOUT_PACK_BIN mUsbKeyboardLayoutBin = {
sizeof (USB_KEYBOARD_LAYOUT_PACK_BIN) - sizeof (UINT32),
EFI_HII_PACKAGE_KEYBOARD_LAYOUT
},
- 1, // LayoutCount
- sizeof (USB_KEYBOARD_LAYOUT_PACK_BIN) - sizeof (UINT32) - sizeof (EFI_HII_PACKAGE_HEADER) - sizeof (UINT16), // LayoutLength
- USB_KEYBOARD_LAYOUT_KEY_GUID, // KeyGuid
+ 1, // LayoutCount
+ sizeof (USB_KEYBOARD_LAYOUT_PACK_BIN) - sizeof (UINT32) - sizeof (EFI_HII_PACKAGE_HEADER) - sizeof (UINT16), // LayoutLength
+ USB_KEYBOARD_LAYOUT_KEY_GUID, // KeyGuid
sizeof (UINT16) + sizeof (EFI_GUID) + sizeof (UINT32) + sizeof (UINT8) + (USB_KEYBOARD_KEY_COUNT * sizeof (EFI_KEY_DESCRIPTOR)), // LayoutDescriptorStringOffset
- USB_KEYBOARD_KEY_COUNT, // DescriptorCount
+ USB_KEYBOARD_KEY_COUNT, // DescriptorCount
{
//
// EFI_KEY_DESCRIPTOR (total number is USB_KEYBOARD_KEY_COUNT)
//
- {EfiKeyC1, 'a', 'A', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyB5, 'b', 'B', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyB3, 'c', 'C', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyC3, 'd', 'D', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyD3, 'e', 'E', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyC4, 'f', 'F', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyC5, 'g', 'G', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyC6, 'h', 'H', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyD8, 'i', 'I', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyC7, 'j', 'J', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyC8, 'k', 'K', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyC9, 'l', 'L', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyB7, 'm', 'M', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyB6, 'n', 'N', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyD9, 'o', 'O', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyD10, 'p', 'P', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyD1, 'q', 'Q', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyD4, 'r', 'R', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyC2, 's', 'S', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyD5, 't', 'T', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyD7, 'u', 'U', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyB4, 'v', 'V', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyD2, 'w', 'W', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyB2, 'x', 'X', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyD6, 'y', 'Y', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyB1, 'z', 'Z', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK},
- {EfiKeyE1, '1', '!', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyE2, '2', '@', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyE3, '3', '#', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyE4, '4', '$', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyE5, '5', '%', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyE6, '6', '^', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyE7, '7', '&', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyE8, '8', '*', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyE9, '9', '(', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyE10, '0', ')', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyEnter, 0x0d, 0x0d, 0, 0, EFI_NULL_MODIFIER, 0},
- {EfiKeyEsc, 0x1b, 0x1b, 0, 0, EFI_NULL_MODIFIER, 0},
- {EfiKeyBackSpace, 0x08, 0x08, 0, 0, EFI_NULL_MODIFIER, 0},
- {EfiKeyTab, 0x09, 0x09, 0, 0, EFI_NULL_MODIFIER, 0},
- {EfiKeySpaceBar, ' ', ' ', 0, 0, EFI_NULL_MODIFIER, 0},
- {EfiKeyE11, '-', '_', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyE12, '=', '+', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyD11, '[', '{', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyD12, ']', '}', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyD13, '\\', '|', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyC12, '\\', '|', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyC10, ';', ':', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyC11, '\'', '"', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyE0, '`', '~', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyB8, ',', '<', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyB9, '.', '>', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyB10, '/', '?', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT},
- {EfiKeyCapsLock, 0x00, 0x00, 0, 0, EFI_CAPS_LOCK_MODIFIER, 0},
- {EfiKeyF1, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_ONE_MODIFIER, 0},
- {EfiKeyF2, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_TWO_MODIFIER, 0},
- {EfiKeyF3, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_THREE_MODIFIER, 0},
- {EfiKeyF4, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_FOUR_MODIFIER, 0},
- {EfiKeyF5, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_FIVE_MODIFIER, 0},
- {EfiKeyF6, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_SIX_MODIFIER, 0},
- {EfiKeyF7, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_SEVEN_MODIFIER, 0},
- {EfiKeyF8, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_EIGHT_MODIFIER, 0},
- {EfiKeyF9, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_NINE_MODIFIER, 0},
- {EfiKeyF10, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_TEN_MODIFIER, 0},
- {EfiKeyF11, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_ELEVEN_MODIFIER, 0},
- {EfiKeyF12, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_TWELVE_MODIFIER, 0},
- {EfiKeyPrint, 0x00, 0x00, 0, 0, EFI_PRINT_MODIFIER, 0},
- {EfiKeySLck, 0x00, 0x00, 0, 0, EFI_SCROLL_LOCK_MODIFIER, 0},
- {EfiKeyPause, 0x00, 0x00, 0, 0, EFI_PAUSE_MODIFIER, 0},
- {EfiKeyIns, 0x00, 0x00, 0, 0, EFI_INSERT_MODIFIER, 0},
- {EfiKeyHome, 0x00, 0x00, 0, 0, EFI_HOME_MODIFIER, 0},
- {EfiKeyPgUp, 0x00, 0x00, 0, 0, EFI_PAGE_UP_MODIFIER, 0},
- {EfiKeyDel, 0x00, 0x00, 0, 0, EFI_DELETE_MODIFIER, 0},
- {EfiKeyEnd, 0x00, 0x00, 0, 0, EFI_END_MODIFIER, 0},
- {EfiKeyPgDn, 0x00, 0x00, 0, 0, EFI_PAGE_DOWN_MODIFIER, 0},
- {EfiKeyRightArrow, 0x00, 0x00, 0, 0, EFI_RIGHT_ARROW_MODIFIER, 0},
- {EfiKeyLeftArrow, 0x00, 0x00, 0, 0, EFI_LEFT_ARROW_MODIFIER, 0},
- {EfiKeyDownArrow, 0x00, 0x00, 0, 0, EFI_DOWN_ARROW_MODIFIER, 0},
- {EfiKeyUpArrow, 0x00, 0x00, 0, 0, EFI_UP_ARROW_MODIFIER, 0},
- {EfiKeyNLck, 0x00, 0x00, 0, 0, EFI_NUM_LOCK_MODIFIER, 0},
- {EfiKeySlash, '/', '/', 0, 0, EFI_NULL_MODIFIER, 0},
- {EfiKeyAsterisk, '*', '*', 0, 0, EFI_NULL_MODIFIER, 0},
- {EfiKeyMinus, '-', '-', 0, 0, EFI_NULL_MODIFIER, 0},
- {EfiKeyPlus, '+', '+', 0, 0, EFI_NULL_MODIFIER, 0},
- {EfiKeyEnter, 0x0d, 0x0d, 0, 0, EFI_NULL_MODIFIER, 0},
- {EfiKeyOne, '1', '1', 0, 0, EFI_END_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK},
- {EfiKeyTwo, '2', '2', 0, 0, EFI_DOWN_ARROW_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK},
- {EfiKeyThree, '3', '3', 0, 0, EFI_PAGE_DOWN_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK},
- {EfiKeyFour, '4', '4', 0, 0, EFI_LEFT_ARROW_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK},
- {EfiKeyFive, '5', '5', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK},
- {EfiKeySix, '6', '6', 0, 0, EFI_RIGHT_ARROW_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK},
- {EfiKeySeven, '7', '7', 0, 0, EFI_HOME_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK},
- {EfiKeyEight, '8', '8', 0, 0, EFI_UP_ARROW_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK},
- {EfiKeyNine, '9', '9', 0, 0, EFI_PAGE_UP_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK},
- {EfiKeyZero, '0', '0', 0, 0, EFI_INSERT_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK},
- {EfiKeyPeriod, '.', '.', 0, 0, EFI_DELETE_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK},
- {EfiKeyA4, 0x00, 0x00, 0, 0, EFI_MENU_MODIFIER, 0},
- {EfiKeyLCtrl, 0, 0, 0, 0, EFI_LEFT_CONTROL_MODIFIER, 0},
- {EfiKeyLShift, 0, 0, 0, 0, EFI_LEFT_SHIFT_MODIFIER, 0},
- {EfiKeyLAlt, 0, 0, 0, 0, EFI_LEFT_ALT_MODIFIER, 0},
- {EfiKeyA0, 0, 0, 0, 0, EFI_LEFT_LOGO_MODIFIER, 0},
- {EfiKeyRCtrl, 0, 0, 0, 0, EFI_RIGHT_CONTROL_MODIFIER, 0},
- {EfiKeyRShift, 0, 0, 0, 0, EFI_RIGHT_SHIFT_MODIFIER, 0},
- {EfiKeyA2, 0, 0, 0, 0, EFI_RIGHT_ALT_MODIFIER, 0},
- {EfiKeyA3, 0, 0, 0, 0, EFI_RIGHT_LOGO_MODIFIER, 0},
+ { EfiKeyC1, 'a', 'A', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyB5, 'b', 'B', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyB3, 'c', 'C', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyC3, 'd', 'D', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyD3, 'e', 'E', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyC4, 'f', 'F', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyC5, 'g', 'G', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyC6, 'h', 'H', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyD8, 'i', 'I', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyC7, 'j', 'J', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyC8, 'k', 'K', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyC9, 'l', 'L', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyB7, 'm', 'M', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyB6, 'n', 'N', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyD9, 'o', 'O', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyD10, 'p', 'P', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyD1, 'q', 'Q', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyD4, 'r', 'R', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyC2, 's', 'S', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyD5, 't', 'T', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyD7, 'u', 'U', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyB4, 'v', 'V', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyD2, 'w', 'W', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyB2, 'x', 'X', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyD6, 'y', 'Y', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyB1, 'z', 'Z', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK },
+ { EfiKeyE1, '1', '!', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyE2, '2', '@', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyE3, '3', '#', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyE4, '4', '$', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyE5, '5', '%', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyE6, '6', '^', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyE7, '7', '&', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyE8, '8', '*', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyE9, '9', '(', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyE10, '0', ')', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyEnter, 0x0d, 0x0d, 0, 0, EFI_NULL_MODIFIER, 0 },
+ { EfiKeyEsc, 0x1b, 0x1b, 0, 0, EFI_NULL_MODIFIER, 0 },
+ { EfiKeyBackSpace, 0x08, 0x08, 0, 0, EFI_NULL_MODIFIER, 0 },
+ { EfiKeyTab, 0x09, 0x09, 0, 0, EFI_NULL_MODIFIER, 0 },
+ { EfiKeySpaceBar, ' ', ' ', 0, 0, EFI_NULL_MODIFIER, 0 },
+ { EfiKeyE11, '-', '_', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyE12, '=', '+', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyD11, '[', '{', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyD12, ']', '}', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyD13, '\\', '|', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyC12, '\\', '|', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyC10, ';', ':', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyC11, '\'', '"', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyE0, '`', '~', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyB8, ',', '<', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyB9, '.', '>', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyB10, '/', '?', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT },
+ { EfiKeyCapsLock, 0x00, 0x00, 0, 0, EFI_CAPS_LOCK_MODIFIER, 0 },
+ { EfiKeyF1, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_ONE_MODIFIER, 0 },
+ { EfiKeyF2, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_TWO_MODIFIER, 0 },
+ { EfiKeyF3, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_THREE_MODIFIER, 0 },
+ { EfiKeyF4, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_FOUR_MODIFIER, 0 },
+ { EfiKeyF5, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_FIVE_MODIFIER, 0 },
+ { EfiKeyF6, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_SIX_MODIFIER, 0 },
+ { EfiKeyF7, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_SEVEN_MODIFIER, 0 },
+ { EfiKeyF8, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_EIGHT_MODIFIER, 0 },
+ { EfiKeyF9, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_NINE_MODIFIER, 0 },
+ { EfiKeyF10, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_TEN_MODIFIER, 0 },
+ { EfiKeyF11, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_ELEVEN_MODIFIER, 0 },
+ { EfiKeyF12, 0x00, 0x00, 0, 0, EFI_FUNCTION_KEY_TWELVE_MODIFIER, 0 },
+ { EfiKeyPrint, 0x00, 0x00, 0, 0, EFI_PRINT_MODIFIER, 0 },
+ { EfiKeySLck, 0x00, 0x00, 0, 0, EFI_SCROLL_LOCK_MODIFIER, 0 },
+ { EfiKeyPause, 0x00, 0x00, 0, 0, EFI_PAUSE_MODIFIER, 0 },
+ { EfiKeyIns, 0x00, 0x00, 0, 0, EFI_INSERT_MODIFIER, 0 },
+ { EfiKeyHome, 0x00, 0x00, 0, 0, EFI_HOME_MODIFIER, 0 },
+ { EfiKeyPgUp, 0x00, 0x00, 0, 0, EFI_PAGE_UP_MODIFIER, 0 },
+ { EfiKeyDel, 0x00, 0x00, 0, 0, EFI_DELETE_MODIFIER, 0 },
+ { EfiKeyEnd, 0x00, 0x00, 0, 0, EFI_END_MODIFIER, 0 },
+ { EfiKeyPgDn, 0x00, 0x00, 0, 0, EFI_PAGE_DOWN_MODIFIER, 0 },
+ { EfiKeyRightArrow, 0x00, 0x00, 0, 0, EFI_RIGHT_ARROW_MODIFIER, 0 },
+ { EfiKeyLeftArrow, 0x00, 0x00, 0, 0, EFI_LEFT_ARROW_MODIFIER, 0 },
+ { EfiKeyDownArrow, 0x00, 0x00, 0, 0, EFI_DOWN_ARROW_MODIFIER, 0 },
+ { EfiKeyUpArrow, 0x00, 0x00, 0, 0, EFI_UP_ARROW_MODIFIER, 0 },
+ { EfiKeyNLck, 0x00, 0x00, 0, 0, EFI_NUM_LOCK_MODIFIER, 0 },
+ { EfiKeySlash, '/', '/', 0, 0, EFI_NULL_MODIFIER, 0 },
+ { EfiKeyAsterisk, '*', '*', 0, 0, EFI_NULL_MODIFIER, 0 },
+ { EfiKeyMinus, '-', '-', 0, 0, EFI_NULL_MODIFIER, 0 },
+ { EfiKeyPlus, '+', '+', 0, 0, EFI_NULL_MODIFIER, 0 },
+ { EfiKeyEnter, 0x0d, 0x0d, 0, 0, EFI_NULL_MODIFIER, 0 },
+ { EfiKeyOne, '1', '1', 0, 0, EFI_END_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK },
+ { EfiKeyTwo, '2', '2', 0, 0, EFI_DOWN_ARROW_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK },
+ { EfiKeyThree, '3', '3', 0, 0, EFI_PAGE_DOWN_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK },
+ { EfiKeyFour, '4', '4', 0, 0, EFI_LEFT_ARROW_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK },
+ { EfiKeyFive, '5', '5', 0, 0, EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK },
+ { EfiKeySix, '6', '6', 0, 0, EFI_RIGHT_ARROW_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK },
+ { EfiKeySeven, '7', '7', 0, 0, EFI_HOME_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK },
+ { EfiKeyEight, '8', '8', 0, 0, EFI_UP_ARROW_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK },
+ { EfiKeyNine, '9', '9', 0, 0, EFI_PAGE_UP_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK },
+ { EfiKeyZero, '0', '0', 0, 0, EFI_INSERT_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK },
+ { EfiKeyPeriod, '.', '.', 0, 0, EFI_DELETE_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK },
+ { EfiKeyA4, 0x00, 0x00, 0, 0, EFI_MENU_MODIFIER, 0 },
+ { EfiKeyLCtrl, 0, 0, 0, 0, EFI_LEFT_CONTROL_MODIFIER, 0 },
+ { EfiKeyLShift, 0, 0, 0, 0, EFI_LEFT_SHIFT_MODIFIER, 0 },
+ { EfiKeyLAlt, 0, 0, 0, 0, EFI_LEFT_ALT_MODIFIER, 0 },
+ { EfiKeyA0, 0, 0, 0, 0, EFI_LEFT_LOGO_MODIFIER, 0 },
+ { EfiKeyRCtrl, 0, 0, 0, 0, EFI_RIGHT_CONTROL_MODIFIER, 0 },
+ { EfiKeyRShift, 0, 0, 0, 0, EFI_RIGHT_SHIFT_MODIFIER, 0 },
+ { EfiKeyA2, 0, 0, 0, 0, EFI_RIGHT_ALT_MODIFIER, 0 },
+ { EfiKeyA3, 0, 0, 0, 0, EFI_RIGHT_LOGO_MODIFIER, 0 },
},
- 1, // DescriptionCount
- {'e', 'n', '-', 'U', 'S'}, // RFC4646 language code
- ' ', // Space
- {'E', 'n', 'g', 'l', 'i', 's', 'h', ' ', 'K', 'e', 'y', 'b', 'o', 'a', 'r', 'd', '\0'}, // DescriptionString[]
+ 1, // DescriptionCount
+ { 'e', 'n', '-', 'U', 'S' }, // RFC4646 language code
+ ' ', // Space
+ { 'E', 'n', 'g', 'l', 'i', 's', 'h', ' ', 'K', 'e', 'y', 'b', 'o', 'a', 'r', 'd', '\0' }, // DescriptionString[]
};
//
@@ -144,7 +144,7 @@ USB_KEYBOARD_LAYOUT_PACK_BIN mUsbKeyboardLayoutBin = {
// EFI_KEY is defined in UEFI spec.
// USB Keycode is defined in USB HID Firmware spec.
//
-UINT8 EfiKeyToUsbKeyCodeConvertionTable[] = {
+UINT8 EfiKeyToUsbKeyCodeConvertionTable[] = {
0xe0, // EfiKeyLCtrl
0xe3, // EfiKeyA0
0xe2, // EfiKeyLAlt
@@ -256,7 +256,7 @@ UINT8 EfiKeyToUsbKeyCodeConvertionTable[] = {
// Keyboard modifier value to EFI Scan Code conversion table
// EFI Scan Code and the modifier values are defined in UEFI spec.
//
-UINT8 ModifierValueToEfiScanCodeConvertionTable[] = {
+UINT8 ModifierValueToEfiScanCodeConvertionTable[] = {
SCAN_NULL, // EFI_NULL_MODIFIER
SCAN_NULL, // EFI_LEFT_CONTROL_MODIFIER
SCAN_NULL, // EFI_RIGHT_CONTROL_MODIFIER
@@ -314,12 +314,12 @@ UINT8 ModifierValueToEfiScanCodeConvertionTable[] = {
**/
EFI_STATUS
InstallDefaultKeyboardLayout (
- IN OUT USB_KB_DEV *UsbKeyboardDevice
+ IN OUT USB_KB_DEV *UsbKeyboardDevice
)
{
- EFI_STATUS Status;
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
- EFI_HII_HANDLE HiiHandle;
+ EFI_STATUS Status;
+ EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
+ EFI_HII_HANDLE HiiHandle;
//
// Locate Hii database protocol
@@ -327,7 +327,7 @@ InstallDefaultKeyboardLayout (
Status = gBS->LocateProtocol (
&gEfiHiiDatabaseProtocolGuid,
NULL,
- (VOID **) &HiiDatabase
+ (VOID **)&HiiDatabase
);
if (EFI_ERROR (Status)) {
return Status;
@@ -354,7 +354,6 @@ InstallDefaultKeyboardLayout (
return Status;
}
-
/**
Uses USB I/O to check whether the device is a USB keyboard device.
@@ -366,7 +365,7 @@ InstallDefaultKeyboardLayout (
**/
BOOLEAN
IsUSBKeyboard (
- IN EFI_USB_IO_PROTOCOL *UsbIo
+ IN EFI_USB_IO_PROTOCOL *UsbIo
)
{
EFI_STATUS Status;
@@ -384,10 +383,11 @@ IsUSBKeyboard (
return FALSE;
}
- if (InterfaceDescriptor.InterfaceClass == CLASS_HID &&
- InterfaceDescriptor.InterfaceSubClass == SUBCLASS_BOOT &&
- InterfaceDescriptor.InterfaceProtocol == PROTOCOL_KEYBOARD
- ) {
+ if ((InterfaceDescriptor.InterfaceClass == CLASS_HID) &&
+ (InterfaceDescriptor.InterfaceSubClass == SUBCLASS_BOOT) &&
+ (InterfaceDescriptor.InterfaceProtocol == PROTOCOL_KEYBOARD)
+ )
+ {
return TRUE;
}
@@ -406,10 +406,10 @@ GetCurrentKeyboardLayout (
VOID
)
{
- EFI_STATUS Status;
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
- EFI_HII_KEYBOARD_LAYOUT *KeyboardLayout;
- UINT16 Length;
+ EFI_STATUS Status;
+ EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
+ EFI_HII_KEYBOARD_LAYOUT *KeyboardLayout;
+ UINT16 Length;
//
// Locate HII Database Protocol
@@ -417,7 +417,7 @@ GetCurrentKeyboardLayout (
Status = gBS->LocateProtocol (
&gEfiHiiDatabaseProtocolGuid,
NULL,
- (VOID **) &HiiDatabase
+ (VOID **)&HiiDatabase
);
if (EFI_ERROR (Status)) {
return NULL;
@@ -426,14 +426,14 @@ GetCurrentKeyboardLayout (
//
// Get current keyboard layout from HII database
//
- Length = 0;
+ Length = 0;
KeyboardLayout = NULL;
- Status = HiiDatabase->GetKeyboardLayout (
- HiiDatabase,
- NULL,
- &Length,
- KeyboardLayout
- );
+ Status = HiiDatabase->GetKeyboardLayout (
+ HiiDatabase,
+ NULL,
+ &Length,
+ KeyboardLayout
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
KeyboardLayout = AllocatePool (Length);
ASSERT (KeyboardLayout != NULL);
@@ -465,8 +465,8 @@ GetCurrentKeyboardLayout (
**/
EFI_KEY_DESCRIPTOR *
GetKeyDescriptor (
- IN USB_KB_DEV *UsbKeyboardDevice,
- IN UINT8 KeyCode
+ IN USB_KB_DEV *UsbKeyboardDevice,
+ IN UINT8 KeyCode
)
{
UINT8 Index;
@@ -482,9 +482,9 @@ GetKeyDescriptor (
// Calculate the index of Key Descriptor in Key Convertion Table
//
if (KeyCode <= 0x65) {
- Index = (UINT8) (KeyCode - 4);
+ Index = (UINT8)(KeyCode - 4);
} else {
- Index = (UINT8) (KeyCode - 0xe0 + NUMBER_OF_VALID_NON_MODIFIER_USB_KEYCODE);
+ Index = (UINT8)(KeyCode - 0xe0 + NUMBER_OF_VALID_NON_MODIFIER_USB_KEYCODE);
}
return &UsbKeyboardDevice->KeyConvertionTable[Index];
@@ -506,12 +506,12 @@ FindUsbNsKey (
IN EFI_KEY_DESCRIPTOR *KeyDescriptor
)
{
- LIST_ENTRY *Link;
- LIST_ENTRY *NsKeyList;
- USB_NS_KEY *UsbNsKey;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *NsKeyList;
+ USB_NS_KEY *UsbNsKey;
NsKeyList = &UsbKeyboardDevice->NsKeyList;
- Link = GetFirstNode (NsKeyList);
+ Link = GetFirstNode (NsKeyList);
while (!IsNull (NsKeyList, Link)) {
UsbNsKey = USB_NS_KEY_FORM_FROM_LINK (Link);
@@ -578,23 +578,23 @@ FindPhysicalKey (
VOID
EFIAPI
SetKeyboardLayoutEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- USB_KB_DEV *UsbKeyboardDevice;
- EFI_HII_KEYBOARD_LAYOUT *KeyboardLayout;
- EFI_KEY_DESCRIPTOR TempKey;
- EFI_KEY_DESCRIPTOR *KeyDescriptor;
- EFI_KEY_DESCRIPTOR *TableEntry;
- EFI_KEY_DESCRIPTOR *NsKey;
- USB_NS_KEY *UsbNsKey;
- UINTN Index;
- UINTN Index2;
- UINTN KeyCount;
- UINT8 KeyCode;
-
- UsbKeyboardDevice = (USB_KB_DEV *) Context;
+ USB_KB_DEV *UsbKeyboardDevice;
+ EFI_HII_KEYBOARD_LAYOUT *KeyboardLayout;
+ EFI_KEY_DESCRIPTOR TempKey;
+ EFI_KEY_DESCRIPTOR *KeyDescriptor;
+ EFI_KEY_DESCRIPTOR *TableEntry;
+ EFI_KEY_DESCRIPTOR *NsKey;
+ USB_NS_KEY *UsbNsKey;
+ UINTN Index;
+ UINTN Index2;
+ UINTN KeyCount;
+ UINT8 KeyCode;
+
+ UsbKeyboardDevice = (USB_KB_DEV *)Context;
if (UsbKeyboardDevice->Signature != USB_KB_DEV_SIGNATURE) {
return;
}
@@ -611,13 +611,13 @@ SetKeyboardLayoutEvent (
// Re-allocate resource for KeyConvertionTable
//
ReleaseKeyboardLayoutResources (UsbKeyboardDevice);
- UsbKeyboardDevice->KeyConvertionTable = AllocateZeroPool ((NUMBER_OF_VALID_USB_KEYCODE) * sizeof (EFI_KEY_DESCRIPTOR));
+ UsbKeyboardDevice->KeyConvertionTable = AllocateZeroPool ((NUMBER_OF_VALID_USB_KEYCODE)*sizeof (EFI_KEY_DESCRIPTOR));
ASSERT (UsbKeyboardDevice->KeyConvertionTable != NULL);
//
// Traverse the list of key descriptors following the header of EFI_HII_KEYBOARD_LAYOUT
//
- KeyDescriptor = (EFI_KEY_DESCRIPTOR *) (((UINT8 *) KeyboardLayout) + sizeof (EFI_HII_KEYBOARD_LAYOUT));
+ KeyDescriptor = (EFI_KEY_DESCRIPTOR *)(((UINT8 *)KeyboardLayout) + sizeof (EFI_HII_KEYBOARD_LAYOUT));
for (Index = 0; Index < KeyboardLayout->DescriptorCount; Index++) {
//
// Copy from HII keyboard layout package binary for alignment
@@ -627,13 +627,14 @@ SetKeyboardLayoutEvent (
//
// Fill the key into KeyConvertionTable, whose index is calculated from USB keycode.
//
- KeyCode = EfiKeyToUsbKeyCodeConvertionTable [(UINT8) (TempKey.Key)];
+ KeyCode = EfiKeyToUsbKeyCodeConvertionTable[(UINT8)(TempKey.Key)];
TableEntry = GetKeyDescriptor (UsbKeyboardDevice, KeyCode);
if (TableEntry == NULL) {
ReleaseKeyboardLayoutResources (UsbKeyboardDevice);
FreePool (KeyboardLayout);
return;
}
+
CopyMem (TableEntry, KeyDescriptor, sizeof (EFI_KEY_DESCRIPTOR));
//
@@ -647,29 +648,30 @@ SetKeyboardLayoutEvent (
// Search for sequential children physical key definitions
//
KeyCount = 0;
- NsKey = KeyDescriptor + 1;
- for (Index2 = (UINT8) Index + 1; Index2 < KeyboardLayout->DescriptorCount; Index2++) {
+ NsKey = KeyDescriptor + 1;
+ for (Index2 = (UINT8)Index + 1; Index2 < KeyboardLayout->DescriptorCount; Index2++) {
CopyMem (&TempKey, NsKey, sizeof (EFI_KEY_DESCRIPTOR));
if (TempKey.Modifier == EFI_NS_KEY_DEPENDENCY_MODIFIER) {
KeyCount++;
} else {
break;
}
+
NsKey++;
}
UsbNsKey->Signature = USB_NS_KEY_SIGNATURE;
- UsbNsKey->KeyCount = KeyCount;
- UsbNsKey->NsKey = AllocateCopyPool (
- (KeyCount + 1) * sizeof (EFI_KEY_DESCRIPTOR),
- KeyDescriptor
- );
+ UsbNsKey->KeyCount = KeyCount;
+ UsbNsKey->NsKey = AllocateCopyPool (
+ (KeyCount + 1) * sizeof (EFI_KEY_DESCRIPTOR),
+ KeyDescriptor
+ );
InsertTailList (&UsbKeyboardDevice->NsKeyList, &UsbNsKey->Link);
//
// Skip over the child physical keys
//
- Index += KeyCount;
+ Index += KeyCount;
KeyDescriptor += KeyCount;
}
@@ -679,7 +681,7 @@ SetKeyboardLayoutEvent (
//
// There are two EfiKeyEnter, duplicate its key descriptor
//
- TableEntry = GetKeyDescriptor (UsbKeyboardDevice, 0x58);
+ TableEntry = GetKeyDescriptor (UsbKeyboardDevice, 0x58);
KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, 0x28);
CopyMem (TableEntry, KeyDescriptor, sizeof (EFI_KEY_DESCRIPTOR));
@@ -694,19 +696,20 @@ SetKeyboardLayoutEvent (
**/
VOID
ReleaseKeyboardLayoutResources (
- IN OUT USB_KB_DEV *UsbKeyboardDevice
+ IN OUT USB_KB_DEV *UsbKeyboardDevice
)
{
- USB_NS_KEY *UsbNsKey;
- LIST_ENTRY *Link;
+ USB_NS_KEY *UsbNsKey;
+ LIST_ENTRY *Link;
if (UsbKeyboardDevice->KeyConvertionTable != NULL) {
FreePool (UsbKeyboardDevice->KeyConvertionTable);
}
+
UsbKeyboardDevice->KeyConvertionTable = NULL;
while (!IsListEmpty (&UsbKeyboardDevice->NsKeyList)) {
- Link = GetFirstNode (&UsbKeyboardDevice->NsKeyList);
+ Link = GetFirstNode (&UsbKeyboardDevice->NsKeyList);
UsbNsKey = USB_NS_KEY_FORM_FROM_LINK (Link);
RemoveEntryList (&UsbNsKey->Link);
@@ -732,17 +735,17 @@ ReleaseKeyboardLayoutResources (
**/
EFI_STATUS
InitKeyboardLayout (
- OUT USB_KB_DEV *UsbKeyboardDevice
+ OUT USB_KB_DEV *UsbKeyboardDevice
)
{
- EFI_HII_KEYBOARD_LAYOUT *KeyboardLayout;
- EFI_STATUS Status;
+ EFI_HII_KEYBOARD_LAYOUT *KeyboardLayout;
+ EFI_STATUS Status;
- UsbKeyboardDevice->KeyConvertionTable = AllocateZeroPool ((NUMBER_OF_VALID_USB_KEYCODE) * sizeof (EFI_KEY_DESCRIPTOR));
+ UsbKeyboardDevice->KeyConvertionTable = AllocateZeroPool ((NUMBER_OF_VALID_USB_KEYCODE)*sizeof (EFI_KEY_DESCRIPTOR));
ASSERT (UsbKeyboardDevice->KeyConvertionTable != NULL);
InitializeListHead (&UsbKeyboardDevice->NsKeyList);
- UsbKeyboardDevice->CurrentNsKey = NULL;
+ UsbKeyboardDevice->CurrentNsKey = NULL;
UsbKeyboardDevice->KeyboardLayoutEvent = NULL;
//
@@ -776,6 +779,7 @@ InitKeyboardLayout (
//
return EFI_NOT_READY;
}
+
//
// If no keyboard layout can be retrieved from HII database, and default layout
// is enabled, then load the default keyboard layout.
@@ -786,7 +790,6 @@ InitKeyboardLayout (
return EFI_SUCCESS;
}
-
/**
Initialize USB keyboard device and all private data structures.
@@ -798,13 +801,13 @@ InitKeyboardLayout (
**/
EFI_STATUS
InitUSBKeyboard (
- IN OUT USB_KB_DEV *UsbKeyboardDevice
+ IN OUT USB_KB_DEV *UsbKeyboardDevice
)
{
- UINT16 ConfigValue;
- UINT8 Protocol;
- EFI_STATUS Status;
- UINT32 TransferResult;
+ UINT16 ConfigValue;
+ UINT8 Protocol;
+ EFI_STATUS Status;
+ UINT32 TransferResult;
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
EFI_PROGRESS_CODE,
@@ -868,12 +871,12 @@ InitUSBKeyboard (
);
}
- UsbKeyboardDevice->CtrlOn = FALSE;
- UsbKeyboardDevice->AltOn = FALSE;
- UsbKeyboardDevice->ShiftOn = FALSE;
- UsbKeyboardDevice->NumLockOn = FALSE;
- UsbKeyboardDevice->CapsOn = FALSE;
- UsbKeyboardDevice->ScrollOn = FALSE;
+ UsbKeyboardDevice->CtrlOn = FALSE;
+ UsbKeyboardDevice->AltOn = FALSE;
+ UsbKeyboardDevice->ShiftOn = FALSE;
+ UsbKeyboardDevice->NumLockOn = FALSE;
+ UsbKeyboardDevice->CapsOn = FALSE;
+ UsbKeyboardDevice->ScrollOn = FALSE;
UsbKeyboardDevice->LeftCtrlOn = FALSE;
UsbKeyboardDevice->LeftAltOn = FALSE;
@@ -886,7 +889,7 @@ InitUSBKeyboard (
UsbKeyboardDevice->MenuKeyOn = FALSE;
UsbKeyboardDevice->SysReqOn = FALSE;
- UsbKeyboardDevice->AltGrOn = FALSE;
+ UsbKeyboardDevice->AltGrOn = FALSE;
UsbKeyboardDevice->CurrentNsKey = NULL;
@@ -932,7 +935,6 @@ InitUSBKeyboard (
return EFI_SUCCESS;
}
-
/**
Handler function for USB keyboard's asynchronous interrupt transfer.
@@ -954,32 +956,32 @@ InitUSBKeyboard (
EFI_STATUS
EFIAPI
KeyboardHandler (
- IN VOID *Data,
- IN UINTN DataLength,
- IN VOID *Context,
- IN UINT32 Result
+ IN VOID *Data,
+ IN UINTN DataLength,
+ IN VOID *Context,
+ IN UINT32 Result
)
{
- USB_KB_DEV *UsbKeyboardDevice;
- EFI_USB_IO_PROTOCOL *UsbIo;
- UINT8 *CurKeyCodeBuffer;
- UINT8 *OldKeyCodeBuffer;
- UINT8 CurModifierMap;
- UINT8 OldModifierMap;
- UINT8 Mask;
- UINTN Index;
- UINT8 Index2;
- BOOLEAN KeyRelease;
- BOOLEAN KeyPress;
- USB_KEY UsbKey;
- UINT8 NewRepeatKey;
- UINT32 UsbStatus;
- EFI_KEY_DESCRIPTOR *KeyDescriptor;
+ USB_KB_DEV *UsbKeyboardDevice;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ UINT8 *CurKeyCodeBuffer;
+ UINT8 *OldKeyCodeBuffer;
+ UINT8 CurModifierMap;
+ UINT8 OldModifierMap;
+ UINT8 Mask;
+ UINTN Index;
+ UINT8 Index2;
+ BOOLEAN KeyRelease;
+ BOOLEAN KeyPress;
+ USB_KEY UsbKey;
+ UINT8 NewRepeatKey;
+ UINT32 UsbStatus;
+ EFI_KEY_DESCRIPTOR *KeyDescriptor;
ASSERT (Context != NULL);
NewRepeatKey = 0;
- UsbKeyboardDevice = (USB_KB_DEV *) Context;
+ UsbKeyboardDevice = (USB_KB_DEV *)Context;
UsbIo = UsbKeyboardDevice->UsbIo;
//
@@ -1001,10 +1003,10 @@ KeyboardHandler (
UsbKeyboardDevice->RepeatKey = 0;
gBS->SetTimer (
- UsbKeyboardDevice->RepeatTimer,
- TimerCancel,
- USBKBD_REPEAT_RATE
- );
+ UsbKeyboardDevice->RepeatTimer,
+ TimerCancel,
+ USBKBD_REPEAT_RATE
+ );
if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {
UsbClearEndpointHalt (
@@ -1042,7 +1044,7 @@ KeyboardHandler (
//
// If no error and no data, just return EFI_SUCCESS.
//
- if (DataLength == 0 || Data == NULL) {
+ if ((DataLength == 0) || (Data == NULL)) {
return EFI_SUCCESS;
}
@@ -1057,8 +1059,8 @@ KeyboardHandler (
return EFI_DEVICE_ERROR;
}
- CurKeyCodeBuffer = (UINT8 *) Data;
- OldKeyCodeBuffer = UsbKeyboardDevice->LastKeyCodeArray;
+ CurKeyCodeBuffer = (UINT8 *)Data;
+ OldKeyCodeBuffer = UsbKeyboardDevice->LastKeyCodeArray;
//
// Checks for new key stroke.
@@ -1079,8 +1081,8 @@ KeyboardHandler (
//
// Parse the modifier key, which is the first byte of keyboard input report.
//
- CurModifierMap = CurKeyCodeBuffer[0];
- OldModifierMap = OldKeyCodeBuffer[0];
+ CurModifierMap = CurKeyCodeBuffer[0];
+ OldModifierMap = OldKeyCodeBuffer[0];
//
// Handle modifier key's pressing or releasing situation.
@@ -1095,15 +1097,15 @@ KeyboardHandler (
// Bit7: Right GUI, Keycode: 0xe7
//
for (Index = 0; Index < 8; Index++) {
- Mask = (UINT8) (1 << Index);
+ Mask = (UINT8)(1 << Index);
if ((CurModifierMap & Mask) != (OldModifierMap & Mask)) {
//
// If current modifier key is up, then CurModifierMap & Mask = 0;
// otherwise it is a non-zero value.
// Insert the changed modifier key into key buffer.
//
- UsbKey.KeyCode = (UINT8) (0xe0 + Index);
- UsbKey.Down = (BOOLEAN) ((CurModifierMap & Mask) != 0);
+ UsbKey.KeyCode = (UINT8)(0xe0 + Index);
+ UsbKey.Down = (BOOLEAN)((CurModifierMap & Mask) != 0);
Enqueue (&UsbKeyboardDevice->UsbKeyQueue, &UsbKey, sizeof (UsbKey));
}
}
@@ -1114,17 +1116,16 @@ KeyboardHandler (
//
KeyRelease = FALSE;
for (Index = 2; Index < 8; Index++) {
-
if (!USBKBD_VALID_KEYCODE (OldKeyCodeBuffer[Index])) {
continue;
}
+
//
// For any key in old keycode buffer, if it is not in current keycode buffer,
// then it is released. Otherwise, it is not released.
//
KeyRelease = TRUE;
for (Index2 = 2; Index2 < 8; Index2++) {
-
if (!USBKBD_VALID_KEYCODE (CurKeyCodeBuffer[Index2])) {
continue;
}
@@ -1164,17 +1165,16 @@ KeyboardHandler (
//
KeyPress = FALSE;
for (Index = 2; Index < 8; Index++) {
-
if (!USBKBD_VALID_KEYCODE (CurKeyCodeBuffer[Index])) {
continue;
}
+
//
// For any key in current keycode buffer, if it is not in old keycode buffer,
// then it is pressed. Otherwise, it is not pressed.
//
KeyPress = TRUE;
for (Index2 = 2; Index2 < 8; Index2++) {
-
if (!USBKBD_VALID_KEYCODE (OldKeyCodeBuffer[Index2])) {
continue;
}
@@ -1198,7 +1198,7 @@ KeyboardHandler (
continue;
}
- if (KeyDescriptor->Modifier == EFI_NUM_LOCK_MODIFIER || KeyDescriptor->Modifier == EFI_CAPS_LOCK_MODIFIER) {
+ if ((KeyDescriptor->Modifier == EFI_NUM_LOCK_MODIFIER) || (KeyDescriptor->Modifier == EFI_CAPS_LOCK_MODIFIER)) {
//
// For NumLock or CapsLock pressed, there is no need to handle repeat key for them.
//
@@ -1207,7 +1207,7 @@ KeyboardHandler (
//
// Prepare new repeat key, and clear the original one.
//
- NewRepeatKey = CurKeyCodeBuffer[Index];
+ NewRepeatKey = CurKeyCodeBuffer[Index];
UsbKeyboardDevice->RepeatKey = 0;
}
}
@@ -1241,7 +1241,6 @@ KeyboardHandler (
return EFI_SUCCESS;
}
-
/**
Retrieves a USB keycode after parsing the raw data in keyboard buffer.
@@ -1258,7 +1257,7 @@ KeyboardHandler (
EFI_STATUS
USBParseKey (
IN OUT USB_KB_DEV *UsbKeyboardDevice,
- OUT UINT8 *KeyCode
+ OUT UINT8 *KeyCode
)
{
USB_KEY UsbKey;
@@ -1276,194 +1275,193 @@ USBParseKey (
if (KeyDescriptor == NULL) {
continue;
}
+
if (!UsbKey.Down) {
//
// Key is released.
//
switch (KeyDescriptor->Modifier) {
+ //
+ // Ctrl release
+ //
+ case EFI_LEFT_CONTROL_MODIFIER:
+ UsbKeyboardDevice->LeftCtrlOn = FALSE;
+ UsbKeyboardDevice->CtrlOn = FALSE;
+ break;
+ case EFI_RIGHT_CONTROL_MODIFIER:
+ UsbKeyboardDevice->RightCtrlOn = FALSE;
+ UsbKeyboardDevice->CtrlOn = FALSE;
+ break;
+
+ //
+ // Shift release
+ //
+ case EFI_LEFT_SHIFT_MODIFIER:
+ UsbKeyboardDevice->LeftShiftOn = FALSE;
+ UsbKeyboardDevice->ShiftOn = FALSE;
+ break;
+ case EFI_RIGHT_SHIFT_MODIFIER:
+ UsbKeyboardDevice->RightShiftOn = FALSE;
+ UsbKeyboardDevice->ShiftOn = FALSE;
+ break;
+
+ //
+ // Alt release
+ //
+ case EFI_LEFT_ALT_MODIFIER:
+ UsbKeyboardDevice->LeftAltOn = FALSE;
+ UsbKeyboardDevice->AltOn = FALSE;
+ break;
+ case EFI_RIGHT_ALT_MODIFIER:
+ UsbKeyboardDevice->RightAltOn = FALSE;
+ UsbKeyboardDevice->AltOn = FALSE;
+ break;
+ //
+ // Left Logo release
+ //
+ case EFI_LEFT_LOGO_MODIFIER:
+ UsbKeyboardDevice->LeftLogoOn = FALSE;
+ break;
+
+ //
+ // Right Logo release
+ //
+ case EFI_RIGHT_LOGO_MODIFIER:
+ UsbKeyboardDevice->RightLogoOn = FALSE;
+ break;
+
+ //
+ // Menu key release
+ //
+ case EFI_MENU_MODIFIER:
+ UsbKeyboardDevice->MenuKeyOn = FALSE;
+ break;
+
+ //
+ // SysReq release
+ //
+ case EFI_PRINT_MODIFIER:
+ case EFI_SYS_REQUEST_MODIFIER:
+ UsbKeyboardDevice->SysReqOn = FALSE;
+ break;
+
+ //
+ // AltGr release
+ //
+ case EFI_ALT_GR_MODIFIER:
+ UsbKeyboardDevice->AltGrOn = FALSE;
+ break;
+
+ default:
+ break;
+ }
+
+ continue;
+ }
+
+ //
+ // Analyzes key pressing situation
+ //
+ switch (KeyDescriptor->Modifier) {
//
- // Ctrl release
+ // Ctrl press
//
case EFI_LEFT_CONTROL_MODIFIER:
- UsbKeyboardDevice->LeftCtrlOn = FALSE;
- UsbKeyboardDevice->CtrlOn = FALSE;
+ UsbKeyboardDevice->LeftCtrlOn = TRUE;
+ UsbKeyboardDevice->CtrlOn = TRUE;
break;
case EFI_RIGHT_CONTROL_MODIFIER:
- UsbKeyboardDevice->RightCtrlOn = FALSE;
- UsbKeyboardDevice->CtrlOn = FALSE;
+ UsbKeyboardDevice->RightCtrlOn = TRUE;
+ UsbKeyboardDevice->CtrlOn = TRUE;
break;
//
- // Shift release
+ // Shift press
//
case EFI_LEFT_SHIFT_MODIFIER:
- UsbKeyboardDevice->LeftShiftOn = FALSE;
- UsbKeyboardDevice->ShiftOn = FALSE;
+ UsbKeyboardDevice->LeftShiftOn = TRUE;
+ UsbKeyboardDevice->ShiftOn = TRUE;
break;
case EFI_RIGHT_SHIFT_MODIFIER:
- UsbKeyboardDevice->RightShiftOn = FALSE;
- UsbKeyboardDevice->ShiftOn = FALSE;
+ UsbKeyboardDevice->RightShiftOn = TRUE;
+ UsbKeyboardDevice->ShiftOn = TRUE;
break;
//
- // Alt release
+ // Alt press
//
case EFI_LEFT_ALT_MODIFIER:
- UsbKeyboardDevice->LeftAltOn = FALSE;
- UsbKeyboardDevice->AltOn = FALSE;
+ UsbKeyboardDevice->LeftAltOn = TRUE;
+ UsbKeyboardDevice->AltOn = TRUE;
break;
case EFI_RIGHT_ALT_MODIFIER:
- UsbKeyboardDevice->RightAltOn = FALSE;
- UsbKeyboardDevice->AltOn = FALSE;
+ UsbKeyboardDevice->RightAltOn = TRUE;
+ UsbKeyboardDevice->AltOn = TRUE;
break;
//
- // Left Logo release
+ // Left Logo press
//
case EFI_LEFT_LOGO_MODIFIER:
- UsbKeyboardDevice->LeftLogoOn = FALSE;
+ UsbKeyboardDevice->LeftLogoOn = TRUE;
break;
//
- // Right Logo release
+ // Right Logo press
//
case EFI_RIGHT_LOGO_MODIFIER:
- UsbKeyboardDevice->RightLogoOn = FALSE;
+ UsbKeyboardDevice->RightLogoOn = TRUE;
break;
//
- // Menu key release
+ // Menu key press
//
case EFI_MENU_MODIFIER:
- UsbKeyboardDevice->MenuKeyOn = FALSE;
+ UsbKeyboardDevice->MenuKeyOn = TRUE;
break;
//
- // SysReq release
+ // SysReq press
//
case EFI_PRINT_MODIFIER:
case EFI_SYS_REQUEST_MODIFIER:
- UsbKeyboardDevice->SysReqOn = FALSE;
+ UsbKeyboardDevice->SysReqOn = TRUE;
break;
//
- // AltGr release
+ // AltGr press
//
case EFI_ALT_GR_MODIFIER:
- UsbKeyboardDevice->AltGrOn = FALSE;
+ UsbKeyboardDevice->AltGrOn = TRUE;
break;
- default:
+ case EFI_NUM_LOCK_MODIFIER:
+ //
+ // Toggle NumLock
+ //
+ UsbKeyboardDevice->NumLockOn = (BOOLEAN)(!(UsbKeyboardDevice->NumLockOn));
+ SetKeyLED (UsbKeyboardDevice);
break;
- }
-
- continue;
- }
-
- //
- // Analyzes key pressing situation
- //
- switch (KeyDescriptor->Modifier) {
-
- //
- // Ctrl press
- //
- case EFI_LEFT_CONTROL_MODIFIER:
- UsbKeyboardDevice->LeftCtrlOn = TRUE;
- UsbKeyboardDevice->CtrlOn = TRUE;
- break;
- case EFI_RIGHT_CONTROL_MODIFIER:
- UsbKeyboardDevice->RightCtrlOn = TRUE;
- UsbKeyboardDevice->CtrlOn = TRUE;
- break;
-
- //
- // Shift press
- //
- case EFI_LEFT_SHIFT_MODIFIER:
- UsbKeyboardDevice->LeftShiftOn = TRUE;
- UsbKeyboardDevice->ShiftOn = TRUE;
- break;
- case EFI_RIGHT_SHIFT_MODIFIER:
- UsbKeyboardDevice->RightShiftOn = TRUE;
- UsbKeyboardDevice->ShiftOn = TRUE;
- break;
-
- //
- // Alt press
- //
- case EFI_LEFT_ALT_MODIFIER:
- UsbKeyboardDevice->LeftAltOn = TRUE;
- UsbKeyboardDevice->AltOn = TRUE;
- break;
- case EFI_RIGHT_ALT_MODIFIER:
- UsbKeyboardDevice->RightAltOn = TRUE;
- UsbKeyboardDevice->AltOn = TRUE;
- break;
-
- //
- // Left Logo press
- //
- case EFI_LEFT_LOGO_MODIFIER:
- UsbKeyboardDevice->LeftLogoOn = TRUE;
- break;
-
- //
- // Right Logo press
- //
- case EFI_RIGHT_LOGO_MODIFIER:
- UsbKeyboardDevice->RightLogoOn = TRUE;
- break;
-
- //
- // Menu key press
- //
- case EFI_MENU_MODIFIER:
- UsbKeyboardDevice->MenuKeyOn = TRUE;
- break;
-
- //
- // SysReq press
- //
- case EFI_PRINT_MODIFIER:
- case EFI_SYS_REQUEST_MODIFIER:
- UsbKeyboardDevice->SysReqOn = TRUE;
- break;
-
- //
- // AltGr press
- //
- case EFI_ALT_GR_MODIFIER:
- UsbKeyboardDevice->AltGrOn = TRUE;
- break;
- case EFI_NUM_LOCK_MODIFIER:
- //
- // Toggle NumLock
- //
- UsbKeyboardDevice->NumLockOn = (BOOLEAN) (!(UsbKeyboardDevice->NumLockOn));
- SetKeyLED (UsbKeyboardDevice);
- break;
-
- case EFI_CAPS_LOCK_MODIFIER:
- //
- // Toggle CapsLock
- //
- UsbKeyboardDevice->CapsOn = (BOOLEAN) (!(UsbKeyboardDevice->CapsOn));
- SetKeyLED (UsbKeyboardDevice);
- break;
+ case EFI_CAPS_LOCK_MODIFIER:
+ //
+ // Toggle CapsLock
+ //
+ UsbKeyboardDevice->CapsOn = (BOOLEAN)(!(UsbKeyboardDevice->CapsOn));
+ SetKeyLED (UsbKeyboardDevice);
+ break;
- case EFI_SCROLL_LOCK_MODIFIER:
- //
- // Toggle ScrollLock
- //
- UsbKeyboardDevice->ScrollOn = (BOOLEAN) (!(UsbKeyboardDevice->ScrollOn));
- SetKeyLED (UsbKeyboardDevice);
- break;
+ case EFI_SCROLL_LOCK_MODIFIER:
+ //
+ // Toggle ScrollLock
+ //
+ UsbKeyboardDevice->ScrollOn = (BOOLEAN)(!(UsbKeyboardDevice->ScrollOn));
+ SetKeyLED (UsbKeyboardDevice);
+ break;
- default:
- break;
+ default:
+ break;
}
//
@@ -1490,8 +1488,8 @@ USBParseKey (
**/
VOID
InitializeKeyState (
- IN USB_KB_DEV *UsbKeyboardDevice,
- OUT EFI_KEY_STATE *KeyState
+ IN USB_KB_DEV *UsbKeyboardDevice,
+ OUT EFI_KEY_STATE *KeyState
)
{
KeyState->KeyShiftState = EFI_SHIFT_STATE_VALID;
@@ -1500,30 +1498,39 @@ InitializeKeyState (
if (UsbKeyboardDevice->LeftCtrlOn) {
KeyState->KeyShiftState |= EFI_LEFT_CONTROL_PRESSED;
}
+
if (UsbKeyboardDevice->RightCtrlOn) {
KeyState->KeyShiftState |= EFI_RIGHT_CONTROL_PRESSED;
}
+
if (UsbKeyboardDevice->LeftAltOn) {
KeyState->KeyShiftState |= EFI_LEFT_ALT_PRESSED;
}
+
if (UsbKeyboardDevice->RightAltOn) {
KeyState->KeyShiftState |= EFI_RIGHT_ALT_PRESSED;
}
+
if (UsbKeyboardDevice->LeftShiftOn) {
KeyState->KeyShiftState |= EFI_LEFT_SHIFT_PRESSED;
}
+
if (UsbKeyboardDevice->RightShiftOn) {
KeyState->KeyShiftState |= EFI_RIGHT_SHIFT_PRESSED;
}
+
if (UsbKeyboardDevice->LeftLogoOn) {
KeyState->KeyShiftState |= EFI_LEFT_LOGO_PRESSED;
}
+
if (UsbKeyboardDevice->RightLogoOn) {
KeyState->KeyShiftState |= EFI_RIGHT_LOGO_PRESSED;
}
+
if (UsbKeyboardDevice->MenuKeyOn) {
KeyState->KeyShiftState |= EFI_MENU_KEY_PRESSED;
}
+
if (UsbKeyboardDevice->SysReqOn) {
KeyState->KeyShiftState |= EFI_SYS_REQ_PRESSED;
}
@@ -1531,12 +1538,15 @@ InitializeKeyState (
if (UsbKeyboardDevice->ScrollOn) {
KeyState->KeyToggleState |= EFI_SCROLL_LOCK_ACTIVE;
}
+
if (UsbKeyboardDevice->NumLockOn) {
KeyState->KeyToggleState |= EFI_NUM_LOCK_ACTIVE;
}
+
if (UsbKeyboardDevice->CapsOn) {
KeyState->KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;
}
+
if (UsbKeyboardDevice->IsSupportPartialKey) {
KeyState->KeyToggleState |= EFI_KEY_STATE_EXPOSED;
}
@@ -1560,15 +1570,15 @@ InitializeKeyState (
**/
EFI_STATUS
UsbKeyCodeToEfiInputKey (
- IN USB_KB_DEV *UsbKeyboardDevice,
- IN UINT8 KeyCode,
- OUT EFI_KEY_DATA *KeyData
+ IN USB_KB_DEV *UsbKeyboardDevice,
+ IN UINT8 KeyCode,
+ OUT EFI_KEY_DATA *KeyData
)
{
- EFI_KEY_DESCRIPTOR *KeyDescriptor;
- LIST_ENTRY *Link;
- LIST_ENTRY *NotifyList;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ EFI_KEY_DESCRIPTOR *KeyDescriptor;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *NotifyList;
+ KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
//
// KeyCode must in the range of [0x4, 0x65] or [0xe0, 0xe7].
@@ -1591,7 +1601,7 @@ UsbKeyCodeToEfiInputKey (
// If this keystroke follows a non-spacing key, then find the descriptor for corresponding
// physical key.
//
- KeyDescriptor = FindPhysicalKey (UsbKeyboardDevice->CurrentNsKey, KeyDescriptor);
+ KeyDescriptor = FindPhysicalKey (UsbKeyboardDevice->CurrentNsKey, KeyDescriptor);
UsbKeyboardDevice->CurrentNsKey = NULL;
}
@@ -1605,7 +1615,7 @@ UsbKeyCodeToEfiInputKey (
KeyData->Key.ScanCode = ModifierValueToEfiScanCodeConvertionTable[KeyDescriptor->Modifier];
KeyData->Key.UnicodeChar = KeyDescriptor->Unicode;
- if ((KeyDescriptor->AffectedAttribute & EFI_AFFECTED_BY_STANDARD_SHIFT)!= 0) {
+ if ((KeyDescriptor->AffectedAttribute & EFI_AFFECTED_BY_STANDARD_SHIFT) != 0) {
if (UsbKeyboardDevice->ShiftOn) {
KeyData->Key.UnicodeChar = KeyDescriptor->ShiftedUnicode;
@@ -1614,8 +1624,9 @@ UsbKeyCodeToEfiInputKey (
// are normally adjusted by shift modifiers. e.g. Shift Key + 'f' key = 'F'
//
if ((KeyDescriptor->Unicode != CHAR_NULL) && (KeyDescriptor->ShiftedUnicode != CHAR_NULL) &&
- (KeyDescriptor->Unicode != KeyDescriptor->ShiftedUnicode)) {
- UsbKeyboardDevice->LeftShiftOn = FALSE;
+ (KeyDescriptor->Unicode != KeyDescriptor->ShiftedUnicode))
+ {
+ UsbKeyboardDevice->LeftShiftOn = FALSE;
UsbKeyboardDevice->RightShiftOn = FALSE;
}
@@ -1660,17 +1671,17 @@ UsbKeyCodeToEfiInputKey (
//
// Translate Unicode 0x1B (ESC) to EFI Scan Code
//
- if (KeyData->Key.UnicodeChar == 0x1B && KeyData->Key.ScanCode == SCAN_NULL) {
- KeyData->Key.ScanCode = SCAN_ESC;
+ if ((KeyData->Key.UnicodeChar == 0x1B) && (KeyData->Key.ScanCode == SCAN_NULL)) {
+ KeyData->Key.ScanCode = SCAN_ESC;
KeyData->Key.UnicodeChar = CHAR_NULL;
}
//
// Not valid for key without both unicode key code and EFI Scan Code.
//
- if (KeyData->Key.UnicodeChar == 0 && KeyData->Key.ScanCode == SCAN_NULL) {
+ if ((KeyData->Key.UnicodeChar == 0) && (KeyData->Key.ScanCode == SCAN_NULL)) {
if (!UsbKeyboardDevice->IsSupportPartialKey) {
- return EFI_NOT_READY;
+ return EFI_NOT_READY;
}
}
@@ -1709,15 +1720,15 @@ UsbKeyCodeToEfiInputKey (
**/
VOID
InitQueue (
- IN OUT USB_SIMPLE_QUEUE *Queue,
- IN UINTN ItemSize
+ IN OUT USB_SIMPLE_QUEUE *Queue,
+ IN UINTN ItemSize
)
{
- UINTN Index;
+ UINTN Index;
- Queue->ItemSize = ItemSize;
- Queue->Head = 0;
- Queue->Tail = 0;
+ Queue->ItemSize = ItemSize;
+ Queue->Head = 0;
+ Queue->Tail = 0;
if (Queue->Buffer[0] != NULL) {
FreePool (Queue->Buffer[0]);
@@ -1727,7 +1738,7 @@ InitQueue (
ASSERT (Queue->Buffer[0] != NULL);
for (Index = 1; Index < sizeof (Queue->Buffer) / sizeof (Queue->Buffer[0]); Index++) {
- Queue->Buffer[Index] = ((UINT8 *) Queue->Buffer[Index - 1]) + ItemSize;
+ Queue->Buffer[Index] = ((UINT8 *)Queue->Buffer[Index - 1]) + ItemSize;
}
}
@@ -1738,13 +1749,12 @@ InitQueue (
**/
VOID
DestroyQueue (
- IN OUT USB_SIMPLE_QUEUE *Queue
+ IN OUT USB_SIMPLE_QUEUE *Queue
)
{
FreePool (Queue->Buffer[0]);
}
-
/**
Check whether the queue is empty.
@@ -1756,16 +1766,15 @@ DestroyQueue (
**/
BOOLEAN
IsQueueEmpty (
- IN USB_SIMPLE_QUEUE *Queue
+ IN USB_SIMPLE_QUEUE *Queue
)
{
//
// Meet FIFO empty condition
//
- return (BOOLEAN) (Queue->Head == Queue->Tail);
+ return (BOOLEAN)(Queue->Head == Queue->Tail);
}
-
/**
Check whether the queue is full.
@@ -1777,13 +1786,12 @@ IsQueueEmpty (
**/
BOOLEAN
IsQueueFull (
- IN USB_SIMPLE_QUEUE *Queue
+ IN USB_SIMPLE_QUEUE *Queue
)
{
- return (BOOLEAN) (((Queue->Tail + 1) % (MAX_KEY_ALLOWED + 1)) == Queue->Head);
+ return (BOOLEAN)(((Queue->Tail + 1) % (MAX_KEY_ALLOWED + 1)) == Queue->Head);
}
-
/**
Enqueue the item to the queue.
@@ -1793,9 +1801,9 @@ IsQueueFull (
**/
VOID
Enqueue (
- IN OUT USB_SIMPLE_QUEUE *Queue,
- IN VOID *Item,
- IN UINTN ItemSize
+ IN OUT USB_SIMPLE_QUEUE *Queue,
+ IN VOID *Item,
+ IN UINTN ItemSize
)
{
ASSERT (ItemSize == Queue->ItemSize);
@@ -1815,7 +1823,6 @@ Enqueue (
Queue->Tail = (Queue->Tail + 1) % (MAX_KEY_ALLOWED + 1);
}
-
/**
Dequeue a item from the queue.
@@ -1829,9 +1836,9 @@ Enqueue (
**/
EFI_STATUS
Dequeue (
- IN OUT USB_SIMPLE_QUEUE *Queue,
- OUT VOID *Item,
- IN UINTN ItemSize
+ IN OUT USB_SIMPLE_QUEUE *Queue,
+ OUT VOID *Item,
+ IN UINTN ItemSize
)
{
ASSERT (Queue->ItemSize == ItemSize);
@@ -1850,7 +1857,6 @@ Dequeue (
return EFI_SUCCESS;
}
-
/**
Sets USB keyboard LED state.
@@ -1859,21 +1865,21 @@ Dequeue (
**/
VOID
SetKeyLED (
- IN USB_KB_DEV *UsbKeyboardDevice
+ IN USB_KB_DEV *UsbKeyboardDevice
)
{
- LED_MAP Led;
- UINT8 ReportId;
+ LED_MAP Led;
+ UINT8 ReportId;
//
// Set each field in Led map.
//
- Led.NumLock = (UINT8) ((UsbKeyboardDevice->NumLockOn) ? 1 : 0);
- Led.CapsLock = (UINT8) ((UsbKeyboardDevice->CapsOn) ? 1 : 0);
- Led.ScrollLock = (UINT8) ((UsbKeyboardDevice->ScrollOn) ? 1 : 0);
+ Led.NumLock = (UINT8)((UsbKeyboardDevice->NumLockOn) ? 1 : 0);
+ Led.CapsLock = (UINT8)((UsbKeyboardDevice->CapsOn) ? 1 : 0);
+ Led.ScrollLock = (UINT8)((UsbKeyboardDevice->ScrollOn) ? 1 : 0);
Led.Resrvd = 0;
- ReportId = 0;
+ ReportId = 0;
//
// Call Set_Report Request to lighten the LED.
//
@@ -1883,11 +1889,10 @@ SetKeyLED (
ReportId,
HID_OUTPUT_REPORT,
1,
- (UINT8 *) &Led
+ (UINT8 *)&Led
);
}
-
/**
Handler for Repeat Key event.
@@ -1904,14 +1909,14 @@ SetKeyLED (
VOID
EFIAPI
USBKeyboardRepeatHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
USB_KB_DEV *UsbKeyboardDevice;
USB_KEY UsbKey;
- UsbKeyboardDevice = (USB_KB_DEV *) Context;
+ UsbKeyboardDevice = (USB_KB_DEV *)Context;
//
// Do nothing when there is no repeat key.
@@ -1935,7 +1940,6 @@ USBKeyboardRepeatHandler (
}
}
-
/**
Handler for Delayed Recovery event.
@@ -1952,20 +1956,19 @@ USBKeyboardRepeatHandler (
VOID
EFIAPI
USBKeyboardRecoveryHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
+ USB_KB_DEV *UsbKeyboardDevice;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ UINT8 PacketSize;
- USB_KB_DEV *UsbKeyboardDevice;
- EFI_USB_IO_PROTOCOL *UsbIo;
- UINT8 PacketSize;
+ UsbKeyboardDevice = (USB_KB_DEV *)Context;
- UsbKeyboardDevice = (USB_KB_DEV *) Context;
-
- UsbIo = UsbKeyboardDevice->UsbIo;
+ UsbIo = UsbKeyboardDevice->UsbIo;
- PacketSize = (UINT8) (UsbKeyboardDevice->IntEndpointDescriptor.MaxPacketSize);
+ PacketSize = (UINT8)(UsbKeyboardDevice->IntEndpointDescriptor.MaxPacketSize);
//
// Re-submit Asynchronous Interrupt Transfer for recovery.
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h
index 811f136..0518944 100644
--- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h
+++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h
@@ -9,10 +9,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _EFI_KEYBOARD_H_
#define _EFI_KEYBOARD_H_
-
#include "EfiKey.h"
-#define USB_KEYBOARD_KEY_COUNT 105
+#define USB_KEYBOARD_KEY_COUNT 105
#define USB_KEYBOARD_LANGUAGE_STR_LEN 5 // RFC4646 Language Code: "en-US"
#define USB_KEYBOARD_DESCRIPTION_STR_LEN (16 + 1) // Description: "English Keyboard"
@@ -22,28 +21,29 @@ typedef struct {
//
// This 4-bytes total array length is required by PreparePackageList()
//
- UINT32 Length;
+ UINT32 Length;
//
// Keyboard Layout package definition
//
- EFI_HII_PACKAGE_HEADER PackageHeader;
- UINT16 LayoutCount;
+ EFI_HII_PACKAGE_HEADER PackageHeader;
+ UINT16 LayoutCount;
//
// EFI_HII_KEYBOARD_LAYOUT
//
- UINT16 LayoutLength;
- EFI_GUID Guid;
- UINT32 LayoutDescriptorStringOffset;
- UINT8 DescriptorCount;
- EFI_KEY_DESCRIPTOR KeyDescriptor[USB_KEYBOARD_KEY_COUNT];
- UINT16 DescriptionCount;
- CHAR16 Language[USB_KEYBOARD_LANGUAGE_STR_LEN];
- CHAR16 Space;
- CHAR16 DescriptionString[USB_KEYBOARD_DESCRIPTION_STR_LEN];
+ UINT16 LayoutLength;
+ EFI_GUID Guid;
+ UINT32 LayoutDescriptorStringOffset;
+ UINT8 DescriptorCount;
+ EFI_KEY_DESCRIPTOR KeyDescriptor[USB_KEYBOARD_KEY_COUNT];
+ UINT16 DescriptionCount;
+ CHAR16 Language[USB_KEYBOARD_LANGUAGE_STR_LEN];
+ CHAR16 Space;
+ CHAR16 DescriptionString[USB_KEYBOARD_DESCRIPTION_STR_LEN];
} USB_KEYBOARD_LAYOUT_PACK_BIN;
#pragma pack()
+
/**
Uses USB I/O to check whether the device is a USB keyboard device.
@@ -55,7 +55,7 @@ typedef struct {
**/
BOOLEAN
IsUSBKeyboard (
- IN EFI_USB_IO_PROTOCOL *UsbIo
+ IN EFI_USB_IO_PROTOCOL *UsbIo
);
/**
@@ -69,7 +69,7 @@ IsUSBKeyboard (
**/
EFI_STATUS
InitUSBKeyboard (
- IN OUT USB_KB_DEV *UsbKeyboardDevice
+ IN OUT USB_KB_DEV *UsbKeyboardDevice
);
/**
@@ -89,7 +89,7 @@ InitUSBKeyboard (
**/
EFI_STATUS
InitKeyboardLayout (
- OUT USB_KB_DEV *UsbKeyboardDevice
+ OUT USB_KB_DEV *UsbKeyboardDevice
);
/**
@@ -100,7 +100,7 @@ InitKeyboardLayout (
**/
VOID
ReleaseKeyboardLayoutResources (
- IN OUT USB_KB_DEV *UsbKeyboardDevice
+ IN OUT USB_KB_DEV *UsbKeyboardDevice
);
/**
@@ -124,10 +124,10 @@ ReleaseKeyboardLayoutResources (
EFI_STATUS
EFIAPI
KeyboardHandler (
- IN VOID *Data,
- IN UINTN DataLength,
- IN VOID *Context,
- IN UINT32 Result
+ IN VOID *Data,
+ IN UINTN DataLength,
+ IN VOID *Context,
+ IN UINT32 Result
);
/**
@@ -146,8 +146,8 @@ KeyboardHandler (
VOID
EFIAPI
USBKeyboardRecoveryHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -187,12 +187,11 @@ USBParseKey (
**/
EFI_STATUS
UsbKeyCodeToEfiInputKey (
- IN USB_KB_DEV *UsbKeyboardDevice,
- IN UINT8 KeyCode,
- OUT EFI_KEY_DATA *KeyData
+ IN USB_KB_DEV *UsbKeyboardDevice,
+ IN UINT8 KeyCode,
+ OUT EFI_KEY_DATA *KeyData
);
-
/**
Create the queue.
@@ -202,8 +201,8 @@ UsbKeyCodeToEfiInputKey (
**/
VOID
InitQueue (
- IN OUT USB_SIMPLE_QUEUE *Queue,
- IN UINTN ItemSize
+ IN OUT USB_SIMPLE_QUEUE *Queue,
+ IN UINTN ItemSize
);
/**
@@ -213,10 +212,9 @@ InitQueue (
**/
VOID
DestroyQueue (
- IN OUT USB_SIMPLE_QUEUE *Queue
+ IN OUT USB_SIMPLE_QUEUE *Queue
);
-
/**
Check whether the queue is empty.
@@ -228,10 +226,9 @@ DestroyQueue (
**/
BOOLEAN
IsQueueEmpty (
- IN USB_SIMPLE_QUEUE *Queue
+ IN USB_SIMPLE_QUEUE *Queue
);
-
/**
Check whether the queue is full.
@@ -243,10 +240,9 @@ IsQueueEmpty (
**/
BOOLEAN
IsQueueFull (
- IN USB_SIMPLE_QUEUE *Queue
+ IN USB_SIMPLE_QUEUE *Queue
);
-
/**
Enqueue the item to the queue.
@@ -256,12 +252,11 @@ IsQueueFull (
**/
VOID
Enqueue (
- IN OUT USB_SIMPLE_QUEUE *Queue,
- IN VOID *Item,
- IN UINTN ItemSize
+ IN OUT USB_SIMPLE_QUEUE *Queue,
+ IN VOID *Item,
+ IN UINTN ItemSize
);
-
/**
Dequeue a item from the queue.
@@ -275,9 +270,9 @@ Enqueue (
**/
EFI_STATUS
Dequeue (
- IN OUT USB_SIMPLE_QUEUE *Queue,
- OUT VOID *Item,
- IN UINTN ItemSize
+ IN OUT USB_SIMPLE_QUEUE *Queue,
+ OUT VOID *Item,
+ IN UINTN ItemSize
);
/**
@@ -296,8 +291,8 @@ Dequeue (
VOID
EFIAPI
USBKeyboardRepeatHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -308,7 +303,7 @@ USBKeyboardRepeatHandler (
**/
VOID
SetKeyLED (
- IN USB_KB_DEV *UsbKeyboardDevice
+ IN USB_KB_DEV *UsbKeyboardDevice
);
/**
@@ -319,8 +314,8 @@ SetKeyLED (
**/
VOID
InitializeKeyState (
- IN USB_KB_DEV *UsbKeyboardDevice,
- OUT EFI_KEY_STATE *KeyState
+ IN USB_KB_DEV *UsbKeyboardDevice,
+ OUT EFI_KEY_STATE *KeyState
);
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/ComponentName.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/ComponentName.c
index dff3d3a..69cf36a 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/ComponentName.c
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/ComponentName.c
@@ -20,17 +20,16 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbMassStorageCompon
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbMassStorageComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UsbMassStorageGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UsbMassStorageGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbMassStorageComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)UsbMassStorageGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)UsbMassStorageGetControllerName,
"en"
};
-
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
-mUsbMassStorageDriverNameTable[] = {
- {"eng;en", L"Usb Mass Storage Driver"},
- {NULL, NULL}
+ mUsbMassStorageDriverNameTable[] = {
+ { "eng;en", L"Usb Mass Storage Driver" },
+ { NULL, NULL }
};
/**
@@ -145,11 +144,11 @@ UsbMassStorageGetDriverName (
EFI_STATUS
EFIAPI
UsbMassStorageGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMass.h b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMass.h
index fccb203..2ac9803 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMass.h
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMass.h
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _EFI_USBMASS_H_
#define _EFI_USBMASS_H_
-
#include <Uefi.h>
#include <IndustryStandard/Scsi.h>
#include <Protocol/BlockIo.h>
@@ -26,8 +25,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/MemoryAllocationLib.h>
#include <Library/DevicePathLib.h>
-typedef struct _USB_MASS_TRANSPORT USB_MASS_TRANSPORT;
-typedef struct _USB_MASS_DEVICE USB_MASS_DEVICE;
+typedef struct _USB_MASS_TRANSPORT USB_MASS_TRANSPORT;
+typedef struct _USB_MASS_DEVICE USB_MASS_DEVICE;
#include "UsbMassBot.h"
#include "UsbMassCbi.h"
@@ -44,9 +43,9 @@ typedef struct _USB_MASS_DEVICE USB_MASS_DEVICE;
#define USB_MASS_1_MILLISECOND 1000
#define USB_MASS_1_SECOND (1000 * USB_MASS_1_MILLISECOND)
-#define USB_MASS_CMD_SUCCESS 0
-#define USB_MASS_CMD_FAIL 1
-#define USB_MASS_CMD_PERSISTENT 2
+#define USB_MASS_CMD_SUCCESS 0
+#define USB_MASS_CMD_FAIL 1
+#define USB_MASS_CMD_PERSISTENT 2
/**
Initializes USB transport protocol.
@@ -65,8 +64,8 @@ typedef struct _USB_MASS_DEVICE USB_MASS_DEVICE;
typedef
EFI_STATUS
(*USB_MASS_INIT_TRANSPORT) (
- IN EFI_USB_IO_PROTOCOL *Usb,
- OUT VOID **Context OPTIONAL
+ IN EFI_USB_IO_PROTOCOL *Usb,
+ OUT VOID **Context OPTIONAL
);
/**
@@ -114,8 +113,8 @@ EFI_STATUS
typedef
EFI_STATUS
(*USB_MASS_RESET) (
- IN VOID *Context,
- IN BOOLEAN ExtendedVerification
+ IN VOID *Context,
+ IN BOOLEAN ExtendedVerification
);
/**
@@ -132,8 +131,8 @@ EFI_STATUS
typedef
EFI_STATUS
(*USB_MASS_GET_MAX_LUN) (
- IN VOID *Context,
- IN UINT8 *MaxLun
+ IN VOID *Context,
+ IN UINT8 *MaxLun
);
/**
@@ -147,7 +146,7 @@ EFI_STATUS
typedef
EFI_STATUS
(*USB_MASS_CLEAN_UP) (
- IN VOID *Context
+ IN VOID *Context
);
///
@@ -159,29 +158,29 @@ EFI_STATUS
/// it is no longer necessary.
///
struct _USB_MASS_TRANSPORT {
- UINT8 Protocol;
- USB_MASS_INIT_TRANSPORT Init; ///< Initialize the mass storage transport protocol
- USB_MASS_EXEC_COMMAND ExecCommand; ///< Transport command to the device then get result
- USB_MASS_RESET Reset; ///< Reset the device
- USB_MASS_GET_MAX_LUN GetMaxLun; ///< Get max lun, only for bot
- USB_MASS_CLEAN_UP CleanUp; ///< Clean up the resources.
+ UINT8 Protocol;
+ USB_MASS_INIT_TRANSPORT Init; ///< Initialize the mass storage transport protocol
+ USB_MASS_EXEC_COMMAND ExecCommand; ///< Transport command to the device then get result
+ USB_MASS_RESET Reset; ///< Reset the device
+ USB_MASS_GET_MAX_LUN GetMaxLun; ///< Get max lun, only for bot
+ USB_MASS_CLEAN_UP CleanUp; ///< Clean up the resources.
};
struct _USB_MASS_DEVICE {
- UINT32 Signature;
- EFI_HANDLE Controller;
- EFI_USB_IO_PROTOCOL *UsbIo;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_BLOCK_IO_PROTOCOL BlockIo;
- EFI_BLOCK_IO_MEDIA BlockIoMedia;
- BOOLEAN OpticalStorage;
- UINT8 Lun; ///< Logical Unit Number
- UINT8 Pdt; ///< Peripheral Device Type
- USB_MASS_TRANSPORT *Transport; ///< USB mass storage transport protocol
- VOID *Context;
- EFI_DISK_INFO_PROTOCOL DiskInfo;
- USB_BOOT_INQUIRY_DATA InquiryData;
- BOOLEAN Cdb16Byte;
+ UINT32 Signature;
+ EFI_HANDLE Controller;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_BLOCK_IO_PROTOCOL BlockIo;
+ EFI_BLOCK_IO_MEDIA BlockIoMedia;
+ BOOLEAN OpticalStorage;
+ UINT8 Lun; ///< Logical Unit Number
+ UINT8 Pdt; ///< Peripheral Device Type
+ USB_MASS_TRANSPORT *Transport; ///< USB mass storage transport protocol
+ VOID *Context;
+ EFI_DISK_INFO_PROTOCOL DiskInfo;
+ USB_BOOT_INQUIRY_DATA InquiryData;
+ BOOLEAN Cdb16Byte;
};
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
index 7b29bc8..f648187 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
@@ -24,15 +24,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
EFI_STATUS
UsbBootRequestSense (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
)
{
- USB_BOOT_REQUEST_SENSE_CMD SenseCmd;
- USB_BOOT_REQUEST_SENSE_DATA SenseData;
- EFI_BLOCK_IO_MEDIA *Media;
- USB_MASS_TRANSPORT *Transport;
- EFI_STATUS Status;
- UINT32 CmdResult;
+ USB_BOOT_REQUEST_SENSE_CMD SenseCmd;
+ USB_BOOT_REQUEST_SENSE_DATA SenseData;
+ EFI_BLOCK_IO_MEDIA *Media;
+ USB_MASS_TRANSPORT *Transport;
+ EFI_STATUS Status;
+ UINT32 CmdResult;
Transport = UsbMass->Transport;
@@ -43,8 +43,8 @@ UsbBootRequestSense (
ZeroMem (&SenseData, sizeof (USB_BOOT_REQUEST_SENSE_DATA));
SenseCmd.OpCode = USB_BOOT_REQUEST_SENSE_OPCODE;
- SenseCmd.Lun = (UINT8) (USB_BOOT_LUN (UsbMass->Lun));
- SenseCmd.AllocLen = (UINT8) sizeof (USB_BOOT_REQUEST_SENSE_DATA);
+ SenseCmd.Lun = (UINT8)(USB_BOOT_LUN (UsbMass->Lun));
+ SenseCmd.AllocLen = (UINT8)sizeof (USB_BOOT_REQUEST_SENSE_DATA);
Status = Transport->ExecCommand (
UsbMass->Context,
@@ -57,11 +57,12 @@ UsbBootRequestSense (
USB_BOOT_GENERAL_CMD_TIMEOUT,
&CmdResult
);
- if (EFI_ERROR (Status) || CmdResult != USB_MASS_CMD_SUCCESS) {
+ if (EFI_ERROR (Status) || (CmdResult != USB_MASS_CMD_SUCCESS)) {
DEBUG ((DEBUG_ERROR, "UsbBootRequestSense: (%r) CmdResult=0x%x\n", Status, CmdResult));
if (!EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
}
+
return Status;
}
@@ -72,77 +73,80 @@ UsbBootRequestSense (
Media = &UsbMass->BlockIoMedia;
switch (USB_BOOT_SENSE_KEY (SenseData.SenseKey)) {
+ case USB_BOOT_SENSE_NO_SENSE:
+ if (SenseData.Asc == USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION) {
+ //
+ // It is not an error if a device does not have additional sense information
+ //
+ Status = EFI_SUCCESS;
+ } else {
+ Status = EFI_NO_RESPONSE;
+ }
- case USB_BOOT_SENSE_NO_SENSE:
- if (SenseData.Asc == USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION) {
+ break;
+
+ case USB_BOOT_SENSE_RECOVERED:
//
- // It is not an error if a device does not have additional sense information
+ // Suppose hardware can handle this case, and recover later by itself
//
- Status = EFI_SUCCESS;
- } else {
- Status = EFI_NO_RESPONSE;
- }
- break;
-
- case USB_BOOT_SENSE_RECOVERED:
- //
- // Suppose hardware can handle this case, and recover later by itself
- //
- Status = EFI_NOT_READY;
- break;
-
- case USB_BOOT_SENSE_NOT_READY:
- Status = EFI_DEVICE_ERROR;
- if (SenseData.Asc == USB_BOOT_ASC_NO_MEDIA) {
- Media->MediaPresent = FALSE;
- Status = EFI_NO_MEDIA;
- } else if (SenseData.Asc == USB_BOOT_ASC_NOT_READY) {
Status = EFI_NOT_READY;
- }
- break;
+ break;
- case USB_BOOT_SENSE_ILLEGAL_REQUEST:
- Status = EFI_INVALID_PARAMETER;
- break;
+ case USB_BOOT_SENSE_NOT_READY:
+ Status = EFI_DEVICE_ERROR;
+ if (SenseData.Asc == USB_BOOT_ASC_NO_MEDIA) {
+ Media->MediaPresent = FALSE;
+ Status = EFI_NO_MEDIA;
+ } else if (SenseData.Asc == USB_BOOT_ASC_NOT_READY) {
+ Status = EFI_NOT_READY;
+ }
- case USB_BOOT_SENSE_UNIT_ATTENTION:
- Status = EFI_DEVICE_ERROR;
- if (SenseData.Asc == USB_BOOT_ASC_MEDIA_CHANGE) {
- //
- // If MediaChange, reset ReadOnly and new MediaId
- //
- Status = EFI_MEDIA_CHANGED;
- Media->ReadOnly = FALSE;
- Media->MediaId++;
- } else if (SenseData.Asc == USB_BOOT_ASC_NOT_READY) {
- Status = EFI_NOT_READY;
- } else if (SenseData.Asc == USB_BOOT_ASC_NO_MEDIA) {
- Status = EFI_NOT_READY;
- }
- break;
+ break;
+
+ case USB_BOOT_SENSE_ILLEGAL_REQUEST:
+ Status = EFI_INVALID_PARAMETER;
+ break;
+
+ case USB_BOOT_SENSE_UNIT_ATTENTION:
+ Status = EFI_DEVICE_ERROR;
+ if (SenseData.Asc == USB_BOOT_ASC_MEDIA_CHANGE) {
+ //
+ // If MediaChange, reset ReadOnly and new MediaId
+ //
+ Status = EFI_MEDIA_CHANGED;
+ Media->ReadOnly = FALSE;
+ Media->MediaId++;
+ } else if (SenseData.Asc == USB_BOOT_ASC_NOT_READY) {
+ Status = EFI_NOT_READY;
+ } else if (SenseData.Asc == USB_BOOT_ASC_NO_MEDIA) {
+ Status = EFI_NOT_READY;
+ }
- case USB_BOOT_SENSE_DATA_PROTECT:
- Status = EFI_WRITE_PROTECTED;
- Media->ReadOnly = TRUE;
- break;
+ break;
+
+ case USB_BOOT_SENSE_DATA_PROTECT:
+ Status = EFI_WRITE_PROTECTED;
+ Media->ReadOnly = TRUE;
+ break;
- default:
- Status = EFI_DEVICE_ERROR;
- break;
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
}
- DEBUG ((DEBUG_INFO, "UsbBootRequestSense: (%r) with error code (%x) sense key %x/%x/%x\n",
- Status,
- SenseData.ErrorCode,
- USB_BOOT_SENSE_KEY (SenseData.SenseKey),
- SenseData.Asc,
- SenseData.Ascq
- ));
+ DEBUG ((
+ DEBUG_INFO,
+ "UsbBootRequestSense: (%r) with error code (%x) sense key %x/%x/%x\n",
+ Status,
+ SenseData.ErrorCode,
+ USB_BOOT_SENSE_KEY (SenseData.SenseKey),
+ SenseData.Asc,
+ SenseData.Ascq
+ ));
return Status;
}
-
/**
Execute the USB mass storage bootability commands.
@@ -164,18 +168,18 @@ UsbBootRequestSense (
**/
EFI_STATUS
UsbBootExecCmd (
- IN USB_MASS_DEVICE *UsbMass,
- IN VOID *Cmd,
- IN UINT8 CmdLen,
- IN EFI_USB_DATA_DIRECTION DataDir,
- IN VOID *Data,
- IN UINT32 DataLen,
- IN UINT32 Timeout
+ IN USB_MASS_DEVICE *UsbMass,
+ IN VOID *Cmd,
+ IN UINT8 CmdLen,
+ IN EFI_USB_DATA_DIRECTION DataDir,
+ IN VOID *Data,
+ IN UINT32 DataLen,
+ IN UINT32 Timeout
)
{
- USB_MASS_TRANSPORT *Transport;
- EFI_STATUS Status;
- UINT32 CmdResult;
+ USB_MASS_TRANSPORT *Transport;
+ EFI_STATUS Status;
+ UINT32 CmdResult;
Transport = UsbMass->Transport;
Status = Transport->ExecCommand (
@@ -210,7 +214,6 @@ UsbBootExecCmd (
return UsbBootRequestSense (UsbMass);
}
-
/**
Execute the USB mass storage bootability commands with retrial.
@@ -234,18 +237,18 @@ UsbBootExecCmd (
**/
EFI_STATUS
UsbBootExecCmdWithRetry (
- IN USB_MASS_DEVICE *UsbMass,
- IN VOID *Cmd,
- IN UINT8 CmdLen,
- IN EFI_USB_DATA_DIRECTION DataDir,
- IN VOID *Data,
- IN UINT32 DataLen,
- IN UINT32 Timeout
+ IN USB_MASS_DEVICE *UsbMass,
+ IN VOID *Cmd,
+ IN UINT8 CmdLen,
+ IN EFI_USB_DATA_DIRECTION DataDir,
+ IN VOID *Data,
+ IN UINT32 DataLen,
+ IN UINT32 Timeout
)
{
- EFI_STATUS Status;
- UINTN Retry;
- EFI_EVENT TimeoutEvt;
+ EFI_STATUS Status;
+ UINTN Retry;
+ EFI_EVENT TimeoutEvt;
Retry = 0;
Status = EFI_SUCCESS;
@@ -260,7 +263,7 @@ UsbBootExecCmdWithRetry (
return Status;
}
- Status = gBS->SetTimer (TimeoutEvt, TimerRelative, EFI_TIMER_PERIOD_SECONDS(60));
+ Status = gBS->SetTimer (TimeoutEvt, TimerRelative, EFI_TIMER_PERIOD_SECONDS (60));
if (EFI_ERROR (Status)) {
goto EXIT;
}
@@ -278,9 +281,10 @@ UsbBootExecCmdWithRetry (
DataLen,
Timeout
);
- if (Status == EFI_SUCCESS || Status == EFI_NO_MEDIA) {
+ if ((Status == EFI_SUCCESS) || (Status == EFI_NO_MEDIA)) {
break;
}
+
//
// If the sense data shows the drive is not ready, we need execute the cmd again.
// We limit the upper boundary to 60 seconds.
@@ -288,6 +292,7 @@ UsbBootExecCmdWithRetry (
if (Status == EFI_NOT_READY) {
continue;
}
+
//
// If the status is other error, then just retry 5 times.
//
@@ -304,7 +309,6 @@ EXIT:
return Status;
}
-
/**
Execute TEST UNIT READY command to check if the device is ready.
@@ -316,20 +320,20 @@ EXIT:
**/
EFI_STATUS
UsbBootIsUnitReady (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
)
{
USB_BOOT_TEST_UNIT_READY_CMD TestCmd;
ZeroMem (&TestCmd, sizeof (USB_BOOT_TEST_UNIT_READY_CMD));
- TestCmd.OpCode = USB_BOOT_TEST_UNIT_READY_OPCODE;
- TestCmd.Lun = (UINT8) (USB_BOOT_LUN (UsbMass->Lun));
+ TestCmd.OpCode = USB_BOOT_TEST_UNIT_READY_OPCODE;
+ TestCmd.Lun = (UINT8)(USB_BOOT_LUN (UsbMass->Lun));
return UsbBootExecCmdWithRetry (
UsbMass,
&TestCmd,
- (UINT8) sizeof (USB_BOOT_TEST_UNIT_READY_CMD),
+ (UINT8)sizeof (USB_BOOT_TEST_UNIT_READY_CMD),
EfiUsbNoData,
NULL,
0,
@@ -337,7 +341,6 @@ UsbBootIsUnitReady (
);
}
-
/**
Execute INQUIRY Command to request information regarding parameters of
the device be sent to the host computer.
@@ -350,12 +353,12 @@ UsbBootIsUnitReady (
**/
EFI_STATUS
UsbBootInquiry (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
)
{
- USB_BOOT_INQUIRY_CMD InquiryCmd;
- EFI_BLOCK_IO_MEDIA *Media;
- EFI_STATUS Status;
+ USB_BOOT_INQUIRY_CMD InquiryCmd;
+ EFI_BLOCK_IO_MEDIA *Media;
+ EFI_STATUS Status;
Media = &(UsbMass->BlockIoMedia);
@@ -363,13 +366,13 @@ UsbBootInquiry (
ZeroMem (&UsbMass->InquiryData, sizeof (USB_BOOT_INQUIRY_DATA));
InquiryCmd.OpCode = USB_BOOT_INQUIRY_OPCODE;
- InquiryCmd.Lun = (UINT8) (USB_BOOT_LUN (UsbMass->Lun));
- InquiryCmd.AllocLen = (UINT8) sizeof (USB_BOOT_INQUIRY_DATA);
+ InquiryCmd.Lun = (UINT8)(USB_BOOT_LUN (UsbMass->Lun));
+ InquiryCmd.AllocLen = (UINT8)sizeof (USB_BOOT_INQUIRY_DATA);
Status = UsbBootExecCmdWithRetry (
UsbMass,
&InquiryCmd,
- (UINT8) sizeof (USB_BOOT_INQUIRY_CMD),
+ (UINT8)sizeof (USB_BOOT_INQUIRY_CMD),
EfiUsbDataIn,
&UsbMass->InquiryData,
sizeof (USB_BOOT_INQUIRY_DATA),
@@ -383,12 +386,12 @@ UsbBootInquiry (
// Get information from PDT (Peripheral Device Type) field and Removable Medium Bit
// from the inquiry data.
//
- UsbMass->Pdt = (UINT8) (USB_BOOT_PDT (UsbMass->InquiryData.Pdt));
- Media->RemovableMedia = (BOOLEAN) (USB_BOOT_REMOVABLE (UsbMass->InquiryData.Removable));
+ UsbMass->Pdt = (UINT8)(USB_BOOT_PDT (UsbMass->InquiryData.Pdt));
+ Media->RemovableMedia = (BOOLEAN)(USB_BOOT_REMOVABLE (UsbMass->InquiryData.Removable));
//
// Set block size to the default value of 512 Bytes, in case no media is present at first time.
//
- Media->BlockSize = 0x0200;
+ Media->BlockSize = 0x0200;
return Status;
}
@@ -410,16 +413,16 @@ UsbBootInquiry (
**/
EFI_STATUS
UsbBootReadCapacity16 (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
)
{
- UINT8 CapacityCmd[16];
- EFI_SCSI_DISK_CAPACITY_DATA16 CapacityData;
- EFI_BLOCK_IO_MEDIA *Media;
- EFI_STATUS Status;
- UINT32 BlockSize;
+ UINT8 CapacityCmd[16];
+ EFI_SCSI_DISK_CAPACITY_DATA16 CapacityData;
+ EFI_BLOCK_IO_MEDIA *Media;
+ EFI_STATUS Status;
+ UINT32 BlockSize;
- Media = &UsbMass->BlockIoMedia;
+ Media = &UsbMass->BlockIoMedia;
Media->MediaPresent = FALSE;
Media->LastBlock = 0;
@@ -428,8 +431,8 @@ UsbBootReadCapacity16 (
ZeroMem (CapacityCmd, sizeof (CapacityCmd));
ZeroMem (&CapacityData, sizeof (CapacityData));
- CapacityCmd[0] = EFI_SCSI_OP_READ_CAPACITY16;
- CapacityCmd[1] = 0x10;
+ CapacityCmd[0] = EFI_SCSI_OP_READ_CAPACITY16;
+ CapacityCmd[1] = 0x10;
//
// Partial medium indicator, set the bytes 2 ~ 9 of the Cdb as ZERO.
//
@@ -440,7 +443,7 @@ UsbBootReadCapacity16 (
Status = UsbBootExecCmdWithRetry (
UsbMass,
CapacityCmd,
- (UINT8) sizeof (CapacityCmd),
+ (UINT8)sizeof (CapacityCmd),
EfiUsbDataIn,
&CapacityData,
sizeof (CapacityData),
@@ -455,13 +458,13 @@ UsbBootReadCapacity16 (
// from READ CAPACITY data.
//
Media->MediaPresent = TRUE;
- Media->LastBlock = SwapBytes64 (ReadUnaligned64 ((CONST UINT64 *) &(CapacityData.LastLba7)));
+ Media->LastBlock = SwapBytes64 (ReadUnaligned64 ((CONST UINT64 *)&(CapacityData.LastLba7)));
- BlockSize = SwapBytes32 (ReadUnaligned32 ((CONST UINT32 *) &(CapacityData.BlockSize3)));
+ BlockSize = SwapBytes32 (ReadUnaligned32 ((CONST UINT32 *)&(CapacityData.BlockSize3)));
Media->LowestAlignedLba = (CapacityData.LowestAlignLogic2 << 8) |
- CapacityData.LowestAlignLogic1;
- Media->LogicalBlocksPerPhysicalBlock = (1 << CapacityData.LogicPerPhysical);
+ CapacityData.LowestAlignLogic1;
+ Media->LogicalBlocksPerPhysicalBlock = (1 << CapacityData.LogicPerPhysical);
if (BlockSize == 0) {
//
// Get sense data
@@ -474,7 +477,6 @@ UsbBootReadCapacity16 (
return Status;
}
-
/**
Execute READ CAPACITY command to request information regarding
the capacity of the installed medium of the device.
@@ -492,27 +494,27 @@ UsbBootReadCapacity16 (
**/
EFI_STATUS
UsbBootReadCapacity (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
)
{
- USB_BOOT_READ_CAPACITY_CMD CapacityCmd;
- USB_BOOT_READ_CAPACITY_DATA CapacityData;
- EFI_BLOCK_IO_MEDIA *Media;
- EFI_STATUS Status;
- UINT32 BlockSize;
+ USB_BOOT_READ_CAPACITY_CMD CapacityCmd;
+ USB_BOOT_READ_CAPACITY_DATA CapacityData;
+ EFI_BLOCK_IO_MEDIA *Media;
+ EFI_STATUS Status;
+ UINT32 BlockSize;
- Media = &UsbMass->BlockIoMedia;
+ Media = &UsbMass->BlockIoMedia;
ZeroMem (&CapacityCmd, sizeof (USB_BOOT_READ_CAPACITY_CMD));
ZeroMem (&CapacityData, sizeof (USB_BOOT_READ_CAPACITY_DATA));
CapacityCmd.OpCode = USB_BOOT_READ_CAPACITY_OPCODE;
- CapacityCmd.Lun = (UINT8) (USB_BOOT_LUN (UsbMass->Lun));
+ CapacityCmd.Lun = (UINT8)(USB_BOOT_LUN (UsbMass->Lun));
Status = UsbBootExecCmdWithRetry (
UsbMass,
&CapacityCmd,
- (UINT8) sizeof (USB_BOOT_READ_CAPACITY_CMD),
+ (UINT8)sizeof (USB_BOOT_READ_CAPACITY_CMD),
EfiUsbDataIn,
&CapacityData,
sizeof (USB_BOOT_READ_CAPACITY_DATA),
@@ -527,9 +529,9 @@ UsbBootReadCapacity (
// from READ CAPACITY data.
//
Media->MediaPresent = TRUE;
- Media->LastBlock = SwapBytes32 (ReadUnaligned32 ((CONST UINT32 *) CapacityData.LastLba));
+ Media->LastBlock = SwapBytes32 (ReadUnaligned32 ((CONST UINT32 *)CapacityData.LastLba));
- BlockSize = SwapBytes32 (ReadUnaligned32 ((CONST UINT32 *) CapacityData.BlockLen));
+ BlockSize = SwapBytes32 (ReadUnaligned32 ((CONST UINT32 *)CapacityData.BlockLen));
if (BlockSize == 0) {
//
// Get sense data
@@ -560,15 +562,15 @@ UsbBootReadCapacity (
**/
EFI_STATUS
UsbScsiModeSense (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
)
{
- EFI_STATUS Status;
- USB_SCSI_MODE_SENSE6_CMD ModeSenseCmd;
- USB_SCSI_MODE_SENSE6_PARA_HEADER ModeParaHeader;
- EFI_BLOCK_IO_MEDIA *Media;
+ EFI_STATUS Status;
+ USB_SCSI_MODE_SENSE6_CMD ModeSenseCmd;
+ USB_SCSI_MODE_SENSE6_PARA_HEADER ModeParaHeader;
+ EFI_BLOCK_IO_MEDIA *Media;
- Media = &UsbMass->BlockIoMedia;
+ Media = &UsbMass->BlockIoMedia;
ZeroMem (&ModeSenseCmd, sizeof (USB_SCSI_MODE_SENSE6_CMD));
ZeroMem (&ModeParaHeader, sizeof (USB_SCSI_MODE_SENSE6_PARA_HEADER));
@@ -576,15 +578,15 @@ UsbScsiModeSense (
//
// MODE SENSE(6) command is defined in Section 8.2.10 of SCSI-2 Spec
//
- ModeSenseCmd.OpCode = USB_SCSI_MODE_SENSE6_OPCODE;
- ModeSenseCmd.Lun = (UINT8) USB_BOOT_LUN (UsbMass->Lun);
- ModeSenseCmd.PageCode = 0x3F;
- ModeSenseCmd.AllocateLen = (UINT8) sizeof (USB_SCSI_MODE_SENSE6_PARA_HEADER);
+ ModeSenseCmd.OpCode = USB_SCSI_MODE_SENSE6_OPCODE;
+ ModeSenseCmd.Lun = (UINT8)USB_BOOT_LUN (UsbMass->Lun);
+ ModeSenseCmd.PageCode = 0x3F;
+ ModeSenseCmd.AllocateLen = (UINT8)sizeof (USB_SCSI_MODE_SENSE6_PARA_HEADER);
Status = UsbBootExecCmdWithRetry (
UsbMass,
&ModeSenseCmd,
- (UINT8) sizeof (USB_SCSI_MODE_SENSE6_CMD),
+ (UINT8)sizeof (USB_SCSI_MODE_SENSE6_CMD),
EfiUsbDataIn,
&ModeParaHeader,
sizeof (USB_SCSI_MODE_SENSE6_PARA_HEADER),
@@ -597,13 +599,12 @@ UsbScsiModeSense (
// BIT7 of this byte is indicates whether the medium is write protected.
//
if (!EFI_ERROR (Status)) {
- Media->ReadOnly = (BOOLEAN) ((ModeParaHeader.DevicePara & BIT7) != 0);
+ Media->ReadOnly = (BOOLEAN)((ModeParaHeader.DevicePara & BIT7) != 0);
}
return Status;
}
-
/**
Get the parameters for the USB mass storage media.
@@ -621,13 +622,13 @@ UsbScsiModeSense (
**/
EFI_STATUS
UsbBootGetParams (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
)
{
- EFI_BLOCK_IO_MEDIA *Media;
- EFI_STATUS Status;
+ EFI_BLOCK_IO_MEDIA *Media;
+ EFI_STATUS Status;
- Media = &(UsbMass->BlockIoMedia);
+ Media = &(UsbMass->BlockIoMedia);
Status = UsbBootInquiry (UsbMass);
if (EFI_ERROR (Status)) {
@@ -640,9 +641,10 @@ UsbBootGetParams (
// 4 Peripheral Device Types are in spec.
//
if ((UsbMass->Pdt != USB_PDT_DIRECT_ACCESS) &&
- (UsbMass->Pdt != USB_PDT_CDROM) &&
- (UsbMass->Pdt != USB_PDT_OPTICAL) &&
- (UsbMass->Pdt != USB_PDT_SIMPLE_DIRECT)) {
+ (UsbMass->Pdt != USB_PDT_CDROM) &&
+ (UsbMass->Pdt != USB_PDT_OPTICAL) &&
+ (UsbMass->Pdt != USB_PDT_SIMPLE_DIRECT))
+ {
DEBUG ((DEBUG_ERROR, "UsbBootGetParams: Found an unsupported peripheral type[%d]\n", UsbMass->Pdt));
return EFI_UNSUPPORTED;
}
@@ -659,7 +661,7 @@ UsbBootGetParams (
//
// Default value 2048 Bytes, in case no media present at first time
//
- Media->BlockSize = 0x0800;
+ Media->BlockSize = 0x0800;
}
Status = UsbBootDetectMedia (UsbMass);
@@ -667,7 +669,6 @@ UsbBootGetParams (
return Status;
}
-
/**
Detect whether the removable media is present and whether it has changed.
@@ -679,19 +680,19 @@ UsbBootGetParams (
**/
EFI_STATUS
UsbBootDetectMedia (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
)
{
- EFI_BLOCK_IO_MEDIA OldMedia;
- EFI_BLOCK_IO_MEDIA *Media;
- UINT8 CmdSet;
- EFI_STATUS Status;
+ EFI_BLOCK_IO_MEDIA OldMedia;
+ EFI_BLOCK_IO_MEDIA *Media;
+ UINT8 CmdSet;
+ EFI_STATUS Status;
- Media = &UsbMass->BlockIoMedia;
+ Media = &UsbMass->BlockIoMedia;
CopyMem (&OldMedia, &(UsbMass->BlockIoMedia), sizeof (EFI_BLOCK_IO_MEDIA));
- CmdSet = ((EFI_USB_INTERFACE_DESCRIPTOR *) (UsbMass->Context))->InterfaceSubClass;
+ CmdSet = ((EFI_USB_INTERFACE_DESCRIPTOR *)(UsbMass->Context))->InterfaceSubClass;
Status = UsbBootIsUnitReady (UsbMass);
if (EFI_ERROR (Status)) {
@@ -723,7 +724,7 @@ UsbBootDetectMedia (
}
}
- if (EFI_ERROR (Status) && Status != EFI_NO_MEDIA) {
+ if (EFI_ERROR (Status) && (Status != EFI_NO_MEDIA)) {
//
// For NoMedia, BlockIo is still needed.
//
@@ -749,8 +750,8 @@ UsbBootDetectMedia (
(Media->MediaPresent != OldMedia.MediaPresent) ||
(Media->ReadOnly != OldMedia.ReadOnly) ||
(Media->BlockSize != OldMedia.BlockSize) ||
- (Media->LastBlock != OldMedia.LastBlock)) {
-
+ (Media->LastBlock != OldMedia.LastBlock))
+ {
//
// This function is called from:
// Block I/O Protocol APIs, which run at TPL_CALLBACK.
@@ -781,7 +782,8 @@ UsbBootDetectMedia (
if ((Media->ReadOnly != OldMedia.ReadOnly) ||
(Media->BlockSize != OldMedia.BlockSize) ||
- (Media->LastBlock != OldMedia.LastBlock)) {
+ (Media->LastBlock != OldMedia.LastBlock))
+ {
Media->MediaId++;
}
@@ -791,7 +793,6 @@ UsbBootDetectMedia (
return Status;
}
-
/**
Read or write some blocks from the device.
@@ -807,20 +808,20 @@ UsbBootDetectMedia (
**/
EFI_STATUS
UsbBootReadWriteBlocks (
- IN USB_MASS_DEVICE *UsbMass,
- IN BOOLEAN Write,
- IN UINT32 Lba,
- IN UINTN TotalBlock,
- IN OUT UINT8 *Buffer
+ IN USB_MASS_DEVICE *UsbMass,
+ IN BOOLEAN Write,
+ IN UINT32 Lba,
+ IN UINTN TotalBlock,
+ IN OUT UINT8 *Buffer
)
{
- USB_BOOT_READ_WRITE_10_CMD Cmd;
- EFI_STATUS Status;
- UINT32 Count;
- UINT32 CountMax;
- UINT32 BlockSize;
- UINT32 ByteSize;
- UINT32 Timeout;
+ USB_BOOT_READ_WRITE_10_CMD Cmd;
+ EFI_STATUS Status;
+ UINT32 Count;
+ UINT32 CountMax;
+ UINT32 BlockSize;
+ UINT32 ByteSize;
+ UINT32 Timeout;
BlockSize = UsbMass->BlockIoMedia.BlockSize;
CountMax = USB_BOOT_MAX_CARRY_SIZE / BlockSize;
@@ -839,22 +840,22 @@ UsbBootReadWriteBlocks (
//
// USB command's upper limit timeout is 5s. [USB2.0-9.2.6.1]
//
- Timeout = (UINT32) USB_BOOT_GENERAL_CMD_TIMEOUT;
+ Timeout = (UINT32)USB_BOOT_GENERAL_CMD_TIMEOUT;
//
// Fill in the command then execute
//
ZeroMem (&Cmd, sizeof (USB_BOOT_READ_WRITE_10_CMD));
- Cmd.OpCode = Write ? USB_BOOT_WRITE10_OPCODE : USB_BOOT_READ10_OPCODE;
- Cmd.Lun = (UINT8) (USB_BOOT_LUN (UsbMass->Lun));
- WriteUnaligned32 ((UINT32 *) Cmd.Lba, SwapBytes32 (Lba));
- WriteUnaligned16 ((UINT16 *) Cmd.TransferLen, SwapBytes16 ((UINT16)Count));
+ Cmd.OpCode = Write ? USB_BOOT_WRITE10_OPCODE : USB_BOOT_READ10_OPCODE;
+ Cmd.Lun = (UINT8)(USB_BOOT_LUN (UsbMass->Lun));
+ WriteUnaligned32 ((UINT32 *)Cmd.Lba, SwapBytes32 (Lba));
+ WriteUnaligned16 ((UINT16 *)Cmd.TransferLen, SwapBytes16 ((UINT16)Count));
Status = UsbBootExecCmdWithRetry (
UsbMass,
&Cmd,
- (UINT8) sizeof (USB_BOOT_READ_WRITE_10_CMD),
+ (UINT8)sizeof (USB_BOOT_READ_WRITE_10_CMD),
Write ? EfiUsbDataOut : EfiUsbDataIn,
Buffer,
ByteSize,
@@ -863,10 +864,13 @@ UsbBootReadWriteBlocks (
if (EFI_ERROR (Status)) {
return Status;
}
+
DEBUG ((
- DEBUG_BLKIO, "UsbBoot%sBlocks: LBA (0x%lx), Blk (0x%x)\n",
+ DEBUG_BLKIO,
+ "UsbBoot%sBlocks: LBA (0x%lx), Blk (0x%x)\n",
Write ? L"Write" : L"Read",
- Lba, Count
+ Lba,
+ Count
));
Lba += Count;
Buffer += ByteSize;
@@ -890,20 +894,20 @@ UsbBootReadWriteBlocks (
**/
EFI_STATUS
UsbBootReadWriteBlocks16 (
- IN USB_MASS_DEVICE *UsbMass,
- IN BOOLEAN Write,
- IN UINT64 Lba,
- IN UINTN TotalBlock,
- IN OUT UINT8 *Buffer
+ IN USB_MASS_DEVICE *UsbMass,
+ IN BOOLEAN Write,
+ IN UINT64 Lba,
+ IN UINTN TotalBlock,
+ IN OUT UINT8 *Buffer
)
{
- UINT8 Cmd[16];
- EFI_STATUS Status;
- UINT32 Count;
- UINT32 CountMax;
- UINT32 BlockSize;
- UINT32 ByteSize;
- UINT32 Timeout;
+ UINT8 Cmd[16];
+ EFI_STATUS Status;
+ UINT32 Count;
+ UINT32 CountMax;
+ UINT32 BlockSize;
+ UINT32 ByteSize;
+ UINT32 Timeout;
BlockSize = UsbMass->BlockIoMedia.BlockSize;
CountMax = USB_BOOT_MAX_CARRY_SIZE / BlockSize;
@@ -919,22 +923,22 @@ UsbBootReadWriteBlocks16 (
//
// USB command's upper limit timeout is 5s. [USB2.0-9.2.6.1]
//
- Timeout = (UINT32) USB_BOOT_GENERAL_CMD_TIMEOUT;
+ Timeout = (UINT32)USB_BOOT_GENERAL_CMD_TIMEOUT;
//
// Fill in the command then execute
//
ZeroMem (Cmd, sizeof (Cmd));
- Cmd[0] = Write ? EFI_SCSI_OP_WRITE16 : EFI_SCSI_OP_READ16;
- Cmd[1] = (UINT8) ((USB_BOOT_LUN (UsbMass->Lun) & 0xE0));
- WriteUnaligned64 ((UINT64 *) &Cmd[2], SwapBytes64 (Lba));
- WriteUnaligned32 ((UINT32 *) &Cmd[10], SwapBytes32 (Count));
+ Cmd[0] = Write ? EFI_SCSI_OP_WRITE16 : EFI_SCSI_OP_READ16;
+ Cmd[1] = (UINT8)((USB_BOOT_LUN (UsbMass->Lun) & 0xE0));
+ WriteUnaligned64 ((UINT64 *)&Cmd[2], SwapBytes64 (Lba));
+ WriteUnaligned32 ((UINT32 *)&Cmd[10], SwapBytes32 (Count));
Status = UsbBootExecCmdWithRetry (
UsbMass,
Cmd,
- (UINT8) sizeof (Cmd),
+ (UINT8)sizeof (Cmd),
Write ? EfiUsbDataOut : EfiUsbDataIn,
Buffer,
ByteSize,
@@ -943,10 +947,13 @@ UsbBootReadWriteBlocks16 (
if (EFI_ERROR (Status)) {
return Status;
}
+
DEBUG ((
- DEBUG_BLKIO, "UsbBoot%sBlocks16: LBA (0x%lx), Blk (0x%x)\n",
+ DEBUG_BLKIO,
+ "UsbBoot%sBlocks16: LBA (0x%lx), Blk (0x%x)\n",
Write ? L"Write" : L"Read",
- Lba, Count
+ Lba,
+ Count
));
Lba += Count;
Buffer += ByteSize;
@@ -968,14 +975,14 @@ UsbBootReadWriteBlocks16 (
**/
EFI_STATUS
UsbClearEndpointStall (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 EndpointAddr
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT8 EndpointAddr
)
{
- EFI_USB_DEVICE_REQUEST Request;
- EFI_STATUS Status;
- UINT32 CmdResult;
- UINT32 Timeout;
+ EFI_USB_DEVICE_REQUEST Request;
+ EFI_STATUS Status;
+ UINT32 CmdResult;
+ UINT32 Timeout;
Request.RequestType = 0x02;
Request.Request = USB_REQ_CLEAR_FEATURE;
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h
index f34a412..6722c3b 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h
@@ -17,15 +17,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Others are "Group 1 Timeout Commands". That is,
// they should be retried if driver is ready.
//
-#define USB_BOOT_INQUIRY_OPCODE 0x12
-#define USB_BOOT_REQUEST_SENSE_OPCODE 0x03
-#define USB_BOOT_MODE_SENSE10_OPCODE 0x5A
-#define USB_BOOT_READ_CAPACITY_OPCODE 0x25
-#define USB_BOOT_TEST_UNIT_READY_OPCODE 0x00
-#define USB_BOOT_READ10_OPCODE 0x28
-#define USB_BOOT_WRITE10_OPCODE 0x2A
+#define USB_BOOT_INQUIRY_OPCODE 0x12
+#define USB_BOOT_REQUEST_SENSE_OPCODE 0x03
+#define USB_BOOT_MODE_SENSE10_OPCODE 0x5A
+#define USB_BOOT_READ_CAPACITY_OPCODE 0x25
+#define USB_BOOT_TEST_UNIT_READY_OPCODE 0x00
+#define USB_BOOT_READ10_OPCODE 0x28
+#define USB_BOOT_WRITE10_OPCODE 0x2A
-#define USB_SCSI_MODE_SENSE6_OPCODE 0x1A
+#define USB_SCSI_MODE_SENSE6_OPCODE 0x1A
//
// The Sense Key part of the sense data. Sense data has three levels:
@@ -53,25 +53,25 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Supported PDT codes, or Peripheral Device Type
//
-#define USB_PDT_DIRECT_ACCESS 0x00 ///< Direct access device
-#define USB_PDT_CDROM 0x05 ///< CDROM
-#define USB_PDT_OPTICAL 0x07 ///< Non-CD optical disks
-#define USB_PDT_SIMPLE_DIRECT 0x0E ///< Simplified direct access device
+#define USB_PDT_DIRECT_ACCESS 0x00 ///< Direct access device
+#define USB_PDT_CDROM 0x05 ///< CDROM
+#define USB_PDT_OPTICAL 0x07 ///< Non-CD optical disks
+#define USB_PDT_SIMPLE_DIRECT 0x0E ///< Simplified direct access device
//
// Other parameters, Max carried size is 64KB.
//
-#define USB_BOOT_MAX_CARRY_SIZE SIZE_64KB
+#define USB_BOOT_MAX_CARRY_SIZE SIZE_64KB
//
// Retry mass command times, set by experience
//
-#define USB_BOOT_COMMAND_RETRY 5
+#define USB_BOOT_COMMAND_RETRY 5
//
// Wait for unit ready command, set by experience
//
-#define USB_BOOT_RETRY_UNIT_READY_STALL (500 * USB_MASS_1_MILLISECOND)
+#define USB_BOOT_RETRY_UNIT_READY_STALL (500 * USB_MASS_1_MILLISECOND)
//
// Mass command timeout, refers to specification[USB20-9.2.6.1]
@@ -80,7 +80,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// USB CD-Rom and iPod devices are much slower than USB key when response
// most of commands, So we set 5s as timeout here.
//
-#define USB_BOOT_GENERAL_CMD_TIMEOUT (5 * USB_MASS_1_SECOND)
+#define USB_BOOT_GENERAL_CMD_TIMEOUT (5 * USB_MASS_1_SECOND)
//
// The required commands are INQUIRY, READ CAPACITY, TEST UNIT READY,
@@ -90,122 +90,122 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
#pragma pack(1)
typedef struct {
- UINT8 OpCode;
- UINT8 Lun; ///< Lun (high 3 bits)
- UINT8 Reserved0[2];
- UINT8 AllocLen;
- UINT8 Reserved1;
- UINT8 Pad[6];
+ UINT8 OpCode;
+ UINT8 Lun; ///< Lun (high 3 bits)
+ UINT8 Reserved0[2];
+ UINT8 AllocLen;
+ UINT8 Reserved1;
+ UINT8 Pad[6];
} USB_BOOT_INQUIRY_CMD;
typedef struct {
- UINT8 Pdt; ///< Peripheral Device Type (low 5 bits)
- UINT8 Removable; ///< Removable Media (highest bit)
- UINT8 Reserved0[2];
- UINT8 AddLen; ///< Additional length
- UINT8 Reserved1[3];
- UINT8 VendorID[8];
- UINT8 ProductID[16];
- UINT8 ProductRevision[4];
+ UINT8 Pdt; ///< Peripheral Device Type (low 5 bits)
+ UINT8 Removable; ///< Removable Media (highest bit)
+ UINT8 Reserved0[2];
+ UINT8 AddLen; ///< Additional length
+ UINT8 Reserved1[3];
+ UINT8 VendorID[8];
+ UINT8 ProductID[16];
+ UINT8 ProductRevision[4];
} USB_BOOT_INQUIRY_DATA;
typedef struct {
- UINT8 OpCode;
- UINT8 Lun;
- UINT8 Reserved0[8];
- UINT8 Pad[2];
+ UINT8 OpCode;
+ UINT8 Lun;
+ UINT8 Reserved0[8];
+ UINT8 Pad[2];
} USB_BOOT_READ_CAPACITY_CMD;
typedef struct {
- UINT8 LastLba[4];
- UINT8 BlockLen[4];
+ UINT8 LastLba[4];
+ UINT8 BlockLen[4];
} USB_BOOT_READ_CAPACITY_DATA;
typedef struct {
- UINT8 OpCode;
- UINT8 Lun;
- UINT8 Reserved[4];
- UINT8 Pad[6];
+ UINT8 OpCode;
+ UINT8 Lun;
+ UINT8 Reserved[4];
+ UINT8 Pad[6];
} USB_BOOT_TEST_UNIT_READY_CMD;
typedef struct {
- UINT8 OpCode;
- UINT8 Lun;
- UINT8 PageCode;
- UINT8 Reserved0[4];
- UINT8 ParaListLenMsb;
- UINT8 ParaListLenLsb;
- UINT8 Reserved1;
- UINT8 Pad[2];
+ UINT8 OpCode;
+ UINT8 Lun;
+ UINT8 PageCode;
+ UINT8 Reserved0[4];
+ UINT8 ParaListLenMsb;
+ UINT8 ParaListLenLsb;
+ UINT8 Reserved1;
+ UINT8 Pad[2];
} USB_BOOT_MODE_SENSE10_CMD;
typedef struct {
- UINT8 ModeDataLenMsb;
- UINT8 ModeDataLenLsb;
- UINT8 Reserved0[4];
- UINT8 BlkDesLenMsb;
- UINT8 BlkDesLenLsb;
+ UINT8 ModeDataLenMsb;
+ UINT8 ModeDataLenLsb;
+ UINT8 Reserved0[4];
+ UINT8 BlkDesLenMsb;
+ UINT8 BlkDesLenLsb;
} USB_BOOT_MODE_SENSE10_PARA_HEADER;
typedef struct {
- UINT8 OpCode;
- UINT8 Lun; ///< Lun (High 3 bits)
- UINT8 Lba[4]; ///< Logical block address
- UINT8 Reserved0;
- UINT8 TransferLen[2]; ///< Transfer length
- UINT8 Reserverd1;
- UINT8 Pad[2];
+ UINT8 OpCode;
+ UINT8 Lun; ///< Lun (High 3 bits)
+ UINT8 Lba[4]; ///< Logical block address
+ UINT8 Reserved0;
+ UINT8 TransferLen[2]; ///< Transfer length
+ UINT8 Reserverd1;
+ UINT8 Pad[2];
} USB_BOOT_READ_WRITE_10_CMD;
typedef struct {
- UINT8 OpCode;
- UINT8 Lun; ///< Lun (High 3 bits)
- UINT8 Reserved0[2];
- UINT8 AllocLen; ///< Allocation length
- UINT8 Reserved1;
- UINT8 Pad[6];
+ UINT8 OpCode;
+ UINT8 Lun; ///< Lun (High 3 bits)
+ UINT8 Reserved0[2];
+ UINT8 AllocLen; ///< Allocation length
+ UINT8 Reserved1;
+ UINT8 Pad[6];
} USB_BOOT_REQUEST_SENSE_CMD;
typedef struct {
- UINT8 ErrorCode;
- UINT8 Reserved0;
- UINT8 SenseKey; ///< Sense key (low 4 bits)
- UINT8 Infor[4];
- UINT8 AddLen; ///< Additional Sense length, 10
- UINT8 Reserved1[4];
- UINT8 Asc; ///< Additional Sense Code
- UINT8 Ascq; ///< Additional Sense Code Qualifier
- UINT8 Reserverd2[4];
+ UINT8 ErrorCode;
+ UINT8 Reserved0;
+ UINT8 SenseKey; ///< Sense key (low 4 bits)
+ UINT8 Infor[4];
+ UINT8 AddLen; ///< Additional Sense length, 10
+ UINT8 Reserved1[4];
+ UINT8 Asc; ///< Additional Sense Code
+ UINT8 Ascq; ///< Additional Sense Code Qualifier
+ UINT8 Reserverd2[4];
} USB_BOOT_REQUEST_SENSE_DATA;
typedef struct {
- UINT8 OpCode;
- UINT8 Lun;
- UINT8 PageCode;
- UINT8 Reserved0;
- UINT8 AllocateLen;
- UINT8 Control;
+ UINT8 OpCode;
+ UINT8 Lun;
+ UINT8 PageCode;
+ UINT8 Reserved0;
+ UINT8 AllocateLen;
+ UINT8 Control;
} USB_SCSI_MODE_SENSE6_CMD;
typedef struct {
- UINT8 ModeDataLen;
- UINT8 MediumType;
- UINT8 DevicePara;
- UINT8 BlkDesLen;
+ UINT8 ModeDataLen;
+ UINT8 MediumType;
+ UINT8 DevicePara;
+ UINT8 BlkDesLen;
} USB_SCSI_MODE_SENSE6_PARA_HEADER;
#pragma pack()
//
// Convert a LUN number to that in the command
//
-#define USB_BOOT_LUN(Lun) ((Lun) << 5)
+#define USB_BOOT_LUN(Lun) ((Lun) << 5)
//
// Get the removable, PDT, and sense key bits from the command data
//
-#define USB_BOOT_REMOVABLE(RmbByte) (((RmbByte) & BIT7) != 0)
-#define USB_BOOT_PDT(Pdt) ((Pdt) & 0x1f)
-#define USB_BOOT_SENSE_KEY(Key) ((Key) & 0x0f)
+#define USB_BOOT_REMOVABLE(RmbByte) (((RmbByte) & BIT7) != 0)
+#define USB_BOOT_PDT(Pdt) ((Pdt) & 0x1f)
+#define USB_BOOT_SENSE_KEY(Key) ((Key) & 0x0f)
/**
Get the parameters for the USB mass storage media.
@@ -224,7 +224,7 @@ typedef struct {
**/
EFI_STATUS
UsbBootGetParams (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
);
/**
@@ -238,7 +238,7 @@ UsbBootGetParams (
**/
EFI_STATUS
UsbBootIsUnitReady (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
);
/**
@@ -252,7 +252,7 @@ UsbBootIsUnitReady (
**/
EFI_STATUS
UsbBootDetectMedia (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
);
/**
@@ -269,10 +269,10 @@ UsbBootDetectMedia (
**/
EFI_STATUS
UsbBootReadBlocks (
- IN USB_MASS_DEVICE *UsbMass,
- IN UINT32 Lba,
- IN UINTN TotalBlock,
- OUT UINT8 *Buffer
+ IN USB_MASS_DEVICE *UsbMass,
+ IN UINT32 Lba,
+ IN UINTN TotalBlock,
+ OUT UINT8 *Buffer
);
/**
@@ -290,11 +290,11 @@ UsbBootReadBlocks (
**/
EFI_STATUS
UsbBootReadWriteBlocks (
- IN USB_MASS_DEVICE *UsbMass,
- IN BOOLEAN Write,
- IN UINT32 Lba,
- IN UINTN TotalBlock,
- IN OUT UINT8 *Buffer
+ IN USB_MASS_DEVICE *UsbMass,
+ IN BOOLEAN Write,
+ IN UINT32 Lba,
+ IN UINTN TotalBlock,
+ IN OUT UINT8 *Buffer
);
/**
@@ -311,11 +311,11 @@ UsbBootReadWriteBlocks (
**/
EFI_STATUS
UsbBootReadWriteBlocks16 (
- IN USB_MASS_DEVICE *UsbMass,
- IN BOOLEAN Write,
- IN UINT64 Lba,
- IN UINTN TotalBlock,
- IN OUT UINT8 *Buffer
+ IN USB_MASS_DEVICE *UsbMass,
+ IN BOOLEAN Write,
+ IN UINT64 Lba,
+ IN UINTN TotalBlock,
+ IN OUT UINT8 *Buffer
);
/**
@@ -330,9 +330,8 @@ UsbBootReadWriteBlocks16 (
**/
EFI_STATUS
UsbClearEndpointStall (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN UINT8 EndpointAddr
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT8 EndpointAddr
);
#endif
-
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c
index ce252e6..55c239d 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c
@@ -12,7 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Definition of USB BOT Transport Protocol
//
-USB_MASS_TRANSPORT mUsbBotTransport = {
+USB_MASS_TRANSPORT mUsbBotTransport = {
USB_MASS_STORE_BOT,
UsbBotInit,
UsbBotExecCommand,
@@ -38,8 +38,8 @@ USB_MASS_TRANSPORT mUsbBotTransport = {
**/
EFI_STATUS
UsbBotInit (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- OUT VOID **Context OPTIONAL
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ OUT VOID **Context OPTIONAL
)
{
USB_BOT_PROTOCOL *UsbBot;
@@ -84,17 +84,17 @@ UsbBotInit (
}
if (USB_IS_IN_ENDPOINT (EndPoint.EndpointAddress) &&
- (UsbBot->BulkInEndpoint == NULL)) {
-
- UsbBot->BulkInEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *) (UsbBot + 1);
- CopyMem(UsbBot->BulkInEndpoint, &EndPoint, sizeof (EndPoint));
+ (UsbBot->BulkInEndpoint == NULL))
+ {
+ UsbBot->BulkInEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *)(UsbBot + 1);
+ CopyMem (UsbBot->BulkInEndpoint, &EndPoint, sizeof (EndPoint));
}
if (USB_IS_OUT_ENDPOINT (EndPoint.EndpointAddress) &&
- (UsbBot->BulkOutEndpoint == NULL)) {
-
- UsbBot->BulkOutEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *) (UsbBot + 1) + 1;
- CopyMem (UsbBot->BulkOutEndpoint, &EndPoint, sizeof(EndPoint));
+ (UsbBot->BulkOutEndpoint == NULL))
+ {
+ UsbBot->BulkOutEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *)(UsbBot + 1) + 1;
+ CopyMem (UsbBot->BulkOutEndpoint, &EndPoint, sizeof (EndPoint));
}
}
@@ -145,19 +145,19 @@ ON_ERROR:
**/
EFI_STATUS
UsbBotSendCommand (
- IN USB_BOT_PROTOCOL *UsbBot,
- IN UINT8 *Cmd,
- IN UINT8 CmdLen,
- IN EFI_USB_DATA_DIRECTION DataDir,
- IN UINT32 TransLen,
- IN UINT8 Lun
+ IN USB_BOT_PROTOCOL *UsbBot,
+ IN UINT8 *Cmd,
+ IN UINT8 CmdLen,
+ IN EFI_USB_DATA_DIRECTION DataDir,
+ IN UINT32 TransLen,
+ IN UINT8 Lun
)
{
- USB_BOT_CBW Cbw;
- EFI_STATUS Status;
- UINT32 Result;
- UINTN DataLen;
- UINTN Timeout;
+ USB_BOT_CBW Cbw;
+ EFI_STATUS Status;
+ UINT32 Result;
+ UINTN DataLen;
+ UINTN Timeout;
ASSERT ((CmdLen > 0) && (CmdLen <= USB_BOT_MAX_CMDLEN));
@@ -167,7 +167,7 @@ UsbBotSendCommand (
Cbw.Signature = USB_BOT_CBW_SIGNATURE;
Cbw.Tag = UsbBot->CbwTag;
Cbw.DataLen = TransLen;
- Cbw.Flag = (UINT8) ((DataDir == EfiUsbDataIn) ? BIT7 : 0);
+ Cbw.Flag = (UINT8)((DataDir == EfiUsbDataIn) ? BIT7 : 0);
Cbw.Lun = Lun;
Cbw.CmdLen = CmdLen;
@@ -190,7 +190,7 @@ UsbBotSendCommand (
&Result
);
if (EFI_ERROR (Status)) {
- if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL) && DataDir == EfiUsbDataOut) {
+ if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL) && (DataDir == EfiUsbDataOut)) {
//
// Respond to Bulk-Out endpoint stall with a Reset Recovery,
// according to section 5.3.1 of USB Mass Storage Class Bulk-Only Transport Spec, v1.0.
@@ -204,7 +204,6 @@ UsbBotSendCommand (
return Status;
}
-
/**
Transfer the data between the device and host.
@@ -226,16 +225,16 @@ UsbBotSendCommand (
**/
EFI_STATUS
UsbBotDataTransfer (
- IN USB_BOT_PROTOCOL *UsbBot,
- IN EFI_USB_DATA_DIRECTION DataDir,
- IN OUT UINT8 *Data,
- IN OUT UINTN *TransLen,
- IN UINT32 Timeout
+ IN USB_BOT_PROTOCOL *UsbBot,
+ IN EFI_USB_DATA_DIRECTION DataDir,
+ IN OUT UINT8 *Data,
+ IN OUT UINTN *TransLen,
+ IN UINT32 Timeout
)
{
- EFI_USB_ENDPOINT_DESCRIPTOR *Endpoint;
- EFI_STATUS Status;
- UINT32 Result;
+ EFI_USB_ENDPOINT_DESCRIPTOR *Endpoint;
+ EFI_STATUS Status;
+ UINT32 Result;
//
// If no data to transfer, just return EFI_SUCCESS.
@@ -274,15 +273,15 @@ UsbBotDataTransfer (
} else {
DEBUG ((DEBUG_ERROR, "UsbBotDataTransfer: (%r)\n", Status));
}
- if(Status == EFI_TIMEOUT){
- UsbBotResetDevice(UsbBot, FALSE);
+
+ if (Status == EFI_TIMEOUT) {
+ UsbBotResetDevice (UsbBot, FALSE);
}
}
return Status;
}
-
/**
Get the command execution status from device.
@@ -304,19 +303,19 @@ UsbBotDataTransfer (
**/
EFI_STATUS
UsbBotGetStatus (
- IN USB_BOT_PROTOCOL *UsbBot,
- IN UINT32 TransLen,
- OUT UINT8 *CmdStatus
+ IN USB_BOT_PROTOCOL *UsbBot,
+ IN UINT32 TransLen,
+ OUT UINT8 *CmdStatus
)
{
- USB_BOT_CSW Csw;
- UINTN Len;
- UINT8 Endpoint;
- EFI_STATUS Status;
- UINT32 Result;
- EFI_USB_IO_PROTOCOL *UsbIo;
- UINT32 Index;
- UINTN Timeout;
+ USB_BOT_CSW Csw;
+ UINTN Len;
+ UINT8 Endpoint;
+ EFI_STATUS Status;
+ UINT32 Result;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ UINT32 Index;
+ UINTN Timeout;
*CmdStatus = USB_BOT_COMMAND_ERROR;
Status = EFI_DEVICE_ERROR;
@@ -339,10 +338,11 @@ UsbBotGetStatus (
Timeout,
&Result
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL)) {
UsbClearEndpointStall (UsbIo, Endpoint);
}
+
continue;
}
@@ -361,15 +361,15 @@ UsbBotGetStatus (
break;
}
}
+
//
- //The tag is increased even if there is an error.
+ // The tag is increased even if there is an error.
//
UsbBot->CbwTag++;
return Status;
}
-
/**
Call the USB Mass Storage Class BOT protocol to issue
the command/data/status circle to execute the commands.
@@ -402,13 +402,13 @@ UsbBotExecCommand (
OUT UINT32 *CmdStatus
)
{
- USB_BOT_PROTOCOL *UsbBot;
- EFI_STATUS Status;
- UINTN TransLen;
- UINT8 Result;
+ USB_BOT_PROTOCOL *UsbBot;
+ EFI_STATUS Status;
+ UINTN TransLen;
+ UINT8 Result;
- *CmdStatus = USB_MASS_CMD_FAIL;
- UsbBot = (USB_BOT_PROTOCOL *) Context;
+ *CmdStatus = USB_MASS_CMD_FAIL;
+ UsbBot = (USB_BOT_PROTOCOL *)Context;
//
// Send the command to the device. Return immediately if device
@@ -425,7 +425,7 @@ UsbBotExecCommand (
// failed. The host should attempt to receive the CSW no matter
// whether it succeeds or fails.
//
- TransLen = (UINTN) DataLen;
+ TransLen = (UINTN)DataLen;
UsbBotDataTransfer (UsbBot, DataDir, Data, &TransLen, Timeout);
//
@@ -444,7 +444,6 @@ UsbBotExecCommand (
return EFI_SUCCESS;
}
-
/**
Reset the USB mass storage device by BOT protocol.
@@ -459,8 +458,8 @@ UsbBotExecCommand (
**/
EFI_STATUS
UsbBotResetDevice (
- IN VOID *Context,
- IN BOOLEAN ExtendedVerification
+ IN VOID *Context,
+ IN BOOLEAN ExtendedVerification
)
{
USB_BOT_PROTOCOL *UsbBot;
@@ -469,7 +468,7 @@ UsbBotResetDevice (
UINT32 Result;
UINT32 Timeout;
- UsbBot = (USB_BOT_PROTOCOL *) Context;
+ UsbBot = (USB_BOT_PROTOCOL *)Context;
if (ExtendedVerification) {
//
@@ -522,7 +521,6 @@ UsbBotResetDevice (
return Status;
}
-
/**
Get the max LUN (Logical Unit Number) of USB mass storage device.
@@ -536,8 +534,8 @@ UsbBotResetDevice (
**/
EFI_STATUS
UsbBotGetMaxLun (
- IN VOID *Context,
- OUT UINT8 *MaxLun
+ IN VOID *Context,
+ OUT UINT8 *MaxLun
)
{
USB_BOT_PROTOCOL *UsbBot;
@@ -546,11 +544,11 @@ UsbBotGetMaxLun (
UINT32 Result;
UINT32 Timeout;
- if (Context == NULL || MaxLun == NULL) {
+ if ((Context == NULL) || (MaxLun == NULL)) {
return EFI_INVALID_PARAMETER;
}
- UsbBot = (USB_BOT_PROTOCOL *) Context;
+ UsbBot = (USB_BOT_PROTOCOL *)Context;
//
// Issue a class specific Bulk-Only Mass Storage get max lun request.
@@ -568,11 +566,11 @@ UsbBotGetMaxLun (
&Request,
EfiUsbDataIn,
Timeout,
- (VOID *) MaxLun,
+ (VOID *)MaxLun,
1,
&Result
);
- if (EFI_ERROR (Status) || *MaxLun > USB_BOT_MAX_LUN) {
+ if (EFI_ERROR (Status) || (*MaxLun > USB_BOT_MAX_LUN)) {
//
// If the Get LUN request returns an error or the MaxLun is larger than
// the maximum LUN value (0x0f) supported by the USB Mass Storage Class
@@ -598,7 +596,7 @@ UsbBotGetMaxLun (
**/
EFI_STATUS
UsbBotCleanUp (
- IN VOID *Context
+ IN VOID *Context
)
{
FreePool (Context);
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.h b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.h
index 3ef8f24..cf8e9a3 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.h
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.h
@@ -11,29 +11,29 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _EFI_USBMASS_BOT_H_
#define _EFI_USBMASS_BOT_H_
-extern USB_MASS_TRANSPORT mUsbBotTransport;
+extern USB_MASS_TRANSPORT mUsbBotTransport;
//
// Usb Bulk-Only class specific request
//
-#define USB_BOT_RESET_REQUEST 0xFF ///< Bulk-Only Mass Storage Reset
-#define USB_BOT_GETLUN_REQUEST 0xFE ///< Get Max Lun
-#define USB_BOT_CBW_SIGNATURE 0x43425355 ///< dCBWSignature, tag the packet as CBW
-#define USB_BOT_CSW_SIGNATURE 0x53425355 ///< dCSWSignature, tag the packet as CSW
-#define USB_BOT_MAX_LUN 0x0F ///< Lun number is from 0 to 15
-#define USB_BOT_MAX_CMDLEN 16 ///< Maximum number of command from command set
+#define USB_BOT_RESET_REQUEST 0xFF ///< Bulk-Only Mass Storage Reset
+#define USB_BOT_GETLUN_REQUEST 0xFE ///< Get Max Lun
+#define USB_BOT_CBW_SIGNATURE 0x43425355 ///< dCBWSignature, tag the packet as CBW
+#define USB_BOT_CSW_SIGNATURE 0x53425355 ///< dCSWSignature, tag the packet as CSW
+#define USB_BOT_MAX_LUN 0x0F ///< Lun number is from 0 to 15
+#define USB_BOT_MAX_CMDLEN 16 ///< Maximum number of command from command set
//
// Usb BOT command block status values
//
-#define USB_BOT_COMMAND_OK 0x00 ///< Command passed, good status
-#define USB_BOT_COMMAND_FAILED 0x01 ///< Command failed
-#define USB_BOT_COMMAND_ERROR 0x02 ///< Phase error, need to reset the device
+#define USB_BOT_COMMAND_OK 0x00 ///< Command passed, good status
+#define USB_BOT_COMMAND_FAILED 0x01 ///< Command failed
+#define USB_BOT_COMMAND_ERROR 0x02 ///< Phase error, need to reset the device
//
// Usb Bot retry to get CSW, refers to specification[BOT10-5.3, it says 2 times]
//
-#define USB_BOT_RECV_CSW_RETRY 3
+#define USB_BOT_RECV_CSW_RETRY 3
//
// Usb Bot wait device reset complete, set by experience
@@ -43,32 +43,32 @@ extern USB_MASS_TRANSPORT mUsbBotTransport;
//
// Usb Bot transport timeout, set by experience
//
-#define USB_BOT_SEND_CBW_TIMEOUT (3 * USB_MASS_1_SECOND)
-#define USB_BOT_RECV_CSW_TIMEOUT (3 * USB_MASS_1_SECOND)
-#define USB_BOT_RESET_DEVICE_TIMEOUT (3 * USB_MASS_1_SECOND)
+#define USB_BOT_SEND_CBW_TIMEOUT (3 * USB_MASS_1_SECOND)
+#define USB_BOT_RECV_CSW_TIMEOUT (3 * USB_MASS_1_SECOND)
+#define USB_BOT_RESET_DEVICE_TIMEOUT (3 * USB_MASS_1_SECOND)
#pragma pack(1)
///
/// The CBW (Command Block Wrapper) structures used by the USB BOT protocol.
///
typedef struct {
- UINT32 Signature;
- UINT32 Tag;
- UINT32 DataLen; ///< Length of data between CBW and CSW
- UINT8 Flag; ///< Bit 7, 0 ~ Data-Out, 1 ~ Data-In
- UINT8 Lun; ///< Lun number. Bits 0~3 are used
- UINT8 CmdLen; ///< Length of the command. Bits 0~4 are used
- UINT8 CmdBlock[USB_BOT_MAX_CMDLEN];
+ UINT32 Signature;
+ UINT32 Tag;
+ UINT32 DataLen; ///< Length of data between CBW and CSW
+ UINT8 Flag; ///< Bit 7, 0 ~ Data-Out, 1 ~ Data-In
+ UINT8 Lun; ///< Lun number. Bits 0~3 are used
+ UINT8 CmdLen; ///< Length of the command. Bits 0~4 are used
+ UINT8 CmdBlock[USB_BOT_MAX_CMDLEN];
} USB_BOT_CBW;
///
/// The and CSW (Command Status Wrapper) structures used by the USB BOT protocol.
///
typedef struct {
- UINT32 Signature;
- UINT32 Tag;
- UINT32 DataResidue;
- UINT8 CmdStatus;
+ UINT32 Signature;
+ UINT32 Tag;
+ UINT32 DataResidue;
+ UINT8 CmdStatus;
} USB_BOT_CSW;
#pragma pack()
@@ -76,11 +76,11 @@ typedef struct {
//
// Put Interface at the first field to make it easy to distinguish BOT/CBI Protocol instance
//
- EFI_USB_INTERFACE_DESCRIPTOR Interface;
- EFI_USB_ENDPOINT_DESCRIPTOR *BulkInEndpoint;
- EFI_USB_ENDPOINT_DESCRIPTOR *BulkOutEndpoint;
- UINT32 CbwTag;
- EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_USB_INTERFACE_DESCRIPTOR Interface;
+ EFI_USB_ENDPOINT_DESCRIPTOR *BulkInEndpoint;
+ EFI_USB_ENDPOINT_DESCRIPTOR *BulkOutEndpoint;
+ UINT32 CbwTag;
+ EFI_USB_IO_PROTOCOL *UsbIo;
} USB_BOT_PROTOCOL;
/**
@@ -100,8 +100,8 @@ typedef struct {
**/
EFI_STATUS
UsbBotInit (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- OUT VOID **Context OPTIONAL
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ OUT VOID **Context OPTIONAL
);
/**
@@ -150,8 +150,8 @@ UsbBotExecCommand (
**/
EFI_STATUS
UsbBotResetDevice (
- IN VOID *Context,
- IN BOOLEAN ExtendedVerification
+ IN VOID *Context,
+ IN BOOLEAN ExtendedVerification
);
/**
@@ -167,8 +167,8 @@ UsbBotResetDevice (
**/
EFI_STATUS
UsbBotGetMaxLun (
- IN VOID *Context,
- OUT UINT8 *MaxLun
+ IN VOID *Context,
+ OUT UINT8 *MaxLun
);
/**
@@ -181,7 +181,7 @@ UsbBotGetMaxLun (
**/
EFI_STATUS
UsbBotCleanUp (
- IN VOID *Context
+ IN VOID *Context
);
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.c
index 423104f..05903a5 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.c
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.c
@@ -14,7 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Definition of USB CBI0 Transport Protocol
//
-USB_MASS_TRANSPORT mUsbCbi0Transport = {
+USB_MASS_TRANSPORT mUsbCbi0Transport = {
USB_MASS_STORE_CBI0,
UsbCbiInit,
UsbCbiExecCommand,
@@ -26,7 +26,7 @@ USB_MASS_TRANSPORT mUsbCbi0Transport = {
//
// Definition of USB CBI1 Transport Protocol
//
-USB_MASS_TRANSPORT mUsbCbi1Transport = {
+USB_MASS_TRANSPORT mUsbCbi1Transport = {
USB_MASS_STORE_CBI1,
UsbCbiInit,
UsbCbiExecCommand,
@@ -52,8 +52,8 @@ USB_MASS_TRANSPORT mUsbCbi1Transport = {
**/
EFI_STATUS
UsbCbiInit (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- OUT VOID **Context OPTIONAL
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ OUT VOID **Context OPTIONAL
)
{
USB_CBI_PROTOCOL *UsbCbi;
@@ -82,8 +82,9 @@ UsbCbiInit (
}
Interface = &UsbCbi->Interface;
- if ((Interface->InterfaceProtocol != USB_MASS_STORE_CBI0)
- && (Interface->InterfaceProtocol != USB_MASS_STORE_CBI1)) {
+ if ( (Interface->InterfaceProtocol != USB_MASS_STORE_CBI0)
+ && (Interface->InterfaceProtocol != USB_MASS_STORE_CBI1))
+ {
Status = EFI_UNSUPPORTED;
goto ON_ERROR;
}
@@ -102,27 +103,27 @@ UsbCbiInit (
// Use the first Bulk-In and Bulk-Out endpoints
//
if (USB_IS_IN_ENDPOINT (EndPoint.EndpointAddress) &&
- (UsbCbi->BulkInEndpoint == NULL)) {
-
- UsbCbi->BulkInEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *) (UsbCbi + 1);
- CopyMem(UsbCbi->BulkInEndpoint, &EndPoint, sizeof (EndPoint));;
+ (UsbCbi->BulkInEndpoint == NULL))
+ {
+ UsbCbi->BulkInEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *)(UsbCbi + 1);
+ CopyMem (UsbCbi->BulkInEndpoint, &EndPoint, sizeof (EndPoint));
}
if (USB_IS_OUT_ENDPOINT (EndPoint.EndpointAddress) &&
- (UsbCbi->BulkOutEndpoint == NULL)) {
-
- UsbCbi->BulkOutEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *) (UsbCbi + 1) + 1;
- CopyMem(UsbCbi->BulkOutEndpoint, &EndPoint, sizeof (EndPoint));
+ (UsbCbi->BulkOutEndpoint == NULL))
+ {
+ UsbCbi->BulkOutEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *)(UsbCbi + 1) + 1;
+ CopyMem (UsbCbi->BulkOutEndpoint, &EndPoint, sizeof (EndPoint));
}
} else if (USB_IS_INTERRUPT_ENDPOINT (EndPoint.Attributes)) {
//
// Use the first interrupt endpoint if it is CBI0
//
if ((Interface->InterfaceProtocol == USB_MASS_STORE_CBI0) &&
- (UsbCbi->InterruptEndpoint == NULL)) {
-
- UsbCbi->InterruptEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *) (UsbCbi + 1) + 2;
- CopyMem(UsbCbi->InterruptEndpoint, &EndPoint, sizeof (EndPoint));
+ (UsbCbi->InterruptEndpoint == NULL))
+ {
+ UsbCbi->InterruptEndpoint = (EFI_USB_ENDPOINT_DESCRIPTOR *)(UsbCbi + 1) + 2;
+ CopyMem (UsbCbi->InterruptEndpoint, &EndPoint, sizeof (EndPoint));
}
}
}
@@ -131,6 +132,7 @@ UsbCbiInit (
Status = EFI_UNSUPPORTED;
goto ON_ERROR;
}
+
if ((Interface->InterfaceProtocol == USB_MASS_STORE_CBI0) && (UsbCbi->InterruptEndpoint == NULL)) {
Status = EFI_UNSUPPORTED;
goto ON_ERROR;
@@ -166,10 +168,10 @@ ON_ERROR:
**/
EFI_STATUS
UsbCbiSendCommand (
- IN USB_CBI_PROTOCOL *UsbCbi,
- IN UINT8 *Cmd,
- IN UINT8 CmdLen,
- IN UINT32 Timeout
+ IN USB_CBI_PROTOCOL *UsbCbi,
+ IN UINT8 *Cmd,
+ IN UINT8 CmdLen,
+ IN UINT32 Timeout
)
{
EFI_USB_DEVICE_REQUEST Request;
@@ -188,8 +190,8 @@ UsbCbiSendCommand (
Request.Index = UsbCbi->Interface.InterfaceNumber;
Request.Length = CmdLen;
- Status = EFI_SUCCESS;
- Timeout = Timeout / USB_MASS_1_MILLISECOND;
+ Status = EFI_SUCCESS;
+ Timeout = Timeout / USB_MASS_1_MILLISECOND;
for (Retry = 0; Retry < USB_CBI_MAX_RETRY; Retry++) {
//
@@ -223,7 +225,6 @@ UsbCbiSendCommand (
return Status;
}
-
/**
Transfer data between the device and host.
@@ -244,20 +245,20 @@ UsbCbiSendCommand (
**/
EFI_STATUS
UsbCbiDataTransfer (
- IN USB_CBI_PROTOCOL *UsbCbi,
- IN EFI_USB_DATA_DIRECTION DataDir,
- IN OUT UINT8 *Data,
- IN OUT UINTN *TransLen,
- IN UINT32 Timeout
+ IN USB_CBI_PROTOCOL *UsbCbi,
+ IN EFI_USB_DATA_DIRECTION DataDir,
+ IN OUT UINT8 *Data,
+ IN OUT UINTN *TransLen,
+ IN UINT32 Timeout
)
{
- EFI_USB_ENDPOINT_DESCRIPTOR *Endpoint;
- EFI_STATUS Status;
- UINT32 TransStatus;
- UINTN Remain;
- UINTN Increment;
- UINT8 *Next;
- UINTN Retry;
+ EFI_USB_ENDPOINT_DESCRIPTOR *Endpoint;
+ EFI_STATUS Status;
+ UINT32 TransStatus;
+ UINTN Remain;
+ UINTN Increment;
+ UINT8 *Next;
+ UINTN Retry;
//
// If no data to transfer, just return EFI_SUCCESS.
@@ -287,7 +288,7 @@ UsbCbiDataTransfer (
while (Remain > 0) {
TransStatus = 0;
- if (Remain > (UINTN) USB_CBI_MAX_PACKET_NUM * Endpoint->MaxPacketSize) {
+ if (Remain > (UINTN)USB_CBI_MAX_PACKET_NUM * Endpoint->MaxPacketSize) {
Increment = USB_CBI_MAX_PACKET_NUM * Endpoint->MaxPacketSize;
} else {
Increment = Remain;
@@ -334,7 +335,7 @@ UsbCbiDataTransfer (
goto ON_EXIT;
}
- Next += Increment;
+ Next += Increment;
Remain -= Increment;
}
@@ -343,7 +344,6 @@ ON_EXIT:
return Status;
}
-
/**
Gets the result of high level command execution from interrupt endpoint.
@@ -362,20 +362,20 @@ ON_EXIT:
**/
EFI_STATUS
UsbCbiGetStatus (
- IN USB_CBI_PROTOCOL *UsbCbi,
- IN UINT32 Timeout,
- OUT USB_CBI_STATUS *Result
+ IN USB_CBI_PROTOCOL *UsbCbi,
+ IN UINT32 Timeout,
+ OUT USB_CBI_STATUS *Result
)
{
- UINTN Len;
- UINT8 Endpoint;
- EFI_STATUS Status;
- UINT32 TransStatus;
- INTN Retry;
+ UINTN Len;
+ UINT8 Endpoint;
+ EFI_STATUS Status;
+ UINT32 TransStatus;
+ INTN Retry;
- Endpoint = UsbCbi->InterruptEndpoint->EndpointAddress;
- Status = EFI_SUCCESS;
- Timeout = Timeout / USB_MASS_1_MILLISECOND;
+ Endpoint = UsbCbi->InterruptEndpoint->EndpointAddress;
+ Status = EFI_SUCCESS;
+ Timeout = Timeout / USB_MASS_1_MILLISECOND;
//
// Attempt to the read the result from interrupt endpoint
@@ -405,7 +405,6 @@ UsbCbiGetStatus (
return Status;
}
-
/**
Execute USB mass storage command through the CBI0/CBI1 transport protocol.
@@ -436,13 +435,13 @@ UsbCbiExecCommand (
OUT UINT32 *CmdStatus
)
{
- USB_CBI_PROTOCOL *UsbCbi;
- USB_CBI_STATUS Result;
- EFI_STATUS Status;
- UINTN TransLen;
+ USB_CBI_PROTOCOL *UsbCbi;
+ USB_CBI_STATUS Result;
+ EFI_STATUS Status;
+ UINTN TransLen;
- *CmdStatus = USB_MASS_CMD_SUCCESS;
- UsbCbi = (USB_CBI_PROTOCOL *) Context;
+ *CmdStatus = USB_MASS_CMD_SUCCESS;
+ UsbCbi = (USB_CBI_PROTOCOL *)Context;
//
// Send the command to the device. Return immediately if device
@@ -450,8 +449,8 @@ UsbCbiExecCommand (
//
Status = UsbCbiSendCommand (UsbCbi, Cmd, CmdLen, Timeout);
if (EFI_ERROR (Status)) {
- gBS->Stall(10 * USB_MASS_1_MILLISECOND);
- DEBUG ((DEBUG_ERROR, "UsbCbiExecCommand: UsbCbiSendCommand (%r)\n",Status));
+ gBS->Stall (10 * USB_MASS_1_MILLISECOND);
+ DEBUG ((DEBUG_ERROR, "UsbCbiExecCommand: UsbCbiSendCommand (%r)\n", Status));
return Status;
}
@@ -459,11 +458,11 @@ UsbCbiExecCommand (
// Transfer the data. Return this status if no interrupt endpoint
// is used to report the transfer status.
//
- TransLen = (UINTN) DataLen;
+ TransLen = (UINTN)DataLen;
- Status = UsbCbiDataTransfer (UsbCbi, DataDir, Data, &TransLen, Timeout);
+ Status = UsbCbiDataTransfer (UsbCbi, DataDir, Data, &TransLen, Timeout);
if (UsbCbi->InterruptEndpoint == NULL) {
- DEBUG ((DEBUG_ERROR, "UsbCbiExecCommand: UsbCbiDataTransfer (%r)\n",Status));
+ DEBUG ((DEBUG_ERROR, "UsbCbiExecCommand: UsbCbiDataTransfer (%r)\n", Status));
return Status;
}
@@ -472,7 +471,7 @@ UsbCbiExecCommand (
//
Status = UsbCbiGetStatus (UsbCbi, Timeout, &Result);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "UsbCbiExecCommand: UsbCbiGetStatus (%r)\n",Status));
+ DEBUG ((DEBUG_ERROR, "UsbCbiExecCommand: UsbCbiGetStatus (%r)\n", Status));
return Status;
}
@@ -483,7 +482,7 @@ UsbCbiExecCommand (
// Do not set the USB_MASS_CMD_FAIL for a request sense command
// as a bad result type doesn't mean a cmd failure
//
- if (Result.Type != 0 && *(UINT8*)Cmd != 0x03) {
+ if ((Result.Type != 0) && (*(UINT8 *)Cmd != 0x03)) {
*CmdStatus = USB_MASS_CMD_FAIL;
}
} else {
@@ -491,40 +490,39 @@ UsbCbiExecCommand (
// Check page 27, CBI spec 1.1 for vaious reture status.
//
switch (Result.Value & 0x03) {
- case 0x00:
- //
- // Pass
- //
- *CmdStatus = USB_MASS_CMD_SUCCESS;
- break;
+ case 0x00:
+ //
+ // Pass
+ //
+ *CmdStatus = USB_MASS_CMD_SUCCESS;
+ break;
- case 0x02:
- //
- // Phase Error, response with reset.
- // No break here to fall through to "Fail".
- //
- UsbCbiResetDevice (UsbCbi, FALSE);
+ case 0x02:
+ //
+ // Phase Error, response with reset.
+ // No break here to fall through to "Fail".
+ //
+ UsbCbiResetDevice (UsbCbi, FALSE);
- case 0x01:
- //
- // Fail
- //
- *CmdStatus = USB_MASS_CMD_FAIL;
- break;
+ case 0x01:
+ //
+ // Fail
+ //
+ *CmdStatus = USB_MASS_CMD_FAIL;
+ break;
- case 0x03:
- //
- // Persistent Fail. Need to send REQUEST SENSE.
- //
- *CmdStatus = USB_MASS_CMD_PERSISTENT;
- break;
+ case 0x03:
+ //
+ // Persistent Fail. Need to send REQUEST SENSE.
+ //
+ *CmdStatus = USB_MASS_CMD_PERSISTENT;
+ break;
}
}
return EFI_SUCCESS;
}
-
/**
Reset the USB mass storage device by CBI protocol.
@@ -542,17 +540,17 @@ UsbCbiExecCommand (
**/
EFI_STATUS
UsbCbiResetDevice (
- IN VOID *Context,
- IN BOOLEAN ExtendedVerification
+ IN VOID *Context,
+ IN BOOLEAN ExtendedVerification
)
{
- UINT8 ResetCmd[USB_CBI_RESET_CMD_LEN];
- USB_CBI_PROTOCOL *UsbCbi;
- USB_CBI_STATUS Result;
- EFI_STATUS Status;
- UINT32 Timeout;
+ UINT8 ResetCmd[USB_CBI_RESET_CMD_LEN];
+ USB_CBI_PROTOCOL *UsbCbi;
+ USB_CBI_STATUS Result;
+ EFI_STATUS Status;
+ UINT32 Timeout;
- UsbCbi = (USB_CBI_PROTOCOL *) Context;
+ UsbCbi = (USB_CBI_PROTOCOL *)Context;
//
// Fill in the reset command.
@@ -587,7 +585,6 @@ UsbCbiResetDevice (
return Status;
}
-
/**
Clean up the CBI protocol's resource.
@@ -598,7 +595,7 @@ UsbCbiResetDevice (
**/
EFI_STATUS
UsbCbiCleanUp (
- IN VOID *Context
+ IN VOID *Context
)
{
FreePool (Context);
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.h b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.h
index b79b9c2..8aca913 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.h
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.h
@@ -10,19 +10,19 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _EFI_USBMASS_CBI_H_
#define _EFI_USBMASS_CBI_H_
-extern USB_MASS_TRANSPORT mUsbCbi0Transport;
-extern USB_MASS_TRANSPORT mUsbCbi1Transport;
+extern USB_MASS_TRANSPORT mUsbCbi0Transport;
+extern USB_MASS_TRANSPORT mUsbCbi1Transport;
-#define USB_CBI_MAX_PACKET_NUM 16
-#define USB_CBI_RESET_CMD_LEN 12
+#define USB_CBI_MAX_PACKET_NUM 16
+#define USB_CBI_RESET_CMD_LEN 12
//
// USB CBI retry C/B/I transport times, set by experience
//
-#define USB_CBI_MAX_RETRY 3
+#define USB_CBI_MAX_RETRY 3
//
// Time to wait for USB CBI reset to complete, set by experience
//
-#define USB_CBI_RESET_DEVICE_STALL (50 * USB_MASS_1_MILLISECOND)
+#define USB_CBI_RESET_DEVICE_STALL (50 * USB_MASS_1_MILLISECOND)
//
// USB CBI transport timeout, set by experience
//
@@ -32,17 +32,17 @@ typedef struct {
//
// Put Interface at the first field to make it easy to distinguish BOT/CBI Protocol instance
//
- EFI_USB_INTERFACE_DESCRIPTOR Interface;
- EFI_USB_ENDPOINT_DESCRIPTOR *BulkInEndpoint;
- EFI_USB_ENDPOINT_DESCRIPTOR *BulkOutEndpoint;
- EFI_USB_ENDPOINT_DESCRIPTOR *InterruptEndpoint;
- EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_USB_INTERFACE_DESCRIPTOR Interface;
+ EFI_USB_ENDPOINT_DESCRIPTOR *BulkInEndpoint;
+ EFI_USB_ENDPOINT_DESCRIPTOR *BulkOutEndpoint;
+ EFI_USB_ENDPOINT_DESCRIPTOR *InterruptEndpoint;
+ EFI_USB_IO_PROTOCOL *UsbIo;
} USB_CBI_PROTOCOL;
#pragma pack(1)
typedef struct {
- UINT8 Type;
- UINT8 Value;
+ UINT8 Type;
+ UINT8 Value;
} USB_CBI_STATUS;
#pragma pack()
@@ -63,8 +63,8 @@ typedef struct {
**/
EFI_STATUS
UsbCbiInit (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- OUT VOID **Context OPTIONAL
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ OUT VOID **Context OPTIONAL
);
/**
@@ -114,8 +114,8 @@ UsbCbiExecCommand (
**/
EFI_STATUS
UsbCbiResetDevice (
- IN VOID *Context,
- IN BOOLEAN ExtendedVerification
+ IN VOID *Context,
+ IN BOOLEAN ExtendedVerification
);
/**
@@ -128,7 +128,7 @@ UsbCbiResetDevice (
**/
EFI_STATUS
UsbCbiCleanUp (
- IN VOID *Context
+ IN VOID *Context
);
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassDiskInfo.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassDiskInfo.c
index 44e1d0c..5620608 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassDiskInfo.c
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassDiskInfo.c
@@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "UsbMass.h"
-EFI_DISK_INFO_PROTOCOL gUsbDiskInfoProtocolTemplate = {
+EFI_DISK_INFO_PROTOCOL gUsbDiskInfoProtocolTemplate = {
EFI_DISK_INFO_USB_INTERFACE_GUID,
UsbDiskInfoInquiry,
UsbDiskInfoIdentify,
@@ -27,13 +27,12 @@ EFI_DISK_INFO_PROTOCOL gUsbDiskInfoProtocolTemplate = {
**/
VOID
InitializeDiskInfo (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
)
{
CopyMem (&UsbMass->DiskInfo, &gUsbDiskInfoProtocolTemplate, sizeof (gUsbDiskInfoProtocolTemplate));
}
-
/**
Provides inquiry information for the controller type.
@@ -53,26 +52,26 @@ InitializeDiskInfo (
EFI_STATUS
EFIAPI
UsbDiskInfoInquiry (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *InquiryData,
- IN OUT UINT32 *InquiryDataSize
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *InquiryData,
+ IN OUT UINT32 *InquiryDataSize
)
{
- EFI_STATUS Status;
- USB_MASS_DEVICE *UsbMass;
+ EFI_STATUS Status;
+ USB_MASS_DEVICE *UsbMass;
- UsbMass = USB_MASS_DEVICE_FROM_DISK_INFO (This);
+ UsbMass = USB_MASS_DEVICE_FROM_DISK_INFO (This);
Status = EFI_BUFFER_TOO_SMALL;
if (*InquiryDataSize >= sizeof (UsbMass->InquiryData)) {
Status = EFI_SUCCESS;
CopyMem (InquiryData, &UsbMass->InquiryData, sizeof (UsbMass->InquiryData));
}
+
*InquiryDataSize = sizeof (UsbMass->InquiryData);
return Status;
}
-
/**
Provides identify information for the controller type.
@@ -94,9 +93,9 @@ UsbDiskInfoInquiry (
EFI_STATUS
EFIAPI
UsbDiskInfoIdentify (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *IdentifyData,
- IN OUT UINT32 *IdentifyDataSize
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *IdentifyData,
+ IN OUT UINT32 *IdentifyDataSize
)
{
return EFI_NOT_FOUND;
@@ -122,16 +121,15 @@ UsbDiskInfoIdentify (
EFI_STATUS
EFIAPI
UsbDiskInfoSenseData (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *SenseData,
- IN OUT UINT32 *SenseDataSize,
- OUT UINT8 *SenseDataNumber
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *SenseData,
+ IN OUT UINT32 *SenseDataSize,
+ OUT UINT8 *SenseDataNumber
)
{
return EFI_NOT_FOUND;
}
-
/**
This function is used to get controller information.
@@ -146,11 +144,10 @@ UsbDiskInfoSenseData (
EFI_STATUS
EFIAPI
UsbDiskInfoWhichIde (
- IN EFI_DISK_INFO_PROTOCOL *This,
- OUT UINT32 *IdeChannel,
- OUT UINT32 *IdeDevice
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ OUT UINT32 *IdeChannel,
+ OUT UINT32 *IdeDevice
)
{
return EFI_UNSUPPORTED;
}
-
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassDiskInfo.h b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassDiskInfo.h
index 2571cc5..4ada890 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassDiskInfo.h
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassDiskInfo.h
@@ -20,10 +20,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
VOID
InitializeDiskInfo (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
);
-
/**
Provides inquiry information for the controller type.
@@ -43,9 +42,9 @@ InitializeDiskInfo (
EFI_STATUS
EFIAPI
UsbDiskInfoInquiry (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *InquiryData,
- IN OUT UINT32 *InquiryDataSize
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *InquiryData,
+ IN OUT UINT32 *InquiryDataSize
);
/**
@@ -69,9 +68,9 @@ UsbDiskInfoInquiry (
EFI_STATUS
EFIAPI
UsbDiskInfoIdentify (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *IdentifyData,
- IN OUT UINT32 *IdentifyDataSize
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *IdentifyData,
+ IN OUT UINT32 *IdentifyDataSize
);
/**
@@ -94,13 +93,12 @@ UsbDiskInfoIdentify (
EFI_STATUS
EFIAPI
UsbDiskInfoSenseData (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *SenseData,
- IN OUT UINT32 *SenseDataSize,
- OUT UINT8 *SenseDataNumber
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *SenseData,
+ IN OUT UINT32 *SenseDataSize,
+ OUT UINT8 *SenseDataNumber
);
-
/**
This function is used to get controller information.
@@ -115,9 +113,9 @@ UsbDiskInfoSenseData (
EFI_STATUS
EFIAPI
UsbDiskInfoWhichIde (
- IN EFI_DISK_INFO_PROTOCOL *This,
- OUT UINT32 *IdeChannel,
- OUT UINT32 *IdeDevice
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ OUT UINT32 *IdeChannel,
+ OUT UINT32 *IdeDevice
);
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c
index de9c5f0..9c5fd4e 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c
@@ -8,17 +8,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "UsbMass.h"
-#define USB_MASS_TRANSPORT_COUNT 3
+#define USB_MASS_TRANSPORT_COUNT 3
//
// Array of USB transport interfaces.
//
-USB_MASS_TRANSPORT *mUsbMassTransport[USB_MASS_TRANSPORT_COUNT] = {
+USB_MASS_TRANSPORT *mUsbMassTransport[USB_MASS_TRANSPORT_COUNT] = {
&mUsbCbi0Transport,
&mUsbCbi1Transport,
&mUsbBotTransport,
};
-EFI_DRIVER_BINDING_PROTOCOL gUSBMassDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gUSBMassDriverBinding = {
USBMassDriverBindingSupported,
USBMassDriverBindingStart,
USBMassDriverBindingStop,
@@ -45,19 +45,19 @@ EFI_DRIVER_BINDING_PROTOCOL gUSBMassDriverBinding = {
EFI_STATUS
EFIAPI
UsbMassReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- USB_MASS_DEVICE *UsbMass;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
+ USB_MASS_DEVICE *UsbMass;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
//
// Raise TPL to TPL_CALLBACK to serialize all its operations
// to protect shared data structures.
//
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
UsbMass = USB_MASS_DEVICE_FROM_BLOCK_IO (This);
Status = UsbMass->Transport->Reset (UsbMass->Context, ExtendedVerification);
@@ -94,11 +94,11 @@ UsbMassReset (
EFI_STATUS
EFIAPI
UsbMassReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
)
{
USB_MASS_DEVICE *UsbMass;
@@ -168,7 +168,7 @@ UsbMassReadBlocks (
if (UsbMass->Cdb16Byte) {
Status = UsbBootReadWriteBlocks16 (UsbMass, FALSE, Lba, TotalBlock, Buffer);
} else {
- Status = UsbBootReadWriteBlocks (UsbMass, FALSE, (UINT32) Lba, TotalBlock, Buffer);
+ Status = UsbBootReadWriteBlocks (UsbMass, FALSE, (UINT32)Lba, TotalBlock, Buffer);
}
if (EFI_ERROR (Status)) {
@@ -181,7 +181,6 @@ ON_EXIT:
return Status;
}
-
/**
Writes a specified number of blocks to the device.
@@ -210,11 +209,11 @@ ON_EXIT:
EFI_STATUS
EFIAPI
UsbMassWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
USB_MASS_DEVICE *UsbMass;
@@ -288,7 +287,7 @@ UsbMassWriteBlocks (
if (UsbMass->Cdb16Byte) {
Status = UsbBootReadWriteBlocks16 (UsbMass, TRUE, Lba, TotalBlock, Buffer);
} else {
- Status = UsbBootReadWriteBlocks (UsbMass, TRUE, (UINT32) Lba, TotalBlock, Buffer);
+ Status = UsbBootReadWriteBlocks (UsbMass, TRUE, (UINT32)Lba, TotalBlock, Buffer);
}
if (EFI_ERROR (Status)) {
@@ -335,11 +334,11 @@ UsbMassFlushBlocks (
**/
EFI_STATUS
UsbMassInitMedia (
- IN USB_MASS_DEVICE *UsbMass
+ IN USB_MASS_DEVICE *UsbMass
)
{
- EFI_BLOCK_IO_MEDIA *Media;
- EFI_STATUS Status;
+ EFI_BLOCK_IO_MEDIA *Media;
+ EFI_STATUS Status;
Media = &UsbMass->BlockIoMedia;
@@ -363,6 +362,7 @@ UsbMassInitMedia (
//
Status = EFI_SUCCESS;
}
+
return Status;
}
@@ -400,7 +400,7 @@ UsbMassInitTransport (
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
+ (VOID **)&UsbIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -427,7 +427,7 @@ UsbMassInitTransport (
*Transport = mUsbMassTransport[Index];
if (Interface.InterfaceProtocol == (*Transport)->Protocol) {
- Status = (*Transport)->Init (UsbIo, Context);
+ Status = (*Transport)->Init (UsbIo, Context);
break;
}
}
@@ -471,12 +471,12 @@ ON_EXIT:
**/
EFI_STATUS
UsbMassInitMultiLun (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN USB_MASS_TRANSPORT *Transport,
- IN VOID *Context,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN UINT8 MaxLun
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN USB_MASS_TRANSPORT *Transport,
+ IN VOID *Context,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN UINT8 MaxLun
)
{
USB_MASS_DEVICE *UsbMass;
@@ -490,24 +490,23 @@ UsbMassInitMultiLun (
ReturnStatus = EFI_NOT_FOUND;
for (Index = 0; Index <= MaxLun; Index++) {
-
DEBUG ((DEBUG_INFO, "UsbMassInitMultiLun: Start to initialize No.%d logic unit\n", Index));
UsbIo = NULL;
UsbMass = AllocateZeroPool (sizeof (USB_MASS_DEVICE));
ASSERT (UsbMass != NULL);
- UsbMass->Signature = USB_MASS_SIGNATURE;
- UsbMass->UsbIo = UsbIo;
- UsbMass->BlockIo.Media = &UsbMass->BlockIoMedia;
- UsbMass->BlockIo.Reset = UsbMassReset;
- UsbMass->BlockIo.ReadBlocks = UsbMassReadBlocks;
- UsbMass->BlockIo.WriteBlocks = UsbMassWriteBlocks;
- UsbMass->BlockIo.FlushBlocks = UsbMassFlushBlocks;
- UsbMass->OpticalStorage = FALSE;
- UsbMass->Transport = Transport;
- UsbMass->Context = Context;
- UsbMass->Lun = Index;
+ UsbMass->Signature = USB_MASS_SIGNATURE;
+ UsbMass->UsbIo = UsbIo;
+ UsbMass->BlockIo.Media = &UsbMass->BlockIoMedia;
+ UsbMass->BlockIo.Reset = UsbMassReset;
+ UsbMass->BlockIo.ReadBlocks = UsbMassReadBlocks;
+ UsbMass->BlockIo.WriteBlocks = UsbMassWriteBlocks;
+ UsbMass->BlockIo.FlushBlocks = UsbMassFlushBlocks;
+ UsbMass->OpticalStorage = FALSE;
+ UsbMass->Transport = Transport;
+ UsbMass->Context = Context;
+ UsbMass->Lun = Index;
//
// Initialize the media parameter data for EFI_BLOCK_IO_MEDIA of Block I/O Protocol.
@@ -566,7 +565,7 @@ UsbMassInitMultiLun (
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
+ (VOID **)&UsbIo,
This->DriverBindingHandle,
UsbMass->Controller,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -588,6 +587,7 @@ UsbMassInitMultiLun (
FreePool (UsbMass);
continue;
}
+
ReturnStatus = EFI_SUCCESS;
DEBUG ((DEBUG_INFO, "UsbMassInitMultiLun: Success to initialize No.%d logic unit\n", Index));
}
@@ -609,15 +609,15 @@ UsbMassInitMultiLun (
**/
EFI_STATUS
UsbMassInitNonLun (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN USB_MASS_TRANSPORT *Transport,
- IN VOID *Context
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN USB_MASS_TRANSPORT *Transport,
+ IN VOID *Context
)
{
- USB_MASS_DEVICE *UsbMass;
- EFI_USB_IO_PROTOCOL *UsbIo;
- EFI_STATUS Status;
+ USB_MASS_DEVICE *UsbMass;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_STATUS Status;
UsbIo = NULL;
UsbMass = AllocateZeroPool (sizeof (USB_MASS_DEVICE));
@@ -626,7 +626,7 @@ UsbMassInitNonLun (
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
+ (VOID **)&UsbIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -637,17 +637,17 @@ UsbMassInitNonLun (
goto ON_ERROR;
}
- UsbMass->Signature = USB_MASS_SIGNATURE;
- UsbMass->Controller = Controller;
- UsbMass->UsbIo = UsbIo;
- UsbMass->BlockIo.Media = &UsbMass->BlockIoMedia;
- UsbMass->BlockIo.Reset = UsbMassReset;
- UsbMass->BlockIo.ReadBlocks = UsbMassReadBlocks;
- UsbMass->BlockIo.WriteBlocks = UsbMassWriteBlocks;
- UsbMass->BlockIo.FlushBlocks = UsbMassFlushBlocks;
- UsbMass->OpticalStorage = FALSE;
- UsbMass->Transport = Transport;
- UsbMass->Context = Context;
+ UsbMass->Signature = USB_MASS_SIGNATURE;
+ UsbMass->Controller = Controller;
+ UsbMass->UsbIo = UsbIo;
+ UsbMass->BlockIo.Media = &UsbMass->BlockIoMedia;
+ UsbMass->BlockIo.Reset = UsbMassReset;
+ UsbMass->BlockIo.ReadBlocks = UsbMassReadBlocks;
+ UsbMass->BlockIo.WriteBlocks = UsbMassWriteBlocks;
+ UsbMass->BlockIo.FlushBlocks = UsbMassFlushBlocks;
+ UsbMass->OpticalStorage = FALSE;
+ UsbMass->Transport = Transport;
+ UsbMass->Context = Context;
//
// Initialize the media parameter data for EFI_BLOCK_IO_MEDIA of Block I/O Protocol.
@@ -678,6 +678,7 @@ ON_ERROR:
if (UsbMass != NULL) {
FreePool (UsbMass);
}
+
if (UsbIo != NULL) {
gBS->CloseProtocol (
Controller,
@@ -686,10 +687,10 @@ ON_ERROR:
Controller
);
}
+
return Status;
}
-
/**
Check whether the controller is a supported USB mass storage.
@@ -718,7 +719,7 @@ USBMassDriverBindingSupported (
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
+ (VOID **)&UsbIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -793,13 +794,13 @@ USBMassDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- USB_MASS_TRANSPORT *Transport;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- VOID *Context;
- UINT8 MaxLun;
- EFI_STATUS Status;
- EFI_USB_IO_PROTOCOL *UsbIo;
- EFI_TPL OldTpl;
+ USB_MASS_TRANSPORT *Transport;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ VOID *Context;
+ UINT8 MaxLun;
+ EFI_STATUS Status;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@@ -813,6 +814,7 @@ USBMassDriverBindingStart (
DEBUG ((DEBUG_ERROR, "USBMassDriverBindingStart: UsbMassInitTransport (%r)\n", Status));
goto Exit;
}
+
if (MaxLun == 0) {
//
// Initialize data for device that does not support multiple LUNSs.
@@ -828,7 +830,7 @@ USBMassDriverBindingStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath,
+ (VOID **)&DevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -842,7 +844,7 @@ USBMassDriverBindingStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
+ (VOID **)&UsbIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -866,26 +868,26 @@ USBMassDriverBindingStart (
Status = UsbMassInitMultiLun (This, Controller, Transport, Context, DevicePath, MaxLun);
if (EFI_ERROR (Status)) {
gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
gBS->CloseProtocol (
- Controller,
- &gEfiUsbIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiUsbIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
DEBUG ((DEBUG_ERROR, "USBMassDriverBindingStart: UsbMassInitMultiLun (%r) with Maxlun=%d\n", Status, MaxLun));
}
}
+
Exit:
gBS->RestoreTPL (OldTpl);
return Status;
}
-
/**
Stop controlling the device.
@@ -903,18 +905,18 @@ Exit:
EFI_STATUS
EFIAPI
USBMassDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_STATUS Status;
- USB_MASS_DEVICE *UsbMass;
- EFI_USB_IO_PROTOCOL *UsbIo;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- UINTN Index;
- BOOLEAN AllChildrenStopped;
+ EFI_STATUS Status;
+ USB_MASS_DEVICE *UsbMass;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ UINTN Index;
+ BOOLEAN AllChildrenStopped;
//
// This is a bus driver stop function since multi-lun is supported.
@@ -930,29 +932,29 @@ USBMassDriverBindingStop (
Status = gBS->OpenProtocol (
Controller,
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
+ (VOID **)&BlockIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
//
// This is a 2nd type handle(multi-lun root), it needs to close devicepath
// and usbio protocol.
//
gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
gBS->CloseProtocol (
- Controller,
- &gEfiUsbIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiUsbIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
DEBUG ((DEBUG_INFO, "Success to stop multi-lun root handle\n"));
return EFI_SUCCESS;
}
@@ -980,11 +982,11 @@ USBMassDriverBindingStop (
}
gBS->CloseProtocol (
- Controller,
- &gEfiUsbIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiUsbIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
UsbMass->Transport->CleanUp (UsbMass->Context);
FreePool (UsbMass);
@@ -1001,11 +1003,10 @@ USBMassDriverBindingStop (
AllChildrenStopped = TRUE;
for (Index = 0; Index < NumberOfChildren; Index++) {
-
Status = gBS->OpenProtocol (
ChildHandleBuffer[Index],
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
+ (VOID **)&BlockIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1046,7 +1047,7 @@ USBMassDriverBindingStop (
gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
+ (VOID **)&UsbIo,
This->DriverBindingHandle,
ChildHandleBuffer[Index],
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -1058,6 +1059,7 @@ USBMassDriverBindingStop (
if (((Index + 1) == NumberOfChildren) && AllChildrenStopped) {
UsbMass->Transport->CleanUp (UsbMass->Context);
}
+
FreePool (UsbMass);
}
}
@@ -1066,7 +1068,7 @@ USBMassDriverBindingStop (
return EFI_DEVICE_ERROR;
}
- DEBUG ((DEBUG_INFO, "Success to stop all %d multi-lun children handles\n", (UINT32) NumberOfChildren));
+ DEBUG ((DEBUG_INFO, "Success to stop all %d multi-lun children handles\n", (UINT32)NumberOfChildren));
return EFI_SUCCESS;
}
@@ -1085,8 +1087,8 @@ USBMassDriverBindingStop (
EFI_STATUS
EFIAPI
USBMassStorageEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.h b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.h
index 283bed7..0456598 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.h
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.h
@@ -10,7 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _EFI_USBMASS_IMPL_H_
#define _EFI_USBMASS_IMPL_H_
-#define USB_MASS_SIGNATURE SIGNATURE_32 ('U', 's', 'b', 'M')
+#define USB_MASS_SIGNATURE SIGNATURE_32 ('U', 's', 'b', 'M')
#define USB_MASS_DEVICE_FROM_BLOCK_IO(a) \
CR (a, USB_MASS_DEVICE, BlockIo, USB_MASS_SIGNATURE)
@@ -18,7 +18,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define USB_MASS_DEVICE_FROM_DISK_INFO(a) \
CR (a, USB_MASS_DEVICE, DiskInfo, USB_MASS_SIGNATURE)
-
extern EFI_COMPONENT_NAME_PROTOCOL gUsbMassStorageComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gUsbMassStorageComponentName2;
@@ -88,10 +87,10 @@ USBMassDriverBindingStart (
EFI_STATUS
EFIAPI
USBMassDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
);
//
@@ -116,8 +115,8 @@ USBMassDriverBindingStop (
EFI_STATUS
EFIAPI
UsbMassReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
/**
@@ -147,11 +146,11 @@ UsbMassReset (
EFI_STATUS
EFIAPI
UsbMassReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
);
/**
@@ -182,11 +181,11 @@ UsbMassReadBlocks (
EFI_STATUS
EFIAPI
UsbMassWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
/**
@@ -255,7 +254,6 @@ UsbMassStorageGetDriverName (
OUT CHAR16 **DriverName
);
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -317,11 +315,11 @@ UsbMassStorageGetDriverName (
EFI_STATUS
EFIAPI
UsbMassStorageGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/ComponentName.c b/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/ComponentName.c
index efad274..6c861d5 100644
--- a/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/ComponentName.c
+++ b/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/ComponentName.c
@@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "UsbMouseAbsolutePointer.h"
//
@@ -21,16 +20,15 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbMouseAbsolutePoin
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbMouseAbsolutePointerComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UsbMouseAbsolutePointerComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UsbMouseAbsolutePointerComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbMouseAbsolutePointerComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)UsbMouseAbsolutePointerComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)UsbMouseAbsolutePointerComponentNameGetControllerName,
"en"
};
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbMouseAbsolutePointerDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbMouseAbsolutePointerDriverNameTable[] = {
{ "eng;en", L"Usb Mouse Absolute Pointer Driver" },
- { NULL , NULL }
+ { NULL, NULL }
};
/**
@@ -145,17 +143,17 @@ UsbMouseAbsolutePointerComponentNameGetDriverName (
EFI_STATUS
EFIAPI
UsbMouseAbsolutePointerComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
- EFI_STATUS Status;
- USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDev;
- EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointerProtocol;
- EFI_USB_IO_PROTOCOL *UsbIoProtocol;
+ EFI_STATUS Status;
+ USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDev;
+ EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointerProtocol;
+ EFI_USB_IO_PROTOCOL *UsbIoProtocol;
//
// This is a device driver, so ChildHandle must be NULL.
@@ -170,7 +168,7 @@ UsbMouseAbsolutePointerComponentNameGetControllerName (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIoProtocol,
+ (VOID **)&UsbIoProtocol,
gUsbMouseAbsolutePointerDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -189,13 +187,14 @@ UsbMouseAbsolutePointerComponentNameGetControllerName (
if (Status != EFI_ALREADY_STARTED) {
return EFI_UNSUPPORTED;
}
+
//
// Get the device context
//
Status = gBS->OpenProtocol (
ControllerHandle,
- &gEfiAbsolutePointerProtocolGuid,
- (VOID **) &AbsolutePointerProtocol,
+ &gEfiAbsolutePointerProtocolGuid,
+ (VOID **)&AbsolutePointerProtocol,
gUsbMouseAbsolutePointerDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -214,5 +213,4 @@ UsbMouseAbsolutePointerComponentNameGetControllerName (
ControllerName,
(BOOLEAN)(This == &gUsbMouseAbsolutePointerComponentName)
);
-
}
diff --git a/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/MouseHid.c b/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/MouseHid.c
index 10e18e5..96e3e5c 100644
--- a/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/MouseHid.c
+++ b/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/MouseHid.c
@@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "UsbMouseAbsolutePointer.h"
-
/**
Get next HID item from report descriptor.
@@ -31,12 +30,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
UINT8 *
GetNextHidItem (
- IN UINT8 *StartPos,
- IN UINT8 *EndPos,
- OUT HID_ITEM *HidItem
+ IN UINT8 *StartPos,
+ IN UINT8 *EndPos,
+ OUT HID_ITEM *HidItem
)
{
- UINT8 Temp;
+ UINT8 Temp;
if (EndPos <= StartPos) {
return NULL;
@@ -66,7 +65,7 @@ GetNextHidItem (
if ((EndPos - StartPos) >= HidItem->Size) {
HidItem->Data.LongData = StartPos;
- StartPos += HidItem->Size;
+ StartPos += HidItem->Size;
return StartPos;
}
}
@@ -75,48 +74,47 @@ GetNextHidItem (
HidItem->Size = BitFieldRead8 (Temp, 0, 1);
switch (HidItem->Size) {
- case 0:
- //
- // No data
- //
- return StartPos;
-
- case 1:
- //
- // 1-byte data
- //
- if ((EndPos - StartPos) >= 1) {
- HidItem->Data.Uint8 = *StartPos++;
+ case 0:
+ //
+ // No data
+ //
return StartPos;
- }
- case 2:
- //
- // 2-byte data
- //
- if ((EndPos - StartPos) >= 2) {
- CopyMem (&HidItem->Data.Uint16, StartPos, sizeof (UINT16));
- StartPos += 2;
- return StartPos;
- }
+ case 1:
+ //
+ // 1-byte data
+ //
+ if ((EndPos - StartPos) >= 1) {
+ HidItem->Data.Uint8 = *StartPos++;
+ return StartPos;
+ }
- case 3:
- //
- // 4-byte data, adjust size
- //
- HidItem->Size = 4;
- if ((EndPos - StartPos) >= 4) {
- CopyMem (&HidItem->Data.Uint32, StartPos, sizeof (UINT32));
- StartPos += 4;
- return StartPos;
- }
+ case 2:
+ //
+ // 2-byte data
+ //
+ if ((EndPos - StartPos) >= 2) {
+ CopyMem (&HidItem->Data.Uint16, StartPos, sizeof (UINT16));
+ StartPos += 2;
+ return StartPos;
+ }
+
+ case 3:
+ //
+ // 4-byte data, adjust size
+ //
+ HidItem->Size = 4;
+ if ((EndPos - StartPos) >= 4) {
+ CopyMem (&HidItem->Data.Uint32, StartPos, sizeof (UINT32));
+ StartPos += 4;
+ return StartPos;
+ }
}
}
return NULL;
}
-
/**
Get data from HID item.
@@ -131,20 +129,21 @@ GetNextHidItem (
**/
UINT32
GetItemData (
- IN HID_ITEM *HidItem
+ IN HID_ITEM *HidItem
)
{
//
// Get data from HID item.
//
switch (HidItem->Size) {
- case 1:
- return HidItem->Data.Uint8;
- case 2:
- return HidItem->Data.Uint16;
- case 4:
- return HidItem->Data.Uint32;
+ case 1:
+ return HidItem->Data.Uint8;
+ case 2:
+ return HidItem->Data.Uint16;
+ case 4:
+ return HidItem->Data.Uint32;
}
+
return 0;
}
@@ -161,67 +160,68 @@ GetItemData (
**/
VOID
ParseHidItem (
- IN USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouse,
- IN HID_ITEM *HidItem
+ IN USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouse,
+ IN HID_ITEM *HidItem
)
{
UINT8 Data;
switch (HidItem->Type) {
+ case HID_ITEM_TYPE_MAIN:
+ //
+ // we don't care any main items, just skip
+ //
+ return;
- case HID_ITEM_TYPE_MAIN:
- //
- // we don't care any main items, just skip
- //
- return ;
+ case HID_ITEM_TYPE_GLOBAL:
+ //
+ // For global items, we only care Usage Page tag for Button Page here
+ //
+ if (HidItem->Tag == HID_GLOBAL_ITEM_TAG_USAGE_PAGE) {
+ Data = (UINT8)GetItemData (HidItem);
+ if (Data == 0x09) {
+ //
+ // Button Page
+ //
+ UsbMouse->PrivateData.ButtonDetected = TRUE;
+ }
+ }
- case HID_ITEM_TYPE_GLOBAL:
- //
- // For global items, we only care Usage Page tag for Button Page here
- //
- if (HidItem->Tag == HID_GLOBAL_ITEM_TAG_USAGE_PAGE) {
- Data = (UINT8) GetItemData (HidItem);
- if (Data == 0x09) {
+ return;
+
+ case HID_ITEM_TYPE_LOCAL:
+ if (HidItem->Size == 0) {
//
- // Button Page
+ // No expected data for local item
//
- UsbMouse->PrivateData.ButtonDetected = TRUE;
+ return;
}
- }
- return;
- case HID_ITEM_TYPE_LOCAL:
- if (HidItem->Size == 0) {
- //
- // No expected data for local item
- //
- return ;
- }
+ Data = (UINT8)GetItemData (HidItem);
- Data = (UINT8) GetItemData (HidItem);
+ switch (HidItem->Tag) {
+ case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
+ if (UsbMouse->PrivateData.ButtonDetected) {
+ UsbMouse->PrivateData.ButtonMinIndex = Data;
+ }
- switch (HidItem->Tag) {
- case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
- if (UsbMouse->PrivateData.ButtonDetected) {
- UsbMouse->PrivateData.ButtonMinIndex = Data;
- }
- return ;
+ return;
- case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
- {
- if (UsbMouse->PrivateData.ButtonDetected) {
- UsbMouse->PrivateData.ButtonMaxIndex = Data;
- }
- return ;
- }
+ case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
+ {
+ if (UsbMouse->PrivateData.ButtonDetected) {
+ UsbMouse->PrivateData.ButtonMaxIndex = Data;
+ }
+
+ return;
+ }
- default:
- return ;
+ default:
+ return;
}
}
}
-
/**
Parse Mouse Report Descriptor.
@@ -240,9 +240,9 @@ ParseHidItem (
**/
EFI_STATUS
ParseMouseReportDescriptor (
- OUT USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointer,
- IN UINT8 *ReportDescriptor,
- IN UINTN ReportSize
+ OUT USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointer,
+ IN UINT8 *ReportDescriptor,
+ IN UINTN ReportSize
)
{
UINT8 *DescriptorEnd;
@@ -265,11 +265,11 @@ ParseMouseReportDescriptor (
Ptr = GetNextHidItem (Ptr, DescriptorEnd, &HidItem);
}
- UsbMouseAbsolutePointer->NumberOfButtons = (UINT8) (UsbMouseAbsolutePointer->PrivateData.ButtonMaxIndex - UsbMouseAbsolutePointer->PrivateData.ButtonMinIndex + 1);
- UsbMouseAbsolutePointer->XLogicMax = 1023;
- UsbMouseAbsolutePointer->YLogicMax = 1023;
- UsbMouseAbsolutePointer->XLogicMin = -1023;
- UsbMouseAbsolutePointer->YLogicMin = -1023;
+ UsbMouseAbsolutePointer->NumberOfButtons = (UINT8)(UsbMouseAbsolutePointer->PrivateData.ButtonMaxIndex - UsbMouseAbsolutePointer->PrivateData.ButtonMinIndex + 1);
+ UsbMouseAbsolutePointer->XLogicMax = 1023;
+ UsbMouseAbsolutePointer->YLogicMax = 1023;
+ UsbMouseAbsolutePointer->XLogicMin = -1023;
+ UsbMouseAbsolutePointer->YLogicMin = -1023;
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.c b/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.c
index 926e03f..ad5f066 100644
--- a/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.c
+++ b/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.c
@@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "UsbMouseAbsolutePointer.h"
-EFI_DRIVER_BINDING_PROTOCOL gUsbMouseAbsolutePointerDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gUsbMouseAbsolutePointerDriverBinding = {
USBMouseAbsolutePointerDriverBindingSupported,
USBMouseAbsolutePointerDriverBindingStart,
USBMouseAbsolutePointerDriverBindingStop,
@@ -32,11 +32,11 @@ EFI_DRIVER_BINDING_PROTOCOL gUsbMouseAbsolutePointerDriverBinding = {
EFI_STATUS
EFIAPI
USBMouseAbsolutePointerDriverBindingEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
@@ -51,7 +51,6 @@ USBMouseAbsolutePointerDriverBindingEntryPoint (
return EFI_SUCCESS;
}
-
/**
Check whether USB Mouse Absolute Pointer Driver supports this device.
@@ -66,18 +65,18 @@ USBMouseAbsolutePointerDriverBindingEntryPoint (
EFI_STATUS
EFIAPI
USBMouseAbsolutePointerDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_STATUS Status;
+ EFI_USB_IO_PROTOCOL *UsbIo;
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
+ (VOID **)&UsbIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -96,16 +95,15 @@ USBMouseAbsolutePointerDriverBindingSupported (
}
gBS->CloseProtocol (
- Controller,
- &gEfiUsbIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiUsbIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return Status;
}
-
/**
Starts the mouse device with this driver.
@@ -128,22 +126,22 @@ USBMouseAbsolutePointerDriverBindingSupported (
EFI_STATUS
EFIAPI
USBMouseAbsolutePointerDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_USB_IO_PROTOCOL *UsbIo;
- USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDevice;
- UINT8 EndpointNumber;
- EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
- UINT8 Index;
- UINT8 EndpointAddr;
- UINT8 PollingInterval;
- UINT8 PacketSize;
- BOOLEAN Found;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDevice;
+ UINT8 EndpointNumber;
+ EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
+ UINT8 Index;
+ UINT8 EndpointAddr;
+ UINT8 PollingInterval;
+ UINT8 PacketSize;
+ BOOLEAN Found;
+ EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
@@ -152,7 +150,7 @@ USBMouseAbsolutePointerDriverBindingStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
+ (VOID **)&UsbIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -173,7 +171,7 @@ USBMouseAbsolutePointerDriverBindingStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &UsbMouseAbsolutePointerDevice->DevicePath,
+ (VOID **)&UsbMouseAbsolutePointerDevice->DevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -214,11 +212,12 @@ USBMouseAbsolutePointerDriverBindingStart (
);
if (((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) &&
- ((EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) != 0)) {
+ ((EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) != 0))
+ {
//
// We only care interrupt endpoint here
//
- CopyMem (&UsbMouseAbsolutePointerDevice->IntEndpointDescriptor, &EndpointDescriptor, sizeof(EndpointDescriptor));
+ CopyMem (&UsbMouseAbsolutePointerDevice->IntEndpointDescriptor, &EndpointDescriptor, sizeof (EndpointDescriptor));
Found = TRUE;
break;
}
@@ -267,7 +266,7 @@ USBMouseAbsolutePointerDriverBindingStart (
//
UsbMouseAbsolutePointerDevice->AbsolutePointerProtocol.GetState = GetMouseAbsolutePointerState;
UsbMouseAbsolutePointerDevice->AbsolutePointerProtocol.Reset = UsbMouseAbsolutePointerReset;
- UsbMouseAbsolutePointerDevice->AbsolutePointerProtocol.Mode = &UsbMouseAbsolutePointerDevice->Mode;
+ UsbMouseAbsolutePointerDevice->AbsolutePointerProtocol.Mode = &UsbMouseAbsolutePointerDevice->Mode;
Status = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
@@ -307,7 +306,7 @@ USBMouseAbsolutePointerDriverBindingStart (
//
EndpointAddr = UsbMouseAbsolutePointerDevice->IntEndpointDescriptor.EndpointAddress;
PollingInterval = UsbMouseAbsolutePointerDevice->IntEndpointDescriptor.Interval;
- PacketSize = (UINT8) (UsbMouseAbsolutePointerDevice->IntEndpointDescriptor.MaxPacketSize);
+ PacketSize = (UINT8)(UsbMouseAbsolutePointerDevice->IntEndpointDescriptor.MaxPacketSize);
Status = UsbIo->UsbAsyncInterruptTransfer (
UsbIo,
@@ -337,8 +336,8 @@ USBMouseAbsolutePointerDriverBindingStart (
gUsbMouseAbsolutePointerComponentName.SupportedLanguages,
&UsbMouseAbsolutePointerDevice->ControllerNameTable,
L"Generic Usb Mouse Absolute Pointer",
- TRUE
- );
+ TRUE
+ );
AddUnicodeString2 (
"en",
gUsbMouseAbsolutePointerComponentName2.SupportedLanguages,
@@ -350,17 +349,17 @@ USBMouseAbsolutePointerDriverBindingStart (
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
-//
-// Error handler
-//
+ //
+ // Error handler
+ //
ErrorExit:
if (EFI_ERROR (Status)) {
gBS->CloseProtocol (
- Controller,
- &gEfiUsbIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiUsbIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
if (UsbMouseAbsolutePointerDevice != NULL) {
if ((UsbMouseAbsolutePointerDevice->AbsolutePointerProtocol).WaitForInput != NULL) {
@@ -378,7 +377,6 @@ ErrorExit1:
return Status;
}
-
/**
Stop the USB mouse device handled by this driver.
@@ -395,10 +393,10 @@ ErrorExit1:
EFI_STATUS
EFIAPI
USBMouseAbsolutePointerDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
EFI_STATUS Status;
@@ -409,7 +407,7 @@ USBMouseAbsolutePointerDriverBindingStop (
Status = gBS->OpenProtocol (
Controller,
&gEfiAbsolutePointerProtocolGuid,
- (VOID **) &AbsolutePointerProtocol,
+ (VOID **)&AbsolutePointerProtocol,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -478,10 +476,8 @@ USBMouseAbsolutePointerDriverBindingStop (
FreePool (UsbMouseAbsolutePointerDevice);
return EFI_SUCCESS;
-
}
-
/**
Uses USB I/O to check whether the device is a USB mouse device.
@@ -493,7 +489,7 @@ USBMouseAbsolutePointerDriverBindingStop (
**/
BOOLEAN
IsUsbMouse (
- IN EFI_USB_IO_PROTOCOL *UsbIo
+ IN EFI_USB_IO_PROTOCOL *UsbIo
)
{
EFI_STATUS Status;
@@ -514,14 +510,14 @@ IsUsbMouse (
if ((InterfaceDescriptor.InterfaceClass == CLASS_HID) &&
(InterfaceDescriptor.InterfaceSubClass == SUBCLASS_BOOT) &&
(InterfaceDescriptor.InterfaceProtocol == PROTOCOL_MOUSE)
- ) {
+ )
+ {
return TRUE;
}
return FALSE;
}
-
/**
Initialize the USB mouse device.
@@ -539,20 +535,20 @@ IsUsbMouse (
**/
EFI_STATUS
InitializeUsbMouseDevice (
- IN USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDev
+ IN USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDev
)
{
- EFI_USB_IO_PROTOCOL *UsbIo;
- UINT8 Protocol;
- EFI_STATUS Status;
- EFI_USB_HID_DESCRIPTOR *MouseHidDesc;
- UINT8 *ReportDesc;
- EFI_USB_CONFIG_DESCRIPTOR ConfigDesc;
- VOID *Buf;
- UINT32 TransferResult;
- UINT16 Total;
- USB_DESC_HEAD *Head;
- BOOLEAN Start;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ UINT8 Protocol;
+ EFI_STATUS Status;
+ EFI_USB_HID_DESCRIPTOR *MouseHidDesc;
+ UINT8 *ReportDesc;
+ EFI_USB_CONFIG_DESCRIPTOR ConfigDesc;
+ VOID *Buf;
+ UINT32 TransferResult;
+ UINT16 Total;
+ USB_DESC_HEAD *Head;
+ BOOLEAN Start;
UsbIo = UsbMouseAbsolutePointerDev->UsbIo;
@@ -589,9 +585,9 @@ InitializeUsbMouseDevice (
return Status;
}
- Total = 0;
- Start = FALSE;
- Head = (USB_DESC_HEAD *)Buf;
+ Total = 0;
+ Start = FALSE;
+ Head = (USB_DESC_HEAD *)Buf;
MouseHidDesc = NULL;
//
@@ -602,19 +598,23 @@ InitializeUsbMouseDevice (
while (Total < ConfigDesc.TotalLength) {
if (Head->Type == USB_DESC_TYPE_INTERFACE) {
if ((((USB_INTERFACE_DESCRIPTOR *)Head)->InterfaceNumber == UsbMouseAbsolutePointerDev->InterfaceDescriptor.InterfaceNumber) &&
- (((USB_INTERFACE_DESCRIPTOR *)Head)->AlternateSetting == UsbMouseAbsolutePointerDev->InterfaceDescriptor.AlternateSetting)) {
+ (((USB_INTERFACE_DESCRIPTOR *)Head)->AlternateSetting == UsbMouseAbsolutePointerDev->InterfaceDescriptor.AlternateSetting))
+ {
Start = TRUE;
}
}
+
if (Start && (Head->Type == USB_DESC_TYPE_ENDPOINT)) {
break;
}
+
if (Start && (Head->Type == USB_DESC_TYPE_HID)) {
MouseHidDesc = (EFI_USB_HID_DESCRIPTOR *)Head;
break;
}
+
Total = Total + (UINT16)Head->Len;
- Head = (USB_DESC_HEAD*)((UINT8 *)Buf + Total);
+ Head = (USB_DESC_HEAD *)((UINT8 *)Buf + Total);
}
if (MouseHidDesc == NULL) {
@@ -722,7 +722,6 @@ InitializeUsbMouseDevice (
return EFI_SUCCESS;
}
-
/**
Handler function for USB mouse's asynchronous interrupt transfer.
@@ -743,19 +742,19 @@ InitializeUsbMouseDevice (
EFI_STATUS
EFIAPI
OnMouseInterruptComplete (
- IN VOID *Data,
- IN UINTN DataLength,
- IN VOID *Context,
- IN UINT32 Result
+ IN VOID *Data,
+ IN UINTN DataLength,
+ IN VOID *Context,
+ IN UINT32 Result
)
{
- USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDevice;
- EFI_USB_IO_PROTOCOL *UsbIo;
- UINT8 EndpointAddr;
- UINT32 UsbResult;
+ USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDevice;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ UINT8 EndpointAddr;
+ UINT32 UsbResult;
- UsbMouseAbsolutePointerDevice = (USB_MOUSE_ABSOLUTE_POINTER_DEV *) Context;
- UsbIo = UsbMouseAbsolutePointerDevice->UsbIo;
+ UsbMouseAbsolutePointerDevice = (USB_MOUSE_ABSOLUTE_POINTER_DEV *)Context;
+ UsbIo = UsbMouseAbsolutePointerDevice->UsbIo;
if (Result != EFI_USB_NOERROR) {
//
@@ -804,7 +803,7 @@ OnMouseInterruptComplete (
//
// If no error and no data, just return EFI_SUCCESS.
//
- if (DataLength == 0 || Data == NULL) {
+ if ((DataLength == 0) || (Data == NULL)) {
return EFI_SUCCESS;
}
@@ -826,26 +825,32 @@ OnMouseInterruptComplete (
UsbMouseAbsolutePointerDevice->StateChanged = TRUE;
- UsbMouseAbsolutePointerDevice->State.ActiveButtons = *(UINT8 *) Data & (BIT0 | BIT1 | BIT2);
+ UsbMouseAbsolutePointerDevice->State.ActiveButtons = *(UINT8 *)Data & (BIT0 | BIT1 | BIT2);
UsbMouseAbsolutePointerDevice->State.CurrentX =
MIN (
- MAX ((INT64) UsbMouseAbsolutePointerDevice->State.CurrentX + *((INT8 *) Data + 1),
- (INT64) UsbMouseAbsolutePointerDevice->Mode.AbsoluteMinX),
- (INT64) UsbMouseAbsolutePointerDevice->Mode.AbsoluteMaxX
+ MAX (
+ (INT64)UsbMouseAbsolutePointerDevice->State.CurrentX + *((INT8 *)Data + 1),
+ (INT64)UsbMouseAbsolutePointerDevice->Mode.AbsoluteMinX
+ ),
+ (INT64)UsbMouseAbsolutePointerDevice->Mode.AbsoluteMaxX
);
UsbMouseAbsolutePointerDevice->State.CurrentY =
MIN (
- MAX ((INT64) UsbMouseAbsolutePointerDevice->State.CurrentY + *((INT8 *) Data + 2),
- (INT64) UsbMouseAbsolutePointerDevice->Mode.AbsoluteMinY),
- (INT64) UsbMouseAbsolutePointerDevice->Mode.AbsoluteMaxY
+ MAX (
+ (INT64)UsbMouseAbsolutePointerDevice->State.CurrentY + *((INT8 *)Data + 2),
+ (INT64)UsbMouseAbsolutePointerDevice->Mode.AbsoluteMinY
+ ),
+ (INT64)UsbMouseAbsolutePointerDevice->Mode.AbsoluteMaxY
);
if (DataLength > 3) {
UsbMouseAbsolutePointerDevice->State.CurrentZ =
MIN (
- MAX ((INT64) UsbMouseAbsolutePointerDevice->State.CurrentZ + *((INT8 *) Data + 1),
- (INT64) UsbMouseAbsolutePointerDevice->Mode.AbsoluteMinZ),
- (INT64) UsbMouseAbsolutePointerDevice->Mode.AbsoluteMaxZ
+ MAX (
+ (INT64)UsbMouseAbsolutePointerDevice->State.CurrentZ + *((INT8 *)Data + 1),
+ (INT64)UsbMouseAbsolutePointerDevice->Mode.AbsoluteMinZ
+ ),
+ (INT64)UsbMouseAbsolutePointerDevice->Mode.AbsoluteMaxZ
);
}
@@ -873,7 +878,7 @@ GetMouseAbsolutePointerState (
OUT EFI_ABSOLUTE_POINTER_STATE *State
)
{
- USB_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev;
+ USB_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev;
if (State == NULL) {
return EFI_INVALID_PARAMETER;
@@ -900,7 +905,6 @@ GetMouseAbsolutePointerState (
return EFI_SUCCESS;
}
-
/**
Resets the pointer device hardware.
@@ -919,9 +923,9 @@ UsbMouseAbsolutePointerReset (
IN BOOLEAN ExtendedVerification
)
{
- USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDevice;
+ USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDevice;
- UsbMouseAbsolutePointerDevice = USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (This);
+ UsbMouseAbsolutePointerDevice = USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (This);
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
EFI_PROGRESS_CODE,
@@ -960,13 +964,13 @@ UsbMouseAbsolutePointerReset (
VOID
EFIAPI
UsbMouseAbsolutePointerWaitForInput (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDev;
+ USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDev;
- UsbMouseAbsolutePointerDev = (USB_MOUSE_ABSOLUTE_POINTER_DEV *) Context;
+ UsbMouseAbsolutePointerDev = (USB_MOUSE_ABSOLUTE_POINTER_DEV *)Context;
//
// If there's input from mouse, signal the event.
@@ -992,16 +996,16 @@ UsbMouseAbsolutePointerWaitForInput (
VOID
EFIAPI
USBMouseRecoveryHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDev;
- EFI_USB_IO_PROTOCOL *UsbIo;
+ USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDev;
+ EFI_USB_IO_PROTOCOL *UsbIo;
- UsbMouseAbsolutePointerDev = (USB_MOUSE_ABSOLUTE_POINTER_DEV *) Context;
+ UsbMouseAbsolutePointerDev = (USB_MOUSE_ABSOLUTE_POINTER_DEV *)Context;
- UsbIo = UsbMouseAbsolutePointerDev->UsbIo;
+ UsbIo = UsbMouseAbsolutePointerDev->UsbIo;
//
// Re-submit Asynchronous Interrupt Transfer for recovery.
diff --git a/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.h b/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.h
index c9edc45..d5f92d2 100644
--- a/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.h
+++ b/MdeModulePkg/Bus/Usb/UsbMouseAbsolutePointerDxe/UsbMouseAbsolutePointer.h
@@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _USB_MOUSE_ABSOLUTE_POINTER_H_
#define _USB_MOUSE_ABSOLUTE_POINTER_H_
-
#include <Uefi.h>
#include <Protocol/AbsolutePointer.h>
@@ -27,14 +26,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <IndustryStandard/Usb.h>
-#define CLASS_HID 3
-#define SUBCLASS_BOOT 1
-#define PROTOCOL_MOUSE 2
+#define CLASS_HID 3
+#define SUBCLASS_BOOT 1
+#define PROTOCOL_MOUSE 2
-#define BOOT_PROTOCOL 0
-#define REPORT_PROTOCOL 1
+#define BOOT_PROTOCOL 0
+#define REPORT_PROTOCOL 1
-#define USB_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE SIGNATURE_32 ('u', 'm', 's', 't')
+#define USB_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE SIGNATURE_32 ('u', 'm', 's', 't')
//
// A common header for usb standard descriptor.
@@ -42,8 +41,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
#pragma pack(1)
typedef struct {
- UINT8 Len;
- UINT8 Type;
+ UINT8 Len;
+ UINT8 Type;
} USB_DESC_HEAD;
#pragma pack()
@@ -51,33 +50,33 @@ typedef struct {
/// Button range and status
///
typedef struct {
- BOOLEAN ButtonDetected;
- UINT8 ButtonMinIndex;
- UINT8 ButtonMaxIndex;
- UINT8 Reserved;
+ BOOLEAN ButtonDetected;
+ UINT8 ButtonMinIndex;
+ UINT8 ButtonMaxIndex;
+ UINT8 Reserved;
} USB_MOUSE_BUTTON_DATA;
///
/// Device instance of USB mouse.
///
typedef struct {
- UINTN Signature;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_EVENT DelayedRecoveryEvent;
- EFI_USB_IO_PROTOCOL *UsbIo;
- EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
- EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;
- UINT8 NumberOfButtons;
- INT32 XLogicMax;
- INT32 XLogicMin;
- INT32 YLogicMax;
- INT32 YLogicMin;
- EFI_ABSOLUTE_POINTER_PROTOCOL AbsolutePointerProtocol;
- EFI_ABSOLUTE_POINTER_STATE State;
- EFI_ABSOLUTE_POINTER_MODE Mode;
- BOOLEAN StateChanged;
- USB_MOUSE_BUTTON_DATA PrivateData;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+ UINTN Signature;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_EVENT DelayedRecoveryEvent;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
+ EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;
+ UINT8 NumberOfButtons;
+ INT32 XLogicMax;
+ INT32 XLogicMin;
+ INT32 YLogicMax;
+ INT32 YLogicMin;
+ EFI_ABSOLUTE_POINTER_PROTOCOL AbsolutePointerProtocol;
+ EFI_ABSOLUTE_POINTER_STATE State;
+ EFI_ABSOLUTE_POINTER_MODE Mode;
+ BOOLEAN StateChanged;
+ USB_MOUSE_BUTTON_DATA PrivateData;
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
} USB_MOUSE_ABSOLUTE_POINTER_DEV;
///
@@ -85,21 +84,21 @@ typedef struct {
///
typedef union {
- UINT8 Uint8;
- UINT16 Uint16;
- UINT32 Uint32;
- INT8 Int8;
- INT16 Int16;
- INT32 Int32;
- UINT8 *LongData;
+ UINT8 Uint8;
+ UINT16 Uint16;
+ UINT32 Uint32;
+ INT8 Int8;
+ INT16 Int16;
+ INT32 Int32;
+ UINT8 *LongData;
} HID_DATA;
typedef struct {
- UINT16 Format;
- UINT8 Size;
- UINT8 Type;
- UINT8 Tag;
- HID_DATA Data;
+ UINT16 Format;
+ UINT8 Size;
+ UINT8 Type;
+ UINT8 Tag;
+ HID_DATA Data;
} HID_ITEM;
#define USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL(a) \
@@ -130,9 +129,9 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gUsbMouseAbsolutePointerComponentName2;
EFI_STATUS
EFIAPI
USBMouseAbsolutePointerDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -157,9 +156,9 @@ USBMouseAbsolutePointerDriverBindingSupported (
EFI_STATUS
EFIAPI
USBMouseAbsolutePointerDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -178,10 +177,10 @@ USBMouseAbsolutePointerDriverBindingStart (
EFI_STATUS
EFIAPI
USBMouseAbsolutePointerDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
);
//
@@ -291,11 +290,11 @@ UsbMouseAbsolutePointerComponentNameGetDriverName (
EFI_STATUS
EFIAPI
UsbMouseAbsolutePointerComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
//
@@ -351,8 +350,8 @@ UsbMouseAbsolutePointerReset (
VOID
EFIAPI
UsbMouseAbsolutePointerWaitForInput (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
//
@@ -370,7 +369,7 @@ UsbMouseAbsolutePointerWaitForInput (
**/
BOOLEAN
IsUsbMouse (
- IN EFI_USB_IO_PROTOCOL *UsbIo
+ IN EFI_USB_IO_PROTOCOL *UsbIo
);
/**
@@ -390,7 +389,7 @@ IsUsbMouse (
**/
EFI_STATUS
InitializeUsbMouseDevice (
- IN USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDev
+ IN USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDev
);
/**
@@ -413,10 +412,10 @@ InitializeUsbMouseDevice (
EFI_STATUS
EFIAPI
OnMouseInterruptComplete (
- IN VOID *Data,
- IN UINTN DataLength,
- IN VOID *Context,
- IN UINT32 Result
+ IN VOID *Data,
+ IN UINTN DataLength,
+ IN VOID *Context,
+ IN UINT32 Result
);
/**
@@ -435,8 +434,8 @@ OnMouseInterruptComplete (
VOID
EFIAPI
USBMouseRecoveryHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -457,9 +456,9 @@ USBMouseRecoveryHandler (
**/
EFI_STATUS
ParseMouseReportDescriptor (
- OUT USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointer,
- IN UINT8 *ReportDescriptor,
- IN UINTN ReportSize
+ OUT USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointer,
+ IN UINT8 *ReportDescriptor,
+ IN UINTN ReportSize
);
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbMouseDxe/ComponentName.c b/MdeModulePkg/Bus/Usb/UsbMouseDxe/ComponentName.c
index 7f4b3e8..0b5adb1 100644
--- a/MdeModulePkg/Bus/Usb/UsbMouseDxe/ComponentName.c
+++ b/MdeModulePkg/Bus/Usb/UsbMouseDxe/ComponentName.c
@@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "UsbMouse.h"
//
@@ -21,16 +20,15 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbMouseComponentNam
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbMouseComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UsbMouseComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UsbMouseComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbMouseComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)UsbMouseComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)UsbMouseComponentNameGetControllerName,
"en"
};
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbMouseDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbMouseDriverNameTable[] = {
{ "eng;en", L"Usb Mouse Driver" },
- { NULL , NULL }
+ { NULL, NULL }
};
/**
@@ -145,17 +143,17 @@ UsbMouseComponentNameGetDriverName (
EFI_STATUS
EFIAPI
UsbMouseComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
- EFI_STATUS Status;
- USB_MOUSE_DEV *UsbMouseDev;
- EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
- EFI_USB_IO_PROTOCOL *UsbIoProtocol;
+ EFI_STATUS Status;
+ USB_MOUSE_DEV *UsbMouseDev;
+ EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
+ EFI_USB_IO_PROTOCOL *UsbIoProtocol;
//
// This is a device driver, so ChildHandle must be NULL.
@@ -170,7 +168,7 @@ UsbMouseComponentNameGetControllerName (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIoProtocol,
+ (VOID **)&UsbIoProtocol,
gUsbMouseDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -189,13 +187,14 @@ UsbMouseComponentNameGetControllerName (
if (Status != EFI_ALREADY_STARTED) {
return EFI_UNSUPPORTED;
}
+
//
// Get the device context
//
Status = gBS->OpenProtocol (
ControllerHandle,
- &gEfiSimplePointerProtocolGuid,
- (VOID **) &SimplePointerProtocol,
+ &gEfiSimplePointerProtocolGuid,
+ (VOID **)&SimplePointerProtocol,
gUsbMouseDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -214,5 +213,4 @@ UsbMouseComponentNameGetControllerName (
ControllerName,
(BOOLEAN)(This == &gUsbMouseComponentName)
);
-
}
diff --git a/MdeModulePkg/Bus/Usb/UsbMouseDxe/MouseHid.c b/MdeModulePkg/Bus/Usb/UsbMouseDxe/MouseHid.c
index 2b6d860..acc19ac 100644
--- a/MdeModulePkg/Bus/Usb/UsbMouseDxe/MouseHid.c
+++ b/MdeModulePkg/Bus/Usb/UsbMouseDxe/MouseHid.c
@@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "UsbMouse.h"
-
/**
Get next HID item from report descriptor.
@@ -31,12 +30,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
UINT8 *
GetNextHidItem (
- IN UINT8 *StartPos,
- IN UINT8 *EndPos,
- OUT HID_ITEM *HidItem
+ IN UINT8 *StartPos,
+ IN UINT8 *EndPos,
+ OUT HID_ITEM *HidItem
)
{
- UINT8 Temp;
+ UINT8 Temp;
if (EndPos <= StartPos) {
return NULL;
@@ -66,7 +65,7 @@ GetNextHidItem (
if ((EndPos - StartPos) >= HidItem->Size) {
HidItem->Data.LongData = StartPos;
- StartPos += HidItem->Size;
+ StartPos += HidItem->Size;
return StartPos;
}
}
@@ -75,48 +74,47 @@ GetNextHidItem (
HidItem->Size = BitFieldRead8 (Temp, 0, 1);
switch (HidItem->Size) {
- case 0:
- //
- // No data
- //
- return StartPos;
-
- case 1:
- //
- // 1-byte data
- //
- if ((EndPos - StartPos) >= 1) {
- HidItem->Data.Uint8 = *StartPos++;
+ case 0:
+ //
+ // No data
+ //
return StartPos;
- }
- case 2:
- //
- // 2-byte data
- //
- if ((EndPos - StartPos) >= 2) {
- CopyMem (&HidItem->Data.Uint16, StartPos, sizeof (UINT16));
- StartPos += 2;
- return StartPos;
- }
+ case 1:
+ //
+ // 1-byte data
+ //
+ if ((EndPos - StartPos) >= 1) {
+ HidItem->Data.Uint8 = *StartPos++;
+ return StartPos;
+ }
- case 3:
- //
- // 4-byte data, adjust size
- //
- HidItem->Size = 4;
- if ((EndPos - StartPos) >= 4) {
- CopyMem (&HidItem->Data.Uint32, StartPos, sizeof (UINT32));
- StartPos += 4;
- return StartPos;
- }
+ case 2:
+ //
+ // 2-byte data
+ //
+ if ((EndPos - StartPos) >= 2) {
+ CopyMem (&HidItem->Data.Uint16, StartPos, sizeof (UINT16));
+ StartPos += 2;
+ return StartPos;
+ }
+
+ case 3:
+ //
+ // 4-byte data, adjust size
+ //
+ HidItem->Size = 4;
+ if ((EndPos - StartPos) >= 4) {
+ CopyMem (&HidItem->Data.Uint32, StartPos, sizeof (UINT32));
+ StartPos += 4;
+ return StartPos;
+ }
}
}
return NULL;
}
-
/**
Get data from HID item.
@@ -131,20 +129,21 @@ GetNextHidItem (
**/
UINT32
GetItemData (
- IN HID_ITEM *HidItem
+ IN HID_ITEM *HidItem
)
{
//
// Get data from HID item.
//
switch (HidItem->Size) {
- case 1:
- return HidItem->Data.Uint8;
- case 2:
- return HidItem->Data.Uint16;
- case 4:
- return HidItem->Data.Uint32;
+ case 1:
+ return HidItem->Data.Uint8;
+ case 2:
+ return HidItem->Data.Uint16;
+ case 4:
+ return HidItem->Data.Uint32;
}
+
return 0;
}
@@ -161,67 +160,68 @@ GetItemData (
**/
VOID
ParseHidItem (
- IN USB_MOUSE_DEV *UsbMouse,
- IN HID_ITEM *HidItem
+ IN USB_MOUSE_DEV *UsbMouse,
+ IN HID_ITEM *HidItem
)
{
UINT8 Data;
switch (HidItem->Type) {
+ case HID_ITEM_TYPE_MAIN:
+ //
+ // we don't care any main items, just skip
+ //
+ return;
- case HID_ITEM_TYPE_MAIN:
- //
- // we don't care any main items, just skip
- //
- return;
+ case HID_ITEM_TYPE_GLOBAL:
+ //
+ // For global items, we only care Usage Page tag for Button Page here
+ //
+ if (HidItem->Tag == HID_GLOBAL_ITEM_TAG_USAGE_PAGE) {
+ Data = (UINT8)GetItemData (HidItem);
+ if (Data == 0x09) {
+ //
+ // Button Page
+ //
+ UsbMouse->PrivateData.ButtonDetected = TRUE;
+ }
+ }
- case HID_ITEM_TYPE_GLOBAL:
- //
- // For global items, we only care Usage Page tag for Button Page here
- //
- if (HidItem->Tag == HID_GLOBAL_ITEM_TAG_USAGE_PAGE) {
- Data = (UINT8) GetItemData (HidItem);
- if (Data == 0x09) {
+ return;
+
+ case HID_ITEM_TYPE_LOCAL:
+ if (HidItem->Size == 0) {
//
- // Button Page
+ // No expected data for local item
//
- UsbMouse->PrivateData.ButtonDetected = TRUE;
+ return;
}
- }
- return;
- case HID_ITEM_TYPE_LOCAL:
- if (HidItem->Size == 0) {
- //
- // No expected data for local item
- //
- return ;
- }
+ Data = (UINT8)GetItemData (HidItem);
- Data = (UINT8) GetItemData (HidItem);
+ switch (HidItem->Tag) {
+ case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
+ if (UsbMouse->PrivateData.ButtonDetected) {
+ UsbMouse->PrivateData.ButtonMinIndex = Data;
+ }
- switch (HidItem->Tag) {
- case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
- if (UsbMouse->PrivateData.ButtonDetected) {
- UsbMouse->PrivateData.ButtonMinIndex = Data;
- }
- return ;
+ return;
- case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
- {
- if (UsbMouse->PrivateData.ButtonDetected) {
- UsbMouse->PrivateData.ButtonMaxIndex = Data;
- }
- return ;
- }
+ case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
+ {
+ if (UsbMouse->PrivateData.ButtonDetected) {
+ UsbMouse->PrivateData.ButtonMaxIndex = Data;
+ }
- default:
- return;
- }
+ return;
+ }
+
+ default:
+ return;
+ }
}
}
-
/**
Parse Mouse Report Descriptor.
@@ -240,9 +240,9 @@ ParseHidItem (
**/
EFI_STATUS
ParseMouseReportDescriptor (
- OUT USB_MOUSE_DEV *UsbMouse,
- IN UINT8 *ReportDescriptor,
- IN UINTN ReportSize
+ OUT USB_MOUSE_DEV *UsbMouse,
+ IN UINT8 *ReportDescriptor,
+ IN UINTN ReportSize
)
{
UINT8 *DescriptorEnd;
@@ -265,11 +265,11 @@ ParseMouseReportDescriptor (
Ptr = GetNextHidItem (Ptr, DescriptorEnd, &HidItem);
}
- UsbMouse->NumberOfButtons = (UINT8) (UsbMouse->PrivateData.ButtonMaxIndex - UsbMouse->PrivateData.ButtonMinIndex + 1);
- UsbMouse->XLogicMax = 127;
- UsbMouse->YLogicMax = 127;
- UsbMouse->XLogicMin = -127;
- UsbMouse->YLogicMin = -127;
+ UsbMouse->NumberOfButtons = (UINT8)(UsbMouse->PrivateData.ButtonMaxIndex - UsbMouse->PrivateData.ButtonMinIndex + 1);
+ UsbMouse->XLogicMax = 127;
+ UsbMouse->YLogicMax = 127;
+ UsbMouse->XLogicMin = -127;
+ UsbMouse->YLogicMin = -127;
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c
index 9861c32..451d4b9 100644
--- a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c
+++ b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c
@@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "UsbMouse.h"
-EFI_DRIVER_BINDING_PROTOCOL gUsbMouseDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gUsbMouseDriverBinding = {
USBMouseDriverBindingSupported,
USBMouseDriverBindingStart,
USBMouseDriverBindingStop,
@@ -32,11 +32,11 @@ EFI_DRIVER_BINDING_PROTOCOL gUsbMouseDriverBinding = {
EFI_STATUS
EFIAPI
USBMouseDriverBindingEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
@@ -51,7 +51,6 @@ USBMouseDriverBindingEntryPoint (
return EFI_SUCCESS;
}
-
/**
Check whether USB mouse driver supports this device.
@@ -66,18 +65,18 @@ USBMouseDriverBindingEntryPoint (
EFI_STATUS
EFIAPI
USBMouseDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_STATUS Status;
+ EFI_USB_IO_PROTOCOL *UsbIo;
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
+ (VOID **)&UsbIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -96,16 +95,15 @@ USBMouseDriverBindingSupported (
}
gBS->CloseProtocol (
- Controller,
- &gEfiUsbIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiUsbIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return Status;
}
-
/**
Starts the mouse device with this driver.
@@ -128,22 +126,22 @@ USBMouseDriverBindingSupported (
EFI_STATUS
EFIAPI
USBMouseDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_USB_IO_PROTOCOL *UsbIo;
- USB_MOUSE_DEV *UsbMouseDevice;
- UINT8 EndpointNumber;
- EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
- UINT8 Index;
- UINT8 EndpointAddr;
- UINT8 PollingInterval;
- UINT8 PacketSize;
- BOOLEAN Found;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ USB_MOUSE_DEV *UsbMouseDevice;
+ UINT8 EndpointNumber;
+ EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
+ UINT8 Index;
+ UINT8 EndpointAddr;
+ UINT8 PollingInterval;
+ UINT8 PacketSize;
+ BOOLEAN Found;
+ EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
//
@@ -152,7 +150,7 @@ USBMouseDriverBindingStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo,
+ (VOID **)&UsbIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -173,7 +171,7 @@ USBMouseDriverBindingStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &UsbMouseDevice->DevicePath,
+ (VOID **)&UsbMouseDevice->DevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -214,11 +212,12 @@ USBMouseDriverBindingStart (
);
if (((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) &&
- ((EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) != 0)) {
+ ((EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) != 0))
+ {
//
// We only care interrupt endpoint here
//
- CopyMem(&UsbMouseDevice->IntEndpointDescriptor, &EndpointDescriptor, sizeof(EndpointDescriptor));
+ CopyMem (&UsbMouseDevice->IntEndpointDescriptor, &EndpointDescriptor, sizeof (EndpointDescriptor));
Found = TRUE;
break;
}
@@ -265,9 +264,9 @@ USBMouseDriverBindingStart (
//
// Initialize and install EFI Simple Pointer Protocol.
//
- UsbMouseDevice->SimplePointerProtocol.GetState = GetMouseState;
- UsbMouseDevice->SimplePointerProtocol.Reset = UsbMouseReset;
- UsbMouseDevice->SimplePointerProtocol.Mode = &UsbMouseDevice->Mode;
+ UsbMouseDevice->SimplePointerProtocol.GetState = GetMouseState;
+ UsbMouseDevice->SimplePointerProtocol.Reset = UsbMouseReset;
+ UsbMouseDevice->SimplePointerProtocol.Mode = &UsbMouseDevice->Mode;
Status = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
@@ -307,7 +306,7 @@ USBMouseDriverBindingStart (
//
EndpointAddr = UsbMouseDevice->IntEndpointDescriptor.EndpointAddress;
PollingInterval = UsbMouseDevice->IntEndpointDescriptor.Interval;
- PacketSize = (UINT8) (UsbMouseDevice->IntEndpointDescriptor.MaxPacketSize);
+ PacketSize = (UINT8)(UsbMouseDevice->IntEndpointDescriptor.MaxPacketSize);
Status = UsbIo->UsbAsyncInterruptTransfer (
UsbIo,
@@ -351,17 +350,17 @@ USBMouseDriverBindingStart (
return EFI_SUCCESS;
-//
-// Error handler
-//
+ //
+ // Error handler
+ //
ErrorExit:
if (EFI_ERROR (Status)) {
gBS->CloseProtocol (
- Controller,
- &gEfiUsbIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiUsbIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
if (UsbMouseDevice != NULL) {
if ((UsbMouseDevice->SimplePointerProtocol).WaitForInput != NULL) {
@@ -378,7 +377,6 @@ ErrorExit1:
return Status;
}
-
/**
Stop the USB mouse device handled by this driver.
@@ -395,21 +393,21 @@ ErrorExit1:
EFI_STATUS
EFIAPI
USBMouseDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_STATUS Status;
- USB_MOUSE_DEV *UsbMouseDevice;
- EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
- EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_STATUS Status;
+ USB_MOUSE_DEV *UsbMouseDevice;
+ EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
+ EFI_USB_IO_PROTOCOL *UsbIo;
Status = gBS->OpenProtocol (
Controller,
&gEfiSimplePointerProtocolGuid,
- (VOID **) &SimplePointerProtocol,
+ (VOID **)&SimplePointerProtocol,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -478,10 +476,8 @@ USBMouseDriverBindingStop (
FreePool (UsbMouseDevice);
return EFI_SUCCESS;
-
}
-
/**
Uses USB I/O to check whether the device is a USB mouse device.
@@ -493,7 +489,7 @@ USBMouseDriverBindingStop (
**/
BOOLEAN
IsUsbMouse (
- IN EFI_USB_IO_PROTOCOL *UsbIo
+ IN EFI_USB_IO_PROTOCOL *UsbIo
)
{
EFI_STATUS Status;
@@ -514,14 +510,14 @@ IsUsbMouse (
if ((InterfaceDescriptor.InterfaceClass == CLASS_HID) &&
(InterfaceDescriptor.InterfaceSubClass == SUBCLASS_BOOT) &&
(InterfaceDescriptor.InterfaceProtocol == PROTOCOL_MOUSE)
- ) {
+ )
+ {
return TRUE;
}
return FALSE;
}
-
/**
Initialize the USB mouse device.
@@ -539,20 +535,20 @@ IsUsbMouse (
**/
EFI_STATUS
InitializeUsbMouseDevice (
- IN OUT USB_MOUSE_DEV *UsbMouseDev
+ IN OUT USB_MOUSE_DEV *UsbMouseDev
)
{
- EFI_USB_IO_PROTOCOL *UsbIo;
- UINT8 Protocol;
- EFI_STATUS Status;
- EFI_USB_HID_DESCRIPTOR *MouseHidDesc;
- UINT8 *ReportDesc;
- EFI_USB_CONFIG_DESCRIPTOR ConfigDesc;
- VOID *Buf;
- UINT32 TransferResult;
- UINT16 Total;
- USB_DESC_HEAD *Head;
- BOOLEAN Start;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ UINT8 Protocol;
+ EFI_STATUS Status;
+ EFI_USB_HID_DESCRIPTOR *MouseHidDesc;
+ UINT8 *ReportDesc;
+ EFI_USB_CONFIG_DESCRIPTOR ConfigDesc;
+ VOID *Buf;
+ UINT32 TransferResult;
+ UINT16 Total;
+ USB_DESC_HEAD *Head;
+ BOOLEAN Start;
UsbIo = UsbMouseDev->UsbIo;
@@ -589,9 +585,9 @@ InitializeUsbMouseDevice (
return Status;
}
- Total = 0;
- Start = FALSE;
- Head = (USB_DESC_HEAD *)Buf;
+ Total = 0;
+ Start = FALSE;
+ Head = (USB_DESC_HEAD *)Buf;
MouseHidDesc = NULL;
//
@@ -602,19 +598,23 @@ InitializeUsbMouseDevice (
while (Total < ConfigDesc.TotalLength) {
if (Head->Type == USB_DESC_TYPE_INTERFACE) {
if ((((USB_INTERFACE_DESCRIPTOR *)Head)->InterfaceNumber == UsbMouseDev->InterfaceDescriptor.InterfaceNumber) &&
- (((USB_INTERFACE_DESCRIPTOR *)Head)->AlternateSetting == UsbMouseDev->InterfaceDescriptor.AlternateSetting)) {
+ (((USB_INTERFACE_DESCRIPTOR *)Head)->AlternateSetting == UsbMouseDev->InterfaceDescriptor.AlternateSetting))
+ {
Start = TRUE;
}
}
+
if (Start && (Head->Type == USB_DESC_TYPE_ENDPOINT)) {
break;
}
+
if (Start && (Head->Type == USB_DESC_TYPE_HID)) {
MouseHidDesc = (EFI_USB_HID_DESCRIPTOR *)Head;
break;
}
+
Total = Total + (UINT16)Head->Len;
- Head = (USB_DESC_HEAD*)((UINT8 *)Buf + Total);
+ Head = (USB_DESC_HEAD *)((UINT8 *)Buf + Total);
}
if (MouseHidDesc == NULL) {
@@ -668,9 +668,11 @@ InitializeUsbMouseDevice (
if (UsbMouseDev->NumberOfButtons >= 1) {
UsbMouseDev->Mode.LeftButton = TRUE;
}
+
if (UsbMouseDev->NumberOfButtons > 1) {
UsbMouseDev->Mode.RightButton = TRUE;
}
+
UsbMouseDev->Mode.ResolutionX = 8;
UsbMouseDev->Mode.ResolutionY = 8;
UsbMouseDev->Mode.ResolutionZ = 0;
@@ -720,7 +722,6 @@ InitializeUsbMouseDevice (
return EFI_SUCCESS;
}
-
/**
Handler function for USB mouse's asynchronous interrupt transfer.
@@ -741,19 +742,19 @@ InitializeUsbMouseDevice (
EFI_STATUS
EFIAPI
OnMouseInterruptComplete (
- IN VOID *Data,
- IN UINTN DataLength,
- IN VOID *Context,
- IN UINT32 Result
+ IN VOID *Data,
+ IN UINTN DataLength,
+ IN VOID *Context,
+ IN UINT32 Result
)
{
- USB_MOUSE_DEV *UsbMouseDevice;
- EFI_USB_IO_PROTOCOL *UsbIo;
- UINT8 EndpointAddr;
- UINT32 UsbResult;
+ USB_MOUSE_DEV *UsbMouseDevice;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ UINT8 EndpointAddr;
+ UINT32 UsbResult;
- UsbMouseDevice = (USB_MOUSE_DEV *) Context;
- UsbIo = UsbMouseDevice->UsbIo;
+ UsbMouseDevice = (USB_MOUSE_DEV *)Context;
+ UsbIo = UsbMouseDevice->UsbIo;
if (Result != EFI_USB_NOERROR) {
//
@@ -802,7 +803,7 @@ OnMouseInterruptComplete (
//
// If no error and no data, just return EFI_SUCCESS.
//
- if (DataLength == 0 || Data == NULL) {
+ if ((DataLength == 0) || (Data == NULL)) {
return EFI_SUCCESS;
}
@@ -824,13 +825,13 @@ OnMouseInterruptComplete (
UsbMouseDevice->StateChanged = TRUE;
- UsbMouseDevice->State.LeftButton = (BOOLEAN) ((*(UINT8 *) Data & BIT0) != 0);
- UsbMouseDevice->State.RightButton = (BOOLEAN) ((*(UINT8 *) Data & BIT1) != 0);
- UsbMouseDevice->State.RelativeMovementX += *((INT8 *) Data + 1);
- UsbMouseDevice->State.RelativeMovementY += *((INT8 *) Data + 2);
+ UsbMouseDevice->State.LeftButton = (BOOLEAN)((*(UINT8 *)Data & BIT0) != 0);
+ UsbMouseDevice->State.RightButton = (BOOLEAN)((*(UINT8 *)Data & BIT1) != 0);
+ UsbMouseDevice->State.RelativeMovementX += *((INT8 *)Data + 1);
+ UsbMouseDevice->State.RelativeMovementY += *((INT8 *)Data + 2);
if (DataLength > 3) {
- UsbMouseDevice->State.RelativeMovementZ += *((INT8 *) Data + 3);
+ UsbMouseDevice->State.RelativeMovementZ += *((INT8 *)Data + 3);
}
return EFI_SUCCESS;
@@ -857,7 +858,7 @@ GetMouseState (
OUT EFI_SIMPLE_POINTER_STATE *MouseState
)
{
- USB_MOUSE_DEV *MouseDev;
+ USB_MOUSE_DEV *MouseDev;
if (MouseState == NULL) {
return EFI_INVALID_PARAMETER;
@@ -885,12 +886,11 @@ GetMouseState (
MouseDev->State.RelativeMovementY = 0;
MouseDev->State.RelativeMovementZ = 0;
- MouseDev->StateChanged = FALSE;
+ MouseDev->StateChanged = FALSE;
return EFI_SUCCESS;
}
-
/**
Resets the pointer device hardware.
@@ -905,13 +905,13 @@ GetMouseState (
EFI_STATUS
EFIAPI
UsbMouseReset (
- IN EFI_SIMPLE_POINTER_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- USB_MOUSE_DEV *UsbMouseDevice;
+ USB_MOUSE_DEV *UsbMouseDevice;
- UsbMouseDevice = USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This);
+ UsbMouseDevice = USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (This);
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
EFI_PROGRESS_CODE,
@@ -941,13 +941,13 @@ UsbMouseReset (
VOID
EFIAPI
UsbMouseWaitForInput (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- USB_MOUSE_DEV *UsbMouseDev;
+ USB_MOUSE_DEV *UsbMouseDev;
- UsbMouseDev = (USB_MOUSE_DEV *) Context;
+ UsbMouseDev = (USB_MOUSE_DEV *)Context;
//
// If there's input from mouse, signal the event.
@@ -973,16 +973,16 @@ UsbMouseWaitForInput (
VOID
EFIAPI
USBMouseRecoveryHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- USB_MOUSE_DEV *UsbMouseDev;
- EFI_USB_IO_PROTOCOL *UsbIo;
+ USB_MOUSE_DEV *UsbMouseDev;
+ EFI_USB_IO_PROTOCOL *UsbIo;
- UsbMouseDev = (USB_MOUSE_DEV *) Context;
+ UsbMouseDev = (USB_MOUSE_DEV *)Context;
- UsbIo = UsbMouseDev->UsbIo;
+ UsbIo = UsbMouseDev->UsbIo;
//
// Re-submit Asynchronous Interrupt Transfer for recovery.
diff --git a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.h b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.h
index f460696..3ddd765 100644
--- a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.h
+++ b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.h
@@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _EFI_USB_MOUSE_H_
#define _EFI_USB_MOUSE_H_
-
#include <Uefi.h>
#include <Protocol/SimplePointer.h>
@@ -27,14 +26,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <IndustryStandard/Usb.h>
-#define CLASS_HID 3
-#define SUBCLASS_BOOT 1
-#define PROTOCOL_MOUSE 2
+#define CLASS_HID 3
+#define SUBCLASS_BOOT 1
+#define PROTOCOL_MOUSE 2
-#define BOOT_PROTOCOL 0
-#define REPORT_PROTOCOL 1
+#define BOOT_PROTOCOL 0
+#define REPORT_PROTOCOL 1
-#define USB_MOUSE_DEV_SIGNATURE SIGNATURE_32 ('u', 'm', 'o', 'u')
+#define USB_MOUSE_DEV_SIGNATURE SIGNATURE_32 ('u', 'm', 'o', 'u')
//
// A common header for usb standard descriptor.
@@ -42,8 +41,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
#pragma pack(1)
typedef struct {
- UINT8 Len;
- UINT8 Type;
+ UINT8 Len;
+ UINT8 Type;
} USB_DESC_HEAD;
#pragma pack()
@@ -51,33 +50,33 @@ typedef struct {
/// Button range and status
///
typedef struct {
- BOOLEAN ButtonDetected;
- UINT8 ButtonMinIndex;
- UINT8 ButtonMaxIndex;
- UINT8 Reserved;
+ BOOLEAN ButtonDetected;
+ UINT8 ButtonMinIndex;
+ UINT8 ButtonMaxIndex;
+ UINT8 Reserved;
} USB_MOUSE_BUTTON_DATA;
///
/// Device instance of USB mouse.
///
typedef struct {
- UINTN Signature;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_EVENT DelayedRecoveryEvent;
- EFI_USB_IO_PROTOCOL *UsbIo;
- EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
- EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;
- UINT8 NumberOfButtons;
- INT32 XLogicMax;
- INT32 XLogicMin;
- INT32 YLogicMax;
- INT32 YLogicMin;
- EFI_SIMPLE_POINTER_PROTOCOL SimplePointerProtocol;
- EFI_SIMPLE_POINTER_STATE State;
- EFI_SIMPLE_POINTER_MODE Mode;
- BOOLEAN StateChanged;
- USB_MOUSE_BUTTON_DATA PrivateData;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+ UINTN Signature;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_EVENT DelayedRecoveryEvent;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
+ EFI_USB_ENDPOINT_DESCRIPTOR IntEndpointDescriptor;
+ UINT8 NumberOfButtons;
+ INT32 XLogicMax;
+ INT32 XLogicMin;
+ INT32 YLogicMax;
+ INT32 YLogicMin;
+ EFI_SIMPLE_POINTER_PROTOCOL SimplePointerProtocol;
+ EFI_SIMPLE_POINTER_STATE State;
+ EFI_SIMPLE_POINTER_MODE Mode;
+ BOOLEAN StateChanged;
+ USB_MOUSE_BUTTON_DATA PrivateData;
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
} USB_MOUSE_DEV;
///
@@ -85,21 +84,21 @@ typedef struct {
///
typedef union {
- UINT8 Uint8;
- UINT16 Uint16;
- UINT32 Uint32;
- INT8 Int8;
- INT16 Int16;
- INT32 Int32;
- UINT8 *LongData;
+ UINT8 Uint8;
+ UINT16 Uint16;
+ UINT32 Uint32;
+ INT8 Int8;
+ INT16 Int16;
+ INT32 Int32;
+ UINT8 *LongData;
} HID_DATA;
typedef struct {
- UINT16 Format;
- UINT8 Size;
- UINT8 Type;
- UINT8 Tag;
- HID_DATA Data;
+ UINT16 Format;
+ UINT8 Size;
+ UINT8 Type;
+ UINT8 Tag;
+ HID_DATA Data;
} HID_ITEM;
#define USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL(a) \
@@ -130,9 +129,9 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gUsbMouseComponentName2;
EFI_STATUS
EFIAPI
USBMouseDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -157,9 +156,9 @@ USBMouseDriverBindingSupported (
EFI_STATUS
EFIAPI
USBMouseDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -178,10 +177,10 @@ USBMouseDriverBindingStart (
EFI_STATUS
EFIAPI
USBMouseDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
);
//
@@ -291,11 +290,11 @@ UsbMouseComponentNameGetDriverName (
EFI_STATUS
EFIAPI
UsbMouseComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
//
@@ -337,8 +336,8 @@ GetMouseState (
EFI_STATUS
EFIAPI
UsbMouseReset (
- IN EFI_SIMPLE_POINTER_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_POINTER_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
/**
@@ -351,8 +350,8 @@ UsbMouseReset (
VOID
EFIAPI
UsbMouseWaitForInput (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
//
@@ -370,7 +369,7 @@ UsbMouseWaitForInput (
**/
BOOLEAN
IsUsbMouse (
- IN EFI_USB_IO_PROTOCOL *UsbIo
+ IN EFI_USB_IO_PROTOCOL *UsbIo
);
/**
@@ -390,7 +389,7 @@ IsUsbMouse (
**/
EFI_STATUS
InitializeUsbMouseDevice (
- IN OUT USB_MOUSE_DEV *UsbMouseDev
+ IN OUT USB_MOUSE_DEV *UsbMouseDev
);
/**
@@ -413,10 +412,10 @@ InitializeUsbMouseDevice (
EFI_STATUS
EFIAPI
OnMouseInterruptComplete (
- IN VOID *Data,
- IN UINTN DataLength,
- IN VOID *Context,
- IN UINT32 Result
+ IN VOID *Data,
+ IN UINTN DataLength,
+ IN VOID *Context,
+ IN UINT32 Result
);
/**
@@ -435,8 +434,8 @@ OnMouseInterruptComplete (
VOID
EFIAPI
USBMouseRecoveryHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -457,9 +456,9 @@ USBMouseRecoveryHandler (
**/
EFI_STATUS
ParseMouseReportDescriptor (
- OUT USB_MOUSE_DEV *UsbMouse,
- IN UINT8 *ReportDescriptor,
- IN UINTN ReportSize
+ OUT USB_MOUSE_DEV *UsbMouse,
+ IN UINT8 *ReportDescriptor,
+ IN UINTN ReportSize
);
#endif