2 * Copyright (C) 1993, 1994 by
3 * Digital Equipment Corporation, Maynard, Massachusetts.
6 * This software is furnished under a license and may be used and copied
7 * only in accordance of the terms of such license and with the
8 * inclusion of the above copyright notice. This software or any other
9 * copies thereof may not be provided or otherwise made available to any
10 * other person. No title to and ownership of the software is hereby
13 * The information in this software is subject to change without notice
14 * and should not be construed as a commitment by Digital Equipment
17 * Digital assumes no responsibility for the use or reliability of its
18 * software on equipment which is not supplied by Digital.
23 /*#include "kxalpha.h"*/
24 #include "alpha-regdef.h"
26 #define LEAF_ENTRY(NAME) .text ; .align 4 ; .globl NAME ; .ent NAME, 0 ; NAME: ; .frame sp, 0, ra ; .prologue 0 ;
29 #define PICIACKADR 0xfffffc0100000000
30 #define EISABAD 0xfffffc0200000000
31 #define EISABIO 0xfffffc0300000000
33 #define EISA_BYTE_ADJ 0x80
34 #define EISA_WORD_ADJ 0x100
35 #define EISA_LONG_ADJ 0x200
40 LEAF_ENTRY(flush_i_cache)
42 ret zero, (ra) // return
56 // t - tri-byte 24 bits
60 // Routine Description:
62 // This function uses the 64-bit super-page to write data to a port
63 // of the EISA bus for JENSEN. Only AT (ISA) cycles are supported.
67 // port (a0) - port address on the EISA to which to write data
68 // data (a1) - data to write to the port.
83 // generate super-page address of EISA base address
84 // upper bits must be sign extension of bit 42
85 // va<42:41> = 10 (binary) for super-page address
87 and a0,3,t0 // get byte index from address
88 insbl a1,t0,t5 // put byte in proper position
89 and a0,0x1ffffff,t1 // 25 bit mask
90 ldiq t0,EISABIO // get EISA IO base address
91 sll t1, 7, a0 // shift 7 for EISA
92 bis t0,a0,t0 // t0 = address of EISA
93 stl t5, 0(t0) // write data to port
94 mb // guarantee write ordering
95 ret zero, (ra) // return
104 // generate super-page address of EISA base address
105 // upper bits must be sign extension of bit 42
106 // va<42:41> = 10 (binary) for super-page address
108 and a0,3,t0 // get byte index from address
109 inswl a1,t0,t5 // put byte in proper position
110 and a0,0x1ffffff,t1 // 25 bit mask
111 ldiq t0,EISABIO // get EISA IO base address
112 or t0,0x20,t0 // t0 = ffff fc03 0000 0020 - word
113 sll t1, 7, a0 // shift 7 for EISA
114 bis t0,a0,t0 // t0 = address of EISA
115 stl t5, 0(t0) // write data to port
116 mb // guarantee write ordering
117 ret zero, (ra) // return
126 // generate super-page address of EISA base address
127 // upper bits must be sign extension of bit 42
128 // va<42:41> = 10 (binary) for super-page address
130 and a0,0x1ffffff,t1 // 25 bit mask
131 ldiq t0,EISABIO // get EISA IO base address
132 or t0,0x60,t0 // t0 = ffff fc03 0000 0060 - long
133 sll t1, 7, a0 // shift 7 for EISA
134 bis t0,a0,t0 // t0 = address of EISA
135 stl a1, 0(t0) // write data to port
136 mb // guarantee write ordering
137 ret zero, (ra) // return
147 // generate super-page address of EISA base address
148 // upper bits must be sign extension of bit 42
149 // va<42:41> = 10 (binary) for super-page address
151 sra a0, 3, t0 // right shift addr by 3
152 and t0, 3, t1 // and addr with 3
153 s8addq t1, zero, t2 // multiply by 8
154 sll a1, t2, t3 // left shift data
155 sll a0, 4, t4 // left shift addr by 4
156 lda t0,0xfc00 // t0 = 0000 0000 0000 0c00
157 ldah t0,-1(t0) // t0 = ffff ffff ffff 0c00
158 sll t0,32,t0 // t0 = ffff fc00 0000 0000
159 or t0,t4,t4 // make io address
160 stl t3, 0(t4) // store data
161 mb // guarantee write ordering
162 ret zero, (ra) // return
179 // t - tri-byte 24 bits
182 // Routine Description:
184 // This function uses the 64-bit super-page to read data from an EISA
189 // port (a0) - EISA port number.
193 // data (v0) - the data read and only the low byte is valid
203 // generate super-page address of EISA, base address
204 // upper bits must be sign extension of bit 42
205 // va<42:41> = 10 (binary) for super-page address
207 and a0,0x1ffffff,t1 // 25 bit mask
208 ldiq t0,EISABIO // get EISA IO base address
209 sll t1, 7, t2 // shift 7 for EISA
210 bis t0,t2,t0 // t0 = address of EISA
211 ldl v0, 0(t0) // get EISA IO byte
212 and a0,0x3,t1 // setup word shift count
213 extbl v0,t1,v0 // put into low byte
214 ret zero, (ra) // return
223 // generate super-page address of vti, base address
224 // upper bits must be sign extension of bit 42
225 // va<42:41> = 10 (binary) for super-page address
227 and a0,0x1ffffff,t1 // 25 bit mask
228 ldiq t0,EISABIO // get EISA IO base addr
229 or t0,0x20,t0 // t0 = ffff fc03 0000 0020 - word
230 sll t1, 7, t2 // shift 7 for EISA
231 bis t0,t2,t0 // t0 = address of EISA
232 ldl v0, 0(t0) // load EISA word
233 and a0,0x3,t1 // setup shift count
234 extwl v0,t1,v0 // put into low word
235 ret zero, (ra) // return
245 // generate super-page address of vti, base address
246 // upper bits must be sign extension of bit 42
247 // va<42:41> = 10 (binary) for super-page address
249 and a0,0x1ffffff,t1 // 25 bit mask
250 ldiq t0,EISABIO // get EISA IO base address
251 or t0,0x60,t0 // t0 = ffff fc03 0000 0060
252 sll t1, 7, t2 // shift 7 for EISA
253 bis t0,t2,t0 // t0 = address of EISA
254 ldl v0, 0(t0) // load EISA word
255 ret zero, (ra) // return
264 // generate super-page address of EISA base address
265 // upper bits must be sign extension of bit 42
266 // va<42:41> = 10 (binary) for super-page address
268 sll a0, 4, t5 // left shift address by 4
269 lda t0,0xfc00 // t0 = 0000 0000 0000 fc00
270 ldah t0,-1(t0) // t0 = ffff ffff ffff fc00
271 sll t0,32,t0 // t0 = ffff fc00 0000 0000
272 or t0,t5,t0 // make io address
273 ldl t4, 0(t0) // load data
274 sra a0, 3, t1 // right shift addr by 3
275 and t1, 3, t2 // and addr with 3
276 s8addq t2, zero, t3 // multiply by 8
277 srl t4, t3, v0 // right shift data
278 ret zero, (ra) // return
291 // get Iack from pic, need two to get the vector
294 ldl v0,0(t0) // load data
295 and v0,0xff,v0 // make it a byte
296 ret zero, (ra) // return
305 // generate super-page address of EISA base address
306 // upper bits must be sign extension of bit 42
307 // va<42:41> = 10 (binary) for super-page address
309 and a0,3,t0 // get byte index from address
310 insbl a1,t0,t5 // put byte in proper position
312 and a0,0x1ffffff,t1 // 25 bit mask
313 ldiq t0,EISABAD // get EISA address
315 sll t1, 7, a0 // shift 7 for EISA
316 bis t0,a0,t0 // t0 = address of EISA
317 stl t5, 0(t0) // write data to port
318 ret zero, (ra) // return
326 // generate super-page address of EISA base address
327 // upper bits must be sign extension of bit 42
328 // va<42:41> = 10 (binary) for super-page address
330 and a0,3,t0 // get byte index from address
331 inswl a1,t0,t5 // put byte in proper position
333 and a0,0x1ffffff,t1 // 25 bit mask
335 ldiq t0,EISABAD // get EISA address
336 or t0,0x20,t0 // t0 = ffff fc02 0000 0020 - word
338 sll t1, 7, a0 // shift 7 for EISA
339 bis t0,a0,t0 // t0 = address of EISA
340 stl t5, 0(t0) // write data to port
341 ret zero, (ra) // return
350 // generate super-page address of EISA base address
351 // upper bits must be sign extension of bit 42
352 // va<42:41> = 10 (binary) for super-page address
354 and a0,0x1ffffff,t1 // 25 bit mask
356 ldiq t0,EISABAD // get EISA address
357 or t0,0x60,t0 // t0 = ffff fc02 0000 0060 - long
359 sll t1, 7, a0 // shift 7 for EISA
360 bis t0,a0,t0 // t0 = address of EISA
361 stl a1, 0(t0) // write data to port
362 ret zero, (ra) // return
371 a0 address of destination buffer (byte aligned).
372 a1 address of source buffer in memory (byte aligned)
373 a2 Number of bytes to move (Count).
377 // generate super-page address of EISA base address
378 // upper bits must be sign extension of bit 42
379 // va<42:41> = 10 (binary) for super-page address
381 beq a2, donewb // leave if nothing to do
383 ldiq t0,EISABAD // get EISA address
385 and a0,3,t3 // get byte index from dst address
387 and a0,0x1ffffff,t1 // 25 bit mask
388 sll t1,EISA_SHIFT,t4 // shift 7 for EISA
389 bis t0,t4,t0 // t0 = address of EISA
392 ldq_u t1, 0(a1) // get src data
393 subl a2, 1, a2 // decrement count
394 extbl t1, a1,t1 // extract byte
395 addl a1, 1, a1 // point ot next src address
396 insbl t1,t3,t1 // insert byte in proper place
397 stl t1, 0(t0) // write data to EISA memory
398 addq t0,EISA_BYTE_ADJ, t0 // increment EISA memory pointer
399 addl t3,1,t3 // increment index
400 and t3,3,t3 // mask off overflow
412 a0 address of destination buffer (word aligned), eisa.
413 a1 address of source buffer in memory (word aligned)
414 a2 Number of words to move (Count).
418 // generate super-page address of EISA base address
419 // upper bits must be sign extension of bit 42
420 // va<42:41> = 10 (binary) for super-page address
422 beq a2, doneww // leave if nothing to do
424 ldiq t0,EISABAD // get EISA address
425 or t0,0x20,t0 // t0 = ffff fc02 0000 0020 - word
427 and a0,3,t3 // get word index from dst address
429 and a0,0x1ffffff,t1 // 25 bit mask
430 sll t1,EISA_SHIFT,t4 // shift 7 for EISA
431 bis t0,t4,t0 // t0 = address of EISA
434 ldq_u t1, 0(a1) // get src data
435 subl a2, 1, a2 // decrement count
436 extwl t1, a1,t1 // extract word
437 addl a1, 2, a1 // point ot next src address
438 inswl t1,t3,t1 // insert in proper place
439 stl t1, 0(t0) // write data to EISA memory
440 addq t0,EISA_WORD_ADJ, t0 // increment EISA memory pointer
441 addl t3,2,t3 // increment index
442 and t3,3,t3 // mask off overflow
456 a0 address of destination buffer (long aligned), eisa.
457 a1 address of source buffer in memory (long aligned)
458 a2 Number of longs to move (Count).
462 // generate super-page address of EISA base address
463 // upper bits must be sign extension of bit 42
464 // va<42:41> = 10 (binary) for super-page address
466 beq a2, donewl // leave if nothing to do
468 ldiq t0,EISABAD // get EISA address
469 or t0,0x60,t0 // t0 = ffff fc02 0000 0060 - long
471 and a0,0x1ffffff,t1 // 25 bit mask
472 sll t1,EISA_SHIFT,t4 // shift 7 for EISA
473 bis t0,t4,t0 // t0 = address of EISA
476 ldl t1, 0(a1) // get src data
477 subl a2, 1, a2 // decrement count
478 stl t1, 0(t0) // write data to EISA memory
479 addl a1, 4, a1 // point ot next src address
480 addq t0,EISA_LONG_ADJ, t0 // increment EISA memory pointer
492 // generate super-page address of EISA, base address
493 // upper bits must be sign extension of bit 42
494 // va<42:41> = 10 (binary) for super-page address
496 and a0,0x1ffffff,t1 // 25 bit mask
498 ldiq t0,EISABAD // get EISA address
500 sll t1, 7, t2 // shift 7 for EISA
501 bis t0,t2,t0 // t0 = address of EISA
502 ldl v0, 0(t0) // get EISA byte
504 and a0,0x3,t1 // setup word shift count
505 extbl v0,t1,v0 // put into low byte
507 ret zero, (ra) // return
517 // generate super-page address of EISA, base address
518 // upper bits must be sign extension of bit 42
519 // va<42:41> = 10 (binary) for super-page address
521 and a0,0x1ffffff,t1 // 25 bit mask
523 ldiq t0,EISABAD // get EISA base addr
524 or t0,0x20,t0 // t0 = ffff fc02 0000 0020 - word
526 sll t1, 7, t2 // shift 7 for EISA
527 bis t0,t2,t0 // t0 = address of EISA
529 ldl v0, 0(t0) // get EISA short
531 and a0,0x3,t1 // setup byte shift count
532 extwl v0,t1,v0 // put into low word
534 ret zero, (ra) // return
544 // generate super-page address of EISA, base address
545 // upper bits must be sign extension of bit 42
546 // va<42:41> = 10 (binary) for super-page address
548 and a0,0x1ffffff,t1 // 25 bit mask
550 ldiq t0,EISABAD // get EISA base address
551 or t0,0x60,t0 // t0 = ffff fc02 0000 0060 - long
553 sll t1, 7, t2 // shift 7 for EISA
554 bis t0,t2,t0 // t0 = address of EISA
556 ldl v0, 0(t0) // get EISA 4 bytes
557 ret zero, (ra) // return
569 a0 source buffer in eisa bus memory.
570 a1 destination buffer in memory.
571 a2 Number of bytes to move (Count).
575 // generate super-page address of EISA, base address
576 // upper bits must be sign extension of bit 42
577 // va<42:41> = 10 (binary) for super-page address
579 beq a2, donerb // leave if nothing to do
581 ldiq t0,EISABAD // get EISA base address
583 and a0,3,t3 // get byte index from src address
585 and a0,0x1ffffff,t1 // 25 bit mask
586 sll t1, EISA_SHIFT, t4 // shift 7 for EISA
587 bis t0,t4,t0 // t0 = address of EISA
590 ldl t1, 0(t0) // get EISA 4 bytes
591 subl a2, 1, a2 // decrement byte count
592 extbl t1, t3, t1 // extract byte
593 addq t0, EISA_BYTE_ADJ, t0 // increment EISA address
594 stb t1, 0(a1) // assembler preserves the memory
595 // behind the newly stored byte
596 addl a1, 1, a1 // increment memory pointer
597 addl t3, 1, t3 // point to next byte in long
598 and t3, 3, t3 // get new index
601 ret zero, (ra) // return
612 a0 source buffer in eisa bus memory.
613 a1 destination buffer in memory.
614 a2 Number of words to move (Count).
619 // generate super-page address of EISA, base address
620 // upper bits must be sign extension of bit 42
621 // va<42:41> = 10 (binary) for super-page address
623 beq a2, donerw // leave if nothing to do
625 ldiq t0,EISABAD // get EISA base address
626 or t0,0x20,t0 // t0 = ffff fc02 0000 0020 - word
629 and a0,3,t3 // get byte index from src address
631 and a0,0x1ffffff,t1 // 25 bit mask
632 sll t1, EISA_SHIFT, t4 // shift 7 for EISA
633 bis t0,t4,t0 // t0 = address of EISA
636 ldl t1, 0(t0) // get EISA 4 bytes
637 subl a2, 1, a2 // decrement word count
638 extwl t1, t3, t1 // extract word
639 addq t0, EISA_WORD_ADJ, t0 // increment EISA address
640 stw t1, 0(a1) // store in dst memory
641 addl a1, 2, a1 // increment memory pointer
642 addl t3, 2, t3 // point to next word in long
643 and t3, 3, t3 // get new index
646 ret zero, (ra) // return
656 a0 source buffer in eisa bus memory.
657 a1 destination buffer in memory.
658 a2 Number of longs to move (Count).
662 // generate super-page address of EISA, base address
663 // upper bits must be sign extension of bit 42
664 // va<42:41> = 10 (binary) for super-page address
666 beq a2, donerl // leave if nothing to do
668 ldiq t0,EISABAD // get EISA base address
669 or t0,0x60,t0 // t0 = ffff fc02 0000 0060 - long
671 and a0,0x1ffffff,t1 // 25 bit mask
672 sll t1, EISA_SHIFT, t4 // shift 7 for EISA
673 bis t0,t4,t0 // t0 = address of EISA
676 ldl v0, 0(t0) // get EISA 4 bytes
677 subl a2, 1, a2 // decrement long count
678 stl v0, 0(a1) // store in dst memory
679 addl a1, 4, a1 // increment memory pointer
680 addq t0, EISA_LONG_ADJ, t0 // increment EISA address
683 ret zero, (ra) // return
692 // generate super-page address of EISA, base address
693 // upper bits must be sign extension of bit 42
694 // va<42:41> = 10 (binary) for super-page address
696 lda t0,0xfc01 // t0 = 0000 0000 0000 fc01
697 ldah t0,-1(t0) // t0 = ffff ffff ffff fc01
698 sll t0,32,t0 // t0 = ffff fc01 0000 0000
699 bis t0,0xe0000000,t0 // t0 = ffff fc01 e000 0000
701 ldl v0, 0(t0) // get EISA byte
704 ret zero, (ra) // return
719 // Routine Description:
721 // This function uses the 64-bit super-page to write data to a port
722 // of the on-board VTI combo chip for JENSEN.
726 // port (a0) - port number on VTI chip to which to write data
727 // data (a1) - data to write to the port, only low byte is significant
739 // generate super-page address of vti, base address
740 // N.B. - upper bits must be sign extension of bit 42
741 // va<42:41> = 10 (binary) for super-page address
744 lda t0, 0xc01c(zero) // t0 = 0000 0000 0000 c01c
745 ldah t0, -1(t0) // t0 = ffff ffff ffff c01c
746 sll t0, 28, t0 // t0 = ffff fc01 c000 0000
750 // Shift in the port number to generate the port address we
752 // N.B. - access width is always zero = byte access for VTI
755 sll a0, 9, a0 // a0 << 9
756 bis t0, a0, t0 // t0 = address of VTI port
760 // Do the port write, guarantee that subsequent writes (and reads)
761 // are ordered with respect to this write and return to caller
764 stl a1, 0(t0) // write data to port
765 mb // guarantee write ordering
767 ret zero, (ra) // return
780 // Routine Description:
782 // This function uses the 64-bit super-page to read data from a port
783 // of the on-board VTI combo chip for JENSEN.
787 // port (a0) - port number on VTI chip to which to write data
791 // data (v0) - the data read from the VTI chip, only the low byte will
799 // generate super-page address of vti, base address
800 // N.B. - upper bits must be sign extension of bit 42
801 // va<42:41> = 10 (binary) for super-page address
804 lda t0, 0xc01c(zero) // t0 = 0000 0000 0000 c01c
805 ldah t0, -1(t0) // t0 = ffff ffff ffff c01c
806 sll t0, 28, t0 // t0 = ffff fc01 c000 0000
810 // Shift in the port number to generate the port address we
812 // N.B. - access width for VTI is always 0 = byte access
815 sll a0, 9, a0 // a0 << 9
816 bis t0, a0, t0 // t0 = address of VTI port
820 // Do the super-page i/o access and return data to caller
823 ldl v0, 0(t0) // read data from port
826 ret zero, (ra) // return
833 bis zero, ONE_USEC, t1
834 rpcc t0 /* RCC T0, read cycle counter */
836 loop0: rpcc t2 /* RCC T2, read cycle counter */
837 subl t2, t0, t2 /* check for wrapping */
838 bge t2, over0 /* check, and see if negative */
840 ornot t0, zero, t4 /* calculate the offset */
844 subl t1, t4, t1 /* adjust the counter */
845 and zero, t0, t0 /* set t0 to zero */
847 over0: cmplt t2, t1, t2 /* compare these for usec timer */
848 bne t2, loop0 /* stay in... */
849 done0: ret zero, (ra)
854 LEAF_ENTRY(delay_500ns)
855 bis zero, HALF_USEC, t1
856 rpcc t0 /* RCC T0, read cycle counter */
858 loop1: rpcc t2 /* RCC T2, read cycle counter */
859 subl t2, t0, t2 /* check for wrapping */
860 bge t2, over1 /* check, and see if negative */
862 ornot t0, zero, t4 /* calculate the offset */
866 subl t1, t4, t1 /* adjust the counter */
867 and zero, t0, t0 /* set t0 to zero */
869 over1: cmplt t2, t1, t2 /* compare these for usec timer */
870 bne t2, loop1 /* stay in... */
871 done1: ret zero, (ra)