Fri Jun 9 17:55:18 2017 UTC ()
Make VAXstation 4000 TURBOchannel adaptor work.
PIO and IRQ tested on VS4000/60 and /96 with TC-USB (slhci) and PMAD-AA (le).
DMA is untested.
vax needs space to be mapped out, so memory space is pre-mapped for TC option
drivers not bus_space'ified yet, also providing custom bus_space methods for
this kludge.


(flxd)
diff -r1.45 -r1.46 src/sys/arch/alpha/tc/tcasic.c
diff -r1.32 -r1.33 src/sys/arch/pmax/tc/tcbus.c
diff -r1.120 -r1.121 src/sys/arch/vax/conf/files.vax
diff -r1.7 -r1.8 src/sys/arch/vax/vsa/tc_vsbus.c
diff -r1.54 -r1.55 src/sys/dev/tc/tc.c
diff -r1.26 -r1.27 src/sys/dev/tc/tcvar.h

cvs diff -r1.45 -r1.46 src/sys/arch/alpha/tc/tcasic.c (expand / switch to unified diff)

--- src/sys/arch/alpha/tc/tcasic.c 2016/12/12 17:03:40 1.45
+++ src/sys/arch/alpha/tc/tcasic.c 2017/06/09 17:55:18 1.46
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tcasic.c,v 1.45 2016/12/12 17:03:40 flxd Exp $ */ 1/* $NetBSD: tcasic.c,v 1.46 2017/06/09 17:55:18 flxd Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. 4 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Author: Chris G. Demetriou 7 * Author: Chris G. Demetriou
8 * 8 *
9 * Permission to use, copy, modify and distribute this software and 9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright 10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the 11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions 12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation. 13 * thereof, and that both notices appear in supporting documentation.
14 * 14 *
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * School of Computer Science 22 * School of Computer Science
23 * Carnegie Mellon University 23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890 24 * Pittsburgh PA 15213-3890
25 * 25 *
26 * any improvements or extensions that they make and grant Carnegie the 26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes. 27 * rights to redistribute these changes.
28 */ 28 */
29 29
30#include "opt_dec_3000_300.h" 30#include "opt_dec_3000_300.h"
31#include "opt_dec_3000_500.h" 31#include "opt_dec_3000_500.h"
32 32
33#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 33#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
34 34
35__KERNEL_RCSID(0, "$NetBSD: tcasic.c,v 1.45 2016/12/12 17:03:40 flxd Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: tcasic.c,v 1.46 2017/06/09 17:55:18 flxd Exp $");
36 36
37#include <sys/param.h> 37#include <sys/param.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39#include <sys/device.h> 39#include <sys/device.h>
40 40
41#include <machine/autoconf.h> 41#include <machine/autoconf.h>
42#include <machine/rpb.h> 42#include <machine/rpb.h>
43#include <machine/alpha.h> 43#include <machine/alpha.h>
44 44
45#include <dev/tc/tcvar.h> 45#include <dev/tc/tcvar.h>
46#include <alpha/tc/tc_conf.h> 46#include <alpha/tc/tc_conf.h>
47 47
48/* Definition of the driver for autoconfig. */ 48/* Definition of the driver for autoconfig. */
@@ -212,27 +212,27 @@ struct cnboards { @@ -212,27 +212,27 @@ struct cnboards {
212}; 212};
213 213
214/* 214/*
215 * tc_fb_cnattach -- 215 * tc_fb_cnattach --
216 * Attempt to attach the appropriate display driver to the 216 * Attempt to attach the appropriate display driver to the
217 * output console. 217 * output console.
218 */ 218 */
219int 219int
220tc_fb_cnattach(tc_addr_t tcaddr) 220tc_fb_cnattach(tc_addr_t tcaddr)
221{ 221{
222 char tcname[TC_ROM_LLEN]; 222 char tcname[TC_ROM_LLEN];
223 int i; 223 int i;
224 224
225 if (tc_badaddr(tcaddr) || (tc_checkslot(tcaddr, tcname) == 0)) 225 if (tc_badaddr(tcaddr) || (tc_checkslot(tcaddr, tcname, NULL) == 0))
226 return (EINVAL); 226 return (EINVAL);
227 227
228 for (i = 0; i < sizeof(cnboards) / sizeof(cnboards[0]); i++) 228 for (i = 0; i < sizeof(cnboards) / sizeof(cnboards[0]); i++)
229 if (strncmp(tcname, cnboards[i].cb_tcname, TC_ROM_LLEN) == 0) 229 if (strncmp(tcname, cnboards[i].cb_tcname, TC_ROM_LLEN) == 0)
230 break; 230 break;
231 231
232 if (i == sizeof(cnboards) / sizeof(cnboards[0])) 232 if (i == sizeof(cnboards) / sizeof(cnboards[0]))
233 return (ENXIO); 233 return (ENXIO);
234 234
235 (cnboards[i].cb_cnattach)(tcaddr); 235 (cnboards[i].cb_cnattach)(tcaddr);
236 return (0); 236 return (0);
237} 237}
238#endif /* if NWSDISPLAY > 0 */ 238#endif /* if NWSDISPLAY > 0 */

cvs diff -r1.32 -r1.33 src/sys/arch/pmax/tc/tcbus.c (expand / switch to unified diff)

