Changeset 92574f4 in mainline for uspace/lib/drv/include/ddf/driver.h


Ignore:
Timestamp:
2011-02-24T12:03:27Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e7b7ebd5
Parents:
4837092 (diff), a80849c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged development (changes in DDF, etc.).

Conflicts in uspace/drv/usbkbd/main.c

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/include/ddf/driver.h

    r4837092 r92574f4  
    11/*
    22 * Copyright (c) 2010 Lenka Trochtova
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    3334 */
    3435
    35 #ifndef LIBDRV_DRIVER_H_
    36 #define LIBDRV_DRIVER_H_
     36#ifndef DDF_DRIVER_H_
     37#define DDF_DRIVER_H_
    3738
    38 #include <adt/list.h>
    39 #include <ipc/ipc.h>
    40 #include <devman.h>
    4139#include <ipc/devman.h>
    4240#include <ipc/dev_iface.h>
    43 #include <assert.h>
    44 #include <ddi.h>
    45 #include <libarch/ddi.h>
    46 #include <fibril_synch.h>
    47 #include <malloc.h>
    4841
    49 #include "dev_iface.h"
     42#include "../dev_iface.h"
    5043
    51 struct device;
    52 typedef struct device device_t;
     44typedef struct ddf_dev ddf_dev_t;
     45typedef struct ddf_fun ddf_fun_t;
    5346
    5447/*
    55  * Device class
     48 * Device
    5649 */
    5750
    5851/** Devices operations */
    59 typedef struct device_ops {
     52typedef struct ddf_dev_ops {
    6053        /**
    6154         * Optional callback function called when a client is connecting to the
    6255         * device.
    6356         */
    64         int (*open)(device_t *);
     57        int (*open)(ddf_fun_t *);
    6558       
    6659        /**
     
    6861         * the device.
    6962         */
    70         void (*close)(device_t *);
     63        void (*close)(ddf_fun_t *);
    7164       
    7265        /** The table of standard interfaces implemented by the device. */
     
    7972         */
    8073        remote_handler_t *default_handler;
    81 } device_ops_t;
    82 
    83 
    84 /*
    85  * Device
    86  */
     74} ddf_dev_ops_t;
    8775
    8876/** Device structure */
    89 struct device {
     77struct ddf_dev {
    9078        /**
    9179         * Globally unique device identifier (assigned to the device by the
     
    10088        int parent_phone;
    10189       
    102         /** Parent device if handled by this driver, NULL otherwise */
    103         device_t *parent;
    10490        /** Device name */
    10591        const char *name;
    106         /** List of device ids for device-to-driver matching */
    107         match_id_list_t match_ids;
     92       
    10893        /** Driver-specific data associated with this device */
    10994        void *driver_data;
    110         /** The implementation of operations provided by this device */
    111         device_ops_t *ops;
    11295       
    11396        /** Link in the list of devices handled by the driver */
     97        link_t link;
     98};
     99
     100/** Function structure */
     101struct ddf_fun {
     102        /** True if bound to the device manager */
     103        bool bound;
     104        /** Function indentifier (asigned by device manager) */
     105        devman_handle_t handle;
     106       
     107        /** Device which this function belogs to */
     108        ddf_dev_t *dev;
     109       
     110        /** Function type */
     111        fun_type_t ftype;
     112        /** Function name */
     113        const char *name;
     114        /** List of device ids for driver matching */
     115        match_id_list_t match_ids;
     116        /** Driver-specific data associated with this function */
     117        void *driver_data;
     118        /** Implementation of operations provided by this function */
     119        ddf_dev_ops_t *ops;
     120       
     121        /** Link in the list of functions handled by the driver */
    114122        link_t link;
    115123};
     
    122130typedef struct driver_ops {
    123131        /** Callback method for passing a new device to the device driver */
    124         int (*add_device)(device_t *dev);
     132        int (*add_device)(ddf_dev_t *dev);
    125133        /* TODO: add other generic driver operations */
    126134} driver_ops_t;
     
    134142} driver_t;
    135143
    136 int driver_main(driver_t *);
     144extern int ddf_driver_main(driver_t *);
    137145
    138 /** Create new device structure.
    139  *
    140  * @return              The device structure.
    141  */
    142 extern device_t *create_device(void);
    143 extern void delete_device(device_t *);
    144 extern void *device_get_ops(device_t *, dev_inferface_idx_t);
     146extern ddf_fun_t *ddf_fun_create(ddf_dev_t *, fun_type_t, const char *);
     147extern void ddf_fun_destroy(ddf_fun_t *);
     148extern int ddf_fun_bind(ddf_fun_t *);
     149extern int ddf_fun_add_match_id(ddf_fun_t *, const char *, int);
    145150
    146 extern int child_device_register(device_t *, device_t *);
    147 extern int child_device_register_wrapper(device_t *, const char *, const char *,
    148     int, devman_handle_t *);
    149 
    150 /*
    151  * Interrupts
    152  */
    153 
    154 typedef void interrupt_handler_t(device_t *, ipc_callid_t, ipc_call_t *);
    155 
    156 typedef struct interrupt_context {
    157         int id;
    158         device_t *dev;
    159         int irq;
    160         interrupt_handler_t *handler;
    161         link_t link;
    162 } interrupt_context_t;
    163 
    164 typedef struct interrupt_context_list {
    165         int curr_id;
    166         link_t contexts;
    167         fibril_mutex_t mutex;
    168 } interrupt_context_list_t;
    169 
    170 extern interrupt_context_t *create_interrupt_context(void);
    171 extern void delete_interrupt_context(interrupt_context_t *);
    172 extern void init_interrupt_context_list(interrupt_context_list_t *);
    173 extern void add_interrupt_context(interrupt_context_list_t *,
    174     interrupt_context_t *);
    175 extern void remove_interrupt_context(interrupt_context_list_t *,
    176     interrupt_context_t *);
    177 extern interrupt_context_t *find_interrupt_context_by_id(
    178     interrupt_context_list_t *, int);
    179 extern interrupt_context_t *find_interrupt_context(
    180     interrupt_context_list_t *, device_t *, int);
    181 
    182 extern int register_interrupt_handler(device_t *, int, interrupt_handler_t *,
    183     irq_code_t *);
    184 extern int unregister_interrupt_handler(device_t *, int);
    185 
    186 extern remote_handler_t *device_get_default_handler(device_t *);
    187 extern int add_device_to_class(device_t *, const char *);
     151extern int ddf_fun_add_to_class(ddf_fun_t *, const char *);
    188152
    189153#endif
Note: See TracChangeset for help on using the changeset viewer.