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