--- src/sys/arch/pmax/tc/tcbus.c 2016/12/12 17:03:41 1.32
+++ src/sys/arch/pmax/tc/tcbus.c 2017/06/09 17:55:18 1.33
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tcbus.c,v 1.32 2016/12/12 17:03:41 flxd Exp $ */ 1/* $NetBSD: tcbus.c,v 1.33 2017/06/09 17:55:18 flxd Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tohru Nishimura. 8 * by Tohru Nishimura.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: tcbus.c,v 1.32 2016/12/12 17:03:41 flxd Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: tcbus.c,v 1.33 2017/06/09 17:55:18 flxd Exp $");
34 34
35#define _PMAX_BUS_DMA_PRIVATE 35#define _PMAX_BUS_DMA_PRIVATE
36/* 36/*
37 * Which system models were configured? 37 * Which system models were configured?
38 */ 38 */
39#include "opt_dec_3max.h" 39#include "opt_dec_3max.h"
40#include "opt_dec_3min.h" 40#include "opt_dec_3min.h"
41#include "opt_dec_maxine.h" 41#include "opt_dec_maxine.h"
42#include "opt_dec_3maxplus.h" 42#include "opt_dec_3maxplus.h"
43 43
44#include <sys/param.h> 44#include <sys/param.h>
45#include <sys/bus.h> 45#include <sys/bus.h>
46#include <sys/cpu.h> 46#include <sys/cpu.h>
@@ -211,27 +211,27 @@ struct cnboards { @@ -211,27 +211,27 @@ struct cnboards {
211 { "PMAGB-FA", pxg_cnattach }, 211 { "PMAGB-FA", pxg_cnattach },
212 { "PMAGB-FB", pxg_cnattach }, 212 { "PMAGB-FB", pxg_cnattach },
213#endif 213#endif
214}; 214};
215 215
216int 216int
217tcfb_cnattach(int slotno) 217tcfb_cnattach(int slotno)
218{ 218{
219 paddr_t tcaddr; 219 paddr_t tcaddr;
220 char tcname[TC_ROM_LLEN]; 220 char tcname[TC_ROM_LLEN];
221 int i; 221 int i;
222 222
223 tcaddr = promcall(callv->_slot_address, slotno); 223 tcaddr = promcall(callv->_slot_address, slotno);
224 if (tc_badaddr(tcaddr) || tc_checkslot(tcaddr, tcname) == 0) 224 if (tc_badaddr(tcaddr) || tc_checkslot(tcaddr, tcname, NULL) == 0)
225 panic("TC console designated by PROM does not exist!?"); 225 panic("TC console designated by PROM does not exist!?");
226 226
227 for (i = 0; i < __arraycount(cnboards); i++) { 227 for (i = 0; i < __arraycount(cnboards); i++) {
228 if (strncmp(tcname, cnboards[i].cb_tcname, TC_ROM_LLEN) == 0) 228 if (strncmp(tcname, cnboards[i].cb_tcname, TC_ROM_LLEN) == 0)
229 break; 229 break;
230 } 230 }
231 231
232 if (i == __arraycount(cnboards)) 232 if (i == __arraycount(cnboards))
233 return (0); 233 return (0);
234 234
235 (cnboards[i].cb_cnattach)((tc_addr_t)TC_PHYS_TO_UNCACHED(tcaddr)); 235 (cnboards[i].cb_cnattach)((tc_addr_t)TC_PHYS_TO_UNCACHED(tcaddr));
236 return (1); 236 return (1);
237} 237}

cvs diff -r1.120 -r1.121 src/sys/arch/vax/conf/files.vax (expand / switch to unified diff)

--- src/sys/arch/vax/conf/files.vax 2015/07/05 03:06:27 1.120
+++ src/sys/arch/vax/conf/files.vax 2017/06/09 17:55:18 1.121
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: files.vax,v 1.120 2015/07/05 03:06:27 matt Exp $ 1# $NetBSD: files.vax,v 1.121 2017/06/09 17:55:18 flxd Exp $
2# 2#
3# new style config file for vax architecture 3# new style config file for vax architecture
4# 4#
5 5
6# maxpartitions must be first item in files.${ARCH}.newconf 6# maxpartitions must be first item in files.${ARCH}.newconf
7maxpartitions 8 7maxpartitions 8
8 8
9maxusers 8 32 64 9maxusers 8 32 64
10 10
11device mainbus { }: bus 11device mainbus { }: bus
12attach mainbus at root 12attach mainbus at root
13 13
14# Define a bunch of devices, needed in more than one place. 14# Define a bunch of devices, needed in more than one place.
@@ -100,28 +100,28 @@ include "dev/dec/files.dec" @@ -100,28 +100,28 @@ include "dev/dec/files.dec"
100 100
101# Memory Disk for install floppy 101# Memory Disk for install floppy
102file dev/md_root.c memory_disk_hooks 102file dev/md_root.c memory_disk_hooks
103 103
104# MSCP device drivers 104# MSCP device drivers
105include "dev/mscp/files.mscp" 105include "dev/mscp/files.mscp"
106 106
107# Unibus/Q22 bus definitions 107# Unibus/Q22 bus definitions
108include "dev/qbus/files.uba" 108include "dev/qbus/files.uba"
109 109
110# TurboCHANNEL bus support and device drivers 110# TurboCHANNEL bus support and device drivers
111include "dev/tc/files.tc" 111include "dev/tc/files.tc"
112 112
113attach tc at vsbus with tcbus 113attach tc at vsbus with tc_vsbus
114file arch/vax/vsa/tc_vsbus.c tcbus 114file arch/vax/vsa/tc_vsbus.c tc_vsbus
115 115
116attach uba at mainbus with uba_mainbus 116attach uba at mainbus with uba_mainbus
117file arch/vax/uba/uba_mainbus.c uba_mainbus 117file arch/vax/uba/uba_mainbus.c uba_mainbus
118attach uba at sbi with uba_sbi 118attach uba at sbi with uba_sbi
119file arch/vax/uba/uba_sbi.c uba_sbi 119file arch/vax/uba/uba_sbi.c uba_sbi
120attach uba at cmi with uba_cmi 120attach uba at cmi with uba_cmi
121file arch/vax/uba/uba_cmi.c uba_cmi 121file arch/vax/uba/uba_cmi.c uba_cmi
122attach uba at ubi with uba_ubi 122attach uba at ubi with uba_ubi
123file arch/vax/uba/uba_ubi.c uba_ubi 123file arch/vax/uba/uba_ubi.c uba_ubi
124 124
125# BI bus definitions 125# BI bus definitions
126include "dev/bi/files.bi" 126include "dev/bi/files.bi"
127 127

