XINU
rdisksys.h
Go to the documentation of this file.
1 /* rdisksys.h - definitions for remote disk system pseudo-devices */
2 
3 #ifndef Nrds
4 #define Nrds 1
5 #endif
6 
7 /* Remote disk block size */
8 
9 #define RD_BLKSIZ 512
10 
11 /* Global data for the remote disk server */
12 
13 #ifndef RD_SERVER_IP
14 #define RD_SERVER_IP "255.255.255.255"
15 #endif
16 
17 #ifndef RD_SERVER_PORT
18 #define RD_SERVER_PORT 33124
19 #endif
20 
21 #ifndef RD_LOC_PORT
22 #define RD_LOC_PORT 33124 /* Base port number - minor dev */
23  /* number is added to insure */
24  /* that each device is unique */
25 #endif
26 
27 /* Control block for remote disk device */
28 
29 #define RD_IDLEN 64 /* Size of a remote disk ID */
30 #define RD_BUFFS 64 /* Number of disk buffers */
31 #define RD_STACK 16384 /* Stack size for comm. process */
32 #define RD_PRIO 200 /* Priorty of comm. process */
33 
34 /* Constants for state of the device */
35 
36 #define RD_FREE 0 /* Device is available */
37 #define RD_OPEN 1 /* Device is open (in use) */
38 #define RD_PEND 2 /* Open is pending */
39 
40 /* Operations for request queue */
41 
42 #define RD_OP_READ 1 /* Read operation on req. list */
43 #define RD_OP_WRITE 2 /* Write operation on req. list */
44 #define RD_OP_SYNC 3 /* Sync operation on req. list */
45 
46 /* Status values for a buffer */
47 
48 #define RD_VALID 0 /* Buffer contains valid data */
49 #define RD_INVALID 1 /* Buffer does not contain data */
50 
51 /* Definition of a buffer with a header that allows the same node to be */
52 /* used as a request on the request queue, an item in the cache, or a */
53 /* node on the free list of buffers */
54 
55 struct rdbuff { /* Request list node */
56  struct rdbuff *rd_next; /* Ptr to next node on a list */
57  struct rdbuff *rd_prev; /* Ptr to prev node on a list */
58  int32 rd_op; /* Operation - read/write/sync */
59  int32 rd_refcnt; /* Reference count of processes */
60  /* reading the block */
61  uint32 rd_blknum; /* Block number of this block */
62  int32 rd_status; /* Is buffer currently valid? */
63  pid32 rd_pid; /* Process that initiated a */
64  /* read request for the block */
65  char rd_block[RD_BLKSIZ]; /* Space to hold one disk block */
66 };
67 
68 struct rdscblk {
69  int32 rd_state; /* State of device */
70  char rd_id[RD_IDLEN]; /* Disk ID currently being used */
71  int32 rd_seq; /* Next sequence number to use */
72  /* Request queue head and tail */
73  struct rdbuff *rd_rhnext; /* Head of request queue: next */
74  struct rdbuff *rd_rhprev; /* and previous */
75  struct rdbuff *rd_rtnext; /* Tail of request queue: next */
76  struct rdbuff *rd_rtprev; /* (null) and previous */
77 
78  /* Cache head and tail */
79 
80  struct rdbuff *rd_chnext; /* Head of cache: next and */
81  struct rdbuff *rd_chprev; /* previous */
82  struct rdbuff *rd_ctnext; /* Tail of cache: next (null) */
83  struct rdbuff *rd_ctprev; /* and previous */
84 
85  /* Free list head (singly-linked) */
86 
87  struct rdbuff *rd_free; /* Pointer to free list */
88 
89  pid32 rd_comproc; /* Process ID of comm. process */
90  bool8 rd_comruns; /* Has comm. process started? */
91  sid32 rd_availsem; /* Semaphore ID for avail buffs */
92  sid32 rd_reqsem; /* Semaphore ID for requests */
93  uint32 rd_ser_ip; /* Server IP address */
94  uint16 rd_ser_port; /* Server UDP port */
95  uint16 rd_loc_port; /* Local (client) UPD port */
96  bool8 rd_registered; /* Has UDP port been registered?*/
97  int32 rd_udpslot; /* Registered UDP slot */
98 };
99 
100 
101 extern struct rdscblk rdstab[]; /* Remote disk control block */
102 
103 /* Definitions of parameters used during server access */
104 
105 #define RD_RETRIES 3 /* Times to retry sending a msg */
106 #define RD_TIMEOUT 2000 /* Timeout for reply (2 seconds)*/
107 
108 /* Control functions for a remote file pseudo device */
109 
110 #define RDS_CTL_DEL 1 /* Delete (erase) an entire disk*/
111 #define RDS_CTL_SYNC 2 /* Write all pending blocks */
112 
113 /************************************************************************/
114 /* Definition of messages exchanged with the remote disk server */
115 /************************************************************************/
116 /* Values for the type field in messages */
117 
118 #define RD_MSG_RESPONSE 0x0100 /* Bit that indicates response */
119 
120 #define RD_MSG_RREQ 0x0010 /* Read request and response */
121 #define RD_MSG_RRES (RD_MSG_RREQ | RD_MSG_RESPONSE)
122 
123 #define RD_MSG_WREQ 0x0020 /* Write request and response */
124 #define RD_MSG_WRES (RD_MSG_WREQ | RD_MSG_RESPONSE)
125 
126 #define RD_MSG_OREQ 0x0030 /* Open request and response */
127 #define RD_MSG_ORES (RD_MSG_OREQ | RD_MSG_RESPONSE)
128 
129 #define RD_MSG_CREQ 0x0040 /* Close request and response */
130 #define RD_MSG_CRES (RD_MSG_CREQ | RD_MSG_RESPONSE)
131 
132 #define RD_MSG_DREQ 0x0050 /* Delete request and response */
133 #define RD_MSG_DRES (RD_MSG_DREQ | RD_MSG_RESPONSE)
134 
135 #define RD_MIN_REQ RD_MSG_RREQ /* Minimum request type */
136 #define RD_MAX_REQ RD_MSG_DREQ /* Maximum request type */
137 
138 /* Message header fields present in each message */
139 
140 #define RD_MSG_HDR /* Common message fields */\
141  uint16 rd_type; /* Message type */\
142  uint16 rd_status; /* 0 in req, status in response */\
143  uint32 rd_seq; /* Message sequence number */\
144  char rd_id[RD_IDLEN]; /* Null-terminated disk ID */
145 
146 /************************************************************************/
147 /* Header */
148 /************************************************************************/
149 /* The standard header present in all messages with no extra fields */
150 #pragma pack(2)
151 struct rd_msg_hdr { /* Header fields present in each*/
152  RD_MSG_HDR /* remote file system message */
153 };
154 #pragma pack()
155 
156 /************************************************************************/
157 /* Read */
158 /************************************************************************/
159 #pragma pack(2)
160 struct rd_msg_rreq { /* Remote file read request */
161  RD_MSG_HDR /* Header fields */
162  uint32 rd_blk; /* Block number to read */
163 };
164 #pragma pack()
165 
166 #pragma pack(2)
167 struct rd_msg_rres { /* Remote file read reply */
168  RD_MSG_HDR /* Header fields */
169  uint32 rd_blk; /* Block number that was read */
170  char rd_data[RD_BLKSIZ]; /* Array containing one block */
171 };
172 #pragma pack()
173 
174 /************************************************************************/
175 /* Write */
176 /************************************************************************/
177 #pragma pack(2)
178 struct rd_msg_wreq { /* Remote file write request */
179  RD_MSG_HDR /* Header fields */
180  uint32 rd_blk; /* Block number to write */
181  char rd_data[RD_BLKSIZ]; /* Array containing one block */
182 };
183 #pragma pack()
184 
185 #pragma pack(2)
186 struct rd_msg_wres { /* Remote file write response */
187  RD_MSG_HDR /* Header fields */
188  uint32 rd_blk; /* Block number that was written*/
189 };
190 #pragma pack()
191 
192 /************************************************************************/
193 /* Open */
194 /************************************************************************/
195 #pragma pack(2)
196 struct rd_msg_oreq { /* Remote file open request */
197  RD_MSG_HDR /* Header fields */
198 };
199 #pragma pack()
200 
201 #pragma pack(2)
202 struct rd_msg_ores { /* Remote file open response */
203  RD_MSG_HDR /* Header fields */
204 };
205 #pragma pack()
206 
207 /************************************************************************/
208 /* Close */
209 /************************************************************************/
210 #pragma pack(2)
211 struct rd_msg_creq { /* Remote file close request */
212  RD_MSG_HDR /* Header fields */
213 };
214 #pragma pack()
215 
216 #pragma pack(2)
217 struct rd_msg_cres { /* Remote file close response */
218  RD_MSG_HDR /* Header fields */
219 };
220 #pragma pack()
221 
222 /************************************************************************/
223 /* Delete */
224 /************************************************************************/
225 #pragma pack(2)
226 struct rd_msg_dreq { /* Remote file delete request */
227  RD_MSG_HDR /* Header fields */
228 };
229 #pragma pack()
230 
231 #pragma pack(2)
232 struct rd_msg_dres { /* Remote file delete response */
233  RD_MSG_HDR /* Header fields */
234 };
235 #pragma pack()
int32 rd_udpslot
Definition: rdisksys.h:97
uint16 rd_loc_port
Definition: rdisksys.h:95
uint32 rd_ser_ip
Definition: rdisksys.h:93
#define RD_BLKSIZ
Definition: rdisksys.h:9
sid32 rd_reqsem
Definition: rdisksys.h:92
int32 rd_op
Definition: rdisksys.h:58
#define RD_MSG_HDR
Definition: rdisksys.h:140
bool8 rd_registered
Definition: rdisksys.h:96
struct rdbuff * rd_rtnext
Definition: rdisksys.h:75
#define RD_IDLEN
Definition: rdisksys.h:29
int32 rd_status
Definition: rdisksys.h:62
sid32 rd_availsem
Definition: rdisksys.h:91
byte bool8
Boolean値
Definition: kernel.h:36
pid32 rd_comproc
Definition: rdisksys.h:89
bool8 rd_comruns
Definition: rdisksys.h:90
struct rdbuff * rd_chprev
Definition: rdisksys.h:81
RD_MSG_HDR uint32 rd_blk
Definition: rdisksys.h:169
RD_MSG_HDR uint32 rd_blk
Definition: rdisksys.h:180
uint16 rd_ser_port
Definition: rdisksys.h:94
struct rdbuff * rd_free
Definition: rdisksys.h:87
struct rdbuff * rd_prev
Definition: rdisksys.h:57
struct rdbuff * rd_rhnext
Definition: rdisksys.h:73
struct rdbuff * rd_rhprev
Definition: rdisksys.h:74
RD_MSG_HDR uint32 rd_blk
Definition: rdisksys.h:162
struct rdscblk rdstab[]
Definition: rdsinit.c:11
int int32
符号あり32ビット整数(int)
Definition: kernel.h:11
int32 rd_refcnt
Definition: rdisksys.h:59
struct rdbuff * rd_next
Definition: rdisksys.h:56
unsigned short uint16
符号なし16ビット整数(unsigned short)
Definition: kernel.h:17
pid32 rd_pid
Definition: rdisksys.h:63
struct rdbuff * rd_rtprev
Definition: rdisksys.h:76
int32 rd_seq
Definition: rdisksys.h:71
struct rdbuff * rd_ctnext
Definition: rdisksys.h:82
int32 pid32
プロセスID
Definition: kernel.h:26
struct rdbuff * rd_ctprev
Definition: rdisksys.h:83
struct rdbuff * rd_chnext
Definition: rdisksys.h:80
int32 rd_state
Definition: rdisksys.h:69
unsigned int uint32
符号なし32ビット整数(unsigned int)
Definition: kernel.h:15
RD_MSG_HDR uint32 rd_blk
Definition: rdisksys.h:188
char rd_block[RD_BLKSIZ]
Definition: rdisksys.h:65
uint32 rd_blknum
Definition: rdisksys.h:61
int32 sid32
セマフォID
Definition: kernel.h:22