Changeset d369b3b in mainline for uspace/drv


Ignore:
Timestamp:
2018-01-25T02:05:57Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
296d22fc
Parents:
b357377
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-25 01:52:13)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-25 02:05:57)
Message:

usb2_bus: no longer be a bus

As the number of implemented functions got to 3, it's not so beneficial
to inherit usb2 bus to get the functionality. Overall, four trampolines
needed to be added, which is an acceptable number.

Now, the usb2_bus has become a usb2_bus_helper, to be used as
a companion to the common bus.

This is mostly a preparation to remove the runtime binding of the bus
methods.

Location:
uspace/drv/bus/usb
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/ehci_bus.c

    rb357377 rd369b3b  
    5757}
    5858
     59static int ehci_device_enumerate(device_t *dev)
     60{
     61        ehci_bus_t *bus = (ehci_bus_t *) dev->bus;
     62        return usb2_bus_device_enumerate(&bus->helper, dev);
     63}
    5964
    6065/** Creates new hcd endpoint representation.
     
    101106        ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep);
    102107
    103         const int err = usb2_bus_ops.endpoint_register(ep);
     108        const int err = usb2_bus_endpoint_register(&bus->helper, ep);
    104109        if (err)
    105110                return err;
     
    119124        assert(ep);
    120125
    121         usb2_bus_ops.endpoint_unregister(ep);
     126        usb2_bus_endpoint_unregister(&bus->helper, ep);
    122127        hc_dequeue_endpoint(hc, ep);
    123128        /*
     
    154159
    155160static const bus_ops_t ehci_bus_ops = {
    156         .parent = &usb2_bus_ops,
    157 
    158161        .interrupt = ehci_hc_interrupt,
    159162        .status = ehci_hc_status,
     163
     164        .device_enumerate = ehci_device_enumerate,
    160165
    161166        .endpoint_destroy = ehci_endpoint_destroy,
     
    174179        assert(bus);
    175180
    176         usb2_bus_t *usb2_bus = (usb2_bus_t *) bus;
    177181        bus_t *bus_base = (bus_t *) bus;
     182        bus_init(bus_base, sizeof(device_t));
     183        bus_base->ops = &ehci_bus_ops;
    178184
    179         usb2_bus_init(usb2_bus, &bandwidth_accounting_usb2);
    180         bus_base->ops = &ehci_bus_ops;
     185        usb2_bus_helper_init(&bus->helper, &bandwidth_accounting_usb2);
    181186
    182187        bus->hc = hc;
  • uspace/drv/bus/usb/ehci/ehci_bus.h

    rb357377 rd369b3b  
    6464
    6565typedef struct {
    66         usb2_bus_t base;
     66        bus_t base;
     67        usb2_bus_helper_t helper;
    6768        hc_t *hc;
    6869} ehci_bus_t;
  • uspace/drv/bus/usb/ohci/ohci_bus.c

    rb357377 rd369b3b  
    5757}
    5858
     59static int ohci_device_enumerate(device_t *dev)
     60{
     61        ohci_bus_t *bus = (ohci_bus_t *) dev->bus;
     62        return usb2_bus_device_enumerate(&bus->helper, dev);
     63}
     64
    5965/** Creates new hcd endpoint representation.
    6066 */
     
    109115        ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep);
    110116
    111         const int err = usb2_bus_ops.endpoint_register(ep);
     117        const int err = usb2_bus_endpoint_register(&bus->helper, ep);
    112118        if (err)
    113119                return err;
     
    126132        assert(ep);
    127133
    128         usb2_bus_ops.endpoint_unregister(ep);
     134        usb2_bus_endpoint_unregister(&bus->helper, ep);
    129135        hc_dequeue_endpoint(bus->hc, ep);
    130136
     
    162168
    163169static const bus_ops_t ohci_bus_ops = {
    164         .parent = &usb2_bus_ops,
    165 
    166170        .interrupt = ohci_hc_interrupt,
    167171        .status = ohci_hc_status,
     172
     173        .device_enumerate = ohci_device_enumerate,
    168174
    169175        .endpoint_destroy = ohci_endpoint_destroy,
     
    183189        assert(bus);
    184190
    185         usb2_bus_t *usb2_bus = (usb2_bus_t *) bus;
    186191        bus_t *bus_base = (bus_t *) bus;
    187 
    188         usb2_bus_init(usb2_bus, &bandwidth_accounting_usb11);
     192        bus_init(bus_base, sizeof(device_t));
    189193        bus_base->ops = &ohci_bus_ops;
     194
     195        usb2_bus_helper_init(&bus->helper, &bandwidth_accounting_usb11);
    190196
    191197        bus->hc = hc;
  • uspace/drv/bus/usb/ohci/ohci_bus.h

    rb357377 rd369b3b  
    6060
    6161typedef struct {
    62         usb2_bus_t base;
     62        bus_t base;
     63        usb2_bus_helper_t helper;
    6364        hc_t *hc;
    6465} ohci_bus_t;
  • uspace/drv/bus/usb/uhci/hc.c

    rb357377 rd369b3b  
    329329        hc_t * const hc = bus_to_hc(endpoint_get_bus(ep));
    330330
    331         const int err = usb2_bus_ops.endpoint_register(ep);
     331        const int err = usb2_bus_endpoint_register(&hc->bus_helper, ep);
    332332        if (err)
    333333                return err;
     
    350350{
    351351        hc_t * const hc = bus_to_hc(endpoint_get_bus(ep));
    352         usb2_bus_ops.endpoint_unregister(ep);
     352        usb2_bus_endpoint_unregister(&hc->bus_helper, ep);
    353353
    354354        // Check for the roothub, as it does not schedule into lists
     
    406406}
    407407
     408static int device_enumerate(device_t *dev)
     409{
     410        hc_t * const hc = bus_to_hc(dev->bus);
     411        return usb2_bus_device_enumerate(&hc->bus_helper, dev);
     412}
     413
    408414static int hc_status(bus_t *, uint32_t *);
    409415static int hc_schedule(usb_transfer_batch_t *);
    410416
    411417static const bus_ops_t uhci_bus_ops = {
    412         .parent = &usb2_bus_ops,
    413 
    414418        .interrupt = hc_interrupt,
    415419        .status = hc_status,
     420
     421        .device_enumerate = device_enumerate,
    416422
    417423        .endpoint_create = endpoint_create,
     
    438444        assert(instance);
    439445
    440         usb2_bus_init(&instance->bus, &bandwidth_accounting_usb11);
    441 
    442         bus_t *bus = (bus_t *) &instance->bus;
    443         bus->ops = &uhci_bus_ops;
    444 
    445         hc_device_setup(&instance->base, bus);
     446        usb2_bus_helper_init(&instance->bus_helper, &bandwidth_accounting_usb11);
     447
     448        bus_init(&instance->bus, sizeof(device_t));
     449        instance->bus.ops = &uhci_bus_ops;
     450
     451        hc_device_setup(&instance->base, &instance->bus);
    446452
    447453        /* Init USB frame list page */
  • uspace/drv/bus/usb/uhci/hc.h

    rb357377 rd369b3b  
    104104
    105105        uhci_rh_t rh;
    106         usb2_bus_t bus;
     106        bus_t bus;
     107        usb2_bus_helper_t bus_helper;
     108
    107109        /** Addresses of I/O registers */
    108110        uhci_regs_t *registers;
  • uspace/drv/bus/usb/vhc/transfer.c

    rb357377 rd369b3b  
    163163}
    164164
     165static int device_enumerate(device_t *device)
     166{
     167        vhc_data_t *vhc = bus_to_vhc(device->bus);
     168        return usb2_bus_device_enumerate(&vhc->bus_helper, device);
     169}
     170
     171static int endpoint_register(endpoint_t *endpoint)
     172{
     173        vhc_data_t *vhc = bus_to_vhc(endpoint->device->bus);
     174        return usb2_bus_endpoint_register(&vhc->bus_helper, endpoint);
     175}
     176
     177static void endpoint_unregister(endpoint_t *endpoint)
     178{
     179        vhc_data_t *vhc = bus_to_vhc(endpoint->device->bus);
     180        usb2_bus_endpoint_unregister(&vhc->bus_helper, endpoint);
     181
     182        // TODO: abort transfer?
     183}
     184
    165185static const bus_ops_t vhc_bus_ops = {
    166         .parent = &usb2_bus_ops,
    167 
    168186        .batch_create = batch_create,
    169187        .batch_schedule = vhc_schedule,
     188
     189        .device_enumerate = device_enumerate,
     190        .endpoint_register = endpoint_register,
     191        .endpoint_unregister = endpoint_unregister,
    170192};
    171193
     
    175197        list_initialize(&instance->devices);
    176198        fibril_mutex_initialize(&instance->guard);
    177         usb2_bus_init(&instance->bus, &bandwidth_accounting_usb11);
    178         instance->bus.base.ops = &vhc_bus_ops;
     199        bus_init(&instance->bus, sizeof(device_t));
     200        usb2_bus_helper_init(&instance->bus_helper, &bandwidth_accounting_usb11);
     201        instance->bus.ops = &vhc_bus_ops;
    179202        return virthub_init(&instance->hub, "root hub");
    180203}
  • uspace/drv/bus/usb/vhc/vhcd.h

    rb357377 rd369b3b  
    6060        hc_device_t base;
    6161
    62         usb2_bus_t bus;
     62        bus_t bus;
     63        usb2_bus_helper_t bus_helper;
     64
    6365        ddf_fun_t *virtual_fun;
    6466        list_t devices;
Note: See TracChangeset for help on using the changeset viewer.