VAXstation CPU and serial console support.

This commit is contained in:
ragge 1996-07-20 18:29:49 +00:00
parent 7707223bc4
commit a8f6512e6d
6 changed files with 1659 additions and 0 deletions

344
sys/arch/vax/vax/dzcons.c Normal file
View File

@ -0,0 +1,344 @@
/* $NetBSD: dzcons.c,v 1.1 1996/07/20 18:29:49 ragge Exp $ */
/*
* Copyright (c) 1994 Gordon W. Ross
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed at Ludd, University of Lule}.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*
* kd.c,v 1.2 1994/05/05 04:46:51 gwr Exp $
*/
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/file.h>
#include <sys/conf.h>
#include <sys/device.h>
#include <sys/reboot.h>
#include <dev/cons.h>
#include <machine/mtpr.h>
#include <machine/sid.h>
#include <machine/uvax.h>
#include <machine/ka410.h>
#include <machine/../vax/gencons.h>
volatile unsigned char *ka410_intreq = (void*)KA410_INTREQ;
volatile unsigned char *ka410_intclr = (void*)KA410_INTCLR;
volatile unsigned char *ka410_intmsk = (void*)KA410_INTMSK;
/*----------------------------------------------------------------------*/
int
dzcngetc(dev)
dev_t dev;
{
int c;
int mapen;
int imsk;
imsk = *ka410_intmsk; /* save interrupt-mask */
*ka410_intmsk = 0; /* disable console-receive interrupt! */
#if 0
do {
c = get_fp() & 0xFF; /* 0x7F ??? */
} while (c == 17 || c == 19); /* ignore XON/XOFF */
*ka410_intclr = 0x80; /* clear the interrupt request */
*ka410_intmsk = imsk; /* restore interrupt-mask */
#else
for (;;)
;
#endif
if (c == 13)
c = 10;
return (c);
}
#define REG(name) short name; short X##name##X;
static volatile struct {/* base address of DZ-controller: 0x200A0000 */
REG(csr); /* 00 Csr: control/status register */
REG(rbuf); /* 04 Rbuf/Lpr: receive buffer/line param reg. */
REG(tcr); /* 08 Tcr: transmit console register */
REG(tdr); /* 0C Msr/Tdr: modem status reg/transmit data reg */
REG(lpr0); /* 10 Lpr0: */
REG(lpr1); /* 14 Lpr0: */
REG(lpr2); /* 18 Lpr0: */
REG(lpr3); /* 1C Lpr0: */
} *dz = (void*)0x200A0000;
#undef REG
struct tty *dzcn_tty[1];
int dzcnparam();
void dzcnstart();
int ka410_consintr_enable __P((void));
int
dzcnopen(dev, flag, mode, p)
dev_t dev;
int flag, mode;
struct proc *p;
{
int unit;
struct tty *tp;
unit = minor(dev);
if (unit) return ENXIO;
tp = dzcn_tty[0];
tp->t_oproc = dzcnstart;
tp->t_param = dzcnparam;
tp->t_dev = dev;
if ((tp->t_state & TS_ISOPEN) == 0) {
tp->t_state |= TS_WOPEN;
ttychars(tp);
tp->t_iflag = TTYDEF_IFLAG;
tp->t_oflag = TTYDEF_OFLAG;
tp->t_cflag = TTYDEF_CFLAG;
tp->t_lflag = TTYDEF_LFLAG;
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
dzcnparam(tp, &tp->t_termios);
ttsetwater(tp);
} else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
return EBUSY;
tp->t_state |= TS_CARR_ON;
ka410_consintr_enable(); /* Turn on interrupts */
return ((*linesw[tp->t_line].l_open)(dev, tp));
}
int
dzcnclose(dev, flag, mode, p)
dev_t dev;
int flag, mode;
struct proc *p;
{
int unit = minor(dev);
struct tty *tp = dzcn_tty[0];
(*linesw[tp->t_line].l_close)(tp, flag);
ttyclose(tp);
return (0);
}
struct tty *
dzcntty(dev)
dev_t dev;
{
return dzcn_tty[0]; /* XXX */
}
int
dzcnread(dev, uio, flag)
dev_t dev;
struct uio *uio;
int flag;
{
int unit = minor(dev);
struct tty *tp = dzcn_tty[0];
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
}
int
dzcnwrite(dev, uio, flag)
dev_t dev;
struct uio *uio;
int flag;
{
int unit = minor(dev);
struct tty *tp = dzcn_tty[0];
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
}
int
dzcnioctl(dev, cmd, data, flag, p)
dev_t dev;
int cmd;
caddr_t data;
int flag;
struct proc *p;
{
int error;
int unit = minor(dev);
struct tty *tp = dzcn_tty[0];
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
if (error >= 0)
return error;
error = ttioctl(tp, cmd, data, flag, p);
if (error >= 0) return error;
return ENOTTY;
}
void
dzcnstart(tp)
struct tty *tp;
{
struct clist *cl;
int s, ch;
s = spltty();
if (tp->t_state & (TS_BUSY|TS_TTSTOP|TS_TIMEOUT))
goto out;
cl = &tp->t_outq;
if(cl->c_cc){
tp->t_state |= TS_BUSY;
ch = getc(cl);
dz->tdr = ch;
} else {
if (tp->t_state & TS_ASLEEP) {
tp->t_state &= ~TS_ASLEEP;
wakeup((caddr_t)cl);
}
selwakeup(&tp->t_wsel);
}
out: splx(s);
}
dzcnrint()
{
struct tty *tp;
int i, j;
tp = dzcn_tty[0];
i = dz->rbuf;
#ifdef DDB
j = kdbrint(i);
if (j == 1) /* Escape received, just return */
return;
if (j == 2) /* Second char wasn't 'D' */
(*linesw[tp->t_line].l_rint)(27, tp);
#endif
(*linesw[tp->t_line].l_rint)(i,tp);
return;
}
int
dzcnstop(tp, flag)
struct tty *tp;
int flag;
{
}
dzcntint()
{
struct tty *tp;
tp = dzcn_tty[0];
tp->t_state &= ~TS_BUSY;
dzcnstart(tp);
}
int
dzcnparam(tp, t)
struct tty *tp;
struct termios *t;
{
/* XXX - These are ignored... */
tp->t_ispeed = t->c_ispeed;
tp->t_ospeed = t->c_ospeed;
tp->t_cflag = t->c_cflag;
return 0;
}
void
dzcnprobe(cndev)
struct consdev *cndev;
{
int i;
switch (vax_boardtype) {
case VAX_BTYP_410:
case VAX_BTYP_43:
break;
default:
cndev->cn_pri = CN_DEAD;
return;
}
for (i = 0; i < nchrdev; i++)
if (cdevsw[i].d_open == dzcnopen) {
cndev->cn_dev = makedev(i,0);
cndev->cn_pri = CN_NORMAL;
return;
}
cndev->cn_pri = CN_DEAD;
return;
}
int
dzcninit(cndev)
struct consdev *cndev;
{
}
dzcnslask()
{
dzcn_tty[0] = ttymalloc();
}
void
dzcnputc(dev,ch)
dev_t dev;
int ch;
{
int timeout = 1<<15; /* don't hang the machine! */
while ((dz->csr & 0x8000) == 0) /* Wait until ready */
if (--timeout < 0)
break;
dz->tdr = ch; /* Put the character */
}
conout(str)
char *str;
{
while (*str)
gencnputc(0, *str++);
}

