1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-26 19:52:11 +00:00

bdk: usb: support deconfiguration of endpoints

TODO: Signal that to userspace and manage it.
This commit is contained in:
CTCaer 2022-06-14 18:48:21 +03:00
parent f6c9e636d1
commit 258a343e21
2 changed files with 21 additions and 4 deletions

View file

@ -1056,6 +1056,16 @@ static int _usbd_handle_set_request(bool *ep_stall)
if (!res) if (!res)
{ {
usbd_otg->config_num = usbd_otg->control_setup.wValue; usbd_otg->config_num = usbd_otg->control_setup.wValue;
// Remove configuration.
if (!usbd_otg->config_num)
{
//! TODO: Signal that to userspace.
_usb_reset_disable_ep1();
return res;
}
// Initialize configuration.
_usbd_initialize_ep_ctrl(USB_EP_BULK_OUT); _usbd_initialize_ep_ctrl(USB_EP_BULK_OUT);
_usbd_initialize_ep_ctrl(USB_EP_BULK_IN); _usbd_initialize_ep_ctrl(USB_EP_BULK_IN);
usbd_otg->configuration_set = true; usbd_otg->configuration_set = true;

View file

@ -1608,9 +1608,18 @@ static void _xusb_handle_set_request_dev_address(usb_ctrl_setup_t *ctrl_setup)
static void _xusb_handle_set_request_configuration(usb_ctrl_setup_t *ctrl_setup) static void _xusb_handle_set_request_configuration(usb_ctrl_setup_t *ctrl_setup)
{ {
u32 config_num = ctrl_setup->wValue; usbd_xotg->config_num = ctrl_setup->wValue;
if (!config_num) //TODO! we can change device_state here.
// Remove configuration.
if (!usbd_xotg->config_num)
{
//! TODO: Signal that to userspace.
_xusb_disable_ep1();
_xusb_issue_status_trb(USB_DIR_IN);
return; return;
}
// Initialize BULK EPs. // Initialize BULK EPs.
_xusbd_ep_initialize(USB_EP_BULK_OUT); _xusbd_ep_initialize(USB_EP_BULK_OUT);
@ -1621,8 +1630,6 @@ static void _xusb_handle_set_request_configuration(usb_ctrl_setup_t *ctrl_setup)
XUSB_DEV_XHCI(XUSB_DEV_XHCI_ST) |= XHCI_ST_RC; XUSB_DEV_XHCI(XUSB_DEV_XHCI_ST) |= XHCI_ST_RC;
_xusb_issue_status_trb(USB_DIR_IN); _xusb_issue_status_trb(USB_DIR_IN);
usbd_xotg->config_num = config_num;
usbd_xotg->device_state = XUSB_CONFIGURED_STS_WAIT; usbd_xotg->device_state = XUSB_CONFIGURED_STS_WAIT;
} }