Home | History | Annotate | Line # | Download | only in vax
ka43.c revision 1.5
      1  1.5     ragge /*	$NetBSD: ka43.c,v 1.5 1997/04/18 18:53:38 ragge Exp $ */
      2  1.1     ragge /*
      3  1.1     ragge  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
      4  1.1     ragge  * All rights reserved.
      5  1.1     ragge  *
      6  1.1     ragge  * This code is derived from software contributed to Ludd by Bertram Barth.
      7  1.1     ragge  *
      8  1.1     ragge  * Redistribution and use in source and binary forms, with or without
      9  1.1     ragge  * modification, are permitted provided that the following conditions
     10  1.1     ragge  * are met:
     11  1.1     ragge  * 1. Redistributions of source code must retain the above copyright
     12  1.1     ragge  *    notice, this list of conditions and the following disclaimer.
     13  1.1     ragge  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1     ragge  *    notice, this list of conditions and the following disclaimer in the
     15  1.1     ragge  *    documentation and/or other materials provided with the distribution.
     16  1.1     ragge  * 3. All advertising materials mentioning features or use of this software
     17  1.1     ragge  *    must display the following acknowledgement:
     18  1.4     ragge  *	This product includes software developed at Ludd, University of
     19  1.4     ragge  *	Lule}, Sweden and its contributors.
     20  1.1     ragge  * 4. The name of the author may not be used to endorse or promote products
     21  1.1     ragge  *    derived from this software without specific prior written permission
     22  1.1     ragge  *
     23  1.1     ragge  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24  1.1     ragge  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  1.1     ragge  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  1.1     ragge  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27  1.1     ragge  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28  1.1     ragge  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29  1.1     ragge  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30  1.1     ragge  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31  1.1     ragge  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32  1.1     ragge  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33  1.1     ragge  */
     34  1.1     ragge 
     35  1.1     ragge #include <sys/param.h>
     36  1.1     ragge #include <sys/types.h>
     37  1.1     ragge #include <sys/device.h>
     38  1.1     ragge #include <sys/kernel.h>
     39  1.1     ragge 
     40  1.1     ragge #include <vm/vm.h>
     41  1.1     ragge #include <vm/vm_kern.h>
     42  1.1     ragge 
     43  1.1     ragge #include <machine/pte.h>
     44  1.4     ragge #include <machine/cpu.h>
     45  1.1     ragge #include <machine/mtpr.h>
     46  1.1     ragge #include <machine/sid.h>
     47  1.1     ragge #include <machine/pmap.h>
     48  1.1     ragge #include <machine/nexus.h>
     49  1.1     ragge #include <machine/uvax.h>
     50  1.1     ragge #include <machine/ka43.h>
     51  1.1     ragge #include <machine/clock.h>
     52  1.1     ragge 
     53  1.1     ragge void	ka43_conf __P((struct device*, struct device*, void*));
     54  1.1     ragge void	ka43_steal_pages __P((void));
     55  1.1     ragge 
     56  1.5     ragge int	ka43_mchk __P((caddr_t));
     57  1.1     ragge void	ka43_memerr __P((void));
     58  1.1     ragge 
     59  1.5     ragge int	ka43_clear_errors __P((void));
     60  1.1     ragge 
     61  1.5     ragge int	ka43_cache_init __P((void));	/* "int mapen" as argument? */
     62  1.5     ragge int	ka43_cache_reset __P((void));
     63  1.5     ragge int	ka43_cache_enable __P((void));
     64  1.5     ragge int	ka43_cache_disable __P((void));
     65  1.5     ragge int	ka43_cache_invalidate __P((void));
     66  1.1     ragge 
     67  1.4     ragge static struct uc_map ka43_map[] = {
     68  1.1     ragge 	{ KA43_CFGTST,		KA43_CFGTST,	4,		0 },
     69  1.1     ragge 	{ KA43_ROM_BASE,	KA43_ROM_END,	KA43_ROM_SIZE,	0 },
     70  1.1     ragge 	{ KA43_CPU_BASE,	KA43_CPU_END,	KA43_CPU_SIZE,	0 },
     71  1.1     ragge 	{ KA43_CT2_BASE,	KA43_CT2_END,	KA43_CT2_SIZE,	0 },
     72  1.1     ragge 	{ KA43_CH2_CREG,	KA43_CH2_CREG,	4,		0 },
     73  1.1     ragge 	{ KA43_NWA_BASE,	KA43_NWA_END,	KA43_NWA_SIZE,	0 },
     74  1.1     ragge 	{ KA43_SER_BASE,	KA43_SER_END,	KA43_SER_SIZE,	0 },
     75  1.1     ragge 	{ KA43_WAT_BASE,	KA43_WAT_END,	KA43_WAT_SIZE,	0 },
     76  1.1     ragge 	{ KA43_SCS_BASE,	KA43_SCS_END,	KA43_SCS_SIZE,	0 },
     77  1.1     ragge 	{ KA43_LAN_BASE,	KA43_LAN_END,	KA43_LAN_SIZE,	0 },
     78  1.1     ragge 	{ KA43_CUR_BASE,	KA43_CUR_END,	KA43_CUR_SIZE,	0 },
     79  1.1     ragge 	{ KA43_DMA_BASE,	KA43_DMA_END,	KA43_DMA_SIZE,	0 },
     80  1.1     ragge 	{ KA43_VME_BASE,	KA43_VME_END,	KA43_VME_SIZE,	0 },
     81  1.1     ragge 	/*
     82  1.1     ragge 	 * there's more to come, eg. framebuffers (GPX/SPX)
     83  1.1     ragge 	 */
     84  1.1     ragge 	{0, 0, 0, 0},
     85  1.1     ragge };
     86  1.1     ragge 
     87  1.4     ragge struct	cpu_dep ka43_calls = {
     88  1.4     ragge 	ka43_steal_pages,
     89  1.4     ragge 	no_nicr_clock,
     90  1.4     ragge 	ka43_mchk,
     91  1.4     ragge 	ka43_memerr,
     92  1.4     ragge 	ka43_conf,
     93  1.5     ragge 	chip_clkread,
     94  1.5     ragge 	chip_clkwrite,
     95  1.5     ragge 	7,	/* 7.6 VUP */
     96  1.4     ragge 	(void*)KA43_INTREQ,
     97  1.4     ragge 	(void*)KA43_INTCLR,
     98  1.4     ragge 	(void*)KA43_INTMSK,
     99  1.4     ragge 	ka43_map,
    100  1.4     ragge };
    101  1.4     ragge 
    102  1.5     ragge /*
    103  1.5     ragge  * ka43_steal_pages() is called with MMU disabled, after that call MMU gets
    104  1.5     ragge  * enabled. Thus we initialize these four pointers with physical addresses,
    105  1.5     ragge  * but before leving ka43_steal_pages() we reset them to virtual addresses.
    106  1.5     ragge  */
    107  1.5     ragge struct	ka43_cpu   *ka43_cpu	= (void*)KA43_CPU_BASE;
    108  1.1     ragge 
    109  1.5     ragge u_int	*ka43_creg = (void*)KA43_CH2_CREG;
    110  1.5     ragge u_int	*ka43_ctag = (void*)KA43_CT2_BASE;
    111  1.1     ragge 
    112  1.5     ragge #define KA43_MC_RESTART	0x00008000	/* Restart possible*/
    113  1.5     ragge #define KA43_PSL_FPDONE	0x00010000	/* First Part Done */
    114  1.1     ragge 
    115  1.5     ragge struct ka43_mcframe {		/* Format of RigelMAX machine check frame: */
    116  1.5     ragge 	int	mc43_bcnt;	/* byte count, always 24 (0x18) */
    117  1.5     ragge 	int	mc43_code;	/* machine check type code and restart bit */
    118  1.5     ragge 	int	mc43_addr;	/* most recent (faulting?) virtual address */
    119  1.5     ragge 	int	mc43_viba;	/* contents of VIBA register */
    120  1.5     ragge 	int	mc43_sisr;	/* ICCS bit 6 and SISR bits 15:0 */
    121  1.5     ragge 	int	mc43_istate;	/* internal state */
    122  1.5     ragge 	int	mc43_sc;	/* shift count register */
    123  1.5     ragge 	int	mc43_pc;	/* trapped PC */
    124  1.5     ragge 	int	mc43_psl;	/* trapped PSL */
    125  1.5     ragge };
    126  1.1     ragge 
    127  1.5     ragge static char *ka43_mctype[] = {
    128  1.5     ragge 	"no error (0)",			/* Code 0: No error */
    129  1.5     ragge 	"FPA: protocol error",		/* Code 1-5: FPA errors */
    130  1.5     ragge 	"FPA: illegal opcode",
    131  1.5     ragge 	"FPA: operand parity error",
    132  1.5     ragge 	"FPA: unknown status",
    133  1.5     ragge 	"FPA: result parity error",
    134  1.5     ragge 	"unused (6)",			/* Code 6-7: Unused */
    135  1.1     ragge 	"unused (7)",
    136  1.5     ragge 	"MMU error (TLB miss)",		/* Code 8-9: MMU errors */
    137  1.1     ragge 	"MMU error (TLB hit)",
    138  1.5     ragge 	"HW interrupt at unused IPL",	/* Code 10: Interrupt error */
    139  1.5     ragge 	"MOVCx impossible state",	/* Code 11-13: Microcode errors */
    140  1.1     ragge 	"undefined trap code (i-box)",
    141  1.1     ragge 	"undefined control store address",
    142  1.5     ragge 	"unused (14)",			/* Code 14-15: Unused */
    143  1.1     ragge 	"unused (15)",
    144  1.5     ragge 	"PC tag or data parity error",	/* Code 16: Cache error */
    145  1.5     ragge 	"data bus parity error",	/* Code 17: Read error */
    146  1.5     ragge 	"data bus error (NXM)",		/* Code 18: Write error */
    147  1.5     ragge 	"undefined data bus state",	/* Code 19: Bus error */
    148  1.1     ragge };
    149  1.5     ragge #define MC43_MAX	19
    150  1.5     ragge 
    151  1.5     ragge static int ka43_error_count = 0;
    152  1.1     ragge 
    153  1.1     ragge int
    154  1.1     ragge ka43_mchk(addr)
    155  1.1     ragge 	caddr_t addr;
    156  1.1     ragge {
    157  1.5     ragge 	register struct ka43_mcframe *mcf = (void*)addr;
    158  1.5     ragge 
    159  1.5     ragge 	mtpr(0x00, PR_MCESR);	/* Acknowledge the machine check */
    160  1.5     ragge 	printf("machine check %d (0x%x)\n", mcf->mc43_code, mcf->mc43_code);
    161  1.5     ragge 	printf("reason: %s\n", ka43_mctype[mcf->mc43_code & 0xff]);
    162  1.5     ragge 	if (++ka43_error_count > 10) {
    163  1.5     ragge 		printf("error_count exceeded: %d\n", ka43_error_count);
    164  1.5     ragge 		return (-1);
    165  1.5     ragge 	}
    166  1.1     ragge 
    167  1.5     ragge 	/*
    168  1.5     ragge 	 * If either the Restart flag is set or the First-Part-Done flag
    169  1.5     ragge 	 * is set, and the TRAP2 (double error) bit is not set, the the
    170  1.5     ragge 	 * error is recoverable.
    171  1.5     ragge 	 */
    172  1.5     ragge 	if (mfpr(PR_PCSTS) & KA43_PCS_TRAP2) {
    173  1.5     ragge 		printf("TRAP2 (double error) in ka43_mchk.\n");
    174  1.5     ragge 		panic("unrecoverable state in ka43_mchk.\n");
    175  1.5     ragge 		return (-1);
    176  1.5     ragge 	}
    177  1.5     ragge 	if ((mcf->mc43_code & KA43_MC_RESTART) ||
    178  1.5     ragge 	    (mcf->mc43_psl & KA43_PSL_FPDONE)) {
    179  1.5     ragge 		printf("ka43_mchk: recovering from machine-check.\n");
    180  1.5     ragge 		ka43_cache_reset();	/* reset caches */
    181  1.5     ragge 		return (0);		/* go on; */
    182  1.5     ragge 	}
    183  1.5     ragge 
    184  1.5     ragge 	/*
    185  1.5     ragge 	 * Unknown error state, panic/halt the machine!
    186  1.5     ragge 	 */
    187  1.5     ragge 	printf("ka43_mchk: unknown error state!\n");
    188  1.1     ragge 	return (-1);
    189  1.1     ragge }
    190  1.1     ragge 
    191  1.5     ragge void
    192  1.5     ragge ka43_memerr()
    193  1.5     ragge {
    194  1.5     ragge 	/*
    195  1.5     ragge 	 * Don\'t know what to do here. So just print some messages
    196  1.5     ragge 	 * and try to go on...
    197  1.5     ragge 	 */
    198  1.5     ragge 	printf("memory error!\n");
    199  1.5     ragge 	printf("primary cache status: %b\n", mfpr(PR_PCSTS), KA43_PCSTS_BITS);
    200  1.5     ragge 	printf("secondary cache status: %b\n", *ka43_creg, KA43_SESR_BITS);
    201  1.5     ragge }
    202  1.5     ragge 
    203  1.1     ragge int
    204  1.5     ragge ka43_cache_init()
    205  1.1     ragge {
    206  1.5     ragge 	return (ka43_cache_reset());
    207  1.5     ragge }
    208  1.1     ragge 
    209  1.5     ragge int
    210  1.5     ragge ka43_clear_errors()
    211  1.5     ragge {
    212  1.5     ragge 	int val = *ka43_creg;
    213  1.5     ragge 	val |= KA43_SESR_SERR | KA43_SESR_LERR | KA43_SESR_CERR;
    214  1.5     ragge 	*ka43_creg = val;
    215  1.1     ragge }
    216  1.1     ragge 
    217  1.5     ragge int
    218  1.5     ragge ka43_cache_reset()
    219  1.1     ragge {
    220  1.5     ragge 	/*
    221  1.5     ragge 	 * resetting primary and secondary caches is done in three steps:
    222  1.5     ragge 	 *	1. disable both caches
    223  1.5     ragge 	 *	2. manually clear secondary cache
    224  1.5     ragge 	 *	3. enable both caches
    225  1.5     ragge 	 */
    226  1.5     ragge 	ka43_cache_disable();
    227  1.5     ragge 	ka43_cache_invalidate();
    228  1.5     ragge 	ka43_cache_enable();
    229  1.5     ragge 
    230  1.5     ragge 	printf("primary cache status: %b\n", mfpr(PR_PCSTS), KA43_PCSTS_BITS);
    231  1.5     ragge 	printf("secondary cache status: %b\n", *ka43_creg, KA43_SESR_BITS);
    232  1.5     ragge 	printf("cpu status: parctl=0x%x, hltcod=0x%x\n",
    233  1.5     ragge 	       ka43_cpu->parctl, ka43_cpu->hltcod);
    234  1.1     ragge 
    235  1.1     ragge 	return (0);
    236  1.5     ragge }
    237  1.5     ragge 
    238  1.5     ragge int
    239  1.5     ragge ka43_cache_disable()
    240  1.5     ragge {
    241  1.5     ragge 	int i, val;
    242  1.1     ragge 
    243  1.1     ragge 	/*
    244  1.5     ragge 	 * first disable primary cache and clear error flags
    245  1.1     ragge 	 */
    246  1.5     ragge 	mtpr(KA43_PCS_REFRESH, PR_PCSTS);	/* disable primary cache */
    247  1.5     ragge 	val = mfpr(PR_PCSTS);
    248  1.5     ragge 	mtpr(val, PR_PCSTS);			/* clear error flags */
    249  1.5     ragge 
    250  1.1     ragge 	/*
    251  1.5     ragge 	 * now disable secondary cache and clear error flags
    252  1.1     ragge 	 */
    253  1.5     ragge 	val = *ka43_creg & ~KA43_SESR_CENB;	/* BICL !!! */
    254  1.5     ragge 	*ka43_creg = val;			/* disable secondary cache */
    255  1.5     ragge 	val = KA43_SESR_SERR | KA43_SESR_LERR | KA43_SESR_CERR;
    256  1.5     ragge 	*ka43_creg = val;			/* clear error flags */
    257  1.5     ragge 
    258  1.5     ragge 	return (0);
    259  1.5     ragge }
    260  1.5     ragge 
    261  1.5     ragge int
    262  1.5     ragge ka43_cache_invalidate()
    263  1.5     ragge {
    264  1.5     ragge 	int i, val;
    265  1.5     ragge 
    266  1.5     ragge 	val = KA43_PCTAG_PARITY;	/* clear valid flag, set parity bit */
    267  1.5     ragge 	for (i = 0; i < 256; i++) {	/* 256 Quadword entries */
    268  1.5     ragge 		mtpr(i*8, PR_PCIDX);	/* write index of tag */
    269  1.5     ragge 		mtpr(val, PR_PCTAG);	/* write value into tag */
    270  1.5     ragge 	}
    271  1.5     ragge 	val = KA43_PCS_FLUSH | KA43_PCS_REFRESH;
    272  1.5     ragge 	mtpr(val, PR_PCSTS);		/* flush primary cache */
    273  1.5     ragge 
    274  1.5     ragge 	/*
    275  1.5     ragge 	 * Rigel\'s secondary cache doesn\'t implement a valid-flag.
    276  1.5     ragge 	 * Thus we initialize all entries with out-of-range/dummy
    277  1.5     ragge 	 * addresses which will never be referenced (ie. never hit).
    278  1.5     ragge 	 * After enabling cache we also access 128K of memory starting
    279  1.5     ragge 	 * at 0x00 so that secondary cache will be filled with these
    280  1.5     ragge 	 * valid addresses...
    281  1.5     ragge 	 */
    282  1.5     ragge 	val = 0xff;
    283  1.5     ragge 	/* if (memory > 28 MB) val = 0x55; */
    284  1.5     ragge 	printf("clearing tags...\n");
    285  1.5     ragge 	for (i = 0; i < KA43_CT2_SIZE; i+= 4) {	/* Quadword entries ?? */
    286  1.5     ragge 		ka43_ctag[i/4] = val;		/* reset upper and lower */
    287  1.1     ragge 	}
    288  1.5     ragge 
    289  1.5     ragge 	return (0);
    290  1.1     ragge }
    291  1.1     ragge 
    292  1.5     ragge 
    293  1.5     ragge int
    294  1.5     ragge ka43_cache_enable()
    295  1.1     ragge {
    296  1.5     ragge 	volatile char *membase = (void*)0x80000000;	/* physical 0x00 */
    297  1.5     ragge 	int i, val;
    298  1.5     ragge 
    299  1.5     ragge 	val = KA43_PCS_FLUSH | KA43_PCS_REFRESH;
    300  1.5     ragge 	mtpr(val, PR_PCSTS);		/* flush primary cache */
    301  1.1     ragge 
    302  1.1     ragge 	/*
    303  1.5     ragge 	 * now we enable secondary cache and access first 128K of memory
    304  1.5     ragge 	 * so that secondary cache gets really initialized and holds
    305  1.5     ragge 	 * valid addresses/data...
    306  1.1     ragge 	 */
    307  1.5     ragge 	*ka43_creg = KA43_SESR_CENB;	/* enable secondary cache */
    308  1.5     ragge 	for (i=0; i<128*1024; i++) {
    309  1.5     ragge 		val += membase[i];	/* some dummy operation... */
    310  1.1     ragge 	}
    311  1.1     ragge 
    312  1.5     ragge 	val = KA43_PCS_ENABLE | KA43_PCS_REFRESH;
    313  1.5     ragge 	mtpr(val, PR_PCSTS);		/* enable primary cache */
    314  1.5     ragge 
    315  1.5     ragge 	return (0);
    316  1.1     ragge }
    317  1.1     ragge 
    318  1.1     ragge void
    319  1.1     ragge ka43_conf(parent, self, aux)
    320  1.1     ragge 	struct	device *parent, *self;
    321  1.1     ragge 	void	*aux;
    322  1.1     ragge {
    323  1.1     ragge 	extern char cpu_model[];
    324  1.1     ragge 	extern int vax_siedata;
    325  1.1     ragge 
    326  1.1     ragge 	if (vax_siedata & 0x02)		/* "single-user" flag */
    327  1.1     ragge 		strcpy(cpu_model,"VAXstation 3100 model 76");
    328  1.1     ragge 	else if (vax_siedata & 0x01)	/* "multiuser" flag */
    329  1.1     ragge 		strcpy(cpu_model,"MicroVAX 3100 model 76(?)");
    330  1.1     ragge 	else
    331  1.1     ragge 		strcpy(cpu_model, "unknown KA43 board");
    332  1.1     ragge 
    333  1.3  christos 	printf(": %s\n", cpu_model);
    334  1.1     ragge 
    335  1.5     ragge 	/*
    336  1.5     ragge 	 * ka43_conf() gets called with MMU enabled, now it's save to
    337  1.5     ragge 	 * init/reset the caches.
    338  1.5     ragge 	 */
    339  1.5     ragge 	ka43_cache_init();
    340  1.1     ragge }
    341  1.1     ragge 
    342  1.1     ragge 
    343  1.1     ragge /*
    344  1.5     ragge  * The interface for communication with the LANCE ethernet controller
    345  1.5     ragge  * is setup in the xxx_steal_pages() routine. We decrease highest
    346  1.5     ragge  * available address by 64K and use this area as communication buffer.
    347  1.1     ragge  */
    348  1.1     ragge u_long le_iomem;		/* base addr of RAM -- CPU's view */
    349  1.1     ragge u_long le_ioaddr;		/* base addr of RAM -- LANCE's view */
    350  1.1     ragge 
    351  1.1     ragge void
    352  1.1     ragge ka43_steal_pages()
    353  1.1     ragge {
    354  1.4     ragge 	extern	vm_offset_t avail_start, virtual_avail, avail_end;
    355  1.5     ragge         extern  short *clk_page;
    356  1.5     ragge         extern  int clk_adrshift, clk_tweak;
    357  1.5     ragge 	int	junk, val;
    358  1.1     ragge 	int	i;
    359  1.1     ragge 
    360  1.3  christos 	printf ("ka43_steal_pages: avail_end=0x%x\n", avail_end);
    361  1.1     ragge 
    362  1.1     ragge 	/*
    363  1.1     ragge 	 * SCB is already copied/initialized at addr avail_start
    364  1.1     ragge 	 * by pmap_bootstrap(), but it's not yet mapped. Thus we use
    365  1.1     ragge 	 * the MAPPHYS() macro to reserve these two pages and to
    366  1.1     ragge 	 * perform the mapping. The mapped address is assigned to junk.
    367  1.1     ragge 	 */
    368  1.1     ragge 	MAPPHYS(junk, 2, VM_PROT_READ|VM_PROT_WRITE);
    369  1.1     ragge 
    370  1.5     ragge         clk_adrshift = 1;       /* Addressed at long's... */
    371  1.5     ragge         clk_tweak = 2;          /* ...and shift two */
    372  1.5     ragge         MAPVIRT(clk_page, 2);
    373  1.5     ragge         pmap_map((vm_offset_t)clk_page, (vm_offset_t)KA43_WAT_BASE,
    374  1.5     ragge             (vm_offset_t)KA43_WAT_BASE + NBPG, VM_PROT_READ|VM_PROT_WRITE);
    375  1.5     ragge 
    376  1.5     ragge #if 0
    377  1.1     ragge 	/*
    378  1.1     ragge 	 * At top of physical memory there are some console-prom and/or
    379  1.1     ragge 	 * restart-specific data. Make this area unavailable.
    380  1.1     ragge 	 */
    381  1.5     ragge 	avail_end -= 64 * NBPG;		/* scratch RAM ??? */
    382  1.5     ragge 	avail_end = 0x00FC0000;		/* XXX: for now from ">>> show mem" */
    383  1.5     ragge 
    384  1.5     ragge This is no longer neccessary since the memsize in RPB does not include
    385  1.5     ragge these unavailable pages. Only valid/available pages are counted in RPB.
    386  1.5     ragge 
    387  1.1     ragge #endif
    388  1.1     ragge 
    389  1.1     ragge 	/*
    390  1.1     ragge 	 * If we need to map physical areas also, we can decrease avail_end
    391  1.1     ragge 	 * (the highest available memory-address), copy the stuff into the
    392  1.5     ragge 	 * gap between and use pmap_map to map it. This is done for LANCE's
    393  1.5     ragge 	 * 64K communication area.
    394  1.1     ragge 	 *
    395  1.1     ragge 	 * Don't use the MAPPHYS macro here, since this uses and changes(!)
    396  1.1     ragge 	 * the value of avail_start. Use MAPVIRT even if it's name misleads.
    397  1.1     ragge 	 */
    398  1.5     ragge 	avail_end -= (64 * 1024);	/* reserve 64K */
    399  1.5     ragge 	avail_end &= ~0xffff;		/* force proper (quad?) alignment */
    400  1.1     ragge 
    401  1.5     ragge 	/*
    402  1.5     ragge 	 * Oh holy shit! It took me over one year(!) to find out that
    403  1.5     ragge 	 * the 3100/76 has to use diag-mem instead of physical memory
    404  1.5     ragge 	 * for communication with LANCE (using phys-mem results in
    405  1.5     ragge 	 * parity errors and mchk exceptions with code 17 (0x11)).
    406  1.5     ragge 	 *
    407  1.5     ragge 	 * Many thanks to Matt Thomas, without his help it could have
    408  1.5     ragge 	 * been some more years...  ;-)
    409  1.5     ragge 	 */
    410  1.5     ragge 	le_ioaddr = avail_end | KA43_DIAGMEM;	/* ioaddr in diag-mem!!! */
    411  1.1     ragge 	MAPVIRT(le_iomem, (64 * 1024)/NBPG);
    412  1.1     ragge 	pmap_map((vm_offset_t)le_iomem, le_ioaddr, le_ioaddr + 0xffff,
    413  1.1     ragge 		 VM_PROT_READ|VM_PROT_WRITE);
    414  1.1     ragge 
    415  1.5     ragge 	/*
    416  1.5     ragge 	 * if LANCE\'s io-buffer is above 16 MB, then the appropriate flag
    417  1.5     ragge 	 * in the parity control register has to be set (it works as an
    418  1.5     ragge 	 * additional address bit). In any case, don\'t enable CPEN and
    419  1.5     ragge 	 * DPEN in the PARCTL register, somewhow they are internally managed
    420  1.5     ragge 	 * by the RIGEL chip itself!?!
    421  1.5     ragge 	 */
    422  1.5     ragge 	val = ka43_cpu->parctl & 0x03;	/* read the old value */
    423  1.5     ragge 	if (le_ioaddr & (1 << 24))	/* if RAM above 16 MB */
    424  1.5     ragge 		val |= KA43_PCTL_DMA;	/* set LANCE DMA flag */
    425  1.5     ragge 	ka43_cpu->parctl = val;		/* and write new value */
    426  1.5     ragge 	le_ioaddr &= 0xffffff;		/* Lance uses 24-bit addresses */
    427  1.1     ragge 
    428  1.1     ragge 	/*
    429  1.1     ragge 	 * now map in anything listed in ka43_map...
    430  1.1     ragge 	 */
    431  1.4     ragge 	uvax_fillmap();
    432  1.1     ragge 
    433  1.1     ragge 	/*
    434  1.1     ragge 	 * Clear restart and boot in progress flags in the CPMBX.
    435  1.1     ragge 	 */
    436  1.5     ragge 	((struct ka43_clock *)KA43_WAT_BASE)->cpmbx =
    437  1.5     ragge 	    ((struct ka43_clock *)KA43_WAT_BASE)->cpmbx & 0xF0;
    438  1.1     ragge 
    439  1.5     ragge #if 0
    440  1.1     ragge 	/*
    441  1.5     ragge 	 * Clear all error flags, not really neccessary here, this will
    442  1.5     ragge 	 * be done by ka43_cache_init() anyway...
    443  1.1     ragge 	 */
    444  1.5     ragge 	ka43_clear_errors();
    445  1.5     ragge #endif
    446  1.1     ragge 
    447  1.1     ragge 	/*
    448  1.1     ragge 	 * MM is not yet enabled, thus we still used the physical addresses,
    449  1.1     ragge 	 * but before leaving this routine, we need to reset them to virtual.
    450  1.1     ragge 	 */
    451  1.5     ragge 	ka43_cpu    = (void*)uvax_phys2virt(KA43_CPU_BASE);
    452  1.5     ragge 	ka43_creg   = (void*)uvax_phys2virt(KA43_CH2_CREG);
    453  1.5     ragge 	ka43_ctag   = (void*)uvax_phys2virt(KA43_CT2_BASE);
    454  1.1     ragge }
    455