3a4,5 . / modified 1/9/78 (jfh) to add Rk0 swap area dump from NSA 11/45 . 6d7 * / jsq BBN 3-14-79 7a9,11 . RKCS = 177404 / RK csr for dump . rkstart = 4360. / allow 512. blocks for dump (won't all fit) . 101a106 . / Character list get/put 103,118c108 * / =========================== C L I S T ============================== / * / * / These routines manipulate character queues of the form declared in * / tty.h. putc(char, queue) puts a char on the tail of the queue; * / getc(queue) returns a char from the head of the queue. unputc(queue) * / returns a char from the tail of the queue, that is, the last char * / putc'ed. * / * / This implementation differs from the standard one in that * / in addition to handling char values from 0 to 255, it can also * / handle values from -2 to -256. They are represented internally * / with a 255 byte as prefix. A plain 255 byte is represented as * / 255 255. (Note that -1 comes out as 255.) These additional values ease the * / task of providing a true 8-bit path in the driver. * / putc, unputc, getc are NOT significantly less efficient in the normal case. * --- . .globl _getc, _putc 121,130c111,112 * / --------------------------- P U T C ----------------------------- / * / * / putc(char, queue_ptr) puts the char (actually an int) on the specified * / queue. It returns 0 if it was successful, a nonzero value if it was not. * / * .globl _putc * _putc: * mov 2(sp),r0 / r0 := char * mov 4(sp),r1 / r1 := q_ptr * / save environment --- . _getc: . mov 2(sp),r1 133,159c115,122 * mov r3,-(sp) * * bis $340,PS * bic $100,PS / spl 5 * cmp r0,$377 / is it >= 0377 (unsigned)? * bhis esc_put / yes. * jsr pc, putc / no, do it normally * br rest / done * esc_put: * mov $377,r0 / yes. Load escape char * jsr pc, putc / enter it * mov 10(sp),r0 / get char again * jsr pc, putc / enter it * beq rest / if it worked, done * / Here \377 entered, but char did not. Remove \377 and report failure. * jsr pc, unputc * / The \377 will serve as a nonzero return value. * * / restore environment * rest: * mov (sp)+,r3 * mov (sp)+,r2 * mov (sp)+,PS * rts pc * * putc: / char in r0, q_ptr in r1; clobbers r2, r3 * mov 4(r1),r2 / r2 := c_cl --- . bis $340,PS . bic $100,PS / spl 5 . mov 2(r1),r2 / first ptr . beq 9f / empty . movb (r2)+,r0 / character . bic $!377,r0 . mov r2,2(r1) . dec (r1)+ / count 161,168c124,125 * * / first time, get clist block * * mov _cfreelist,r2 / r2 := &clist * beq 9f / zero? moby loss * mov (r2),_cfreelist / unchain clist * clr (r2)+ / clear its ptr, r2++ * mov r2,2(r1) / c_cf := r2 (incremented) --- . clr (r1)+ . clr (r1)+ / last block 170,172d126 * * / not first time. Check if c_cl points just after last char position in block * 174,181c128,131 * bit $7,r2 / need new block? * bne 2f / if nonzero, no. * mov _cfreelist,r3 / else r3 := &clist * beq 9f / zero? moby loss * mov (r3),_cfreelist / unchain clist block * mov r3,-10(r2) / make current clist chain ptr -> new block * mov r3,r2 * clr (r2)+ / and zero new block's chain ptr --- . bit $7,r2 . bne 3f . mov -10(r2),(r1) / next block . add $2,(r1) 183,189c133,139 * * / here r2 finally points at a nice place to put a char * * movb r0,(r2)+ / put in char * mov r2,4(r1) / update c_cl * inc (r1) / and c_cc * clr r0 / return zero --- . dec r2 . bic $7,r2 . mov _cfreelist,(r2) . mov r2,_cfreelist . 3: . mov (sp)+,r2 . mov (sp)+,PS 191,193d140 * * / moby loss, no free storage * 195c142,145 * mov pc,r0 / return nonzero value --- . clr 4(r1) . mov $-1,r0 . mov (sp)+,r2 . mov (sp)+,PS 198,207c148,150 * / --------------------------- G E T C ---------------------------- * / * / getc -- get a char from a clist * / * / use: c = getc(queue_ptr) * / returns -1 if empty * * .globl _getc * * _getc: --- . _putc: . mov 2(sp),r0 . mov 4(sp),r1 210,231c153,156 * bis $340,PS * bic $100,PS / spl 5 * jsr pc,getc / get char * cmp r0,$377 / escape char? * bne done / no, all done * jsr pc,getc / yes, get following char * cmp r0,$377 / also escape? * beq done / if so, all done * bis $!377,r0 / if not, must be negative value * done: * mov (sp)+,r2 * mov (sp)+,PS * rts pc / and leave * * getc: / q_ptr at 10(sp); clobbers r2 * mov 10(sp),r1 / r1 := q_ptr * mov 2(r1),r2 / r2 := c_cf * beq 9f / empty * movb (r2)+,r0 / r0 := char * bic $!377,r0 / undo sign-extension * mov r2,2(r1) / update c_cf * dec (r1)+ / update c_cc --- . mov r3,-(sp) . bis $340,PS . bic $100,PS / spl 5 . mov 4(r1),r2 / last ptr 233,237c158,163 * / here was last block * clr (r1)+ / zero c_cf * clr (r1)+ / zero c_cl * br 2f / go put block on cfreelist * --- . mov _cfreelist,r2 . beq 9f . mov (r2),_cfreelist . clr (r2)+ . mov r2,2(r1) / first ptr . br 2f 239,243c165,172 * bit $7,r2 / end of block? * bne 3f / nope * mov -10(r2),(r1) / yes, update c_cf to point to next block * add $2,(r1) / actually to first char of that block * / here free block --- . bit $7,r2 . bne 2f . mov _cfreelist,r3 . beq 9f . mov (r3),_cfreelist . mov r3,-10(r2) . mov r3,r2 . clr (r2)+ 245,250c174,180 * dec r2 / get back into current block * bic $7,r2 / make pointer to base of block * mov _cfreelist,(r2) / chain it onto free list * mov r2,_cfreelist * / here leave, all OK * 3: --- . movb r0,(r2)+ . mov r2,4(r1) . inc (r1) / count . clr r0 . mov (sp)+,r3 . mov (sp)+,r2 . mov (sp)+,PS 252,254d181 * * / no char to give! * 256,257c183,186 * clr 4(r1) / zero c_cl??? * mov $-1,r0 / return -1 --- . mov pc,r0 . mov (sp)+,r3 . mov (sp)+,r2 . mov (sp)+,PS 260,338d188 * / --------------------------- U N P U T C --------------------------- / * / * / char = unputc(queue_ptr) is like getc, but gets char from tail of * / queue instead of head, thus undoing last putc. * / Modified by BBN:Dan Franklin for escape byte processing. * * .globl _unputc * * _unputc: * mov PS, -(sp) / up priority * bis $340,PS * bic $100,PS / spl 5 * mov r2, -(sp) / save r2 * mov 6(sp), r1 / r1 := q_ptr * jsr pc, unputc / get last char * mov r0, r2 * blt finish / if neg, must be empty * / here we got a char. Peek at previous to see if it's escape. * mov 6(sp), r1 / r1 := q_ptr * mov 4(r1), r1 / r1 := c_cl * beq finish / if zero, there is no previous char * cmpb -(r1),$377 / is previous char escape byte? * bne finish / nope, go away * / here previous was escape byte. Remove it and set high byte of char. * mov 6(sp), r1 / r1 := q_ptr * jsr pc, unputc / else get it for real * mov r2, r0 * cmp $377, r0 * beq finish / \377 \377 maps into \377, not -1 * bis $!377, r0 * finish: * mov (sp)+, r2 * mov (sp)+, PS * rts pc * * / unputc: qp in R1, char left in R0; clobbers r1 * unputc: / Mike Patrick, June 76 * mov r2,-(sp) / save regs * mov r3,-(sp) * * mov 4(r1),r2 / c_cl into r2 * beq 5f / if 0, empty queue * dec r2 / Last char put in * movb (r2),r0 / char into r0 * bic $!377,r0 / undo DEC braindamage * dec (r1)+ / decrement count, advance r1 * beq 4f / if zilch, empty queue now * bit $5,r2 / check if emptied block * bne 3f / if not 010b, return. (can't be 000b) * bic $7,r2 / point to c_next * mov _cfreelist,(r2) / put empty block on freelist * mov r2,_cfreelist * mov (r1),r3 / c_cf into r3 * bic $7,r3 / ptr to next block down the line * 1: cmp (r3),r2 / block preceding c_cl's ? * beq 2f * mov (r3),r3 / nope, move down the line * br 1b * 2: / yep * clr (r3) / end of list * mov r3,r2 * add $10,r2 / r2 now points past last char put in * 3: * mov r2,2(r1) / New c_cl * br 9f / return * * 4: clr (r1)+ / c_cf zeroed * clr (r1)+ / c_cl " * bic $7,r2 * mov _cfreelist,(r2) / put block on freelist * mov r2,_cfreelist * br 9f / return * * 5: mov $-1,r0 / error condition * * 9: * mov (sp)+,r3 / restore state * mov (sp)+,r2 * rts pc / bye! 364,365c214,215 * asr (sp) * asr (sp) --- . asr (sp) . asr (sp) 733d582 * _spl_imp: 734a584 . _spl_imp: 833a684 . / Dump entries 852,853c703 * / dump all of core (ie to first mt error) * / onto mag tape. (9 track or 7 track 'binary') --- . / dump all of core to swap area -- note it won't all fit for now 855,856c705,706 * mov $MTC,r0 * mov $60004,(r0)+ --- . mov $RKCS,r0 . mov $2,(r0)+ 857a708 . mov $[rkstart\/12.*16.|[rkstart%12.]],4(r0) 859c710 * mov $-512.,(r0) --- . mov $-256.,(r0) 867,870d717 * * / end of file and loop * * mov $60007,-(r0) 872a720 . 960,964d807 * .globl _itol * _itol: mov 2(sp),r0 * mov 4(sp),r1 * rts pc * 976,979c819,822 * mov r5,r2 * mov -(r2),r4 * mov -(r2),r3 * mov -(r2),r2 --- . mov r5,r1 . mov -(r1),r4 . mov -(r1),r3 . mov -(r1),r2 990,992d832 * .globl _u * _u = 140000 * usize = 16. 994,1006c834,835 * PS = 177776 * SSR0 = 177572 * SSR2 = 177576 * KISA0 = 172340 * KISA6 = 172354 * KISD0 = 172300 * MTC = 172522 * UISA0 = 177640 * UISA1 = 177642 * UISD0 = 177600 * UISD1 = 177602 * IO = 7600 * --- . . 1023,1028d851 * / machine language part of reboot system call. * / reads block 0 off of disk into the low 512 bytes of memory, * / then executes it. This is the usual bootstrap (the one * / with the @ prompt to which you type /unix or whatever). * / if r4 contains a special code, r4 contains an inumber * / No need to enter a name on tty8. 1030,1043d852 * .if .rkboot * .globl _rkboot * _rkboot: * reset / resets memory mapping, etc. * mov $177412,r1 / clear disk sector address * clr (r1) / set track and block address * clr -(r1) / unibus address * mov $-256.,-(r1) / word count * mov $05,-(r1) / read and go in controller * 1: * tstb (r1) / wait until done * bge 1b * clr pc / execute it * .endif 1045,1054c854,861 * .if .hpboot * .globl _hpboot * _hpboot: * hpda = 176706 * hpca = 176734 * reset /clears HPCS2, HPBAE, drive and unit select,disables interrupts * clr *$hpca * mov $hpda,r1 * clr (r1) / set track and block address to zero * clr -(r1) / read 512 bytes into low memory --- . . .globl _rkboot . _rkboot: . /Modified to work for RK05 driver (BBN: jfh 4/78) . reset / disable interrupts and mem mgmt . mov $177412,r1 / RKDA . clr (r1) / set disk address to zero . clr -(r1) / read 512 bytes into low memory 1056,1058c863,864 * mov $71,-(r1) / read and go * 1: * tstb (r1) / wait until done --- . mov $05,-(r1) . 1: tstb (r1) / wait until done 1060,1061c866 * clr pc / execute it * .endif --- . clr pc / execute it 1062a868,884 . .globl _u . _u = 140000 . usize = 16. . . PS = 177776 . SSR0 = 177572 . SSR2 = 177576 . KISA0 = 172340 . KISA6 = 172354 . KISD0 = 172300 . MTC = 172522 . UISA0 = 177640 . UISA1 = 177642 . UISD0 = 177600 . UISD1 = 177602 . IO = 7600 .