249
sys/arch/vax/vax/ka410.c Normal file
View File

@ -0,0 +1,249 @@
/* $NetBSD: ka410.c,v 1.1 1996/07/20 18:29:50 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
*
* This code is derived from software contributed to Ludd by Bertram Barth.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed at Ludd, University of
* Lule}, Sweden and its contributors.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <sys/param.h>
#include <sys/types.h>
#include <sys/device.h>
#include <sys/kernel.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
#include <machine/pte.h>
#include <machine/mtpr.h>
#include <machine/sid.h>
#include <machine/pmap.h>
#include <machine/nexus.h>
#include <machine/uvax.h>
#include <machine/ka410.h>
#include <machine/clock.h>
/*
* Maybe all these variables/functions should be static or "integrate"
*/
void ka410_conf __P((struct device*, struct device*, void*));
void ka410_memenable __P((struct sbi_attach_args *, struct device *));
void ka410_steal_pages __P((void));
#ifdef notyet
void ka410_memerr __P((void));
int ka410_mchk __P((caddr_t));
#endif
struct ka410_cpu *ka410_cpuptr = (void*)KA410_CPU_BASE;
struct ka410_clock *ka410_clkptr = (void*)KA410_WAT_BASE;
extern int uVAX_fillmap __P((struct uc_map *));
struct uc_map ka410_map[] = {
{ KA410_CFGTST, KA410_CFGTST+1023, 1024, 0 },
{ KA410_ROM_BASE, KA410_ROM_END, KA410_ROM_SIZE, 0 },
{ KA410_CPU_BASE, KA410_CPU_END, KA410_CPU_SIZE, 0 },
{ KA410_NWA_BASE, KA410_NWA_END, KA410_NWA_SIZE, 0 },
{ KA410_SER_BASE, KA410_SER_END, KA410_SER_SIZE, 0 },
{ KA410_WAT_BASE, KA410_WAT_END, KA410_WAT_SIZE, 0 },
#if 0
{ KA410_SCS_BASE, KA410_SCS_END, KA410_SCS_SIZE, 0 },
#else
{ 0x200C0000, 0x200C01FF, 0x200, 0 },
#endif
{ KA410_LAN_BASE, KA410_LAN_END, KA410_LAN_SIZE, 0 },
{ KA410_CUR_BASE, KA410_CUR_END, KA410_CUR_SIZE, 0 },
{ KA410_DMA_BASE, KA410_DMA_END, KA410_DMA_SIZE, 0 },
/*
* there's more to come, eg. framebuffers (mono + GPX)
*/
{0, 0, 0, 0},
};
int
ka410_setup(uc,flags)
struct uvax_calls *uc;
int flags;
{
uc->uc_name = "ka410";
uc->uc_phys2virt = NULL; /* ka410_mapaddr; */
uc->uc_physmap = ka410_map; /* ptv_map ? p2v_map */
uc->uc_steal_pages = ka410_steal_pages;
uc->uc_conf = ka410_conf;
uc->uc_clkread = ka410_clkread;
uc->uc_clkwrite = ka410_clkwrite;
#ifdef notyet
uc->uc_memerr = ka410_memerr;
uc->uc_mchk = ka410_mchk;
#endif
uc->uc_intreq = (void*)KA410_INTREQ;
uc->uc_intclr = (void*)KA410_INTCLR;
uc->uc_intmsk = (void*)KA410_INTMSK;
uc->uc_busTypes = VAX_VSBUS;
}
void
ka410_conf(parent, self, aux)
struct device *parent, *self;
void *aux;
{
extern char cpu_model[];
if (vax_confdata & 0x80) /* MSB in CFGTST */
strcpy(cpu_model,"MicroVAX 2000");
else
strcpy(cpu_model,"VAXstation 2000");
printf(": %s\n", cpu_model);
}
/*
*
*/
u_long le_iomem; /* base addr of RAM -- CPU's view */
u_long le_ioaddr; /* base addr of RAM -- LANCE's view */
void
ka410_steal_pages()
{
extern vm_offset_t avail_start, virtual_avail, avail_end;
int junk;
int i;
struct {
u_long :2;
u_long data:8;
u_long :22;
} *p;
int *srp; /* Scratch Ram */
char *q = (void*)&srp;
srp = NULL;
p = (void*)KA410_SCR;
for (i=0; i<4; i++) {
printf("p[%d] = %x, ", i, p[i].data);
q[i] = p[i].data;
}
p = (void*)KA410_SCRLEN;
printf("\nlen = %d\n", p->data);
printf("srp = 0x%x\n", srp);
for (i=0; i<0x2; i++) {
printf("%x:0x%x ", i*4, srp[i]);
if ((i & 0x07) == 0x07)
printf("\n");
}
printf("\n");
/*
* SCB is already copied/initialized at addr avail_start
* by pmap_bootstrap(), but it's not yet mapped. Thus we use
* the MAPPHYS() macro to reserve these two pages and to
* perform the mapping. The mapped address is assigned to junk.
*/
MAPPHYS(junk, 2, VM_PROT_READ|VM_PROT_WRITE);
/*
* At top of physical memory there are some console-prom and/or
* restart-specific data. Make this area unavailable.
*/
avail_end -= 10 * NBPG;
/*
* If we need to map physical areas also, we can decrease avail_end
* (the highest available memory-address), copy the stuff into the
* gap between and use pmap_map to map it...
*
* Don't use the MAPPHYS macro here, since this uses and changes(!)
* the value of avail_start. Use MAPVIRT even if it's name misleads.
*/
avail_end -= 10 * NBPG; /* paranoid: has been done before */
avail_end = (int)srp;
avail_end &= ~0xffff; /* make avail_end 64K-aligned */
avail_end -= (64 * 1024); /* steal 64K for LANCE's iobuf */
le_ioaddr = avail_end; /* ioaddr=phys, iomem=virt */
MAPVIRT(le_iomem, (64 * 1024)/NBPG);
pmap_map((vm_offset_t)le_iomem, le_ioaddr, le_ioaddr + 0xffff,
VM_PROT_READ|VM_PROT_WRITE);
printf("le_iomem: %x, le_ioaddr: %x, srp: %x, avail_end: %x\n",
le_iomem, le_ioaddr, srp, avail_end);
/*
* VAXstation 2000 and MicroVAX 2000:
* since there's no bus, we have to map in anything which
* could be neccessary/used/interesting...
*
* MAPVIRT(ptr,count) reserves a virtual area with the requested size
* and initializes ptr to point at this location
* pmap_map(ptr,...) inserts a pair of virtual/physical addresses
* into the system maptable (Sysmap)
*/
uVAX_fillmap(ka410_map);
/*
* Clear restart and boot in progress flags
* in the CPMBX. (ie. clear bits 4 and 5)
*/
ka410_clkptr->cpmbx = (ka410_clkptr->cpmbx & ~0x30);
/*
* Enable memory parity error detection and clear error bits.
*/
ka410_cpuptr->ka410_mser = 1;
/* (UVAXIIMSER_PEN | UVAXIIMSER_MERR | UVAXIIMSER_LEB); */
/*
* MM is not yet enabled, thus we still used the physical addresses,
* but before leaving this routine, we need to reset them to virtual.
*/
ka410_cpuptr = (void*)uvax_phys2virt(KA410_CPU_BASE);
ka410_clkptr = (void*)uvax_phys2virt(KA410_WAT_BASE);
}
/*
* define what we need and overwrite the uVAX_??? names
*/
#define uVAX_clock ka410_clock
#define uVAX_clkptr ka410_clkptr
#define uVAX_clkread ka410_clkread
#define uVAX_clkwrite ka410_clkwrite
#include <arch/vax/vax/uvax_proto.c>

