Selaa lähdekoodia

[efi] Expose unused USB devices via EFI_USB_IO_PROTOCOL

Allow the UEFI platform firmware to provide drivers for unrecognised
devices, by exposing our own implementation of EFI_USB_IO_PROTOCOL.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 vuotta sitten
vanhempi
commit
5df081d6c0

+ 7
- 0
src/config/config_usb.c Näytä tiedosto

@@ -53,3 +53,10 @@ REQUIRE_OBJECT ( usbio );
53 53
 #ifdef USB_KEYBOARD
54 54
 REQUIRE_OBJECT ( usbkbd );
55 55
 #endif
56
+
57
+/*
58
+ * Drag in USB external interfaces
59
+ */
60
+#ifdef USB_EFI
61
+REQUIRE_OBJECT ( efi_usb );
62
+#endif

+ 5
- 0
src/config/defaults/efi.h Näytä tiedosto

@@ -26,6 +26,11 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
26 26
 #define	IMAGE_EFI		/* EFI image support */
27 27
 #define	IMAGE_SCRIPT		/* iPXE script image support */
28 28
 
29
+#define	USB_HCD_XHCI		/* xHCI USB host controller */
30
+#define	USB_HCD_EHCI		/* EHCI USB host controller */
31
+#define	USB_HCD_UHCI		/* UHCI USB host controller */
32
+#define	USB_EFI			/* Provide EFI_USB_IO_PROTOCOL interface */
33
+
29 34
 #define	REBOOT_CMD		/* Reboot command */
30 35
 #define	CPUID_CMD		/* x86 CPU feature detection command */
31 36
 

+ 11
- 5
src/config/usb.h Näytä tiedosto

@@ -15,16 +15,22 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
15 15
  * USB host controllers (all enabled by default)
16 16
  *
17 17
  */
18
-//#undef	USB_HCD_XHCI		/* xHCI USB host controller */
19
-//#undef	USB_HCD_EHCI		/* EHCI USB host controller */
20
-//#undef	USB_HCD_UHCI		/* UHCI USB host controller */
21
-//#define	USB_HCD_USBIO		/* Very slow EFI USB host controller */
18
+//#undef	USB_HCD_XHCI	/* xHCI USB host controller */
19
+//#undef	USB_HCD_EHCI	/* EHCI USB host controller */
20
+//#undef	USB_HCD_UHCI	/* UHCI USB host controller */
21
+//#define	USB_HCD_USBIO	/* Very slow EFI USB host controller */
22 22
 
23 23
 /*
24 24
  * USB peripherals
25 25
  *
26 26
  */
27
-//#undef	USB_KEYBOARD		/* USB keyboards */
27
+//#undef	USB_KEYBOARD	/* USB keyboards */
28
+
29
+/*
30
+ * USB external interfaces
31
+ *
32
+ */
33
+//#undef	USB_EFI		/* Provide EFI_USB_IO_PROTOCOL interface */
28 34
 
29 35
 #include <config/named.h>
30 36
 #include NAMED_CONFIG(usb.h)

+ 80
- 0
src/include/ipxe/efi/efi_usb.h Näytä tiedosto

@@ -0,0 +1,80 @@
1
+#ifndef _IPXE_EFI_USB_H
2
+#define _IPXE_EFI_USB_H
3
+
4
+/** @file
5
+ *
6
+ * USB I/O protocol
7
+ *
8
+ */
9
+
10
+#include <ipxe/list.h>
11
+#include <ipxe/efi/efi.h>
12
+#include <ipxe/efi/efi_driver.h>
13
+#include <ipxe/efi/Protocol/UsbIo.h>
14
+#include <ipxe/usb.h>
15
+
16
+/** An EFI USB device */
17
+struct efi_usb_device {
18
+	/** Name */
19
+	const char *name;
20
+	/** The underlying USB device */
21
+	struct usb_device *usb;
22
+	/** The underlying EFI device */
23
+	struct efi_device *efidev;
24
+	/** Configuration descriptor */
25
+	struct usb_configuration_descriptor *config;
26
+	/** Supported languages */
27
+	struct usb_descriptor_header *languages;
28
+	/** List of interfaces */
29
+	struct list_head interfaces;
30
+};
31
+
32
+/** An EFI USB device interface */
33
+struct efi_usb_interface {
34
+	/** Name */
35
+	char name[32];
36
+	/** Containing USB device */
37
+	struct efi_usb_device *usbdev;
38
+	/** List of interfaces */
39
+	struct list_head list;
40
+
41
+	/** Interface number */
42
+	unsigned int interface;
43
+	/** Alternate setting */
44
+	unsigned int alternate;
45
+	/** EFI handle */
46
+	EFI_HANDLE handle;
47
+	/** USB I/O protocol */
48
+	EFI_USB_IO_PROTOCOL usbio;
49
+	/** Device path */
50
+	EFI_DEVICE_PATH_PROTOCOL *path;
51
+
52
+	/** Opened endpoints */
53
+	struct efi_usb_endpoint *endpoint[32];
54
+};
55
+
56
+/** An EFI USB device endpoint */
57
+struct efi_usb_endpoint {
58
+	/** EFI USB device interface */
59
+	struct efi_usb_interface *usbintf;
60
+	/** USB endpoint */
61
+	struct usb_endpoint ep;
62
+
63
+	/** Most recent synchronous completion status */
64
+	int rc;
65
+
66
+	/** Asynchronous timer event */
67
+	EFI_EVENT event;
68
+	/** Asynchronous callback handler */
69
+	EFI_ASYNC_USB_TRANSFER_CALLBACK callback;
70
+	/** Asynchronous callback context */
71
+	void *context;
72
+};
73
+
74
+/** Asynchronous transfer fill level
75
+ *
76
+ * This is a policy decision.
77
+ */
78
+#define EFI_USB_ASYNC_FILL 2
79
+
80
+#endif /* _IPXE_EFI_USB_H */

+ 1
- 0
src/include/ipxe/errfile.h Näytä tiedosto

@@ -341,6 +341,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
341 341
 #define ERRFILE_efi_time	      ( ERRFILE_OTHER | 0x00480000 )
342 342
 #define ERRFILE_efi_watchdog	      ( ERRFILE_OTHER | 0x00490000 )
343 343
 #define ERRFILE_efi_pxe		      ( ERRFILE_OTHER | 0x004a0000 )
344
+#define ERRFILE_efi_usb		      ( ERRFILE_OTHER | 0x004b0000 )
344 345
 
345 346
 /** @} */
346 347
 

+ 1305
- 0
src/interface/efi/efi_usb.c
File diff suppressed because it is too large
Näytä tiedosto


Loading…
Peruuta
Tallenna