XHCI store pdevice configs, ifs and endpoints as static length arrays
This commit is contained in:
@@ -77,6 +77,29 @@ struct usb_endpoint_desc {
|
||||
uint8_t interval;
|
||||
} PACKED;
|
||||
|
||||
#define USB_CBW_SIGNATURE 0x43425355
|
||||
|
||||
/* command block wrapper */
|
||||
struct usb_cbw {
|
||||
uint32_t signature;
|
||||
uint32_t tag;
|
||||
uint32_t length;
|
||||
uint8_t dir;
|
||||
uint8_t lun;
|
||||
uint8_t cmd_len;
|
||||
uint8_t data[16];
|
||||
} PACKED;
|
||||
|
||||
#define USB_CSW_SIGNATURE 0x53425355
|
||||
|
||||
/* command status wrapper */
|
||||
struct usb_csw {
|
||||
uint32_t signature;
|
||||
uint32_t tag;
|
||||
uint32_t residue;
|
||||
uint8_t status;
|
||||
};
|
||||
|
||||
struct usb_driver_info {
|
||||
uint8_t if_class;
|
||||
uint8_t if_subclass;
|
||||
|
||||
@@ -835,10 +835,8 @@ static void xhci_pdevice_setup_init_endpoints (struct xhci* xhci, struct xhci_pd
|
||||
|
||||
uint8_t max_device_ctx_idx = 0;
|
||||
|
||||
struct list_node_link *eps_link, *tmp_eps_link;
|
||||
list_foreach (pdevice->endpoints, eps_link, tmp_eps_link) {
|
||||
struct xhci_pdevice_endpoint* endpoint =
|
||||
list_entry (eps_link, struct xhci_pdevice_endpoint, endpoints_link);
|
||||
for (size_t ep = 0; ep < pdevice->endpoints_count; ep++) {
|
||||
struct xhci_pdevice_endpoint* endpoint = &pdevice->endpoints[ep];
|
||||
|
||||
uint8_t dci = xhci_get_device_ctx_idx (&endpoint->desc);
|
||||
|
||||
@@ -856,14 +854,11 @@ static void xhci_pdevice_setup_init_endpoints (struct xhci* xhci, struct xhci_pd
|
||||
|
||||
ctx64->ctrl.dw[1] = (1 << 0);
|
||||
|
||||
// ctx64->slot.dw[0] = (max_device_ctx_idx << XHCI_SLCTX_CTX_ENTRIES);
|
||||
ctx64->slot.dw[0] = (ctx64->slot.dw[0] & ~(0x1F << XHCI_SLCTX_CTX_ENTRIES)) |
|
||||
(max_device_ctx_idx << XHCI_SLCTX_CTX_ENTRIES);
|
||||
|
||||
struct list_node_link *eps_link, *tmp_eps_link;
|
||||
list_foreach (pdevice->endpoints, eps_link, tmp_eps_link) {
|
||||
struct xhci_pdevice_endpoint* endpoint =
|
||||
list_entry (eps_link, struct xhci_pdevice_endpoint, endpoints_link);
|
||||
for (size_t ep = 0; ep < pdevice->endpoints_count; ep++) {
|
||||
struct xhci_pdevice_endpoint* endpoint = &pdevice->endpoints[ep];
|
||||
|
||||
uint8_t dci = xhci_get_device_ctx_idx (&endpoint->desc);
|
||||
|
||||
@@ -909,10 +904,8 @@ static void xhci_pdevice_setup_init_endpoints (struct xhci* xhci, struct xhci_pd
|
||||
ctx32->slot.dw[0] = (ctx32->slot.dw[0] & ~(0x1F << XHCI_SLCTX_CTX_ENTRIES)) |
|
||||
(max_device_ctx_idx << XHCI_SLCTX_CTX_ENTRIES);
|
||||
|
||||
struct list_node_link *eps_link, *tmp_eps_link;
|
||||
list_foreach (pdevice->endpoints, eps_link, tmp_eps_link) {
|
||||
struct xhci_pdevice_endpoint* endpoint =
|
||||
list_entry (eps_link, struct xhci_pdevice_endpoint, endpoints_link);
|
||||
for (size_t ep = 0; ep < pdevice->endpoints_count; ep++) {
|
||||
struct xhci_pdevice_endpoint* endpoint = &pdevice->endpoints[ep];
|
||||
|
||||
uint8_t dci = xhci_get_device_ctx_idx (&endpoint->desc);
|
||||
|
||||
@@ -1149,10 +1142,9 @@ static bool xhci_pdevice_setup_get_config_full (struct xhci* xhci, struct xhci_p
|
||||
|
||||
switch (hdr->desc_type) {
|
||||
case USB_DESC_CONFIG: {
|
||||
struct xhci_pdevice_config* config = malloc (sizeof (*config));
|
||||
struct xhci_pdevice_config* config = &pdevice->configs[pdevice->configs_count++];
|
||||
memset (config, 0, sizeof (*config));
|
||||
config->desc = *(struct usb_config_desc*)ptr;
|
||||
list_append (pdevice->configs, &config->configs_link);
|
||||
|
||||
DEBUG (
|
||||
"Found USB device config: total_len=%u num_ifs=%u, cfgval=%u cfg=%u attrs=%02x maxpow=%u\n",
|
||||
@@ -1160,10 +1152,9 @@ static bool xhci_pdevice_setup_get_config_full (struct xhci* xhci, struct xhci_p
|
||||
config->desc.config, config->desc.attrs, config->desc.max_power);
|
||||
} break;
|
||||
case USB_DESC_IF: {
|
||||
struct xhci_pdevice_if* if_ = malloc (sizeof (*if_));
|
||||
struct xhci_pdevice_if* if_ = &pdevice->ifs[pdevice->ifs_count++];
|
||||
memset (if_, 0, sizeof (*if_));
|
||||
if_->desc = *(struct usb_if_desc*)ptr;
|
||||
list_append (pdevice->ifs, &if_->ifs_link);
|
||||
|
||||
DEBUG (
|
||||
"Found USB device interface: ifnum=%u altsetting=%u eps=%u ifclass=%u ifsubclass=%u ifproto=%u if=%u\n",
|
||||
@@ -1171,10 +1162,9 @@ static bool xhci_pdevice_setup_get_config_full (struct xhci* xhci, struct xhci_p
|
||||
if_->desc.if_subclass, if_->desc.if_proto, if_->desc.if1);
|
||||
} break;
|
||||
case USB_DESC_ENDPOINT: {
|
||||
struct xhci_pdevice_endpoint* endpoint = malloc (sizeof (*endpoint));
|
||||
struct xhci_pdevice_endpoint* endpoint = &pdevice->endpoints[pdevice->endpoints_count++];
|
||||
memset (endpoint, 0, sizeof (*endpoint));
|
||||
endpoint->desc = *(struct usb_endpoint_desc*)ptr;
|
||||
list_append (pdevice->endpoints, &endpoint->endpoints_link);
|
||||
|
||||
DEBUG ("Found USB device endpoint: addr=%u attrs=%u maxpkt=%u intvl=%u\n",
|
||||
endpoint->desc.endpoint_addr, endpoint->desc.attrs, endpoint->desc.max_packet_size,
|
||||
@@ -1194,10 +1184,8 @@ static bool xhci_pdevice_setup_get_config_full (struct xhci* xhci, struct xhci_p
|
||||
|
||||
static void xhci_poll_setup_init_ifs (struct xhci* xhci, struct xhci_pdevice* pdevice,
|
||||
uint64_t* lockflags) {
|
||||
struct list_node_link *ifs_link, *tmp_ifs_link;
|
||||
|
||||
list_foreach (pdevice->ifs, ifs_link, tmp_ifs_link) {
|
||||
struct xhci_pdevice_if* if_ = list_entry (ifs_link, struct xhci_pdevice_if, ifs_link);
|
||||
for (size_t if0 = 0; if0 < pdevice->ifs_count; if0++) {
|
||||
struct xhci_pdevice_if* if_ = &pdevice->ifs[if0];
|
||||
|
||||
for (size_t i = 0; i < USB_DRIVER_MAX_MATCHES; i++) {
|
||||
struct usb_driver_info* info = &usb_driver_infos[i];
|
||||
|
||||
@@ -69,21 +69,21 @@ struct xhci_ring {
|
||||
|
||||
struct xhci_pdevice_config {
|
||||
struct usb_config_desc desc;
|
||||
struct list_node_link configs_link;
|
||||
};
|
||||
|
||||
struct xhci_pdevice_if {
|
||||
struct usb_if_desc desc;
|
||||
struct list_node_link ifs_link;
|
||||
};
|
||||
|
||||
struct xhci_pdevice_endpoint {
|
||||
struct usb_endpoint_desc desc;
|
||||
struct list_node_link endpoints_link;
|
||||
|
||||
struct xhci_ring transfer_ring;
|
||||
};
|
||||
|
||||
#define XHCI_PDEVICE_CONFIGS_MAX 16
|
||||
#define XHCI_PDEVICE_IFS_MAX 16
|
||||
#define XHCI_PDEVICE_ENDPOINTS_MAX 16
|
||||
|
||||
struct xhci_pdevice {
|
||||
struct list_node_link pdevices_link;
|
||||
struct xhci_port* xhci_port;
|
||||
@@ -93,9 +93,15 @@ struct xhci_pdevice {
|
||||
|
||||
struct usb_device_desc device_desc;
|
||||
struct usb_config_desc config_desc;
|
||||
struct list_node_link* configs;
|
||||
struct list_node_link* ifs;
|
||||
struct list_node_link* endpoints;
|
||||
|
||||
struct xhci_pdevice_config configs[XHCI_PDEVICE_CONFIGS_MAX];
|
||||
size_t configs_count;
|
||||
|
||||
struct xhci_pdevice_if ifs[XHCI_PDEVICE_IFS_MAX];
|
||||
size_t ifs_count;
|
||||
|
||||
struct xhci_pdevice_endpoint endpoints[XHCI_PDEVICE_ENDPOINTS_MAX];
|
||||
size_t endpoints_count;
|
||||
};
|
||||
|
||||
struct xhci_port_status_change {
|
||||
|
||||
Reference in New Issue
Block a user