From 1eebcfa03ee7d7bc328d0ef460609fe3535966bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Wed, 28 Sep 2022 22:43:42 +0200 Subject: [PATCH] usb: add an interface for usb controllers using the new driver API Change-Id: I25f481c8a7c3e4aafa3080640ce156b9232eaf73 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5707 Reviewed-by: waddlesplash --- src/add-ons/kernel/bus_managers/usb/usb.cpp | 36 +++++++++++++++++++ .../kernel/bus_managers/usb/usb_private.h | 18 ++++++++++ 2 files changed, 54 insertions(+) diff --git a/src/add-ons/kernel/bus_managers/usb/usb.cpp b/src/add-ons/kernel/bus_managers/usb/usb.cpp index fec533f578..ae2ac51770 100644 --- a/src/add-ons/kernel/bus_managers/usb/usb.cpp +++ b/src/add-ons/kernel/bus_managers/usb/usb.cpp @@ -895,8 +895,44 @@ struct usb_module_info_v2 gModuleInfoV2 = { // +status_t +usb_added_device(device_node *parent) +{ + dprintf("usb_added_device\n"); + return B_OK; +} + + +status_t +usb_get_stack(void** stack) +{ + *stack = gUSBStack; + return B_OK; +} + + +usb_for_controller_interface gForControllerModule = { + { + { + USB_FOR_CONTROLLER_MODULE_NAME, + B_KEEP_LOADED, + &bus_std_ops + }, + + NULL, // supported devices + usb_added_device, + NULL, + NULL, + NULL + }, + + usb_get_stack, +}; + + module_info *modules[] = { (module_info *)&gModuleInfoV2, (module_info *)&gModuleInfoV3, + (module_info *)&gForControllerModule, NULL }; diff --git a/src/add-ons/kernel/bus_managers/usb/usb_private.h b/src/add-ons/kernel/bus_managers/usb/usb_private.h index a5bcd77fa4..a5734048db 100644 --- a/src/add-ons/kernel/bus_managers/usb/usb_private.h +++ b/src/add-ons/kernel/bus_managers/usb/usb_private.h @@ -759,4 +759,22 @@ private: uint16 fBandwidth; }; + +#include + + +// Interface between usb_bus and underlying implementation (xhci_pci) +typedef struct usb_bus_interface { + driver_module_info info; +} usb_bus_interface; + + +typedef struct { + driver_module_info info; + status_t (*get_stack)(void** stack); +} usb_for_controller_interface; + +#define USB_FOR_CONTROLLER_MODULE_NAME "bus_managers/usb/controller/driver_v1" + + #endif // _USB_PRIVATE_H