444
sys/arch/vax/vax/ka43.c Normal file
View File

@ -0,0 +1,444 @@
/* $NetBSD: ka43.c,v 1.1 1996/07/20 18:29:51 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
*
* This code is derived from software contributed to Ludd by Bertram Barth.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed at Ludd, University of
* Lule}, Sweden and its contributors.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <sys/param.h>
#include <sys/types.h>
#include <sys/device.h>
#include <sys/kernel.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
#include <machine/pte.h>
#include <machine/mtpr.h>
#include <machine/sid.h>
#include <machine/pmap.h>
#include <machine/nexus.h>
#include <machine/uvax.h>
#include <machine/ka43.h>
#include <machine/clock.h>
#include <machine/ka650.h> /* cache ??? */
#define xtrace(x)
void ka43_conf __P((struct device*, struct device*, void*));
void ka43_steal_pages __P((void));
void ka43_memerr __P((void));
int ka43_mchk __P((caddr_t));
struct ka43_cpu *ka43_cpuptr = (void*)KA43_CPU_BASE;
struct ka43_clock *ka43_clkptr = (void*)KA43_WAT_BASE;
extern int uVAX_fillmap __P((struct uc_map *));
struct uc_map ka43_map[] = {
{ KA43_CFGTST, KA43_CFGTST, 4, 0 },
{ KA43_ROM_BASE, KA43_ROM_END, KA43_ROM_SIZE, 0 },
{ KA43_CPU_BASE, KA43_CPU_END, KA43_CPU_SIZE, 0 },
{ KA43_CT2_BASE, KA43_CT2_END, KA43_CT2_SIZE, 0 },
{ KA43_CH2_CREG, KA43_CH2_CREG, 4, 0 },
{ KA43_NWA_BASE, KA43_NWA_END, KA43_NWA_SIZE, 0 },
{ KA43_SER_BASE, KA43_SER_END, KA43_SER_SIZE, 0 },
{ KA43_WAT_BASE, KA43_WAT_END, KA43_WAT_SIZE, 0 },
{ KA43_SCS_BASE, KA43_SCS_END, KA43_SCS_SIZE, 0 },
{ KA43_LAN_BASE, KA43_LAN_END, KA43_LAN_SIZE, 0 },
{ KA43_CUR_BASE, KA43_CUR_END, KA43_CUR_SIZE, 0 },
{ KA43_DMA_BASE, KA43_DMA_END, KA43_DMA_SIZE, 0 },
{ KA43_VME_BASE, KA43_VME_END, KA43_VME_SIZE, 0 },
/*
* there's more to come, eg. framebuffers (GPX/SPX)
*/
{0, 0, 0, 0},
};
#define CH1_BITS \
"\020\015BCHIT\014BUSERR\013PPERR\012DPERR\011TPERR\010TRAP1" \
"\007TRAP2\006INTR\005HIT\004REFRESH\003FLUSH\002ENABLE\001FORCEHIT"
#define CH2_BITS \
"\020\010TPE\007DPE\006MISS\005DIRTY\004CERR\003LERR\002SERR\001ENAB"
void
ka43_memerr()
{
int mapen;
int *ch2reg;
printf("memory error!\n");
printf("primary cache status: %b\n", mfpr(PR_PCSTS), CH1_BITS);
mapen = mfpr(PR_MAPEN);
if (mapen)
ch2reg = (void*)uvax_phys2virt(KA43_CH2_CREG);
else
ch2reg = (void*)KA43_CH2_CREG;
printf("secondary cache status: %b\n", *ch2reg, CH2_BITS);
}
static char *mcc43[] = {
"no error (0)",
"FPA signalled protocoll error",
"FPA signalled illegal opcode",
"FPA detected parity error",
"FPA returned unknown status",
"FPA result has parity error",
"unused (6)",
"unused (7)",
"MMU error (TLB miss)",
"MMU error (TLB hit)",
"HW interrupt at unused IPL",
"impossible microcode state",
"undefined trap code (i-box)",
"undefined control store address",
"unused (14)",
"unused (15)",
"PC tag or data parity error",
"data bus parity error",
"data bus error (NXM)",
"undefined data bus state",
};
int
ka43_mchk(addr)
caddr_t addr;
{
struct {
int bcount; /* byte count (0x18) */
int mcc; /* "R"-flag and machine check code */
int mrva; /* most recent virtual address */
int viba; /* contents of VIBA register */
int sisr; /* ICCS bit 6 and SISR bits 15:0 */
int isd; /* internal state */
int scr; /* shift count register */
int pc; /* program counter */
int psl; /* processor status longword */
} *p = (void*)addr;
printf("machine check: 0x%x\n", p->mcc);
printf("reason: %s\n", mcc43[p->mcc & 0xff]);
printf("bcount:0x%x, check-code:0x%x, virtaddr:0x%x\n",
p->bcount, p->mcc, p->mrva);
printf("pc:0x%x, psl:0x%x, viba: %x, state: %x\n",
p->pc, p->psl, p->viba, p->isd);
return (-1);
}
int
ka43_setup(uc,flags)
struct uvax_calls *uc;
int flags;
{
uc->uc_name = "ka43";
uc->uc_phys2virt = NULL;
uc->uc_physmap = ka43_map;
uc->uc_steal_pages = ka43_steal_pages;
uc->uc_conf = ka43_conf;
uc->uc_clkread = ka43_clkread;
uc->uc_clkwrite = ka43_clkwrite;
uc->uc_memerr = ka43_memerr;
uc->uc_mchk = ka43_mchk;
uc->uc_intreq = (void*)KA43_INTREQ;
uc->uc_intclr = (void*)KA43_INTCLR;
uc->uc_intmsk = (void*)KA43_INTMSK;
uc->uc_busTypes = VAX_VSBUS;
}
ka43_discache()
{
int *ctag;
int *creg;
int mapen;
int i;
xtrace(("ka43_discache()\n"));
return (0);
/*
* first disable primary cache
*/
#if 0
mtpr(0, PR_PCSTS);
mtpr(0, PR_PCERR);
mtpr(0, PR_PCIDX);
mtpr(0, PR_PCTAG);
#else
i = mfpr(PR_PCSTS);
mtpr((i & ~2), PR_PCSTS);
printf("pcsts: %x --> %x\n", i, mfpr(PR_PCSTS));
#endif
/*
* now secondary cache
*/
mapen = mfpr(PR_MAPEN);
if (mapen) {
ctag = (void*)uvax_phys2virt(KA43_CT2_BASE);
creg = (void*)uvax_phys2virt(KA43_CH2_CREG);
} else {
ctag = (void*)KA43_CT2_BASE;
creg = (void*)KA43_CH2_CREG;
}
i = *creg;
*creg = (i & ~1);
printf("creg: %x --> %x\n", i, *creg);
xtrace(("ka43_discache() done.\n"));
}
ka43_encache()
{
int *ctag;
int *creg;
int mapen;
int i;
xtrace(("ka43_encache()\n"));
ka43_discache();
/*
* first enable primary cache
*/
printf("P-0");
i = mfpr(PR_PCSTS);
mtpr((i & ~2), PR_PCSTS);
mtpr(0, PR_PCSTS);
printf("P-1");
#if 1
mtpr(KA43_PCS_ENABLE | KA43_PCS_FLUSH | KA43_PCS_REFRESH, PR_PCSTS);
#else
mtpr(KA43_PCS_ENABLE, PR_PCSTS);
#endif
printf("P-2");
/*
* now secondary cache
*/
mapen = mfpr(PR_MAPEN);
if (mapen) {
ctag = (void*)uvax_phys2virt(KA43_CT2_BASE);
creg = (void*)uvax_phys2virt(KA43_CH2_CREG);
} else {
ctag = (void*)KA43_CT2_BASE;
creg = (void*)KA43_CH2_CREG;
}
printf("ctag: %x, creg: %x\n", ctag, creg);
printf("S-1");
i = *creg;
printf("creg=[%x] ", *creg);
#if 0
*creg = (i & ~1);
printf("creg=[%x] ", *creg);
printf("S-2");
for (i = 0; i < KA43_CT2_SIZE; i += 4) /* Quadword entries */
ctag[i/4] = 0; /* reset lower half */
printf("S-3");
i = *creg;
printf("creg=[%x] ", *creg);
*creg = (i & ~1);
printf("creg=[%x] ", *creg);
printf("S-4");
/* *creg = 1; */
printf("S-5");
#endif
xtrace(("ka43_encache() done.\n"));
printf("primary cache status: %b\n", mfpr(PR_PCSTS), CH1_BITS);
printf("secondary cache status: %b\n", *creg, CH2_BITS);
}
void
ka43_conf(parent, self, aux)
struct device *parent, *self;
void *aux;
{
extern char cpu_model[];
extern int vax_siedata;
if (vax_siedata & 0x02) /* "single-user" flag */
strcpy(cpu_model,"VAXstation 3100 model 76");
else if (vax_siedata & 0x01) /* "multiuser" flag */
strcpy(cpu_model,"MicroVAX 3100 model 76(?)");
else
strcpy(cpu_model, "unknown KA43 board");
printf(": %s\n", cpu_model);
ka43_encache();
}
/*
*
*/
u_long le_iomem; /* base addr of RAM -- CPU's view */
u_long le_ioaddr; /* base addr of RAM -- LANCE's view */
void
ka43_steal_pages()
{
extern vm_offset_t avail_start, virtual_avail, avail_end;
int junk;
int i;
struct {
u_long :2;
u_long data:8;
u_long :22;
} *p;
int *srp; /* Scratch Ram */
int *pctl; /* parity control register */
char *q = (void*)&srp;
char line[20];
ka43_encache();
pctl = (void*)KA43_PARCTL;
printf("parctl: 0x%x\n", *pctl);
#if 0
*pctl = KA43_PCTL_DPEN | KA43_PCTL_CPEN;
#else
*pctl = KA43_PCTL_CPEN;
#endif
printf("new value for parctl: ");
gets(line);
*pctl = *line - '0';
printf("parctl: 0x%x\n", *pctl);
srp = NULL;
p = (void*)KA43_SCR;
for (i=0; i<4; i++) {
printf("p[%d] = %x, ", i, p[i].data);
q[i] = p[i].data;
}
p = (void*)KA43_SCRLEN;
printf("\nlen = %d\n", p->data);
printf("srp = 0x%x\n", srp);
for (i=0; i<0x2; i++) {
printf("%x:0x%x ", i*4, srp[i]);
if ((i & 0x07) == 0x07)
printf("\n");
}
printf("\n");
printf ("ka43_steal_pages: avail_end=0x%x\n", avail_end);
/*
* SCB is already copied/initialized at addr avail_start
* by pmap_bootstrap(), but it's not yet mapped. Thus we use
* the MAPPHYS() macro to reserve these two pages and to
* perform the mapping. The mapped address is assigned to junk.
*/
MAPPHYS(junk, 2, VM_PROT_READ|VM_PROT_WRITE);
/*
* At top of physical memory there are some console-prom and/or
* restart-specific data. Make this area unavailable.
*/
#if 1
avail_end -= 10 * NBPG;
#endif
/*
* If we need to map physical areas also, we can decrease avail_end
* (the highest available memory-address), copy the stuff into the
* gap between and use pmap_map to map it...
*
* Don't use the MAPPHYS macro here, since this uses and changes(!)
* the value of avail_start. Use MAPVIRT even if it's name misleads.
*/
avail_end &= ~0xffff;
avail_end -= (64 * 1024);
avail_end = 0xf00000;
le_ioaddr = 0xf40000;
MAPVIRT(le_iomem, (64 * 1024)/NBPG);
pmap_map((vm_offset_t)le_iomem, le_ioaddr, le_ioaddr + 0xffff,
VM_PROT_READ|VM_PROT_WRITE);
if (1 || le_ioaddr > 0xffffff) {
le_ioaddr &= 0xffffff;
*pctl |= KA43_PCTL_DMA;
}
printf("le_iomem: %x, le_ioaddr: %x, parctl:%x\n",
le_iomem, le_ioaddr, *pctl);
/*
* now map in anything listed in ka43_map...
*/
uVAX_fillmap(ka43_map);
/*
* Clear restart and boot in progress flags in the CPMBX.
*/
ka43_clkptr->cpmbx = ka43_clkptr->cpmbx & 0xF0;
/*
* Enable memory parity error detection and clear error bits.
*/
ka43_cpuptr->ka43_mser = 0x01;
/* (UVAXIIMSER_PEN | UVAXIIMSER_MERR | UVAXIIMSER_LEB); */
/*
* MM is not yet enabled, thus we still used the physical addresses,
* but before leaving this routine, we need to reset them to virtual.
*/
ka43_cpuptr = (void*)uvax_phys2virt(KA43_CPU_BASE);
ka43_clkptr = (void*)uvax_phys2virt(KA43_WAT_BASE);
printf ("steal_pages done.\n");
}
/*
* define what we need and overwrite the uVAX_??? names
*/
#define NEED_UVAX_GENCLOCK
#define NEED_UVAX_PROTOCLOCK
#define uVAX_clock ka43_clock
#define uVAX_clkptr ka43_clkptr
#define uVAX_clkread ka43_clkread
#define uVAX_clkwrite ka43_clkwrite
#define uVAX_genclock ka43_genclock
#include <arch/vax/vax/uvax_proto.c>