cvs diff -r1.7 -r1.8 src/sys/arch/vax/vsa/tc_vsbus.c (expand / switch to unified diff)

--- src/sys/arch/vax/vsa/tc_vsbus.c 2011/06/05 16:12:50 1.7
+++ src/sys/arch/vax/vsa/tc_vsbus.c 2017/06/09 17:55:18 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tc_vsbus.c,v 1.7 2011/06/05 16:12:50 christos Exp $ */ 1/* $NetBSD: tc_vsbus.c,v 1.8 2017/06/09 17:55:18 flxd Exp $ */
2/*- 2/*-
3 * Copyright (c) 2008 The NetBSD Foundation, Inc. 3 * Copyright (c) 2008 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Matt Thomas <matt@3am-software.com>. 7 * by Matt Thomas <matt@3am-software.com>.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -18,130 +18,417 @@ @@ -18,130 +18,417 @@
18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE. 28 * POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
 31#include <sys/cdefs.h>
 32__KERNEL_RCSID(0, "$NetBSD: tc_vsbus.c,v 1.8 2017/06/09 17:55:18 flxd Exp $");
 33
31#include <sys/param.h> 34#include <sys/param.h>
32#include <sys/bus.h> 35#include <sys/bus.h>
33#include <sys/cpu.h> 36#include <sys/cpu.h>
34#include <sys/device.h> 37#include <sys/device.h>
35 38
 39#include <machine/cpu.h>
36#include <machine/pte.h> 40#include <machine/pte.h>
37#include <machine/scb.h> 41#include <machine/scb.h>
 42#include <machine/sid.h>
38#include <machine/vsbus.h> 43#include <machine/vsbus.h>
 44
39#include <dev/tc/tcvar.h> 45#include <dev/tc/tcvar.h>
40 46
41static int tcbus_match(device_t, cfdata_t, void *); 47#define NSLOTS 1
42static void tcbus_attach(device_t, device_t, void *); 
43 48
44struct tcbus_softc { 49struct tc_vsbus_softc {
45 struct tc_softc sc_tc; 50 struct tc_softc sc_tc;
46 struct tc_slotdesc sc_slots[1]; 51 struct tc_slotdesc sc_slots[NSLOTS];
47 struct vax_bus_dma_tag sc_dmatag; 52 struct vax_bus_dma_tag sc_dmatag;
48 struct vax_sgmap sc_sgmap; 53 struct vax_sgmap sc_sgmap;
49 struct evcnt sc_ev; 54 struct evcnt sc_ev;
50 bus_space_handle_t sc_memh; 55 int (*sc_intr_func)(void *);
 56 void *sc_intr_arg;
 57 bus_space_tag_t sc_bst;
 58 bus_space_handle_t sc_bsh_csr;
 59 int sc_cvec;
51}; 60};
52 61
53static bus_dma_tag_t tcbus_dmat; 62static int tc_vsbus_match(device_t, cfdata_t, void *);
 63static void tc_vsbus_attach(device_t, device_t, void *);
 64
 65static int tc_vsbus_dma_init(device_t);
 66static bus_dma_tag_t tc_vsbus_get_dma_tag(int);
 67
 68static void tc_vsbus_intr(void *);
 69static void tc_vsbus_intr_establish(device_t, void *, int, int (*)(void *),
 70 void *);
 71static void tc_vsbus_intr_disestablish(device_t, void *);
 72static const struct evcnt *tc_vsbus_intr_evcnt(device_t, void *);
 73
 74static int vax_tc_bus_space_map(void *, bus_addr_t, bus_size_t, int,
 75 bus_space_handle_t *, int);
 76static int vax_tc_bus_space_subregion(void *, bus_space_handle_t, bus_size_t,
 77 bus_size_t, bus_space_handle_t *);
 78static void vax_tc_bus_space_unmap(void *, bus_space_handle_t, bus_size_t, int);
 79static int vax_tc_bus_space_alloc(void *, bus_addr_t, bus_addr_t, bus_size_t,
 80 bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *);
 81static void vax_tc_bus_space_free(void *, bus_space_handle_t, bus_size_t);
 82static paddr_t vax_tc_bus_space_mmap(void *, bus_addr_t, off_t, int, int);
 83
 84CFATTACH_DECL_NEW(tc_vsbus, sizeof(struct tc_vsbus_softc),
 85 tc_vsbus_match, tc_vsbus_attach, 0, 0);
 86
 87static bus_dma_tag_t tc_vsbus_dmat;
 88
 89struct vax_bus_space vax_tc_bus_space = {
 90 NULL,
 91 vax_tc_bus_space_map,
 92 vax_tc_bus_space_unmap,
 93 vax_tc_bus_space_subregion,
 94 vax_tc_bus_space_alloc,
 95 vax_tc_bus_space_free,
 96 vax_tc_bus_space_mmap,
 97};
 98
 99/*
 100 * taken from KA46 System Board Specification, KA46-0-DBF, Rev. X.02,
 101 * 10 October 1990
 102 */
 103#define KA46_BWF0 0x20080014
 104#define KA46_BWF0_ADP __BIT(31)
 105#define KA46_BWF0_SZ 4
 106
 107/*
 108 * taken from KA49 Processor Module Specification V 1.1, 20 August 1992
 109 */
 110#define KA49_CFG 0x25800000
 111#define KA49_CFG_BA __BIT(0)
 112#define KA49_CFG_SZ 2
 113
 114/*
 115 * taken from Pmariah TURBOchannel Adapter Specification, 29 November 1991
 116 */
 117#define KA4x_TCA_BASE 0x30000000
 118#define KA4x_TCA_DIAG_TRIG (KA4x_TCA_BASE + 0x4000000)
 119#define KA4x_TCA_MAP_CHK_SEQ (KA4x_TCA_BASE + 0x4800000)
 120#define KA4x_TCA_FIFO_DIAG (KA4x_TCA_BASE + 0x5000000)
 121#define KA4x_TCA_SGMAP (KA4x_TCA_BASE + 0x5800000)
 122#define KA4x_TCA_DIAG_ROM (KA4x_TCA_BASE + 0x6000000)
 123#define KA4x_TCA_CSR (KA4x_TCA_BASE + 0x6800000)
 124#define KA4x_TCA_CSR_BLK_SZ __BITS(0, 2) /* 0x00007 RW */
 125#define KA4x_TCA_CSR_SPARE __BIT(3) /* 0x00008 RW */
 126#define KA4x_TCA_CSR_BAD_PAR __BITS(4, 7) /* 0x000f0 RW */
 127#define KA4x_TCA_CSR_RST_TC __BIT(8) /* 0x00100 RW */
 128#define KA4x_TCA_CSR_EN_MAP __BIT(9) /* 0x00200 RW */
 129#define KA4x_TCA_CSR_INVAL_REF __BIT(10) /* 0x00400 RW1C */
 130#define KA4x_TCA_CSR_TC_TMO __BIT(11) /* 0x00800 RW */
 131#define KA4x_TCA_CSR_EN_TC_IRQ __BIT(12) /* 0x01000 RW */
 132#define KA4x_TCA_CSR_TC_IRQ __BIT(13) /* 0x02000 R */
 133#define KA4x_TCA_CSR_ERR __BIT(14) /* 0x04000 RW1C */
 134#define KA4x_TCA_CSR_ALT_CYC_ST __BIT(15) /* 0x08000 RW */
 135#define KA4x_TCA_CSR_EN_PAR __BIT(16) /* 0x10000 RW */
 136#define KA4x_TCA_CSR_FIFO_EMPTY __BIT(17) /* 0x20000 R */
 137#define KA4x_TCA_CSR_SZ 4
 138
 139static int
 140tc_vsbus_match(device_t parent, cfdata_t cfdata, void *aux)
 141{
 142 struct vsbus_attach_args * const va = aux;
 143 uint32_t *csr;
 144 bus_space_tag_t bst = va->va_memt;
 145 bus_space_handle_t bsh;
 146 int found, rc;
 147
 148 if (va->va_paddr != KA4x_TCA_CSR)
 149 return 0;
 150
 151 /* Bus adaptor present? */
 152 switch (vax_boardtype) {
 153 case VAX_BTYP_46:
 154 if (bus_space_map(bst, KA46_BWF0, KA46_BWF0_SZ, 0, &bsh))
 155 return 0;
 156 found = ((bus_space_read_4(bst, bsh, 0) & KA46_BWF0_ADP) != 0);
 157 bus_space_unmap(bst, bsh, KA46_BWF0_SZ);
 158 /*
 159 * On VS4000/60, although interrupting on a real vector, fool
 160 * vsbus interrupt, as no interrupt bit will be set in
 161 * vsbus_softc's sc_intreq for TC adaptor.
 162 */
 163 rc = 20;
 164 break;
 165 case VAX_BTYP_49:
 166 if (bus_space_map(bst, KA49_CFG, KA49_CFG_SZ, 0, &bsh))
 167 return 0;
 168 found = ((bus_space_read_2(bst, bsh, 0) & KA49_CFG_BA) != 0);
 169 bus_space_unmap(bst, bsh, KA49_CFG_SZ);
 170 rc = 10;
 171 break;
 172 default:
 173 return 0;
 174 }
 175 if (!found)
 176 return 0;
 177
 178 /* XXX Assume a found bus adaptor is the TC bus adaptor. */
 179
 180 /* Force interrupt. */
 181 csr = (uint32_t *)va->va_addr;
 182 *csr |= KA4x_TCA_CSR_TC_TMO;
 183 DELAY(10000);
 184 *csr &= ~KA4x_TCA_CSR_TC_TMO;
 185 DELAY(10000);
 186
 187 return rc;
 188}
 189
 190#define INIT_SLOTSZ 1
 191
 192static void
 193tc_vsbus_attach(device_t parent, device_t self, void *aux)
 194{
 195 struct tcbus_attach_args tba;
 196 struct vsbus_attach_args * const va = aux;
 197 struct tc_vsbus_softc * const sc = device_private(self);
 198 struct tc_rommap *rommap;
 199 bus_space_tag_t bst = va->va_memt;
 200 bus_space_handle_t bsh_csr, bsh_slot;
 201 const bus_size_t slotb = 4194304;
 202 uint32_t csr;
 203 int error, slotsz;
 204
 205 sc->sc_cvec = va->va_cvec;
54 206
55CFATTACH_DECL_NEW(tcbus, sizeof(struct tcbus_softc), 207 error = bus_space_map(bst, KA4x_TCA_CSR, KA4x_TCA_CSR_SZ, 0, &bsh_csr);
56 tcbus_match, tcbus_attach, 0, 0); 208 if (error) {
 209 aprint_normal(": failed to map TCA CSR: %d\n", error);
 210 return;
 211 }
 212 sc->sc_bst = bst;
 213 sc->sc_bsh_csr = bsh_csr;
 214
 215 /* Deassert TC option reset and clean up. */
 216 csr = bus_space_read_4(bst, bsh_csr, 0);
 217 csr &= ~(KA4x_TCA_CSR_TC_TMO | KA4x_TCA_CSR_RST_TC);
 218 csr |= KA4x_TCA_CSR_ERR | KA4x_TCA_CSR_INVAL_REF;
 219 bus_space_write_4(bst, bsh_csr, 0, csr);
 220
 221 /*
 222 * Map initial number of "slots" (4 MB each) to read the option ROM
 223 * header.
 224 */
 225 error = bus_space_map(bst, KA4x_TCA_BASE, INIT_SLOTSZ * slotb,
 226 BUS_SPACE_MAP_LINEAR, &bsh_slot);
 227 if (error) {
 228 aprint_normal(": failed to map TC slot: %d", error);
 229 goto fail;
 230 }
 231 /* Determine number of slots required from option ROM header. */
 232 slotsz = 0;
 233 if (tc_checkslot((tc_addr_t)bus_space_vaddr(bst, bsh_slot), NULL,
 234 &rommap))
 235 slotsz = rommap->tcr_ssize.v;
 236 if (slotsz == 0) {
 237 /* Invalid option ROM header or no option present. */
 238 bus_space_unmap(bst, bsh_slot, INIT_SLOTSZ * slotb);
 239 goto fail;
 240 } else if (slotsz > INIT_SLOTSZ) {
 241 /* Remap with actual slot size required. */
 242 bus_space_unmap(bst, bsh_slot, INIT_SLOTSZ * slotb);
 243 error = bus_space_map(bst, KA4x_TCA_BASE, slotsz * slotb,
 244 BUS_SPACE_MAP_LINEAR, &bsh_slot);
 245 if (error) {
 246 aprint_normal(": failed to map TC slot: %d", error);
 247 goto fail;
 248 }
 249 } else
 250 slotsz = INIT_SLOTSZ;
 251
 252 /* Pass pre-mapped space for TC drivers not bus_space'ified yet. */
 253 sc->sc_slots[0].tcs_addr = (tc_addr_t)bus_space_vaddr(bst, bsh_slot);
 254 sc->sc_slots[0].tcs_cookie = sc;
 255 sc->sc_slots[0].tcs_used = 0;
 256
 257 tba.tba_busname = "tc";
 258 /* Tag with custom methods for pre-mapped bus_space. */
 259 tba.tba_memt = &vax_tc_bus_space;
 260 tba.tba_speed = TC_SPEED_12_5_MHZ;
 261 tba.tba_nslots = __arraycount(sc->sc_slots);
 262 tba.tba_slots = sc->sc_slots;
 263 tba.tba_nbuiltins = 0;
 264 tba.tba_intr_evcnt = tc_vsbus_intr_evcnt;
 265 tba.tba_intr_establish = tc_vsbus_intr_establish;
 266 tba.tba_intr_disestablish = tc_vsbus_intr_disestablish;
 267 tba.tba_get_dma_tag = tc_vsbus_get_dma_tag;
 268
 269 error = tc_vsbus_dma_init(self);
 270 if (error) {
 271 aprint_normal(": failed to init DMA: %d", error);
 272 bus_space_unmap(bst, bsh_slot, slotsz * slotb);
 273 goto fail;
 274 }
 275
 276 evcnt_attach_dynamic(&sc->sc_ev, EVCNT_TYPE_INTR, NULL,
 277 device_xname(self), "intr");
 278
 279 /* Enable SGDMA and option IRQ now. */
 280 csr = bus_space_read_4(bst, bsh_csr, 0);
 281 csr &= ~(KA4x_TCA_CSR_TC_TMO | KA4x_TCA_CSR_RST_TC);
 282 csr |= KA4x_TCA_CSR_ERR | KA4x_TCA_CSR_EN_TC_IRQ |
 283 KA4x_TCA_CSR_INVAL_REF | KA4x_TCA_CSR_EN_MAP;
 284 bus_space_write_4(bst, bsh_csr, 0, csr);
 285
 286 /* XXX: why not config_found(9)?? */
 287 tcattach(parent, self, &tba);
 288
 289 return;
 290
 291fail:
 292 aprint_normal("\n");
 293 /* Clear possible timeout bit which asserts TC interrupt. */
 294 csr = bus_space_read_4(bst, bsh_csr, 0);
 295 csr &= ~KA4x_TCA_CSR_TC_TMO;
 296 bus_space_write_4(bst, bsh_csr, 0, csr);
 297 bus_space_unmap(bst, bsh_csr, KA4x_TCA_CSR_SZ);
 298}
 299
 300static int
 301tc_vsbus_dma_init(device_t dev)
 302{
 303 struct tc_vsbus_softc * const sc = device_private(dev);
 304 struct pte *pte;
 305 bus_dma_tag_t dmat = &sc->sc_dmatag;
 306 bus_space_tag_t bst = sc->sc_bst;
 307 bus_space_handle_t bsh;
 308 const bus_size_t ptecnt = 8192;
 309 const bus_size_t mapsize = ptecnt * sizeof(pte[0]);
 310 int error;
 311
 312 vax_sgmap_dmatag_init(dmat, sc, ptecnt);
 313
 314 dmat->_sgmap = &sc->sc_sgmap;
 315
 316 error = bus_space_map(bst, KA4x_TCA_SGMAP, mapsize,
 317 BUS_SPACE_MAP_LINEAR, &bsh);
 318 if (error)
 319 return error;
 320 bus_space_set_region_4(bst, bsh, 0, 0, ptecnt);
 321 pte = bus_space_vaddr(bst, bsh);
 322
 323 /* Initialize the SGMAP. */
 324 vax_sgmap_init(dmat, &sc->sc_sgmap, "tc_sgmap", dmat->_wbase,
 325 dmat->_wsize, pte, 0);
 326
 327 tc_vsbus_dmat = dmat;
 328
 329 return 0;
 330}
