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