193
sys/arch/vax/vax/ka630.c Normal file
View File

@ -0,0 +1,193 @@
/* $NetBSD: ka630.c,v 1.1 1996/07/20 18:29:52 ragge Exp $ */
/*-
* Copyright (c) 1982, 1988, 1990, 1993
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* @(#)ka630.c 7.8 (Berkeley) 5/9/91
*/
#include <sys/param.h>
#include <sys/types.h>
#include <sys/device.h>
#include <sys/kernel.h>
#include <sys/time.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
#include <machine/pte.h>
#include <machine/mtpr.h>
#include <machine/sid.h>
#include <machine/pmap.h>
#include <machine/nexus.h>
#include <machine/uvax.h>
#include <machine/ka630.h>
#include <machine/clock.h>
struct uvaxIIcpu *uvaxIIcpu_ptr;
struct ka630clock *ka630_clkptr = KA630CLK;
static void ka630_conf __P((struct device *, struct device *, void *));
static void ka630_memerr __P((void));
static int ka630_mchk __P((caddr_t));
static void ka630_steal_pages __P((void));
int
ka630_setup(uc,flags)
struct uvax_calls *uc;
int flags;
{
uc->uc_name = "ka630";
uc->uc_phys2virt = NULL;
uc->uc_physmap = NULL; /* ptv_map ? p2v_map */
uc->uc_steal_pages = ka630_steal_pages;
uc->uc_conf = ka630_conf;
uc->uc_clkread = ka630_clkread;
uc->uc_clkwrite = ka630_clkwrite;
#ifdef notyet
uc->uc_memerr = ka630_memerr;
uc->uc_mchk = ka630_mchk;
#endif
uc->uc_busTypes = VAX_Q22BUS;
}
/*
* uvaxII_conf() is called by cpu_attach to do the cpu_specific setup.
*/
void
ka630_conf(parent, self, aux)
struct device *parent, *self;
void *aux;
{
extern char cpu_model[];
strcpy(cpu_model,"MicroVAX II");
printf(": %s\n", cpu_model);
}
/* log crd errors */
uvaxII_memerr()
{
printf("memory err!\n");
}
#define NMC78032 10
char *mc78032[] = {
0, "immcr (fsd)", "immcr (ssd)", "fpu err 0",
"fpu err 7", "mmu st(tb)", "mmu st(m=0)", "pte in p0",
"pte in p1", "un intr id",
};
struct mc78032frame {
int mc63_bcnt; /* byte count == 0xc */
int mc63_summary; /* summary parameter */
int mc63_mrvaddr; /* most recent vad */
int mc63_istate; /* internal state */
int mc63_pc; /* trapped pc */
int mc63_psl; /* trapped psl */
};
uvaxII_mchk(cmcf)
caddr_t cmcf;
{
register struct mc78032frame *mcf = (struct mc78032frame *)cmcf;
register u_int type = mcf->mc63_summary;
printf("machine check %x", type);
if (type < NMC78032 && mc78032[type])
printf(": %s", mc78032[type]);
printf("\n\tvap %x istate %x pc %x psl %x\n",
mcf->mc63_mrvaddr, mcf->mc63_istate,
mcf->mc63_pc, mcf->mc63_psl);
if (uvaxIIcpu_ptr && uvaxIIcpu_ptr->uvaxII_mser & UVAXIIMSER_MERR) {
printf("\tmser=0x%x ", uvaxIIcpu_ptr->uvaxII_mser);
if (uvaxIIcpu_ptr->uvaxII_mser & UVAXIIMSER_CPUE)
printf("page=%d", uvaxIIcpu_ptr->uvaxII_cear);
if (uvaxIIcpu_ptr->uvaxII_mser & UVAXIIMSER_DQPE)
printf("page=%d", uvaxIIcpu_ptr->uvaxII_dear);
printf("\n");
}
return (-1);
}
void
ka630_steal_pages()
{
extern vm_offset_t avail_start, virtual_avail, avail_end;
int junk;
/*
* MicroVAX II: get 10 pages from top of memory,
* map in Qbus map registers, cpu and clock registers.
*/
avail_end -= 10;
MAPPHYS(junk, 2, VM_PROT_READ|VM_PROT_WRITE);
MAPVIRT(nexus, btoc(0x400000));
pmap_map((vm_offset_t)nexus, 0x20088000, 0x20090000,
VM_PROT_READ|VM_PROT_WRITE);
MAPVIRT(uvaxIIcpu_ptr, 1);
pmap_map((vm_offset_t)uvaxIIcpu_ptr, (vm_offset_t)UVAXIICPU,
(vm_offset_t)UVAXIICPU + NBPG, VM_PROT_READ|VM_PROT_WRITE);
MAPVIRT(ka630_clkptr, 1);
pmap_map((vm_offset_t)ka630_clkptr, (vm_offset_t)KA630CLK,
(vm_offset_t)KA630CLK + NBPG, VM_PROT_READ|VM_PROT_WRITE);
/*
* Clear restart and boot in progress flags
* in the CPMBX.
/
ka630clk_ptr->cpmbx = (ka630clk_ptr->cpmbx & KA630CLK_LANG);
/*
* Enable memory parity error detection and clear error bits.
*/
uvaxIIcpu_ptr->uvaxII_mser = (UVAXIIMSER_PEN | UVAXIIMSER_MERR |
UVAXIIMSER_LEB);
}
#define uVAX_gettodr ka630_gettodr
#define uVAX_settodr ka630_settodr
#define uVAX_clkptr ka630_clkptr
#define uVAX_genclock ka630_genclock
#define uVAX_clock ka630clock
#define uVAX_clkread ka630_clkread
#define uVAX_clkwrite ka630_clkwrite
#include <arch/vax/vax/uvax_proto.c>

