xref: /netbsd-src/sys/arch/vax/vax/ubi.c (revision c7fb772b85b2b5d4cfb282f868f454b4701534fd)
1 /*	$NetBSD: ubi.c,v 1.8 2021/08/07 16:19:07 thorpej Exp $ */
2 /*
3  * Copyright (c) 1999 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  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #include <sys/cdefs.h>
28 __KERNEL_RCSID(0, "$NetBSD: ubi.c,v 1.8 2021/08/07 16:19:07 thorpej Exp $");
29 
30 #include <sys/param.h>
31 #include <sys/systm.h>
32 #include <sys/bus.h>
33 #include <sys/cpu.h>
34 #include <sys/device.h>
35 
36 #include <machine/nexus.h>
37 #include <machine/sid.h>
38 #include <machine/ka730.h>
39 
40 static	int ubi_print(void *, const char *);
41 static	int ubi_match(device_t, cfdata_t, void *);
42 static	void ubi_attach(device_t, device_t, void*);
43 
44 CFATTACH_DECL_NEW(ubi, 0,
45     ubi_match, ubi_attach, NULL, NULL);
46 
47 int
ubi_print(void * aux,const char * name)48 ubi_print(void *aux, const char *name)
49 {
50 	struct sbi_attach_args *sa = (struct sbi_attach_args *)aux;
51 
52 	if (name)
53 		aprint_normal("unknown device 0x%x at %s", sa->sa_type, name);
54 
55 	aprint_normal(" tr%d", sa->sa_nexnum);
56 	return (UNCONF);
57 }
58 
59 
60 int
ubi_match(device_t parent,cfdata_t cf,void * aux)61 ubi_match(device_t parent, cfdata_t cf, void *aux)
62 {
63 	if (vax_bustype == VAX_UNIBUS)
64 		return 1;
65 	return 0;
66 }
67 
68 void
ubi_attach(device_t parent,device_t self,void * aux)69 ubi_attach(device_t parent, device_t self, void *aux)
70 {
71 	struct	sbi_attach_args sa;
72 
73 	printf("\n");
74 
75         sa.sa_base = (bus_addr_t)NEX730;
76 
77 #define NEXPAGES (sizeof(struct nexus) / VAX_NBPG)
78 
79 #if 0
80 	/*
81 	 * Probe for memory, can be in the first 4 slots.
82 	 */
83 
84 	for (sa.sa_nexnum = 0; sa.sa_nexnum < 4; sa.sa_nexnum++) {
85 		sa.sa_ioh = vax_map_physmem(NEX730 +
86 		    sizeof(struct nexus) * sa.sa_nexnum, NEXPAGES);
87 		if (badaddr((caddr_t)sa.sa_ioh, 4)) {
88 			vax_unmap_physmem((vaddr_t)sa.sa_ioh, NEXPAGES);
89 		} else {
90 			sa.sa_type = NEX_MEM16;
91 			config_found(self, (void*)&sa, ubi_print, CFARGS_NONE);
92 		}
93 	}
94 #endif
95 
96 	/* VAX 730 fixed configuration */
97 
98 	/* memory */
99 	sa.sa_nexnum = 0;
100 	sa.sa_ioh = vax_map_physmem((int)NEX730 +
101 	   sizeof(struct nexus) * sa.sa_nexnum, NEXPAGES);
102 	sa.sa_type = NEX_MEM16;
103 	config_found(self, (void*)&sa, ubi_print, CFARGS_NONE);
104 
105 	printf("\n");
106 
107 	/* generic UBA */
108 	sa.sa_nexnum = 3;
109 	sa.sa_ioh = vax_map_physmem((int)NEX730 +
110 	    sizeof(struct nexus) * sa.sa_nexnum, NEXPAGES);
111 	sa.sa_type = NEX_UBA0;
112 	config_found(self, (void*)&sa, ubi_print, CFARGS_NONE);
113 }
114