Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 70e5ad5 in mainline


Ignore:
Timestamp:
2010-12-16T11:12:31Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
11658b64, 5863a95
Parents:
cea3fca
Message:

More doxygen comments

Location:
uspace/drv/vhc/hub
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/vhc/hub/hub.c

    rcea3fca r70e5ad5  
    3131 */
    3232/** @file
    33  * @brief Virtual USB hub.
     33 * @brief Representation of an USB hub (implementation).
    3434 */
    3535#include <usb/classes/classes.h>
     
    338338}
    339339
     340/** Create hub status change bitmap.
     341 *
     342 * @warning This function assumes that the whole bitmap fits into 8 bits.
     343 *
     344 * @param hub Hub in question.
     345 * @return Hub status change bitmap.
     346 */
    340347uint8_t hub_get_status_change_bitmap(hub_t *hub)
    341348{
     
    361368 */
    362369
     370/** Find a port in a hub.
     371 *
     372 * @param hub Hub in question.
     373 * @param port Port index (zero based).
     374 * @return Port structure.
     375 * @retval NULL Invalid port index.
     376 */
    363377static hub_port_t *get_hub_port(hub_t *hub, size_t port)
    364378{
     
    370384}
    371385
     386/** Adds a port status change to a port.
     387 *
     388 * @param port The port with status change.
     389 * @param change Change to be added to the status.
     390 */
    372391static void set_port_status_change(hub_port_t *port,
    373392    hub_status_change_t change)
     
    377396}
    378397
     398/** Clears a port status change on a port.
     399 *
     400 * @param port The port with status change.
     401 * @param change Change to be removed from the status.
     402 */
    379403static void clear_port_status_change(hub_port_t *port,
    380404    uint16_t change)
     
    384408}
    385409
     410/** Structure for automatic (delayed) port state change. */
    386411struct delay_port_state_change {
     412        /** Delay in microseconds. */
    387413        suseconds_t delay;
     414        /** Old state of the port. */
    388415        hub_port_state_t old_state;
     416        /** New state of the port. */
    389417        hub_port_state_t new_state;
     418        /** Port index (zero based). */
    390419        size_t port;
     420        /** Hub. */
    391421        hub_t *hub;
    392422};
    393423
     424/** Fibril responsible for delayed port state change.
     425 *
     426 * @param arg Pointer to delay_port_state_change.
     427 * @return Always EOK.
     428 */
    394429static int set_port_state_delayed_fibril(void *arg)
    395430{
     
    416451}
    417452
     453/** Change port state with a delay.
     454 *
     455 * @warning If the port state changes during the waiting phase, the state
     456 * is not changed.
     457 *
     458 * @param hub Hub in question.
     459 * @param port_index Port index (zero based).
     460 * @param delay_time_ms Delay time in miliseconds.
     461 * @param old_state Old (current) state of the port.
     462 * @param new_state New state of the port.
     463 */
    418464static void set_port_state_delayed(hub_t *hub, size_t port_index,
    419465    suseconds_t delay_time_ms,
  • uspace/drv/vhc/hub/hub.h

    rcea3fca r70e5ad5  
    3131 */
    3232/** @file
    33  * @brief
     33 * @brief Representation of an USB hub.
    3434 */
    3535#ifndef VHC_HUB_HUB_H_
     
    7272/** Hub port information. */
    7373typedef struct {
     74        /** Custom pointer to connected device. */
    7475        void *connected_device;
     76        /** Port index (one based). */
    7577        size_t index;
     78        /** Port state. */
    7679        hub_port_state_t state;
     80        /** Status change bitmap. */
    7781        uint16_t status_change;
    7882} hub_port_t;
     
    8084/** Hub device type. */
    8185typedef struct {
     86        /** Hub ports. */
    8287        hub_port_t ports[HUB_PORT_COUNT];
     88        /** Custom hub data. */
    8389        void *custom_data;
     90        /** Access guard to the whole hub. */
    8491        fibril_mutex_t guard;
    8592} hub_t;
  • uspace/drv/vhc/hub/virthub.c

    rcea3fca r70e5ad5  
    7272};
    7373
     74/** Hub descriptor. */
    7475hub_descriptor_t hub_descriptor = {
    7576        .length = sizeof(hub_descriptor_t),
     
    140141};
    141142
     143/** Initializes virtual hub device.
     144 *
     145 * @param dev Virtual USB device backend.
     146 * @return Error code.
     147 */
    142148int virthub_init(usbvirt_device_t *dev)
    143149{
     
    163169}
    164170
     171/** Connect a device to a virtual hub.
     172 *
     173 * @param dev Virtual device representing the hub.
     174 * @param conn Device to be connected.
     175 * @return Port device was connected to.
     176 */
    165177int virthub_connect_device(usbvirt_device_t *dev, virtdev_connection_t *conn)
    166178{
     
    177189}
    178190
     191/** Disconnect a device from a virtual hub.
     192 *
     193 * @param dev Virtual device representing the hub.
     194 * @param conn Device to be disconnected.
     195 * @return Error code.
     196 */
    179197int virthub_disconnect_device(usbvirt_device_t *dev, virtdev_connection_t *conn)
    180198{
     
    185203
    186204        hub_acquire(hub);
     205        /* TODO: implement. */
    187206        hub_release(hub);
    188207
     
    190209}
    191210
     211/** Whether trafic is propagated to given device.
     212 *
     213 * @param dev Virtual device representing the hub.
     214 * @param conn Connected device.
     215 * @return Whether port is signalling to the device.
     216 */
    192217bool virthub_is_device_enabled(usbvirt_device_t *dev, virtdev_connection_t *conn)
    193218{
     
    209234}
    210235
     236/** Format status of a virtual hub.
     237 *
     238 * @param dev Virtual device representing the hub.
     239 * @param[out] status Hub status information.
     240 * @param[in] len Size of the @p status buffer.
     241 */
    211242void virthub_get_status(usbvirt_device_t *dev, char *status, size_t len)
    212243{
  • uspace/drv/vhc/hub/virthub.h

    rcea3fca r70e5ad5  
    3131 */
    3232/** @file
    33  * @brief
     33 * @brief USB hub as a virtual USB device.
    3434 */
    3535#ifndef VHC_HUB_VIRTHUB_H_
  • uspace/drv/vhc/hub/virthubops.c

    rcea3fca r70e5ad5  
    8686}
    8787
    88 
     88/** Handle ClearHubFeature request.
     89 *
     90 * @param dev Virtual device representing the hub.
     91 * @param request The SETUP packet of the control request.
     92 * @param data Extra data (when DATA stage present).
     93 * @return Error code.
     94 */
    8995static int req_clear_hub_feature(usbvirt_device_t *dev,
    9096    usb_device_request_setup_packet_t *request,
     
    94100}
    95101
     102/** Handle ClearPortFeature request.
     103 *
     104 * @param dev Virtual device representing the hub.
     105 * @param request The SETUP packet of the control request.
     106 * @param data Extra data (when DATA stage present).
     107 * @return Error code.
     108 */
    96109static int req_clear_port_feature(usbvirt_device_t *dev,
    97110    usb_device_request_setup_packet_t *request,
     
    167180}
    168181
     182/** Handle GetBusState request.
     183 *
     184 * @param dev Virtual device representing the hub.
     185 * @param request The SETUP packet of the control request.
     186 * @param data Extra data (when DATA stage present).
     187 * @return Error code.
     188 */
    169189static int req_get_bus_state(usbvirt_device_t *dev,
    170190    usb_device_request_setup_packet_t *request,
     
    174194}
    175195
     196/** Handle GetDescriptor request.
     197 *
     198 * @param dev Virtual device representing the hub.
     199 * @param request The SETUP packet of the control request.
     200 * @param data Extra data (when DATA stage present).
     201 * @return Error code.
     202 */
    176203static int req_get_descriptor(usbvirt_device_t *dev,
    177204    usb_device_request_setup_packet_t *request,
     
    188215}
    189216
     217/** Handle GetHubStatus request.
     218 *
     219 * @param dev Virtual device representing the hub.
     220 * @param request The SETUP packet of the control request.
     221 * @param data Extra data (when DATA stage present).
     222 * @return Error code.
     223 */
    190224static int req_get_hub_status(usbvirt_device_t *dev,
    191225    usb_device_request_setup_packet_t *request,
     
    198232}
    199233
     234/** Handle GetPortStatus request.
     235 *
     236 * @param dev Virtual device representing the hub.
     237 * @param request The SETUP packet of the control request.
     238 * @param data Extra data (when DATA stage present).
     239 * @return Error code.
     240 */
    200241static int req_get_port_status(usbvirt_device_t *dev,
    201242    usb_device_request_setup_packet_t *request,
     
    213254}
    214255
     256/** Handle SetHubFeature request.
     257 *
     258 * @param dev Virtual device representing the hub.
     259 * @param request The SETUP packet of the control request.
     260 * @param data Extra data (when DATA stage present).
     261 * @return Error code.
     262 */
    215263static int req_set_hub_feature(usbvirt_device_t *dev,
    216264    usb_device_request_setup_packet_t *request,
     
    220268}
    221269
     270/** Handle SetPortFeature request.
     271 *
     272 * @param dev Virtual device representing the hub.
     273 * @param request The SETUP packet of the control request.
     274 * @param data Extra data (when DATA stage present).
     275 * @return Error code.
     276 */
    222277static int req_set_port_feature(usbvirt_device_t *dev,
    223278    usb_device_request_setup_packet_t *request,
     
    265320
    266321
    267 
     322/** IN class request. */
    268323#define CLASS_REQ_IN(recipient) \
    269324        USBVIRT_MAKE_CONTROL_REQUEST_TYPE(USB_DIRECTION_IN, \
    270325        USBVIRT_REQUEST_TYPE_CLASS, recipient)
     326/** OUT class request. */
    271327#define CLASS_REQ_OUT(recipient) \
    272328        USBVIRT_MAKE_CONTROL_REQUEST_TYPE(USB_DIRECTION_OUT, \
    273329        USBVIRT_REQUEST_TYPE_CLASS, recipient)
    274330
     331/** Recipient: other. */
    275332#define REC_OTHER USBVIRT_REQUEST_RECIPIENT_OTHER
     333/** Recipient: device. */
    276334#define REC_DEVICE USBVIRT_REQUEST_RECIPIENT_DEVICE
     335/** Direction: in. */
    277336#define DIR_IN USB_DIRECTION_IN
     337/** Direction: out. */
    278338#define DIR_OUT USB_DIRECTION_OUT
    279339
     340/** Create a class request.
     341 *
     342 * @param direction Request direction.
     343 * @param recipient Request recipient.
     344 * @param req Request code.
     345 */
    280346#define CLASS_REQ(direction, recipient, req) \
    281347        .request_type = USBVIRT_MAKE_CONTROL_REQUEST_TYPE(direction, \
     
    283349        .request = req
    284350
     351/** Create a standard request.
     352 *
     353 * @param direction Request direction.
     354 * @param recipient Request recipient.
     355 * @param req Request code.
     356 */
    285357#define STD_REQ(direction, recipient, req) \
    286358        .request_type = USBVIRT_MAKE_CONTROL_REQUEST_TYPE(direction, \
Note: See TracChangeset for help on using the changeset viewer.