1 /* $NetBSD: nmi_mainbus.c,v 1.1 2000/07/26 11:47:19 ragge Exp $ */ 2 /* 3 * Copyright (c) 2000 Ludd, University of Lule}, Sweden. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed at Ludd, University of 17 * Lule}, Sweden and its contributors. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #include <sys/param.h> 34 #include <sys/device.h> 35 #include <sys/systm.h> 36 37 #define _VAX_BUS_DMA_PRIVATE 38 #include <machine/bus.h> 39 #include <machine/nexus.h> 40 #include <machine/sid.h> 41 #include <machine/scb.h> 42 #include <machine/cpu.h> 43 #include <machine/ka88.h> 44 45 46 extern struct vax_bus_space vax_mem_bus_space; 47 extern struct vax_bus_dma_tag vax_bus_dma_tag; 48 49 static int 50 nmi_mainbus_print(void *aux, const char *name) 51 { 52 struct nmi_attach_args *na = aux; 53 char *c; 54 55 if (name) { 56 if (na->slot < 10) 57 c = "bi"; 58 else if (na->slot < 20) 59 c = "mem"; 60 else 61 c = "cpu"; 62 printf("%s at %s", c, name); 63 if (na->slot < 10) 64 printf(" slot %d", na->slot); 65 if (vax_boardtype == VAX_BTYP_8800 && na->slot > 20) 66 printf(" (%s)", ka88_confdata & KA88_LEFTPRIM ? 67 "right" : "left"); 68 } 69 return UNCONF; 70 } 71 72 static int 73 nmi_mainbus_match(struct device *parent, struct cfdata *vcf, void *aux) 74 { 75 if (vax_bustype == VAX_NBIBUS) 76 return 1; 77 return 0; 78 } 79 80 static void 81 nmi_mainbus_attach(struct device *parent, struct device *self, void *aux) 82 { 83 struct nmi_attach_args na; 84 int nbia, *r = 0; 85 86 printf("\n"); 87 88 /* One CPU is always found */ 89 na.slot = 20; 90 config_found(self, (void *)&na, nmi_mainbus_print); 91 92 /* Check for a second one */ 93 if (vax_boardtype == VAX_BTYP_8800) { 94 na.slot = 21; 95 config_found(self, (void *)&na, nmi_mainbus_print); 96 } 97 98 /* One memory adapter is also present */ 99 na.slot = 10; 100 config_found(self, (void *)&na, nmi_mainbus_print); 101 102 /* Enable BI interrupts */ 103 mtpr(NICTRL_DEV0|NICTRL_DEV1|NICTRL_MNF, PR_NICTRL); 104 105 /* Search for NBIA/NBIB adapters */ 106 for (nbia = 0; nbia < 2; nbia++) { 107 if (r) 108 vax_unmap_physmem((vaddr_t)r, 1); 109 r = (int *)vax_map_physmem(NBIA_REGS(nbia), 1); 110 if (badaddr((caddr_t)r, 4)) 111 continue; 112 na.slot = 2 * nbia; 113 if (r[1] & 2) 114 config_found(self, (void *)&na, nmi_mainbus_print); 115 na.slot++; 116 if (r[1] & 4) 117 config_found(self, (void *)&na, nmi_mainbus_print); 118 } 119 } 120 121 struct cfattach nmi_mainbus_ca = { 122 sizeof(struct device), nmi_mainbus_match, nmi_mainbus_attach 123 }; 124