Changeset 83a2f43 in mainline for uspace/lib/drv


Ignore:
Timestamp:
2011-02-15T19:43:50Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
af6b5157
Parents:
34588a80
Message:

Rename bunch of stuff so that it starts with 'ddf_'.

Location:
uspace/lib/drv
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/driver.c

    r34588a80 r83a2f43  
    11/*
    22 * Copyright (c) 2010 Lenka Trochtova
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    7677};
    7778
    78 static device_t *create_device(void);
    79 static void delete_device(device_t *);
     79static ddf_dev_t *create_device(void);
     80static void delete_device(ddf_dev_t *);
    8081
    8182static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall)
     
    152153
    153154interrupt_context_t *
    154 find_interrupt_context(interrupt_context_list_t *list, device_t *dev, int irq)
     155find_interrupt_context(interrupt_context_list_t *list, ddf_dev_t *dev, int irq)
    155156{
    156157        fibril_mutex_lock(&list->mutex);
     
    174175
    175176int
    176 register_interrupt_handler(device_t *dev, int irq, interrupt_handler_t *handler,
     177register_interrupt_handler(ddf_dev_t *dev, int irq, interrupt_handler_t *handler,
    177178    irq_code_t *pseudocode)
    178179{
     
    197198}
    198199
    199 int unregister_interrupt_handler(device_t *dev, int irq)
     200int unregister_interrupt_handler(ddf_dev_t *dev, int irq)
    200201{
    201202        interrupt_context_t *ctx = find_interrupt_context(&interrupt_contexts,
     
    211212}
    212213
    213 static void add_to_functions_list(function_t *fun)
     214static void add_to_functions_list(ddf_fun_t *fun)
    214215{
    215216        fibril_mutex_lock(&functions_mutex);
     
    218219}
    219220
    220 static void remove_from_functions_list(function_t *fun)
     221static void remove_from_functions_list(ddf_fun_t *fun)
    221222{
    222223        fibril_mutex_lock(&functions_mutex);
     
    225226}
    226227
    227 static function_t *driver_get_function(link_t *functions, devman_handle_t handle)
    228 {
    229         function_t *fun = NULL;
     228static ddf_fun_t *driver_get_function(link_t *functions, devman_handle_t handle)
     229{
     230        ddf_fun_t *fun = NULL;
    230231        printf("driver_get_function handle=%" PRIun "\n", handle);
    231232       
     
    234235       
    235236        while (link != functions) {
    236                 fun = list_get_instance(link, function_t, link);
     237                fun = list_get_instance(link, ddf_fun_t, link);
    237238                printf(" - fun handle %" PRIun "\n", fun->handle);
    238239                if (fun->handle == handle) {
     
    257258        devman_handle_t parent_fun_handle = IPC_GET_ARG2(*icall);
    258259       
    259         device_t *dev = create_device();
     260        ddf_dev_t *dev = create_device();
    260261        dev->handle = dev_handle;
    261262
     
    318319         */
    319320        devman_handle_t handle = IPC_GET_ARG2(*icall);
    320         function_t *fun = driver_get_function(&functions, handle);
     321        ddf_fun_t *fun = driver_get_function(&functions, handle);
    321322
    322323        if (fun == NULL) {
     
    461462 * @return              The device structure.
    462463 */
    463 static device_t *create_device(void)
    464 {
    465         device_t *dev;
    466 
    467         dev = malloc(sizeof(device_t));
     464static ddf_dev_t *create_device(void)
     465{
     466        ddf_dev_t *dev;
     467
     468        dev = malloc(sizeof(ddf_dev_t));
    468469        if (dev == NULL)
    469470                return NULL;
    470471
    471         memset(dev, 0, sizeof(device_t));
     472        memset(dev, 0, sizeof(ddf_dev_t));
    472473        return dev;
    473474}
     
    477478 * @return              The device structure.
    478479 */
    479 static function_t *create_function(void)
    480 {
    481         function_t *fun;
    482 
    483         fun = calloc(1, sizeof(function_t));
     480static ddf_fun_t *create_function(void)
     481{
     482        ddf_fun_t *fun;
     483
     484        fun = calloc(1, sizeof(ddf_fun_t));
    484485        if (fun == NULL)
    485486                return NULL;
     
    495496 * @param dev           The device structure.
    496497 */
    497 static void delete_device(device_t *dev)
     498static void delete_device(ddf_dev_t *dev)
    498499{
    499500        free(dev);
     
    504505 * @param dev           The device structure.
    505506 */
    506 static void delete_function(function_t *fun)
     507static void delete_function(ddf_fun_t *fun)
    507508{
    508509        clean_match_ids(&fun->match_ids);
     
    535536 * @return              New function or @c NULL if memory is not available
    536537 */
    537 function_t *ddf_fun_create(device_t *dev, fun_type_t ftype, const char *name)
    538 {
    539         function_t *fun;
     538ddf_fun_t *ddf_fun_create(ddf_dev_t *dev, fun_type_t ftype, const char *name)
     539{
     540        ddf_fun_t *fun;
    540541
    541542        fun = create_function();
     
    563564 * @param fun           Function to destroy
    564565 */
    565 void ddf_fun_destroy(function_t *fun)
     566void ddf_fun_destroy(ddf_fun_t *fun)
    566567{
    567568        assert(fun->bound == false);
     
    569570}
    570571
    571 void *function_get_ops(function_t *fun, dev_inferface_idx_t idx)
     572void *function_get_ops(ddf_fun_t *fun, dev_inferface_idx_t idx)
    572573{
    573574        assert(is_valid_iface_idx(idx));
     
    589590 * @return              EOK on success or negative error code
    590591 */
    591 int ddf_fun_bind(function_t *fun)
     592int ddf_fun_bind(ddf_fun_t *fun)
    592593{
    593594        assert(fun->name != NULL);
     
    617618 * @return                      EOK on success, ENOMEM if out of memory.
    618619 */
    619 int ddf_fun_add_match_id(function_t *fun, const char *match_id_str,
     620int ddf_fun_add_match_id(ddf_fun_t *fun, const char *match_id_str,
    620621    int match_score)
    621622{
     
    637638
    638639/** Get default handler for client requests */
    639 remote_handler_t *function_get_default_handler(function_t *fun)
     640remote_handler_t *function_get_default_handler(ddf_fun_t *fun)
    640641{
    641642        if (fun->ops == NULL)
     
    648649 * Must only be called when the function is bound.
    649650 */
    650 int add_function_to_class(function_t *fun, const char *class_name)
     651int ddf_fun_add_to_class(ddf_fun_t *fun, const char *class_name)
    651652{
    652653        assert(fun->bound == true);
     
    656657}
    657658
    658 int driver_main(driver_t *drv)
     659int ddf_driver_main(driver_t *drv)
    659660{
    660661        /*
  • uspace/lib/drv/generic/remote_char_dev.c

    r34588a80 r83a2f43  
    4141#define MAX_CHAR_RW_COUNT 256
    4242
    43 static void remote_char_read(function_t *, void *, ipc_callid_t, ipc_call_t *);
    44 static void remote_char_write(function_t *, void *, ipc_callid_t, ipc_call_t *);
     43static void remote_char_read(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     44static void remote_char_write(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    4545
    4646/** Remote character interface operations. */
     
    7171 */
    7272static void
    73 remote_char_read(function_t *fun, void *ops, ipc_callid_t callid,
     73remote_char_read(ddf_fun_t *fun, void *ops, ipc_callid_t callid,
    7474    ipc_call_t *call)
    7575{
     
    118118 */
    119119static void
    120 remote_char_write(function_t *fun, void *ops, ipc_callid_t callid,
     120remote_char_write(ddf_fun_t *fun, void *ops, ipc_callid_t callid,
    121121    ipc_call_t *call)
    122122{
  • uspace/lib/drv/generic/remote_hw_res.c

    r34588a80 r83a2f43  
    3939#include "driver.h"
    4040
    41 static void remote_hw_res_get_resource_list(function_t *, void *, ipc_callid_t,
     41static void remote_hw_res_get_resource_list(ddf_fun_t *, void *, ipc_callid_t,
    4242    ipc_call_t *);
    43 static void remote_hw_res_enable_interrupt(function_t *, void *, ipc_callid_t,
     43static void remote_hw_res_enable_interrupt(ddf_fun_t *, void *, ipc_callid_t,
    4444    ipc_call_t *);
    4545
     
    5555};
    5656
    57 static void remote_hw_res_enable_interrupt(function_t *fun, void *ops,
     57static void remote_hw_res_enable_interrupt(ddf_fun_t *fun, void *ops,
    5858    ipc_callid_t callid, ipc_call_t *call)
    5959{
     
    6868}
    6969
    70 static void remote_hw_res_get_resource_list(function_t *fun, void *ops,
     70static void remote_hw_res_get_resource_list(ddf_fun_t *fun, void *ops,
    7171    ipc_callid_t callid, ipc_call_t *call)
    7272{
  • uspace/lib/drv/include/dev_iface.h

    r34588a80 r83a2f43  
    4343 */
    4444
    45 struct function;
     45struct ddf_fun;
    4646
    4747/*
     
    4949 * devices driver.
    5050 */
    51 typedef void remote_iface_func_t(struct function *, void *, ipc_callid_t,
     51typedef void remote_iface_func_t(struct ddf_fun *, void *, ipc_callid_t,
    5252    ipc_call_t *);
    5353typedef remote_iface_func_t *remote_iface_func_ptr_t;
    54 typedef void remote_handler_t(struct function *, ipc_callid_t, ipc_call_t *);
     54typedef void remote_handler_t(struct ddf_fun *, ipc_callid_t, ipc_call_t *);
    5555
    5656typedef struct {
  • uspace/lib/drv/include/driver.h

    r34588a80 r83a2f43  
    4949#include "dev_iface.h"
    5050
    51 struct device;
    52 typedef struct device device_t;
    53 
    54 struct function;
    55 typedef struct function function_t;
     51typedef struct ddf_dev ddf_dev_t;
     52typedef struct ddf_fun ddf_fun_t;
    5653
    5754/*
     
    6057
    6158/** Devices operations */
    62 typedef struct device_ops {
     59typedef struct ddf_dev_ops {
    6360        /**
    6461         * Optional callback function called when a client is connecting to the
    6562         * device.
    6663         */
    67         int (*open)(function_t *);
     64        int (*open)(ddf_fun_t *);
    6865       
    6966        /**
     
    7168         * the device.
    7269         */
    73         void (*close)(function_t *);
     70        void (*close)(ddf_fun_t *);
    7471       
    7572        /** The table of standard interfaces implemented by the device. */
     
    8279         */
    8380        remote_handler_t *default_handler;
    84 } device_ops_t;
    85 
     81} ddf_dev_ops_t;
    8682
    8783/*
     
    9086
    9187/** Device structure */
    92 struct device {
     88struct ddf_dev {
    9389        /**
    9490         * Globally unique device identifier (assigned to the device by the
     
    114110
    115111/** Function structure */
    116 struct function {
     112struct ddf_fun {
    117113        /** True if bound to the device manager */
    118114        bool bound;
     
    121117       
    122118        /** Device which this function belogs to */
    123         device_t *dev;
     119        ddf_dev_t *dev;
    124120       
    125121        /** Function type */
     
    132128        void *driver_data;
    133129        /** Implementation of operations provided by this function */
    134         device_ops_t *ops;
     130        ddf_dev_ops_t *ops;
    135131       
    136132        /** Link in the list of functions handled by the driver */
     
    145141typedef struct driver_ops {
    146142        /** Callback method for passing a new device to the device driver */
    147         int (*add_device)(device_t *dev);
     143        int (*add_device)(ddf_dev_t *dev);
    148144        /* TODO: add other generic driver operations */
    149145} driver_ops_t;
     
    157153} driver_t;
    158154
    159 int driver_main(driver_t *);
    160 
    161 extern function_t *ddf_fun_create(device_t *, fun_type_t, const char *);
    162 extern void ddf_fun_destroy(function_t *);
    163 extern int ddf_fun_bind(function_t *);
    164 extern int ddf_fun_add_match_id(function_t *, const char *, int);
    165 
    166 extern void *function_get_ops(function_t *, dev_inferface_idx_t);
     155int ddf_driver_main(driver_t *);
     156
     157extern ddf_fun_t *ddf_fun_create(ddf_dev_t *, fun_type_t, const char *);
     158extern void ddf_fun_destroy(ddf_fun_t *);
     159extern int ddf_fun_bind(ddf_fun_t *);
     160extern int ddf_fun_add_match_id(ddf_fun_t *, const char *, int);
     161
     162extern void *function_get_ops(ddf_fun_t *, dev_inferface_idx_t);
    167163
    168164/*
     
    170166 */
    171167
    172 typedef void interrupt_handler_t(device_t *, ipc_callid_t, ipc_call_t *);
     168typedef void interrupt_handler_t(ddf_dev_t *, ipc_callid_t, ipc_call_t *);
    173169
    174170typedef struct interrupt_context {
    175171        int id;
    176         device_t *dev;
     172        ddf_dev_t *dev;
    177173        int irq;
    178174        interrupt_handler_t *handler;
     
    196192    interrupt_context_list_t *, int);
    197193extern interrupt_context_t *find_interrupt_context(
    198     interrupt_context_list_t *, device_t *, int);
    199 
    200 extern int register_interrupt_handler(device_t *, int, interrupt_handler_t *,
     194    interrupt_context_list_t *, ddf_dev_t *, int);
     195
     196extern int register_interrupt_handler(ddf_dev_t *, int, interrupt_handler_t *,
    201197    irq_code_t *);
    202 extern int unregister_interrupt_handler(device_t *, int);
    203 
    204 extern remote_handler_t *function_get_default_handler(function_t *);
    205 extern int add_function_to_class(function_t *fun, const char *class_name);
     198extern int unregister_interrupt_handler(ddf_dev_t *, int);
     199
     200extern remote_handler_t *function_get_default_handler(ddf_fun_t *);
     201extern int ddf_fun_add_to_class(ddf_fun_t *fun, const char *class_name);
    206202
    207203#endif
  • uspace/lib/drv/include/ops/char_dev.h

    r34588a80 r83a2f43  
    3939
    4040typedef struct {
    41         int (*read)(function_t *, char *, size_t);
    42         int (*write)(function_t *, char *, size_t);
     41        int (*read)(ddf_fun_t *, char *, size_t);
     42        int (*write)(ddf_fun_t *, char *, size_t);
    4343} char_dev_ops_t;
    4444
  • uspace/lib/drv/include/ops/hw_res.h

    r34588a80 r83a2f43  
    4242
    4343typedef struct {
    44          hw_resource_list_t *(*get_resource_list)(function_t *);
    45          bool (*enable_interrupt)(function_t *);
     44         hw_resource_list_t *(*get_resource_list)(ddf_fun_t *);
     45         bool (*enable_interrupt)(ddf_fun_t *);
    4646} hw_res_ops_t;
    4747
Note: See TracChangeset for help on using the changeset viewer.