Mercurial > hg > Members > kono > os9 > sbc09
annotate src/vdisk.c @ 191:d0f5894e9b3a default tip
some how load: confilicts in gmake
author | kono |
---|---|
date | Thu, 07 Dec 2023 09:37:15 +0900 |
parents | b93996f54090 |
children |
rev | line source |
---|---|
43 | 1 /******************************************************************** |
2 * Virtual RBF - Random Block File Manager | |
3 * | |
4 * Shinji KONO (kono@ie.u-ryukyu.ac.jp) 2018/7/17 | |
5 * GPL v1 license | |
6 */ | |
7 | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
8 #define engine extern |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
9 #include "v09.h" |
43 | 10 #include <stdio.h> |
11 #include <stdlib.h> | |
12 #include <unistd.h> | |
13 #include <sys/stat.h> | |
14 #include <sys/select.h> | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
15 #include <dirent.h> |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
16 #include <string.h> |
47 | 17 #include <time.h> |
49 | 18 #include <arpa/inet.h> |
61 | 19 #include <fcntl.h> |
151 | 20 #include <sys/types.h> |
43 | 21 |
62 | 22 static int vdiskdebug = 0; // bit 1 trace, bit 2 filename |
43 | 23 |
158 | 24 extern char *prog ; // for disass |
25 #ifdef USE_MMU | |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
26 Byte pmmu[8]; // process dat mmu |
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
27 |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
28 extern Byte * mem0(Byte *iphymem, Word adr, Byte *immu) ; |
47 | 29 // smem physical address using system mmu |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
30 // pmem physical address using caller's mmu |
46 | 31 #define smem(a) mem0(phymem,a,&mem[0x20+IOPAGE]) |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
32 #define pmem(a) mem0(phymem,a,pmmu) |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
33 #else |
46 | 34 #define smem(a) (&mem[a]) |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
35 #define pmem(a) (&mem[a]) |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
36 #endif |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
37 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
38 #define MAXPDV 256 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
39 |
59 | 40 /* |
41 * os9 has one path descriptor for one open file or directory | |
42 * keep coresponding information in vdisk file manager | |
43 */ | |
45 | 44 |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
45 typedef struct pathDesc { |
59 | 46 char *name; // path name relative to drvRoot |
47 FILE *fp; // file , memfile for directory | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
48 int mode; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
49 int inode ; // lower 24 bit of unix inode, os9 lsn |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
50 int num ; |
45 | 51 int sz ; // used only for directory |
52 char drv ; | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
53 char use ; |
59 | 54 char dir; // is directory? |
55 char *fd ; // simulated os9 file descriptor ( not used now) | |
56 char *dirfp; // simulated os9 directory file | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
57 } PathDesc, *PathDescPtr; |
43 | 58 |
49 | 59 static void |
60 vdisklog(Word u,PathDesc *pd, Word pdptr, int curdir,FILE *fp) ; | |
61 | |
45 | 62 #define MAXVDRV 4 |
43 | 63 |
49 | 64 static char *drvRoot[] = { ".",".",".","."}; |
65 static PathDesc pdv[MAXPDV]; | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
66 |
49 | 67 /* |
59 | 68 * byte order staff |
49 | 69 */ |
70 static inline Word | |
71 getword(Byte *adr) { | |
72 Word *padr = (Word*)adr; | |
73 return ntohs(*padr); | |
74 } | |
75 | |
76 static inline void | |
77 setword(Byte *adr,Word value) { | |
78 Word *padr = (Word*)adr; | |
79 *padr = htons(value); | |
80 } | |
81 | |
59 | 82 int |
49 | 83 setVdisk(int drv,char *name) { |
45 | 84 if (drv<0 || drv>=MAXVDRV) return -1; |
85 drvRoot[drv] = name; | |
86 return 0; | |
87 } | |
88 | |
49 | 89 static void |
90 closepd(PathDesc *pd) { | |
48
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
91 if(pd->fp) fclose(pd->fp) ; |
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
92 pd->dir = 0; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
93 pd->use = 0; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
94 pd->fp = 0; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
95 pd->mode = 0; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
96 free(pd->dirfp); pd->dirfp = 0; |
158 | 97 free(pd->name); pd->name = 0; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
98 } |
43 | 99 |
49 | 100 /* |
101 * keep track current directory ( most recently 256 entry ) | |
102 * too easy approach | |
59 | 103 * |
104 * dir command keep old directory LSN, so we have to too | |
49 | 105 */ |
106 char *cdt[512]; | |
107 static int cdtptr = 0; | |
108 | |
109 Byte | |
110 setcd(char *name) { | |
111 int len; | |
51 | 112 for(int i=0;i<512;i++) { |
49 | 113 if (cdt[i] && strcmp(name,cdt[i])==0) return i; |
114 } | |
51 | 115 cdtptr &= 0x1ff; |
49 | 116 if (cdt[cdtptr]) free(cdt[cdtptr]); |
117 cdt[cdtptr] = (char*)malloc(len=strlen(name)+1); | |
118 strcpy(cdt[cdtptr],name); | |
119 return cdtptr++; | |
120 } | |
121 | |
43 | 122 #define MAXPAHTLEN 256 |
123 | |
59 | 124 /* |
125 * print os9 string for debug | |
126 */ | |
49 | 127 static void |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
128 putOs9str(char *s,int max) { |
49 | 129 if (s==0) { |
130 printf("(null)"); | |
131 return; | |
132 } | |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
133 while(*s && (*s&0x7f)>=' ' && ((*s&0x80)==0) && --max !=0) { |
49 | 134 putchar(*s); s++; |
135 } | |
136 if (*s&0x80) putchar(*s&0x7f); | |
137 } | |
138 | |
51 | 139 static void |
140 err(int error) { | |
141 printf("err %d\n",error); | |
142 } | |
143 | |
59 | 144 /* |
145 * add current directory name to the path | |
146 * if name starts /v0, drvRoot will be add | |
147 */ | |
49 | 148 static char * |
149 addCurdir(char *name, PathDesc *pd, int curdir) { | |
46 | 150 int ns =0 ; |
47 | 151 char *n = name; |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
152 if(vdiskdebug&0x2) { printf("addcur \""); putOs9str(name,0); printf("\" cur \""); putOs9str( cdt[curdir],0); printf("\"\n"); } |
46 | 153 if (name[0]=='/') { |
49 | 154 name++; while(*name !='/' && *name!=0) name ++ ; // skip /d0 |
46 | 155 while(name[ns]!=0) ns++; |
49 | 156 } else if (!cdt[curdir] ) return 0; // no current directory |
157 else ns = strlen(name); | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
158 int ps = ns; |
45 | 159 char *base ; |
49 | 160 if (name[0]=='/') { |
161 base = drvRoot[pd->drv]; ps += strlen(drvRoot[pd->drv])+1; name++; | |
47 | 162 } else if (name[0]==0) { |
48
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
163 base = drvRoot[pd->drv]; |
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
164 char *path = (char*)malloc(strlen(base)+1); // we'll free this, malloc it. |
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
165 int i = 0; |
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
166 for(;base[i];i++) path[i] = base[i]; |
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
167 path[i]=0; |
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
168 return path; |
47 | 169 } else { |
49 | 170 base = cdt[curdir]; ps += strlen(cdt[curdir])+2; |
47 | 171 } |
49 | 172 char *path = (char*)malloc(ps); |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
173 int i = 0; |
45 | 174 for(;base[i];i++) path[i] = base[i]; |
175 path[i++] = '/'; | |
158 | 176 for(int j=0;i<ps-1;j++,i++) path[i] = name[j]; |
51 | 177 path[i] = 0; |
178 if (i>ps) | |
179 printf("overrun i=%d ps=%d\n",i,ps); // err(__LINE__); | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
180 return path; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
181 } |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
182 |
59 | 183 /* |
184 * os9 file name may contains garbage such as 8th bit on or traling space | |
185 * fix it. and make the pointer to next path for the return value | |
186 * | |
187 * pd->name will be freed, we have to malloc it | |
188 */ | |
49 | 189 static char * |
190 checkFileName(char *path, PathDesc *pd, int curdir) { | |
43 | 191 char *p = path; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
192 char *name = path; |
43 | 193 int maxlen = MAXPAHTLEN; |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
194 if(vdiskdebug&2) { printf("checkf \""); putOs9str(name,0); printf("\"\n"); } |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
195 while(*p!=0 && (*p&0x80)==0 && (*p&0x7f)>' ' && maxlen-->0) p++; |
43 | 196 if (maxlen==MAXPAHTLEN) return 0; |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
197 if (*p) { // 8th bit termination or non ascii termination |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
198 int eighth = ((*p&0x80)!=0); |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
199 name = (char *)malloc(p-path+1+eighth); |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
200 int i; |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
201 for(i=0;i<p-path;i++) name[i] = path[i]; |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
202 if (eighth) { name[i] = path[i]&0x7f; p++ ; i++; } |
51 | 203 name[i] = 0; |
61 | 204 // skip trailing space |
205 while(*p==' ') p++; | |
43 | 206 } |
45 | 207 char *name1 = addCurdir(name,pd,curdir); |
157 | 208 if (name1!=name && path!=name) { |
209 free(name); | |
210 } | |
47 | 211 if (name1==0) return 0; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
212 pd->name = name1; |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
213 if(vdiskdebug&2) { |
49 | 214 printf(" remain = \""); |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
215 char *p1 = p; int max=31; |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
216 while(*p1 && (*p1&0x80)==0 && max-->0) { if (*p1<0x20) printf("(0x%02x)",*p1); else putchar(*p1); p1++; } |
49 | 217 if (*p1) { if ((*p1&0x7f)<0x20) printf("(0x%02x)",*p1); else putchar(*p1&0x7f); } |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
218 printf("\" checkname result \""); putOs9str(pd->name,0); printf("\"\n"); |
49 | 219 } |
43 | 220 return p; |
221 } | |
222 | |
59 | 223 /* |
224 * os9 / unix mode conversion | |
225 */ | |
49 | 226 static void |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
227 os9setmode(Byte *os9mode,int mode) { |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
228 char m = 0; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
229 if (mode&S_IFDIR) m|=0x80; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
230 if (mode&S_IRUSR) m|=0x01; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
231 if (mode&S_IWUSR) m|=0x02; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
232 if (mode&S_IXUSR) m|=0x04; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
233 if (mode&S_IROTH) m|=0x08; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
234 if (mode&S_IWOTH) m|=0x10; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
235 if (mode&S_IXOTH) m|=0x20; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
236 m|=0x60; // always sharable |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
237 *os9mode = m; |
43 | 238 } |
239 | |
49 | 240 static char * |
61 | 241 os9toUnixAttr(Byte mode) { |
242 if ((mode&0x1) && (mode&0x2)) return "r+"; | |
243 if (!(mode&0x1) && (mode&0x2)) return "w"; | |
244 if ((mode&0x1) && !(mode&0x2)) return "r"; | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
245 return "r"; |
43 | 246 } |
247 | |
61 | 248 static int |
249 os9mode(Byte m) { | |
250 int mode = 0; | |
251 if ((m&0x80)) mode|=S_IFDIR ; | |
252 if ((m&0x01)) mode|=S_IRUSR ; | |
253 if ((m&0x02)) mode|=S_IWUSR ; | |
254 if ((m&0x04)) mode|=S_IXUSR ; | |
255 if ((m&0x08)) mode|=S_IROTH ; | |
256 if ((m&0x10)) mode|=S_IWOTH ; | |
257 if ((m&0x20)) mode|=S_IXOTH ; | |
258 return mode; | |
259 } | |
260 | |
150
da020c491fbb
add more fmemopen mess
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
149
diff
changeset
|
261 #ifdef NOFMEMOPEN |
148
fa0fbcbccbc9
add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
71
diff
changeset
|
262 |
fa0fbcbccbc9
add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
71
diff
changeset
|
263 FILE *fmemopen(char *buf,long sz, const char *mode) { |
fa0fbcbccbc9
add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
71
diff
changeset
|
264 static char fname[] = "/tmp/myfileXXXXXX"; |
fa0fbcbccbc9
add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
71
diff
changeset
|
265 int fd; |
fa0fbcbccbc9
add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
71
diff
changeset
|
266 fd = mkstemp(fname); /* Create and open temp file */ |
fa0fbcbccbc9
add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
71
diff
changeset
|
267 write(fd, buf, sz); /* Write something to file */ |
fa0fbcbccbc9
add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
71
diff
changeset
|
268 lseek(fd, 0L, SEEK_SET); |
fa0fbcbccbc9
add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
71
diff
changeset
|
269 FILE *fp = fdopen(fd,mode); |
fa0fbcbccbc9
add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
71
diff
changeset
|
270 unlink(fname); |
fa0fbcbccbc9
add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
71
diff
changeset
|
271 return fp; |
fa0fbcbccbc9
add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
71
diff
changeset
|
272 } |
fa0fbcbccbc9
add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
71
diff
changeset
|
273 |
fa0fbcbccbc9
add easy fmemopen replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
71
diff
changeset
|
274 #endif |
61 | 275 |
43 | 276 /* |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
277 * os9 file descriptor |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
278 * * File Descriptor Format |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
279 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
280 * The file descriptor is a sector that is present for every file |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
281 * on an RBF device. It contains attributes, modification dates, |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
282 * and segment information on a file. |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
283 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
284 * ORG 0 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
285 *FD.ATT RMB 1 Attributes |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
286 *FD.OWN RMB 2 Owner |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
287 *FD.DAT RMB 5 Date last modified |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
288 *FD.LNK RMB 1 Link count |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
289 *FD.SIZ RMB 4 File size |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
290 *FD.Creat RMB 3 File creation date (YY/MM/DD) |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
291 *FD.SEG EQU . Beginning of segment list |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
292 * Segment List Entry Format |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
293 ORG 0 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
294 * FDSL.A RMB 3 Segment beginning physical sector number |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
295 * FDSL.B RMB 2 Segment size |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
296 * FDSL.S EQU . Segment list entry size |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
297 * FD.LS1 EQU FD.SEG+((256-FD.SEG)/FDSL.S-1)*FDSL.S |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
298 * FD.LS2 EQU (256/FDSL.S-1)*FDSL.S |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
299 * MINSEC SET 16 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
300 */ |
43 | 301 |
45 | 302 #define FD_ATT 0 |
303 #define FD_OWN 1 | |
304 #define FD_DAT 3 | |
305 #define FD_LNK 8 | |
306 #define FD_SIZ 9 | |
307 #define FD_Creat 13 | |
308 #define FD_SEG 16 | |
309 | |
310 | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
311 /* |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
312 * os9 directory structure |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
313 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
314 * ORG 0 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
315 *DIR.NM RMB 29 File name |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
316 *DIR.FD RMB 3 File descriptor physical sector number |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
317 *DIR.SZ EQU . Directory record size |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
318 */ |
45 | 319 #define DIR_SZ 32 |
320 #define DIR_NM 29 | |
43 | 321 |
322 | |
59 | 323 /* read direcotry entry |
324 * | |
325 * create simulated os9 directory structure for dir command | |
326 * writing to the directory is not allowed | |
327 * */ | |
49 | 328 static int |
329 os9opendir(PathDesc *pd) { | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
330 DIR *dir; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
331 struct dirent *dp; |
48
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
332 if (pd->dirfp) return 0; // already opened |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
333 dir = opendir(pd->name); |
47 | 334 if (dir==0) return -1; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
335 int dircount = 0; |
45 | 336 while ((dp = readdir(dir)) != NULL) dircount++; // pass 1 to determine the size |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
337 if (dircount==0) return 0; // should contains . and .. at least |
45 | 338 pd->sz = dircount*DIR_SZ; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
339 pd->dirfp = (char *)malloc(dircount*DIR_SZ); |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
340 rewinddir(dir); |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
341 int i = 0; |
51 | 342 while ((dp = readdir(dir)) != NULL && dircount-->=0) { |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
343 int j = 0; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
344 for(j = 0; j < DIR_NM ; j++) { |
190 | 345 if (j< strlen(dp->d_name)) { |
152 | 346 pd->dirfp[i+j] = dp->d_name[j]&0x7f; // this is wrong but os9 does not allow 8th bit |
190 | 347 if (j== strlen(dp->d_name)-1 || dp->d_name[j+1]==0) { |
48
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
348 pd->dirfp[i+j] |= 0x80; // os9 EOL |
152 | 349 } |
48
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
350 } else |
47 | 351 pd->dirfp[i+j] = 0; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
352 } |
47 | 353 pd->dirfp[i+j] = (dp->d_ino&0xff0000)>>16; |
354 pd->dirfp[i+j+1] = (dp->d_ino&0xff00)>>8; | |
355 pd->dirfp[i+j+2] = dp->d_ino&0xff; | |
356 i += DIR_SZ; | |
51 | 357 if (i>pd->sz) |
358 return 0; | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
359 } |
158 | 360 pd->fp = fmemopen(pd->dirfp,pd->sz+1,"r"); |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
361 return 0; |
43 | 362 } |
363 | |
49 | 364 static void |
151 | 365 os9setdate(Byte *d,time_t * unixtime) { |
45 | 366 // yymmddhhss |
47 | 367 struct tm r; |
151 | 368 localtime_r(unixtime,&r); |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
369 d[0] = r.tm_year-2048; |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
370 d[1] = r.tm_mon + 1; |
47 | 371 d[2] = r.tm_mday; |
372 d[3] = r.tm_hour; | |
373 d[4] = r.tm_min; | |
374 d[5] = r.tm_sec; | |
45 | 375 } |
43 | 376 |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
377 /* read file descriptor of Path Desc |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
378 * create file descriptor sector if necessary |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
379 * if buf!=0, copy it |
59 | 380 * |
381 * only dir command accesses this using undocumented getstat fdinfo command | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
382 */ |
49 | 383 static int |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
384 filedescriptor(Byte *buf, int len, Byte *name,int curdir) { |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
385 int err = 0x255; |
157 | 386 PathDesc pd; pd.name = 0; |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
387 if (len<13) return -1; |
157 | 388 if (checkFileName((char*)name,&pd,curdir)==0) goto err1; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
389 struct stat st; |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
390 if (stat(pd.name,&st)!=0) goto err1; |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
391 os9setmode(buf+FD_ATT,st.st_mode); |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
392 buf[FD_OWN]=(st.st_uid&0xff00)>>8; |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
393 buf[FD_OWN+1]=st.st_uid&0xff; |
151 | 394 os9setdate(buf+ FD_DAT,&st.st_mtime); |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
395 buf[FD_LNK]=st.st_nlink&0xff; |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
396 buf[FD_SIZ+0]=(st.st_size&0xff000000)>>24; |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
397 buf[FD_SIZ+1]=(st.st_size&0xff0000)>>16; |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
398 buf[FD_SIZ+2]=(st.st_size&0xff00)>>8; |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
399 buf[FD_SIZ+3]=st.st_size&0xff; |
151 | 400 os9setdate(buf+FD_Creat,&st.st_ctime); |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
401 err = 0; |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
402 err1: |
158 | 403 free(pd.name); |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
404 return err; |
43 | 405 } |
406 | |
59 | 407 /* |
408 * undocumented getstat command | |
409 * | |
410 * read direcotry entry for *any* file in the directory | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
411 * we only returns a file descriptor only in the current opened directory |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
412 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
413 * inode==0 should return disk id section |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
414 * inode==bitmap should return disk sector map for os9 free command |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
415 */ |
49 | 416 static int |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
417 fdinfo(Byte *buf,int len, int inode, PathDesc *pd,int curdir) { |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
418 int i; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
419 for(i=0;i<MAXPDV;i++) { |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
420 PathDesc *pd = pdv+i; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
421 if (!pd->use || !pd->dir) continue; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
422 // find inode in directory |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
423 Byte *dir = (Byte*)pd->dirfp; |
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
424 Byte *end = (Byte*)pd->dirfp + pd->sz; |
49 | 425 while( dir < end ) { |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
426 Byte *p = (dir + DIR_NM); |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
427 int dinode = (p[0]<<16)+(p[1]<<8)+p[2]; |
45 | 428 if (inode == dinode) { |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
429 return filedescriptor(buf,len,dir,curdir); |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
430 } |
49 | 431 dir += 0x20; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
432 } |
43 | 433 } |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
434 return 255; |
43 | 435 } |
436 | |
59 | 437 /* |
438 * on os9 level 2, user process may on different memory map | |
439 * get DAT table on process descriptor on 0x50 in system page | |
440 */ | |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
441 void |
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
442 getDAT() { |
59 | 443 #ifdef USE_MMU |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
444 Word ps = getword(smem(0x50)); // process structure |
59 | 445 Byte *dat = smem(ps+0x40); // process dat (dynamic address translation) |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
446 for(int i=0; i<8; i++) { |
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
447 pmmu[i] = dat[i*2+1]; |
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
448 } |
59 | 449 #endif |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
450 } |
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
451 |
43 | 452 /* |
59 | 453 * vdisk command processing |
454 * | |
455 * vrbf.asm will write a command on 0x40+IOPAGE ( 0xffc0 or 0xe040) | |
456 * | |
457 * U contains caller's stack (call and return value) on 0x45+IOPAGE | |
458 * current directory (cwd or cxd) on 0x44+IOPAGE | |
459 * Path dcriptor number on 0x47+IOPAGE | |
460 * drive number on 0x41+IOPAGE | |
461 * caller's process descriptor on <0x50 | |
462 * | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
463 * each command should have preallocated os9 path descriptor on Y |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
464 * |
49 | 465 * name or buffer, can be in a user map, check that drive number ( mem[0x41+IOPAGE] 0 sys 1 user ) |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
466 * current directory path number mem[0x42+IOPAGE] |
45 | 467 * yreg has pd number |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
468 */ |
49 | 469 void |
470 do_vdisk(Byte cmd) { | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
471 int err; |
49 | 472 int curdir = mem[0x44+IOPAGE]; // garbage until set |
46 | 473 Byte attr ; |
49 | 474 Word u = getword(&mem[0x45+IOPAGE]); // caller's stack in system segment |
475 Byte *frame = smem(u); | |
476 xreg = getword(frame+4); | |
477 yreg = getword(frame+6); | |
46 | 478 *areg = *smem(u+1); |
479 *breg = *smem(u+2); | |
49 | 480 Byte mode = 0; |
481 Byte *os9pd = smem(getword(&mem[0x47+IOPAGE])); | |
47 | 482 PathDesc *pd = pdv+*os9pd; |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
483 |
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
484 getDAT(); |
47 | 485 pd->num = *os9pd; |
486 pd->drv = mem[0x41+IOPAGE]; | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
487 char *path,*next,*buf; |
49 | 488 if (vdiskdebug&1) vdisklog(u,pd,getword(&mem[0x47+IOPAGE]),curdir,stdout); |
43 | 489 |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
490 switch(cmd) { |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
491 /* |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
492 * I$Create Entry Point |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
493 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
494 * Entry: A = access mode desired |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
495 * B = file attributes |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
496 * X = address of the pathlist |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
497 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
498 * Exit: A = pathnum |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
499 * X = last byte of pathlist address |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
500 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
501 * Error: CC Carry set |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
502 * B = errcode |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
503 */ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
504 case 0xd1: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
505 mode = *areg; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
506 attr = *breg; |
61 | 507 pd->fp = 0; |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
508 path = (char *)pmem(xreg); |
61 | 509 next = checkFileName(path,pd,curdir); |
510 *breg = 0xff; | |
511 int fd = open(pd->name, O_RDWR+O_CREAT,os9mode(attr) ); | |
512 if (fd>0) | |
513 pd->fp = fdopen(fd, os9toUnixAttr(mode)); | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
514 if (next!=0 && pd->fp ) { |
61 | 515 *breg = 0; |
516 *areg = pd->num; | |
517 *smem(u+1) = *areg ; | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
518 xreg += ( next - path ); |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
519 pd->use = 1; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
520 } else { |
47 | 521 pd->use = 0; |
43 | 522 } |
523 break; | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
524 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
525 /* |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
526 * I$Open Entry Point |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
527 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
528 * Entry: A = access mode desired |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
529 * X = address of the pathlist |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
530 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
531 * Exit: A = pathnum |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
532 * X = last byte of pathlist address |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
533 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
534 * Error: CC Carry set |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
535 * B = errcode |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
536 */ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
537 case 0xd2: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
538 mode = *areg; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
539 attr = *breg; |
157 | 540 pd->fp = 0; pd->name = 0; |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
541 path = (char*)pmem(xreg); |
45 | 542 next = checkFileName(path,pd,curdir); |
47 | 543 *breg = 0xff; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
544 if (next!=0) { |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
545 struct stat buf; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
546 if (stat(pd->name,&buf)!=0) break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
547 if ((buf.st_mode & S_IFMT) == S_IFDIR) { |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
548 pd->dir = 1; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
549 os9opendir(pd); |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
550 } else { |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
551 pd->dir = 0; |
45 | 552 pd->fp = fopen( pd->name,os9toUnixAttr(mode)); |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
553 } |
47 | 554 pd->use = 1; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
555 } |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
556 if (next!=0 && pd->fp !=0) { |
47 | 557 *breg = 0; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
558 *areg = pd->num; |
49 | 559 *smem(u+1) = *areg ; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
560 xreg += ( next - path ); |
47 | 561 pd->use = 1; |
562 } else { | |
563 pd->use = 0; | |
564 } | |
43 | 565 break; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
566 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
567 /* |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
568 * I$MakDir Entry Point |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
569 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
570 * Entry: X = address of the pathlist |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
571 * B = directory attributes |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
572 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
573 * Exit: X = last byte of pathlist address |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
574 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
575 * Error: CC Carry set |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
576 * B = errcode |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
577 */ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
578 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
579 case 0xd3: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
580 *breg = 0xff; |
63 | 581 mode = *areg; |
582 attr = *breg; | |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
583 path = (char*)pmem(xreg); |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
584 next = checkFileName(path,pd,curdir); |
63 | 585 if (next!=0 && mkdir(pd->name,os9mode(attr))== 0 ) { |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
586 xreg += ( next - path ); |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
587 *breg = 0; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
588 } |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
589 closepd(pd); |
43 | 590 break; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
591 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
592 /* |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
593 * I$ChgDir Entry Point |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
594 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
595 * data dir P$DIO 3-5 contains open dir Path number |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
596 * exec dir P$DIO 9-11 contains open dir Path number |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
597 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
598 * Entry: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
599 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
600 * *areg = access mode |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
601 * 0 = Use any special device capabilities |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
602 * 1 = Read only |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
603 * 2 = Write only |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
604 * 3 = Update (read and write) |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
605 * Entry: X = address of the pathlist |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
606 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
607 * Exit: X = last byte of pathlist address |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
608 * A = open directory Path Number |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
609 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
610 * Error: CC Carry set |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
611 * B = errcode |
49 | 612 * |
613 * | |
614 * we keep track a cwd and a cxd for a process using 8bit id | |
61 | 615 * don't use path descriptor on y |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
616 */ |
61 | 617 case 0xd4: { |
618 PathDesc dm = *pd; | |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
619 path = (char*)pmem(xreg); |
61 | 620 next = checkFileName(path,&dm,curdir); |
49 | 621 if (next!=0) { |
622 struct stat buf; | |
61 | 623 if (stat(dm.name,&buf)!=0) break; |
49 | 624 if ((buf.st_mode & S_IFMT) != S_IFDIR) break; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
625 xreg += ( next - path ); |
61 | 626 *areg = setcd(dm.name); |
49 | 627 *smem(u+1) = *areg ; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
628 *breg = 0; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
629 break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
630 } |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
631 *breg = 0xff; |
61 | 632 } |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
633 break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
634 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
635 /* |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
636 * I$Delete Entry Point |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
637 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
638 * Entry: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
639 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
640 * Exit: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
641 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
642 * Error: CC Carry set |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
643 * B = errcode |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
644 */ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
645 case 0xd5: { |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
646 *breg = 0xff; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
647 if (pd==0) break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
648 struct stat st; |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
649 path = (char*)pmem(xreg); |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
650 next = checkFileName(path,pd,curdir); |
47 | 651 pd->use = 0; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
652 if (next!=0 && stat(pd->name,&st)!=0) break; |
45 | 653 if (next!=0 && ((st.st_mode&S_IFDIR)?rmdir(pd->name):unlink(pd->name)) == 0) { |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
654 xreg += ( next - path ); |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
655 *breg = 0; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
656 } |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
657 } |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
658 break; |
43 | 659 |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
660 /* |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
661 * I$Seek Entry Point |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
662 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
663 * Entry Conditions |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
664 * A path number |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
665 * X MS 16 bits of the desired file position |
49 | 666 * U LS 16 bits of the desired file position |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
667 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
668 * Exit: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
669 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
670 * Error: CC Carry set |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
671 * B = errcode |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
672 */ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
673 case 0xd6: { |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
674 *breg = 0xff; |
49 | 675 ureg = (*smem(u+8)<<8)+*smem(u+9); |
676 off_t seek = (xreg<<16)+ureg; | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
677 *breg = fseek(pd->fp,(off_t)seek,SEEK_SET); |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
678 break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
679 } |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
680 /* |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
681 * I$ReadLn Entry Point |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
682 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
683 * Entry: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
684 * Entry Conditions in correct mmu map |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
685 * A path number |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
686 * X address at which to store data |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
687 * Y maximum number of bytes to read |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
688 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
689 * Exit: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
690 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
691 * Y number of bytes read |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
692 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
693 * Error: CC Carry set |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
694 * B = errcode |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
695 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
696 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
697 */ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
698 case 0xd7: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
699 *breg = 0xff; |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
700 buf = (char*)pmem(xreg); |
48
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
701 char *b; |
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
702 if ((b=fgets(buf,yreg,pd->fp))) { |
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
703 if (b==0) { |
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
704 *breg = 0xd3; |
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
705 break; |
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
706 } |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
707 int i; |
49 | 708 for(i=0;i<yreg && buf[i];i++); |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
709 if (i>0 && buf[i-1]=='\n') { |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
710 buf[i-1] = '\r'; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
711 yreg = i; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
712 } |
49 | 713 // set y |
714 setword(smem(u+6),yreg); | |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
715 *breg = 0; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
716 } |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
717 break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
718 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
719 /* |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
720 * I$Read Entry Point |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
721 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
722 * Entry: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
723 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
724 * Exit: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
725 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
726 * Error: CC Carry set |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
727 * B = errcode |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
728 */ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
729 case 0xd8: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
730 *breg = 0xff; |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
731 buf = (char*)pmem(xreg); |
48
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
732 int i = fread(buf,1,yreg,pd->fp); |
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
733 // set y |
49 | 734 setword(smem(u+6),i); |
48
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
735 *breg = (i==0?0xd3:0) ; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
736 break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
737 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
738 /* |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
739 * I$WritLn Entry Point |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
740 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
741 * Entry: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
742 * A path number |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
743 * X address of the data to write |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
744 * Y maximum number of bytes to read |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
745 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
746 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
747 * Exit: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
748 * Y number of bytes written |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
749 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
750 * Error: CC Carry set |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
751 * B = errcode |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
752 */ |
48
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
753 case 0xd9: { |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
754 *breg = 0xff; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
755 if (pd->dir) break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
756 int len = yreg; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
757 int i = 0; |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
758 Byte *buf = pmem(xreg); |
61 | 759 while(len>0 && buf[i] !='\r') { |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
760 fputc(buf[i++],pd->fp); |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
761 len--; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
762 } |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
763 if (buf[i]=='\r') { |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
764 fputc('\n',pd->fp); |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
765 i++; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
766 } |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
767 *breg = 0; |
48
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
768 // set y |
49 | 769 setword(smem(u+6),i); |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
770 break; |
48
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
771 } |
43 | 772 |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
773 /* |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
774 * I$Write Entry Point |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
775 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
776 * Entry: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
777 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
778 * Exit: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
779 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
780 * Error: CC Carry set |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
781 * B = errcode |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
782 */ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
783 case 0xda : |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
784 *breg = 0xff; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
785 if (!pd->dir) { |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
786 Byte *buf = pmem(xreg); |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
787 int len = yreg; |
48
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
788 int err = fwrite(buf,1,len,pd->fp); |
49 | 789 *breg = err?0:0xff; |
48
ea1b17311bf3
dir /v0 worked but dir /v0/src and chd /v0; dir does not
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
47
diff
changeset
|
790 // set y |
49 | 791 setword(smem(u+6),err); |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
792 } |
43 | 793 break; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
794 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
795 /* I$Close Entry Point |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
796 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
797 * Entry: A = path number |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
798 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
799 * Exit: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
800 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
801 * Error: CC Carry set |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
802 * B = errcode |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
803 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
804 */ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
805 case 0xdb: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
806 *breg = 0xff; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
807 if (pd==0) break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
808 closepd(pd); |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
809 *breg = 0; |
43 | 810 break; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
811 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
812 /* |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
813 * I$GetStat Entry Point |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
814 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
815 * Entry: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
816 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
817 * Exit: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
818 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
819 * Error: CC Carry set |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
820 * B = errcode |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
821 */ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
822 case 0xdc: { |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
823 struct stat st; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
824 off_t pos; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
825 switch (*breg) { |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
826 case 01: // SS.Ready |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
827 *breg = 0xff; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
828 if (pd==0) break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
829 fstat(fileno(pd->fp),&st); |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
830 if ((pos = ftell(pd->fp))) { |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
831 xreg = st.st_size - pos; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
832 *breg = 0; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
833 } |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
834 break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
835 case 02: // SS.SIZ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
836 *breg = 0xff; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
837 if (pd==0) break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
838 fstat(fileno(pd->fp),&st); |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
839 xreg = st.st_size ; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
840 *breg = 0; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
841 break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
842 case 05: // SS.Pos |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
843 *breg = 0xff; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
844 if (pd==0) break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
845 xreg = ftell(pd->fp); |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
846 *breg = 0; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
847 break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
848 case 15: // SS.FD |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
849 /* SS.FD ($0F) - Returns a file descriptor |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
850 * Entry: R$A=Path # |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
851 * R$B=SS.FD ($0F) |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
852 * R$X=Pointer to a 256 byte buffer |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
853 * R$Y=# bytes of FD required |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
854 */ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
855 *breg = 0xff; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
856 if (pd==0) break; |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
857 *breg = filedescriptor(pmem(xreg), yreg,(Byte*)pd->name,curdir) ; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
858 break; |
59 | 859 case 0x20: // Pos.FDInf mandatry for dir command (undocumented, use the source) |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
860 /* SS.FDInf ($20) - Directly reads a file descriptor from anywhere |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
861 * on drive. |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
862 * Entry: R$A=Path # |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
863 * R$B=SS.FDInf ($20) |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
864 * R$X=Pointer to a 256 byte buffer |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
865 * R$Y= MSB - Length of read |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
866 * LSB - MSB of logical sector # |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
867 * R$U= LSW of logical sector # |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
868 */ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
869 *breg = 0xff; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
870 if (pd==0) break; |
49 | 871 ureg = getword(smem(u+8)); |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
872 *breg = fdinfo(pmem(xreg),(yreg&0xff),((yreg&0xff00)>>8)*0x10000+ureg,pd,curdir); |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
873 break; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
874 default: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
875 *breg = 0xff; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
876 } |
43 | 877 break; |
44
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
878 } |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
879 |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
880 /* |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
881 * I$SetStat Entry Point |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
882 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
883 * Entry: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
884 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
885 * Exit: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
886 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
887 * |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
888 * Error: CC Carry set |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
889 * B = errcode |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
890 */ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
891 case 0xdd: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
892 switch (*breg) { |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
893 case 0: // SS.Opt |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
894 case 02: // SS.SIZ |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
895 case 15: // SS.FD |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
896 case 0x11: // SS.Lock |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
897 case 0x10: // SS.Ticks |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
898 case 0x20: // SS.RsBit |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
899 case 0x1c: // SS.Attr |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
900 default: |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
901 *breg = 0xff; |
b26c23331d02
add more function on vdisk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
43
diff
changeset
|
902 } |
43 | 903 break; |
904 } | |
52
51b437557f42
boot without disk image
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
51
diff
changeset
|
905 if (vdiskdebug && *breg) printf(" vdisk call error %x\n",*breg); |
46 | 906 // return value |
56 | 907 mem[0x40+IOPAGE] = *breg; |
46 | 908 *smem(u+2) = *breg ; |
49 | 909 setword(smem(u+4),xreg); |
910 } | |
46 | 911 |
49 | 912 static void |
913 vdisklog(Word u,PathDesc *pd, Word pdptr, int curdir, FILE *fp) { | |
914 char *cd = cdt[curdir]?cdt[curdir]:"(null)"; | |
915 fprintf(fp,"pd %d 0x%x cd[%d]=%s ",pd->num, pdptr, curdir,cd); | |
916 Byte *frame = smem(u); | |
917 sreg = u; | |
918 ccreg = frame[0]; | |
919 *areg = frame[1]; | |
920 *breg = frame[2]; | |
921 xreg = getword(frame+4); | |
922 yreg = getword(frame+6); | |
923 ureg = getword(frame+8); | |
59 | 924 pcreg = getword(frame+10)-3; // point os9 swi2 |
50
1430678cd4fb
use process structure's mmu
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
49
diff
changeset
|
925 prog = (char*)(pmem(pcreg) - pcreg); |
61 | 926 if (*pmem(pcreg)==0 && *pmem(pcreg+1)==0) { |
927 // may be we are called from system state | |
158 | 928 // of course, this may wrong. but in system state, <$50 process has wrong DAT for pc |
61 | 929 // and we can't know wether we are called from system or user |
930 prog = (char*)(smem(pcreg) - pcreg); | |
931 } | |
49 | 932 do_trace(fp); |
43 | 933 } |
934 | |
935 | |
49 | 936 /* end */ |