1 /** @file 2 EFI_USB_HC_PROTOCOL as defined in EFI 1.10. 3 4 The USB Host Controller Protocol is used by code, typically USB bus drivers, 5 running in the EFI boot services environment, to perform data transactions 6 over a USB bus. In addition, it provides an abstraction for the root hub of the USB bus. 7 8 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR> 9 This program and the accompanying materials 10 are licensed and made available under the terms and conditions of the BSD License 11 which accompanies this distribution. The full text of the license may be found at 12 http://opensource.org/licenses/bsd-license.php 13 14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 16 17 **/ 18 19 #ifndef _USB_HOSTCONTROLLER_H_ 20 #define _USB_HOSTCONTROLLER_H_ 21 22 FILE_LICENCE ( BSD3 ); 23 24 #include <ipxe/efi/Protocol/Usb2HostController.h> 25 26 #define EFI_USB_HC_PROTOCOL_GUID \ 27 { \ 28 0xf5089266, 0x1aa0, 0x4953, {0x97, 0xd8, 0x56, 0x2f, 0x8a, 0x73, 0xb5, 0x19 } \ 29 } 30 31 /// 32 /// Forward reference for pure ANSI compatability 33 /// 34 typedef struct _EFI_USB_HC_PROTOCOL EFI_USB_HC_PROTOCOL; 35 36 // 37 // Protocol definitions 38 // 39 40 /** 41 Provides software reset for the USB host controller. 42 43 @param This A pointer to the EFI_USB_HC_PROTOCOL instance. 44 @param Attributes A bit mask of the reset operation to perform. 45 46 @retval EFI_SUCCESS The reset operation succeeded. 47 @retval EFI_UNSUPPORTED The type of reset specified by Attributes is not currently supported 48 by the host controller hardware. 49 @retval EFI_INVALID_PARAMETER Attributes is not valid. 50 @retval EFI_DEVICE_ERROR An error was encountered while attempting to perform the reset operation. 51 52 **/ 53 typedef 54 EFI_STATUS 55 (EFIAPI *EFI_USB_HC_PROTOCOL_RESET)( 56 IN EFI_USB_HC_PROTOCOL *This, 57 IN UINT16 Attributes 58 ); 59 60 /** 61 Retrieves current state of the USB host controller. 62 63 @param This A pointer to the EFI_USB_HC_PROTOCOL instance. 64 @param State A pointer to the EFI_USB_HC_STATE data structure that 65 indicates current state of the USB host controller. 66 67 @retval EFI_SUCCESS The state information of the host controller was returned in State. 68 @retval EFI_INVALID_PARAMETER State is NULL. 69 @retval EFI_DEVICE_ERROR An error was encountered while attempting to retrieve the host controller's 70 current state. 71 72 **/ 73 typedef 74 EFI_STATUS 75 (EFIAPI *EFI_USB_HC_PROTOCOL_GET_STATE)( 76 IN EFI_USB_HC_PROTOCOL *This, 77 OUT EFI_USB_HC_STATE *State 78 ); 79 80 /** 81 Sets the USB host controller to a specific state. 82 83 @param This A pointer to the EFI_USB_HC_PROTOCOL instance. 84 @param State Indicates the state of the host controller that will be set. 85 86 @retval EFI_SUCCESS The USB host controller was successfully placed in the state specified by 87 State. 88 @retval EFI_INVALID_PARAMETER State is NULL. 89 @retval EFI_DEVICE_ERROR Failed to set the state specified by State due to device error. 90 91 **/ 92 typedef 93 EFI_STATUS 94 (EFIAPI *EFI_USB_HC_PROTOCOL_SET_STATE)( 95 IN EFI_USB_HC_PROTOCOL *This, 96 IN EFI_USB_HC_STATE State 97 ); 98 99 /** 100 Submits control transfer to a target USB device. 101 102 @param This A pointer to the EFI_USB_HC_PROTOCOL instance. 103 @param DeviceAddress Represents the address of the target device on the USB, which is 104 assigned during USB enumeration. 105 @param IsSlowDevice Indicates whether the target device is slow device or full-speed 106 device. 107 @param MaximumPacketLength Indicates the maximum packet size that the default control 108 transfer endpoint is capable of sending or receiving. 109 @param Request A pointer to the USB device request that will be sent to the USB 110 device. 111 @param TransferDirection Specifies the data direction for the transfer. There are three 112 values available, EfiUsbDataIn, EfiUsbDataOut and EfiUsbNoData. 113 @param Data A pointer to the buffer of data that will be transmitted to USB 114 device or received from USB device. 115 @param DataLength On input, indicates the size, in bytes, of the data buffer specified 116 by Data. On output, indicates the amount of data actually 117 transferred. 118 @param TimeOut Indicates the maximum time, in milliseconds, which the transfer 119 is allowed to complete. 120 @param TransferResult A pointer to the detailed result information generated by this 121 control transfer. 122 123 @retval EFI_SUCCESS The control transfer was completed successfully. 124 @retval EFI_OUT_OF_RESOURCES The control transfer could not be completed due to a lack of resources. 125 @retval EFI_INVALID_PARAMETER Some parameters are invalid. 126 @retval EFI_TIMEOUT The control transfer failed due to timeout. 127 @retval EFI_DEVICE_ERROR The control transfer failed due to host controller or device error. 128 129 **/ 130 typedef 131 EFI_STATUS 132 (EFIAPI *EFI_USB_HC_PROTOCOL_CONTROL_TRANSFER)( 133 IN EFI_USB_HC_PROTOCOL *This, 134 IN UINT8 DeviceAddress, 135 IN BOOLEAN IsSlowDevice, 136 IN UINT8 MaximumPacketLength, 137 IN EFI_USB_DEVICE_REQUEST *Request, 138 IN EFI_USB_DATA_DIRECTION TransferDirection, 139 IN OUT VOID *Data OPTIONAL, 140 IN OUT UINTN *DataLength OPTIONAL, 141 IN UINTN TimeOut, 142 OUT UINT32 *TransferResult 143 ); 144 145 /** 146 Submits bulk transfer to a bulk endpoint of a USB device. 147 148 @param This A pointer to the EFI_USB_HC_PROTOCOL instance. 149 @param DeviceAddress Represents the address of the target device on the USB, which is 150 assigned during USB enumeration. 151 @param EndPointAddress The combination of an endpoint number and an endpoint 152 direction of the target USB device. Each endpoint address 153 supports data transfer in one direction except the control 154 endpoint (whose default endpoint address is 0). It is the 155 caller's responsibility to make sure that the EndPointAddress 156 represents a bulk endpoint. 157 @param MaximumPacketLength Indicates the maximum packet size that the default control 158 transfer endpoint is capable of sending or receiving. 159 @param Data A pointer to the buffer of data that will be transmitted to USB 160 device or received from USB device. 161 @param DataLength On input, indicates the size, in bytes, of the data buffer specified 162 by Data. On output, indicates the amount of data actually 163 transferred. 164 @param DataToggle A pointer to the data toggle value. 165 @param TimeOut Indicates the maximum time, in milliseconds, which the transfer 166 is allowed to complete. 167 @param TransferResult A pointer to the detailed result information of the bulk transfer. 168 169 @retval EFI_SUCCESS The bulk transfer was completed successfully. 170 @retval EFI_OUT_OF_RESOURCES The bulk transfer could not be completed due to a lack of resources. 171 @retval EFI_INVALID_PARAMETER Some parameters are invalid. 172 @retval EFI_TIMEOUT The bulk transfer failed due to timeout. 173 @retval EFI_DEVICE_ERROR The bulk transfer failed due to host controller or device error. 174 175 **/ 176 typedef 177 EFI_STATUS 178 (EFIAPI *EFI_USB_HC_PROTOCOL_BULK_TRANSFER)( 179 IN EFI_USB_HC_PROTOCOL *This, 180 IN UINT8 DeviceAddress, 181 IN UINT8 EndPointAddress, 182 IN UINT8 MaximumPacketLength, 183 IN OUT VOID *Data, 184 IN OUT UINTN *DataLength, 185 IN OUT UINT8 *DataToggle, 186 IN UINTN TimeOut, 187 OUT UINT32 *TransferResult 188 ); 189 190 /** 191 Submits an asynchronous interrupt transfer to an interrupt endpoint of a USB device. 192 193 @param This A pointer to the EFI_USB_HC_PROTOCOL instance. 194 @param DeviceAddress Represents the address of the target device on the USB, which is 195 assigned during USB enumeration. 196 @param EndPointAddress The combination of an endpoint number and an endpoint 197 direction of the target USB device. Each endpoint address 198 supports data transfer in one direction except the control 199 endpoint (whose default endpoint address is zero). It is the 200 caller's responsibility to make sure that the 201 EndPointAddress represents an interrupt endpoint. 202 @param IsSlowDevice Indicates whether the target device is slow device or full-speed 203 device. 204 @param MaximumPacketLength Indicates the maximum packet size that the default control 205 transfer endpoint is capable of sending or receiving. 206 @param IsNewTransfer If TRUE, an asynchronous interrupt pipe is built between the host 207 and the target interrupt endpoint. If FALSE, the specified asynchronous 208 interrupt pipe is canceled. If TRUE, and an interrupt transfer exists 209 for the target end point, then EFI_INVALID_PARAMETER is returned. 210 @param DataToggle A pointer to the data toggle value. On input, it is valid when 211 IsNewTransfer is TRUE, and it indicates the initial data toggle 212 value the asynchronous interrupt transfer should adopt. On output, 213 it is valid when IsNewTransfer is FALSE, and it is updated to indicate 214 the data toggle value of the subsequent asynchronous interrupt transfer. 215 @param PollingInterval Indicates the interval, in milliseconds, that the asynchronous 216 interrupt transfer is polled. 217 @param DataLength Indicates the length of data to be received at the rate specified by 218 PollingInterval from the target asynchronous interrupt 219 endpoint. This parameter is only required when IsNewTransfer is TRUE. 220 @param CallBackFunction The Callback function. This function is called at the rate specified by 221 PollingInterval. This parameter is only required when IsNewTransfer is TRUE. 222 @param Context The context that is passed to the CallBackFunction. 223 224 @retval EFI_SUCCESS The asynchronous interrupt transfer request has been successfully 225 submitted or canceled. 226 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. 227 @retval EFI_INVALID_PARAMETER Some parameters are invalid. 228 @retval EFI_TIMEOUT The bulk transfer failed due to timeout. 229 @retval EFI_DEVICE_ERROR The bulk transfer failed due to host controller or device error. 230 231 **/ 232 typedef 233 EFI_STATUS 234 (EFIAPI *EFI_USB_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER)( 235 IN EFI_USB_HC_PROTOCOL *This, 236 IN UINT8 DeviceAddress, 237 IN UINT8 EndPointAddress, 238 IN BOOLEAN IsSlowDevice, 239 IN UINT8 MaxiumPacketLength, 240 IN BOOLEAN IsNewTransfer, 241 IN OUT UINT8 *DataToggle, 242 IN UINTN PollingInterval OPTIONAL, 243 IN UINTN DataLength OPTIONAL, 244 IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction OPTIONAL, 245 IN VOID *Context OPTIONAL 246 ); 247 248 /** 249 Submits synchronous interrupt transfer to an interrupt endpoint of a USB device. 250 251 @param This A pointer to the EFI_USB_HC_PROTOCOL instance. 252 @param DeviceAddress Represents the address of the target device on the USB, which is 253 assigned during USB enumeration. 254 @param EndPointAddress The combination of an endpoint number and an endpoint 255 direction of the target USB device. Each endpoint address 256 supports data transfer in one direction except the control 257 endpoint (whose default endpoint address is zero). It is the 258 caller's responsibility to make sure that the 259 EndPointAddress represents an interrupt endpoint. 260 @param IsSlowDevice Indicates whether the target device is slow device or full-speed 261 device. 262 @param MaximumPacketLength Indicates the maximum packet size that the default control 263 transfer endpoint is capable of sending or receiving. 264 @param Data A pointer to the buffer of data that will be transmitted to USB 265 device or received from USB device. asynchronous interrupt pipe is canceled. 266 @param DataLength On input, the size, in bytes, of the data buffer specified by Data. 267 On output, the number of bytes transferred. 268 @param DataToggle A pointer to the data toggle value. On input, it indicates the initial 269 data toggle value the synchronous interrupt transfer should adopt; 270 on output, it is updated to indicate the data toggle value of the 271 subsequent synchronous interrupt transfer. 272 @param TimeOut Indicates the maximum time, in milliseconds, which the transfer 273 is allowed to complete. 274 @param TransferResult A pointer to the detailed result information from the synchronous 275 interrupt transfer. 276 277 @retval EFI_SUCCESS The synchronous interrupt transfer was completed successfully. 278 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. 279 @retval EFI_INVALID_PARAMETER Some parameters are invalid. 280 @retval EFI_TIMEOUT The synchronous interrupt transfer failed due to timeout. 281 @retval EFI_DEVICE_ERROR The synchronous interrupt transfer failed due to host controller or device error. 282 283 **/ 284 typedef 285 EFI_STATUS 286 (EFIAPI *EFI_USB_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER)( 287 IN EFI_USB_HC_PROTOCOL *This, 288 IN UINT8 DeviceAddress, 289 IN UINT8 EndPointAddress, 290 IN BOOLEAN IsSlowDevice, 291 IN UINT8 MaximumPacketLength, 292 IN OUT VOID *Data, 293 IN OUT UINTN *DataLength, 294 IN OUT UINT8 *DataToggle, 295 IN UINTN TimeOut, 296 OUT UINT32 *TransferResult 297 ); 298 299 /** 300 Submits isochronous transfer to an isochronous endpoint of a USB device. 301 302 @param This A pointer to the EFI_USB_HC_PROTOCOL instance. 303 @param DeviceAddress Represents the address of the target device on the USB, which is 304 assigned during USB enumeration. 305 @param EndPointAddress The combination of an endpoint number and an endpoint 306 direction of the target USB device. Each endpoint address 307 supports data transfer in one direction except the control 308 endpoint (whose default endpoint address is 0). It is the caller's 309 responsibility to make sure that the EndPointAddress 310 represents an isochronous endpoint. 311 @param MaximumPacketLength Indicates the maximum packet size that the default control 312 transfer endpoint is capable of sending or receiving. 313 @param Data A pointer to the buffer of data that will be transmitted to USB 314 device or received from USB device. asynchronous interrupt pipe is canceled. 315 @param DataLength Specifies the length, in bytes, of the data to be sent to or received 316 from the USB device. 317 @param TransferResult A pointer to the detailed result information from the isochronous 318 transfer. 319 320 @retval EFI_SUCCESS The isochronous transfer was completed successfully. 321 @retval EFI_OUT_OF_RESOURCES The isochronous could not be completed due to a lack of resources. 322 @retval EFI_INVALID_PARAMETER Some parameters are invalid. 323 @retval EFI_TIMEOUT The isochronous transfer failed due to timeout. 324 @retval EFI_DEVICE_ERROR The isochronous transfer failed due to host controller or device error. 325 326 **/ 327 typedef 328 EFI_STATUS 329 (EFIAPI *EFI_USB_HC_PROTOCOL_ISOCHRONOUS_TRANSFER)( 330 IN EFI_USB_HC_PROTOCOL *This, 331 IN UINT8 DeviceAddress, 332 IN UINT8 EndPointAddress, 333 IN UINT8 MaximumPacketLength, 334 IN OUT VOID *Data, 335 IN UINTN DataLength, 336 OUT UINT32 *TransferResult 337 ); 338 339 /** 340 Submits nonblocking isochronous transfer to an isochronous endpoint of a USB device. 341 342 @param This A pointer to the EFI_USB_HC_PROTOCOL instance. 343 @param DeviceAddress Represents the address of the target device on the USB, which is 344 assigned during USB enumeration. 345 @param EndPointAddress The combination of an endpoint number and an endpoint 346 direction of the target USB device. Each endpoint address 347 supports data transfer in one direction except the control 348 endpoint (whose default endpoint address is zero). It is the 349 caller's responsibility to make sure that the 350 EndPointAddress represents an isochronous endpoint. 351 @param MaximumPacketLength Indicates the maximum packet size that the default control 352 transfer endpoint is capable of sending or receiving. For isochronous 353 endpoints, this value is used to reserve the bus time in the schedule, 354 required for the perframe data payloads. The pipe may, on an ongoing basis, 355 actually use less bandwidth than that reserved. 356 @param Data A pointer to the buffer of data that will be transmitted to USB 357 device or received from USB device. asynchronous interrupt pipe is canceled. 358 @param DataLength Specifies the length, in bytes, of the data to be sent to or received 359 from the USB device. 360 @param IsochronousCallback The Callback function.This function is called if the requested 361 isochronous transfer is completed. 362 @param Context Data passed to the IsochronousCallback function. This is 363 an optional parameter and may be NULL. 364 365 @retval EFI_SUCCESS The asynchronous isochronous transfer was completed successfully. 366 @retval EFI_OUT_OF_RESOURCES The asynchronous isochronous could not be completed due to a lack of resources. 367 @retval EFI_INVALID_PARAMETER Some parameters are invalid. 368 369 **/ 370 typedef 371 EFI_STATUS 372 (EFIAPI *EFI_USB_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER)( 373 IN EFI_USB_HC_PROTOCOL *This, 374 IN UINT8 DeviceAddress, 375 IN UINT8 EndPointAddress, 376 IN UINT8 MaximumPacketLength, 377 IN OUT VOID *Data, 378 IN UINTN DataLength, 379 IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack, 380 IN VOID *Context OPTIONAL 381 ); 382 383 /** 384 Retrieves the number of root hub ports. 385 386 @param This A pointer to the EFI_USB_HC_PROTOCOL instance. 387 @param PortNumber A pointer to the number of the root hub ports. 388 389 @retval EFI_SUCCESS The port number was retrieved successfully. 390 @retval EFI_DEVICE_ERROR An error was encountered while attempting to retrieve the port number. 391 @retval EFI_INVALID_PARAMETER PortNumber is NULL. 392 393 **/ 394 typedef 395 EFI_STATUS 396 (EFIAPI *EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_NUMBER)( 397 IN EFI_USB_HC_PROTOCOL *This, 398 OUT UINT8 *PortNumber 399 ); 400 401 /** 402 Retrieves the current status of a USB root hub port. 403 404 @param This A pointer to the EFI_USB_HC_PROTOCOL instance. 405 @param PortNumber Specifies the root hub port from which the status is to be retrieved. 406 This value is zero based. For example, if a root hub has two ports, 407 then the first port is numbered 0, and the second port is 408 numbered 1. 409 @param PortStatus A pointer to the current port status bits and port status change bits. 410 411 @retval EFI_SUCCESS The status of the USB root hub port specified by PortNumber 412 was returned in PortStatus. 413 @retval EFI_INVALID_PARAMETER PortNumber is invalid. 414 415 **/ 416 typedef 417 EFI_STATUS 418 (EFIAPI *EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS)( 419 IN EFI_USB_HC_PROTOCOL *This, 420 IN UINT8 PortNumber, 421 OUT EFI_USB_PORT_STATUS *PortStatus 422 ); 423 424 /** 425 Sets a feature for the specified root hub port. 426 427 @param This A pointer to the EFI_USB_HC_PROTOCOL instance. 428 @param PortNumber Specifies the root hub port from which the status is to be retrieved. 429 This value is zero based. For example, if a root hub has two ports, 430 then the first port is numbered 0, and the second port is 431 numbered 1. 432 @param PortFeature Indicates the feature selector associated with the feature set 433 request. 434 435 @retval EFI_SUCCESS The feature specified by PortFeature was set for the USB 436 root hub port specified by PortNumber. 437 @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function. 438 439 **/ 440 typedef 441 EFI_STATUS 442 (EFIAPI *EFI_USB_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE)( 443 IN EFI_USB_HC_PROTOCOL *This, 444 IN UINT8 PortNumber, 445 IN EFI_USB_PORT_FEATURE PortFeature 446 ); 447 448 /** 449 Clears a feature for the specified root hub port. 450 451 @param This A pointer to the EFI_USB_HC_PROTOCOL instance. 452 @param PortNumber Specifies the root hub port from which the status is to be retrieved. 453 This value is zero based. For example, if a root hub has two ports, 454 then the first port is numbered 0, and the second port is 455 numbered 1. 456 @param PortFeature Indicates the feature selector associated with the feature clear 457 request. 458 459 @retval EFI_SUCCESS The feature specified by PortFeature was cleared for the USB 460 root hub port specified by PortNumber. 461 @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function. 462 463 **/ 464 typedef 465 EFI_STATUS 466 (EFIAPI *EFI_USB_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE)( 467 IN EFI_USB_HC_PROTOCOL *This, 468 IN UINT8 PortNumber, 469 IN EFI_USB_PORT_FEATURE PortFeature 470 ); 471 472 473 /// 474 /// The EFI_USB_HC_PROTOCOL provides USB host controller management, basic data transactions 475 /// over a USB bus, and USB root hub access. A device driver that wishes to manage a USB bus in a 476 /// system retrieves the EFI_USB_HC_PROTOCOL instance that is associated with the USB bus to be 477 /// managed. A device handle for a USB host controller will minimally contain an 478 /// EFI_DEVICE_PATH_PROTOCOL instance, and an EFI_USB_HC_PROTOCOL instance. 479 /// 480 struct _EFI_USB_HC_PROTOCOL { 481 EFI_USB_HC_PROTOCOL_RESET Reset; 482 EFI_USB_HC_PROTOCOL_GET_STATE GetState; 483 EFI_USB_HC_PROTOCOL_SET_STATE SetState; 484 EFI_USB_HC_PROTOCOL_CONTROL_TRANSFER ControlTransfer; 485 EFI_USB_HC_PROTOCOL_BULK_TRANSFER BulkTransfer; 486 EFI_USB_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER AsyncInterruptTransfer; 487 EFI_USB_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER SyncInterruptTransfer; 488 EFI_USB_HC_PROTOCOL_ISOCHRONOUS_TRANSFER IsochronousTransfer; 489 EFI_USB_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER AsyncIsochronousTransfer; 490 EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_NUMBER GetRootHubPortNumber; 491 EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS GetRootHubPortStatus; 492 EFI_USB_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE SetRootHubPortFeature; 493 EFI_USB_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE ClearRootHubPortFeature; 494 /// 495 /// The major revision number of the USB host controller. The revision information 496 /// indicates the release of the Universal Serial Bus Specification with which the 497 /// host controller is compliant. 498 /// 499 UINT16 MajorRevision; 500 /// 501 /// The minor revision number of the USB host controller. The revision information 502 /// indicates the release of the Universal Serial Bus Specification with which the 503 /// host controller is compliant. 504 /// 505 UINT16 MinorRevision; 506 }; 507 508 extern EFI_GUID gEfiUsbHcProtocolGuid; 509 510 #endif 511