source: mainline/uspace/lib/drv/include/ddf/driver.h@ 09ab0a9a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 09ab0a9a was 09ab0a9a, checked in by Jiri Svoboda <jiri@…>, 7 years ago

Fix vertical spacing with new Ccheck revision.

  • Property mode set to 100644
File size: 4.3 KB
RevLine 
[c16cf62]1/*
[a1769ee]2 * Copyright (c) 2010 Lenka Trochtova
[af6b5157]3 * Copyright (c) 2011 Jiri Svoboda
[c16cf62]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 */
[7a252ec8]35
[af6b5157]36#ifndef DDF_DRIVER_H_
37#define DDF_DRIVER_H_
[c16cf62]38
[79ae36dd]39#include <async.h>
[bda60d9]40#include <ipc/devman.h>
[a1769ee]41#include <ipc/dev_iface.h>
[af6b5157]42#include "../dev_iface.h"
[22027b6e]43
[97adec8]44/*
[af6b5157]45 * Device
[97adec8]46 */
[3843ecb]47
[56fd7cf]48typedef struct ddf_dev ddf_dev_t;
49typedef struct ddf_fun ddf_fun_t;
50
[97adec8]51/** Devices operations */
[83a2f43]52typedef struct ddf_dev_ops {
[7a252ec8]53 /**
54 * Optional callback function called when a client is connecting to the
55 * device.
56 */
[b7fd2a0]57 errno_t (*open)(ddf_fun_t *);
[a35b458]58
[7a252ec8]59 /**
60 * Optional callback function called when a client is disconnecting from
61 * the device.
62 */
[83a2f43]63 void (*close)(ddf_fun_t *);
[a35b458]64
[08d9525a]65 /** The table of standard interfaces implemented by the device. */
[7a252ec8]66 void *interfaces[DEV_IFACE_COUNT];
[a35b458]67
[7a252ec8]68 /**
69 * The default handler of remote client requests. If the client's remote
70 * request cannot be handled by any of the standard interfaces, the
71 * default handler is used.
72 */
[08d9525a]73 remote_handler_t *default_handler;
[83a2f43]74} ddf_dev_ops_t;
[3843ecb]75
[97adec8]76/** Device structure */
[56fd7cf]77struct ddf_dev;
[c16cf62]78
[8b1e15ac]79/** Function structure */
[56fd7cf]80struct ddf_fun;
[8b1e15ac]81
[97adec8]82/*
83 * Driver
84 */
[a1769ee]85
[97adec8]86/** Generic device driver operations */
[a1769ee]87typedef struct driver_ops {
[97adec8]88 /** Callback method for passing a new device to the device driver */
[b7fd2a0]89 errno_t (*dev_add)(ddf_dev_t *);
[a35b458]90
[1a5b252]91 /** Ask driver to remove a device */
[b7fd2a0]92 errno_t (*dev_remove)(ddf_dev_t *);
[a35b458]93
[80a96d2]94 /** Inform driver a device disappeared */
[b7fd2a0]95 errno_t (*dev_gone)(ddf_dev_t *);
[a35b458]96
[1a5b252]97 /** Ask driver to online a specific function */
[b7fd2a0]98 errno_t (*fun_online)(ddf_fun_t *);
[a35b458]99
[1a5b252]100 /** Ask driver to offline a specific function */
[b7fd2a0]101 errno_t (*fun_offline)(ddf_fun_t *);
[c16cf62]102} driver_ops_t;
103
[97adec8]104/** Driver structure */
[c16cf62]105typedef struct driver {
[97adec8]106 /** Name of the device driver */
[c16cf62]107 const char *name;
[97adec8]108 /** Generic device driver operations */
[6da3ef46]109 const driver_ops_t *driver_ops;
[c16cf62]110} driver_t;
111
[0c322fa]112extern int ddf_driver_main(const driver_t *);
[c16cf62]113
[c5be39b]114extern void *ddf_dev_data_alloc(ddf_dev_t *, size_t);
[56fd7cf]115extern void *ddf_dev_data_get(ddf_dev_t *);
116extern devman_handle_t ddf_dev_get_handle(ddf_dev_t *);
117extern const char *ddf_dev_get_name(ddf_dev_t *);
118extern async_sess_t *ddf_dev_parent_sess_get(ddf_dev_t *);
[83a2f43]119extern ddf_fun_t *ddf_fun_create(ddf_dev_t *, fun_type_t, const char *);
[56fd7cf]120extern devman_handle_t ddf_fun_get_handle(ddf_fun_t *);
[83a2f43]121extern void ddf_fun_destroy(ddf_fun_t *);
[c5be39b]122extern void *ddf_fun_data_alloc(ddf_fun_t *, size_t);
[56fd7cf]123extern void *ddf_fun_data_get(ddf_fun_t *);
124extern const char *ddf_fun_get_name(ddf_fun_t *);
[b7fd2a0]125extern errno_t ddf_fun_set_name(ddf_fun_t *, const char *);
[56fd7cf]126extern ddf_dev_t *ddf_fun_get_dev(ddf_fun_t *);
[b7fd2a0]127extern errno_t ddf_fun_bind(ddf_fun_t *);
128extern errno_t ddf_fun_unbind(ddf_fun_t *);
129extern errno_t ddf_fun_online(ddf_fun_t *);
130extern errno_t ddf_fun_offline(ddf_fun_t *);
131extern errno_t ddf_fun_add_match_id(ddf_fun_t *, const char *, int);
[facc34d]132extern void ddf_fun_set_ops(ddf_fun_t *, const ddf_dev_ops_t *);
[b688fd8]133extern void ddf_fun_set_conn_handler(ddf_fun_t *, async_port_handler_t);
[b7fd2a0]134extern errno_t ddf_fun_add_to_category(ddf_fun_t *, const char *);
[692c40cb]135
[c16cf62]136#endif
137
138/**
139 * @}
[a1769ee]140 */
Note: See TracBrowser for help on using the repository browser.