|
|
1.1 root 1: /* Console Processor Interface */
2: /* Tahoe version, Nov. 1982 */
3:
4: /****************************************/
5: /* */
6: /* Reduced DCB layout for byte */
7: /* communication. */
8: /* */
9: /****************************************/
10:
11: asm(".set CPMDCB,21");
12: asm(".set DC_OFF,2");
13: asm(".set DC_ON,1");
14: asm(".set MME,9");
15: asm(".set DCR,27");
16: asm(".set PDCS,28");
17: asm(".set CTL_SW,0x41b"); /* Addr of switches to turn on Cache, MME, Fault */
18: long tmp_lw;
19:
20:
21: #define CPBUFLEN 200 /* Output buffer length */
22: struct cphdr
23: {
24: char cp_unit; /* Done bit & unit # */
25: char cp_comm; /* Command */
26: short cp_count; /* Counter (when relevant) */
27: };
28:
29: struct cpdcb_o /* Output structure */
30: {
31: struct cphdr cp_hdr;
32: char cp_buf[CPBUFLEN]; /* Buffer for output or 'stty' */
33: };
34:
35: struct cpdcb_i /* Structure for input */
36: {
37: struct cphdr cp_hdr;
38: char cpi_buf[4]; /* Buffer for input */
39: };
40:
41: #define CPDONE 0x80 /* 'Done' bit in cp_unit */
42: #define CPTAKE 0x40 /* CP 'ack' to this cpdcb */
43:
44: /* Values for 'unit' */
45: #define CPUNIT 0 /* The CP itself */
46: #define CPCONS 1 /* Console line */
47: #define CPREMOT 2 /* Remote line */
48:
49: /* Values for 'command' */
50: #define CPRESET 0
51: #define CPWRITE 1
52: #define CPREAD 2
53: #define CPSTTY 3
54: #define CPBOOT 4
55:
56:
57: /* Put a char to CPU2 console */
58:
59: #define NCHAR 1
60:
61: long cpbuf_sz = 1; /* Buffer size */
62: long charcnt = 0;
63: struct cpdcb_o cpout; /* DCB for output */
64:
65: asm(".set HISR,0x410");
66:
67: putstr(str)
68: char *str;
69: { long c_cnt;
70:
71: cpout.cp_hdr.cp_unit = CPCONS; /* Reset done bit */
72: cpout.cp_hdr.cp_comm = CPWRITE; /* Set command */
73: for(c_cnt=0;;c_cnt++) {
74: cpout.cp_buf[c_cnt] = *str++;
75: if (cpout.cp_buf[c_cnt]=='\n') {
76: c_cnt++;
77: cpout.cp_buf[c_cnt]='\r';
78: }
79: if (cpout.cp_buf[c_cnt]=='\0') break;
80: }
81: if (c_cnt) {
82: cpout.cp_hdr.cp_count = c_cnt;
83: cp_poll('\0'); }
84: }
85:
86: putchar(c)
87: {
88: cpout.cp_hdr.cp_unit = CPCONS; /* Reset done bit */
89: cpout.cp_hdr.cp_comm = CPWRITE; /* Set command */
90: cpout.cp_buf[charcnt] = c;
91: cpout.cp_hdr.cp_count = 1;
92: cp_poll(c);
93: }
94:
95: cp_poll(c)
96: char c;
97: { register long time, r11;
98:
99: time = 0x1ff0000;
100: asm("movab _cpout,r10");
101: asm("andl2 $0xffffff,r10");
102: asm("mtpr r10,$CPMDCB");
103: tmp_lw = (long)(&cpout.cp_hdr.cp_unit);
104:
105: r11 = (long)(&cpout.cp_hdr.cp_unit);
106: while (time-- && !(cpout.cp_hdr.cp_unit & CPDONE)) {
107: asm("mtpr r11,$0x1c"); /* mtpr r11,$PDCS */
108: }
109: if (!(cpout.cp_hdr.cp_unit & CPDONE)) cp_hlt(); /* Time out */
110: if (c== '\n') putchar('\r');
111: }
112:
113: cp_hlt()
114: {
115: asm("movl $0xeeeeeeee,r0");
116: asm("movl $0xeeeeeeee,r1");
117: asm("movl $0xeeeeeeee,r2");
118: asm("halt");
119: }
120:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.