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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a35b458 was a35b458, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

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