1/* $NetBSD: locore_machdep.S,v 1.18 2001/08/27 02:00:19 nisimura Exp $ */ 2 3/* 4 * Copyright (c) 1992, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Digital Equipment Corporation and Ralph Campbell. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * Copyright (C) 1989 Digital Equipment Corporation. 39 * Permission to use, copy, modify, and distribute this software and 40 * its documentation for any purpose and without fee is hereby granted, 41 * provided that the above copyright notice appears in all copies. 42 * Digital Equipment Corporation makes no representations about the 43 * suitability of this software for any purpose. It is provided "as is" 44 * without express or implied warranty. 45 * 46 * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/loMem.s, 47 * v 1.1 89/07/11 17:55:04 nelson Exp SPRITE (DECWRL) 48 * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsm.s, 49 * v 9.2 90/01/29 18:00:39 shirriff Exp SPRITE (DECWRL) 50 * from: Header: /sprite/src/kernel/vm/ds3100.md/vmPmaxAsm.s, 51 * v 1.1 89/07/10 14:27:41 nelson Exp SPRITE (DECWRL) 52 * 53 * @(#)locore.s 8.5 (Berkeley) 1/4/94 54 */ 55 56/* 57 * DECstation-specific mips locore code. 58 */ 59 60#include <mips/asm.h> 61#include <mips/cpuregs.h> /* XXX - misnomer? */ 62 63#include "sii.h" 64#include "opt_dec_5100.h" 65#include "opt_dec_5400.h" 66 67 .set noreorder 68 69#if NSII > 0 70/* 71 * Copy data to a DMA buffer padded with 16 bits of data, 16 72 * bits of padding per 32bit word (e.g., for pmin/pmax sii DMA). 73 * 74 * The DMA bufffer can only be written one short at a time 75 * (and takes ~14 cycles). 76 * 77 * CopyToBuffer(src, dst, length) 78 * u_short *src; NOTE: must be short aligned 79 * u_short *dst; 80 * int length; 81 */ 82LEAF(CopyToBuffer) 83 blez a2, 2f 84 nop 851: 86 lhu t0, 0(a0) # read 2 bytes of data 87 subu a2, a2, 2 88 addu a0, a0, 2 89 addu a1, a1, 4 90 bgtz a2, 1b 91 sh t0, -4(a1) # write 2 bytes of data to buffer 922: 93 j ra 94 nop 95END(CopyToBuffer) 96 97/* 98 * Copy data from the DMA buffer. 99 * The DMA bufffer can only be read one short at a time 100 * (and takes ~12 cycles). 101 * 102 * CopyFromBuffer(src, dst, length) 103 * u_short *src; 104 * char *dst; 105 * int length; 106 */ 107LEAF(CopyFromBuffer) 108 and t0, a1, 1 # test for aligned dst 109 beq t0, zero, 3f 110 nop 111 blt a2, 2, 7f # at least 2 bytes to copy? 112 nop 1131: 114 lhu t0, 0(a0) # read 2 bytes of data from buffer 115 addu a0, a0, 4 # keep buffer pointer word aligned 116 addu a1, a1, 2 117 subu a2, a2, 2 118 sb t0, -2(a1) 119 srl t0, t0, 8 120 bge a2, 2, 1b 121 sb t0, -1(a1) 1223: 123 blt a2, 2, 7f # at least 2 bytes to copy? 124 nop 1256: 126 lhu t0, 0(a0) # read 2 bytes of data from buffer 127 addu a0, a0, 4 # keep buffer pointer word aligned 128 addu a1, a1, 2 129 subu a2, a2, 2 130 bge a2, 2, 6b 131 sh t0, -2(a1) 1327: 133 ble a2, zero, 9f # done? 134 nop 135 lhu t0, 0(a0) # copy one more byte 136 nop 137 sb t0, 0(a1) 1389: 139 j ra 140 nop 141END(CopyFromBuffer) 142#endif /* NSII > 0 */ 143 144/* 145 * Write-buffer flush for writebuffer hardware on DEC mips r2000a 146 */ 147#if defined(DEC_5100) || defined(DEC_5400) 148LEAF(dec_mips1_wbflush) 149ALEAF(kn230_wbflush) 150ALEAF(kn210_wbflush) 151 mfc0 v0, MIPS_COP_0_STATUS_REG # save original SR in v0 152 li t0, 0x80000000 # set CU3 bit 153 or v1, v0 ,t0 # v1 = v0 | 0x80000000 154 nop 155 mtc0 v1, MIPS_COP_0_STATUS_REG 156 nop /* two more cycles to complete */ 157 nop 158 1591: # spin 160 bc3f 1b # until write buffer drained 161 nop # (branch delay slot) 162 163 mtc0 v0, MIPS_COP_0_STATUS_REG # restore SR on exit 164 nop 165 j ra 166 nop 167END(dec_mips1_wbflush) 168#endif /* defined(DEC_5100) || defined(DEC_5400) */ 169 170/* 171 * Interrupt counters for vmstat. 172 */ 173 .data 174EXPORT(intrnames) 175 .asciiz "serial0" 176 .asciiz "serial1" 177 .asciiz "ether" 178 .asciiz "scsi" 179 .asciiz "optslot0" 180 .asciiz "optslot1" 181 .asciiz "optslot2" 182 .asciiz "dtop" 183 .asciiz "isdn" 184 .asciiz "floppy" 185EXPORT(eintrnames) 186 .align 2 187EXPORT(intrcnt) 188 .word 0,0,0,0, 0,0,0,0, 0,0,0,0 189EXPORT(eintrcnt) 190 .word 0 # This shouldn't be needed but with 4.4bsd's as, the eintrcnt 191 # label ends end up in a different section otherwise. 192