57 331
58static bus_dma_tag_t 332static bus_dma_tag_t
59tcbus_get_dma_tag(int slotno) 333tc_vsbus_get_dma_tag(int slotno)
60{ 334{
61 return tcbus_dmat; 335
 336 return tc_vsbus_dmat;
 337}
 338
 339static void
 340tc_vsbus_intr(void *arg)
 341{
 342 struct tc_vsbus_softc * const sc = arg;
 343 bus_space_tag_t bst = sc->sc_bst;
 344 bus_space_handle_t bsh = sc->sc_bsh_csr;
 345 uint32_t csr;
 346
 347 sc->sc_ev.ev_count++;
 348
 349 csr = bus_space_read_4(bst, bsh, 0);
 350 if (__predict_true((csr & KA4x_TCA_CSR_TC_IRQ) == 0)) /* active low */
 351 sc->sc_intr_func(sc->sc_intr_arg);
 352
 353 /* Clear possible timeout bit which asserts TC interrupt. */
 354 csr = bus_space_read_4(bst, bsh, 0);
 355 csr &= ~KA4x_TCA_CSR_TC_TMO;
 356 bus_space_write_4(bst, bsh, 0, csr);
62} 357}
63 358
64static void 359static void
65tcbus_intr_establish(device_t dv, void *cookie, int level, 360tc_vsbus_intr_establish(device_t dv, void *cookie, int level,
66 int (*func)(void *), void *arg) 361 int (*func)(void *), void *arg)
67{ 362{
68 struct tcbus_softc * const sc = cookie; 363 struct tc_vsbus_softc * const sc = cookie;
 364
 365 sc->sc_intr_func = func;
 366 sc->sc_intr_arg = arg;
69 367
70 scb_vecalloc(0x51, (void (*)(void *)) func, arg, SCB_ISTACK, 368 scb_vecalloc(sc->sc_cvec, tc_vsbus_intr, sc, SCB_ISTACK, &sc->sc_ev);
71 &sc->sc_ev); 
72} 369}
73 370
74static void 371static void
75tcbus_intr_disestablish(device_t dv, void *cookie) 372tc_vsbus_intr_disestablish(device_t dv, void *cookie)
76{ 373{
 374
 375 /* Do nothing. */
77} 376}
78 377
79static const struct evcnt * 378static const struct evcnt *
80tcbus_intr_evcnt(device_t dv, void *cookie) 379tc_vsbus_intr_evcnt(device_t dv, void *cookie)
81{ 380{
82 return NULL; 381 struct tc_vsbus_softc * const sc = device_private(dv);
 382
 383 return &sc->sc_ev;
83} 384}
84 385
85int 386static int
86tcbus_match(device_t parent, cfdata_t cfdata, void *aux) 387vax_tc_bus_space_map(void *t, bus_addr_t pa, bus_size_t size, int cacheable,
 388 bus_space_handle_t *bshp, int f2)
