Changeset 3b5d1535 in mainline for uspace/lib/drv/include/ddf/driver.h


Ignore:
Timestamp:
2011-02-23T10:28:21Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
eb48f61
Parents:
e936e8e (diff), eb1a2f4 (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:

Merge mainline changes

File:
1 moved

Legend:

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

    re936e8e r3b5d1535  
    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 <sys/types.h>
    39 #include <kernel/ddi/irq.h>
    40 #include <adt/list.h>
    41 #include <devman.h>
    4239#include <ipc/devman.h>
    4340#include <ipc/dev_iface.h>
    44 #include <assert.h>
    45 #include <ddi.h>
    46 #include <libarch/ddi.h>
    47 #include <fibril_synch.h>
    48 #include <malloc.h>
    4941
    50 #include "dev_iface.h"
     42#include "../dev_iface.h"
    5143
    52 struct device;
    53 typedef struct device device_t;
     44typedef struct ddf_dev ddf_dev_t;
     45typedef struct ddf_fun ddf_fun_t;
    5446
    5547/*
    56  * Device class
     48 * Device
    5749 */
    5850
    5951/** Devices operations */
    60 typedef struct device_ops {
     52typedef struct ddf_dev_ops {
    6153        /**
    6254         * Optional callback function called when a client is connecting to the
    6355         * device.
    6456         */
    65         int (*open)(device_t *);
     57        int (*open)(ddf_fun_t *);
    6658       
    6759        /**
     
    6961         * the device.
    7062         */
    71         void (*close)(device_t *);
     63        void (*close)(ddf_fun_t *);
    7264       
    7365        /** The table of standard interfaces implemented by the device. */
     
    8072         */
    8173        remote_handler_t *default_handler;
    82 } device_ops_t;
    83 
    84 
    85 /*
    86  * Device
    87  */
     74} ddf_dev_ops_t;
    8875
    8976/** Device structure */
    90 struct device {
     77struct ddf_dev {
    9178        /**
    9279         * Globally unique device identifier (assigned to the device by the
     
    10188        int parent_phone;
    10289       
    103         /** Parent device if handled by this driver, NULL otherwise */
    104         device_t *parent;
    10590        /** Device name */
    10691        const char *name;
    107         /** List of device ids for device-to-driver matching */
    108         match_id_list_t match_ids;
     92       
    10993        /** Driver-specific data associated with this device */
    11094        void *driver_data;
    111         /** The implementation of operations provided by this device */
    112         device_ops_t *ops;
    11395       
    11496        /** 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 */
    115122        link_t link;
    116123};
     
    123130typedef struct driver_ops {
    124131        /** Callback method for passing a new device to the device driver */
    125         int (*add_device)(device_t *dev);
     132        int (*add_device)(ddf_dev_t *dev);
    126133        /* TODO: add other generic driver operations */
    127134} driver_ops_t;
     
    135142} driver_t;
    136143
    137 int driver_main(driver_t *);
     144extern int ddf_driver_main(driver_t *);
    138145
    139 /** Create new device structure.
    140  *
    141  * @return              The device structure.
    142  */
    143 extern device_t *create_device(void);
    144 extern void delete_device(device_t *);
    145 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);
    146150
    147 extern int child_device_register(device_t *, device_t *);
    148 extern int child_device_register_wrapper(device_t *, const char *, const char *,
    149     int, devman_handle_t *);
    150 
    151 /*
    152  * Interrupts
    153  */
    154 
    155 typedef void interrupt_handler_t(device_t *, ipc_callid_t, ipc_call_t *);
    156 
    157 typedef struct interrupt_context {
    158         int id;
    159         device_t *dev;
    160         int irq;
    161         interrupt_handler_t *handler;
    162         link_t link;
    163 } interrupt_context_t;
    164 
    165 typedef struct interrupt_context_list {
    166         int curr_id;
    167         link_t contexts;
    168         fibril_mutex_t mutex;
    169 } interrupt_context_list_t;
    170 
    171 extern interrupt_context_t *create_interrupt_context(void);
    172 extern void delete_interrupt_context(interrupt_context_t *);
    173 extern void init_interrupt_context_list(interrupt_context_list_t *);
    174 extern void add_interrupt_context(interrupt_context_list_t *,
    175     interrupt_context_t *);
    176 extern void remove_interrupt_context(interrupt_context_list_t *,
    177     interrupt_context_t *);
    178 extern interrupt_context_t *find_interrupt_context_by_id(
    179     interrupt_context_list_t *, int);
    180 extern interrupt_context_t *find_interrupt_context(
    181     interrupt_context_list_t *, device_t *, int);
    182 
    183 extern int register_interrupt_handler(device_t *, int, interrupt_handler_t *,
    184     irq_code_t *);
    185 extern int unregister_interrupt_handler(device_t *, int);
    186 
    187 extern remote_handler_t *device_get_default_handler(device_t *);
    188 extern int add_device_to_class(device_t *, const char *);
     151extern int ddf_fun_add_to_class(ddf_fun_t *, const char *);
    189152
    190153#endif
Note: See TracChangeset for help on using the changeset viewer.