|
|
1.1 root 1:
2: #include "definitions"
3: #define LINE 80
4: #define CRTN 0x0d
5: #define EOL '.'
1.1.1.2 ! root 6: int cyccnt;
1.1 root 7:
8: /* I/O ROUTINES TO CPU2 CONSOLE */
9:
10: writec(c)
11: char c;
12: {
13: putchar(c);
14: }
15:
16: writes(s)
17: char *s;
18: {
19: putstr(s);
20: }
21:
22: writeh(ix) /* 32 bits HEX */
23: long ix;
24: { register long count, mask, indx;
25: char c, str[9];
26:
27: if (ix==0) { writec('0'); return; }
28: indx = 0; count = 28;
29: mask = 0xf0000000;
30: str[8]='\0';
31: while (mask) {
32: c = ( (ix&mask) >> count )&0xf;
33: count -= 4;
34: if (indx==0) mask = 0xf000000;
35: else mask = mask >> 4;
36: if ((c>=0)&&(c<=9)) c=c+'0';
37: else c=c+'7';
38: str[indx++] = c;
39: }
40: /* replace leading 0 with space */
41: for (indx=0; indx<8; indx++) {
42: if (str[indx]!='0') break;
43: /* esle str[indx]=' '; */
44: }
45: writes(&str[indx]);
46: }
47:
48: /* Function to write a 32_bit decimal to Console
49: */
50: writed(ix)
51: long ix;
52: { char c;
53: register long div, lead0;
54:
55: if (ix==0) { writec('0'); return; }
56: if (ix<0) { writec('-'); ix = (~ix)+1; }
57: lead0 = 1;
58: div = 1000000000;
59: while (div) {
60: c = (ix/div)+'0';
61: ix = ix%div; /* Mod */
62: div /= 10;
63: if ((c=='0')&&(lead0)) c=' ';
64: else lead0 = 0;
65: if (c != ' ') writec(c);
66: }
67: }
68:
69: /* Function read 1 char from Console
70: */
71: char readc()
72: { char c, rdchar();
73:
74: writec(c = rdchar());
75: return(c);
76: }
77:
78: /* This function read a string of characters.
79: calling sequence : nochar = reads(s);
80: input argument : char *s;
81: return value : no. of char read; excluding NULL or CR.
82: */
83: reads(s)
84: char *s;
85: { register long ix;
86:
87: for(ix=0;;ix++) {
88: *s = readc();
89: if ((*s==NULL)||(*s==CR))
90: { *s = NULL; break; }
91: else s++;
92: }
93: return(ix);
94: }
95:
96:
97: /* This function read a string of HEX digit and
98: convert it to integer value.
99: calling sequence : stat = readh(ix);
100: input parameter : long *ix;
101: return value : (stat < 0) if error else (stat = 0);
102: */
103: /*
104: readh(ix)
105: long *ix;
106: { char line[ALINE], *getnum(), *del;
107: int nochar;
108:
109: if ( (nochar = reads(line)) > 8 ) return(-1);
110: if ( (del = getnum(line,ix,del,HEX)) < 0 ) return(-1);
111: else return(0);
112: }
113:
114: */
115:
116:
117:
118:
119: /* This function read a string of DEC digit and
120: convert it to integer value.
121: calling sequence : stat = readd(ix);
122: input parameter : long *ix;
123: return value : (stat < 0) if error else (stat = 0);
124: */
125:
126: /*
127: readd(ix)
128: long *ix;
129: { char line[ALINE], *getnum(), *del;
130: int nochar;
131:
132: if ( (nochar = reads(line)) > 11 ) return(-1);
133: if ( (del = getnum(line,ix,del,DEC)) < 0 ) return(-1);
134: else return(0);
135: }
136: */
137: echo(c) /* routine to get a test number, validate it
138: and set bits in a flag word. */
139:
140: int c;
141:
142: {
143:
1.1.1.2 ! root 144: #define ALL 0x8
! 145: #define MT 0xe
! 146: #define VIOC 0xd
! 147: #define VDDC 0xb
! 148: #define EXIT 0x7
1.1 root 149:
150: int flag, valid;
151:
152: flag = 0;
153: valid = 1;
154:
155: while (valid){
156: c = readc();
157: switch(c){
158: case '0':
159: flag |= ALL;
160: valid = 0;
161: break;
162: case '1':
163: flag |= MT;
164: valid = 0;
165: break;
166: case '2':
167: flag |= VIOC;
168: valid = 0;
169: break;
170: case '3':
171: flag |= VDDC;
172: valid = 0;
173: break;
1.1.1.2 ! root 174: case '4':
! 175: flag |= EXIT;
! 176: valid = 0;
! 177: break;
1.1 root 178: default:
179: writes(" invalid test number\n");
180: writes("\nRe-enter test number : ");
181: valid = 1;
182: break;
183: }
184: }
185: c = flag;
186: return(c);
187: }
188: getcont(c) /* routine to get controller number */
189: int c;
190: {
191: int valid, cont;
192: valid = 1;
1.1.1.2 ! root 193: writes("\n\nController number [0-7] : ");
1.1 root 194: while(valid){
195: c = readc();
196: switch(c){
197: case '0':
198: cont = 0;
199: valid = 0;
200: break;
201: case '1':
202: cont = 1;
203: valid = 0;
204: break;
205: case '2':
206: cont = 2;
207: valid = 0;
208: break;
209: case '3':
210: cont = 3;
211: valid = 0;
212: break;
1.1.1.2 ! root 213: case '4':
! 214: cont = 4;
! 215: valid = 0;
! 216: break;
! 217: case '5':
! 218: cont = 5;
! 219: valid = 0;
! 220: break;
! 221: case '6':
! 222: cont = 6;
! 223: valid = 0;
! 224: break;
! 225: case '7':
! 226: cont = 7;
! 227: valid = 0;
! 228: break;
1.1 root 229: default:
230: writes(" invalid controller number\n");
231: writes("\nRe-enter controller number : ");
232: valid = 1;
233: break;
234: }
235: }
236: return(cont);
237: }
238: gettype(c) /* routine to get type of disk */
239: int c;
240: {
241: int valid, type;
242: valid = 1;
1.1.1.2 ! root 243: cyccnt = 30;
! 244: writes("\n\nEnter disk type [0 = fsd, 1 = smd, 2 = xfd, 3 = xsd] : ");
1.1 root 245: while(valid){
246: c = readc();
247: switch(c){
248: case '0':
249: type = 0;
250: valid = 0;
251: break;
252: case '1':
253: type = 1;
254: valid = 0;
255: break;
256: case '2':
257: type = 2;
258: valid = 0;
259: break;
1.1.1.2 ! root 260: case '3':
! 261: type = 3;
! 262: valid = 0;
! 263: break;
1.1 root 264: default:
265: writes(" invalid disk type\n");
266: writes("\nRe-enter disk type : ");
267: valid = 1;
268: break;
269: }
270: }
1.1.1.2 ! root 271: writes("\n\nEnter number of cycles for seek test (default 30): ");
! 272: c = getdec();
! 273: if (c != 0) cyccnt = c;
1.1 root 274: return(type);
275: }
276: /**********************************************************
277: Hex input routine, call fill and validates the characters
278: in the character buffer. Then returns the HEX value back to
279: the calling routine.
280: **********************************************************/
281: gethex()
282: {
283: char s[LINE];
284: int k[1],i,n;
285: n=0x0;
286: fill(s,k); /* Fill s[] */
287: for (i=0;i<k[0];++i) {
288: if (s[i] >= 'a' && s[i] <= 'f')
289: n=0x10*n+s[i]-'W';
290: if (s[i] >= 'A' && s[i] <= 'F')
291: n=0x10*n+s[i]-'7';
292: if (s[i] >= '0' && s[i] <= '9')
293: n=0x10*n+s[i]-'0';
294: if ((s[i] < '0' ) || (s[i] > '9' && s[i] < 'A') || (s[i] > 'F'
295: && s[i] < 'a') || (s[i] > 'f'))
296: {
297: writes("\nInvalid hex digit: "); writec(s[i]); writes(" (ignored)");
298: }
299: }
300: return(n);
301: }
1.1.1.2 ! root 302: /**********************************************************
! 303: Decimal input routine, call fill and validates the characters
! 304: in the character buffer. Then returns the DECIMAL value back to
! 305: the calling routine.
! 306: **********************************************************/
! 307: getdec()
! 308: {
! 309: char s[LINE];
! 310: int k[1],i,n;
! 311: n=0;
! 312: fill(s,k); /* Fill s[] */
! 313: for (i=0;i<k[0];++i) {
! 314: if (s[i] >= '0' && s[i] <= '9')
! 315: n=0x10*n+s[i]-'0';
! 316: if ((s[i] < '0' ) || (s[i] > '9'))
! 317: {
! 318: writes("\nInvalid decimal digit: "); writec(s[i]); writes(" (ignored)");
! 319: }
! 320: }
! 321: return(n);
! 322: }
1.1 root 323: /****************************************************
324: This routine fills a character buffer with characters
325: that are input on the console.
326: ****************************************************/
327: fill(s,k)
328: char s[];
329: int k[];
330: {
331: char c;
332: int i;
333: k[0]=0;
334: for (i=0;(c=readc())!=CRTN;++i)
335: {
336: if (k[0]>LINE - 1) break;
337: if (c==EOL) break;
338: s[i]=c;
339: ++k[0];
340: }
341: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.