87{ 389{
 390
 391 /* bus_space is pre-mapped, so "pa" is a virtual address already. */
 392 *bshp = pa;
88 return 0; 393 return 0;
89} 394}
90 395
91#define KA4x_TURBO 0x30000000 396static int
92#define KA4x_TURBOMAPS 0x35800000 397vax_tc_bus_space_subregion(void *t, bus_space_handle_t h, bus_size_t o,
93#define KA4x_TURBOCSR 0x36800000 398 bus_size_t s, bus_space_handle_t *hp)
94 
95void 
96tcbus_attach(device_t parent, device_t self, void *aux) 
97{ 399{
98 struct vsbus_attach_args * const va = aux; 
99 struct tcbus_softc * const sc = device_private(self); 
100 struct tcbus_attach_args tba; 
101 struct pte *pte; 
102 const size_t nentries = 32768; 
103 int error; 
104 int i; 
105 400
106 error = bus_space_map(va->va_memt, KA4x_TURBO, 0x10000, 401 *hp = h + o;
107 BUS_SPACE_MAP_LINEAR, &sc->sc_memh); 402 return 0;
108 if (error) { 403}
109 aprint_error(": failed to map TC slot 0: %d\n", error); 
110 return; 
111 } 
112 404
113 sc->sc_slots[0].tcs_addr = sc->sc_memh; 405static void
114 sc->sc_slots[0].tcs_cookie = sc; 406vax_tc_bus_space_unmap(void *t, bus_space_handle_t h, bus_size_t size, int f)
 407{
115 408
116 tba.tba_speed = TC_SPEED_12_5_MHZ; 409 /* Do nothing. */
117 tba.tba_slots = sc->sc_slots; 410}
118 tba.tba_nslots = 1; 
119 tba.tba_intr_evcnt = tcbus_intr_evcnt; 
120 tba.tba_intr_establish = tcbus_intr_establish; 
121 tba.tba_intr_disestablish = tcbus_intr_disestablish; 
122 tba.tba_get_dma_tag = tcbus_get_dma_tag; 
123 
124 vax_sgmap_dmatag_init(&sc->sc_dmatag, sc, nentries); 
125 pte = (struct pte *) vax_map_physmem(KA4x_TURBOMAPS, 
126 nentries * sizeof(pte[0])); 
127 411
128 for (i = nentries; i > 0; ) 412static int
129 ((uint32_t *) pte)[--i] = 0; 413vax_tc_bus_space_alloc(void *t, bus_addr_t rs, bus_addr_t re, bus_size_t s,
 414 bus_size_t a, bus_size_t b, int f, bus_addr_t *ap, bus_space_handle_t *hp)
 415{
130 416
131 sc->sc_dmatag._sgmap = &sc->sc_sgmap; 417 panic("vax_tc_bus_space_alloc not implemented");
132 /* 418}
133 * Initialize the SGMAP. 
134 */ 
135 vax_sgmap_init(&sc->sc_dmatag, &sc->sc_sgmap, "tc_sgmap", 
136 sc->sc_dmatag._wbase, sc->sc_dmatag._wsize, pte, 0); 
137 419
138 aprint_normal("\n"); 420static void
 421vax_tc_bus_space_free(void *t, bus_space_handle_t h, bus_size_t s)
 422{
139 423
140 aprint_verbose_dev(self, "32K entry DMA SGMAP at PA 0x%x (VA %p)\n", 424 panic("vax_tc_bus_space_free not implemented");
141 KA4x_TURBOMAPS, pte); 425}
142 426
143 tcbus_dmat = &sc->sc_dmatag; 427static paddr_t
 428vax_tc_bus_space_mmap(void *v, bus_addr_t addr, off_t off, int prot, int flags)
 429{
 430 bus_addr_t rv;
144 431
145 /* XXX: why not config_found(9)?? */ 432 rv = addr + off;
146 tcattach(parent, self, &tba); 433 return btop(rv);
147} 434}

cvs diff -r1.54 -r1.55 src/sys/dev/tc/tc.c (expand / switch to unified diff)

--- src/sys/dev/tc/tc.c 2016/12/12 17:03:41 1.54
+++ src/sys/dev/tc/tc.c 2017/06/09 17:55:18 1.55
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tc.c,v 1.54 2016/12/12 17:03:41 flxd Exp $ */ 1/* $NetBSD: tc.c,v 1.55 2017/06/09 17:55:18 flxd Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Carnegie-Mellon University. 4 * Copyright (c) 1994, 1995 Carnegie-Mellon University.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Author: Chris G. Demetriou 7 * Author: Chris G. Demetriou
8 * 8 *
9 * Permission to use, copy, modify and distribute this software and 9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright 10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the 11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions 12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation. 13 * thereof, and that both notices appear in supporting documentation.
14 * 14 *
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * 18 *
19 * Carnegie Mellon requests users of this software to return to 19 * Carnegie Mellon requests users of this software to return to
20 * 20 *
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science 22 * School of Computer Science
23 * Carnegie Mellon University 23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890 24 * Pittsburgh PA 15213-3890
25 * 25 *
26 * any improvements or extensions that they make and grant Carnegie the 26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes. 27 * rights to redistribute these changes.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31__KERNEL_RCSID(0, "$NetBSD: tc.c,v 1.54 2016/12/12 17:03:41 flxd Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: tc.c,v 1.55 2017/06/09 17:55:18 flxd Exp $");
32 32
33#include "opt_tcverbose.h" 33#include "opt_tcverbose.h"
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/systm.h> 36#include <sys/systm.h>
37#include <sys/device.h> 37#include <sys/device.h>
38 38
39#include <machine/cpu.h> /* for badaddr */ 39#include <machine/cpu.h> /* for badaddr */
40 40
41#include <dev/tc/tcreg.h> 41#include <dev/tc/tcreg.h>
42#include <dev/tc/tcvar.h> 42#include <dev/tc/tcvar.h>
43#include <dev/tc/tcdevs.h> 43#include <dev/tc/tcdevs.h>
44 44
@@ -146,27 +146,27 @@ tcattach(device_t parent, device_t self, @@ -146,27 +146,27 @@ tcattach(device_t parent, device_t self,
146 for (i = sc->sc_nslots - 1; i >= 0; i--) { 146 for (i = sc->sc_nslots - 1; i >= 0; i--) {
147 slot = &sc->sc_slots[i]; 147 slot = &sc->sc_slots[i];
148 148
149 /* If already checked above, don't look again now. */ 149 /* If already checked above, don't look again now. */
150 if (slot->tcs_used) 150 if (slot->tcs_used)
151 continue; 151 continue;
152 152
153 /* 153 /*
154 * Make sure something is there, and find out what it is. 154 * Make sure something is there, and find out what it is.
155 */ 155 */
156 tcaddr = slot->tcs_addr; 156 tcaddr = slot->tcs_addr;
157 if (tc_badaddr(tcaddr)) 157 if (tc_badaddr(tcaddr))
158 continue; 158 continue;
159 if (tc_checkslot(tcaddr, ta.ta_modname) == 0) 159 if (tc_checkslot(tcaddr, ta.ta_modname, NULL) == 0)
160 continue; 160 continue;
161 161
162 /* 162 /*
163 * Set up the rest of the attachment information. 163 * Set up the rest of the attachment information.
164 */ 164 */
165 ta.ta_memt = tba->tba_memt; 165 ta.ta_memt = tba->tba_memt;
166 ta.ta_dmat = (*sc->sc_get_dma_tag)(i); 166 ta.ta_dmat = (*sc->sc_get_dma_tag)(i);
167 ta.ta_slot = i; 167 ta.ta_slot = i;
168 ta.ta_offset = 0; 168 ta.ta_offset = 0;
169 ta.ta_addr = tcaddr; 169 ta.ta_addr = tcaddr;
170 ta.ta_cookie = slot->tcs_cookie; 170 ta.ta_cookie = slot->tcs_cookie;
171 171
172 /* 172 /*
@@ -191,29 +191,27 @@ tcprint(void *aux, const char *pnp) @@ -191,29 +191,27 @@ tcprint(void *aux, const char *pnp)
191 char devinfo[256]; 191 char devinfo[256];
192 192
193 if (pnp) { 193 if (pnp) {
194 tc_devinfo(ta->ta_modname, devinfo, sizeof(devinfo)); 194 tc_devinfo(ta->ta_modname, devinfo, sizeof(devinfo));
195 aprint_normal("%s at %s", devinfo, pnp); 195 aprint_normal("%s at %s", devinfo, pnp);
196 } 196 }
197 aprint_normal(" slot %d offset 0x%x", ta->ta_slot, ta->ta_offset); 197 aprint_normal(" slot %d offset 0x%x", ta->ta_slot, ta->ta_offset);
198 return (UNCONF); 198 return (UNCONF);
199} 199}
200 200
201 201
202static const tc_offset_t tc_slot_romoffs[] = { 202static const tc_offset_t tc_slot_romoffs[] = {
203 TC_SLOT_ROM, 203 TC_SLOT_ROM,
204#ifndef __vax__ 
205 TC_SLOT_PROTOROM, 204 TC_SLOT_PROTOROM,
206#endif 
207}; 205};
208 206
209static int 207static int
210tc_check_romp(const struct tc_rommap *romp) 208tc_check_romp(const struct tc_rommap *romp)
211{ 209{
212 210
213 switch (romp->tcr_width.v) { 211 switch (romp->tcr_width.v) {
214 case 1: 212 case 1:
215 case 2: 213 case 2:
216 case 4: 214 case 4:
217 break; 215 break;
218 216
219 default: 217 default:
@@ -224,41 +222,45 @@ tc_check_romp(const struct tc_rommap *ro @@ -224,41 +222,45 @@ tc_check_romp(const struct tc_rommap *ro
224 return 0; 222 return 0;
225 223
226 for (size_t j = 0; j < romp->tcr_width.v; j++) { 224 for (size_t j = 0; j < romp->tcr_width.v; j++) {
227 if (romp->tcr_test[j + 0 * romp->tcr_stride.v] != 0x55 || 225 if (romp->tcr_test[j + 0 * romp->tcr_stride.v] != 0x55 ||
228 romp->tcr_test[j + 1 * romp->tcr_stride.v] != 0x00 || 226 romp->tcr_test[j + 1 * romp->tcr_stride.v] != 0x00 ||
229 romp->tcr_test[j + 2 * romp->tcr_stride.v] != 0xaa || 227 romp->tcr_test[j + 2 * romp->tcr_stride.v] != 0xaa ||
230 romp->tcr_test[j + 3 * romp->tcr_stride.v] != 0xff) 228 romp->tcr_test[j + 3 * romp->tcr_stride.v] != 0xff)
231 return 0; 229 return 0;
232 } 230 }
233 return 1; 231 return 1;
234} 232}
235 233
236int 234int
237tc_checkslot(tc_addr_t slotbase, char *namep) 235tc_checkslot(tc_addr_t slotbase, char *namep, struct tc_rommap **rompp)
238{ 236{
239 struct tc_rommap *romp; 237 struct tc_rommap *romp;
240 int i, j; 238 int i, j;
241 239
242 for (i = 0; i < __arraycount(tc_slot_romoffs); i++) { 240 for (i = 0; i < __arraycount(tc_slot_romoffs); i++) {
243 romp = (struct tc_rommap *) 241 romp = (struct tc_rommap *)
244 (slotbase + tc_slot_romoffs[i]); 242 (slotbase + tc_slot_romoffs[i]);
245 243
246 if (!tc_check_romp(romp)) 244 if (!tc_check_romp(romp))
247 continue; 245 continue;
248 246
249 for (j = 0; j < TC_ROM_LLEN; j++) 247 if (namep != NULL) {
250 namep[j] = romp->tcr_modname[j].v; 248 for (j = 0; j < TC_ROM_LLEN; j++)
251 namep[j] = '\0'; 249 namep[j] = romp->tcr_modname[j].v;
 250 namep[j] = '\0';
 251 }
 252 if (rompp != NULL)
 253 *rompp = romp;
252 return (1); 254 return (1);
253 } 255 }
254 return (0); 256 return (0);
255} 257}
256 258
257const struct evcnt * 259const struct evcnt *
258tc_intr_evcnt(device_t dev, void *cookie) 260tc_intr_evcnt(device_t dev, void *cookie)
259{ 261{
260 struct tc_softc *sc = device_lookup_private(&tc_cd, 0); 262 struct tc_softc *sc = device_lookup_private(&tc_cd, 0);
261 263
262 return ((*sc->sc_intr_evcnt)(dev, cookie)); 264 return ((*sc->sc_intr_evcnt)(dev, cookie));
263} 265}
264 266

cvs diff -r1.26 -r1.27 src/sys/dev/tc/tcvar.h (expand / switch to unified diff)

--- src/sys/dev/tc/tcvar.h 2011/06/04 01:57:34 1.26
+++ src/sys/dev/tc/tcvar.h 2017/06/09 17:55:18 1.27
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tcvar.h,v 1.26 2011/06/04 01:57:34 tsutsui Exp $ */ 1/* $NetBSD: tcvar.h,v 1.27 2017/06/09 17:55:18 flxd Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1995 Carnegie-Mellon University. 4 * Copyright (c) 1995 Carnegie-Mellon University.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Author: Chris G. Demetriou 7 * Author: Chris G. Demetriou
8 * 8 *
9 * Permission to use, copy, modify and distribute this software and 9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright 10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the 11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions 12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation. 13 * thereof, and that both notices appear in supporting documentation.
14 * 14 *
@@ -129,27 +129,27 @@ struct tc_slotdesc { @@ -129,27 +129,27 @@ struct tc_slotdesc {
129 * Description of built-in TURBOchannel devices, provided by 129 * Description of built-in TURBOchannel devices, provided by
130 * machine-dependent code to the TURBOchannel bus driver. 130 * machine-dependent code to the TURBOchannel bus driver.
131 */ 131 */
132struct tc_builtin { 132struct tc_builtin {
133 const char *tcb_modname; 133 const char *tcb_modname;
134 u_int tcb_slot; 134 u_int tcb_slot;
135 tc_offset_t tcb_offset; 135 tc_offset_t tcb_offset;
136 void *tcb_cookie; 136 void *tcb_cookie;
137}; 137};
138 138
139/* 139/*
140 * Interrupt establishment functions. 140 * Interrupt establishment functions.
141 */ 141 */
142int tc_checkslot(tc_addr_t, char *); 142int tc_checkslot(tc_addr_t, char *, struct tc_rommap **);
143void tcattach(device_t, device_t, void *); 143void tcattach(device_t, device_t, void *);
144const struct evcnt *tc_intr_evcnt(device_t, void *); 144const struct evcnt *tc_intr_evcnt(device_t, void *);
145void tc_intr_establish(device_t, void *, int, int (*)(void *), 145void tc_intr_establish(device_t, void *, int, int (*)(void *),
146 void *); 146 void *);
147void tc_intr_disestablish(device_t, void *); 147void tc_intr_disestablish(device_t, void *);
148 148
149/* 149/*
150 * Miscellaneous definitions. 150 * Miscellaneous definitions.
151 */ 151 */
152#define TC_SPEED_12_5_MHZ 0 /* 12.5MHz TC bus */ 152#define TC_SPEED_12_5_MHZ 0 /* 12.5MHz TC bus */
153#define TC_SPEED_25_MHZ 1 /* 25MHz TC bus */ 153#define TC_SPEED_25_MHZ 1 /* 25MHz TC bus */
154 154
155#endif /* __DEV_TC_TCVAR_H__ */ 155#endif /* __DEV_TC_TCVAR_H__ */