/* $NetBSD: uba_sbi.c,v 1.30 2017/05/22 17:15:45 ragge Exp $ */
/*
* Copyright (c) 1982, 1986 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)uba.c 7.10 (Berkeley) 12/16/90
* @(#)autoconf.c 7.20 (Berkeley) 5/9/91
*/
/*
* Copyright (c) 1996 Jonathan Stone.
* Copyright (c) 1994, 1996 Ludd, University of Lule}, Sweden.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)uba.c 7.10 (Berkeley) 12/16/90
* @(#)autoconf.c 7.20 (Berkeley) 5/9/91
*/
/*
* Abus support added by Johnny Billquist 2010
* Changed UBA code to need to know less of the innards of the
* actual machine at the same time. Information passed down from
* the SBI bus instead.
*/
int
dw780_match(device_t parent, cfdata_t cf, void *aux)
{
struct sbi_attach_args * const sa = aux;
if (cf->cf_loc[SBICF_TR] != sa->sa_nexnum &&
cf->cf_loc[SBICF_TR] != SBICF_TR_DEFAULT)
return 0;
/*
* The uba type is actually only telling where the uba
* space is in nexus space.
*/
if ((sa->sa_type & ~3) != NEX_UBA0)
return 0;
uvec->ev_count--; /* This interrupt should not be counted against
the uba. */
ivec = &scb_vec[(vc->uh_ibase + vec)/4];
if (cold && *ivec->hoppaddr == scb_stray) {
scb_fake(vec + vc->uh_ibase, br);
} else {
if (*ivec->hoppaddr == scb_stray)
strayint.ev_count++; /* Count against stray int */
else
ivec->ev->ev_count++; /* Count against device */
(*ivec->hoppaddr)(ivec->pushlarg);
}
}
int ubawedgecnt = 10;
int ubacrazy = 500;
int zvcnt_max = 5000; /* in 8 sec */
int ubaerrcnt;
/*
* This routine is called by the locore code to process a UBA
* error on an 11/780 or 8600. The arguments are passed
* on the stack, and value-result (through some trickery).
* In particular, the uvec argument is used for further
* uba processing so the result aspect of it is very important.
*/
/*ARGSUSED*/
void
ubaerror(struct uba_softc *uh, int *ipl, int *uvec)
{
struct uba_vsoftc *vc = (void *)uh;
struct uba_regs *uba = vc->uv_uba;
int sr, s;
char sbuf[256], sbuf2[256];
if (*uvec == 0) {
/*
* Declare dt as unsigned so that negative values
* are handled as >8 below, in case time was set back.
*/
u_long dt = time_second - vc->uh_zvtime;
vc->uh_zvtotal++;
if (dt > 8) {
vc->uh_zvtime = time_second;
vc->uh_zvcnt = 0;
}
if (++vc->uh_zvcnt > zvcnt_max) {
aprint_error_dev(vc->uv_sc.uh_dev,
"too many zero vectors (%d in <%d sec)\n",
vc->uh_zvcnt, (int)dt + 1);