1 /* $NetBSD: intreg.c,v 1.29 2008/06/28 12:13:38 tsutsui Exp $ */ 2 3 /*- 4 * Copyright (c) 1996 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Adam Glass and Gordon W. Ross. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 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 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 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 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 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* 33 * This handles multiple attach of autovectored interrupts, 34 * and the handy software interrupt request register. 35 */ 36 37 #include <sys/cdefs.h> 38 __KERNEL_RCSID(0, "$NetBSD: intreg.c,v 1.29 2008/06/28 12:13:38 tsutsui Exp $"); 39 40 #include <sys/param.h> 41 #include <sys/systm.h> 42 #include <sys/device.h> 43 #include <sys/vmmeter.h> 44 45 #include <uvm/uvm_extern.h> 46 47 #include <m68k/asm_single.h> 48 49 #include <machine/autoconf.h> 50 #include <machine/cpu.h> 51 #include <machine/mon.h> 52 53 #include <sun3/sun3/interreg.h> 54 #include <sun3/sun3/machdep.h> 55 56 struct intreg_softc { 57 device_t sc_dev; 58 volatile uint8_t *sc_reg; 59 }; 60 61 static int intreg_match(device_t, cfdata_t, void *); 62 static void intreg_attach(device_t, device_t, void *); 63 64 CFATTACH_DECL_NEW(intreg, sizeof(struct intreg_softc), 65 intreg_match, intreg_attach, NULL, NULL); 66 67 volatile uint8_t *interrupt_reg; 68 static int intreg_attached; 69 70 /* called early (by internal_configure) */ 71 void 72 intreg_init(void) 73 { 74 vaddr_t va; 75 76 if (find_prom_map(IREG_ADDR, PMAP_OBIO, 1, &va) != 0) { 77 mon_printf("intreg_init\n"); 78 sunmon_abort(); 79 } 80 interrupt_reg = (void *)va; 81 82 /* Turn off all interrupts until clock_attach */ 83 *interrupt_reg = 0; 84 } 85 86 87 static int 88 intreg_match(device_t parent, cfdata_t cf, void *args) 89 { 90 struct confargs *ca = args; 91 92 /* This driver only supports one instance. */ 93 if (intreg_attached) 94 return 0; 95 96 /* Validate the given address. */ 97 if (ca->ca_paddr != IREG_ADDR) 98 return 0; 99 100 return 1; 101 } 102 103 104 static void 105 intreg_attach(device_t parent, device_t self, void *args) 106 { 107 struct intreg_softc *sc = device_private(self); 108 109 sc->sc_dev = self; 110 aprint_normal("\n"); 111 112 sc->sc_reg = interrupt_reg; 113 114 intreg_attached = 1; 115 } 116 117 118 #if 0 119 void 120 isr_soft_request(int level) 121 { 122 uint8_t bit; 123 124 if ((level < _IPL_SOFT_LEVEL_MIN) || (level > _IPL_SOFT_LEVEL_MAX)) 125 return; 126 127 bit = 1 << level; 128 single_inst_bset_b(*interrupt_reg, bit); 129 } 130 131 void 132 isr_soft_clear(int level) 133 { 134 uint8_t bit; 135 136 if ((level < _IPL_SOFT_LEVEL_MIN) || (level > _IPL_SOFT_LEVEL_MAX)) 137 return; 138 139 bit = 1 << level; 140 single_inst_bclr_b(*interrupt_reg, bit); 141 } 142 #endif 143