~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
cvs/emstar/fusd/include/fusd_msg.h


  1 /*
  2  *
  3  * Copyright (c) 2003 The Regents of the University of California.  All 
  4  * 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  *
 13  * - Neither the name of the University nor the names of its
 14  *   contributors may be used to endorse or promote products derived
 15  *   from this software without specific prior written permission.
 16  *
 17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
 18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 19  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 20  * PARTICULAR  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
 21  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 25  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28  *
 29  */
 30  
 31 
 32 /*
 33  * FUSD: the Framework for User-Space Devices
 34  *
 35  * Defines the interface between the kernel module and userspace library.
 36  *
 37  */
 38 
 39 #ifndef __FUSD_MSG_H__
 40 #define __FUSD_MSG_H__
 41 
 42 #ifndef __KERNEL__
 43 #include <inttypes.h>
 44 #endif
 45 
 46 
 47 /* filenames */
 48 #define DEFAULT_DEV_ROOT           "/dev/"
 49 #define FUSD_CONTROL_FILENAME      "fusd/control"
 50 #define FUSD_STATUS_FILENAME       "fusd/status"
 51 #define NET_BASE_DIR               "net"
 52 
 53 #define FUSD_NET_BASE_DIR          "fusd/net/"
 54 #define FUSD_NET_LOG_FILENAME      FUSD_NET_BASE_DIR "log"
 55 #define FUSD_NET_COMMAND_FILENAME  FUSD_NET_BASE_DIR "command"
 56 #define FUSD_NET_STATUS_FILENAME   FUSD_NET_BASE_DIR "status"
 57 #define FUSD_NET_INT_FILENAME      FUSD_NET_BASE_DIR ".int"
 58 
 59 #define FUSD_CONTROL_DEVNAME       DEFAULT_DEV_ROOT FUSD_CONTROL_FILENAME
 60 #define FUSD_STATUS_DEVNAME        DEFAULT_DEV_ROOT FUSD_STATUS_FILENAME
 61 #define FUSD_NET_LOG_DEVNAME       DEFAULT_DEV_ROOT FUSD_NET_LOG_FILENAME
 62 #define FUSD_NET_COMMAND_DEVNAME   DEFAULT_DEV_ROOT FUSD_NET_COMMAND_FILENAME
 63 #define FUSD_NET_STATUS_DEVNAME    DEFAULT_DEV_ROOT FUSD_NET_STATUS_FILENAME
 64 #define FUSD_NET_INT_DEVNAME       DEFAULT_DEV_ROOT FUSD_NET_INT_FILENAME
 65 
 66 /* ioctl number to tell FUSD status device to return binary info */
 67 #define FUSD_STATUS_USE_BINARY     _IO('F', 100)
 68 
 69 /* ioctl number to support non-devfs FUSD daemon */
 70 #define FUSD_STATUS_I_AM_FUSDD     _IO('F', 101)
 71 /* ioctl number to query whether this is a DevFS system */
 72 #define FUSD_STATUS_NO_DEVFS       _IO('F', 102)
 73 
 74 /* constants */
 75 #define FUSD_MAX_NAME_LENGTH       47 /* 47, to avoid expanding union size */
 76 
 77 
 78 /* commands */
 79 #define FUSD_REGISTER_DEVICE       0 /* device registration */
 80 #define FUSD_UNREGISTER_DEVICE     1 /* device unregistration */
 81 
 82 /* these two must have successive numbers */
 83 #define FUSD_FOPS_CALL             2 /* synchronous round-trip call: request */
 84 #define FUSD_FOPS_REPLY            (FUSD_FOPS_CALL + 1)
 85 
 86 /* these two must have successive numbers */
 87 #define FUSD_FOPS_NONBLOCK         4 /* call that does not block for a reply */
 88 #define FUSD_FOPS_NONBLOCK_REPLY   (FUSD_FOPS_NONBLOCK + 1)
 89 
 90 #define FUSD_FOPS_CALL_DROPREPLY   6 /* call that doesn't want a reply */
 91 
 92 /* fusdnet internal message types */
 93 #define FUSD_NET_MESSAGE           10
 94 #define FUSD_NET_SUBOP_CONNECT     110
 95 
 96 /* subcommands */
 97 #define FUSD_OPEN                  100
 98 #define FUSD_CLOSE                 101
 99 #define FUSD_READ                  102
100 #define FUSD_WRITE                 103
101 #define FUSD_IOCTL                 104
102 #define FUSD_POLL_DIFF             105
103 #define FUSD_UNBLOCK               106
104 
105 /* other constants */
106 #define FUSD_MSG_MAGIC      0x7a6b93cf
107 
108 /* user->kernel: register a device */
109 typedef struct {
110   char name[FUSD_MAX_NAME_LENGTH+1];
111   mode_t mode;
112   void *device_info;
113 } register_msg_t;
114 
115 
116 /* kernel->user: fops request message (common data) */
117 typedef struct {
118   pid_t pid;
119   uid_t uid;
120   gid_t gid;
121   unsigned int flags;           /* flags from file struct */
122   void *device_info;            /* device info */
123   void *private_info;           /* file info */
124 
125   /* parameters and return values for various calls.  should be a
126    * union but it just makes things too complex and doesn't save all
127    * that much memory anyway */
128   ssize_t retval;
129   size_t length;
130   loff_t offset;
131   unsigned int cmd;  /* ioctl cmd, poll_diff cached_state */
132   unsigned long arg; /* ioctl */
133 
134   /* the following are cookies that have meaning internal to the kernel
135    * but must be returned, untouched, by userspace */
136   void *fusd_file;
137   long transid;
138   int hint;
139 } fops_msg_t;
140 
141 
142 /* the message struct written to FUSD control channel */
143 typedef struct {
144   int magic;
145   short int cmd;
146   short int subcmd;
147 
148   char *data;  /* yes, it's slightly inefficient to push this useless
149                 * pointer between user and kernel space, but it makes
150                 * it much easier to have a pointer available in this
151                 * structure that both the kernel and userlib can make
152                 * their own use of. */
153   int datalen;
154   union {
155     register_msg_t register_msg; /* device registration (U->K) */
156     fops_msg_t fops_msg;        /* U->K and K->U fops messages */
157   } parm;
158 } fusd_msg_t;
159 
160 
161 /* structure read from FUSD binary status device */
162 typedef struct {
163   char name[FUSD_MAX_NAME_LENGTH+1];
164   int zombie:1;
165   int unmade:1;
166   int full_mode:1;
167   int reserved:29;
168   pid_t pid;
169   int num_open;
170   uint16_t major;
171   uint16_t minor;
172 } fusd_status_t;
173 
174 
175 /*  
176  *  non-devfs minor numbers
177  */
178 
179 #define FUSD_DEV_MAJOR       242
180 #define FUSD_CONTROL_MINOR     0
181 #define FUSD_STATUS_MINOR      1
182 #define FUSD_DEV_MINOR         2
183 
184 
185 /*
186  *  FUSDnet Port
187  */
188 
189 #define FUSD_NET_PORT       1212
190 
191 #endif /* __FUSD_MSG_H__ */
192 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.