Home | History | Annotate | Line # | Download | only in mace
mace.c revision 1.11
      1  1.11  jmcneill /*	$NetBSD: mace.c,v 1.11 2007/04/14 20:57:55 jmcneill Exp $	*/
      2   1.1    sekiya 
      3   1.1    sekiya /*
      4   1.1    sekiya  * Copyright (c) 2003 Christopher Sekiya
      5   1.1    sekiya  * Copyright (c) 2002,2003 Rafal K. Boni
      6   1.1    sekiya  * Copyright (c) 2000 Soren S. Jorvang
      7   1.1    sekiya  * All rights reserved.
      8   1.1    sekiya  *
      9   1.1    sekiya  * Redistribution and use in source and binary forms, with or without
     10   1.1    sekiya  * modification, are permitted provided that the following conditions
     11   1.1    sekiya  * are met:
     12   1.1    sekiya  * 1. Redistributions of source code must retain the above copyright
     13   1.1    sekiya  *    notice, this list of conditions and the following disclaimer.
     14   1.1    sekiya  * 2. Redistributions in binary form must reproduce the above copyright
     15   1.1    sekiya  *    notice, this list of conditions and the following disclaimer in the
     16   1.1    sekiya  *    documentation and/or other materials provided with the distribution.
     17   1.1    sekiya  * 3. All advertising materials mentioning features or use of this software
     18   1.1    sekiya  *    must display the following acknowledgement:
     19   1.1    sekiya  *          This product includes software developed for the
     20   1.1    sekiya  *          NetBSD Project.  See http://www.NetBSD.org/ for
     21   1.1    sekiya  *          information about NetBSD.
     22   1.1    sekiya  * 4. The name of the author may not be used to endorse or promote products
     23   1.1    sekiya  *    derived from this software without specific prior written permission.
     24   1.1    sekiya  *
     25   1.1    sekiya  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     26   1.1    sekiya  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     27   1.1    sekiya  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     28   1.1    sekiya  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     29   1.1    sekiya  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     30   1.1    sekiya  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     31   1.1    sekiya  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     32   1.1    sekiya  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     33   1.1    sekiya  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     34   1.1    sekiya  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     35   1.1    sekiya  */
     36   1.1    sekiya 
     37   1.1    sekiya /*
     38   1.1    sekiya  * O2 MACE
     39   1.1    sekiya  *
     40   1.1    sekiya  * The MACE is weird -- although it is a 32-bit device, writes only seem to
     41   1.1    sekiya  * work properly if they are 64-bit-at-once writes (at least, out in ISA
     42   1.1    sekiya  * space and probably MEC space -- the PCI stuff seems to be okay with _4).
     43   1.1    sekiya  * Therefore, the _8* routines are used even though the top 32 bits are
     44   1.1    sekiya  * thrown away.
     45   1.1    sekiya  */
     46   1.1    sekiya 
     47   1.1    sekiya #include <sys/cdefs.h>
     48  1.11  jmcneill __KERNEL_RCSID(0, "$NetBSD: mace.c,v 1.11 2007/04/14 20:57:55 jmcneill Exp $");
     49   1.1    sekiya 
     50   1.1    sekiya #include <sys/param.h>
     51   1.1    sekiya #include <sys/systm.h>
     52   1.1    sekiya #include <sys/device.h>
     53   1.1    sekiya #include <sys/callout.h>
     54   1.1    sekiya #include <sys/mbuf.h>
     55   1.1    sekiya #include <sys/malloc.h>
     56   1.1    sekiya #include <sys/kernel.h>
     57   1.1    sekiya #include <sys/socket.h>
     58   1.1    sekiya #include <sys/ioctl.h>
     59   1.1    sekiya #include <sys/errno.h>
     60   1.1    sekiya #include <sys/syslog.h>
     61   1.1    sekiya 
     62   1.1    sekiya #include <uvm/uvm_extern.h>
     63   1.1    sekiya 
     64   1.1    sekiya #define	_SGIMIPS_BUS_DMA_PRIVATE
     65   1.1    sekiya #include <machine/bus.h>
     66   1.1    sekiya #include <machine/cpu.h>
     67   1.1    sekiya #include <machine/locore.h>
     68   1.1    sekiya #include <machine/autoconf.h>
     69   1.1    sekiya #include <machine/machtype.h>
     70   1.1    sekiya 
     71   1.1    sekiya #include <sgimips/mace/macevar.h>
     72   1.1    sekiya #include <sgimips/mace/macereg.h>
     73   1.1    sekiya #include <sgimips/dev/crimevar.h>
     74   1.1    sekiya #include <sgimips/dev/crimereg.h>
     75   1.1    sekiya 
     76   1.1    sekiya #include "locators.h"
     77   1.1    sekiya 
     78   1.1    sekiya #define MACE_NINTR 32 /* actually only 8, but interrupts are shared */
     79   1.1    sekiya 
     80   1.1    sekiya struct {
     81   1.1    sekiya 	unsigned int	irq;
     82   1.1    sekiya 	unsigned int	intrmask;
     83   1.1    sekiya 	int	(*func)(void *);
     84   1.1    sekiya 	void	*arg;
     85   1.4   tsutsui 	struct evcnt evcnt;
     86   1.4   tsutsui 	char	evname[32];
     87   1.1    sekiya } maceintrtab[MACE_NINTR];
     88   1.1    sekiya 
     89   1.1    sekiya struct mace_softc {
     90   1.1    sekiya 	struct device sc_dev;
     91   1.1    sekiya 
     92   1.1    sekiya 	bus_space_tag_t iot;
     93   1.1    sekiya 	bus_space_handle_t ioh;
     94   1.1    sekiya 	bus_dma_tag_t dmat; /* 32KB ring buffers, 4KB segments, for ISA  */
     95   1.1    sekiya 	int nsegs;
     96   1.1    sekiya 	bus_dma_segment_t seg;
     97   1.1    sekiya 	bus_dmamap_t map;
     98   1.1    sekiya 
     99   1.1    sekiya 	void *isa_ringbuffer;
    100   1.1    sekiya };
    101   1.1    sekiya 
    102   1.1    sekiya static int	mace_match(struct device *, struct cfdata *, void *);
    103   1.1    sekiya static void	mace_attach(struct device *, struct device *, void *);
    104   1.1    sekiya static int	mace_print(void *, const char *);
    105   1.6  drochner static int	mace_search(struct device *, struct cfdata *,
    106   1.7  drochner 			    const int *, void *);
    107   1.1    sekiya 
    108   1.1    sekiya CFATTACH_DECL(mace, sizeof(struct mace_softc),
    109   1.1    sekiya     mace_match, mace_attach, NULL, NULL);
    110   1.1    sekiya 
    111   1.1    sekiya #if defined(BLINK)
    112   1.1    sekiya static struct callout mace_blink_ch = CALLOUT_INITIALIZER;
    113   1.1    sekiya static void	mace_blink(void *);
    114   1.1    sekiya #endif
    115   1.1    sekiya 
    116   1.1    sekiya static int
    117   1.1    sekiya mace_match(struct device *parent, struct cfdata *match, void *aux)
    118   1.1    sekiya {
    119   1.1    sekiya 
    120   1.1    sekiya 	/*
    121   1.1    sekiya 	 * The MACE is in the O2.
    122   1.1    sekiya 	 */
    123   1.1    sekiya 	if (mach_type == MACH_SGI_IP32)
    124   1.1    sekiya 		return (1);
    125   1.1    sekiya 
    126   1.1    sekiya 	return (0);
    127   1.1    sekiya }
    128   1.1    sekiya 
    129   1.1    sekiya static void
    130   1.1    sekiya mace_attach(struct device *parent, struct device *self, void *aux)
    131   1.1    sekiya {
    132   1.1    sekiya 	struct mace_softc *sc = (struct mace_softc *)self;
    133   1.1    sekiya 	struct mainbus_attach_args *ma = aux;
    134   1.1    sekiya 	u_int32_t scratch;
    135   1.1    sekiya 
    136   1.1    sekiya 	sc->iot = SGIMIPS_BUS_SPACE_MACE;
    137   1.1    sekiya 	sc->dmat = &sgimips_default_bus_dma_tag;
    138   1.1    sekiya 
    139   1.1    sekiya 	if (bus_space_map(sc->iot, ma->ma_addr, 0,
    140   1.1    sekiya 	    BUS_SPACE_MAP_LINEAR, &sc->ioh))
    141   1.1    sekiya 		panic("mace_attach: could not allocate memory\n");
    142   1.1    sekiya 
    143   1.1    sekiya #if 0
    144   1.1    sekiya 	/*
    145   1.1    sekiya 	 * There's something deeply wrong with the alloc() routine -- it
    146   1.1    sekiya 	 * returns a pointer to memory that is used by the kernel i/o
    147   1.1    sekiya 	 * buffers.  Disable for now.
    148   1.1    sekiya 	 */
    149   1.1    sekiya 
    150   1.1    sekiya 	if ((bus_dmamem_alloc(sc->dmat, 32768, PAGE_SIZE, 32768,
    151   1.1    sekiya 	    &sc->seg, 1, &sc->nsegs, BUS_DMA_NOWAIT)) != 0) {
    152   1.1    sekiya 		printf(": unable to allocate DMA memory\n");
    153   1.1    sekiya 		return;
    154   1.1    sekiya 	}
    155   1.1    sekiya 
    156   1.1    sekiya 	if ((bus_dmamem_map(sc->dmat, &sc->seg, sc->nsegs, 32768,
    157   1.9  christos 	    (void **)&sc->isa_ringbuffer, BUS_DMA_NOWAIT | BUS_DMA_COHERENT))
    158   1.1    sekiya 	    != 0) {
    159   1.1    sekiya 		printf(": unable to map control data\n");
    160   1.1    sekiya 		return;
    161   1.1    sekiya 	}
    162   1.1    sekiya 
    163   1.1    sekiya 	if ((bus_dmamap_create(sc->dmat, 32768, 1, 32768, 0,
    164   1.1    sekiya 	    BUS_DMA_NOWAIT, &sc->map)) != 0) {
    165   1.1    sekiya 		printf(": unable to create DMA map for control data\n");
    166   1.1    sekiya 		return;
    167   1.1    sekiya 	}
    168   1.1    sekiya 
    169   1.1    sekiya 	if ((scratch = bus_dmamap_load(sc->dmat, sc->map, sc->isa_ringbuffer,
    170   1.1    sekiya 	    32768, NULL, BUS_DMA_NOWAIT)) != 0) {
    171   1.1    sekiya 		printf(": unable to load DMA map for control data %i\n",
    172   1.1    sekiya 		    scratch);
    173   1.1    sekiya 	}
    174   1.1    sekiya 
    175   1.1    sekiya 	memset(sc->isa_ringbuffer, 0, 32768);
    176   1.1    sekiya 
    177   1.1    sekiya 	bus_space_write_8(sc->iot, sc->ioh, MACE_ISA_RINGBASE,
    178   1.1    sekiya 	    MIPS_KSEG1_TO_PHYS(sc->isa_ringbuffer) & 0xffff8000);
    179   1.1    sekiya 
    180   1.1    sekiya 	aprint_normal(" isa ringbuffer 0x%x size 32k",
    181   1.1    sekiya 	    MIPS_KSEG1_TO_PHYS((unsigned long)sc->isa_ringbuffer));
    182   1.1    sekiya #endif
    183   1.1    sekiya 
    184   1.1    sekiya 	aprint_normal("\n");
    185   1.1    sekiya 
    186   1.1    sekiya 	aprint_debug("%s: isa sts %llx\n", self->dv_xname,
    187   1.1    sekiya 	    bus_space_read_8(sc->iot, sc->ioh, MACE_ISA_INT_STATUS));
    188   1.1    sekiya 	aprint_debug("%s: isa msk %llx\n", self->dv_xname,
    189   1.1    sekiya 	    bus_space_read_8(sc->iot, sc->ioh, MACE_ISA_INT_MASK));
    190   1.1    sekiya 
    191   1.1    sekiya 	/*
    192  1.10  jmcneill 	 * Turn on most ISA interrupts.  These are actually masked and
    193   1.1    sekiya 	 * registered via the CRIME, as the MACE ISA interrupt mask is
    194   1.1    sekiya 	 * really whacky and nigh on impossible to map to a sane autoconfig
    195  1.11  jmcneill 	 * scheme.  We do, however, turn off the count/compare timer and RTC
    196  1.10  jmcneill 	 * interrupts as they are unused and conflict with the PS/2
    197  1.10  jmcneill 	 * keyboard and mouse interrupts.
    198   1.1    sekiya 	 */
    199   1.1    sekiya 
    200  1.11  jmcneill 	bus_space_write_8(sc->iot, sc->ioh, MACE_ISA_INT_MASK, 0xffff0aff);
    201   1.1    sekiya 	bus_space_write_8(sc->iot, sc->ioh, MACE_ISA_INT_STATUS, 0);
    202   1.1    sekiya 
    203   1.1    sekiya 	/* set up LED for solid green or blink, if that's your fancy */
    204   1.1    sekiya 	scratch = bus_space_read_8(sc->iot, sc->ioh, MACE_ISA_FLASH_NIC_REG);
    205   1.1    sekiya 	scratch |= MACE_ISA_LED_RED;
    206   1.1    sekiya 	scratch &= ~(MACE_ISA_LED_GREEN);
    207   1.1    sekiya 	bus_space_write_8(sc->iot, sc->ioh, MACE_ISA_FLASH_NIC_REG, scratch);
    208   1.1    sekiya 
    209   1.1    sekiya #if defined(BLINK)
    210   1.1    sekiya 	mace_blink(sc);
    211   1.1    sekiya #endif
    212   1.1    sekiya 
    213   1.1    sekiya 	/* Initialize the maceintr elements to sane values */
    214   1.1    sekiya 	for (scratch = 0; scratch < MACE_NINTR; scratch++) {
    215   1.1    sekiya 		maceintrtab[scratch].func = NULL;
    216   1.1    sekiya 		maceintrtab[scratch].irq = 0;
    217   1.1    sekiya 	}
    218   1.1    sekiya 
    219   1.6  drochner 	config_search_ia(mace_search, self, "mace", NULL);
    220   1.1    sekiya }
    221   1.1    sekiya 
    222   1.1    sekiya 
    223   1.1    sekiya static int
    224   1.1    sekiya mace_print(void *aux, const char *pnp)
    225   1.1    sekiya {
    226   1.1    sekiya 	struct mace_attach_args *maa = aux;
    227   1.1    sekiya 
    228   1.1    sekiya 	if (pnp != 0)
    229   1.1    sekiya 		return QUIET;
    230   1.1    sekiya 
    231   1.1    sekiya 	if (maa->maa_offset != MACECF_OFFSET_DEFAULT)
    232   1.1    sekiya 		aprint_normal(" offset 0x%lx", maa->maa_offset);
    233   1.1    sekiya 	if (maa->maa_intr != MACECF_INTR_DEFAULT)
    234   1.1    sekiya 		aprint_normal(" intr %d", maa->maa_intr);
    235   1.1    sekiya 	if (maa->maa_offset != MACECF_INTRMASK_DEFAULT)
    236   1.1    sekiya 		aprint_normal(" intrmask 0x%x", maa->maa_intrmask);
    237   1.1    sekiya 
    238   1.1    sekiya 	return UNCONF;
    239   1.1    sekiya }
    240   1.1    sekiya 
    241   1.1    sekiya static int
    242   1.6  drochner mace_search(struct device *parent, struct cfdata *cf,
    243   1.7  drochner 	    const int *ldesc, void *aux)
    244   1.1    sekiya {
    245   1.1    sekiya 	struct mace_softc *sc = (struct mace_softc *)parent;
    246   1.1    sekiya 	struct mace_attach_args maa;
    247   1.1    sekiya 	int tryagain;
    248   1.1    sekiya 
    249   1.1    sekiya 	do {
    250   1.1    sekiya 		maa.maa_offset = cf->cf_loc[MACECF_OFFSET];
    251   1.1    sekiya 		maa.maa_intr = cf->cf_loc[MACECF_INTR];
    252   1.1    sekiya 		maa.maa_intrmask = cf->cf_loc[MACECF_INTRMASK];
    253   1.1    sekiya 		maa.maa_st = SGIMIPS_BUS_SPACE_MACE;
    254   1.1    sekiya 		maa.maa_sh = sc->ioh;	/* XXX */
    255   1.1    sekiya 		maa.maa_dmat = &sgimips_default_bus_dma_tag;
    256   1.1    sekiya 		maa.isa_ringbuffer = sc->isa_ringbuffer;
    257   1.1    sekiya 
    258   1.1    sekiya 		tryagain = 0;
    259   1.1    sekiya 		if (config_match(parent, cf, &maa) > 0) {
    260   1.1    sekiya 			config_attach(parent, cf, &maa, mace_print);
    261   1.1    sekiya 			tryagain = (cf->cf_fstate == FSTATE_STAR);
    262   1.1    sekiya 		}
    263   1.1    sekiya 
    264   1.1    sekiya 	} while (tryagain);
    265   1.1    sekiya 
    266   1.1    sekiya 	return 0;
    267   1.1    sekiya }
    268   1.1    sekiya 
    269   1.1    sekiya void *
    270   1.1    sekiya mace_intr_establish(int intr, int level, int (*func)(void *), void *arg)
    271   1.1    sekiya {
    272   1.1    sekiya 	int i;
    273   1.1    sekiya 
    274   1.5    sekiya 	if (intr < 0 || intr >= 16)
    275   1.1    sekiya 		panic("invalid interrupt number");
    276   1.1    sekiya 
    277   1.1    sekiya 	for (i = 0; i < MACE_NINTR; i++)
    278   1.2   tsutsui 		if (maceintrtab[i].func == NULL) {
    279   1.2   tsutsui 		        maceintrtab[i].func = func;
    280   1.2   tsutsui 		        maceintrtab[i].arg = arg;
    281   1.2   tsutsui 			maceintrtab[i].irq = (1 << intr);
    282   1.2   tsutsui 			maceintrtab[i].intrmask = level;
    283   1.4   tsutsui 			snprintf(maceintrtab[i].evname,
    284   1.4   tsutsui 			    sizeof(maceintrtab[i].evname),
    285   1.4   tsutsui 			    "intr %d level 0x%x", intr, level);
    286   1.4   tsutsui 			evcnt_attach_dynamic(&maceintrtab[i].evcnt,
    287   1.4   tsutsui 			    EVCNT_TYPE_INTR, NULL,
    288   1.4   tsutsui 			    "mace", maceintrtab[i].evname);
    289   1.1    sekiya 			break;
    290   1.1    sekiya 		}
    291   1.1    sekiya 
    292   1.1    sekiya 	crime_intr_mask(intr);
    293   1.8   tsutsui 	aprint_debug("mace: established interrupt %d (level %x)\n",
    294   1.1    sekiya 	    intr, level);
    295   1.2   tsutsui 	return (void *)&maceintrtab[i];
    296   1.1    sekiya }
    297   1.1    sekiya 
    298   1.1    sekiya void
    299   1.5    sekiya mace_intr_disestablish(void *cookie)
    300   1.5    sekiya {
    301   1.5    sekiya 	int intr = -1, level = 0, irq = 0, i;
    302   1.5    sekiya 
    303   1.5    sekiya 	for (i = 0; i < MACE_NINTR; i++)
    304   1.5    sekiya 		if (&maceintrtab[i] == cookie) {
    305   1.5    sekiya 			evcnt_detach(&maceintrtab[i].evcnt);
    306   1.5    sekiya 			for (intr = 0;
    307   1.5    sekiya 			    maceintrtab[i].irq == (1 << intr); intr ++);
    308   1.5    sekiya 			level = maceintrtab[i].intrmask;
    309   1.5    sekiya 			irq = maceintrtab[i].irq;
    310   1.5    sekiya 
    311   1.5    sekiya 			maceintrtab[i].irq = 0;
    312   1.5    sekiya 			maceintrtab[i].intrmask = 0;
    313   1.5    sekiya 		        maceintrtab[i].func = NULL;
    314   1.5    sekiya 		        maceintrtab[i].arg = NULL;
    315   1.5    sekiya 			bzero(&maceintrtab[i].evcnt, sizeof (struct evcnt));
    316   1.5    sekiya 			bzero(&maceintrtab[i].evname,
    317   1.5    sekiya 			    sizeof (maceintrtab[i].evname));
    318   1.5    sekiya 			break;
    319   1.5    sekiya 		}
    320   1.5    sekiya 	if (intr == -1)
    321   1.5    sekiya 		panic("mace: lost maceintrtab");
    322   1.5    sekiya 
    323   1.5    sekiya 	/* do not do a unmask, when irq is being shared. */
    324   1.5    sekiya 	for (i = 0; i < MACE_NINTR; i++)
    325   1.5    sekiya 		if (&maceintrtab[i].func != NULL && maceintrtab[i].irq == irq)
    326   1.5    sekiya 			break;
    327   1.5    sekiya 	if (i == MACE_NINTR)
    328   1.5    sekiya 		crime_intr_unmask(intr);
    329   1.8   tsutsui 	aprint_debug("mace: disestablished interrupt %d (level %x)\n",
    330   1.5    sekiya 	    intr, level);
    331   1.5    sekiya }
    332   1.5    sekiya 
    333   1.5    sekiya void
    334   1.1    sekiya mace_intr(int irqs)
    335   1.1    sekiya {
    336   1.1    sekiya 	u_int64_t isa_irq, isa_mask;
    337   1.1    sekiya 	int i;
    338   1.1    sekiya 
    339   1.1    sekiya 	/* irq 4 is the ISA cascade interrupt.  Must handle with care. */
    340   1.1    sekiya 	if (irqs & (1 << 4)) {
    341   1.1    sekiya 		isa_mask = mips3_ld((u_int64_t *)MIPS_PHYS_TO_KSEG1(MACE_BASE
    342   1.1    sekiya 		    + MACE_ISA_INT_MASK));
    343   1.1    sekiya 		isa_irq = mips3_ld((u_int64_t *)MIPS_PHYS_TO_KSEG1(MACE_BASE
    344   1.1    sekiya 		    + MACE_ISA_INT_STATUS));
    345   1.1    sekiya 		for (i = 0; i < MACE_NINTR; i++) {
    346   1.1    sekiya 			if ((maceintrtab[i].irq == (1 << 4)) &&
    347   1.1    sekiya 			    (isa_irq & maceintrtab[i].intrmask)) {
    348   1.1    sekiya 		  		(maceintrtab[i].func)(maceintrtab[i].arg);
    349   1.4   tsutsui 				maceintrtab[i].evcnt.ev_count++;
    350   1.1    sekiya 	        	}
    351   1.1    sekiya 		}
    352   1.1    sekiya #if 0
    353   1.1    sekiya 		mips3_sd((u_int64_t *)MIPS_PHYS_TO_KSEG1(MACE_BASE
    354   1.1    sekiya 		    + MACE_ISA_INT_STATUS), isa_mask);
    355   1.1    sekiya #endif
    356   1.1    sekiya 		irqs &= ~(1 << 4);
    357   1.1    sekiya 	}
    358   1.1    sekiya 
    359   1.1    sekiya 	for (i = 0; i < MACE_NINTR; i++)
    360   1.4   tsutsui 		if ((irqs & maceintrtab[i].irq)) {
    361   1.1    sekiya 		  	(maceintrtab[i].func)(maceintrtab[i].arg);
    362   1.4   tsutsui 			maceintrtab[i].evcnt.ev_count++;
    363   1.4   tsutsui 		}
    364   1.1    sekiya }
    365   1.1    sekiya 
    366   1.1    sekiya #if defined(BLINK)
    367   1.1    sekiya static void
    368   1.1    sekiya mace_blink(void *self)
    369   1.1    sekiya {
    370   1.1    sekiya 	struct mace_softc *sc = (struct mace_softc *) self;
    371   1.1    sekiya 	register int s;
    372   1.1    sekiya 	int value;
    373   1.1    sekiya 
    374   1.1    sekiya 	s = splhigh();
    375   1.1    sekiya 	value = bus_space_read_8(sc->iot, sc->ioh, MACE_ISA_FLASH_NIC_REG);
    376   1.1    sekiya 	value ^= MACE_ISA_LED_GREEN;
    377   1.1    sekiya 	bus_space_write_8(sc->iot, sc->ioh, MACE_ISA_FLASH_NIC_REG, value);
    378   1.1    sekiya 	splx(s);
    379   1.1    sekiya 	/*
    380   1.1    sekiya 	 * Blink rate is:
    381   1.1    sekiya 	 *      full cycle every second if completely idle (loadav = 0)
    382   1.1    sekiya 	 *      full cycle every 2 seconds if loadav = 1
    383   1.1    sekiya 	 *      full cycle every 3 seconds if loadav = 2
    384   1.1    sekiya 	 * etc.
    385   1.1    sekiya 	 */
    386   1.1    sekiya 	s = (((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 1));
    387   1.1    sekiya 	callout_reset(&mace_blink_ch, s, mace_blink, sc);
    388   1.1    sekiya 
    389   1.1    sekiya }
    390   1.1    sekiya #endif
    391