Ticket #57: 2010-10-01-multiclass-driver.diff

File 2010-10-01-multiclass-driver.diff, 64.4 KB (added by Nicolas Pouillon, 14 years ago)

PoC

  • drivers/timer/soclib/timer-soclib.c

     
    157157
    158158const struct driver_s   timer_soclib_drv =
    159159{
    160   .class                = device_class_timer,
     160  .funcs_offset = {
     161    [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE,
     162    [device_class_timer] = 0,
     163  },
    161164  .id_table             = timer_soclib_ids,
    162165  .f_init               = timer_soclib_init,
    163166  .f_cleanup            = timer_soclib_cleanup,
    164167  .f_irq                = timer_soclib_irq,
    165   .f.timer = {
    166     .f_setcallback      = timer_soclib_setcallback,
    167     .f_setperiod        = timer_soclib_setperiod,
    168     .f_setvalue         = timer_soclib_setvalue,
    169     .f_getvalue         = timer_soclib_getvalue,
    170   }
     168  .funcs = {
     169    {
     170      .timer = {
     171        .f_setcallback  = timer_soclib_setcallback,
     172        .f_setperiod    = timer_soclib_setperiod,
     173        .f_setvalue             = timer_soclib_setvalue,
     174        .f_getvalue             = timer_soclib_getvalue,
     175      },
     176    },
     177  },
    171178};
    172179
    173180REGISTER_DRIVER(timer_soclib_drv);
  • drivers/icu/soclib-xicu/xicu-soclib.c

     
    216216
    217217const struct driver_s   xicu_root_drv =
    218218{
    219         .class           = device_class_timer,
     219    .funcs_offset = {
     220        [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE,
     221        [device_class_timer] = 0,
     222    },
    220223        .id_table        = xicu_root_ids,
    221224        .f_init          = xicu_root_init,
    222225        .f_cleanup       = xicu_root_cleanup,
    223         .f.timer = {
    224                 .f_setcallback  = xicu_timer_setcallback,
    225                 .f_setperiod    = xicu_timer_setperiod,
    226                 .f_setvalue             = xicu_timer_setvalue,
    227                 .f_getvalue             = xicu_timer_getvalue,
    228         }
     226    .funcs = {
     227        {
     228            .timer = {
     229                .f_setcallback  = xicu_timer_setcallback,
     230                .f_setperiod    = xicu_timer_setperiod,
     231                .f_setvalue             = xicu_timer_setvalue,
     232                .f_getvalue             = xicu_timer_getvalue,
     233            },
     234        },
     235    },
    229236};
    230237
    231238REGISTER_DRIVER(xicu_root_drv);
  • drivers/icu/soclib-xicu/xicu-soclib-filter.c

     
    127127
    128128const struct driver_s   xicu_filter_drv =
    129129{
    130         .class           = device_class_icu,
     130    .funcs_offset = {
     131        [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE,
     132        [device_class_icu] = 0,
     133    },
    131134        .id_table        = xicu_filter_ids,
    132135        .f_irq           = xicu_filter_handler,
    133136        .f_init          = xicu_filter_init,
    134137        .f_cleanup       = xicu_filter_cleanup,
    135         .f.icu = {
    136                 .f_enable    = xicu_filter_enable,
    137                 .f_sethndl   = xicu_filter_sethndl,
    138                 .f_delhndl   = xicu_filter_delhndl,
     138    .funcs = {
     139        {
     140            .icu = {
     141                .f_enable    = xicu_filter_enable,
     142                .f_sethndl   = xicu_filter_sethndl,
     143                .f_delhndl   = xicu_filter_delhndl,
    139144#ifdef CONFIG_HEXO_IPI
    140                 .f_sendipi   = xicu_filter_sendipi,
    141                 .f_setup_ipi_ep  = xicu_filter_setup_ipi_ep,
     145                .f_sendipi   = xicu_filter_sendipi,
     146                .f_setup_ipi_ep  = xicu_filter_setup_ipi_ep,
    142147#endif
    143         }
     148            },
     149        },
     150    },
    144151};
    145152
    146153REGISTER_DRIVER(xicu_filter_drv);
  • drivers/icu/mips/icu-mips.c

     
    135135
    136136const struct driver_s   icu_mips_drv =
    137137{
    138         .class          = device_class_icu,
     138    .funcs_offset = {
     139        [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE,
     140        [device_class_icu] = 0,
     141    },
    139142    .id_table   = icu_mips_ids,
    140143        .f_init         = icu_mips_init,
    141144        .f_irq      = (dev_irq_t *)icu_mips_handler,
    142145        .f_cleanup              = icu_mips_cleanup,
    143         .f.icu = {
    144                 .f_enable               = icu_mips_enable,
    145                 .f_sethndl              = icu_mips_sethndl,
    146                 .f_delhndl              = icu_mips_delhndl,
    147         }
     146    .funcs = {
     147        {
     148            .icu = {
     149                .f_enable               = icu_mips_enable,
     150                .f_sethndl              = icu_mips_sethndl,
     151                .f_delhndl              = icu_mips_delhndl,
     152            },
     153        },
     154    },
    148155};
    149156
    150157REGISTER_DRIVER(icu_mips_drv);
  • drivers/icu/soclib-icu/icu-soclib.c

     
    9494
    9595const struct driver_s   icu_soclib_drv =
    9696{
    97   .class                = device_class_icu,
     97  .funcs_offset = {
     98    [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE,
     99    [device_class_icu] = 0,
     100  },
    98101  .id_table             = icu_soclib_ids,
    99102  .f_init               = icu_soclib_init,
    100103  .f_cleanup            = icu_soclib_cleanup,
    101104  .f_irq            = icu_soclib_handler,
    102   .f.icu = {
    103     .f_enable           = icu_soclib_enable,
    104     .f_sethndl          = icu_soclib_sethndl,
    105     .f_delhndl          = icu_soclib_delhndl,
    106   }
     105  .funcs = {
     106    {
     107      .icu = {
     108        .f_enable               = icu_soclib_enable,
     109        .f_sethndl              = icu_soclib_sethndl,
     110        .f_delhndl              = icu_soclib_delhndl,
     111      },
     112    },
     113  },
    107114};
    108115
    109116REGISTER_DRIVER(icu_soclib_drv);
  • drivers/drivers.config

     
    1111  default defined
    1212%config end
    1313
     14%config CONFIG_DRIVER_MULTICLASS
     15  parent CONFIG_DEVICE
     16  desc Support more than one class in a driver at the same time
     17  default defined
     18%config end
     19
    1420%config CONFIG_DRIVER_CHAR
    1521  parent CONFIG_DEVICE
    1622  flags meta
  • drivers/include/device/block.h

     
    2323 * @file
    2424 * @module{Device drivers}
    2525 * @short Block device driver API
    26  */                                                                 
     26 */
    2727
    2828#ifndef __DEVICE_BLOCK_H__
    2929#define __DEVICE_BLOCK_H__
    3030
    31 #ifdef __DRIVER_H__
    32 # error This header must not be included after "device/driver.h"
    33 #endif
    34 
    3531#include <hexo/types.h>
    3632#include <hexo/error.h>
    3733#include <hexo/gpct_platform_hexo.h>
    3834#include <gpct/cont_clist.h>
    3935
     36#include <device/driver_fw.h>
     37
    4038struct device_s;
    4139struct driver_s;
    4240
     
    7876    required by the driver. */
    7977
    8078struct dev_block_rq_s
    81 { 
     79{
    8280  CONTAINER_ENTRY_TYPE(CLIST)   queue_entry;
    8381
    8482  enum dev_block_rq_type_e      type;    //< request type and flags
     
    10098#define DEVBLOCK_REQUEST(n)     void (n) (struct device_s *dev, \
    10199                                          struct dev_block_rq_s *rq)
    102100
    103 /** Block device class request() methode shortcut */
    104 
    105 #define dev_block_request(dev, ...) (dev)->drv->f.blk.f_request(dev, __VA_ARGS__ )
    106101/**
    107102   Block device request function type. Request count data blocks
    108103   from the device.
     
    128123/** Block device class getparams() function tempate. */
    129124#define DEVBLOCK_GETPARAMS(n)   const struct dev_block_params_s * (n) (struct device_s *dev)
    130125
    131 /** Block device class getparams() methode shortcut */
    132 
    133 #define dev_block_getparams(dev) (dev)->drv->f.blk.f_getparams(dev)
    134 
    135126/**
    136127   Block device getparams function type.
    137128
     
    147138/** Block device class getrqsize() function tempate. */
    148139#define DEVBLOCK_GETRQSIZE(n)   size_t (n) (struct device_s *dev)
    149140
    150 /** Block device class getrqsize() methode shortcut */
    151 
    152 #define dev_block_getrqsize(dev) (dev)->drv->f.blk.f_getrqsize(dev)
    153 
    154141/**
    155142   Block device getrqsize function type.
    156143
     
    171158};
    172159
    173160
     161
     162/** Block device class request() methode shortcut */
     163static inline
     164void dev_block_request(struct device_s *dev, struct dev_block_rq_s *rq)
     165{
     166    const struct dev_class_block_s *funcs =
     167        driver_class_funcs(dev->drv, device_class_block);
     168
     169    return funcs->f_request(dev, rq);
     170}
     171
     172/** Block device class getparams() methode shortcut */
     173static inline
     174const struct dev_block_params_s *dev_block_getparams(struct device_s *dev)
     175{
     176    const struct dev_class_block_s *funcs =
     177        driver_class_funcs(dev->drv, device_class_block);
     178
     179    return funcs->f_getparams(dev);
     180}
     181
     182/** Block device class getrqsize() methode shortcut */
     183static inline
     184size_t dev_block_getrqsize(struct device_s *dev)
     185{
     186    const struct dev_class_block_s *funcs =
     187        driver_class_funcs(dev->drv, device_class_block);
     188
     189    return funcs->f_getrqsize(dev);
     190}
     191
    174192/** Synchronous helper read function. This function use the scheduler
    175193    api to put current context in wait state if no data is available
    176194    from device yet. This function is equivalent to
  • drivers/include/device/spi.h

     
    2828#ifndef __DEVICE_SPI_H__
    2929#define __DEVICE_SPI_H__
    3030
    31 #ifdef __DRIVER_H__
    32 # error This header must not be included after "device/driver.h"
    33 #endif
    34 
    3531#include <hexo/types.h>
    3632#include <hexo/error.h>
    3733#include <hexo/gpct_platform_hexo.h>
    3834#include <gpct/cont_clist.h>
    3935
     36#include <device/driver_fw.h>
     37
    4038struct device_s;
    4139struct driver_s;
    4240struct dev_spi_rq_s;
     
    249247/** Spi device class request() function tempate. */
    250248#define DEVSPI_REQUEST(n)       void  (n) (struct device_s *dev, struct dev_spi_rq_s *rq)
    251249
    252 /** Spi device class request() methode shortcut */
    253 #define dev_spi_request(dev, ...) (dev)->drv->f.spi.f_request(dev, __VA_ARGS__ )
    254 
    255250/**
    256251   Spi device class request() function type. Enqueue a request.
    257252
     
    264259/** Spi device class set_baudrate() function tempate. */
    265260#define DEVSPI_SET_BAUDRATE(n)  uint32_t  (n) (struct device_s *dev, uint_fast8_t device_id, uint32_t br, uint_fast8_t xfer_delay, uint_fast8_t cs_delay)
    266261
    267 /** Spi device class request() methode shortcut */
    268 #define dev_spi_set_baudrate(dev, ...) (dev)->drv->f.spi.f_set_baudrate(dev, __VA_ARGS__ )
    269 
    270262/**
    271263   Spi device class set_baudrate() function type. Change clock for device id.
    272264
     
    297289                bool_t keep_cs_active                                                                                   \
    298290                )
    299291
    300 /** Spi device class request() methode shortcut */
    301 #define dev_spi_set_data_format(dev, ...) (dev)->drv->f.spi.f_set_data_format(dev, __VA_ARGS__ )
    302 
    303292/**
    304293   Spi device class set_data_format() function type. Change communication protocol.
    305294
     
    320309  devspi_set_data_format_t              *f_set_data_format;
    321310};
    322311
     312/** Spi device class request() methode shortcut */
     313static inline
     314void  dev_spi_request (struct device_s *dev, struct dev_spi_rq_s *rq)
     315{
     316    const struct dev_class_spi_s *funcs =
     317        driver_class_funcs(dev->drv, device_class_spi);
     318
     319    return funcs->f_request(dev, rq);
     320}
     321
     322/** Spi device class request() methode shortcut */
     323static inline
     324uint32_t  dev_spi_set_baudrate (struct device_s *dev,
     325                                uint_fast8_t device_id, uint32_t br,
     326                                uint_fast8_t xfer_delay, uint_fast8_t cs_delay)
     327{
     328    const struct dev_class_spi_s *funcs =
     329        driver_class_funcs(dev->drv, device_class_spi);
     330
     331    return funcs->f_set_baudrate(dev, device_id, br, xfer_delay, cs_delay);
     332}
     333
     334/** Spi device class request() methode shortcut */
     335static inline
     336error_t  dev_spi_set_data_format (
     337    struct device_s *dev,
     338    uint_fast8_t device_id,
     339    uint_fast8_t bits_per_word,
     340    enum spi_mode_e spi_mode,
     341    bool_t keep_cs_active
     342    )
     343{
     344    const struct dev_class_spi_s *funcs =
     345        driver_class_funcs(dev->drv, device_class_spi);
     346
     347    return funcs->f_set_data_format(dev, device_id, bits_per_word, spi_mode, keep_cs_active);
     348}
     349
     350
    323351#endif
    324352
  • drivers/include/device/driver.h

     
    3232#include <hexo/error.h>
    3333#include <device/device.h>
    3434
     35/* Forward declaration of type in device/driver_binder.h */
     36struct devenum_ident_s;
    3537
    36 #define PARAM_DATATYPE_INT 1
    37 #define PARAM_DATATYPE_DEVICE_PTR 2
    38 #define PARAM_DATATYPE_ADDR 3
    39 #define PARAM_DATATYPE_BOOL 4
    40 
    41 /**
    42    A link from a device property and a field in the parameter
    43    structure of a driver init()
    44  */
    45 struct driver_param_binder_s
    46 {
    47         const char *param_name;
    48         uint16_t struct_offset;
    49         uint8_t datatype;
    50         uint8_t datalen;
    51 };
    52 
    53 /**
    54    Helper macro to create an entry in a struct driver_param_binder_s
    55 
    56    @param _struct_type full type name of the parameter structure type
    57    @param _struct_entry field name in the parameter structure
    58    @param _datatype type of the data chosen in the PARAM_DATATYPE_*
    59  */
    60 #define PARAM_BIND(_struct_type, _struct_entry, _datatype)                          \
    61         {                                                                                                                                       \
    62                 .param_name = #_struct_entry,                                                                   \
    63                 .struct_offset = __builtin_offsetof(_struct_type, _struct_entry), \
    64                 .datatype = _datatype,                                                                              \
    65                 .datalen = sizeof(((_struct_type *)0)->_struct_entry),              \
    66         }
    67 
    68 #define DEVENUM_TYPE_PCI 0x01
    69 #define DEVENUM_TYPE_ISA 0x02
    70 #define DEVENUM_TYPE_ATA 0x03
    71 #define DEVENUM_TYPE_FDTNAME 0x04
    72 
    73 /** device structure identification informations. wildcard values are
    74     enum driver dependent */
    75 struct devenum_ident_s
    76 {
    77         uint8_t type;
    78         union {
    79                 struct {
    80                         uint16_t vendor;
    81                         uint16_t device;
    82                         uint32_t class;
    83                 } pci;
    84                 struct {
    85                         uint16_t vendor;
    86                 } isa;
    87                 struct {
    88                         const char *name;
    89                         size_t param_size;
    90                         const struct driver_param_binder_s *binder;
    91                 } fdtname;
    92                 struct {
    93                         const char *str;
    94                 } ata;
    95         };
    96 };
    97 
    98 
    99 /**
    100    Shortcut for creating a PCI entry in a static devenum_ident_s
    101    array.
    102 
    103    @param _vendor the vendor id to match, -1 for wildcard
    104    @param _device the device id to match, -1 for wildcard
    105    @param _class the class to match, -1 for wildcard
    106  */
    107 #define DEVENUM_PCI_ENTRY(_vendor, _device, _class)             \
    108         { .type = DEVENUM_TYPE_PCI, { .pci = {                          \
    109                                 .vendor = _vendor, .device = _device,   \
    110                                 .class = _class } } }
    111 
    112 /**
    113    Shortcut for creating an ISA entry in a static devenum_ident_s
    114    array.
    115 
    116    @param _vendor the vendor id to match
    117  */
    118 #define DEVENUM_ISA_ENTRY(_vendor)                                              \
    119         { .type = DEVENUM_TYPE_PCI, { .isa = {                          \
    120                                 .vendor = _vendor } } }
    121 
    122 /**
    123    Shortcut for creating an ATA entry in a static devenum_ident_s
    124    array.
    125 
    126    @param _str the string to match from the device
    127  */
    128 #define DEVENUM_ATA_ENTRY(_str)                                                 \
    129         { .type = DEVENUM_TYPE_ATA, { .ata = {                          \
    130                                 .str = _str } } }
    131 
    132 /**
    133    Shortcut for creating a flat-device-tree entry in a static
    134    devenum_ident_s array.
    135 
    136    @param _name The string to match from the device-tree
    137    @param _binder The data binder table pointer for the fdt to param conversion
    138  */
    139 #define DEVENUM_FDTNAME_ENTRY(_name, _psize, _binder)   \
    140         { .type = DEVENUM_TYPE_FDTNAME, { .fdtname = {          \
    141                                 .name = _name, .param_size = _psize,    \
    142                                 .binder = _binder } } }
    143 
    144 
    14538/** device driver object structure */
    14639
    147 #define DRV_MAX_FUNC_COUNT      6
     40#define DRV_MAX_FUNC_COUNT  6
    14841
    149 struct driver_s
     42union driver_func_s
    15043{
    151   /* device class */
    152   enum device_class_e           class;
    153 
    154   /* device identifier table for detection (optional) */
    155   const struct devenum_ident_s  *id_table;
    156 
    157   dev_create_t                  *f_create;
    158   dev_init_t                    *f_init;
    159   dev_cleanup_t                 *f_cleanup;
    160   dev_irq_t                     *f_irq;
    161 
    162   union {
    163     void                        *ptrs[DRV_MAX_FUNC_COUNT];
    164 
     44    void *ptrs[DRV_MAX_FUNC_COUNT];
    16545#ifdef __DEVICE_CHAR_H__
    166     struct dev_class_char_s     chr;
     46    struct dev_class_char_s chr;
    16747#endif
    168 
    16948#ifdef __DEVICE_ICU_H__
    170     /** interrupt controller devices */
    171     struct dev_class_icu_s      icu;
     49    struct dev_class_icu_s icu;
    17250#endif
    173 
    17451#ifdef __DEVICE_FB_H__
    175     /** frame buffer devices */
    176     struct dev_class_fb_s       fb;
     52    struct dev_class_fb_s fb;
    17753#endif
    178 
    17954#ifdef __DEVICE_TIMER_H__
    180     struct dev_class_timer_s    timer;
     55    struct dev_class_timer_s timer;
    18156#endif
    182 
    18357#ifdef __DEVICE_INPUT_H__
    184     struct dev_class_input_s    input;
     58    struct dev_class_input_s input;
    18559#endif
    186 
    18760#ifdef __DEVICE_ENUM_H__
    188     /** device enumerator class */
    189     struct dev_class_enum_s     denum;
     61    struct dev_class_enum_s denum;
    19062#endif
    191 
    19263#ifdef __DEVICE_NET_H__
    193     struct dev_class_net_s      net;
     64    struct dev_class_net_s net;
    19465#endif
    195 
    19666#ifdef __DEVICE_SOUND_H__
    197     struct dev_class_sound_s    sound;
     67    struct dev_class_sound_s sound;
    19868#endif
    199 
    20069#ifdef __DEVICE_BLOCK_H__
    201     struct dev_class_block_s    blk;
     70    struct dev_class_block_s blk;
    20271#endif
    203 
    20472#ifdef __DEVICE_SPI_H__
    205     struct dev_class_spi_s      spi;
     73    struct dev_class_spi_s spi;
    20674#endif
    207 
    20875#ifdef __DEVICE_LCD_H__
    209     struct dev_class_lcd_s      lcd;
     76    struct dev_class_lcd_s lcd;
    21077#endif
    211 
    21278#ifdef __DEVICE_GPIO_H__
    213     struct dev_class_gpio_s     gpio;
     79    struct dev_class_gpio_s gpio;
    21480#endif
    215 
    21681#ifdef __DEVICE_I2C_H__
    217     struct dev_class_i2c_s      i2c;
     82    struct dev_class_i2c_s i2c;
    21883#endif
    219 
    22084#ifdef __DEVICE_MEM_H__
    221     struct dev_class_mem_s      mem;
     85    struct dev_class_mem_s mem;
    22286#endif
    223   } f;
    22487};
    22588
    226 /**
    227    Registers a driver (struct driver_s) in the global_driver_registry
    228    table.
    229  */
    230 #if defined(CONFIG_ARCH_EMU_DARWIN)
    231 #define REGISTER_DRIVER(name) \
    232         const __attribute__((section ("__DATA, __drivers"))) \
    233         const struct driver_s *name##_drv_ptr = &name
    234 #else
    235 #define REGISTER_DRIVER(name) \
    236         const __attribute__((section (".drivers"))) \
    237         const struct driver_s *name##_drv_ptr = &name
    238 #endif
     89struct driver_s
     90{
     91    /** device identifier table for detection (optional) */
     92    const struct devenum_ident_s *id_table;
    23993
    240 /**
    241    Try to get a driver registered with these characteristics
     94    dev_create_t   *f_create;
     95    dev_init_t     *f_init;
     96    dev_cleanup_t  *f_cleanup;
     97    dev_irq_t      *f_irq;
    24298
    243    @param vendor Vendor of PCI device
    244    @param vendor Device of PCI device
    245    @param vendor Class of PCI device
    246    @return A driver if found, NULL otherwise
    247  */
    248 const struct driver_s *driver_get_matching_pci(
    249         uint16_t vendor,
    250         uint16_t device,
    251         uint32_t class);
     99#if defined(CONFIG_DRIVER_MULTICLASS)
     100    uint8_t funcs_offset[DEVICE_CLASS_COUNT];
     101#endif
    252102
    253 /**
    254    Try to get a driver registered with these characteristics
     103    union driver_func_s funcs[];
     104};
    255105
    256    @param vendor Vendor of ISA device
    257    @return A driver if found, NULL otherwise
    258  */
    259 const struct driver_s *driver_get_matching_isa(
    260         uint16_t vendor);
     106static inline
     107const void *driver_class_funcs(
     108    const struct driver_s *drv,
     109    enum device_class_e class)
     110{
     111#if defined(CONFIG_DRIVER_MULTICLASS)
     112    const uint8_t offset = drv->funcs_offset[class];
    261113
    262 /**
    263    Try to get a driver registered with these characteristics
     114    assert(offset != DEVICE_CLASS_UNAVAILABLE);
     115#else
     116    const uint8_t offset = 0;
     117#endif
    264118
    265    @param name Name of ata device
    266    @return A driver if found, NULL otherwise
    267  */
    268 const struct driver_s *driver_get_matching_ata(
    269         const char *name);
     119    return &drv->funcs[offset];
     120}
    270121
    271 /**
    272    Try to get a driver registered with these characteristics
     122#include <device/driver_binder.h>
    273123
    274    @param name Name of device_type in the FDT
    275    @return A driver if found, NULL otherwise
    276  */
    277 const struct driver_s *driver_get_matching_fdtname(
    278         const char *name);
    279 
    280124#endif
  • drivers/include/device/gpio.h

     
    2828#ifndef __DEVICE_GPIO_H__
    2929#define __DEVICE_GPIO_H__
    3030
    31 #ifdef __DRIVER_H__
    32 # error This header must not be included after "device/driver.h"
    33 #endif
    34 
    3531#include <hexo/types.h>
    3632#include <hexo/error.h>
    3733#include <hexo/gpct_platform_hexo.h>
    3834#include <gpct/cont_clist.h>
    3935
     36#include <device/driver_fw.h>
     37
    4038struct device_s;
    4139struct driver_s;
    4240
     
    6765 */
    6866typedef DEVGPIO_SET_WAY(devgpio_set_way_t);
    6967
    70 /** Gpio device class set_way() methode shortcut */
    71 #define dev_gpio_set_way(dev, ...) (dev)->drv->f.gpio.f_set_way(dev, __VA_ARGS__ )
    7268
    73 
    7469/** Gpio device class set_value() function tempate. */
    7570#define DEVGPIO_SET_VALUE(n)    error_t  (n) (struct device_s *dev,             \
    7671                                                                                          devgpio_id_t gpio,                    \
     
    8984 */
    9085typedef DEVGPIO_SET_VALUE(devgpio_set_value_t);
    9186
    92 /** Gpio device class set_value() methode shortcut */
    93 #define dev_gpio_set_value(dev, ...) (dev)->drv->f.gpio.f_set_value(dev, __VA_ARGS__ )
    9487
    95 
    9688/** Gpio device class set_pullup() function tempate. */
    9789#define DEVGPIO_SET_PULLUP(n)   error_t  (n) (struct device_s *dev,             \
    9890                                                                                          devgpio_id_t gpio,                    \
     
    111103 */
    112104typedef DEVGPIO_SET_PULLUP(devgpio_set_pullup_t);
    113105
    114 /** Gpio device class set_pullup() methode shortcut */
    115 #define dev_gpio_set_pullup(dev, ...) (dev)->drv->f.gpio.f_set_pullup(dev, __VA_ARGS__ )
    116106
    117 
    118107/** Gpio device class assign_to_peripheral() function tempate. */
    119108#define DEVGPIO_ASSIGN_TO_PERIPHERAL(n) error_t  (n) (struct device_s *dev,     \
    120109                                                                                                          devgpio_id_t gpio,    \
     
    135124 */
    136125typedef DEVGPIO_ASSIGN_TO_PERIPHERAL(devgpio_assign_to_peripheral_t);
    137126
    138 /** Gpio device class assign_to_peripheral() methode shortcut */
    139 #define dev_gpio_assign_to_peripheral(dev, ...) (dev)->drv->f.gpio.f_assign_to_peripheral(dev, __VA_ARGS__ )
    140127
    141 
    142128/** Gpio device class get_value() function tempate. */
    143129#define DEVGPIO_GET_VALUE(n)    bool_t  (n) (struct device_s *dev,         \
    144130                                                                                         devgpio_id_t gpio)
     
    154140 */
    155141typedef DEVGPIO_GET_VALUE(devgpio_get_value_t);
    156142
    157 /** Gpio device class get_value() methode shortcut */
    158 #define dev_gpio_get_value(dev, ...) (dev)->drv->f.gpio.f_get_value(dev, __VA_ARGS__ )
    159143
    160 
    161144enum devgpio_event_e
    162145{
    163146        GPIO_EDGE_RAISING,
     
    207190 */
    208191typedef DEVGPIO_REGISTER_IRQ(devgpio_register_irq_t);
    209192
    210 /** Gpio device class register_irq() methode shortcut */
    211 #define dev_gpio_register_irq(dev, ...) (dev)->drv->f.gpio.f_register_irq(dev, __VA_ARGS__ )
    212193
    213194
    214 
    215195/** Gpio device class methodes */
    216196struct dev_class_gpio_s
    217197{
     
    223203  devgpio_register_irq_t        *f_register_irq;
    224204};
    225205
     206
     207/** Gpio device class set_way() methode shortcut */
     208static inline
     209error_t dev_gpio_set_way(struct device_s *dev,
     210                         devgpio_id_t gpio,
     211                         gpio devgpio_way_e way)
     212{
     213    const struct dev_class_gpio_s *funcs =
     214        driver_class_funcs(dev->drv, device_class_gpio);
     215
     216    return funcs->f_set_way(dev, gpio, way);
     217}
     218
     219/** Gpio device class set_value() methode shortcut */
     220static inline
     221error_t  dev_gpio_set_value(struct device_s *dev,
     222                            devgpio_id_t gpio,
     223                            bool_t value)
     224{
     225    const struct dev_class_gpio_s *funcs =
     226        driver_class_funcs(dev->drv, device_class_gpio);
     227
     228    return funcs->f_set_value(dev, gpio, value);
     229}
     230
     231/** Gpio device class set_pullup() methode shortcut */
     232static inline
     233error_t  dev_gpio_set_pullup(struct device_s *dev,
     234                             devgpio_id_t gpio,
     235                             bool_t pullup)
     236{
     237    const struct dev_class_gpio_s *funcs =
     238        driver_class_funcs(dev->drv, device_class_gpio);
     239
     240    return funcs->f_set_pullup(dev, gpio, pullup);
     241}
     242
     243/** Gpio device class assign_to_peripheral() methode shortcut */
     244static inline
     245error_t  dev_gpio_assign_to_peripheral(struct device_s *dev,
     246                                       devgpio_id_t gpio,
     247                                       uint_fast8_t device_id)
     248{
     249    const struct dev_class_gpio_s *funcs =
     250        driver_class_funcs(dev->drv, device_class_gpio);
     251
     252    return funcs->f_assign_to_peripheral(dev, gpio, device_id);
     253}
     254
     255/** Gpio device class get_value() methode shortcut */
     256static inline
     257bool_t  dev_gpio_get_value(struct device_s *dev,
     258                           devgpio_id_t gpio)
     259{
     260    const struct dev_class_gpio_s *funcs =
     261        driver_class_funcs(dev->drv, device_class_gpio);
     262
     263    return funcs->f_get_value(dev, gpio);
     264}
     265
     266/** Gpio device class register_irq() methode shortcut */
     267static inline
     268error_t dev_gpio_register_irq(struct device_s *dev,
     269                              devgpio_id_t gpio,
     270                              enum devgpio_event_e event,
     271                              devgpio_irq_t *callback,
     272                              void *private_data)
     273{
     274    const struct dev_class_gpio_s *funcs =
     275        driver_class_funcs(dev->drv, device_class_gpio);
     276
     277    return funcs->f_register_irq(dev, gpio, event, callback, private_data);
     278}
     279
    226280#endif
    227281
  • drivers/include/device/input.h

     
    2828#ifndef __DEVICE_INPUT_H__
    2929#define __DEVICE_INPUT_H__
    3030
    31 #ifdef __DRIVER_H__
    32 # error This header must not be included after "device/driver.h"
    33 #endif
    34 
    3531#include <hexo/types.h>
    3632#include <hexo/error.h>
    3733
     34#include <device/driver_fw.h>
     35
    3836struct device_s;
    3937struct driver_s;
    4038
     
    6866#define DEVINPUT_INFO(n)        void  (n) (struct device_s *dev,                \
    6967                                           struct devinput_info_s *info)
    7068
    71 #define dev_input_info(dev, ...) (dev)->drv->f.input.f_info(dev, __VA_ARGS__ )
    7269/**
    7370   Input device class info() function type. This function get
    7471   informations about available controles.
     
    8380#define DEVINPUT_READ(n)        devinput_value_t (n) (struct device_s *dev,     \
    8481                                                      devinput_ctrlid_t id)
    8582
    86 #define dev_input_read(dev, ...) (dev)->drv->f.input.f_read(dev, __VA_ARGS__ )
    8783/**
    8884   Input device class read() function type. This function read control
    8985   current value.
     
    10096                                             devinput_ctrlid_t id,      \
    10197                                             devinput_value_t value)
    10298
    103 #define dev_input_write(dev, ...) (dev)->drv->f.input.f_write(dev, __VA_ARGS__ )
    10499/**
    105100   Input device class write() function type. This function set control
    106101   current value.
     
    120115                                             devinput_callback_t *callback,     \
    121116                                             void *priv)
    122117
    123 #define dev_input_setcallback(dev, ...) (dev)->drv->f.input.f_setcallback(dev, __VA_ARGS__ )
    124118/**
    125119   Input device class setcallback() function type. This function set
    126120   a new event handler for a control. Special DEVINPUT_CTRLID_ALL
     
    146140  devinput_setcallback_t        *f_setcallback;
    147141};
    148142
     143static inline
     144void  dev_input_info(struct device_s *dev,
     145                     struct devinput_info_s *info)
     146{
     147    const struct dev_class_input_s *funcs =
     148        driver_class_funcs(dev->drv, device_class_input);
    149149
     150    return funcs->f_info(dev, info);
     151}
     152
     153static inline
     154devinput_value_t dev_input_read(struct device_s *dev,
     155                                devinput_ctrlid_t id)
     156{
     157    const struct dev_class_input_s *funcs =
     158        driver_class_funcs(dev->drv, device_class_input);
     159
     160    return funcs->f_read(dev, id);
     161}
     162
     163static inline
     164error_t dev_input_write(struct device_s *dev,
     165                        devinput_ctrlid_t id,
     166                        devinput_value_t value)
     167{
     168    const struct dev_class_input_s *funcs =
     169        driver_class_funcs(dev->drv, device_class_input);
     170
     171    return funcs->f_write(dev, id, value);
     172}
     173
     174static inline
     175error_t dev_input_setcallback(struct device_s *dev,
     176                              uint_fast8_t type,
     177                              devinput_ctrlid_t id,
     178                              devinput_callback_t *callback,
     179                              void *priv)
     180{
     181    const struct dev_class_input_s *funcs =
     182        driver_class_funcs(dev->drv, device_class_input);
     183
     184    return funcs->f_setcallback(dev, type, id, callback, priv);
     185}
     186
    150187#endif
    151 
  • drivers/include/device/device.h

     
    3535#include <hexo/error.h>
    3636
    3737enum device_class_e
    38   {
    39     device_class_none = 0,
    40 
    41     device_class_block,
     38{
     39#ifdef CONFIG_DRIVER_CHAR
    4240    device_class_char,
    43     device_class_enum,
     41#endif
     42#ifdef CONFIG_DRIVER_ICU
     43    device_class_icu,
     44#endif
     45#ifdef CONFIG_DRIVER_FB
    4446    device_class_fb,
    45     device_class_icu,
     47#endif
     48#ifdef CONFIG_DRIVER_TIMER
     49    device_class_timer,
     50#endif
     51#ifdef CONFIG_DRIVER_INPUT
    4652    device_class_input,
     53#endif
     54#ifdef CONFIG_DRIVER_ENUM
     55    device_class_enum,
     56#endif
     57#ifdef CONFIG_DRIVER_NET
    4758    device_class_net,
     59#endif
     60#ifdef CONFIG_DRIVER_SOUND
    4861    device_class_sound,
    49     device_class_timer,
     62#endif
     63#ifdef CONFIG_DRIVER_BLOCK
     64    device_class_block,
     65#endif
     66#ifdef CONFIG_DRIVER_SPI
    5067    device_class_spi,
     68#endif
     69#ifdef CONFIG_DRIVER_LCD
    5170    device_class_lcd,
     71#endif
     72#ifdef CONFIG_DRIVER_GPIO
    5273    device_class_gpio,
     74#endif
     75#ifdef CONFIG_DRIVER_I2C
    5376    device_class_i2c,
     77#endif
     78#ifdef CONFIG_DRIVER_MEM
    5479    device_class_mem,
    55   };
     80#endif
    5681
     82    DEVICE_CLASS_COUNT,
     83};
    5784
     85#define DEVICE_CLASS_UNAVAILABLE 0xff
     86
    5887/** Common class irq() function template. */
    5988#define DEV_IRQ(n)      bool_t (n) (struct device_s *dev)
    6089
  • drivers/include/device/lcd.h

     
    2828#ifndef __DEVICE_LCD_H__
    2929#define __DEVICE_LCD_H__
    3030
    31 #ifdef __DRIVER_H__
    32 # error This header must not be included after "device/driver.h"
    33 #endif
    34 
    3531#include <hexo/types.h>
    3632#include <hexo/error.h>
    3733#include <hexo/gpct_platform_hexo.h>
    3834#include <gpct/cont_clist.h>
    3935
     36#include <device/driver_fw.h>
     37
    4038struct device_s;
    4139struct driver_s;
    4240
     
    123121
    124122typedef DEVLCD_REQUEST(devlcd_request_t);
    125123
    126 /** Lcd device class request() methode shortcut */
    127 #define dev_lcd_request(dev, ...) (dev)->drv->f.lcd.f_request(dev, __VA_ARGS__ )
    128124
    129125
    130126
     
    140136*/
    141137typedef DEVLCD_GETINFO(devlcd_getinfo_t);
    142138
    143 /** Lcd device class getinfo() methode shortcut */
    144 #define dev_lcd_getinfo(dev) (dev)->drv->f.lcd.f_getinfo(dev)
    145139
    146140
    147141
     
    152146  devlcd_getinfo_t      *f_getinfo;
    153147};
    154148
     149/** Lcd device class request() methode shortcut */
     150static inline
     151error_t  dev_lcd_request(struct device_s *dev,
     152                         struct lcd_req_s *req)
     153{
     154    const struct dev_class_lcd_s *funcs =
     155        driver_class_funcs(dev->drv, device_class_lcd);
    155156
     157    return funcs->f_request(dev, req);
     158}
     159
     160/** Lcd device class getinfo() methode shortcut */
     161static inline
     162const struct lcd_info_s * dev_lcd_getinfo(struct device_s *dev)
     163{
     164    const struct dev_class_lcd_s *funcs =
     165        driver_class_funcs(dev->drv, device_class_lcd);
     166
     167    return funcs->f_getinfo(dev);
     168}
     169
     170
     171
    156172ssize_t dev_lcd_set_palette(struct device_s *dev, struct lcd_pal_s *palette, size_t count);
    157173
    158174/**
  • drivers/include/device/enum.h

     
    2828#ifndef __DEVICE_ENUM_H__
    2929#define __DEVICE_ENUM_H__
    3030
    31 #ifdef __DRIVER_H__
    32 # error This header must not be included after "device/driver.h"
    33 #endif
    34 
    3531#include <hexo/types.h>
    3632#include <hexo/error.h>
    3733
     34#include <device/driver_fw.h>
     35
    3836/**
    3937   Lookup function prototype macro
    4038 */
     
    5048 */
    5149typedef DEVENUM_LOOKUP(devenum_lookup_t);
    5250
    53 /**
    54    Lookup function shortcut
    55  */
    56 #define dev_enum_lookup(dev, ...) (dev)->drv->f.denum.f_lookup(dev, __VA_ARGS__)
    57 
    5851#define DEV_ENUM_MAX_PATH_LEN 32
    5952
    6053struct dev_enum_info_s
     
    8275 */
    8376typedef DEVENUM_INFO(devenum_info_t);
    8477
    85 /**
    86    Info function shortcut
    87  */
    88 #define dev_enum_info(dev, ...) (dev)->drv->f.denum.f_info(dev, __VA_ARGS__)
    89 
    9078struct dev_class_enum_s
    9179{
    9280        devenum_lookup_t *f_lookup;
    9381        devenum_info_t *f_info;
    9482};
    9583
     84/**
     85   Lookup function shortcut
     86 */
     87static inline
     88struct device_s *dev_enum_lookup(struct device_s *dev, const char *path)
     89{
     90    const struct dev_class_enum_s *funcs =
     91        driver_class_funcs(dev->drv, device_class_enum);
     92
     93    return funcs->f_lookup(dev, path);
     94}
     95
     96/**
     97   Info function shortcut
     98 */
     99static inline
     100error_t dev_enum_info(struct device_s *dev,
     101                         struct device_s *child,
     102                         struct dev_enum_info_s *info)
     103{
     104    const struct dev_class_enum_s *funcs =
     105        driver_class_funcs(dev->drv, device_class_enum);
     106
     107    return funcs->f_info(dev, child, info);
     108}
     109
    96110#endif
  • drivers/include/device/i2c.h

     
    2828#ifndef __DEVICE_I2C_H__
    2929#define __DEVICE_I2C_H__
    3030
    31 #ifdef __DRIVER_H__
    32 # error This header must not be included after "device/driver.h"
    33 #endif
    34 
    3531#include <hexo/types.h>
    3632#include <hexo/error.h>
    3733#include <hexo/gpct_platform_hexo.h>
    3834#include <gpct/cont_clist.h>
    3935
     36#include <device/driver_fw.h>
     37
    4038struct device_s;
    4139struct driver_s;
    4240struct dev_i2c_rq_s;
     
    9492/** I2c device class request() function tempate. */
    9593#define DEVI2C_REQUEST(n)       void  (n) (struct device_s *dev, struct dev_i2c_rq_s *rq)
    9694
    97 /** I2c device class request() methode shortcut */
    98 #define dev_i2c_request(dev, ...) (dev)->drv->f.i2c.f_request(dev, __VA_ARGS__ )
    99 
    10095/**
    10196   I2c device class request() function type. Enqueue a request.
    10297
     
    109104/** I2c device class set_baudrate() function tempate. */
    110105#define DEVI2C_SET_BAUDRATE(n)  uint32_t  (n) (struct device_s *dev, uint32_t br)
    111106
    112 /** I2c device class request() methode shortcut */
    113 #define dev_i2c_set_baudrate(dev, ...) (dev)->drv->f.i2c.f_set_baudrate(dev, __VA_ARGS__ )
    114 
    115107/**
    116108   I2c device class set_baudrate() function type. Change clock for device id.
    117109
     
    129121  devi2c_set_baudrate_t         *f_set_baudrate;
    130122};
    131123
     124/** I2c device class request() method shortcut */
     125static inline
     126void dev_i2c_request(struct device_s *dev, struct dev_i2c_rq_s *rq)
     127{
     128    const struct dev_class_i2c_s *funcs =
     129        driver_class_funcs(dev->drv, device_class_i2c);
    132130
     131    return funcs->i2c.f_request(dev, rq);
     132}
     133
     134/** I2c device class set_baudrate() method shortcut */
     135static inline
     136uint32_t dev_i2c_set_baudrate(struct device_s *dev, uint32_t br)
     137{
     138    const struct dev_class_i2c_s *funcs =
     139        driver_class_funcs(dev->drv, device_class_i2c);
     140
     141    return funcs->i2c.f_set_baudrate(dev, br);
     142}
     143
    133144error_t dev_i2c_wait_request(
    134145        struct device_s *dev,
    135146        struct dev_i2c_rq_s *rq);
     
    170181        return dev_i2c_wait_request(dev, &rq);
    171182}
    172183
    173 
    174184#endif
    175185
  • drivers/include/device/char.h

     
    2323 * @file
    2424 * @module{Device drivers}
    2525 * @short Character device driver API
    26  */                                                                 
     26 */
    2727
    2828#ifndef __DEVICE_CHAR_H__
    2929#define __DEVICE_CHAR_H__
    3030
    31 #ifdef __DRIVER_H__
    32 # error This header must not be included after "device/driver.h"
    33 #endif
    34 
    3531#include <hexo/types.h>
    3632#include <hexo/error.h>
    3733#include <hexo/gpct_platform_hexo.h>
    3834#include <gpct/cont_clist.h>
    3935
     36#include <device/driver_fw.h>
     37
    4038struct device_s;
    4139struct driver_s;
    4240struct dev_char_rq_s;
     
    8684/** Char device class request() function tempate. */
    8785#define DEVCHAR_REQUEST(n)      void  (n) (struct device_s *dev, struct dev_char_rq_s *rq)
    8886
    89 /** Char device class request() methode shortcut */
    90 #define dev_char_request(dev, ...) (dev)->drv->f.chr.f_request(dev, __VA_ARGS__ )
    91 
    9287/**
    9388   Char device class request() function type. Enqueue a read or write request.
    9489
     
    105100};
    106101
    107102
     103
     104/** Char device class request() methode shortcut */
     105static inline
     106void dev_char_request(struct device_s *dev, struct dev_char_rq_s *rq)
     107{
     108    const struct dev_class_char_s *funcs =
     109        driver_class_funcs(dev->drv, device_class_char);
     110
     111    return funcs->f_request(dev, rq);
     112}
     113
    108114/** Synchronous helper read function. This function uses the scheduler
    109115    api to put current context in wait state if no data is available
    110116    from device yet. This function spins in a loop waiting for read
  • drivers/include/device/mem.h

     
    2727#ifndef __DEVICE_MEM_H__
    2828#define __DEVICE_MEM_H__
    2929
    30 #ifdef __DRIVER_H__
    31 # error This header must not be included after "device/driver.h"
    32 #endif
    33 
    3430#include <hexo/types.h>
    3531#include <hexo/error.h>
    3632
     33#include <device/driver_fw.h>
     34
    3735struct device_s;
    3836struct driver_s;
    3937
     
    5149/** Mem device class get_info() function tempate. */
    5250#define DEVMEM_GET_INFO(n)      void  (n) (struct device_s *dev, struct dev_mem_info_s *info)
    5351
    54 /** Mem device class request() methode shortcut */
    55 #define dev_mem_get_info(dev, ...) (dev)->drv->f.mem.f_get_info(dev, __VA_ARGS__ )
    56 
    5752/**
    5853   Mem device class get_info() function type. Get information about a ram device.
    5954
     
    6964  devmem_get_info_t             *f_get_info;
    7065};
    7166
     67/** Mem device class get_info() methode shortcut */
     68static inline
     69void dev_mem_get_info(struct device_s *dev, struct dev_mem_info_s *info)
     70{
     71
     72    const struct dev_class_mem_s *funcs =
     73        driver_class_funcs(dev->drv, device_class_mem);
     74
     75    return funcs->f_get_info(dev, info);
     76}
     77
    7278#endif
    7379
  • drivers/include/device/driver_binder.h

     
     1/*
     2    This file is part of MutekH.
     3
     4    MutekH is free software; you can redistribute it and/or modify it
     5    under the terms of the GNU General Public License as published by
     6    the Free Software Foundation; either version 2 of the License, or
     7    (at your option) any later version.
     8
     9    MutekH is distributed in the hope that it will be useful, but
     10    WITHOUT ANY WARRANTY; without even the implied warranty of
     11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12    General Public License for more details.
     13
     14    You should have received a copy of the GNU General Public License
     15    along with MutekH; if not, write to the Free Software Foundation,
     16    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
     17
     18    Copyright (c) 2006-2010, MutekH contributors
     19*/
     20
     21/**
     22 * @file
     23 * @module{Device drivers}
     24 * @short Driver dynamic binder definitions
     25 */
     26
     27#ifndef __DRIVER_BINDER_H__
     28#define __DRIVER_BINDER_H__
     29
     30#include <hexo/types.h>
     31#include <hexo/error.h>
     32
     33#define PARAM_DATATYPE_INT 1
     34#define PARAM_DATATYPE_DEVICE_PTR 2
     35#define PARAM_DATATYPE_ADDR 3
     36#define PARAM_DATATYPE_BOOL 4
     37
     38/**
     39   A link from a device property and a field in the parameter
     40   structure of a driver init()
     41 */
     42struct driver_param_binder_s
     43{
     44        const char *param_name;
     45        uint16_t struct_offset;
     46        uint8_t datatype;
     47        uint8_t datalen;
     48};
     49
     50/**
     51   Helper macro to create an entry in a struct driver_param_binder_s
     52
     53   @param _struct_type full type name of the parameter structure type
     54   @param _struct_entry field name in the parameter structure
     55   @param _datatype type of the data chosen in the PARAM_DATATYPE_*
     56 */
     57#define PARAM_BIND(_struct_type, _struct_entry, _datatype)                          \
     58        {                                                                                                                                       \
     59                .param_name = #_struct_entry,                                                                   \
     60                .struct_offset = __builtin_offsetof(_struct_type, _struct_entry), \
     61                .datatype = _datatype,                                                                              \
     62                .datalen = sizeof(((_struct_type *)0)->_struct_entry),              \
     63        }
     64
     65#define DEVENUM_TYPE_PCI 0x01
     66#define DEVENUM_TYPE_ISA 0x02
     67#define DEVENUM_TYPE_ATA 0x03
     68#define DEVENUM_TYPE_FDTNAME 0x04
     69
     70/** device structure identification informations. wildcard values are
     71    enum driver dependent */
     72struct devenum_ident_s
     73{
     74        uint8_t type;
     75        union {
     76                struct {
     77                        uint16_t vendor;
     78                        uint16_t device;
     79                        uint32_t class;
     80                } pci;
     81                struct {
     82                        uint16_t vendor;
     83                } isa;
     84                struct {
     85                        const char *name;
     86                        size_t param_size;
     87                        const struct driver_param_binder_s *binder;
     88                } fdtname;
     89                struct {
     90                        const char *str;
     91                } ata;
     92        };
     93};
     94
     95
     96/**
     97   Shortcut for creating a PCI entry in a static devenum_ident_s
     98   array.
     99
     100   @param _vendor the vendor id to match, -1 for wildcard
     101   @param _device the device id to match, -1 for wildcard
     102   @param _class the class to match, -1 for wildcard
     103 */
     104#define DEVENUM_PCI_ENTRY(_vendor, _device, _class)             \
     105        { .type = DEVENUM_TYPE_PCI, { .pci = {                          \
     106                                .vendor = _vendor, .device = _device,   \
     107                                .class = _class } } }
     108
     109/**
     110   Shortcut for creating an ISA entry in a static devenum_ident_s
     111   array.
     112
     113   @param _vendor the vendor id to match
     114 */
     115#define DEVENUM_ISA_ENTRY(_vendor)                                              \
     116        { .type = DEVENUM_TYPE_PCI, { .isa = {                          \
     117                                .vendor = _vendor } } }
     118
     119/**
     120   Shortcut for creating an ATA entry in a static devenum_ident_s
     121   array.
     122
     123   @param _str the string to match from the device
     124 */
     125#define DEVENUM_ATA_ENTRY(_str)                                                 \
     126        { .type = DEVENUM_TYPE_ATA, { .ata = {                          \
     127                                .str = _str } } }
     128
     129/**
     130   Shortcut for creating a flat-device-tree entry in a static
     131   devenum_ident_s array.
     132
     133   @param _name The string to match from the device-tree
     134   @param _binder The data binder table pointer for the fdt to param conversion
     135 */
     136#define DEVENUM_FDTNAME_ENTRY(_name, _psize, _binder)   \
     137        { .type = DEVENUM_TYPE_FDTNAME, { .fdtname = {          \
     138                                .name = _name, .param_size = _psize,    \
     139                                .binder = _binder } } }
     140
     141
     142/**
     143   Registers a driver (struct driver_s) in the global_driver_registry
     144   table.
     145*/
     146#if defined(CONFIG_ARCH_EMU_DARWIN)
     147#define REGISTER_DRIVER(name)                                          \
     148    const __attribute__((section ("__DATA, __drivers")))               \
     149    const struct driver_s *name##_drv_ptr = &name
     150#else
     151#define REGISTER_DRIVER(name)                                          \
     152    const __attribute__((section (".drivers")))                        \
     153    const struct driver_s *name##_drv_ptr = &name
     154#endif
     155
     156/**
     157   Try to get a driver registered with these characteristics
     158
     159   @param vendor Vendor of PCI device
     160   @param vendor Device of PCI device
     161   @param vendor Class of PCI device
     162   @return A driver if found, NULL otherwise
     163*/
     164const struct driver_s *driver_get_matching_pci(
     165    uint16_t vendor,
     166    uint16_t device,
     167    uint32_t class);
     168
     169/**
     170   Try to get a driver registered with these characteristics
     171
     172   @param vendor Vendor of ISA device
     173   @return A driver if found, NULL otherwise
     174*/
     175const struct driver_s *driver_get_matching_isa(
     176    uint16_t vendor);
     177
     178/**
     179   Try to get a driver registered with these characteristics
     180
     181   @param name Name of ata device
     182   @return A driver if found, NULL otherwise
     183*/
     184const struct driver_s *driver_get_matching_ata(
     185    const char *name);
     186
     187/**
     188   Try to get a driver registered with these characteristics
     189
     190   @param name Name of device_type in the FDT
     191   @return A driver if found, NULL otherwise
     192*/
     193const struct driver_s *driver_get_matching_fdtname(
     194    const char *name);
     195
     196#endif /* __DRIVER_BINDER_H__ */
  • drivers/include/device/timer.h

    Property changes on: drivers/include/device/driver_binder.h
    ___________________________________________________________________
    Added: svn:mime-type
       + text/plain
    Added: svn:keywords
       + "Author Date Id Rev URL Revision"
    Added: svn:eol-style
       + native
    
     
    2828#ifndef __DEVICE_TIMER_H__
    2929#define __DEVICE_TIMER_H__
    3030
    31 #ifdef __DRIVER_H__
    32 # error This header must not be included after "device/driver.h"
    33 #endif
    34 
    3531#include <hexo/types.h>
    3632#include <hexo/error.h>
    3733
     34#include <device/driver_fw.h>
     35
    3836struct device_s;
    3937struct driver_s;
    4038
     
    5957    * @param priv private data passed to callback function
    6058    */
    6159typedef DEVTIMER_SETCALLBACK(devtimer_setcallback_t);
    62 /** TIMER device class setcallback() function shortcut */
    63 #define dev_timer_setcallback(dev, ...) (dev)->drv->f.timer.f_setcallback(dev, __VA_ARGS__ )
    6460
    6561
    6662
     
    7672    * @param period timer period
    7773    */
    7874typedef DEVTIMER_SETPERIOD(devtimer_setperiod_t);
    79 /** TIMER device class setperiod() function shortcut */
    80 #define dev_timer_setperiod(dev, ...) (dev)->drv->f.timer.f_setperiod(dev, __VA_ARGS__ )
    8175
    8276
    8377
     
    9286    * @param value new timer value
    9387    */
    9488typedef DEVTIMER_SETVALUE(devtimer_setvalue_t);
    95 /** TIMER device class setvalue() function shortcut */
    96 #define dev_timer_setvalue(dev, ...) (dev)->drv->f.timer.f_setvalue(dev, __VA_ARGS__ )
    9789
    9890
    9991
     
    108100    * @return current timer value
    109101    */
    110102typedef DEVTIMER_GETVALUE(devtimer_getvalue_t);
    111 /** TIMER device class getvalue() function shortcut */
    112 #define dev_timer_getvalue(dev, ...) (dev)->drv->f.timer.f_getvalue(dev, __VA_ARGS__ )
    113103
    114104
    115105
     
    123113  devtimer_setvalue_t                   *f_setvalue;
    124114};
    125115
     116/** Timer device class setcallback() function shortcut */
     117static inline
     118error_t dev_timer_setcallback(struct device_s *dev, uint_fast8_t id, devtimer_callback_t *callback, void *priv)
     119{
     120    const struct dev_class_timer_s *funcs =
     121        driver_class_funcs(dev->drv, device_class_timer);
    126122
     123    return funcs->f_setcallback(dev, id, callback, priv);
     124}
     125
     126/** Timer device class setperiod() function shortcut */
     127static inline
     128error_t dev_timer_setperiod(struct device_s *dev, uint_fast8_t id, uintmax_t period)
     129{
     130    const struct dev_class_timer_s *funcs =
     131        driver_class_funcs(dev->drv, device_class_timer);
     132
     133    return funcs->f_setperiod(dev, id, period);
     134}
     135
     136/** Timer device class setvalue() function shortcut */
     137static inline
     138error_t dev_timer_setvalue(struct device_s *dev, uint_fast8_t id, uintmax_t value)
     139{
     140    const struct dev_class_timer_s *funcs =
     141        driver_class_funcs(dev->drv, device_class_timer);
     142
     143    return funcs->f_setvalue(dev, id, value);
     144}
     145
     146/** Timer device class getvalue() function shortcut */
     147static inline
     148uintmax_t dev_timer_getvalue(struct device_s *dev, uint_fast8_t id)
     149{
     150    const struct dev_class_timer_s *funcs =
     151        driver_class_funcs(dev->drv, device_class_timer);
     152
     153    return funcs->f_getvalue(dev, id);
     154}
     155
    127156#endif
    128157
  • drivers/include/device/icu.h

     
    2828#ifndef __DEVICE_ICU_H__
    2929#define __DEVICE_ICU_H__
    3030
    31 #ifdef __DRIVER_H__
    32 # error This header must not be included after "device/driver.h"
    33 #endif
    34 
    3531#include <hexo/types.h>
    3632#include <hexo/error.h>
    3733#include <device/device.h>
    3834
     35#include <device/driver_fw.h>
     36
    3937struct device_s;
    4038struct driver_s;
    4139
     
    5351    */
    5452typedef DEVICU_ENABLE(devicu_enable_t);
    5553
    56 /** ICU device class enable() function shortcut */
    57 #define dev_icu_enable(dev, ...) (dev)->drv->f.icu.f_enable(dev, __VA_ARGS__ )
    5854
    5955
    60 
    6156/** ICU device class sethndl() function template */
    6257#define DEVICU_SETHNDL(n)       error_t (n) (struct device_s *dev, uint_fast8_t irq, dev_irq_t *hndl, void *data)
    6358/** ICU device class sethndl() function type. Setup a new interrupt
     
    7065    * @return negative error code
    7166    */
    7267typedef DEVICU_SETHNDL(devicu_sethndl_t);
    73 /** ICU device class sethndl() function shortcut */
    74 #define dev_icu_sethndl(dev, ...) (dev)->drv->f.icu.f_sethndl(dev, __VA_ARGS__ )
    7568
    7669/** bind a device to this icu irq for an already configured device */   \
    7770#define DEV_ICU_BIND(icu_dev, dev, irq, callback)                       \
     
    9588    * @return negative error code
    9689    */
    9790typedef DEVICU_DELHNDL(devicu_delhndl_t);
    98 /** ICU device class delhndl() function shortcut */
    99 #define dev_icu_delhndl(dev, ...) (dev)->drv->f.icu.f_delhndl(dev, __VA_ARGS__ )
    10091
    10192/** unbind icu irq for a device */
    10293#define DEV_ICU_UNBIND(icu_dev, dev, irq, callback)     \
     
    113104#define DEVICU_SENDIPI(n)       error_t (n) (struct ipi_endpoint_s *endpoint)
    114105/** ICU device class sendipi() function type. send an ipi to specified processor. */
    115106typedef DEVICU_SENDIPI(devicu_sendipi_t);
    116 /** ICU device class sendipi() function shortcut */
    117 #define dev_icu_sendipi(dev, ...) (dev)->drv->f.icu.f_sendipi(__VA_ARGS__ )
    118107
    119108
    120109
     
    124113                                             uint_fast8_t ipi_no)
    125114/** ICU device class setupipi() function type. setup an ipi endpoint. */
    126115typedef DEVICU_SETUP_IPI_EP(devicu_setup_ipi_ep_t);
    127 /** ICU device class setupipi() function shortcut */
    128 #define dev_icu_setup_ipi_ep(dev, ...) (dev)->drv->f.icu.f_setup_ipi_ep(dev, __VA_ARGS__ )
    129116
    130117
    131118
     
    140127  devicu_setup_ipi_ep_t *f_setup_ipi_ep;
    141128};
    142129
     130
     131/** ICU device class enable() function shortcut */
     132static inline
     133error_t dev_icu_enable(struct device_s *dev, uint_fast8_t irq,
     134                       bool_t enable, reg_t flags)
     135{
     136    const struct dev_class_icu_s *funcs =
     137        driver_class_funcs(dev->drv, device_class_icu);
     138
     139    return funcs->f_enable(dev, irq, enable, flags);
     140}
     141
     142/** ICU device class sethndl() function shortcut */
     143static inline
     144error_t dev_icu_sethndl(struct device_s *dev, uint_fast8_t irq, dev_irq_t *hndl, void *data)
     145{
     146    const struct dev_class_icu_s *funcs =
     147        driver_class_funcs(dev->drv, device_class_icu);
     148
     149    return funcs->f_sethndl(dev, irq, hndl, data);
     150}
     151
     152/** ICU device class delhndl() function shortcut */
     153static inline
     154error_t dev_icu_delhndl(struct device_s *dev, uint_fast8_t irq, dev_irq_t *hndl)
     155{
     156    const struct dev_class_icu_s *funcs =
     157        driver_class_funcs(dev->drv, device_class_icu);
     158
     159    return funcs->f_delhndl(dev, irq, hndl);
     160}
     161
     162/** ICU device class sendipi() function shortcut */
     163static inline
     164error_t dev_icu_sendipi(struct device_s *dev, struct ipi_endpoint_s *endpoint)
     165{
     166    const struct dev_class_icu_s *funcs =
     167        driver_class_funcs(dev->drv, device_class_icu);
     168
     169    return funcs->f_sendipi(endpoint);
     170}
     171
     172/** ICU device class setupipi() function shortcut */
     173static inline
     174error_t dev_icu_setup_ipi_ep(struct device_s *dev,
     175                             struct ipi_endpoint_s *endpoint,
     176                             uint_fast8_t ipi_no)
     177{
     178    const struct dev_class_icu_s *funcs =
     179        driver_class_funcs(dev->drv, device_class_icu);
     180
     181    return funcs->f_setup_ipi_ep(dev, endpoint, ipi_no);
     182}
     183
    143184#endif
    144185
  • drivers/include/device/net.h

     
    2828#ifndef __DEVICE_NET_H__
    2929#define __DEVICE_NET_H__
    3030
    31 #ifdef __DRIVER_H__
    32 # error This header must not be included after "device/driver.h"
    33 #endif
    34 
    3531#include <hexo/types.h>
    3632#include <hexo/error.h>
    3733#include <device/device.h>
    3834
     35#include <device/driver_fw.h>
     36
    3937struct device_s;
    4038struct driver_s;
    4139struct net_packet_s;
     
    5957*/
    6058typedef DEVNET_PREPAREPKT(devnet_preparepkt_t);
    6159
    62 /** Network device class preparepkt() method shortcut */
    63 #define dev_net_preparepkt(dev, ...) (dev)->drv->f.net.f_preparepkt(dev, __VA_ARGS__ )
    6460
    6561
    6662/** Network device class packet sending function tempate. */
     
    7672*/
    7773typedef DEVNET_SENDPKT(devnet_sendpkt_t);
    7874
    79 /** Network device class sendpkt() method shortcut */
    80 #define dev_net_sendpkt(dev, ...) (dev)->drv->f.net.f_sendpkt(dev, __VA_ARGS__ )
    8175
    8276
    8377/** Network device class device set option function tempate. */
     
    9589*/
    9690typedef DEVNET_SETOPT(devnet_setopt_t);
    9791
    98 /** Network device class setopt() method shortcut */
    99 #define dev_net_setopt(dev, ...) (dev)->drv->f.net.f_setopt(dev, __VA_ARGS__ )
    10092
    10193
    10294/** Network device class device get option function tempate. */
     
    114106*/
    115107typedef DEVNET_GETOPT(devnet_getopt_t);
    116108
    117 /** Network device class getopt() method shortcut */
    118 #define dev_net_getopt(dev, ...) (dev)->drv->f.net.f_getopt(dev, __VA_ARGS__ )
    119109
    120110
    121111/** Net device class methodes */
     
    127117  devnet_getopt_t               *f_getopt;
    128118};
    129119
     120/** Network device class preparepkt() method shortcut */
     121static inline
     122uint8_t *dev_net_preparepkt(struct device_s *dev, struct net_packet_s *packet, size_t size, size_t max_padding)
     123{
     124    const struct dev_class_net_s *funcs =
     125        driver_class_funcs(dev->drv, device_class_net);
     126
     127    return funcs->f_preparepkt(dev, packet, size, max_padding);
     128}
     129
     130/** Network device class sendpkt() method shortcut */
     131static inline
     132void dev_net_sendpkt(struct device_s *dev, struct net_packet_s *packet, uint_fast16_t proto)
     133{
     134    const struct dev_class_net_s *funcs =
     135        driver_class_funcs(dev->drv, device_class_net);
     136
     137    return funcs->f_sendpkt(dev, packet, proto);
     138}
     139
     140/** Network device class setopt() method shortcut */
     141static inline
     142error_t dev_net_setopt(struct device_s *dev, uint_fast32_t option, void *value, size_t len)
     143{
     144    const struct dev_class_net_s *funcs =
     145        driver_class_funcs(dev->drv, device_class_net);
     146
     147    return funcs->f_setopt(dev, option, value, len);
     148}
     149
     150/** Network device class getopt() method shortcut */
     151static inline
     152error_t dev_net_getopt(struct device_s *dev, uint_fast32_t option, void *value, size_t *len)
     153{
     154    const struct dev_class_net_s *funcs =
     155        driver_class_funcs(dev->drv, device_class_net);
     156
     157    return funcs->f_getopt(dev, option, value, len);
     158}
     159
    130160#endif
    131161
  • drivers/include/device/fb.h

     
    2828#ifndef __DEVICE_FB_H__
    2929#define __DEVICE_FB_H__
    3030
    31 #ifdef __DRIVER_H__
    32 # error This header must not be included after "device/driver.h"
    33 #endif
    34 
    3531#include <hexo/types.h>
    3632#include <hexo/error.h>
    3733
     34#include <device/driver_fw.h>
     35
    3836struct device_s;
    3937struct driver_s;
    4038
     
    7371*/
    7472typedef DEVFB_SETMODE(devfb_setmode_t);
    7573
    76 /** Fb device class setmode() methode shortcut */
    77 #define dev_fb_setmode(dev, ...) (dev)->drv->f.fb.f_setmode(dev, __VA_ARGS__ )
    7874
    7975
    8076
    81 
    8277/** Fb device class getbuffer() function tempate. */
    8378#define DEVFB_GETBUFFER(n)      uintptr_t  (n) (struct device_s *dev, uint_fast8_t page)
    8479
     
    9287*/
    9388typedef DEVFB_GETBUFFER(devfb_getbuffer_t);
    9489
    95 /** Fb device class getbuffer() methode shortcut */
    96 #define dev_fb_getbuffer(dev, ...) (dev)->drv->f.fb.f_getbuffer(dev, __VA_ARGS__ )
    9790
    9891
    9992
     
    110103*/
    111104typedef DEVFB_FLIPPAGE(devfb_flippage_t);
    112105
    113 /** Fb device class flippage() methode shortcut */
    114 #define dev_fb_flippage(dev, ...) (dev)->drv->f.fb.f_flippage(dev, __VA_ARGS__ )
    115106
    116107
    117108
     
    129120*/
    130121typedef DEVFB_SETPALETTE(devfb_setpalette_t);
    131122
    132 /** Fb device class setpalette() methode shortcut */
    133 #define dev_fb_setpalette(dev, ...) (dev)->drv->f.fb.f_setpalette(dev, __VA_ARGS__ )
    134123
    135124
    136125/** Fb device class methodes */
     
    143132};
    144133
    145134
     135/** Fb device class setmode() methode shortcut */
     136static inline
     137error_t dev_fb_setmode(
     138  struct device_s *dev,
     139  uint_fast16_t xres, uint_fast16_t yres,
     140  uint_fast8_t bpp, uint_fast8_t packing)
     141{
     142    const struct dev_class_fb_s *funcs =
     143        driver_class_funcs(dev->drv, device_class_fb);
     144
     145    return funcs->f_setmode(dev, xres, yres, bpp, packing);
     146}
     147
     148/** Fb device class getbuffer() methode shortcut */
     149static inline
     150uintptr_t dev_fb_getbuffer(struct device_s *dev, uint_fast8_t page)
     151{
     152    const struct dev_class_fb_s *funcs =
     153        driver_class_funcs(dev->drv, device_class_fb);
     154
     155    return funcs->f_getbuffer(dev, page);
     156}
     157
     158/** Fb device class flippage() methode shortcut */
     159static inline
     160error_t dev_fb_flippage(struct device_s *dev, uint_fast8_t page)
     161{
     162    const struct dev_class_fb_s *funcs =
     163        driver_class_funcs(dev->drv, device_class_fb);
     164
     165    return funcs->f_flippage(dev, page);
     166}
     167
     168/** Fb device class setpalette() methode shortcut */
     169static inline
     170void dev_fb_setpalette(struct device_s *dev, struct fb_pal_s *pal, size_t count)
     171{
     172    const struct dev_class_fb_s *funcs =
     173        driver_class_funcs(dev->drv, device_class_fb);
     174
     175    return funcs->f_setpalette(dev, pal, count);
     176}
     177
    146178#endif
    147179
  • drivers/include/device/driver_fw.h

     
     1/*
     2    This file is part of MutekH.
     3
     4    MutekH is free software; you can redistribute it and/or modify it
     5    under the terms of the GNU General Public License as published by
     6    the Free Software Foundation; either version 2 of the License, or
     7    (at your option) any later version.
     8
     9    MutekH is distributed in the hope that it will be useful, but
     10    WITHOUT ANY WARRANTY; without even the implied warranty of
     11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12    General Public License for more details.
     13
     14    You should have received a copy of the GNU General Public License
     15    along with MutekH; if not, write to the Free Software Foundation,
     16    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
     17
     18    Copyright (c) 2006-2010, MutekH contributors
     19*/
     20
     21/**                                                                 
     22 * @file                                                           
     23 * @module{Device drivers}
     24 * @short Driver forward definitions
     25 */                                                                 
     26
     27#ifndef __DRIVER_FW_H__
     28#define __DRIVER_FW_H__
     29
     30#ifdef __DRIVER_H__
     31# error This header must not be included after "device/driver.h"
     32#endif
     33
     34#include <device/device.h>
     35#include <hexo/types.h>
     36
     37struct driver_s;
     38enum device_class_e;
     39
     40static inline
     41const void *driver_class_funcs(
     42    const struct driver_s *drv,
     43    enum device_class_e class);
     44
     45#endif
  • drivers/include/device/sound.h

    Property changes on: drivers/include/device/driver_fw.h
    ___________________________________________________________________
    Added: svn:mime-type
       + text/plain
    Added: svn:keywords
       + "Author Date Id Rev URL Revision"
    Added: svn:eol-style
       + native
    
     
    2828#ifndef __DEVICE_SOUND_H__
    2929#define __DEVICE_SOUND_H__
    3030
    31 #ifdef __DRIVER_H__
    32 # error This header must not be included after "device/driver.h"
    33 #endif
    34 
    3531#include <hexo/types.h>
    3632#include <hexo/error.h>
    3733
     34#include <device/driver_fw.h>
     35
    3836struct device_s;
    3937struct driver_s;
    4038
     
    4543#define DEVSOUND_READ(n)        ssize_t  (n) (struct device_s *dev, uint8_t *data, size_t count, \
    4644                                              devsound_callback_t *cback, void *priv)
    4745
    48 /** Sound device class read() methode shortcut */
    49 
    50 #define dev_sound_read(dev, ...) (dev)->drv->f.sound.f_read(dev, __VA_ARGS__ )
    5146/**
    5247   Sound device class read() function type.  Read bytes data from the
    5348   device. Should not block if unable to read more bytes.
     
    7974*/
    8075typedef DEVSOUND_WRITE(devsound_write_t);
    8176
    82 /** Sound device class write() methode shortcut */
    83 #define dev_sound_write(dev, ...) (dev)->drv->f.sound.f_write(dev, __VA_ARGS__ )
    8477
    8578
    8679
     
    108101*/
    109102typedef DEVSOUND_MODE(devsound_mode_t);
    110103
    111 /** Sound device class write() methode shortcut */
    112 #define dev_sound_mode(dev, ...) (dev)->drv->f.sound.f_mode(dev, __VA_ARGS__ )
    113104
    114105
    115 
    116106/** Sound device class methodes */
    117107struct dev_class_sound_s
    118108{
     
    121111  devsound_mode_t               *f_mode;
    122112};
    123113
     114/** Sound device class read() methode shortcut */
     115static inline
     116ssize_t dev_sound_read(struct device_s *dev,
     117                       uint8_t *data, size_t count,
     118                       devsound_callback_t *cback, void *priv)
     119{
     120    const struct dev_class_sound_s *funcs =
     121        driver_class_funcs(dev->drv, device_class_sound);
    124122
     123    return funcs->f_read(dev, data, count, cback, priv);
     124}
     125
     126/** Sound device class write() methode shortcut */
     127static inline
     128ssize_t dev_sound_write(struct device_s *dev, const uint8_t *data, size_t count,
     129                                              devsound_callback_t *cback, void *priv)
     130{
     131    const struct dev_class_sound_s *funcs =
     132        driver_class_funcs(dev->drv, device_class_sound);
     133
     134    return funcs->f_write(dev, data, count, cback, priv);
     135}
     136
     137/** Sound device class write() methode shortcut */
     138static inline
     139error_t dev_sound_mode(struct device_s *dev,
     140                       enum dev_sound_mode_e mode,
     141                       uint_fast8_t chan_count)
     142{
     143    const struct dev_class_sound_s *funcs =
     144        driver_class_funcs(dev->drv, device_class_sound);
     145
     146    return funcs->f_mode(dev, mode, chan_count);
     147}
     148
    125149#endif
    126150
  • drivers/block/soclib/block-soclib.c

     
    213213
    214214const struct driver_s   block_soclib_drv =
    215215{
    216   .class                = device_class_block,
     216  .funcs_offset = {
     217    [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE,
     218    [device_class_block] = 0,
     219  },
    217220  .id_table             = block_soclib_ids,
    218221  .f_init               = block_soclib_init,
    219222  .f_cleanup            = block_soclib_cleanup,
    220223  .f_irq                = block_soclib_irq,
    221   .f.blk = {
    222     .f_request          = block_soclib_request,
    223     .f_getparams        = block_soclib_getparams,
    224     .f_getrqsize        = block_soclib_getrqsize,
    225   }
     224  .funcs = {
     225    {
     226      .blk = {
     227        .f_request              = block_soclib_request,
     228        .f_getparams    = block_soclib_getparams,
     229        .f_getrqsize    = block_soclib_getrqsize,
     230      },
     231    },
     232  },
    226233};
    227234
    228235REGISTER_DRIVER(block_soclib_drv);
  • drivers/enum/root/enum-root.c

     
    4141
    4242const struct driver_s   enum_root_drv =
    4343{
    44         .class          = device_class_enum,
     44    .funcs_offset = {
     45        [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE,
     46        [device_class_enum] = 0,
     47    },
    4548        .f_init         = enum_root_init,
    4649        .f_cleanup              = enum_root_cleanup,
    47         .f.denum = {
    48                 .f_lookup = enum_root_lookup,
    49         }
     50    .funcs = {
     51        {
     52            .denum = {
     53                .f_lookup = enum_root_lookup,
     54            },
     55        },
     56    },
    5057};
    5158
    5259DEV_INIT(enum_root_init)
  • drivers/enum/fdt/enum-fdt-initdev.c

     
    6060    struct device_s *icu = enum_fdt_lookup(enum_dev, (const char*)data);
    6161        dprintk("got %p\n", icu);
    6262
    63     if ( icu->drv != NULL && icu->drv->class != device_class_icu )
     63    if ( icu->drv != NULL &&
     64         icu->drv->funcs_offset[device_class_icu] == DEVICE_CLASS_UNAVAILABLE )
    6465        printk("Warning: %s is not an ICU, expect crashes\n", (const char *)data);
    6566        dev->icudev = icu;
    6667}
  • drivers/enum/fdt/enum-fdt.c

     
    218218
    219219const struct driver_s   enum_fdt_drv =
    220220{
    221         .class          = device_class_enum,
     221    .funcs_offset = {
     222        [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE,
     223        [device_class_enum] = 0,
     224    },
    222225        .f_init         = enum_fdt_init,
    223226        .f_cleanup              = enum_fdt_cleanup,
    224         .f.denum = {
    225                 .f_lookup = enum_fdt_lookup,
    226                 .f_info = enum_fdt_info,
    227 //              .f_register             = enum_fdt_register,
    228         }
     227    .funcs = {
     228        {
     229            .denum = {
     230                .f_lookup = enum_fdt_lookup,
     231                .f_info = enum_fdt_info,
     232//                .f_register           = enum_fdt_register,
     233            },
     234        },
     235        },
    229236};
    230237
    231238static void *clone_blob( void *blob )
  • drivers/char/tty-soclib/tty-soclib.c

     
    168168
    169169const struct driver_s   tty_soclib_drv =
    170170{
    171   .class                = device_class_char,
     171  .funcs_offset = {
     172    [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE,
     173    [device_class_char] = 0,
     174  },
    172175  .id_table             = tty_soclib_ids,
    173176  .f_init               = tty_soclib_init,
    174177  .f_cleanup            = tty_soclib_cleanup,
    175178#ifdef CONFIG_HEXO_IRQ
    176179  .f_irq                = tty_soclib_irq,
    177180#endif
    178   .f.chr = {
    179     .f_request          = tty_soclib_request,
    180   }
     181  .funcs = {
     182    {
     183      .chr = {
     184        .f_request              = tty_soclib_request,
     185      },
     186    },
     187  },
    181188};
    182189
    183190REGISTER_DRIVER(tty_soclib_drv);
  • drivers/mem/memory/memory.c

     
    5050
    5151const struct driver_s   memory_drv =
    5252{
    53     .class      = device_class_mem,
     53    .funcs_offset = {
     54        [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE,
     55        [device_class_mem] = 0,
     56    },
    5457        .id_table       = memory_ids,
    5558    .f_init     = memory_init,
    5659    .f_cleanup  = memory_cleanup,
    57         .f.mem = {
    58                 .f_get_info = memory_get_info,
     60    .funcs = {
     61        {
     62            .mem = {
     63                .f_get_info = memory_get_info,
     64            },
     65        },
    5966        },
    6067};
    6168