1 #ifndef _SERVERS_DEVMAN_DEVMAN_H 2 #define _SERVERS_DEVMAN_DEVMAN_H 3 #define _SYSTEM 1 /* tell headers that this is the kernel */ 4 #define DEVMAN_SERVER 1 5 6 #include <minix/config.h> 7 #include <errno.h> 8 #include <unistd.h> 9 #include <stdlib.h> 10 #include <stdio.h> 11 #include <string.h> 12 #include <lib.h> 13 #include <minix/timers.h> 14 15 #include <minix/callnr.h> 16 #include <minix/type.h> 17 #include <minix/const.h> 18 #include <minix/com.h> 19 #include <minix/syslib.h> 20 #include <minix/sysutil.h> 21 #include <minix/vfsif.h> 22 #include <minix/endpoint.h> 23 #include <minix/sysinfo.h> 24 #include <minix/u64.h> 25 #include <minix/sysinfo.h> 26 #include <minix/type.h> 27 #include <minix/ipc.h> 28 29 #include <sys/time.h> 30 #include <sys/times.h> 31 #include <sys/types.h> 32 #include <sys/stat.h> 33 34 #include <minix/vtreefs.h> 35 36 #include <minix/devman.h> 37 #include <sys/queue.h> 38 39 #define DEVMAN_DEFAULT_MODE (S_IRUSR | S_IRGRP | S_IROTH) 40 #define DEVMAN_STRING_LEN 128 41 42 #define ADD_STRING "ADD " 43 #define REMOVE_STRING "REMOVE " 44 45 enum devman_inode_type { 46 DEVMAN_DEVINFO_STATIC, 47 DEVMAN_DEVINFO_DYNAMIC, 48 DEVMAN_DEVICE 49 }; 50 51 typedef int (*devman_read_fn) 52 (char **ptr, size_t *len, off_t offset, void *data); 53 54 struct devman_device_file { 55 int minor; 56 int type; 57 }; 58 59 struct devman_static_info_inode { 60 struct devman_device *dev; 61 char data[DEVMAN_STRING_LEN]; 62 }; 63 64 struct devman_event { 65 char data[DEVMAN_STRING_LEN]; 66 TAILQ_ENTRY(devman_event) events; 67 }; 68 69 struct devman_event_inode { 70 TAILQ_HEAD(event_head, devman_event) event_queue; 71 }; 72 73 struct devman_inode { 74 struct inode *inode; 75 devman_read_fn read_fn; 76 void *data; 77 TAILQ_ENTRY(devman_inode) inode_list; 78 }; 79 80 struct devman_device { 81 int dev_id; 82 char * name; 83 84 int ref_count; 85 86 int major; 87 #define DEVMAN_DEVICE_ZOMBIE 2 88 #define DEVMAN_DEVICE_BOUND 1 89 #define DEVMAN_DEVICE_UNBOUND 0 90 int state; 91 92 endpoint_t owner; 93 94 struct devman_inode inode; 95 struct devman_device *parent; 96 97 /* the serialized information on this device */ 98 struct devman_device_info *info; 99 100 TAILQ_ENTRY(devman_device) siblings; 101 102 /* devices attached to the this device */ 103 TAILQ_HEAD(children_head, devman_device) children; 104 TAILQ_HEAD(info_head, devman_inode) infos; 105 }; 106 #endif 107