Changeset ca07cd3 in mainline for uspace/lib/usbvirt/device.h


Ignore:
Timestamp:
2010-10-25T13:23:33Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
23cb44b
Parents:
355f7c2
Message:

Code cleanup, various bugfixes

The internal functions of virtual device framework always get
device structure as parameter, thus possible enabling more devices
within single task (that is not possible because currently there
is no way to pass extra argument into callback_connection()).

Also, added some missing comments and completely removed the device
id nonsense (devices can send their descriptors and the hub is able
to enable/disable its ports).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbvirt/device.h

    r355f7c2 rca07cd3  
    4040#include <usb/devreq.h>
    4141
    42 struct usbvirt_device;
     42typedef struct usbvirt_device usbvirt_device_t;
    4343struct usbvirt_control_transfer;
    4444
    45 typedef int (*usbvirt_on_device_request_t)(struct usbvirt_device *dev,
     45typedef int (*usbvirt_on_device_request_t)(usbvirt_device_t *dev,
    4646        usb_device_request_setup_packet_t *request,
    4747        uint8_t *data);
     
    7272        usbvirt_on_device_request_t on_class_device_request;
    7373       
    74         int (*on_control_transfer)(struct usbvirt_device *dev,
     74        int (*on_control_transfer)(usbvirt_device_t *dev,
    7575            usb_endpoint_t endpoint, struct usbvirt_control_transfer *transfer);
    7676       
    7777        /** Callback for all other incoming data. */
    78         int (*on_data)(struct usbvirt_device *dev,
     78        int (*on_data)(usbvirt_device_t *dev,
    7979            usb_endpoint_t endpoint, void *buffer, size_t size);
    8080       
    8181        /** Callback for host request for data. */
    82         int (*on_data_request)(struct usbvirt_device *dev,
     82        int (*on_data_request)(usbvirt_device_t *dev,
    8383            usb_endpoint_t endpoint, void *buffer, size_t size, size_t *actual_size);
    8484       
     
    133133 */
    134134typedef struct usbvirt_control_transfer {
     135        /** Transfer direction (read/write control transfer). */
    135136        usb_direction_t direction;
     137        /** Request data. */
    136138        void *request;
     139        /** Size of request data. */
    137140        size_t request_size;
     141        /** Payload. */
    138142        void *data;
     143        /** Size of payload. */
    139144        size_t data_size;
    140145} usbvirt_control_transfer_t;
    141146
    142147/** Virtual USB device. */
    143 typedef struct usbvirt_device {
     148struct usbvirt_device {
    144149        /** Callback device operations. */
    145150        usbvirt_device_ops_t *ops;
    146151       
    147        
    148152        /** Reply onto control transfer.
    149153         */
    150         int (*control_transfer_reply)(struct usbvirt_device *dev,
     154        int (*control_transfer_reply)(usbvirt_device_t *dev,
    151155            usb_endpoint_t endpoint, void *buffer, size_t size);
    152156       
    153         /* Device attributes. */
     157        /** Device name.
     158         * Used in debug prints and sent to virtual host controller.
     159         */
     160        const char *name;
    154161       
    155162        /** Standard descriptors. */
     
    158165        /** Current device state. */
    159166        usbvirt_device_state_t state;
     167       
    160168        /** Device address. */
    161169        usb_address_t address;
     170        /** New device address.
     171         * This field is used during SET_ADDRESS request.
     172         * On all other occasions, it holds invalid address (e.g. -1).
     173         */
     174        usb_address_t new_address;
    162175       
    163         /* Private attributes. */
    164        
    165         /** Phone to HC.
    166          * @warning Do not change, this is private variable.
    167          */
    168         int vhcd_phone_;
    169        
    170         /** Device id.
    171          * This item will be removed when device enumeration and
    172          * recognition is implemented.
    173          */
    174         int device_id_;
    175        
    176         int (*transaction_out)(struct usbvirt_device *dev,
     176        /** Process OUT transaction. */
     177        int (*transaction_out)(usbvirt_device_t *dev,
    177178            usb_endpoint_t endpoint, void *buffer, size_t size);
    178         int (*transaction_setup)(struct usbvirt_device *dev,
     179        /** Process SETUP transaction. */
     180        int (*transaction_setup)(usbvirt_device_t *dev,
    179181            usb_endpoint_t endpoint, void *buffer, size_t size);
    180         int (*transaction_in)(struct usbvirt_device *dev,
     182        /** Process IN transaction. */
     183        int (*transaction_in)(usbvirt_device_t *dev,
    181184            usb_endpoint_t endpoint, void *buffer, size_t size, size_t *data_size);
    182185       
     186        /** State information on control-transfer endpoints. */
    183187        usbvirt_control_transfer_t current_control_transfers[USB11_ENDPOINT_MAX];
    184 } usbvirt_device_t;
     188};
    185189
    186190#endif
Note: See TracChangeset for help on using the changeset viewer.