| 1 | /*
|
|---|
| 2 | * Copyright (c) 2010 Lenka Trochtova
|
|---|
| 3 | * Copyright (c) 2012 Jiri Svoboda
|
|---|
| 4 | * All rights reserved.
|
|---|
| 5 | *
|
|---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 7 | * modification, are permitted provided that the following conditions
|
|---|
| 8 | * are met:
|
|---|
| 9 | *
|
|---|
| 10 | * - Redistributions of source code must retain the above copyright
|
|---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
|---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 14 | * documentation and/or other materials provided with the distribution.
|
|---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
|---|
| 16 | * derived from this software without specific prior written permission.
|
|---|
| 17 | *
|
|---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 28 | */
|
|---|
| 29 |
|
|---|
| 30 | /** @addtogroup libdrv
|
|---|
| 31 | * @{
|
|---|
| 32 | */
|
|---|
| 33 | /** @file
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| 36 | #ifndef DDF_PRIVATE_DRIVER_H_
|
|---|
| 37 | #define DDF_PRIVATE_DRIVER_H_
|
|---|
| 38 |
|
|---|
| 39 | #include <async.h>
|
|---|
| 40 | #include <refcount.h>
|
|---|
| 41 | #include <ipc/devman.h>
|
|---|
| 42 | #include <ipc/dev_iface.h>
|
|---|
| 43 | #include "dev_iface.h"
|
|---|
| 44 |
|
|---|
| 45 | /** Device structure */
|
|---|
| 46 | struct ddf_dev {
|
|---|
| 47 | /**
|
|---|
| 48 | * Globally unique device identifier (assigned to the device by the
|
|---|
| 49 | * device manager).
|
|---|
| 50 | */
|
|---|
| 51 | devman_handle_t handle;
|
|---|
| 52 |
|
|---|
| 53 | /** Reference count */
|
|---|
| 54 | atomic_refcount_t refcnt;
|
|---|
| 55 |
|
|---|
| 56 | /** Session with the parent device driver */
|
|---|
| 57 | async_sess_t *parent_sess;
|
|---|
| 58 |
|
|---|
| 59 | /** Device name */
|
|---|
| 60 | char *name;
|
|---|
| 61 |
|
|---|
| 62 | /** Driver-specific data associated with this device */
|
|---|
| 63 | void *driver_data;
|
|---|
| 64 |
|
|---|
| 65 | /** Link in the list of devices handled by the driver */
|
|---|
| 66 | link_t link;
|
|---|
| 67 | };
|
|---|
| 68 |
|
|---|
| 69 | /** Function structure */
|
|---|
| 70 | struct ddf_fun {
|
|---|
| 71 | /** True if bound to the device manager */
|
|---|
| 72 | bool bound;
|
|---|
| 73 |
|
|---|
| 74 | /** Function indentifier (asigned by device manager) */
|
|---|
| 75 | devman_handle_t handle;
|
|---|
| 76 |
|
|---|
| 77 | /** Reference count */
|
|---|
| 78 | atomic_refcount_t refcnt;
|
|---|
| 79 |
|
|---|
| 80 | /** Device which this function belogs to */
|
|---|
| 81 | struct ddf_dev *dev;
|
|---|
| 82 |
|
|---|
| 83 | /** Function type */
|
|---|
| 84 | fun_type_t ftype;
|
|---|
| 85 |
|
|---|
| 86 | /** Function name */
|
|---|
| 87 | char *name;
|
|---|
| 88 |
|
|---|
| 89 | /** List of device ids for driver matching */
|
|---|
| 90 | match_id_list_t match_ids;
|
|---|
| 91 |
|
|---|
| 92 | /** Driver-specific data associated with this function */
|
|---|
| 93 | void *driver_data;
|
|---|
| 94 |
|
|---|
| 95 | /** Implementation of operations provided by this function */
|
|---|
| 96 | const ddf_dev_ops_t *ops;
|
|---|
| 97 |
|
|---|
| 98 | /** Connection handler or @c NULL to use the DDF default handler. */
|
|---|
| 99 | async_port_handler_t conn_handler;
|
|---|
| 100 |
|
|---|
| 101 | /** Link in the list of functions handled by the driver */
|
|---|
| 102 | link_t link;
|
|---|
| 103 | };
|
|---|
| 104 |
|
|---|
| 105 | #endif
|
|---|
| 106 |
|
|---|
| 107 | /**
|
|---|
| 108 | * @}
|
|---|
| 109 | */
|
|---|