Commit | Line | Data |
---|---|---|
d52f1552 TL |
1 | # include "CON.h" |
2 | # include "FL.h" | |
3 | /* */ | |
4 | # define BLKSIZ 512 /* tape block size */ | |
5 | int count , sector , isector , icount ; | |
6 | char *bufptr , input[128] , *ibufptr ; | |
7 | int wo = 0 ; | |
8 | /* */ | |
9 | main() { | |
10 | /* | |
11 | * Stand-alone program to copy VAX LSI RX11 floppy diskette to | |
12 | * memory and back to floppy. | |
13 | * Floppy sector no.'s start at 1 for controller - start at 0 | |
14 | * for user input. | |
15 | * Floppy track no.'s start at 0. | |
16 | */ | |
17 | register int kk ; | |
18 | ||
19 | putlin("flpcpy : Floppy-to-Memory-to-Floppy Copy") ; | |
20 | putnl() ; | |
21 | ||
22 | doff : | |
23 | putstr("floppy sector offset : ") ; | |
24 | getcon(input) ; | |
25 | sector = a2l(input) ; | |
26 | if ((sector < 0) || (sector >= MAXSEC)) goto doff ; | |
27 | ||
28 | gknt : | |
29 | putstr("no. of input sectors : ") ; | |
30 | getcon(input) ; | |
31 | count = a2l(input) ; | |
32 | if (count < 0) goto gknt ; | |
33 | if (count == 0) count = MAXSEC ; | |
34 | ||
35 | if (init()) { | |
36 | putlin("init error") ; | |
37 | return(-1) ; | |
38 | } | |
39 | ||
40 | isector = sector ; | |
41 | icount = count ; | |
42 | ||
43 | if (wo) goto wflop ; | |
44 | while (count>0) { | |
45 | if ((count%100) == 0) { | |
46 | kk = count/100 ; | |
47 | l2a(kk,input) ; | |
48 | putstr(input) ; | |
49 | putstr(" ") ; | |
50 | } | |
51 | if (flio(FL_RS)) { /* read */ | |
52 | putlin("floppy input error") ; | |
53 | return(-1) ; | |
54 | } | |
55 | } | |
56 | ||
57 | putnl() ; | |
58 | putlin("floppy read complete") ; | |
59 | ||
60 | wflop : | |
61 | putlin("mount new floppy - type any key when ready") ; | |
62 | getcon(input) ; | |
63 | ||
64 | count = icount ; | |
65 | sector = isector ; | |
66 | bufptr = ibufptr ; | |
67 | ||
68 | while (count > 0) { | |
69 | if ((count%100) == 0) { | |
70 | kk = count/100 ; | |
71 | l2a(kk,input) ; | |
72 | putstr(input) ; | |
73 | putstr(" ") ; | |
74 | } | |
75 | if (flio(FL_WS)) { | |
76 | putlin("floppy output error") ; | |
77 | return(-1) ; | |
78 | } | |
79 | } | |
80 | putnl() ; | |
81 | putlin("floppy write complete") ; | |
82 | ||
83 | end : | |
84 | return(0) ; | |
85 | } | |
86 | ||
87 | /* */ | |
88 | ||
89 | init() { | |
90 | /* | |
91 | * Initialization. | |
92 | */ | |
93 | extern char *end ; | |
94 | ||
95 | ibufptr = bufptr = (char *)(((int)&end+511) & 017777777000) ; | |
96 | return(0) ; | |
97 | } | |
98 | ||
99 | /* */ | |
100 | ||
101 | flio(func) | |
102 | int func ; | |
103 | { | |
104 | /* | |
105 | * Function to read/write 1 sector from floppy disc. | |
106 | * 'sector' is sector no.-1 to read into 'input[]'. | |
107 | * Return (-1) for error, else return (0) . | |
108 | */ | |
109 | register int j , s , t ; | |
110 | register unsigned int c ; | |
111 | ||
112 | /* compute start track & sector from current sector 'sector'. */ | |
113 | t = sector/RXSTRK ; /* track no. */ | |
114 | s = sector%RXSTRK + 1 ; /* sector */ | |
115 | sector++ ; | |
116 | ||
117 | ||
118 | fltwait() ; | |
119 | mtpr(TXDB,func) ; /* Floppy Read/Write Sector command */ | |
120 | fltwait() ; | |
121 | mtpr(TXDB,s|FL_DATA) ; /* supply sector no. to floppy interface */ | |
122 | fltwait() ; | |
123 | mtpr(TXDB,t|FL_DATA) ; /* track no. */ | |
124 | ||
125 | if (func == FL_RS) { /* Read Sector */ | |
126 | /* wait for read to complete */ | |
127 | if (fldone()) return(-1) ; | |
128 | /* loop to read sector bytes from interface */ | |
129 | for (j = 0 ; j < RXBYSEC ; j++) { | |
130 | flrwait() ; /* wait till ready */ | |
131 | (*bufptr++) = mfpr(RXDB) ; /*get data byte-assume from floppy*/ | |
132 | } | |
133 | } | |
134 | else { | |
135 | if (func == FL_WS) { /* Write Sector */ | |
136 | for (j = 0 ; j < RXBYSEC ; j++) { | |
137 | /* send byte over interface */ | |
138 | fltwait() ; | |
139 | c = (*bufptr++) & 0xff ; | |
140 | mtpr(TXDB,(c|FL_DATA)) ; | |
141 | } | |
142 | fltwait() ; | |
143 | if (fldone()) return(-1) ; | |
144 | } | |
145 | } | |
146 | count-- ; | |
147 | return(0) ; | |
148 | } |