source: mainline/uspace/lib/usbhost/include/usb/host/hcd.h

Last change on this file was 8300c72, checked in by Jiri Svoboda <jiri@…>, 4 months ago

Quiesce devices before proceeding with shutdown.

Only implemented for e1k, uhci and xhci.

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[45d105a]1/*
[8300c72]2 * Copyright (c) 2025 Jiri Svoboda
[45d105a]3 * Copyright (c) 2011 Jan Vesely
[e0a5d4c]4 * Copyright (c) 2018 Ondrej Hlavaty
[45d105a]5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * - The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/** @addtogroup libusbhost
32 * @{
33 */
34/** @file
35 *
36 */
[77ad86c]37
[45d105a]38#ifndef LIBUSBHOST_HOST_HCD_H
39#define LIBUSBHOST_HOST_HCD_H
40
[fec7ba0]41#include <fibril.h>
[32fb6bce]42#include <ddf/driver.h>
43#include <usb/request.h>
44
45typedef struct hw_resource_list_parsed hw_res_list_parsed_t;
[64fea02]46typedef struct bus bus_t;
47typedef struct device device_t;
[32fb6bce]48
[7c3fb9b]49/*
50 * Treat this header as read-only in driver code.
[32fb6bce]51 * It could be opaque, but why to complicate matters.
52 */
53typedef struct hc_device {
54 /* Bus instance */
[41924f30]55 bus_t *bus;
[9348862]56
[32fb6bce]57 /* Managed DDF device */
58 ddf_dev_t *ddf_dev;
59
60 /* Control function */
61 ddf_fun_t *ctl_fun;
62
[eadaeae8]63 /* IRQ capability handle of the subscribed IRQ code */
64 cap_irq_handle_t irq_handle;
[32fb6bce]65
[3e200736]66 /** Interrupt replacement fibril */
67 fid_t polling_fibril;
[b5f813c]68
[32fb6bce]69 /* This structure is meant to be extended by driver code. */
70} hc_device_t;
[41924f30]71
[32fb6bce]72typedef struct hc_driver {
73 const char *name;
[77ad86c]74
[32fb6bce]75 /** Size of the device data to be allocated, and passed as the
[7c3fb9b]76 * hc_device_t.
77 */
[32fb6bce]78 size_t hc_device_size;
[77ad86c]79
[32fb6bce]80 /** Initialize device structures. */
81 int (*hc_add)(hc_device_t *, const hw_res_list_parsed_t *);
82
83 /** Generate IRQ code to handle interrupts. */
[ae3a941]84 int (*irq_code_gen)(irq_code_t *, hc_device_t *,
85 const hw_res_list_parsed_t *, int *);
[32fb6bce]86
87 /** Claim device from BIOS. */
88 int (*claim)(hc_device_t *);
89
90 /** Start the host controller. */
91 int (*start)(hc_device_t *);
92
93 /** Setup the virtual roothub. */
94 int (*setup_root_hub)(hc_device_t *);
95
96 /** Stop the host controller (after start has been called) */
97 int (*stop)(hc_device_t *);
98
99 /** HC was asked to be removed (after hc_add has been called) */
100 int (*hc_remove)(hc_device_t *);
101
102 /** HC is gone. */
103 int (*hc_gone)(hc_device_t *);
[8300c72]104
105 /** Quiesce HC. */
106 int (*hc_quiesce)(hc_device_t *);
[32fb6bce]107} hc_driver_t;
108
109/* Drivers should call this before leaving hc_add */
[ae3a941]110static inline void hc_device_setup(hc_device_t *hcd, bus_t *bus)
111{
[32fb6bce]112 hcd->bus = bus;
[b5f813c]113}
114
[32fb6bce]115static inline hc_device_t *dev_to_hcd(ddf_dev_t *dev)
[4daee7a]116{
[32fb6bce]117 return ddf_dev_data_get(dev);
[4daee7a]118}
119
[5a6cc679]120extern errno_t hc_driver_main(const hc_driver_t *);
[9c7ed9c]121
[45d105a]122#endif
[58563585]123
[45d105a]124/**
125 * @}
126 */
Note: See TracBrowser for help on using the repository browser.