From 45a3e3d626bc7f86f1895ac965e71e07c0db2b8a Mon Sep 17 00:00:00 2001 From: miod Date: Sun, 10 Aug 2008 18:20:07 +0000 Subject: [PATCH] Add support for the VAXstation 3[58][24]0 to the bootblocks, currently limited to serial console. This is enough for a 3520 to mopboot and download a kernel over NFS. --- sys/arch/vax/boot/boot/autoconf.c | 19 ++- sys/arch/vax/boot/boot/boot.c | 5 +- sys/arch/vax/boot/boot/consio.c | 213 ++++++++++++++++++++++++----- sys/arch/vax/boot/boot/if_le.c | 97 ++++++++----- sys/arch/vax/boot/boot/version | 3 +- sys/arch/vax/stand/boot/autoconf.c | 19 ++- sys/arch/vax/stand/boot/boot.c | 5 +- sys/arch/vax/stand/boot/consio.c | 213 ++++++++++++++++++++++++----- sys/arch/vax/stand/boot/if_le.c | 97 ++++++++----- sys/arch/vax/stand/boot/version | 3 +- 10 files changed, 526 insertions(+), 148 deletions(-) diff --git a/sys/arch/vax/boot/boot/autoconf.c b/sys/arch/vax/boot/boot/autoconf.c index 8b20a30b1af..1f02f44d51a 100644 --- a/sys/arch/vax/boot/boot/autoconf.c +++ b/sys/arch/vax/boot/boot/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.10 2008/05/21 19:42:07 miod Exp $ */ +/* $OpenBSD: autoconf.c,v 1.11 2008/08/10 18:20:07 miod Exp $ */ /* $NetBSD: autoconf.c,v 1.19 2002/06/01 15:33:22 ragge Exp $ */ /* * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden. @@ -49,6 +49,7 @@ void autoconf(void); void findcpu(void); void consinit(void); void scbinit(void); +void clkstart(void); int getsecs(void); void scb_stray(void *); void longjmp(int *); @@ -68,8 +69,9 @@ autoconf(void) int fromnet = (bootregs[12] != -1); findcpu(); /* Configures CPU variables */ + scbinit(); /* Setup interrupts */ consinit(); /* Allow us to print out things */ - scbinit(); /* Fix interval clock etc */ + clkstart(); /* Fix interval clock etc */ #ifdef DEV_DEBUG printf("Register contents:\n"); @@ -136,14 +138,17 @@ struct ivec_dsp **scb; struct ivec_dsp *scb_vec; extern struct ivec_dsp idsptch; extern int jbuf[10]; +extern int mcheck_silent; static void mcheck(void *arg) { int off, *mfp = (int *)&arg; - off = (mfp[7]/4 + 8); - printf("Machine check, pc=%x, psl=%x\n", mfp[off], mfp[off+1]); + if (!mcheck_silent) { + off = (mfp[7]/4 + 8); + printf("Machine check, pc=%x, psl=%x\n", mfp[off], mfp[off+1]); + } longjmp(jbuf); } @@ -175,9 +180,13 @@ scbinit(void) scb_vec[i].pushlarg = (void *) (i * 4); scb_vec[i].ev = NULL; } - scb_vec[0xc0/4].hoppaddr = rtimer; scb_vec[4/4].hoppaddr = mcheck; +} +void +clkstart(void) +{ + scb_vec[0xc0/4].hoppaddr = rtimer; if (vax_boardtype != VAX_BTYP_VXT) mtpr(-10000, PR_NICR); /* Load in count register */ mtpr(0x800000d1, PR_ICCS); /* Start clock and enable interrupt */ diff --git a/sys/arch/vax/boot/boot/boot.c b/sys/arch/vax/boot/boot/boot.c index 3ee6054da8f..160254d2868 100644 --- a/sys/arch/vax/boot/boot/boot.c +++ b/sys/arch/vax/boot/boot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.17 2008/03/30 19:54:05 miod Exp $ */ +/* $OpenBSD: boot.c,v 1.18 2008/08/10 18:20:07 miod Exp $ */ /* $NetBSD: boot.c,v 1.18 2002/05/31 15:58:26 ragge Exp $ */ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. @@ -79,6 +79,7 @@ const struct vals { int jbuf[10]; int sluttid, senast, skip, askname; +int mcheck_silent; struct rpb bootrpb; void @@ -108,7 +109,7 @@ Xmain(void) transition = ' '; askname = bootrpb.rpb_bootr5 & RB_ASKNAME; - printf("\n\r>> OpenBSD/vax boot [%s] [%s] <<\n", "1.13", __DATE__); + printf("\n\r>> OpenBSD/vax boot [%s] <<\n", "1.14"); printf(">> Press enter to autoboot now, or any other key to abort: "); sluttid = getsecs() + 5; senast = 0; diff --git a/sys/arch/vax/boot/boot/consio.c b/sys/arch/vax/boot/boot/consio.c index b2aabd8da37..4e87e1321b0 100644 --- a/sys/arch/vax/boot/boot/consio.c +++ b/sys/arch/vax/boot/boot/consio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: consio.c,v 1.7 2006/08/30 20:02:13 miod Exp $ */ +/* $OpenBSD: consio.c,v 1.8 2008/08/10 18:20:07 miod Exp $ */ /* $NetBSD: consio.c,v 1.13 2002/05/24 21:40:59 ragge Exp $ */ /* * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden. @@ -32,9 +32,7 @@ /* All bugs are subject to removal without further notice */ - - -#include "sys/param.h" +#include #include "../vax/gencons.h" @@ -51,45 +49,70 @@ static void (*put_fp)(int) = NULL; static int (*get_fp)(void) = NULL; static int (*test_fp)(void) = NULL; -void pr_putchar(int c); /* putchar() using mtpr/mfpr */ -int pr_getchar(void); -int pr_testchar(void); +/* + * I/O using mtpr/mfpr + */ -void rom_putchar(int c); /* putchar() using ROM routines */ -int rom_getchar(void); -int rom_testchar(void); +void pr_putchar(int c); +int pr_getchar(void); +int pr_testchar(void); -int rom_putc; /* ROM-address of put-routine */ -int rom_getc; /* ROM-address of get-routine */ +/* + * I/O using ROM routines + */ + +void rom_putchar(int c); +int rom_getchar(void); +int rom_testchar(void); + +int rom_putc; /* ROM-address of put-routine */ +int rom_getc; /* ROM-address of get-routine */ + +/* + * I/O using the KA630 ROM console routines + */ /* Pointer to KA630 console page, initialized by ka630_consinit */ unsigned char *ka630_conspage; +void ka630_consinit(void); -/* Function that initializes things for KA630 ROM console I/O */ -void ka630_consinit(void); +void ka630_rom_putchar(int c); +int ka630_rom_getchar(void); +int ka630_rom_testchar(void); -/* Functions that use KA630 ROM for console I/O */ -void ka630_rom_putchar(int c); -int ka630_rom_getchar(void); -int ka630_rom_testchar(void); +/* + * I/O using the KA53 ROM console routines + */ -/* Also added such a thing for KA53 - MK-991208 */ unsigned char *ka53_conspage; -void ka53_consinit(void); +void ka53_consinit(void); -void ka53_rom_putchar(int c); -int ka53_rom_getchar(void); -int ka53_rom_testchar(void); +void ka53_rom_putchar(int c); +int ka53_rom_getchar(void); +int ka53_rom_testchar(void); -void vxt_putchar(int c); -int vxt_getchar(void); -int vxt_testchar(void); +/* + * I/O using the VXT2000 serial ports + */ -void putchar(int); -int getchar(void); -int testkey(void); -void consinit(void); -void _rtt(void); +void vxt_putchar(int c); +int vxt_getchar(void); +int vxt_testchar(void); + +/* + * I/O using the VS3[58][24]0 serial ports + */ + +void ff_consinit(void); +void ff_putchar(int c); +int ff_getchar(void); +int ff_testchar(void); + +void putchar(int); +int getchar(void); +int testkey(void); +void consinit(void); +void _rtt(void); void putchar(int c) @@ -108,7 +131,7 @@ getchar(void) c = (*get_fp)() & 0177; while (c == 17 || c == 19); /* ignore XON/XOFF */ if (c < 96 && c > 64) - c += 32; + c += 32; /* force lowercase */ return c; } @@ -176,11 +199,17 @@ consinit(void) ka53_consinit(); break; + case VAX_BTYP_60: + put_fp = ff_putchar; + get_fp = ff_getchar; + test_fp = ff_testchar; + ff_consinit(); + break; + #ifdef notdef case VAX_BTYP_630: case VAX_BTYP_650: case VAX_BTYP_9CC: - case VAX_BTYP_60: put_fp = pr_putchar; get_fp = pr_getchar; break @@ -343,3 +372,121 @@ vxt_testchar(void) return vxtregs[CH_DATA]; } } + +/* + * VaxStation 3[58][24]0 console routines. + * + * We do not know what the proper ROM entry points are, so these routines + * drive the serial ports directly. + * + * Unfortunately the address of the serial ports depend on the position + * of the L2003 I/O board in the system, which requires us to check all + * slots for their ID. Of course, empty slots will cause a machine check, + * and the suggested method of looking at the BUSCTL register to know + * which slots are populated is not usable, since we are way too late in + * the boot process. + */ + +struct ff_dzregs { + volatile unsigned short csr; + volatile unsigned short unused; + volatile unsigned short rbuf; + volatile unsigned short unused2; + volatile unsigned short tcr; + volatile unsigned short unused3; + volatile unsigned short tdr; +}; + +#define DZ_CSR_TX_READY 0100000 +#define DZ_CSR_RX_DONE 0000200 + +int ff_ioslot = -1; +static struct ff_dzregs *ff_dz; + +void +ff_consinit() +{ + extern int jbuf[10]; + extern int mcheck_silent; + extern int setjmp(int *); + + int line = 3; /* printer port */ + int mid, modaddr, modtype; + + mcheck_silent = 1; + for (mid = 0; mid < 8; mid++) { + modaddr = 0x31fffffc + (mid << 25); + if (setjmp(jbuf)) { + /* this slot is empty */ + continue; + } + modtype = *(int *)modaddr; + if ((modtype & 0xff) == 0x04) { + ff_ioslot = mid; + break; + } + } + mcheck_silent = 0; + + if (ff_ioslot < 0) { + /* + * This shouldn't happen. Try mid #5 (slot #4) as a + * supposedly sane default. + */ + ff_ioslot = 5; + } + + ff_dz = (struct ff_dzregs *) + (0x30000000 + (ff_ioslot << 25) + 0x00600000); + ff_dz->tcr = 1 << line; +} + +void +ff_putchar(int c) +{ + while ((ff_dz->csr & DZ_CSR_TX_READY) == 0) + ; + ff_dz->tdr = c; + while ((ff_dz->csr & DZ_CSR_TX_READY) == 0) + ; +} + +int +ff_getchar() +{ + int line = 3; /* printer port */ + unsigned short rbuf; + + for(;;) { + while ((ff_dz->csr & DZ_CSR_RX_DONE) == 0) + ; + rbuf = ff_dz->rbuf; + if (((rbuf >> 8) & 3) == line) + break; + } + + rbuf &= 0x7f; + if (rbuf == 13) + rbuf = 10; + + return (int)rbuf; +} + +int +ff_testchar() +{ + int line = 3; /* printer port */ + unsigned short rbuf; + + if ((ff_dz->csr & DZ_CSR_RX_DONE) == 0) + return 0; + rbuf = ff_dz->rbuf; + if (((rbuf >> 8) & 3) != line) + return 0; + + rbuf &= 0x7f; + if (rbuf == 13) + rbuf = 10; + + return (int)rbuf; +} diff --git a/sys/arch/vax/boot/boot/if_le.c b/sys/arch/vax/boot/boot/if_le.c index 5d1537d393b..8206f98f8ca 100644 --- a/sys/arch/vax/boot/boot/if_le.c +++ b/sys/arch/vax/boot/boot/if_le.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_le.c,v 1.3 2003/11/07 10:16:45 jmc Exp $ */ +/* $OpenBSD: if_le.c,v 1.4 2008/08/10 18:20:07 miod Exp $ */ /* $NetBSD: if_le.c,v 1.6 2000/05/20 13:30:03 ragge Exp $ */ /* * Copyright (c) 1997, 1999 Ludd, University of Lule}, Sweden. @@ -104,7 +104,8 @@ volatile struct buffdesc { short bd_mcnt; } *rdesc, *tdesc; -static int addoff, kopiera = 0; +static int addoff; +static int lebufaddr; /* Flags in the address field */ #define BR_OWN 0x80000000 @@ -145,9 +146,19 @@ leopen(struct open_file *f, int adapt, int ctlr, int unit, int part) if (vax_boardtype == VAX_BTYP_650 && ((vax_siedata >> 8) & 0xff) == VAX_SIE_KA640) { - kopiera = 1; + lebufaddr = 0x20120000; ea = (void *)0x20084200; nireg = (void *)0x20084400; + } else if (vax_boardtype == VAX_BTYP_60) { + extern int ff_ioslot; + lebufaddr = 0x30a00000 + (ff_ioslot << 25); + ea = (int *)(0x30800000 + (ff_ioslot << 25)); + for (i = 0; i < 6; i++) { + eaddr[i] = *(u_char *)((int)ea + 2); + ea++; + } + ea = NULL; + nireg = (void *)(0x30200000 + (ff_ioslot << 25)); } else { *(int *)0x20080014 = 0; /* Be sure we do DMA in low 16MB */ ea = (void *)0x20090000; /* XXX Ethernet address */ @@ -167,8 +178,10 @@ igen: while (to--) ; - for (i = 0; i < 6; i++) - eaddr[i] = ea[i] & 0377; + if (ea != NULL) { + for (i = 0; i < 6; i++) + eaddr[i] = ea[i] & 0377; + } if (initblock == NULL) { (void *)initblock = @@ -180,39 +193,39 @@ igen: (int)rdesc = QW_ALLOC(sizeof(struct buffdesc) * NRBUF) + addoff; initblock->ib_rdr = (RLEN << 29) | (int)rdesc; - if (kopiera) + if (lebufaddr) initblock->ib_rdr -= (int)initblock; (int)tdesc = QW_ALLOC(sizeof(struct buffdesc) * NTBUF) + addoff; initblock->ib_tdr = (TLEN << 29) | (int)tdesc; - if (kopiera) + if (lebufaddr) initblock->ib_tdr -= (int)initblock; - if (kopiera) + if (lebufaddr) copyout(initblock, 0, sizeof(struct initblock)); for (i = 0; i < NRBUF; i++) { rdesc[i].bd_adrflg = QW_ALLOC(BUFSIZE) | BR_OWN; - if (kopiera) + if (lebufaddr) rdesc[i].bd_adrflg -= (int)initblock; rdesc[i].bd_bcnt = -BUFSIZE; rdesc[i].bd_mcnt = 0; } - if (kopiera) + if (lebufaddr) copyout((void *)rdesc, (int)rdesc - (int)initblock, sizeof(struct buffdesc) * NRBUF); for (i = 0; i < NTBUF; i++) { tdesc[i].bd_adrflg = QW_ALLOC(BUFSIZE); - if (kopiera) + if (lebufaddr) tdesc[i].bd_adrflg -= (int)initblock; tdesc[i].bd_bcnt = 0xf000; tdesc[i].bd_mcnt = 0; } - if (kopiera) + if (lebufaddr) copyout((void *)tdesc, (int)tdesc - (int)initblock, sizeof(struct buffdesc) * NTBUF); } - if (kopiera) { + if (lebufaddr) { LEWRCSR(LE_CSR1, 0); LEWRCSR(LE_CSR2, 0); } else { @@ -251,7 +264,7 @@ retry: csr = LERDCSR(LE_CSR0); LEWRCSR(LE_CSR0, csr & (LE_C0_BABL|LE_C0_MISS|LE_C0_MERR|LE_C0_RINT)); - if (kopiera) + if (lebufaddr) copyin((int)&rdesc[next_rdesc] - (int)initblock, (void *)&rdesc[next_rdesc], sizeof(struct buffdesc)); if (rdesc[next_rdesc].bd_adrflg & BR_OWN) @@ -263,7 +276,7 @@ retry: if ((len = rdesc[next_rdesc].bd_mcnt - 4) > maxlen) len = maxlen; - if (kopiera) + if (lebufaddr) copyin((rdesc[next_rdesc].bd_adrflg&0xffffff), pkt, len); else @@ -273,7 +286,7 @@ retry: rdesc[next_rdesc].bd_mcnt = 0; rdesc[next_rdesc].bd_adrflg |= BR_OWN; - if (kopiera) + if (lebufaddr) copyout((void *)&rdesc[next_rdesc], (int)&rdesc[next_rdesc] - (int)initblock, sizeof(struct buffdesc)); if (++next_rdesc >= NRBUF) @@ -298,13 +311,13 @@ retry: csr = LERDCSR(LE_CSR0); LEWRCSR(LE_CSR0, csr & (LE_C0_MISS|LE_C0_CERR|LE_C0_TINT)); - if (kopiera) + if (lebufaddr) copyin((int)&tdesc[next_tdesc] - (int)initblock, (void *)&tdesc[next_tdesc], sizeof(struct buffdesc)); if (tdesc[next_tdesc].bd_adrflg & BT_OWN) goto retry; - if (kopiera) + if (lebufaddr) copyout(pkt, (tdesc[next_tdesc].bd_adrflg & 0xffffff), len); else bcopy(pkt, (char *)(tdesc[next_tdesc].bd_adrflg & 0xffffff) + @@ -313,7 +326,7 @@ retry: (len < ETHER_MIN_LEN ? -ETHER_MIN_LEN : -len); tdesc[next_tdesc].bd_mcnt = 0; tdesc[next_tdesc].bd_adrflg |= BT_OWN | BT_STP | BT_ENP; - if (kopiera) + if (lebufaddr) copyout((void *)&tdesc[next_tdesc], (int)&tdesc[next_tdesc] - (int)initblock, sizeof(struct buffdesc)); @@ -344,29 +357,47 @@ leclose(struct open_file *f) void copyout(void *f, int dest, int len) { - short *from = f; - short *toaddr; + if (vax_boardtype == VAX_BTYP_60) { + u_char *from = f; + u_char *toaddr = (u_char *)lebufaddr + dest; - toaddr = (short *)0x20120000 + dest; + while (len-- > 0) + *toaddr++ = *from++; + } else { + short *from = f; + short *toaddr; - while (len > 0) { - *toaddr = *from++; - toaddr += 2; - len -= 2; + toaddr = (short *)lebufaddr + dest; + + while (len > 0) { + *toaddr = *from++; + toaddr += 2; + len -= 2; + } } } void copyin(int src, void *f, int len) { - short *to = f; - short *fromaddr; + if (vax_boardtype == VAX_BTYP_60) { + u_char *to = f; + u_char *fromaddr; - fromaddr = (short *)0x20120000 + src; + fromaddr = (u_char *)lebufaddr + src; - while (len > 0) { - *to++ = *fromaddr; - fromaddr += 2; - len -= 2; + while (len-- > 0) + *to++ = *fromaddr++; + } else { + short *to = f; + short *fromaddr; + + fromaddr = (short *)lebufaddr + src; + + while (len > 0) { + *to++ = *fromaddr; + fromaddr += 2; + len -= 2; + } } } diff --git a/sys/arch/vax/boot/boot/version b/sys/arch/vax/boot/boot/version index 8aaeca812aa..781a361f1b4 100644 --- a/sys/arch/vax/boot/boot/version +++ b/sys/arch/vax/boot/boot/version @@ -1,4 +1,4 @@ -$OpenBSD: version,v 1.5 2008/03/30 19:54:05 miod Exp $ +$OpenBSD: version,v 1.6 2008/08/10 18:20:07 miod Exp $ $NetBSD: version,v 1.4 2001/11/09 19:53:15 scw Exp $ NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this @@ -34,3 +34,4 @@ is taken as the current. 1.11: Better VXT2000{,+} support. 1.12: Glass console support on VXT2000{,+}. 1.13: Enable the loadfile code added in revision 1.8. +1.14: Support for VaxStation 3[58][24]0 (serial port console only). diff --git a/sys/arch/vax/stand/boot/autoconf.c b/sys/arch/vax/stand/boot/autoconf.c index 8b20a30b1af..1f02f44d51a 100644 --- a/sys/arch/vax/stand/boot/autoconf.c +++ b/sys/arch/vax/stand/boot/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.10 2008/05/21 19:42:07 miod Exp $ */ +/* $OpenBSD: autoconf.c,v 1.11 2008/08/10 18:20:07 miod Exp $ */ /* $NetBSD: autoconf.c,v 1.19 2002/06/01 15:33:22 ragge Exp $ */ /* * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden. @@ -49,6 +49,7 @@ void autoconf(void); void findcpu(void); void consinit(void); void scbinit(void); +void clkstart(void); int getsecs(void); void scb_stray(void *); void longjmp(int *); @@ -68,8 +69,9 @@ autoconf(void) int fromnet = (bootregs[12] != -1); findcpu(); /* Configures CPU variables */ + scbinit(); /* Setup interrupts */ consinit(); /* Allow us to print out things */ - scbinit(); /* Fix interval clock etc */ + clkstart(); /* Fix interval clock etc */ #ifdef DEV_DEBUG printf("Register contents:\n"); @@ -136,14 +138,17 @@ struct ivec_dsp **scb; struct ivec_dsp *scb_vec; extern struct ivec_dsp idsptch; extern int jbuf[10]; +extern int mcheck_silent; static void mcheck(void *arg) { int off, *mfp = (int *)&arg; - off = (mfp[7]/4 + 8); - printf("Machine check, pc=%x, psl=%x\n", mfp[off], mfp[off+1]); + if (!mcheck_silent) { + off = (mfp[7]/4 + 8); + printf("Machine check, pc=%x, psl=%x\n", mfp[off], mfp[off+1]); + } longjmp(jbuf); } @@ -175,9 +180,13 @@ scbinit(void) scb_vec[i].pushlarg = (void *) (i * 4); scb_vec[i].ev = NULL; } - scb_vec[0xc0/4].hoppaddr = rtimer; scb_vec[4/4].hoppaddr = mcheck; +} +void +clkstart(void) +{ + scb_vec[0xc0/4].hoppaddr = rtimer; if (vax_boardtype != VAX_BTYP_VXT) mtpr(-10000, PR_NICR); /* Load in count register */ mtpr(0x800000d1, PR_ICCS); /* Start clock and enable interrupt */ diff --git a/sys/arch/vax/stand/boot/boot.c b/sys/arch/vax/stand/boot/boot.c index 3ee6054da8f..160254d2868 100644 --- a/sys/arch/vax/stand/boot/boot.c +++ b/sys/arch/vax/stand/boot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.17 2008/03/30 19:54:05 miod Exp $ */ +/* $OpenBSD: boot.c,v 1.18 2008/08/10 18:20:07 miod Exp $ */ /* $NetBSD: boot.c,v 1.18 2002/05/31 15:58:26 ragge Exp $ */ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. @@ -79,6 +79,7 @@ const struct vals { int jbuf[10]; int sluttid, senast, skip, askname; +int mcheck_silent; struct rpb bootrpb; void @@ -108,7 +109,7 @@ Xmain(void) transition = ' '; askname = bootrpb.rpb_bootr5 & RB_ASKNAME; - printf("\n\r>> OpenBSD/vax boot [%s] [%s] <<\n", "1.13", __DATE__); + printf("\n\r>> OpenBSD/vax boot [%s] <<\n", "1.14"); printf(">> Press enter to autoboot now, or any other key to abort: "); sluttid = getsecs() + 5; senast = 0; diff --git a/sys/arch/vax/stand/boot/consio.c b/sys/arch/vax/stand/boot/consio.c index b2aabd8da37..4e87e1321b0 100644 --- a/sys/arch/vax/stand/boot/consio.c +++ b/sys/arch/vax/stand/boot/consio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: consio.c,v 1.7 2006/08/30 20:02:13 miod Exp $ */ +/* $OpenBSD: consio.c,v 1.8 2008/08/10 18:20:07 miod Exp $ */ /* $NetBSD: consio.c,v 1.13 2002/05/24 21:40:59 ragge Exp $ */ /* * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden. @@ -32,9 +32,7 @@ /* All bugs are subject to removal without further notice */ - - -#include "sys/param.h" +#include #include "../vax/gencons.h" @@ -51,45 +49,70 @@ static void (*put_fp)(int) = NULL; static int (*get_fp)(void) = NULL; static int (*test_fp)(void) = NULL; -void pr_putchar(int c); /* putchar() using mtpr/mfpr */ -int pr_getchar(void); -int pr_testchar(void); +/* + * I/O using mtpr/mfpr + */ -void rom_putchar(int c); /* putchar() using ROM routines */ -int rom_getchar(void); -int rom_testchar(void); +void pr_putchar(int c); +int pr_getchar(void); +int pr_testchar(void); -int rom_putc; /* ROM-address of put-routine */ -int rom_getc; /* ROM-address of get-routine */ +/* + * I/O using ROM routines + */ + +void rom_putchar(int c); +int rom_getchar(void); +int rom_testchar(void); + +int rom_putc; /* ROM-address of put-routine */ +int rom_getc; /* ROM-address of get-routine */ + +/* + * I/O using the KA630 ROM console routines + */ /* Pointer to KA630 console page, initialized by ka630_consinit */ unsigned char *ka630_conspage; +void ka630_consinit(void); -/* Function that initializes things for KA630 ROM console I/O */ -void ka630_consinit(void); +void ka630_rom_putchar(int c); +int ka630_rom_getchar(void); +int ka630_rom_testchar(void); -/* Functions that use KA630 ROM for console I/O */ -void ka630_rom_putchar(int c); -int ka630_rom_getchar(void); -int ka630_rom_testchar(void); +/* + * I/O using the KA53 ROM console routines + */ -/* Also added such a thing for KA53 - MK-991208 */ unsigned char *ka53_conspage; -void ka53_consinit(void); +void ka53_consinit(void); -void ka53_rom_putchar(int c); -int ka53_rom_getchar(void); -int ka53_rom_testchar(void); +void ka53_rom_putchar(int c); +int ka53_rom_getchar(void); +int ka53_rom_testchar(void); -void vxt_putchar(int c); -int vxt_getchar(void); -int vxt_testchar(void); +/* + * I/O using the VXT2000 serial ports + */ -void putchar(int); -int getchar(void); -int testkey(void); -void consinit(void); -void _rtt(void); +void vxt_putchar(int c); +int vxt_getchar(void); +int vxt_testchar(void); + +/* + * I/O using the VS3[58][24]0 serial ports + */ + +void ff_consinit(void); +void ff_putchar(int c); +int ff_getchar(void); +int ff_testchar(void); + +void putchar(int); +int getchar(void); +int testkey(void); +void consinit(void); +void _rtt(void); void putchar(int c) @@ -108,7 +131,7 @@ getchar(void) c = (*get_fp)() & 0177; while (c == 17 || c == 19); /* ignore XON/XOFF */ if (c < 96 && c > 64) - c += 32; + c += 32; /* force lowercase */ return c; } @@ -176,11 +199,17 @@ consinit(void) ka53_consinit(); break; + case VAX_BTYP_60: + put_fp = ff_putchar; + get_fp = ff_getchar; + test_fp = ff_testchar; + ff_consinit(); + break; + #ifdef notdef case VAX_BTYP_630: case VAX_BTYP_650: case VAX_BTYP_9CC: - case VAX_BTYP_60: put_fp = pr_putchar; get_fp = pr_getchar; break @@ -343,3 +372,121 @@ vxt_testchar(void) return vxtregs[CH_DATA]; } } + +/* + * VaxStation 3[58][24]0 console routines. + * + * We do not know what the proper ROM entry points are, so these routines + * drive the serial ports directly. + * + * Unfortunately the address of the serial ports depend on the position + * of the L2003 I/O board in the system, which requires us to check all + * slots for their ID. Of course, empty slots will cause a machine check, + * and the suggested method of looking at the BUSCTL register to know + * which slots are populated is not usable, since we are way too late in + * the boot process. + */ + +struct ff_dzregs { + volatile unsigned short csr; + volatile unsigned short unused; + volatile unsigned short rbuf; + volatile unsigned short unused2; + volatile unsigned short tcr; + volatile unsigned short unused3; + volatile unsigned short tdr; +}; + +#define DZ_CSR_TX_READY 0100000 +#define DZ_CSR_RX_DONE 0000200 + +int ff_ioslot = -1; +static struct ff_dzregs *ff_dz; + +void +ff_consinit() +{ + extern int jbuf[10]; + extern int mcheck_silent; + extern int setjmp(int *); + + int line = 3; /* printer port */ + int mid, modaddr, modtype; + + mcheck_silent = 1; + for (mid = 0; mid < 8; mid++) { + modaddr = 0x31fffffc + (mid << 25); + if (setjmp(jbuf)) { + /* this slot is empty */ + continue; + } + modtype = *(int *)modaddr; + if ((modtype & 0xff) == 0x04) { + ff_ioslot = mid; + break; + } + } + mcheck_silent = 0; + + if (ff_ioslot < 0) { + /* + * This shouldn't happen. Try mid #5 (slot #4) as a + * supposedly sane default. + */ + ff_ioslot = 5; + } + + ff_dz = (struct ff_dzregs *) + (0x30000000 + (ff_ioslot << 25) + 0x00600000); + ff_dz->tcr = 1 << line; +} + +void +ff_putchar(int c) +{ + while ((ff_dz->csr & DZ_CSR_TX_READY) == 0) + ; + ff_dz->tdr = c; + while ((ff_dz->csr & DZ_CSR_TX_READY) == 0) + ; +} + +int +ff_getchar() +{ + int line = 3; /* printer port */ + unsigned short rbuf; + + for(;;) { + while ((ff_dz->csr & DZ_CSR_RX_DONE) == 0) + ; + rbuf = ff_dz->rbuf; + if (((rbuf >> 8) & 3) == line) + break; + } + + rbuf &= 0x7f; + if (rbuf == 13) + rbuf = 10; + + return (int)rbuf; +} + +int +ff_testchar() +{ + int line = 3; /* printer port */ + unsigned short rbuf; + + if ((ff_dz->csr & DZ_CSR_RX_DONE) == 0) + return 0; + rbuf = ff_dz->rbuf; + if (((rbuf >> 8) & 3) != line) + return 0; + + rbuf &= 0x7f; + if (rbuf == 13) + rbuf = 10; + + return (int)rbuf; +} diff --git a/sys/arch/vax/stand/boot/if_le.c b/sys/arch/vax/stand/boot/if_le.c index 5d1537d393b..8206f98f8ca 100644 --- a/sys/arch/vax/stand/boot/if_le.c +++ b/sys/arch/vax/stand/boot/if_le.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_le.c,v 1.3 2003/11/07 10:16:45 jmc Exp $ */ +/* $OpenBSD: if_le.c,v 1.4 2008/08/10 18:20:07 miod Exp $ */ /* $NetBSD: if_le.c,v 1.6 2000/05/20 13:30:03 ragge Exp $ */ /* * Copyright (c) 1997, 1999 Ludd, University of Lule}, Sweden. @@ -104,7 +104,8 @@ volatile struct buffdesc { short bd_mcnt; } *rdesc, *tdesc; -static int addoff, kopiera = 0; +static int addoff; +static int lebufaddr; /* Flags in the address field */ #define BR_OWN 0x80000000 @@ -145,9 +146,19 @@ leopen(struct open_file *f, int adapt, int ctlr, int unit, int part) if (vax_boardtype == VAX_BTYP_650 && ((vax_siedata >> 8) & 0xff) == VAX_SIE_KA640) { - kopiera = 1; + lebufaddr = 0x20120000; ea = (void *)0x20084200; nireg = (void *)0x20084400; + } else if (vax_boardtype == VAX_BTYP_60) { + extern int ff_ioslot; + lebufaddr = 0x30a00000 + (ff_ioslot << 25); + ea = (int *)(0x30800000 + (ff_ioslot << 25)); + for (i = 0; i < 6; i++) { + eaddr[i] = *(u_char *)((int)ea + 2); + ea++; + } + ea = NULL; + nireg = (void *)(0x30200000 + (ff_ioslot << 25)); } else { *(int *)0x20080014 = 0; /* Be sure we do DMA in low 16MB */ ea = (void *)0x20090000; /* XXX Ethernet address */ @@ -167,8 +178,10 @@ igen: while (to--) ; - for (i = 0; i < 6; i++) - eaddr[i] = ea[i] & 0377; + if (ea != NULL) { + for (i = 0; i < 6; i++) + eaddr[i] = ea[i] & 0377; + } if (initblock == NULL) { (void *)initblock = @@ -180,39 +193,39 @@ igen: (int)rdesc = QW_ALLOC(sizeof(struct buffdesc) * NRBUF) + addoff; initblock->ib_rdr = (RLEN << 29) | (int)rdesc; - if (kopiera) + if (lebufaddr) initblock->ib_rdr -= (int)initblock; (int)tdesc = QW_ALLOC(sizeof(struct buffdesc) * NTBUF) + addoff; initblock->ib_tdr = (TLEN << 29) | (int)tdesc; - if (kopiera) + if (lebufaddr) initblock->ib_tdr -= (int)initblock; - if (kopiera) + if (lebufaddr) copyout(initblock, 0, sizeof(struct initblock)); for (i = 0; i < NRBUF; i++) { rdesc[i].bd_adrflg = QW_ALLOC(BUFSIZE) | BR_OWN; - if (kopiera) + if (lebufaddr) rdesc[i].bd_adrflg -= (int)initblock; rdesc[i].bd_bcnt = -BUFSIZE; rdesc[i].bd_mcnt = 0; } - if (kopiera) + if (lebufaddr) copyout((void *)rdesc, (int)rdesc - (int)initblock, sizeof(struct buffdesc) * NRBUF); for (i = 0; i < NTBUF; i++) { tdesc[i].bd_adrflg = QW_ALLOC(BUFSIZE); - if (kopiera) + if (lebufaddr) tdesc[i].bd_adrflg -= (int)initblock; tdesc[i].bd_bcnt = 0xf000; tdesc[i].bd_mcnt = 0; } - if (kopiera) + if (lebufaddr) copyout((void *)tdesc, (int)tdesc - (int)initblock, sizeof(struct buffdesc) * NTBUF); } - if (kopiera) { + if (lebufaddr) { LEWRCSR(LE_CSR1, 0); LEWRCSR(LE_CSR2, 0); } else { @@ -251,7 +264,7 @@ retry: csr = LERDCSR(LE_CSR0); LEWRCSR(LE_CSR0, csr & (LE_C0_BABL|LE_C0_MISS|LE_C0_MERR|LE_C0_RINT)); - if (kopiera) + if (lebufaddr) copyin((int)&rdesc[next_rdesc] - (int)initblock, (void *)&rdesc[next_rdesc], sizeof(struct buffdesc)); if (rdesc[next_rdesc].bd_adrflg & BR_OWN) @@ -263,7 +276,7 @@ retry: if ((len = rdesc[next_rdesc].bd_mcnt - 4) > maxlen) len = maxlen; - if (kopiera) + if (lebufaddr) copyin((rdesc[next_rdesc].bd_adrflg&0xffffff), pkt, len); else @@ -273,7 +286,7 @@ retry: rdesc[next_rdesc].bd_mcnt = 0; rdesc[next_rdesc].bd_adrflg |= BR_OWN; - if (kopiera) + if (lebufaddr) copyout((void *)&rdesc[next_rdesc], (int)&rdesc[next_rdesc] - (int)initblock, sizeof(struct buffdesc)); if (++next_rdesc >= NRBUF) @@ -298,13 +311,13 @@ retry: csr = LERDCSR(LE_CSR0); LEWRCSR(LE_CSR0, csr & (LE_C0_MISS|LE_C0_CERR|LE_C0_TINT)); - if (kopiera) + if (lebufaddr) copyin((int)&tdesc[next_tdesc] - (int)initblock, (void *)&tdesc[next_tdesc], sizeof(struct buffdesc)); if (tdesc[next_tdesc].bd_adrflg & BT_OWN) goto retry; - if (kopiera) + if (lebufaddr) copyout(pkt, (tdesc[next_tdesc].bd_adrflg & 0xffffff), len); else bcopy(pkt, (char *)(tdesc[next_tdesc].bd_adrflg & 0xffffff) + @@ -313,7 +326,7 @@ retry: (len < ETHER_MIN_LEN ? -ETHER_MIN_LEN : -len); tdesc[next_tdesc].bd_mcnt = 0; tdesc[next_tdesc].bd_adrflg |= BT_OWN | BT_STP | BT_ENP; - if (kopiera) + if (lebufaddr) copyout((void *)&tdesc[next_tdesc], (int)&tdesc[next_tdesc] - (int)initblock, sizeof(struct buffdesc)); @@ -344,29 +357,47 @@ leclose(struct open_file *f) void copyout(void *f, int dest, int len) { - short *from = f; - short *toaddr; + if (vax_boardtype == VAX_BTYP_60) { + u_char *from = f; + u_char *toaddr = (u_char *)lebufaddr + dest; - toaddr = (short *)0x20120000 + dest; + while (len-- > 0) + *toaddr++ = *from++; + } else { + short *from = f; + short *toaddr; - while (len > 0) { - *toaddr = *from++; - toaddr += 2; - len -= 2; + toaddr = (short *)lebufaddr + dest; + + while (len > 0) { + *toaddr = *from++; + toaddr += 2; + len -= 2; + } } } void copyin(int src, void *f, int len) { - short *to = f; - short *fromaddr; + if (vax_boardtype == VAX_BTYP_60) { + u_char *to = f; + u_char *fromaddr; - fromaddr = (short *)0x20120000 + src; + fromaddr = (u_char *)lebufaddr + src; - while (len > 0) { - *to++ = *fromaddr; - fromaddr += 2; - len -= 2; + while (len-- > 0) + *to++ = *fromaddr++; + } else { + short *to = f; + short *fromaddr; + + fromaddr = (short *)lebufaddr + src; + + while (len > 0) { + *to++ = *fromaddr; + fromaddr += 2; + len -= 2; + } } } diff --git a/sys/arch/vax/stand/boot/version b/sys/arch/vax/stand/boot/version index 8aaeca812aa..781a361f1b4 100644 --- a/sys/arch/vax/stand/boot/version +++ b/sys/arch/vax/stand/boot/version @@ -1,4 +1,4 @@ -$OpenBSD: version,v 1.5 2008/03/30 19:54:05 miod Exp $ +$OpenBSD: version,v 1.6 2008/08/10 18:20:07 miod Exp $ $NetBSD: version,v 1.4 2001/11/09 19:53:15 scw Exp $ NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this @@ -34,3 +34,4 @@ is taken as the current. 1.11: Better VXT2000{,+} support. 1.12: Glass console support on VXT2000{,+}. 1.13: Enable the loadfile code added in revision 1.8. +1.14: Support for VaxStation 3[58][24]0 (serial port console only). -- 2.20.1