annotate vdisk.c @ 56:4fa2bdb0c457

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