287
sys/arch/vax/vax/uvax.c Normal file
View File

@ -0,0 +1,287 @@
/* $NetBSD: uvax.c,v 1.1 1996/07/20 18:29:54 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
*
* This code is derived from software contributed to Ludd by Bertram Barth.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed at Ludd, University of
* Lule}, Sweden and its contributors.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* generic(?) MicroVAX and VAXstation support
*
* There are similarities to struct cpu_calls[] in autoconf.c
*/
#include <sys/param.h>
#include <sys/types.h>
#include <sys/device.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
#include <machine/pte.h>
#include <machine/mtpr.h>
#include <machine/sid.h>
#include <machine/pmap.h>
#include <machine/nexus.h>
#include <machine/uvax.h>
#define xtrace(x)
#define xdebug(x)
struct uvax_calls guc; /* Generic uVAX Calls */
/* struct uvax_calls *ucp = &guc; /* not yet public !!! */
static int uvax_callsSetup = 0; /* not yet setup */
u_long uVAX_phys2virt __P((u_long, struct uc_map *));
/* u_long uVAX_physmap; /* XXX another ugly hack... */
int
uvax_notavail(s)
char *s;
{
printf("\"%s()\" not available for uVAX (%s)\n", s, guc.uc_name);
/*
* should we panic() here???
*/
return(0);
}
int
uvax_setup(flags)
int flags;
{
/*
* insert some defaults here !!!
*/
/*
* Now call the specific routines to overwrite these defaults
*/
switch (vax_boardtype) {
#ifdef VAX630
case VAX_BTYP_630:
ka630_setup(&guc, flags);
break;
#endif
#ifdef VAX410
case VAX_BTYP_410:
ka410_setup(&guc, flags);
break;
#endif
#ifdef VAX43
case VAX_BTYP_43:
ka43_setup(&guc, flags);
break;
#endif
default:
printf("don't know how to handle 0x%x\n", vax_boardtype);
printf("Let's try using the defaults...\n");
}
uvax_callsSetup = 1;
}
/*
* XXX_steal_pages() is the first cpu/board specific function to be called.
* Thus we use this call to setup the dispatch structure for further use.
*
* We should have a special setup-routine !!!
*/
void
uvax_steal_pages()
{
if (uvax_callsSetup == 0)
uvax_setup(0);
/*
* now that specific functions are inserted, we can call 'em
*/
if (guc.uc_steal_pages) {
(guc.uc_steal_pages)();
return;
}
uvax_notavail("uc_steal_pages");
}
u_long
uvax_phys2virt(paddr)
u_long paddr;
{
if (guc.uc_phys2virt)
return ((guc.uc_phys2virt)(paddr));
if (guc.uc_physmap)
return (uVAX_phys2virt(paddr, guc.uc_physmap));
uvax_notavail("uc_phys2virt");
return (0);
}
void
uvax_conf(parent, self, aux)
struct device *parent, *self;
void *aux;
{
if (guc.uc_conf) {
(guc.uc_conf)(parent, self, aux);
return;
}
uvax_notavail("uc_conf");
}
void
uvax_memerr()
{
xtrace(("uvax_memerr()\n"));
if (guc.uc_memerr) {
(guc.uc_memerr)();
return;
}
uvax_notavail("uc_memerr");
}
int
uvax_mchk(addr)
caddr_t addr;
{
xtrace(("uvax_mchk(0x%x)\n", addr));
if (guc.uc_mchk)
return ((guc.uc_mchk)(addr));
uvax_notavail("uc_mchk");
return (-1);
}
int
uvax_clkread(base)
time_t base;
{
if (guc.uc_clkread)
return ((guc.uc_clkread)(base));
uvax_notavail("uc_clkread");
}
void
uvax_clkwrite()
{
if (guc.uc_clkwrite)
(guc.uc_clkwrite)();
else
uvax_notavail("uc_clkwrite");
return;
}
/*
* NB: mapping should/must be done in chunks of PAGE_SIZE (ie. 1024),
* while pmap_map() expects size to be in chunks of NBPG (ie. 512).
*
* Thus we round down the start-address to be aligned wrt PAGE_SIZE and
* the end-address up to be just beyond the next multiple of PAGE_SIZE.
* size is the number of bytes between start and end expressed in NBPG.
*/
int
uVAX_old_fillmap(um)
struct uc_map *um;
{
extern vm_offset_t avail_start, virtual_avail, avail_end;
register struct uc_map *p;
register u_int base, end, size;
for (p = um; p->um_base != 0; p++) {
base = p->um_base & ~PAGE_SIZE; /* round base down */
end = ROUND_PAGE(p->um_end + 1) - 1; /* round end up */
size = (end - base + 1) / NBPG; /* size in pages */
MAPVIRT(p->um_virt, size);
pmap_map((vm_offset_t)p->um_virt, base, end,
VM_PROT_READ|VM_PROT_WRITE);
xdebug(("uVAX_fillmap: %x:%x[%x] (%x:%x[%x]) --> %x\n",
p->um_base, p->um_end, p->um_size,
base, end, size, p->um_virt));
}
}
/*
* NB: mapping should/must be done in chunks of PAGE_SIZE (ie. 1024),
* while pmap_map() expects size to be in chunks of NBPG (ie. 512).
*
* Thus we round down the start-address to be aligned wrt PAGE_SIZE and
* the end-address up to be just beyond the next multiple of PAGE_SIZE.
* size is the number of bytes between start and end expressed in NBPG.
*/
int
uVAX_fillmap(um)
struct uc_map *um;
{
extern vm_offset_t avail_start, virtual_avail, avail_end;
register struct uc_map *p;
register u_int base, end, off, size;
for (p = um; p->um_base != 0; p++) {
base = TRUNC_PAGE(p->um_base); /* round base down */
off = p->um_base - base;
size = ROUND_PAGE(off + p->um_size);
if (size < PAGE_SIZE) {
printf("invalid size %d in uVAX_fillmap\n", size);
size = PAGE_SIZE;
}
end = base + size - 1;
MAPVIRT(p->um_virt, size/NBPG);
pmap_map((vm_offset_t)p->um_virt, base, end,
VM_PROT_READ|VM_PROT_WRITE);
xdebug(("uVAX_fillmap: %x:%x[%x] (%x:%x[%x]) --> %x\n",
p->um_base, p->um_end, p->um_size,
base, end, size, p->um_virt));
}
}
u_long
uVAX_phys2virt(phys,um)
u_long phys;
struct uc_map *um;
{
register struct uc_map *p;
u_long virt = 0;
for (p = um; p->um_base != 0; p++) {
if (p->um_base > phys || p->um_end < phys)
continue;
virt = p->um_virt + (phys - trunc_page(p->um_base));
break;
}
if (virt == 0) {
printf("invalid argument 0x%x to uvax_phys2virt()\n", phys);
/* should we panic() here ??? */
}
return (virt);
}

