|
| | FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) |
| | FILE_SECBOOT (PERMITTED) |
| static const char * | efi_usb_direction_name (EFI_USB_DATA_DIRECTION direction) |
| | Transcribe data direction (for debugging)
|
| static VOID EFIAPI | efi_usb_timer (EFI_EVENT event __unused, VOID *context) |
| | Poll USB bus (from endpoint event timer)
|
| static int | efi_usb_mtu (struct efi_usb_interface *usbintf, unsigned int endpoint) |
| | Get endpoint MTU.
|
| static int | efi_usb_is_open (struct efi_usb_interface *usbintf, unsigned int endpoint) |
| | Check if endpoint is open.
|
| static int | efi_usb_open (struct efi_usb_interface *usbintf, unsigned int endpoint, unsigned int attributes, unsigned int interval, struct usb_endpoint_driver_operations *driver) |
| | Open endpoint.
|
| static void | efi_usb_close (struct efi_usb_endpoint *usbep) |
| | Close endpoint.
|
| static void | efi_usb_close_all (struct efi_usb_interface *usbintf) |
| | Close all endpoints.
|
| static void | efi_usb_free_all (struct efi_usb_interface *usbintf) |
| | Free all endpoints.
|
| static void | efi_usb_sync_complete (struct usb_endpoint *ep, struct io_buffer *iobuf __unused, int rc) |
| | Complete synchronous transfer.
|
| static int | efi_usb_sync_transfer (struct efi_usb_interface *usbintf, unsigned int endpoint, unsigned int attributes, unsigned int timeout, void *data, size_t *len) |
| | Perform synchronous transfer.
|
| static void | efi_usb_async_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
| | Complete asynchronous transfer.
|
| static int | efi_usb_async_start (struct efi_usb_interface *usbintf, unsigned int endpoint, unsigned int interval, size_t len, EFI_ASYNC_USB_TRANSFER_CALLBACK callback, void *context) |
| | Start asynchronous transfer.
|
| static void | efi_usb_async_stop (struct efi_usb_interface *usbintf, unsigned int endpoint) |
| | Stop asynchronous transfer.
|
| static EFI_STATUS EFIAPI | efi_usb_control_transfer (EFI_USB_IO_PROTOCOL *usbio, EFI_USB_DEVICE_REQUEST *packet, EFI_USB_DATA_DIRECTION direction, UINT32 timeout, VOID *data, UINTN len, UINT32 *status) |
| | Perform control transfer.
|
| static EFI_STATUS EFIAPI | efi_usb_bulk_transfer (EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint, VOID *data, UINTN *len, UINTN timeout, UINT32 *status) |
| | Perform bulk transfer.
|
| static EFI_STATUS EFIAPI | efi_usb_sync_interrupt_transfer (EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint, VOID *data, UINTN *len, UINTN timeout, UINT32 *status) |
| | Perform synchronous interrupt transfer.
|
| static EFI_STATUS EFIAPI | efi_usb_async_interrupt_transfer (EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint, BOOLEAN start, UINTN interval, UINTN len, EFI_ASYNC_USB_TRANSFER_CALLBACK callback, VOID *context) |
| | Perform asynchronous interrupt transfer.
|
| static EFI_STATUS EFIAPI | efi_usb_isochronous_transfer (EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint, VOID *data, UINTN len, UINT32 *status) |
| | Perform synchronous isochronous transfer.
|
| static EFI_STATUS EFIAPI | efi_usb_async_isochronous_transfer (EFI_USB_IO_PROTOCOL *usbio, UINT8 endpoint, VOID *data, UINTN len, EFI_ASYNC_USB_TRANSFER_CALLBACK callback, VOID *context) |
| | Perform asynchronous isochronous transfers.
|
| static EFI_STATUS EFIAPI | efi_usb_get_device_descriptor (EFI_USB_IO_PROTOCOL *usbio, EFI_USB_DEVICE_DESCRIPTOR *efidesc) |
| | Get device descriptor.
|
| static EFI_STATUS EFIAPI | efi_usb_get_config_descriptor (EFI_USB_IO_PROTOCOL *usbio, EFI_USB_CONFIG_DESCRIPTOR *efidesc) |
| | Get configuration descriptor.
|
| static EFI_STATUS EFIAPI | efi_usb_get_interface_descriptor (EFI_USB_IO_PROTOCOL *usbio, EFI_USB_INTERFACE_DESCRIPTOR *efidesc) |
| | Get interface descriptor.
|
| static EFI_STATUS EFIAPI | efi_usb_get_endpoint_descriptor (EFI_USB_IO_PROTOCOL *usbio, UINT8 index, EFI_USB_ENDPOINT_DESCRIPTOR *efidesc) |
| | Get endpoint descriptor.
|
| static EFI_STATUS EFIAPI | efi_usb_get_string_descriptor (EFI_USB_IO_PROTOCOL *usbio, UINT16 language, UINT8 index, CHAR16 **string) |
| | Get string descriptor.
|
| static EFI_STATUS EFIAPI | efi_usb_get_supported_languages (EFI_USB_IO_PROTOCOL *usbio, UINT16 **languages, UINT16 *len) |
| | Get supported languages.
|
| static EFI_STATUS EFIAPI | efi_usb_port_reset (EFI_USB_IO_PROTOCOL *usbio) |
| | Reset port.
|
| static int | efi_usb_install (struct efi_usb_device *usbdev, unsigned int interface) |
| | Install interface.
|
| static void | efi_usb_uninstall (struct efi_usb_interface *usbintf) |
| | Uninstall interface.
|
| static void | efi_usb_uninstall_all (struct efi_usb_device *efiusb) |
| | Uninstall all interfaces.
|
| static int | efi_usb_probe (struct usb_function *func, struct usb_configuration_descriptor *config) |
| | Probe device.
|
| static void | efi_usb_remove (struct usb_function *func) |
| | Remove device.
|
EFI USB I/O PROTOCOL.
Definition in file efi_usb.c.
Poll USB bus (from endpoint event timer)
- Parameters
-
| event | EFI event |
| context | EFI USB endpoint |
Definition at line 75 of file efi_usb.c.
76 {
79
80
82
83
86}
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
struct usb_function * func
The underlying USB function.
An EFI USB device endpoint.
struct efi_usb_interface * usbintf
EFI USB device interface.
void * context
Asynchronous callback context.
struct usb_endpoint ep
USB endpoint.
struct efi_usb_device * usbdev
Containing USB device.
struct usb_port * port
USB port.
int open
Endpoint is open.
struct usb_device * usb
USB device.
struct usb_bus * bus
USB bus.
struct usb_hub * hub
USB hub.
int usb_refill(struct usb_endpoint *ep)
Refill endpoint.
References __unused, usb_hub::bus, efi_usb_endpoint::context, EFI_EVENT, EFIAPI, efi_usb_endpoint::ep, efi_usb_device::func, usb_port::hub, usb_endpoint::open, usb_device::port, usb_function::usb, usb_poll(), usb_refill(), efi_usb_interface::usbdev, efi_usb_endpoint::usbintf, and VOID.
Referenced by efi_usb_open().
Open endpoint.
- Parameters
-
| usbintf | EFI USB interface |
| endpoint | Endpoint address |
| attributes | Endpoint attributes |
| interval | Interval (in milliseconds) |
| driver | Driver operations |
- Return values
-
Definition at line 148 of file efi_usb.c.
151 {
159
160
161
162
163
164
166 if ( ! usbep ) {
167 usbep =
zalloc (
sizeof ( *usbep ) );
168 if ( ! usbep ) {
170 goto err_alloc;
171 }
174 }
175
176
180 goto err_mtu;
181 }
182
183
186 ( interval << 3 ) );
187
188
190 DBGC ( usbdev,
"USBDEV %s %s could not open: %s\n",
193 goto err_open;
194 }
195 DBGC ( usbdev,
"USBDEV %s %s opened\n",
197
198
201 &usbep->
event ) ) != 0 ) {
203 DBGC ( usbdev,
"USBDEV %s %s could not create event: %s\n",
206 goto err_event;
207 }
208
209 return 0;
210
212 err_event:
214 err_open:
215 err_mtu:
216 err_alloc:
218}
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
#define EVT_NOTIFY_SIGNAL
struct arbelprm_rc_send_wqe rc
static VOID EFIAPI efi_usb_timer(EFI_EVENT event __unused, VOID *context)
Poll USB bus (from endpoint event timer)
static int efi_usb_mtu(struct efi_usb_interface *usbintf, unsigned int endpoint)
Get endpoint MTU.
#define ENOMEM
Not enough space.
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
EFI_SYSTEM_TABLE * efi_systab
static void usb_endpoint_init(struct usb_endpoint *ep, struct usb_device *usb, struct usb_endpoint_driver_operations *driver)
Initialise USB endpoint.
static void usb_endpoint_describe(struct usb_endpoint *ep, unsigned int address, unsigned int attributes, size_t mtu, unsigned int burst, unsigned int interval)
Describe USB endpoint.
void * zalloc(size_t size)
Allocate cleared memory.
char * strerror(int errno)
Retrieve string representation of error number.
EFI_CREATE_EVENT CreateEvent
EFI_CLOSE_EVENT CloseEvent
EFI_EVENT event
Asynchronous timer event.
int usb_endpoint_open(struct usb_endpoint *ep)
Open USB endpoint.
void usb_endpoint_close(struct usb_endpoint *ep)
Close USB endpoint.
const char * usb_endpoint_name(struct usb_endpoint *ep)
Get USB endpoint name (for debugging)
References EFI_BOOT_SERVICES::CloseEvent, EFI_BOOT_SERVICES::CreateEvent, DBGC, EEFI, efi_systab, efi_usb_mtu(), efi_usb_timer(), efi_usb_interface::endpoint, ENOMEM, efi_usb_endpoint::ep, efi_usb_endpoint::event, EVT_NOTIFY_SIGNAL, EVT_TIMER, efi_usb_device::func, index, mtu, efi_usb_interface::name, rc, strerror(), TPL_CALLBACK, usb_function::usb, usb_endpoint_close(), usb_endpoint_describe(), USB_ENDPOINT_IDX, usb_endpoint_init(), usb_endpoint_name(), usb_endpoint_open(), efi_usb_interface::usbdev, efi_usb_endpoint::usbintf, and zalloc().
Referenced by efi_usb_async_start(), and efi_usb_sync_transfer().
| int efi_usb_sync_transfer |
( |
struct efi_usb_interface * | usbintf, |
|
|
unsigned int | endpoint, |
|
|
unsigned int | attributes, |
|
|
unsigned int | timeout, |
|
|
void * | data, |
|
|
size_t * | len ) |
|
static |
Perform synchronous transfer.
- Parameters
-
| usbintf | USB endpoint |
| endpoint | Endpoint address |
| attributes | Endpoint attributes |
| timeout | Timeout (in milliseconds) |
| data | Data buffer |
| len | Length of data buffer |
- Return values
-
Definition at line 313 of file efi_usb.c.
317 {
322 unsigned int i;
324
325
329 goto err_open;
330 }
332
333
335 if ( ! iobuf ) {
337 goto err_alloc;
338 }
342
343
345
346
348 DBGC ( usbdev,
"USBDEV %s %s could not enqueue: %s\n",
351 goto err_stream;
352 }
353
354
357
358
360
361
364 break;
365 }
366
367
369 }
370
371
373 DBGC ( usbdev,
"USBDEV %s %s failed: %s\n", usbintf->
name,
375 goto err_completion;
376 }
377
378
383
384
386
387
388 return 0;
389
390 err_completion:
391 err_stream:
393 err_alloc:
395 err_open:
397}
static int efi_usb_open(struct efi_usb_interface *usbintf, unsigned int endpoint, unsigned int attributes, unsigned int interval, struct usb_endpoint_driver_operations *driver)
Open endpoint.
static int efi_usb_is_open(struct efi_usb_interface *usbintf, unsigned int endpoint)
Check if endpoint is open.
static struct usb_endpoint_driver_operations efi_usb_sync_driver
Synchronous endpoint operations.
uint8_t data[48]
Additional event data.
#define ETIMEDOUT
Connection timed out.
#define EINPROGRESS
Operation in progress.
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
#define USB_ENDPOINT_IN
Endpoint direction is in.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
#define iob_put(iobuf, len)
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
void * data
Start of data.
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
References alloc_iob(), assert, usb_hub::bus, data, io_buffer::data, DBGC, efi_usb_close(), efi_usb_is_open(), efi_usb_open(), efi_usb_sync_driver, EFIRC, EINPROGRESS, efi_usb_interface::endpoint, ENOMEM, efi_usb_endpoint::ep, ETIMEDOUT, free_iob(), efi_usb_device::func, usb_port::hub, index, iob_len(), iob_put, len, mdelay(), memcpy(), efi_usb_interface::name, usb_device::port, efi_usb_endpoint::rc, rc, strerror(), timeout(), usb_function::usb, USB_ENDPOINT_IDX, USB_ENDPOINT_IN, usb_endpoint_name(), usb_poll(), usb_stream(), and efi_usb_interface::usbdev.
Referenced by efi_usb_bulk_transfer(), and efi_usb_sync_interrupt_transfer().
Start asynchronous transfer.
- Parameters
-
| usbintf | EFI USB interface |
| endpoint | Endpoint address |
| interval | Interval (in milliseconds) |
| len | Transfer length |
| callback | Callback function |
| context | Context for callback function |
- Return values
-
Definition at line 450 of file efi_usb.c.
454 {
461
462
465
466
470 goto err_open;
472
473
476
477
480 DBGC ( usbdev,
"USBDEV %s %s could not prefill: %s\n",
483 goto err_prefill;
484 }
485
486
488 ( interval * 10000 ) ) ) != 0 ) {
490 DBGC ( usbdev,
"USBDEV %s %s could not set timer: %s\n",
493 goto err_timer;
494 }
495
496 return 0;
497
499 err_timer:
500 err_prefill:
504 err_open:
506}
@ TimerPeriodic
An event is to be signaled periodically at a specified interval from the current time.
static struct usb_endpoint_driver_operations efi_usb_async_driver
Asynchronous endpoint operations.
#define EFI_USB_ASYNC_FILL
Asynchronous transfer fill level.
static void usb_refill_init(struct usb_endpoint *ep, size_t reserve, size_t len, unsigned int max)
Initialise USB endpoint refill.
#define USB_ENDPOINT_ATTR_INTERRUPT
Interrupt endpoint transfer type.
int usb_prefill(struct usb_endpoint *ep)
Prefill endpoint recycled buffer list.
References efi_usb_endpoint::callback, efi_usb_endpoint::context, DBGC, EEFI, efi_systab, efi_usb_async_driver, EFI_USB_ASYNC_FILL, efi_usb_close(), efi_usb_is_open(), efi_usb_open(), efi_usb_interface::endpoint, efi_usb_endpoint::ep, efi_usb_endpoint::event, index, len, efi_usb_interface::name, NULL, rc, EFI_BOOT_SERVICES::SetTimer, strerror(), TimerCancel, TimerPeriodic, USB_ENDPOINT_ATTR_INTERRUPT, USB_ENDPOINT_IDX, usb_endpoint_name(), usb_prefill(), usb_refill_init(), efi_usb_interface::usbdev, and efi_usb_endpoint::usbintf.
Referenced by efi_usb_async_interrupt_transfer().
Perform control transfer.
- Parameters
-
| usbio | USB I/O protocol |
| packet | Setup packet |
| direction | Data direction |
| timeout | Timeout (in milliseconds) |
| data | Data buffer |
| len | Length of data |
- Return values
-
| status | Transfer status |
| efirc | EFI status code |
Definition at line 553 of file efi_usb.c.
557 {
567
568 DBGC2 ( usbdev,
"USBDEV %s control %04x:%04x:%04x:%04x %s %dms "
572 ( (
size_t )
len ) );
573
574
576
577
579
580
581
582
583
586 DBGC ( usbdev,
"USBDEV %s cannot set configuration %d: not "
587 "logically possible\n", usbintf->
name,
index );
589 goto err_change_config;
590 }
591
592
593
594
598
599
602 DBGC ( usbdev,
"USBDEV %s control %04x:%04x:%04x:%04x %p+%zx "
607 goto err_control;
608 }
609
610
613 DBGC ( usbdev,
"USBDEV %s alt %d selected\n",
615 }
616
617 err_control:
618 err_change_config:
621}
pseudo_bit_t value[0x00020]
void efi_raise_tpl(struct efi_saved_tpl *tpl)
Raise task priority level to internal level.
void efi_restore_tpl(struct efi_saved_tpl *tpl)
Restore task priority level.
static const char * efi_usb_direction_name(EFI_USB_DATA_DIRECTION direction)
Transcribe data direction (for debugging)
static void efi_usb_close_all(struct efi_usb_interface *usbintf)
Close all endpoints.
#define ENOTSUP
Operation not supported.
u8 request[0]
List of IEs requested.
#define USB_REQUEST_TYPE(type)
Construct USB request type.
#define USB_SET_INTERFACE
Set interface.
#define USB_SET_CONFIGURATION
Set configuration.
An EFI saved task priority level.
EFI_USB_IO_PROTOCOL usbio
USB I/O protocol.
uint8_t config
Configuration value.
int usb_control(struct usb_device *usb, unsigned int request, unsigned int value, unsigned int index, void *data, size_t len)
Issue USB control transaction.
References efi_usb_interface::alternate, efi_usb_device::config, usb_configuration_descriptor::config, container_of, data, DBGC, DBGC2, direction, efi_raise_tpl(), efi_restore_tpl(), efi_usb_close_all(), efi_usb_direction_name(), EFI_USB_ERR_SYSTEM, EFIRC, ENOTSUP, efi_usb_device::func, USB_DEVICE_REQUEST::Index, index, le16_to_cpu, len, USB_DEVICE_REQUEST::Length, efi_usb_interface::name, rc, USB_DEVICE_REQUEST::Request, request, USB_DEVICE_REQUEST::RequestType, status, strerror(), timeout(), usb_function::usb, usb_control(), USB_REQUEST_TYPE, USB_SET_CONFIGURATION, USB_SET_INTERFACE, efi_usb_interface::usbdev, efi_usb_interface::usbio, USB_DEVICE_REQUEST::Value, value, and VOID.
Perform bulk transfer.
- Parameters
-
| usbio | USB I/O protocol |
| endpoint | Endpoint address |
| data | Data buffer |
| len | Length of data |
| timeout | Timeout (in milliseconds) |
- Return values
-
| status | Transfer status |
| efirc | EFI status code |
Definition at line 635 of file efi_usb.c.
636 {
640 size_t actual = *
len;
643
644 DBGC2 ( usbdev,
"USBDEV %s bulk %s %p+%zx %dms\n", usbintf->
name,
646 ( (
size_t ) *
len ), ( (
unsigned int )
timeout ) );
647
648
650
651
653
654
657 data, &actual ) ) != 0 ) {
658
660 goto err_transfer;
661 }
662
663 err_transfer:
666}
#define EFI_USB_ERR_TIMEOUT
static int efi_usb_sync_transfer(struct efi_usb_interface *usbintf, unsigned int endpoint, unsigned int attributes, unsigned int timeout, void *data, size_t *len)
Perform synchronous transfer.
#define USB_ENDPOINT_ATTR_BULK
Bulk endpoint transfer type.
References container_of, data, DBGC2, efi_raise_tpl(), efi_restore_tpl(), EFI_USB_ERR_TIMEOUT, efi_usb_sync_transfer(), EFIRC, len, efi_usb_interface::name, rc, status, timeout(), USB_ENDPOINT_ATTR_BULK, USB_ENDPOINT_IN, efi_usb_interface::usbdev, efi_usb_interface::usbio, and VOID.
Perform synchronous interrupt transfer.
- Parameters
-
| usbio | USB I/O protocol |
| endpoint | Endpoint address |
| data | Data buffer |
| len | Length of data |
| timeout | Timeout (in milliseconds) |
- Return values
-
| status | Transfer status |
| efirc | EFI status code |
Definition at line 680 of file efi_usb.c.
682 {
686 size_t actual = *
len;
689
690 DBGC2 ( usbdev,
"USBDEV %s sync intr %s %p+%zx %dms\n", usbintf->
name,
692 ( (
size_t ) *
len ), ( (
unsigned int )
timeout ) );
693
694
696
697
699
700
704
706 goto err_transfer;
707 }
708
709 err_transfer:
712}
References container_of, data, DBGC2, efi_raise_tpl(), efi_restore_tpl(), EFI_USB_ERR_TIMEOUT, efi_usb_sync_transfer(), EFIRC, len, efi_usb_interface::name, rc, status, timeout(), USB_ENDPOINT_ATTR_INTERRUPT, USB_ENDPOINT_IN, efi_usb_interface::usbdev, efi_usb_interface::usbio, and VOID.
Perform asynchronous interrupt transfer.
- Parameters
-
| usbio | USB I/O protocol |
| endpoint | Endpoint address |
| start | Start (rather than stop) transfer |
| interval | Polling interval (in milliseconds) |
| len | Data length |
| callback | Callback function |
| context | Context for callback function |
- Return values
-
Definition at line 727 of file efi_usb.c.
730 {
736
737 DBGC2 ( usbdev,
"USBDEV %s async intr %s len %#zx int %d %p/%p\n",
740 ( (
size_t )
len ), ( (
unsigned int ) interval ),
741 callback, context );
742
743
745
746
748
749
752 context ) ) != 0 )
753 goto err_start;
754
755 } else {
756
757
759
760
762
763 }
764
765 err_start:
768}
static int efi_usb_async_start(struct efi_usb_interface *usbintf, unsigned int endpoint, unsigned int interval, size_t len, EFI_ASYNC_USB_TRANSFER_CALLBACK callback, void *context)
Start asynchronous transfer.
static void efi_usb_async_stop(struct efi_usb_interface *usbintf, unsigned int endpoint)
Stop asynchronous transfer.
uint32_t start
Starting offset.
References container_of, DBGC2, efi_raise_tpl(), efi_restore_tpl(), efi_usb_async_start(), efi_usb_async_stop(), EFIRC, len, efi_usb_interface::name, rc, start, USB_ENDPOINT_IN, efi_usb_interface::usbdev, efi_usb_interface::usbio, and VOID.
Get string descriptor.
- Parameters
-
| usbio | USB I/O protocol |
| language | Language ID |
| index | String index |
- Return values
-
| string | String |
| efirc | EFI status code |
Definition at line 955 of file efi_usb.c.
956 {
967
968 DBGC2 ( usbdev,
"USBDEV %s get string %d:%d descriptor\n",
970
971
973
974
978 sizeof (
header ) ) ) != 0 ) {
979 DBGC ( usbdev,
"USBDEV %s could not get string %d:%d "
980 "descriptor header: %s\n", usbintf->
name, language,
982 goto err_get_header;
983 }
986 DBGC ( usbdev,
"USBDEV %s underlength string %d:%d\n",
989 goto err_len;
990 }
991
992
996 goto err_alloc;
997 }
998
999
1003 DBGC ( usbdev,
"USBDEV %s could not get string %d:%d "
1004 "descriptor: %s\n", usbintf->
name, language,
1006 goto err_get_descriptor;
1007 }
1008
1009
1013
1014
1016
1017
1019 return 0;
1020
1021 err_get_descriptor:
1023 err_alloc:
1024 err_len:
1025 err_get_header:
1028}
#define VOID
Undeclared type.
@ EfiBootServicesData
The data portions of a loaded Boot Serves Driver, and the default data allocation type used by a Boot...
struct ena_llq_option header
Header locations.
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
#define EINVAL
Invalid argument.
#define USB_STRING_DESCRIPTOR
A USB string descriptor.
static int usb_get_descriptor(struct usb_device *usb, unsigned int type, unsigned int desc, unsigned int index, unsigned int language, struct usb_descriptor_header *data, size_t len)
Get USB descriptor.
void * memset(void *dest, int character, size_t len) __nonnull
void * memmove(void *dest, const void *src, size_t len) __nonnull
EFI_ALLOCATE_POOL AllocatePool
References EFI_BOOT_SERVICES::AllocatePool, buffer, container_of, DBGC, DBGC2, EEFI, efi_raise_tpl(), efi_restore_tpl(), efi_systab, EfiBootServicesData, EFIRC, EINVAL, EFI_BOOT_SERVICES::FreePool, efi_usb_device::func, header, index, len, memmove(), memset(), efi_usb_interface::name, rc, strerror(), usb_function::usb, usb_get_descriptor(), USB_STRING_DESCRIPTOR, efi_usb_interface::usbdev, efi_usb_interface::usbio, and VOID.
| int efi_usb_install |
( |
struct efi_usb_device * | usbdev, |
|
|
unsigned int | interface ) |
|
static |
Install interface.
- Parameters
-
| usbdev | EFI USB device |
| interface | Interface number |
- Return values
-
Definition at line 1108 of file efi_usb.c.
1109 {
1113 int leak = 0;
1116
1117
1118 usbintf =
zalloc (
sizeof ( *usbintf ) );
1119 if ( ! usbintf ) {
1121 goto err_alloc;
1122 }
1128 sizeof ( usbintf->
usbio ) );
1129
1130
1132 if ( ! usbintf->
path ) {
1134 goto err_path;
1135 }
1136
1137
1139
1140
1147 DBGC (
usbdev,
"USBDEV %s could not install protocols: %s\n",
1149 goto err_install_protocol;
1150 }
1151
1152 DBGC (
usbdev,
"USBDEV %s installed as %s\n",
1154 return 0;
1155
1161 DBGC (
usbdev,
"USBDEV %s could not uninstall: %s\n",
1163 leak = 1;
1164 }
1166 err_install_protocol:
1170 if ( ! leak )
1172 err_path:
1173 if ( ! leak )
1175 err_alloc:
1176 if ( leak ) {
1177 DBGC (
usbdev,
"USBDEV %s nullified and leaked\n",
1179 }
1181}
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
EFI_GUID efi_usb_io_protocol_guid
USB I/O protocol GUID.
void efi_nullify_usbio(EFI_USB_IO_PROTOCOL *usbio)
Nullify USB I/O protocol.
EFI_DEVICE_PATH_PROTOCOL * efi_usb_path(struct usb_function *func)
Construct EFI device path for USB function.
static EFI_USB_IO_PROTOCOL efi_usb_io_protocol
USB I/O protocol.
static void efi_usb_free_all(struct efi_usb_interface *usbintf)
Free all endpoints.
#define ENODEV
No such device.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
#define list_del(list)
Delete an entry from a list.
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces
struct list_head interfaces
List of interfaces.
EFI_DEVICE_PATH_PROTOCOL * path
Device path.
EFI_HANDLE handle
EFI handle.
struct list_head list
List of interfaces.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
References DBGC, EEFI, efi_device_path_protocol_guid, efi_handle_name(), efi_nullify_usbio(), efi_systab, efi_usb_close_all(), efi_usb_free_all(), efi_usb_io_protocol, efi_usb_io_protocol_guid, efi_usb_path(), ENODEV, ENOMEM, free, efi_usb_device::func, efi_usb_interface::handle, EFI_BOOT_SERVICES::InstallMultipleProtocolInterfaces, efi_usb_interface::interface, efi_usb_device::interfaces, efi_usb_interface::list, list_add_tail, list_del, memcpy(), efi_usb_device::name, efi_usb_interface::name, NULL, efi_usb_interface::path, rc, snprintf(), strerror(), EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces, efi_usb_interface::usbdev, efi_usb_interface::usbio, and zalloc().
Referenced by efi_usb_probe().
Uninstall interface.
- Parameters
-
Definition at line 1188 of file efi_usb.c.
1188 {
1193
1194 DBGC ( usbdev,
"USBDEV %s uninstalling %s\n",
1196
1197
1198
1199
1200
1203
1204
1211 DBGC ( usbdev,
"USBDEV %s could not uninstall: %s\n",
1213 leak = 1;
1214 }
1216
1217
1220
1221
1223
1224
1225 if ( ! leak )
1227
1228
1229 if ( ! leak )
1231
1232
1234 DBGC ( usbdev,
"USBDEV %s nullified and leaked\n",
1236 }
1237}
int efi_disconnect(EFI_HANDLE device, EFI_HANDLE driver)
Disconnect UEFI driver(s)
int efi_shutdown_in_progress
EFI shutdown is in progress.
References DBGC, EEFI, efi_device_path_protocol_guid, efi_disconnect(), efi_handle_name(), efi_nullify_usbio(), efi_shutdown_in_progress, efi_systab, efi_usb_close_all(), efi_usb_free_all(), efi_usb_io_protocol_guid, free, efi_usb_interface::handle, efi_usb_interface::list, list_del, efi_usb_interface::name, NULL, efi_usb_interface::path, strerror(), EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces, efi_usb_interface::usbdev, and efi_usb_interface::usbio.
Referenced by efi_usb_uninstall_all().
Probe device.
- Parameters
-
| func | USB function |
| config | Configuration descriptor |
- Return values
-
Definition at line 1262 of file efi_usb.c.
1263 {
1269 size_t config_len;
1270 size_t lang_len;
1271 unsigned int i;
1273
1274
1276
1277
1280
1282 }
1285
1286
1287 usbdev =
zalloc (
sizeof ( *usbdev ) + config_len +
1288 sizeof ( *lang ) + lang_len );
1289 if ( ! usbdev ) {
1291 goto err_alloc;
1292 }
1295 usbdev->
func = func;
1296 usbdev->
config = ( ( (
void * ) usbdev ) +
sizeof ( *usbdev ) );
1298 lang = ( ( (
void * ) usbdev->
config ) + config_len );
1299 usbdev->
lang = ( ( (
void * ) lang ) +
sizeof ( *lang ) );
1302
1303
1304 if ( lang_len &&
1306 0, 0, lang,
header.len ) ) != 0 ) ) {
1307 DBGC ( usbdev,
"USBDEV %s could not get supported languages: "
1309 goto err_get_languages;
1310 }
1311
1312
1313 for ( i = 0 ; i < func->
desc.
count ; i++ ) {
1316 goto err_install;
1317 }
1318
1319
1322
1323 return 0;
1324
1325 err_install:
1328 err_get_languages:
1330 err_alloc:
1332}
int efi_connect(EFI_HANDLE device, EFI_HANDLE driver)
Connect UEFI driver(s)
static void efi_usb_uninstall_all(struct efi_usb_device *efiusb)
Uninstall all interfaces.
static int efi_usb_install(struct efi_usb_device *usbdev, unsigned int interface)
Install interface.
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
#define INIT_LIST_HEAD(list)
Initialise a list head.
#define list_empty(list)
Test whether a list is empty.
uint16_t len
Total length.
unsigned int count
Number of interfaces.
struct usb_function_descriptor desc
Function descriptor.
uint8_t interface[0]
List of interface numbers.
References assert, efi_usb_device::config, usb_function_descriptor::count, DBGC, usb_function::desc, efi_connect(), efi_usb_install(), efi_usb_uninstall_all(), ENOMEM, free, efi_usb_device::func, efi_usb_interface::handle, header, INIT_LIST_HEAD, usb_function::interface, efi_usb_device::interfaces, efi_usb_device::lang, efi_usb_device::lang_len, le16_to_cpu, usb_configuration_descriptor::len, list_empty, list_for_each_entry, memcpy(), efi_usb_device::name, usb_function::name, NULL, rc, strerror(), usb_function::usb, usb_func_set_drvdata(), usb_get_descriptor(), USB_STRING_DESCRIPTOR, and zalloc().