UbixOS V2 2.0

device.h
Go to the documentation of this file.
1 /*-
2 * Copyright (c) 2002-2018 The UbixOS Project.
3 * All rights reserved.
4 *
5 * This was developed by Christopher W. Olsen for the UbixOS Project.
6 *
7 * Redistribution and use in source and binary forms, with or without modification, are permitted
8 * provided that the following conditions are met:
9 *
10 * 1) Redistributions of source code must retain the above copyright notice, this list of
11 * conditions, the following disclaimer and the list of authors.
12 * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13 * conditions, the following disclaimer and the list of authors in the documentation and/or
14 * other materials provided with the distribution.
15 * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16 * endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef _SYS_DEVICE_H
30 #define _SYS_DEVICE_H
31
32 #include <sys/types.h>
33
34 struct device_node {
35 struct device_node *prev;
36 struct device_node *next;
37 struct device_interface *devInfo;
38 struct device_resource *devRec;
39 char type;
40 int minor;
41 };
42
43 struct device_resource {
44 uInt8 irq;
45 };
46
47 struct device_interface {
48 uInt8 initialized;
49 uInt32 size;
50 int major;
51 void *info;
52 int (*read)(void *, void *, uInt32, uInt32);
53 int (*write)(void *, void *, uInt32, uInt32);
54 void (*reset)(void *);
55 int (*init)(void *);
56 void (*ioctl)(void *);
57 void (*stop)(void *);
58 void (*start)(void *);
59 void (*standby)(void *);
60 };
61
62 int device_add(int, char, struct device_interface *);
63 struct device_node *device_find(int major, int minor);
64 int device_remove(struct device_node *);
65
66 #endif /* END _SYS_DEVICE_H */
device_node::type
char type
Definition: device.h:39
device_interface::initialized
uInt8 initialized
Definition: device.h:48
device_resource
Definition: device.h:43
device_interface
Definition: device.h:47
device_node::next
struct device_node * next
Definition: device.h:36
uInt32
unsigned long int uInt32
Definition: objgfx30.h:49
device_interface::stop
void(* stop)(void *)
Definition: device.h:57
device_node::prev
struct device_node * prev
Definition: device.h:35
device_interface::ioctl
void(* ioctl)(void *)
Definition: device.h:56
device_add
int device_add(int, char, struct device_interface *)
Definition: device.c:49
types.h
device_interface::size
uInt32 size
Definition: device.h:49
device_interface::standby
void(* standby)(void *)
Definition: device.h:59
device_node::minor
int minor
Definition: device.h:40
device_interface::start
void(* start)(void *)
Definition: device.h:58
device_resource::irq
uInt8 irq
Definition: device.h:44
device_node
Definition: device.h:34
uInt8
unsigned char uInt8
Definition: objgfx30.h:47
device_interface::init
int(* init)(void *)
Definition: device.h:55
device_interface::reset
void(* reset)(void *)
Definition: device.h:54
device_interface::write
int(* write)(void *, void *, uInt32, uInt32)
Definition: device.h:53
device_node::devRec
struct device_resource * devRec
Definition: device.h:38
device_interface::read
int(* read)(void *, void *, uInt32, uInt32)
Definition: device.h:52
device_remove
int device_remove(struct device_node *)
Definition: device.c:104
device_find
struct device_node * device_find(int major, int minor)
Definition: device.c:82
device_interface::info
void * info
Definition: device.h:51
device_node::devInfo
struct device_interface * devInfo
Definition: device.h:37
device_interface::major
int major
Definition: device.h:50