View File

@ -0,0 +1,142 @@
/* $NetBSD: uvax_proto.c,v 1.1 1996/07/20 18:29:53 ragge Exp $ */
/*-
* Copyright (c) 1982, 1988, 1990, 1993
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
*/
/*
* MicroVAX and VAXstation and their different models have many
* similarities and also many very specific implementations/solutions.
* Thus this is a trial to have generic and prototypic routines
* which can be used instead of specific routines whenever possible.
*
* usually there are groups of machines using the same CPU chips, eg.
* MicroVAX II
* MicroVAX 2000
* VAXstation 2000
* have the same CPU and thus can share the CPU dependent code.
*
* On the other hand the above machines are quite differnet wrt. the
* way the board-specific details (system-bus, NVRAM layout, etc.)
* and thus can't share this code.
*
* It's also possible to find groups of machines which have enough
* similarities wrt. to board-specific implementations, to share some
* code between them. Eg.
* VAXstation 2000
* VAXstation 3100 (which models ???)
* VAXstation 4000 (which models ???)
* use the same (nonexistent "virtual") system-bus and thus can share
* some pieces of code...
*/
#include <sys/param.h>
#include <sys/types.h>
#include <sys/device.h>
#include <machine/mtpr.h>
static int
uVAX_clkread(base)
time_t base;
{
register struct uVAX_clock *claddr = uVAX_clkptr;
struct chiptime c;
int timeout = 1<<15, rv;
claddr->csr1 = uVAX_CLKSET;
while ((claddr->csr0 & uVAX_CLKUIP) != 0)
if (--timeout == 0) {
printf ("TOY clock timed out");
return CLKREAD_BAD;
}
c.sec = claddr->sec;
c.min = claddr->min;
c.hour = claddr->hr;
c.day = claddr->day;
c.mon = claddr->mon;
c.year = claddr->yr;
/* If the clock is valid, use it. */
if ((claddr->csr3 & uVAX_CLKVRT) != 0 &&
(claddr->csr1 & uVAX_CLKENABLE) == uVAX_CLKENABLE) {
/* simple sanity checks */
time.tv_sec = chiptotime(&c);
if (c.mon < 1 || c.mon > 12 ||
c.day < 1 || c.day > 31) {
printf("WARNING: preposterous clock chip time");
rv = CLKREAD_WARN;
} else
rv = CLKREAD_OK;
claddr->csr0 = uVAX_CLKRATE;
claddr->csr1 = uVAX_CLKENABLE;
return rv;
}
printf("WARNING: TOY clock invalid");
return CLKREAD_BAD;
}
/* Set the time of day clock, called via. stime system call.. */
static void
uVAX_clkwrite()
{
register struct uVAX_clock *claddr = uVAX_clkptr;
struct chiptime c;
int timeout = 1<<15;
int s;
timetochip(&c);
s = splhigh();
claddr->csr1 = uVAX_CLKSET;
while ((claddr->csr0 & uVAX_CLKUIP) != 0)
if (--timeout == 0) {
printf("Trouble saving date, TOY clock timed out\n");
break;
}
claddr->sec = c.sec;
claddr->min = c.min;
claddr->hr = c.hour;
claddr->day = c.day;
claddr->mon = c.mon;
claddr->yr = c.year;
claddr->csr0 = uVAX_CLKRATE;
claddr->csr1 = uVAX_CLKENABLE;
splx(s);
}