Ticket #57: 2010-10-01-multiclass-driver.diff
File 2010-10-01-multiclass-driver.diff, 64.4 KB (added by , 14 years ago) |
---|
-
drivers/timer/soclib/timer-soclib.c
157 157 158 158 const struct driver_s timer_soclib_drv = 159 159 { 160 .class = device_class_timer, 160 .funcs_offset = { 161 [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE, 162 [device_class_timer] = 0, 163 }, 161 164 .id_table = timer_soclib_ids, 162 165 .f_init = timer_soclib_init, 163 166 .f_cleanup = timer_soclib_cleanup, 164 167 .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 }, 171 178 }; 172 179 173 180 REGISTER_DRIVER(timer_soclib_drv); -
drivers/icu/soclib-xicu/xicu-soclib.c
216 216 217 217 const struct driver_s xicu_root_drv = 218 218 { 219 .class = device_class_timer, 219 .funcs_offset = { 220 [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE, 221 [device_class_timer] = 0, 222 }, 220 223 .id_table = xicu_root_ids, 221 224 .f_init = xicu_root_init, 222 225 .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 }, 229 236 }; 230 237 231 238 REGISTER_DRIVER(xicu_root_drv); -
drivers/icu/soclib-xicu/xicu-soclib-filter.c
127 127 128 128 const struct driver_s xicu_filter_drv = 129 129 { 130 .class = device_class_icu, 130 .funcs_offset = { 131 [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE, 132 [device_class_icu] = 0, 133 }, 131 134 .id_table = xicu_filter_ids, 132 135 .f_irq = xicu_filter_handler, 133 136 .f_init = xicu_filter_init, 134 137 .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, 139 144 #ifdef CONFIG_HEXO_IPI 140 141 145 .f_sendipi = xicu_filter_sendipi, 146 .f_setup_ipi_ep = xicu_filter_setup_ipi_ep, 142 147 #endif 143 } 148 }, 149 }, 150 }, 144 151 }; 145 152 146 153 REGISTER_DRIVER(xicu_filter_drv); -
drivers/icu/mips/icu-mips.c
135 135 136 136 const struct driver_s icu_mips_drv = 137 137 { 138 .class = device_class_icu, 138 .funcs_offset = { 139 [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE, 140 [device_class_icu] = 0, 141 }, 139 142 .id_table = icu_mips_ids, 140 143 .f_init = icu_mips_init, 141 144 .f_irq = (dev_irq_t *)icu_mips_handler, 142 145 .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 }, 148 155 }; 149 156 150 157 REGISTER_DRIVER(icu_mips_drv); -
drivers/icu/soclib-icu/icu-soclib.c
94 94 95 95 const struct driver_s icu_soclib_drv = 96 96 { 97 .class = device_class_icu, 97 .funcs_offset = { 98 [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE, 99 [device_class_icu] = 0, 100 }, 98 101 .id_table = icu_soclib_ids, 99 102 .f_init = icu_soclib_init, 100 103 .f_cleanup = icu_soclib_cleanup, 101 104 .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 }, 107 114 }; 108 115 109 116 REGISTER_DRIVER(icu_soclib_drv); -
drivers/drivers.config
11 11 default defined 12 12 %config end 13 13 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 14 20 %config CONFIG_DRIVER_CHAR 15 21 parent CONFIG_DEVICE 16 22 flags meta -
drivers/include/device/block.h
23 23 * @file 24 24 * @module{Device drivers} 25 25 * @short Block device driver API 26 */ 26 */ 27 27 28 28 #ifndef __DEVICE_BLOCK_H__ 29 29 #define __DEVICE_BLOCK_H__ 30 30 31 #ifdef __DRIVER_H__32 # error This header must not be included after "device/driver.h"33 #endif34 35 31 #include <hexo/types.h> 36 32 #include <hexo/error.h> 37 33 #include <hexo/gpct_platform_hexo.h> 38 34 #include <gpct/cont_clist.h> 39 35 36 #include <device/driver_fw.h> 37 40 38 struct device_s; 41 39 struct driver_s; 42 40 … … 78 76 required by the driver. */ 79 77 80 78 struct dev_block_rq_s 81 { 79 { 82 80 CONTAINER_ENTRY_TYPE(CLIST) queue_entry; 83 81 84 82 enum dev_block_rq_type_e type; //< request type and flags … … 100 98 #define DEVBLOCK_REQUEST(n) void (n) (struct device_s *dev, \ 101 99 struct dev_block_rq_s *rq) 102 100 103 /** Block device class request() methode shortcut */104 105 #define dev_block_request(dev, ...) (dev)->drv->f.blk.f_request(dev, __VA_ARGS__ )106 101 /** 107 102 Block device request function type. Request count data blocks 108 103 from the device. … … 128 123 /** Block device class getparams() function tempate. */ 129 124 #define DEVBLOCK_GETPARAMS(n) const struct dev_block_params_s * (n) (struct device_s *dev) 130 125 131 /** Block device class getparams() methode shortcut */132 133 #define dev_block_getparams(dev) (dev)->drv->f.blk.f_getparams(dev)134 135 126 /** 136 127 Block device getparams function type. 137 128 … … 147 138 /** Block device class getrqsize() function tempate. */ 148 139 #define DEVBLOCK_GETRQSIZE(n) size_t (n) (struct device_s *dev) 149 140 150 /** Block device class getrqsize() methode shortcut */151 152 #define dev_block_getrqsize(dev) (dev)->drv->f.blk.f_getrqsize(dev)153 154 141 /** 155 142 Block device getrqsize function type. 156 143 … … 171 158 }; 172 159 173 160 161 162 /** Block device class request() methode shortcut */ 163 static inline 164 void 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 */ 173 static inline 174 const 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 */ 183 static inline 184 size_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 174 192 /** Synchronous helper read function. This function use the scheduler 175 193 api to put current context in wait state if no data is available 176 194 from device yet. This function is equivalent to -
drivers/include/device/spi.h
28 28 #ifndef __DEVICE_SPI_H__ 29 29 #define __DEVICE_SPI_H__ 30 30 31 #ifdef __DRIVER_H__32 # error This header must not be included after "device/driver.h"33 #endif34 35 31 #include <hexo/types.h> 36 32 #include <hexo/error.h> 37 33 #include <hexo/gpct_platform_hexo.h> 38 34 #include <gpct/cont_clist.h> 39 35 36 #include <device/driver_fw.h> 37 40 38 struct device_s; 41 39 struct driver_s; 42 40 struct dev_spi_rq_s; … … 249 247 /** Spi device class request() function tempate. */ 250 248 #define DEVSPI_REQUEST(n) void (n) (struct device_s *dev, struct dev_spi_rq_s *rq) 251 249 252 /** Spi device class request() methode shortcut */253 #define dev_spi_request(dev, ...) (dev)->drv->f.spi.f_request(dev, __VA_ARGS__ )254 255 250 /** 256 251 Spi device class request() function type. Enqueue a request. 257 252 … … 264 259 /** Spi device class set_baudrate() function tempate. */ 265 260 #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) 266 261 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 270 262 /** 271 263 Spi device class set_baudrate() function type. Change clock for device id. 272 264 … … 297 289 bool_t keep_cs_active \ 298 290 ) 299 291 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 303 292 /** 304 293 Spi device class set_data_format() function type. Change communication protocol. 305 294 … … 320 309 devspi_set_data_format_t *f_set_data_format; 321 310 }; 322 311 312 /** Spi device class request() methode shortcut */ 313 static inline 314 void 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 */ 323 static inline 324 uint32_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 */ 335 static inline 336 error_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 323 351 #endif 324 352 -
drivers/include/device/driver.h
32 32 #include <hexo/error.h> 33 33 #include <device/device.h> 34 34 35 /* Forward declaration of type in device/driver_binder.h */ 36 struct devenum_ident_s; 35 37 36 #define PARAM_DATATYPE_INT 137 #define PARAM_DATATYPE_DEVICE_PTR 238 #define PARAM_DATATYPE_ADDR 339 #define PARAM_DATATYPE_BOOL 440 41 /**42 A link from a device property and a field in the parameter43 structure of a driver init()44 */45 struct driver_param_binder_s46 {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_s55 56 @param _struct_type full type name of the parameter structure type57 @param _struct_entry field name in the parameter structure58 @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 0x0169 #define DEVENUM_TYPE_ISA 0x0270 #define DEVENUM_TYPE_ATA 0x0371 #define DEVENUM_TYPE_FDTNAME 0x0472 73 /** device structure identification informations. wildcard values are74 enum driver dependent */75 struct devenum_ident_s76 {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_s101 array.102 103 @param _vendor the vendor id to match, -1 for wildcard104 @param _device the device id to match, -1 for wildcard105 @param _class the class to match, -1 for wildcard106 */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_s114 array.115 116 @param _vendor the vendor id to match117 */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_s124 array.125 126 @param _str the string to match from the device127 */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 static134 devenum_ident_s array.135 136 @param _name The string to match from the device-tree137 @param _binder The data binder table pointer for the fdt to param conversion138 */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 145 38 /** device driver object structure */ 146 39 147 #define DRV_MAX_FUNC_COUNT 40 #define DRV_MAX_FUNC_COUNT 6 148 41 149 struct driver_s42 union driver_func_s 150 43 { 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]; 165 45 #ifdef __DEVICE_CHAR_H__ 166 struct dev_class_char_s 46 struct dev_class_char_s chr; 167 47 #endif 168 169 48 #ifdef __DEVICE_ICU_H__ 170 /** interrupt controller devices */ 171 struct dev_class_icu_s icu; 49 struct dev_class_icu_s icu; 172 50 #endif 173 174 51 #ifdef __DEVICE_FB_H__ 175 /** frame buffer devices */ 176 struct dev_class_fb_s fb; 52 struct dev_class_fb_s fb; 177 53 #endif 178 179 54 #ifdef __DEVICE_TIMER_H__ 180 struct dev_class_timer_s 55 struct dev_class_timer_s timer; 181 56 #endif 182 183 57 #ifdef __DEVICE_INPUT_H__ 184 struct dev_class_input_s 58 struct dev_class_input_s input; 185 59 #endif 186 187 60 #ifdef __DEVICE_ENUM_H__ 188 /** device enumerator class */ 189 struct dev_class_enum_s denum; 61 struct dev_class_enum_s denum; 190 62 #endif 191 192 63 #ifdef __DEVICE_NET_H__ 193 struct dev_class_net_s 64 struct dev_class_net_s net; 194 65 #endif 195 196 66 #ifdef __DEVICE_SOUND_H__ 197 struct dev_class_sound_s 67 struct dev_class_sound_s sound; 198 68 #endif 199 200 69 #ifdef __DEVICE_BLOCK_H__ 201 struct dev_class_block_s 70 struct dev_class_block_s blk; 202 71 #endif 203 204 72 #ifdef __DEVICE_SPI_H__ 205 struct dev_class_spi_s 73 struct dev_class_spi_s spi; 206 74 #endif 207 208 75 #ifdef __DEVICE_LCD_H__ 209 struct dev_class_lcd_s 76 struct dev_class_lcd_s lcd; 210 77 #endif 211 212 78 #ifdef __DEVICE_GPIO_H__ 213 struct dev_class_gpio_s 79 struct dev_class_gpio_s gpio; 214 80 #endif 215 216 81 #ifdef __DEVICE_I2C_H__ 217 struct dev_class_i2c_s 82 struct dev_class_i2c_s i2c; 218 83 #endif 219 220 84 #ifdef __DEVICE_MEM_H__ 221 struct dev_class_mem_s 85 struct dev_class_mem_s mem; 222 86 #endif 223 } f;224 87 }; 225 88 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 89 struct driver_s 90 { 91 /** device identifier table for detection (optional) */ 92 const struct devenum_ident_s *id_table; 239 93 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; 242 98 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 252 102 253 /** 254 Try to get a driver registered with these characteristics 103 union driver_func_s funcs[]; 104 }; 255 105 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); 106 static inline 107 const 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]; 261 113 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 264 118 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 } 270 121 271 /** 272 Try to get a driver registered with these characteristics 122 #include <device/driver_binder.h> 273 123 274 @param name Name of device_type in the FDT275 @return A driver if found, NULL otherwise276 */277 const struct driver_s *driver_get_matching_fdtname(278 const char *name);279 280 124 #endif -
drivers/include/device/gpio.h
28 28 #ifndef __DEVICE_GPIO_H__ 29 29 #define __DEVICE_GPIO_H__ 30 30 31 #ifdef __DRIVER_H__32 # error This header must not be included after "device/driver.h"33 #endif34 35 31 #include <hexo/types.h> 36 32 #include <hexo/error.h> 37 33 #include <hexo/gpct_platform_hexo.h> 38 34 #include <gpct/cont_clist.h> 39 35 36 #include <device/driver_fw.h> 37 40 38 struct device_s; 41 39 struct driver_s; 42 40 … … 67 65 */ 68 66 typedef DEVGPIO_SET_WAY(devgpio_set_way_t); 69 67 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__ )72 68 73 74 69 /** Gpio device class set_value() function tempate. */ 75 70 #define DEVGPIO_SET_VALUE(n) error_t (n) (struct device_s *dev, \ 76 71 devgpio_id_t gpio, \ … … 89 84 */ 90 85 typedef DEVGPIO_SET_VALUE(devgpio_set_value_t); 91 86 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__ )94 87 95 96 88 /** Gpio device class set_pullup() function tempate. */ 97 89 #define DEVGPIO_SET_PULLUP(n) error_t (n) (struct device_s *dev, \ 98 90 devgpio_id_t gpio, \ … … 111 103 */ 112 104 typedef DEVGPIO_SET_PULLUP(devgpio_set_pullup_t); 113 105 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__ )116 106 117 118 107 /** Gpio device class assign_to_peripheral() function tempate. */ 119 108 #define DEVGPIO_ASSIGN_TO_PERIPHERAL(n) error_t (n) (struct device_s *dev, \ 120 109 devgpio_id_t gpio, \ … … 135 124 */ 136 125 typedef DEVGPIO_ASSIGN_TO_PERIPHERAL(devgpio_assign_to_peripheral_t); 137 126 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__ )140 127 141 142 128 /** Gpio device class get_value() function tempate. */ 143 129 #define DEVGPIO_GET_VALUE(n) bool_t (n) (struct device_s *dev, \ 144 130 devgpio_id_t gpio) … … 154 140 */ 155 141 typedef DEVGPIO_GET_VALUE(devgpio_get_value_t); 156 142 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__ )159 143 160 161 144 enum devgpio_event_e 162 145 { 163 146 GPIO_EDGE_RAISING, … … 207 190 */ 208 191 typedef DEVGPIO_REGISTER_IRQ(devgpio_register_irq_t); 209 192 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__ )212 193 213 194 214 215 195 /** Gpio device class methodes */ 216 196 struct dev_class_gpio_s 217 197 { … … 223 203 devgpio_register_irq_t *f_register_irq; 224 204 }; 225 205 206 207 /** Gpio device class set_way() methode shortcut */ 208 static inline 209 error_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 */ 220 static inline 221 error_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 */ 232 static inline 233 error_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 */ 244 static inline 245 error_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 */ 256 static inline 257 bool_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 */ 267 static inline 268 error_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 226 280 #endif 227 281 -
drivers/include/device/input.h
28 28 #ifndef __DEVICE_INPUT_H__ 29 29 #define __DEVICE_INPUT_H__ 30 30 31 #ifdef __DRIVER_H__32 # error This header must not be included after "device/driver.h"33 #endif34 35 31 #include <hexo/types.h> 36 32 #include <hexo/error.h> 37 33 34 #include <device/driver_fw.h> 35 38 36 struct device_s; 39 37 struct driver_s; 40 38 … … 68 66 #define DEVINPUT_INFO(n) void (n) (struct device_s *dev, \ 69 67 struct devinput_info_s *info) 70 68 71 #define dev_input_info(dev, ...) (dev)->drv->f.input.f_info(dev, __VA_ARGS__ )72 69 /** 73 70 Input device class info() function type. This function get 74 71 informations about available controles. … … 83 80 #define DEVINPUT_READ(n) devinput_value_t (n) (struct device_s *dev, \ 84 81 devinput_ctrlid_t id) 85 82 86 #define dev_input_read(dev, ...) (dev)->drv->f.input.f_read(dev, __VA_ARGS__ )87 83 /** 88 84 Input device class read() function type. This function read control 89 85 current value. … … 100 96 devinput_ctrlid_t id, \ 101 97 devinput_value_t value) 102 98 103 #define dev_input_write(dev, ...) (dev)->drv->f.input.f_write(dev, __VA_ARGS__ )104 99 /** 105 100 Input device class write() function type. This function set control 106 101 current value. … … 120 115 devinput_callback_t *callback, \ 121 116 void *priv) 122 117 123 #define dev_input_setcallback(dev, ...) (dev)->drv->f.input.f_setcallback(dev, __VA_ARGS__ )124 118 /** 125 119 Input device class setcallback() function type. This function set 126 120 a new event handler for a control. Special DEVINPUT_CTRLID_ALL … … 146 140 devinput_setcallback_t *f_setcallback; 147 141 }; 148 142 143 static inline 144 void 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); 149 149 150 return funcs->f_info(dev, info); 151 } 152 153 static inline 154 devinput_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 163 static inline 164 error_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 174 static inline 175 error_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 150 187 #endif 151 -
drivers/include/device/device.h
35 35 #include <hexo/error.h> 36 36 37 37 enum device_class_e 38 { 39 device_class_none = 0, 40 41 device_class_block, 38 { 39 #ifdef CONFIG_DRIVER_CHAR 42 40 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 44 46 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 46 52 device_class_input, 53 #endif 54 #ifdef CONFIG_DRIVER_ENUM 55 device_class_enum, 56 #endif 57 #ifdef CONFIG_DRIVER_NET 47 58 device_class_net, 59 #endif 60 #ifdef CONFIG_DRIVER_SOUND 48 61 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 50 67 device_class_spi, 68 #endif 69 #ifdef CONFIG_DRIVER_LCD 51 70 device_class_lcd, 71 #endif 72 #ifdef CONFIG_DRIVER_GPIO 52 73 device_class_gpio, 74 #endif 75 #ifdef CONFIG_DRIVER_I2C 53 76 device_class_i2c, 77 #endif 78 #ifdef CONFIG_DRIVER_MEM 54 79 device_class_mem, 55 }; 80 #endif 56 81 82 DEVICE_CLASS_COUNT, 83 }; 57 84 85 #define DEVICE_CLASS_UNAVAILABLE 0xff 86 58 87 /** Common class irq() function template. */ 59 88 #define DEV_IRQ(n) bool_t (n) (struct device_s *dev) 60 89 -
drivers/include/device/lcd.h
28 28 #ifndef __DEVICE_LCD_H__ 29 29 #define __DEVICE_LCD_H__ 30 30 31 #ifdef __DRIVER_H__32 # error This header must not be included after "device/driver.h"33 #endif34 35 31 #include <hexo/types.h> 36 32 #include <hexo/error.h> 37 33 #include <hexo/gpct_platform_hexo.h> 38 34 #include <gpct/cont_clist.h> 39 35 36 #include <device/driver_fw.h> 37 40 38 struct device_s; 41 39 struct driver_s; 42 40 … … 123 121 124 122 typedef DEVLCD_REQUEST(devlcd_request_t); 125 123 126 /** Lcd device class request() methode shortcut */127 #define dev_lcd_request(dev, ...) (dev)->drv->f.lcd.f_request(dev, __VA_ARGS__ )128 124 129 125 130 126 … … 140 136 */ 141 137 typedef DEVLCD_GETINFO(devlcd_getinfo_t); 142 138 143 /** Lcd device class getinfo() methode shortcut */144 #define dev_lcd_getinfo(dev) (dev)->drv->f.lcd.f_getinfo(dev)145 139 146 140 147 141 … … 152 146 devlcd_getinfo_t *f_getinfo; 153 147 }; 154 148 149 /** Lcd device class request() methode shortcut */ 150 static inline 151 error_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); 155 156 157 return funcs->f_request(dev, req); 158 } 159 160 /** Lcd device class getinfo() methode shortcut */ 161 static inline 162 const 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 156 172 ssize_t dev_lcd_set_palette(struct device_s *dev, struct lcd_pal_s *palette, size_t count); 157 173 158 174 /** -
drivers/include/device/enum.h
28 28 #ifndef __DEVICE_ENUM_H__ 29 29 #define __DEVICE_ENUM_H__ 30 30 31 #ifdef __DRIVER_H__32 # error This header must not be included after "device/driver.h"33 #endif34 35 31 #include <hexo/types.h> 36 32 #include <hexo/error.h> 37 33 34 #include <device/driver_fw.h> 35 38 36 /** 39 37 Lookup function prototype macro 40 38 */ … … 50 48 */ 51 49 typedef DEVENUM_LOOKUP(devenum_lookup_t); 52 50 53 /**54 Lookup function shortcut55 */56 #define dev_enum_lookup(dev, ...) (dev)->drv->f.denum.f_lookup(dev, __VA_ARGS__)57 58 51 #define DEV_ENUM_MAX_PATH_LEN 32 59 52 60 53 struct dev_enum_info_s … … 82 75 */ 83 76 typedef DEVENUM_INFO(devenum_info_t); 84 77 85 /**86 Info function shortcut87 */88 #define dev_enum_info(dev, ...) (dev)->drv->f.denum.f_info(dev, __VA_ARGS__)89 90 78 struct dev_class_enum_s 91 79 { 92 80 devenum_lookup_t *f_lookup; 93 81 devenum_info_t *f_info; 94 82 }; 95 83 84 /** 85 Lookup function shortcut 86 */ 87 static inline 88 struct 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 */ 99 static inline 100 error_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 96 110 #endif -
drivers/include/device/i2c.h
28 28 #ifndef __DEVICE_I2C_H__ 29 29 #define __DEVICE_I2C_H__ 30 30 31 #ifdef __DRIVER_H__32 # error This header must not be included after "device/driver.h"33 #endif34 35 31 #include <hexo/types.h> 36 32 #include <hexo/error.h> 37 33 #include <hexo/gpct_platform_hexo.h> 38 34 #include <gpct/cont_clist.h> 39 35 36 #include <device/driver_fw.h> 37 40 38 struct device_s; 41 39 struct driver_s; 42 40 struct dev_i2c_rq_s; … … 94 92 /** I2c device class request() function tempate. */ 95 93 #define DEVI2C_REQUEST(n) void (n) (struct device_s *dev, struct dev_i2c_rq_s *rq) 96 94 97 /** I2c device class request() methode shortcut */98 #define dev_i2c_request(dev, ...) (dev)->drv->f.i2c.f_request(dev, __VA_ARGS__ )99 100 95 /** 101 96 I2c device class request() function type. Enqueue a request. 102 97 … … 109 104 /** I2c device class set_baudrate() function tempate. */ 110 105 #define DEVI2C_SET_BAUDRATE(n) uint32_t (n) (struct device_s *dev, uint32_t br) 111 106 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 115 107 /** 116 108 I2c device class set_baudrate() function type. Change clock for device id. 117 109 … … 129 121 devi2c_set_baudrate_t *f_set_baudrate; 130 122 }; 131 123 124 /** I2c device class request() method shortcut */ 125 static inline 126 void 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); 132 130 131 return funcs->i2c.f_request(dev, rq); 132 } 133 134 /** I2c device class set_baudrate() method shortcut */ 135 static inline 136 uint32_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 133 144 error_t dev_i2c_wait_request( 134 145 struct device_s *dev, 135 146 struct dev_i2c_rq_s *rq); … … 170 181 return dev_i2c_wait_request(dev, &rq); 171 182 } 172 183 173 174 184 #endif 175 185 -
drivers/include/device/char.h
23 23 * @file 24 24 * @module{Device drivers} 25 25 * @short Character device driver API 26 */ 26 */ 27 27 28 28 #ifndef __DEVICE_CHAR_H__ 29 29 #define __DEVICE_CHAR_H__ 30 30 31 #ifdef __DRIVER_H__32 # error This header must not be included after "device/driver.h"33 #endif34 35 31 #include <hexo/types.h> 36 32 #include <hexo/error.h> 37 33 #include <hexo/gpct_platform_hexo.h> 38 34 #include <gpct/cont_clist.h> 39 35 36 #include <device/driver_fw.h> 37 40 38 struct device_s; 41 39 struct driver_s; 42 40 struct dev_char_rq_s; … … 86 84 /** Char device class request() function tempate. */ 87 85 #define DEVCHAR_REQUEST(n) void (n) (struct device_s *dev, struct dev_char_rq_s *rq) 88 86 89 /** Char device class request() methode shortcut */90 #define dev_char_request(dev, ...) (dev)->drv->f.chr.f_request(dev, __VA_ARGS__ )91 92 87 /** 93 88 Char device class request() function type. Enqueue a read or write request. 94 89 … … 105 100 }; 106 101 107 102 103 104 /** Char device class request() methode shortcut */ 105 static inline 106 void 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 108 114 /** Synchronous helper read function. This function uses the scheduler 109 115 api to put current context in wait state if no data is available 110 116 from device yet. This function spins in a loop waiting for read -
drivers/include/device/mem.h
27 27 #ifndef __DEVICE_MEM_H__ 28 28 #define __DEVICE_MEM_H__ 29 29 30 #ifdef __DRIVER_H__31 # error This header must not be included after "device/driver.h"32 #endif33 34 30 #include <hexo/types.h> 35 31 #include <hexo/error.h> 36 32 33 #include <device/driver_fw.h> 34 37 35 struct device_s; 38 36 struct driver_s; 39 37 … … 51 49 /** Mem device class get_info() function tempate. */ 52 50 #define DEVMEM_GET_INFO(n) void (n) (struct device_s *dev, struct dev_mem_info_s *info) 53 51 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 57 52 /** 58 53 Mem device class get_info() function type. Get information about a ram device. 59 54 … … 69 64 devmem_get_info_t *f_get_info; 70 65 }; 71 66 67 /** Mem device class get_info() methode shortcut */ 68 static inline 69 void 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 72 78 #endif 73 79 -
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 */ 42 struct 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 */ 72 struct 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 */ 164 const 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 */ 175 const 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 */ 184 const 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 */ 193 const 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
28 28 #ifndef __DEVICE_TIMER_H__ 29 29 #define __DEVICE_TIMER_H__ 30 30 31 #ifdef __DRIVER_H__32 # error This header must not be included after "device/driver.h"33 #endif34 35 31 #include <hexo/types.h> 36 32 #include <hexo/error.h> 37 33 34 #include <device/driver_fw.h> 35 38 36 struct device_s; 39 37 struct driver_s; 40 38 … … 59 57 * @param priv private data passed to callback function 60 58 */ 61 59 typedef 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__ )64 60 65 61 66 62 … … 76 72 * @param period timer period 77 73 */ 78 74 typedef 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__ )81 75 82 76 83 77 … … 92 86 * @param value new timer value 93 87 */ 94 88 typedef 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__ )97 89 98 90 99 91 … … 108 100 * @return current timer value 109 101 */ 110 102 typedef 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__ )113 103 114 104 115 105 … … 123 113 devtimer_setvalue_t *f_setvalue; 124 114 }; 125 115 116 /** Timer device class setcallback() function shortcut */ 117 static inline 118 error_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); 126 122 123 return funcs->f_setcallback(dev, id, callback, priv); 124 } 125 126 /** Timer device class setperiod() function shortcut */ 127 static inline 128 error_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 */ 137 static inline 138 error_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 */ 147 static inline 148 uintmax_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 127 156 #endif 128 157 -
drivers/include/device/icu.h
28 28 #ifndef __DEVICE_ICU_H__ 29 29 #define __DEVICE_ICU_H__ 30 30 31 #ifdef __DRIVER_H__32 # error This header must not be included after "device/driver.h"33 #endif34 35 31 #include <hexo/types.h> 36 32 #include <hexo/error.h> 37 33 #include <device/device.h> 38 34 35 #include <device/driver_fw.h> 36 39 37 struct device_s; 40 38 struct driver_s; 41 39 … … 53 51 */ 54 52 typedef DEVICU_ENABLE(devicu_enable_t); 55 53 56 /** ICU device class enable() function shortcut */57 #define dev_icu_enable(dev, ...) (dev)->drv->f.icu.f_enable(dev, __VA_ARGS__ )58 54 59 55 60 61 56 /** ICU device class sethndl() function template */ 62 57 #define DEVICU_SETHNDL(n) error_t (n) (struct device_s *dev, uint_fast8_t irq, dev_irq_t *hndl, void *data) 63 58 /** ICU device class sethndl() function type. Setup a new interrupt … … 70 65 * @return negative error code 71 66 */ 72 67 typedef 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__ )75 68 76 69 /** bind a device to this icu irq for an already configured device */ \ 77 70 #define DEV_ICU_BIND(icu_dev, dev, irq, callback) \ … … 95 88 * @return negative error code 96 89 */ 97 90 typedef 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__ )100 91 101 92 /** unbind icu irq for a device */ 102 93 #define DEV_ICU_UNBIND(icu_dev, dev, irq, callback) \ … … 113 104 #define DEVICU_SENDIPI(n) error_t (n) (struct ipi_endpoint_s *endpoint) 114 105 /** ICU device class sendipi() function type. send an ipi to specified processor. */ 115 106 typedef 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__ )118 107 119 108 120 109 … … 124 113 uint_fast8_t ipi_no) 125 114 /** ICU device class setupipi() function type. setup an ipi endpoint. */ 126 115 typedef 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__ )129 116 130 117 131 118 … … 140 127 devicu_setup_ipi_ep_t *f_setup_ipi_ep; 141 128 }; 142 129 130 131 /** ICU device class enable() function shortcut */ 132 static inline 133 error_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 */ 143 static inline 144 error_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 */ 153 static inline 154 error_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 */ 163 static inline 164 error_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 */ 173 static inline 174 error_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 143 184 #endif 144 185 -
drivers/include/device/net.h
28 28 #ifndef __DEVICE_NET_H__ 29 29 #define __DEVICE_NET_H__ 30 30 31 #ifdef __DRIVER_H__32 # error This header must not be included after "device/driver.h"33 #endif34 35 31 #include <hexo/types.h> 36 32 #include <hexo/error.h> 37 33 #include <device/device.h> 38 34 35 #include <device/driver_fw.h> 36 39 37 struct device_s; 40 38 struct driver_s; 41 39 struct net_packet_s; … … 59 57 */ 60 58 typedef DEVNET_PREPAREPKT(devnet_preparepkt_t); 61 59 62 /** Network device class preparepkt() method shortcut */63 #define dev_net_preparepkt(dev, ...) (dev)->drv->f.net.f_preparepkt(dev, __VA_ARGS__ )64 60 65 61 66 62 /** Network device class packet sending function tempate. */ … … 76 72 */ 77 73 typedef DEVNET_SENDPKT(devnet_sendpkt_t); 78 74 79 /** Network device class sendpkt() method shortcut */80 #define dev_net_sendpkt(dev, ...) (dev)->drv->f.net.f_sendpkt(dev, __VA_ARGS__ )81 75 82 76 83 77 /** Network device class device set option function tempate. */ … … 95 89 */ 96 90 typedef DEVNET_SETOPT(devnet_setopt_t); 97 91 98 /** Network device class setopt() method shortcut */99 #define dev_net_setopt(dev, ...) (dev)->drv->f.net.f_setopt(dev, __VA_ARGS__ )100 92 101 93 102 94 /** Network device class device get option function tempate. */ … … 114 106 */ 115 107 typedef DEVNET_GETOPT(devnet_getopt_t); 116 108 117 /** Network device class getopt() method shortcut */118 #define dev_net_getopt(dev, ...) (dev)->drv->f.net.f_getopt(dev, __VA_ARGS__ )119 109 120 110 121 111 /** Net device class methodes */ … … 127 117 devnet_getopt_t *f_getopt; 128 118 }; 129 119 120 /** Network device class preparepkt() method shortcut */ 121 static inline 122 uint8_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 */ 131 static inline 132 void 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 */ 141 static inline 142 error_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 */ 151 static inline 152 error_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 130 160 #endif 131 161 -
drivers/include/device/fb.h
28 28 #ifndef __DEVICE_FB_H__ 29 29 #define __DEVICE_FB_H__ 30 30 31 #ifdef __DRIVER_H__32 # error This header must not be included after "device/driver.h"33 #endif34 35 31 #include <hexo/types.h> 36 32 #include <hexo/error.h> 37 33 34 #include <device/driver_fw.h> 35 38 36 struct device_s; 39 37 struct driver_s; 40 38 … … 73 71 */ 74 72 typedef DEVFB_SETMODE(devfb_setmode_t); 75 73 76 /** Fb device class setmode() methode shortcut */77 #define dev_fb_setmode(dev, ...) (dev)->drv->f.fb.f_setmode(dev, __VA_ARGS__ )78 74 79 75 80 76 81 82 77 /** Fb device class getbuffer() function tempate. */ 83 78 #define DEVFB_GETBUFFER(n) uintptr_t (n) (struct device_s *dev, uint_fast8_t page) 84 79 … … 92 87 */ 93 88 typedef DEVFB_GETBUFFER(devfb_getbuffer_t); 94 89 95 /** Fb device class getbuffer() methode shortcut */96 #define dev_fb_getbuffer(dev, ...) (dev)->drv->f.fb.f_getbuffer(dev, __VA_ARGS__ )97 90 98 91 99 92 … … 110 103 */ 111 104 typedef DEVFB_FLIPPAGE(devfb_flippage_t); 112 105 113 /** Fb device class flippage() methode shortcut */114 #define dev_fb_flippage(dev, ...) (dev)->drv->f.fb.f_flippage(dev, __VA_ARGS__ )115 106 116 107 117 108 … … 129 120 */ 130 121 typedef DEVFB_SETPALETTE(devfb_setpalette_t); 131 122 132 /** Fb device class setpalette() methode shortcut */133 #define dev_fb_setpalette(dev, ...) (dev)->drv->f.fb.f_setpalette(dev, __VA_ARGS__ )134 123 135 124 136 125 /** Fb device class methodes */ … … 143 132 }; 144 133 145 134 135 /** Fb device class setmode() methode shortcut */ 136 static inline 137 error_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 */ 149 static inline 150 uintptr_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 */ 159 static inline 160 error_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 */ 169 static inline 170 void 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 146 178 #endif 147 179 -
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 37 struct driver_s; 38 enum device_class_e; 39 40 static inline 41 const 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
28 28 #ifndef __DEVICE_SOUND_H__ 29 29 #define __DEVICE_SOUND_H__ 30 30 31 #ifdef __DRIVER_H__32 # error This header must not be included after "device/driver.h"33 #endif34 35 31 #include <hexo/types.h> 36 32 #include <hexo/error.h> 37 33 34 #include <device/driver_fw.h> 35 38 36 struct device_s; 39 37 struct driver_s; 40 38 … … 45 43 #define DEVSOUND_READ(n) ssize_t (n) (struct device_s *dev, uint8_t *data, size_t count, \ 46 44 devsound_callback_t *cback, void *priv) 47 45 48 /** Sound device class read() methode shortcut */49 50 #define dev_sound_read(dev, ...) (dev)->drv->f.sound.f_read(dev, __VA_ARGS__ )51 46 /** 52 47 Sound device class read() function type. Read bytes data from the 53 48 device. Should not block if unable to read more bytes. … … 79 74 */ 80 75 typedef DEVSOUND_WRITE(devsound_write_t); 81 76 82 /** Sound device class write() methode shortcut */83 #define dev_sound_write(dev, ...) (dev)->drv->f.sound.f_write(dev, __VA_ARGS__ )84 77 85 78 86 79 … … 108 101 */ 109 102 typedef DEVSOUND_MODE(devsound_mode_t); 110 103 111 /** Sound device class write() methode shortcut */112 #define dev_sound_mode(dev, ...) (dev)->drv->f.sound.f_mode(dev, __VA_ARGS__ )113 104 114 105 115 116 106 /** Sound device class methodes */ 117 107 struct dev_class_sound_s 118 108 { … … 121 111 devsound_mode_t *f_mode; 122 112 }; 123 113 114 /** Sound device class read() methode shortcut */ 115 static inline 116 ssize_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); 124 122 123 return funcs->f_read(dev, data, count, cback, priv); 124 } 125 126 /** Sound device class write() methode shortcut */ 127 static inline 128 ssize_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 */ 138 static inline 139 error_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 125 149 #endif 126 150 -
drivers/block/soclib/block-soclib.c
213 213 214 214 const struct driver_s block_soclib_drv = 215 215 { 216 .class = device_class_block, 216 .funcs_offset = { 217 [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE, 218 [device_class_block] = 0, 219 }, 217 220 .id_table = block_soclib_ids, 218 221 .f_init = block_soclib_init, 219 222 .f_cleanup = block_soclib_cleanup, 220 223 .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 }, 226 233 }; 227 234 228 235 REGISTER_DRIVER(block_soclib_drv); -
drivers/enum/root/enum-root.c
41 41 42 42 const struct driver_s enum_root_drv = 43 43 { 44 .class = device_class_enum, 44 .funcs_offset = { 45 [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE, 46 [device_class_enum] = 0, 47 }, 45 48 .f_init = enum_root_init, 46 49 .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 }, 50 57 }; 51 58 52 59 DEV_INIT(enum_root_init) -
drivers/enum/fdt/enum-fdt-initdev.c
60 60 struct device_s *icu = enum_fdt_lookup(enum_dev, (const char*)data); 61 61 dprintk("got %p\n", icu); 62 62 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 ) 64 65 printk("Warning: %s is not an ICU, expect crashes\n", (const char *)data); 65 66 dev->icudev = icu; 66 67 } -
drivers/enum/fdt/enum-fdt.c
218 218 219 219 const struct driver_s enum_fdt_drv = 220 220 { 221 .class = device_class_enum, 221 .funcs_offset = { 222 [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE, 223 [device_class_enum] = 0, 224 }, 222 225 .f_init = enum_fdt_init, 223 226 .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 }, 229 236 }; 230 237 231 238 static void *clone_blob( void *blob ) -
drivers/char/tty-soclib/tty-soclib.c
168 168 169 169 const struct driver_s tty_soclib_drv = 170 170 { 171 .class = device_class_char, 171 .funcs_offset = { 172 [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE, 173 [device_class_char] = 0, 174 }, 172 175 .id_table = tty_soclib_ids, 173 176 .f_init = tty_soclib_init, 174 177 .f_cleanup = tty_soclib_cleanup, 175 178 #ifdef CONFIG_HEXO_IRQ 176 179 .f_irq = tty_soclib_irq, 177 180 #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 }, 181 188 }; 182 189 183 190 REGISTER_DRIVER(tty_soclib_drv); -
drivers/mem/memory/memory.c
50 50 51 51 const struct driver_s memory_drv = 52 52 { 53 .class = device_class_mem, 53 .funcs_offset = { 54 [0 ... DEVICE_CLASS_COUNT-1] = DEVICE_CLASS_UNAVAILABLE, 55 [device_class_mem] = 0, 56 }, 54 57 .id_table = memory_ids, 55 58 .f_init = memory_init, 56 59 .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 }, 59 66 }, 60 67 }; 61 68