Lines Matching defs:endpoint

865 	xhci_endpoint *endpoint = (xhci_endpoint *)pipe->ControllerCookie();
866 if (endpoint == NULL) {
867 TRACE_ERROR("control pipe has no endpoint!\n");
870 if (endpoint->device == NULL) {
871 panic("endpoint is not initialized!");
932 status = _LinkDescriptorForPipe(descriptor, endpoint);
951 xhci_endpoint *endpoint = (xhci_endpoint *)pipe->ControllerCookie();
952 if (endpoint == NULL) {
953 TRACE_ERROR("pipe has no endpoint!\n");
956 if (endpoint->device == NULL) {
957 panic("endpoint is not initialized!");
969 size_t trbSize = endpoint->max_burst_payload;
1074 status = _LinkDescriptorForPipe(td, endpoint);
1087 xhci_endpoint* endpoint = (xhci_endpoint*)pipe->ControllerCookie();
1088 if (endpoint == NULL || endpoint->trbs == NULL) {
1089 // Someone's de-allocated this pipe or endpoint in the meantime.
1099 endpoint->used, pipe, pipe->EndpointAddress());
1102 MutexLocker endpointLocker(endpoint->lock);
1104 if (endpoint->td_head == NULL) {
1109 // Calling the callbacks while holding the endpoint lock could potentially
1112 // to stop the endpoint, we cancel the transfers but do not free the TDs.
1116 for (xhci_td* td = endpoint->td_head; td != NULL; td = td->next) {
1129 // It is possible that while waiting for the stop-endpoint command to
1131 // order to avoid a deadlock, we must unlock the endpoint.
1133 status_t status = StopEndpoint(false, endpoint);
1135 // It is possible that the endpoint was stopped by the controller at the
1137 // error. In that case, try again; if the endpoint is already stopped,
1139 status = StopEndpoint(false, endpoint);
1143 TRACE_ERROR("cancel queued transfers: halted endpoint, reset!\n");
1144 status = ResetEndpoint(false, endpoint);
1148 // Detach the head TD from the endpoint.
1149 xhci_td* td_head = endpoint->td_head;
1150 endpoint->td_head = NULL;
1153 // Clear the endpoint's TRBs.
1154 memset(endpoint->trbs, 0, sizeof(xhci_trb) * XHCI_ENDPOINT_RING_SIZE);
1155 endpoint->used = 0;
1156 endpoint->next = 0;
1159 SetTRDequeue(endpoint->trb_addr, 0, endpoint->id + 1,
1160 endpoint->device->slot);
1165 // We couldn't stop the endpoint. Most likely the device has been
1166 // removed and the endpoint was stopped by the hardware, or is
1168 TRACE_ERROR("cancel queued transfers: could not stop endpoint: %s!\n",
1171 // Instead of freeing the TDs, we want to leave them in the endpoint
1173 // as otherwise the endpoint could get "stuck" by having the "used"
1175 endpoint->td_head = td_head;
1202 xhci_endpoint *endpoint = (xhci_endpoint *)pipe->ControllerCookie();
1203 if (endpoint == NULL)
1207 if (mutex_trylock(&endpoint->lock) != B_OK)
1210 mutex_unlock(&endpoint->lock);
1214 mutex_unlock(&endpoint->lock);
1218 mutex_unlock(&endpoint->lock);
1226 // The endpoint's head TD is the TD of the just-submitted transfer.
1228 transfer->SetCallback(NULL, endpoint->td_head);
1641 * XHCI_ENDPOINT_RING_SIZE, "XHCI endpoint trbs");
1666 mutex_init(&endpoint0->lock, "xhci endpoint lock");
1676 // configure the Control endpoint 0
1679 TRACE_ERROR("unable to configure default control endpoint\n");
1806 // We don't want to disable the default endpoint, naturally, which would
1851 XHCI::_GetEndpointState(xhci_endpoint* endpoint)
1853 struct xhci_device_ctx* device_ctx = endpoint->device->device_ctx;
1855 _ReadContext(&device_ctx->endpoints[endpoint->id].dwendpoint0));
1862 TRACE("insert endpoint for pipe %p (%d)\n", pipe, pipe->EndpointAddress());
1898 xhci_endpoint* endpoint = &device->endpoints[id];
1899 mutex_init(&endpoint->lock, "xhci endpoint lock");
1900 MutexLocker endpointLocker(endpoint->lock);
1902 endpoint->device = device;
1903 endpoint->id = id;
1904 endpoint->td_head = NULL;
1905 endpoint->used = 0;
1906 endpoint->next = 0;
1908 endpoint->trbs = device->trbs + id * XHCI_ENDPOINT_RING_SIZE;
1909 endpoint->trb_addr = device->trb_addr
1911 memset(endpoint->trbs, 0,
1914 TRACE("insert endpoint for pipe: trbs, device %p endpoint %p\n",
1915 device->trbs, endpoint->trbs);
1916 TRACE("insert endpoint for pipe: trb_addr, device 0x%" B_PRIxPHYSADDR
1917 " endpoint 0x%" B_PRIxPHYSADDR "\n", device->trb_addr,
1918 endpoint->trb_addr);
1922 status_t status = ConfigureEndpoint(endpoint, device->slot, id, pipe->Type(),
1926 TRACE_ERROR("unable to configure endpoint: %s\n", strerror(status));
1939 TRACE("endpoint[0] state 0x%08" B_PRIx32 "\n",
1942 TRACE("endpoint[%d] state 0x%08" B_PRIx32 "\n", id,
1955 TRACE("remove endpoint for pipe %p (%d)\n", pipe, pipe->EndpointAddress());
1963 xhci_endpoint *endpoint = (xhci_endpoint *)pipe->ControllerCookie();
1964 if (endpoint == NULL || endpoint->trbs == NULL)
1969 if (endpoint->id > 0) {
1970 xhci_device *device = endpoint->device;
1971 uint8 epNumber = endpoint->id + 1;
1972 StopEndpoint(true, endpoint);
1974 mutex_lock(&endpoint->lock);
1978 while ((td = endpoint->td_head) != NULL) {
1979 endpoint->td_head = endpoint->td_head->next;
1983 mutex_destroy(&endpoint->lock);
1984 memset(endpoint, 0, sizeof(xhci_endpoint));
2000 XHCI::_LinkDescriptorForPipe(xhci_td *descriptor, xhci_endpoint *endpoint)
2005 MutexLocker endpointLocker(&endpoint->lock, mutex_trylock(&endpoint->lock) == B_OK);
2010 if (endpoint->used >= (XHCI_MAX_TRANSFERS - 1)) {
2016 if (endpoint->td_head != NULL && endpoint->td_head->transfer != NULL
2017 && endpoint->td_head->transfer->IsFragmented()) {
2022 endpoint->used++;
2023 descriptor->next = endpoint->td_head;
2024 endpoint->td_head = descriptor;
2026 uint32 link = endpoint->next, eventdata = link + 1, next = eventdata + 1;
2037 phys_addr_t addr = endpoint->trb_addr + (eventdata * sizeof(xhci_trb));
2061 endpoint->trbs[link].address =
2063 endpoint->trbs[link].status =
2065 endpoint->trbs[link].flags =
2080 endpoint->trbs[eventdata].address =
2083 endpoint->trbs[eventdata].status =
2085 endpoint->trbs[eventdata].flags =
2089 endpoint->trbs[next].address = 0;
2090 endpoint->trbs[next].status = 0;
2091 endpoint->trbs[next].flags = 0;
2096 endpoint->trbs[link].flags |= B_HOST_TO_LENDIAN_INT32(TRB_3_CYCLE_BIT);
2099 " 0x%" B_PRIxPHYSADDR " 0x%08" B_PRIx32 "\n", &endpoint->trbs[link],
2100 endpoint->trb_addr + link * sizeof(struct xhci_trb),
2101 endpoint->trbs[link].address,
2102 B_LENDIAN_TO_HOST_INT32(endpoint->trbs[link].flags));
2104 endpoint->next = next;
2108 _ReadContext(&endpoint->device->device_ctx->endpoints[endpoint->id].dwendpoint0),
2109 _ReadContext(&endpoint->device->device_ctx->endpoints[endpoint->id].dwendpoint1),
2110 _ReadContext(&endpoint->device->device_ctx->endpoints[endpoint->id].qwendpoint2));
2112 Ring(endpoint->device->slot, endpoint->id + 1);
2115 _ReadContext(&endpoint->device->device_ctx->endpoints[endpoint->id].dwendpoint0),
2116 _ReadContext(&endpoint->device->device_ctx->endpoints[endpoint->id].dwendpoint1),
2117 _ReadContext(&endpoint->device->device_ctx->endpoints[endpoint->id].qwendpoint2));
2124 XHCI::_UnlinkDescriptorForPipe(xhci_td *descriptor, xhci_endpoint *endpoint)
2127 // We presume that the caller has already locked or owns the endpoint.
2129 endpoint->used--;
2130 if (descriptor == endpoint->td_head) {
2131 endpoint->td_head = descriptor->next;
2135 for (xhci_td *td = endpoint->td_head; td->next != NULL; td = td->next) {
2144 endpoint->used++;
2161 // Compute and assign the endpoint type. (XHCI 1.2 �� 6.2.3 Table 6-9 p452.)
2273 TRACE("endpoint 0x%" B_PRIx32 " 0x%" B_PRIx32 " 0x%" B_PRIx64 " 0x%"
2548 XHCI::Ring(uint8 slot, uint8 endpoint)
2550 TRACE("Ding Dong! slot:%d endpoint %d\n", slot, endpoint)
2551 if ((slot == 0 && endpoint > 0) || (slot > 0 && endpoint == 0))
2552 panic("Ring() invalid slot/endpoint combination\n");
2553 if (slot > fSlotCount || endpoint >= XHCI_MAX_ENDPOINTS)
2554 panic("Ring() invalid slot or endpoint\n");
2556 WriteDoorReg32(XHCI_DOORBELL(slot), XHCI_DOORBELL_TARGET(endpoint)
2629 TRACE_ERROR("invalid endpoint\n");
2634 xhci_endpoint *endpoint = &device->endpoints[endpointNumber - 1];
2636 if (endpoint->trbs == NULL) {
2637 TRACE_ERROR("got TRB but endpoint is not allocated!\n");
2642 MutexLocker endpointLocker(endpoint->lock, mutex_trylock(&endpoint->lock) == B_OK);
2657 endpoint->status = completionCode;
2678 TRACE_ALWAYS("transfer error on slot %" B_PRId8 " endpoint %" B_PRId8
2683 if (source >= endpoint->trb_addr
2684 && (source - endpoint->trb_addr) < (XHCI_ENDPOINT_RING_SIZE * sizeof(xhci_trb))) {
2687 const int64 offset = (source - endpoint->trb_addr) / sizeof(xhci_trb);
2688 const int32 type = TRB_3_TYPE_GET(endpoint->trbs[offset].flags);
2690 source = B_LENDIAN_TO_HOST_INT64(endpoint->trbs[offset].address);
2693 for (xhci_td *td = endpoint->td_head; td != NULL; td = td->next) {
2730 // Report the endpoint status (if any.)
2731 if (endpoint->status != 0) {
2732 completionCode = endpoint->status;
2733 endpoint->status = 0;
2751 _UnlinkDescriptorForPipe(td, endpoint);
2773 TRACE_ERROR("TRB 0x%" B_PRIxPHYSADDR " was not found in the endpoint!\n", source);
2938 XHCI::ResetEndpoint(bool preserve, xhci_endpoint* endpoint)
2942 switch (_GetEndpointState(endpoint)) {
2956 | TRB_3_SLOT(endpoint->device->slot) | TRB_3_ENDPOINT(endpoint->id + 1);
2965 XHCI::StopEndpoint(bool suspend, xhci_endpoint* endpoint)
2969 switch (_GetEndpointState(endpoint)) {
2984 | TRB_3_SLOT(endpoint->device->slot) | TRB_3_ENDPOINT(endpoint->id + 1);
2993 XHCI::SetTRDequeue(uint64 dequeue, uint16 stream, uint8 endpoint, uint8 slot)
3002 | TRB_3_SLOT(slot) | TRB_3_ENDPOINT(endpoint);