|
|
Power 6/32 Unix version 1.21
/* Console Processor Interface */
/* Tahoe version, Nov. 1982 */
/****************************************/
/* */
/* Reduced DCB layout for byte */
/* communication. */
/* */
/****************************************/
asm(".set CPMDCB,21");
asm(".set DC_OFF,2");
asm(".set DC_ON,1");
asm(".set MME,9");
asm(".set DCR,27");
asm(".set PDCS,28");
asm(".set CTL_SW,0x41b"); /* Addr of switches to turn on Cache, MME, Fault */
long tmp_lw;
#define CPBUFLEN 200 /* Output buffer length */
struct cphdr
{
char cp_unit; /* Done bit & unit # */
char cp_comm; /* Command */
short cp_count; /* Counter (when relevant) */
};
struct cpdcb_o /* Output structure */
{
struct cphdr cp_hdr;
char cp_buf[CPBUFLEN]; /* Buffer for output or 'stty' */
};
struct cpdcb_i /* Structure for input */
{
struct cphdr cp_hdr;
char cpi_buf[4]; /* Buffer for input */
};
#define CPDONE 0x80 /* 'Done' bit in cp_unit */
#define CPTAKE 0x40 /* CP 'ack' to this cpdcb */
/* Values for 'unit' */
#define CPUNIT 0 /* The CP itself */
#define CPCONS 1 /* Console line */
#define CPREMOT 2 /* Remote line */
/* Values for 'command' */
#define CPRESET 0
#define CPWRITE 1
#define CPREAD 2
#define CPSTTY 3
#define CPBOOT 4
/* Put a char to CPU2 console */
#define NCHAR 1
long cpbuf_sz = 1; /* Buffer size */
long charcnt = 0;
struct cpdcb_o cpout; /* DCB for output */
struct cpdcb_i cpin; /* DCB for input */
asm(".set HISR,0x410");
putstr(str)
char *str;
{ long c_cnt;
cpout.cp_hdr.cp_unit = CPCONS; /* Reset done bit */
cpout.cp_hdr.cp_comm = CPWRITE; /* Set command */
for(c_cnt=0;;c_cnt++) {
cpout.cp_buf[c_cnt] = *str++;
if (cpout.cp_buf[c_cnt]=='\n') {
c_cnt++;
cpout.cp_buf[c_cnt]='\r';
}
if (cpout.cp_buf[c_cnt]=='\0') break;
}
if (c_cnt) {
cpout.cp_hdr.cp_count = c_cnt;
cp_poll('\0'); }
}
putchar(c)
{
cpout.cp_hdr.cp_unit = CPCONS; /* Reset done bit */
cpout.cp_hdr.cp_comm = CPWRITE; /* Set command */
cpout.cp_buf[charcnt] = c;
cpout.cp_hdr.cp_count = 1;
cp_poll(c);
}
char rdchar()
{
register long r12;
cpin.cp_hdr.cp_unit = CPCONS; /* Reset done bit */
cpin.cp_hdr.cp_comm = CPREAD; /* Set command */
cpin.cp_hdr.cp_count = 1;
cp_pollr();
r12 = (long)(&cpin.cpi_buf[0]);
asm("mtpr r12,$0x1c"); /* mtpr r11,$PDCS */
return(cpin.cpi_buf[0] & 0x7f);
}
/* Poll CP on read
*/
cp_pollr()
{ register long r12, r11, time;
r12 = ((long)&cpin) & 0xffffff;
asm("mtpr r12,$CPMDCB");
r11 = (long)(&cpin.cp_hdr.cp_unit);
while (!(cpin.cp_hdr.cp_unit & CPDONE)) {
asm("mtpr r11,$0x1c"); /* mtpr r11,$PDCS */
}
if (!(cpin.cp_hdr.cp_unit & CPDONE)) cp_hlt(); /* Time out */
}
/* Poll CP on write
*/
cp_poll(c)
char c;
{ register long r12, r11, time;
time = 200000;
r12 = ((long)&cpout) & 0xffffff;
asm("mtpr r12,$CPMDCB");
asm("mtpr r12,$CPMDCB");
r11 = (long)(&cpout.cp_hdr.cp_unit);
while (time-- && !(cpout.cp_hdr.cp_unit & CPDONE)) {
asm("mtpr r11,$0x1c"); /* mtpr r11,$PDCS */
}
if (!(cpout.cp_hdr.cp_unit & CPDONE)) cp_hlt(); /* Time out */
if (c== '\n') putchar('\r');
}
cp_hlt()
{
asm("movl $0xeeeeeeee,r0");
asm("movl $0xeeeeeeee,r1");
asm("movl $0xeeeeeeee,r2");
asm("halt");
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.