Changeset 45457265 in mainline for uspace/drv/bus/usb/xhci/hc.c
- Timestamp:
- 2018-02-03T02:14:26Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- eb862fd
- Parents:
- 961a5ee
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/hc.c
r961a5ee r45457265 80 80 * ports to protocol versions and speeds. 81 81 */ 82 static int hc_parse_ec(xhci_hc_t *hc)82 static errno_t hc_parse_ec(xhci_hc_t *hc) 83 83 { 84 84 unsigned psic, major, minor; … … 186 186 * Initialize MMIO spaces of xHC. 187 187 */ 188 int hc_init_mmio(xhci_hc_t *hc, const hw_res_list_parsed_t *hw_res)189 { 190 int err;188 errno_t hc_init_mmio(xhci_hc_t *hc, const hw_res_list_parsed_t *hw_res) 189 { 190 errno_t err; 191 191 192 192 if (hw_res->mem_ranges.count != 1) { … … 257 257 * Initialize structures kept in allocated memory. 258 258 */ 259 int hc_init_memory(xhci_hc_t *hc, ddf_dev_t *device)260 { 261 int err = ENOMEM;259 errno_t hc_init_memory(xhci_hc_t *hc, ddf_dev_t *device) 260 { 261 errno_t err = ENOMEM; 262 262 263 263 if (dma_buffer_alloc(&hc->dcbaa_dma, (1 + hc->max_slots) * sizeof(uint64_t))) … … 362 362 * (except 0) are disabled. 363 363 */ 364 int hc_irq_code_gen(irq_code_t *code, xhci_hc_t *hc, const hw_res_list_parsed_t *hw_res, int *irq)364 errno_t hc_irq_code_gen(irq_code_t *code, xhci_hc_t *hc, const hw_res_list_parsed_t *hw_res, int *irq) 365 365 { 366 366 assert(code); … … 412 412 * Claim xHC from BIOS. Implements handoff as per Section 4.22.1 of xHCI spec. 413 413 */ 414 int hc_claim(xhci_hc_t *hc, ddf_dev_t *dev)414 errno_t hc_claim(xhci_hc_t *hc, ddf_dev_t *dev) 415 415 { 416 416 /* No legacy support capability, the controller is solely for us */ … … 440 440 * Ask the xHC to reset its state. Implements sequence 441 441 */ 442 static int hc_reset(xhci_hc_t *hc)442 static errno_t hc_reset(xhci_hc_t *hc) 443 443 { 444 444 if (xhci_reg_wait(&hc->op_regs->usbsts, XHCI_REG_MASK(XHCI_OP_CNR), 0)) … … 466 466 * Initialize the HC: section 4.2 467 467 */ 468 int hc_start(xhci_hc_t *hc)469 { 470 int err;468 errno_t hc_start(xhci_hc_t *hc) 469 { 470 errno_t err; 471 471 472 472 if ((err = hc_reset(hc))) … … 565 565 * Used only when polling. Shall supplement the irq_commands. 566 566 */ 567 int hc_status(bus_t *bus, uint32_t *status)567 errno_t hc_status(bus_t *bus, uint32_t *status) 568 568 { 569 569 xhci_hc_t *hc = bus_to_hc(bus); … … 583 583 } 584 584 585 static int xhci_handle_mfindex_wrap_event(xhci_hc_t *hc, xhci_trb_t *trb)585 static errno_t xhci_handle_mfindex_wrap_event(xhci_hc_t *hc, xhci_trb_t *trb) 586 586 { 587 587 struct timeval tv; … … 594 594 } 595 595 596 typedef int (*event_handler) (xhci_hc_t *, xhci_trb_t *trb);596 typedef errno_t (*event_handler) (xhci_hc_t *, xhci_trb_t *trb); 597 597 598 598 /** … … 612 612 }; 613 613 614 static int hc_handle_event(xhci_hc_t *hc, xhci_trb_t *trb)614 static errno_t hc_handle_event(xhci_hc_t *hc, xhci_trb_t *trb) 615 615 { 616 616 const unsigned type = TRB_TYPE(*trb); … … 630 630 static int event_worker(void *arg) 631 631 { 632 int err;632 errno_t err; 633 633 xhci_trb_t trb; 634 634 xhci_hc_t * const hc = arg; … … 654 654 xhci_interrupter_regs_t *intr) 655 655 { 656 int err;656 errno_t err; 657 657 658 658 xhci_trb_t trb; … … 781 781 * DCBAA with the newly created slot. 782 782 */ 783 int hc_enable_slot(xhci_device_t *dev)784 { 785 int err;783 errno_t hc_enable_slot(xhci_device_t *dev) 784 { 785 errno_t err; 786 786 xhci_hc_t * const hc = bus_to_hc(dev->base.bus); 787 787 … … 815 815 * Frees the device context. 816 816 */ 817 int hc_disable_slot(xhci_device_t *dev)818 { 819 int err;817 errno_t hc_disable_slot(xhci_device_t *dev) 818 { 819 errno_t err; 820 820 xhci_hc_t * const hc = bus_to_hc(dev->base.bus); 821 821 … … 837 837 * Prepare an empty Endpoint Input Context inside a dma buffer. 838 838 */ 839 static int create_configure_ep_input_ctx(xhci_device_t *dev, dma_buffer_t *dma_buf)839 static errno_t create_configure_ep_input_ctx(xhci_device_t *dev, dma_buffer_t *dma_buf) 840 840 { 841 841 const xhci_hc_t * hc = bus_to_hc(dev->base.bus); 842 const int err = dma_buffer_alloc(dma_buf, XHCI_INPUT_CTX_SIZE(hc));842 const errno_t err = dma_buffer_alloc(dma_buf, XHCI_INPUT_CTX_SIZE(hc)); 843 843 if (err) 844 844 return err; … … 860 860 * @param dev Device to assing an address (unconfigured yet) 861 861 */ 862 int hc_address_device(xhci_device_t *dev)863 { 864 int err = ENOMEM;862 errno_t hc_address_device(xhci_device_t *dev) 863 { 864 errno_t err = ENOMEM; 865 865 xhci_hc_t * const hc = bus_to_hc(dev->base.bus); 866 866 xhci_endpoint_t *ep0 = xhci_endpoint_get(dev->base.endpoints[0]); … … 908 908 * @param slot_id Slot ID assigned to the device. 909 909 */ 910 int hc_configure_device(xhci_device_t *dev)910 errno_t hc_configure_device(xhci_device_t *dev) 911 911 { 912 912 xhci_hc_t * const hc = bus_to_hc(dev->base.bus); … … 914 914 /* Issue configure endpoint command (sec 4.3.5). */ 915 915 dma_buffer_t ictx_dma_buf; 916 const int err = create_configure_ep_input_ctx(dev, &ictx_dma_buf);916 const errno_t err = create_configure_ep_input_ctx(dev, &ictx_dma_buf); 917 917 if (err) 918 918 return err; … … 929 929 * @param dev The owner of the device 930 930 */ 931 int hc_deconfigure_device(xhci_device_t *dev)931 errno_t hc_deconfigure_device(xhci_device_t *dev) 932 932 { 933 933 xhci_hc_t * const hc = bus_to_hc(dev->base.bus); … … 950 950 * @param ep_ctx Endpoint context of the endpoint 951 951 */ 952 int hc_add_endpoint(xhci_endpoint_t *ep)952 errno_t hc_add_endpoint(xhci_endpoint_t *ep) 953 953 { 954 954 xhci_device_t * const dev = xhci_ep_to_dev(ep); … … 957 957 /* Issue configure endpoint command (sec 4.3.5). */ 958 958 dma_buffer_t ictx_dma_buf; 959 const int err = create_configure_ep_input_ctx(dev, &ictx_dma_buf);959 const errno_t err = create_configure_ep_input_ctx(dev, &ictx_dma_buf); 960 960 if (err) 961 961 return err; … … 981 981 * @param ep_idx Endpoint DCI in question 982 982 */ 983 int hc_drop_endpoint(xhci_endpoint_t *ep)983 errno_t hc_drop_endpoint(xhci_endpoint_t *ep) 984 984 { 985 985 xhci_device_t * const dev = xhci_ep_to_dev(ep); … … 992 992 /* Issue configure endpoint command (sec 4.3.5). */ 993 993 dma_buffer_t ictx_dma_buf; 994 const int err = create_configure_ep_input_ctx(dev, &ictx_dma_buf);994 const errno_t err = create_configure_ep_input_ctx(dev, &ictx_dma_buf); 995 995 if (err) 996 996 return err; … … 1013 1013 * @param ep_ctx Endpoint context of the endpoint 1014 1014 */ 1015 int hc_update_endpoint(xhci_endpoint_t *ep)1015 errno_t hc_update_endpoint(xhci_endpoint_t *ep) 1016 1016 { 1017 1017 xhci_device_t * const dev = xhci_ep_to_dev(ep); … … 1021 1021 xhci_hc_t * const hc = bus_to_hc(dev->base.bus); 1022 1022 1023 const int err = dma_buffer_alloc(&ictx_dma_buf, XHCI_INPUT_CTX_SIZE(hc));1023 const errno_t err = dma_buffer_alloc(&ictx_dma_buf, XHCI_INPUT_CTX_SIZE(hc)); 1024 1024 if (err) 1025 1025 return err; … … 1044 1044 * @param ep_idx Endpoint DCI in question 1045 1045 */ 1046 int hc_stop_endpoint(xhci_endpoint_t *ep)1046 errno_t hc_stop_endpoint(xhci_endpoint_t *ep) 1047 1047 { 1048 1048 xhci_device_t * const dev = xhci_ep_to_dev(ep); … … 1065 1065 * @param ep_idx Endpoint DCI in question 1066 1066 */ 1067 int hc_reset_endpoint(xhci_endpoint_t *ep)1067 errno_t hc_reset_endpoint(xhci_endpoint_t *ep) 1068 1068 { 1069 1069 xhci_device_t * const dev = xhci_ep_to_dev(ep); … … 1081 1081 * @param dev The owner of the endpoint 1082 1082 */ 1083 int hc_reset_ring(xhci_endpoint_t *ep, uint32_t stream_id)1083 errno_t hc_reset_ring(xhci_endpoint_t *ep, uint32_t stream_id) 1084 1084 { 1085 1085 xhci_device_t * const dev = xhci_ep_to_dev(ep);
Note:
See TracChangeset
for help on using the changeset viewer.