source: mainline/uspace/drv/bus/usb/xhci/hc.h@ 10cd715

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 10cd715 was 889146e, checked in by Ondřej Hlavatý <aearsis@…>, 8 years ago

xhci: commands shall not just timeout

Previous behavior was breaking semantic: if a command was successful,
but just took too long to complete, we returned an error, and the caller
had no way to know if the command's effect has taken place.

This commit implements command aborting. The wait_for_command now cannot
just timeout - instead it aborts currently running (probably blocked)
command, and then gets back to waiting. So now, if command_sync returns
an error, it means the command was really unsuccessful.

If aborting the command takes too long, we should reset the whole HC.
This is not yet implemented.

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 * Copyright (c) 2017 Ondrej Hlavaty
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup drvusbxhci
30 * @{
31 */
32/** @file
33 * @brief The host controller data bookkeeping.
34 */
35
36#ifndef XHCI_HC_H
37#define XHCI_HC_H
38
39#include <fibril_synch.h>
40#include <usb/host/usb_transfer_batch.h>
41#include "hw_struct/regs.h"
42#include "hw_struct/context.h"
43#include "scratchpad.h"
44#include "trb_ring.h"
45
46#include "rh.h"
47#include "commands.h"
48#include "bus.h"
49
50typedef struct xhci_command xhci_cmd_t;
51
52typedef struct xhci_hc {
53 /* MMIO range */
54 addr_range_t mmio_range;
55
56 /* Mapped register sets */
57 void *reg_base;
58 xhci_cap_regs_t *cap_regs;
59 xhci_op_regs_t *op_regs;
60 xhci_rt_regs_t *rt_regs;
61 xhci_doorbell_t *db_arry;
62 xhci_extcap_t *xecp; /**< First extended capability */
63 xhci_legsup_t *legsup; /**< Legacy support capability */
64
65 /* Structures in allocated memory */
66 xhci_event_ring_t event_ring;
67 uint64_t *dcbaa;
68 dma_buffer_t dcbaa_dma;
69 dma_buffer_t scratchpad_array;
70 dma_buffer_t *scratchpad_buffers;
71
72 /* Command ring management */
73 xhci_cmd_ring_t cr;
74
75 /* Root hub emulation */
76 xhci_rh_t rh;
77
78 /* Bus bookkeeping */
79 xhci_bus_t bus;
80
81 /* Cached capabilities */
82 unsigned max_slots;
83 bool ac64;
84
85 /** Port speed mapping */
86 xhci_port_speed_t speeds [16];
87 uint8_t speed_to_psiv [USB_SPEED_MAX];
88
89 /* TODO: Hack. Figure out a better way. */
90 hcd_t *hcd;
91} xhci_hc_t;
92
93typedef struct xhci_endpoint xhci_endpoint_t;
94typedef struct xhci_device xhci_device_t;
95
96int hc_init_mmio(xhci_hc_t *, const hw_res_list_parsed_t *);
97int hc_init_memory(xhci_hc_t *, ddf_dev_t *);
98int hc_claim(xhci_hc_t *, ddf_dev_t *);
99int hc_irq_code_gen(irq_code_t *, xhci_hc_t *, const hw_res_list_parsed_t *);
100int hc_start(xhci_hc_t *, bool);
101int hc_schedule(xhci_hc_t *hc, usb_transfer_batch_t *batch);
102int hc_status(xhci_hc_t *, uint32_t *);
103void hc_interrupt(xhci_hc_t *, uint32_t);
104void hc_fini(xhci_hc_t *);
105int hc_ring_doorbell(xhci_hc_t *, unsigned, unsigned);
106int hc_enable_slot(xhci_hc_t *, uint32_t *);
107int hc_disable_slot(xhci_hc_t *, xhci_device_t *);
108int hc_address_device(xhci_hc_t *, xhci_device_t *, xhci_endpoint_t *);
109int hc_configure_device(xhci_hc_t *, uint32_t);
110int hc_deconfigure_device(xhci_hc_t *, uint32_t);
111int hc_add_endpoint(xhci_hc_t *, uint32_t, uint8_t, xhci_ep_ctx_t *);
112int hc_drop_endpoint(xhci_hc_t *, uint32_t, uint8_t);
113int hc_update_endpoint(xhci_hc_t *, uint32_t, uint8_t, xhci_ep_ctx_t *);
114
115#endif
116
117/**
118 * @}
119 */
Note: See TracBrowser for help on using the repository browser.