Ignore:
Timestamp:
2017-06-22T21:34:39Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
91ca111
Parents:
cb89430
Message:

usbhost: refactor the initialization

Before that, drivers had to setup MMIO range multiple times, or even parse hw
resources themselves again. The former init method was split in half - init and
start. Init shall allocate and initialize inner structures, start shall start
the HC.

In the XHCI it is demonstrated how to isolate inner HC implementation from the
fact this driver is using libusbhost. It adds some boilerplate code, but
I think it leads to cleaner design.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/ddf_helpers.h

    rcb89430 re4d7363  
    4545#include <device/hw_res_parsed.h>
    4646
    47 typedef int (*driver_init_t)(hcd_t *, const hw_res_list_parsed_t *, bool);
     47typedef int (*driver_init_t)(hcd_t *, const hw_res_list_parsed_t *);
     48typedef int (*irq_code_gen_t)(irq_code_t *, hcd_t *, const hw_res_list_parsed_t *);
     49typedef int (*claim_t)(hcd_t *, ddf_dev_t *);
     50typedef int (*driver_start_t)(hcd_t *, bool irq);
     51
     52typedef void (*driver_stop_t)(hcd_t *);
    4853typedef void (*driver_fini_t)(hcd_t *);
    49 typedef int (*claim_t)(ddf_dev_t *);
    50 typedef int (*irq_code_gen_t)(irq_code_t *, const hw_res_list_parsed_t *);
    5154
     55/**
     56 * All callbacks are optional.
     57 */
    5258typedef struct {
    5359        hcd_ops_t ops;
    54         claim_t claim;
    5560        usb_speed_t hc_speed;
    56         driver_init_t init;
    57         driver_fini_t fini;
    58         interrupt_handler_t *irq_handler;
    59         irq_code_gen_t irq_code_gen;
    6061        const char *name;
     62
     63        interrupt_handler_t *irq_handler;  /**< Handler of IRQ. Do have generic implementation. */
     64
     65        /* Initialization sequence: */
     66        driver_init_t init;                /**< Initialize internal structures, memory */
     67        claim_t claim;                     /**< Claim device from BIOS */
     68        irq_code_gen_t irq_code_gen;       /**< Generate IRQ handling code */
     69        driver_start_t start;              /**< Start the HC */
     70
     71        /* Destruction sequence: */
     72        driver_stop_t stop;                /**< Stop the HC (counterpart of start) */
     73        driver_fini_t fini;                /**< Destroy internal structures (counterpart of init) */
    6174} ddf_hc_driver_t;
    6275
     
    7588    const hw_res_list_parsed_t *hw_res,
    7689    interrupt_handler_t handler,
    77     int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *));
     90    irq_code_gen_t gen_irq_code);
    7891void ddf_hcd_gen_irq_handler(ipc_callid_t iid, ipc_call_t *call, ddf_dev_t *dev);
    7992
Note: See TracChangeset for help on using the changeset viewer.