Home | History | Annotate | Line # | Download | only in booke
booke_machdep.c revision 1.2
      1  1.2  matt /*-
      2  1.2  matt  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
      3  1.2  matt  * All rights reserved.
      4  1.2  matt  *
      5  1.2  matt  * This code is derived from software contributed to The NetBSD Foundation
      6  1.2  matt  * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects
      7  1.2  matt  * Agency and which was developed by Matt Thomas of 3am Software Foundry.
      8  1.2  matt  *
      9  1.2  matt  * This material is based upon work supported by the Defense Advanced Research
     10  1.2  matt  * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under
     11  1.2  matt  * Contract No. N66001-09-C-2073.
     12  1.2  matt  * Approved for Public Release, Distribution Unlimited
     13  1.2  matt  *
     14  1.2  matt  * Redistribution and use in source and binary forms, with or without
     15  1.2  matt  * modification, are permitted provided that the following conditions
     16  1.2  matt  * are met:
     17  1.2  matt  * 1. Redistributions of source code must retain the above copyright
     18  1.2  matt  *    notice, this list of conditions and the following disclaimer.
     19  1.2  matt  * 2. Redistributions in binary form must reproduce the above copyright
     20  1.2  matt  *    notice, this list of conditions and the following disclaimer in the
     21  1.2  matt  *    documentation and/or other materials provided with the distribution.
     22  1.2  matt  *
     23  1.2  matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     24  1.2  matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     25  1.2  matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     26  1.2  matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     27  1.2  matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28  1.2  matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29  1.2  matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     30  1.2  matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     31  1.2  matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     32  1.2  matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     33  1.2  matt  * POSSIBILITY OF SUCH DAMAGE.
     34  1.2  matt  */
     35  1.2  matt 
     36  1.2  matt #define	__INTR_PRIVATE
     37  1.2  matt #define	_POWERPC_BUS_DMA_PRIVATE
     38  1.2  matt 
     39  1.2  matt #include <sys/cdefs.h>
     40  1.2  matt 
     41  1.2  matt #include <sys/param.h>
     42  1.2  matt #include <sys/cpu.h>
     43  1.2  matt #include <sys/device.h>
     44  1.2  matt #include <sys/intr.h>
     45  1.2  matt #include <sys/mount.h>
     46  1.2  matt #include <sys/msgbuf.h>
     47  1.2  matt #include <sys/kernel.h>
     48  1.2  matt #include <sys/reboot.h>
     49  1.2  matt #include <sys/bus.h>
     50  1.2  matt 
     51  1.2  matt #include <uvm/uvm_extern.h>
     52  1.2  matt 
     53  1.2  matt #include <powerpc/altivec.h>
     54  1.2  matt 
     55  1.2  matt /*
     56  1.2  matt  * Global variables used here and there
     57  1.2  matt  */
     58  1.2  matt paddr_t msgbuf_paddr;
     59  1.2  matt psize_t pmemsize;
     60  1.2  matt struct vm_map *phys_map;
     61  1.2  matt 
     62  1.2  matt static bus_addr_t booke_dma_phys_to_bus_mem(bus_dma_tag_t, bus_addr_t);
     63  1.2  matt static bus_addr_t booke_dma_bus_mem_to_phys(bus_dma_tag_t, bus_addr_t);
     64  1.2  matt 
     65  1.2  matt 
     66  1.2  matt struct powerpc_bus_dma_tag booke_bus_dma_tag = {
     67  1.2  matt 	._dmamap_create = _bus_dmamap_create,
     68  1.2  matt 	._dmamap_destroy = _bus_dmamap_destroy,
     69  1.2  matt 	._dmamap_load = _bus_dmamap_load,
     70  1.2  matt 	._dmamap_load_mbuf = _bus_dmamap_load_mbuf,
     71  1.2  matt 	._dmamap_load_uio = _bus_dmamap_load_uio,
     72  1.2  matt 	._dmamap_load_raw = _bus_dmamap_load_raw,
     73  1.2  matt 	._dmamap_unload = _bus_dmamap_unload,
     74  1.2  matt 	._dmamap_sync = _bus_dmamap_sync,
     75  1.2  matt 	._dmamem_alloc = _bus_dmamem_alloc,
     76  1.2  matt 	._dmamem_free = _bus_dmamem_free,
     77  1.2  matt 	._dmamem_map = _bus_dmamem_map,
     78  1.2  matt 	._dmamem_unmap = _bus_dmamem_unmap,
     79  1.2  matt 	._dmamem_mmap = _bus_dmamem_mmap,
     80  1.2  matt 	._dma_phys_to_bus_mem = booke_dma_phys_to_bus_mem,
     81  1.2  matt 	._dma_bus_mem_to_phys = booke_dma_bus_mem_to_phys,
     82  1.2  matt };
     83  1.2  matt 
     84  1.2  matt static bus_addr_t
     85  1.2  matt booke_dma_phys_to_bus_mem(bus_dma_tag_t t, bus_addr_t a)
     86  1.2  matt {
     87  1.2  matt 	return a;
     88  1.2  matt }
     89  1.2  matt 
     90  1.2  matt static bus_addr_t
     91  1.2  matt booke_dma_bus_mem_to_phys(bus_dma_tag_t t, bus_addr_t a)
     92  1.2  matt {
     93  1.2  matt 	return a;
     94  1.2  matt }
     95  1.2  matt 
     96  1.2  matt static int
     97  1.2  matt null_splraise(int ipl)
     98  1.2  matt {
     99  1.2  matt 	int cpl = curcpu()->ci_cpl;
    100  1.2  matt 	curcpu()->ci_cpl = ipl;
    101  1.2  matt 	return cpl;
    102  1.2  matt }
    103  1.2  matt 
    104  1.2  matt static void
    105  1.2  matt null_splx(int ipl)
    106  1.2  matt {
    107  1.2  matt 	curcpu()->ci_cpl = ipl;
    108  1.2  matt }
    109  1.2  matt 
    110  1.2  matt static const struct intrsw null_intrsw = {
    111  1.2  matt 	.intrsw_splraise = null_splraise,
    112  1.2  matt 	.intrsw_splx = null_splx,
    113  1.2  matt };
    114  1.2  matt 
    115  1.2  matt const struct intrsw *powerpc_intrsw = &null_intrsw;
    116  1.2  matt struct cpu_md_ops cpu_md_ops;
    117  1.2  matt extern struct cpu_info cpu_info[1];
    118  1.2  matt 
    119  1.2  matt #if 0
    120  1.2  matt pt_entry_t ptp0[NPTEPG] = {
    121  1.2  matt 	[(0x20000 & SEGOFSET) >> PGSHIFT] = 0x00020000|PTE_xR|PTE_xX|PTE_M,
    122  1.2  matt };
    123  1.2  matt 
    124  1.2  matt struct pmap_segtab pmap_kern_segtab = {
    125  1.2  matt 	.seg_tab[0x20000 >> SEGSHIFT] = ptp0,
    126  1.2  matt };
    127  1.2  matt #endif
    128  1.2  matt 
    129  1.2  matt struct cpu_softc cpu_softc[1] = {
    130  1.2  matt 	[0] = {
    131  1.2  matt 		.cpu_ci = cpu_info,
    132  1.2  matt 	},
    133  1.2  matt };
    134  1.2  matt struct cpu_info cpu_info[1] = {
    135  1.2  matt 	[0] = {
    136  1.2  matt 		.ci_curlwp = &lwp0,
    137  1.2  matt 		.ci_tlb_info = &pmap_tlb0_info,
    138  1.2  matt 		.ci_softc = cpu_softc,
    139  1.2  matt 		.ci_cpl = IPL_HIGH,
    140  1.2  matt 		.ci_fpulwp = &lwp0,
    141  1.2  matt 		.ci_veclwp = &lwp0,
    142  1.2  matt #if 0
    143  1.2  matt 		.ci_pmap_kern_segtab = &pmap_kern_segtab,
    144  1.2  matt #endif
    145  1.2  matt 	},
    146  1.2  matt };
    147  1.2  matt 
    148  1.2  matt /*
    149  1.2  matt  * This should probably be in autoconf!				XXX
    150  1.2  matt  */
    151  1.2  matt char cpu_model[80];
    152  1.2  matt char machine[] = MACHINE;		/* from <machine/param.h> */
    153  1.2  matt char machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
    154  1.2  matt 
    155  1.2  matt char bootpath[256];
    156  1.2  matt 
    157  1.2  matt #if NKSYMS || defined(DDB) || defined(MODULAR)
    158  1.2  matt void *startsym, *endsym;
    159  1.2  matt #endif
    160  1.2  matt 
    161  1.2  matt int fake_mapiodev = 1;
    162  1.2  matt 
    163  1.2  matt void lcsplx(int);
    164  1.2  matt 
    165  1.2  matt void
    166  1.2  matt booke_cpu_startup(const char *model)
    167  1.2  matt {
    168  1.2  matt 	vaddr_t 	minaddr, maxaddr;
    169  1.2  matt 	char 		pbuf[9];
    170  1.2  matt 
    171  1.2  matt 	strlcpy(cpu_model, model, sizeof(cpu_model));
    172  1.2  matt 
    173  1.2  matt 	printf("%s%s", copyright, version);
    174  1.2  matt 
    175  1.2  matt 	format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
    176  1.2  matt 	printf("total memory = %s\n", pbuf);
    177  1.2  matt 
    178  1.2  matt 	minaddr = 0;
    179  1.2  matt 	/*
    180  1.2  matt 	 * Allocate a submap for physio
    181  1.2  matt 	 */
    182  1.2  matt 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    183  1.2  matt 				 VM_PHYS_SIZE, 0, false, NULL);
    184  1.2  matt 
    185  1.2  matt 	/*
    186  1.2  matt 	 * No need to allocate an mbuf cluster submap.  Mbuf clusters
    187  1.2  matt 	 * are allocated via the pool allocator, and we use direct-mapped
    188  1.2  matt 	 * pool pages.
    189  1.2  matt 	 */
    190  1.2  matt 
    191  1.2  matt 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
    192  1.2  matt 	printf("avail memory = %s\n", pbuf);
    193  1.2  matt 
    194  1.2  matt 	/*
    195  1.2  matt 	 * Set up the board properties database.
    196  1.2  matt 	 */
    197  1.2  matt 	board_info_init();
    198  1.2  matt 
    199  1.2  matt 	/*
    200  1.2  matt 	 * Now that we have VM, malloc()s are OK in bus_space.
    201  1.2  matt 	 */
    202  1.2  matt 	bus_space_mallocok();
    203  1.2  matt 	fake_mapiodev = 0;
    204  1.2  matt }
    205  1.2  matt 
    206  1.2  matt static void
    207  1.2  matt dumpsys(void)
    208  1.2  matt {
    209  1.2  matt 
    210  1.2  matt 	printf("dumpsys: TBD\n");
    211  1.2  matt }
    212  1.2  matt 
    213  1.2  matt /*
    214  1.2  matt  * Halt or reboot the machine after syncing/dumping according to howto.
    215  1.2  matt  */
    216  1.2  matt void
    217  1.2  matt cpu_reboot(int howto, char *what)
    218  1.2  matt {
    219  1.2  matt 	static int syncing;
    220  1.2  matt 	static char str[256];
    221  1.2  matt 	char *ap = str, *ap1 = ap;
    222  1.2  matt 
    223  1.2  matt 	boothowto = howto;
    224  1.2  matt 	if (!cold && !(howto & RB_NOSYNC) && !syncing) {
    225  1.2  matt 		syncing = 1;
    226  1.2  matt 		vfs_shutdown();		/* sync */
    227  1.2  matt 		resettodr();		/* set wall clock */
    228  1.2  matt 	}
    229  1.2  matt 
    230  1.2  matt 	splhigh();
    231  1.2  matt 
    232  1.2  matt 	if (!cold && (howto & RB_DUMP))
    233  1.2  matt 		dumpsys();
    234  1.2  matt 
    235  1.2  matt 	doshutdownhooks();
    236  1.2  matt 
    237  1.2  matt 	pmf_system_shutdown(boothowto);
    238  1.2  matt 
    239  1.2  matt 	if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
    240  1.2  matt 	  /* Power off here if we know how...*/
    241  1.2  matt 	}
    242  1.2  matt 
    243  1.2  matt 	if (howto & RB_HALT) {
    244  1.2  matt 		printf("halted\n\n");
    245  1.2  matt 
    246  1.2  matt 		goto reboot;	/* XXX for now... */
    247  1.2  matt 
    248  1.2  matt #ifdef DDB
    249  1.2  matt 		printf("dropping to debugger\n");
    250  1.2  matt 		while(1)
    251  1.2  matt 			Debugger();
    252  1.2  matt #endif
    253  1.2  matt 	}
    254  1.2  matt 
    255  1.2  matt 	printf("rebooting\n\n");
    256  1.2  matt 	if (what && *what) {
    257  1.2  matt 		if (strlen(what) > sizeof str - 5)
    258  1.2  matt 			printf("boot string too large, ignored\n");
    259  1.2  matt 		else {
    260  1.2  matt 			strcpy(str, what);
    261  1.2  matt 			ap1 = ap = str + strlen(str);
    262  1.2  matt 			*ap++ = ' ';
    263  1.2  matt 		}
    264  1.2  matt 	}
    265  1.2  matt 	*ap++ = '-';
    266  1.2  matt 	if (howto & RB_SINGLE)
    267  1.2  matt 		*ap++ = 's';
    268  1.2  matt 	if (howto & RB_KDB)
    269  1.2  matt 		*ap++ = 'd';
    270  1.2  matt 	*ap++ = 0;
    271  1.2  matt 	if (ap[-2] == '-')
    272  1.2  matt 		*ap1 = 0;
    273  1.2  matt 
    274  1.2  matt 	/* flush cache for msgbuf */
    275  1.2  matt 	dcache_wb(msgbuf_paddr, round_page(MSGBUFSIZE));
    276  1.2  matt 
    277  1.2  matt  reboot:
    278  1.2  matt 	__asm volatile("msync; isync");
    279  1.2  matt 	(*cpu_md_ops.md_cpu_reset)();
    280  1.2  matt 
    281  1.2  matt 	printf("%s: md_cpu_reset() failed!\n", __func__);
    282  1.2  matt #ifdef DDB
    283  1.2  matt 	for (;;)
    284  1.2  matt 		Debugger();
    285  1.2  matt #else
    286  1.2  matt 	for (;;)
    287  1.2  matt 		/* nothing */;
    288  1.2  matt #endif
    289  1.2  matt }
    290  1.2  matt void
    291  1.2  matt lcsplx(int spl)
    292  1.2  matt {
    293  1.2  matt 	splx(spl);
    294  1.2  matt }
    295  1.2  matt 
    296  1.2  matt /*
    297  1.2  matt  * mapiodev:
    298  1.2  matt  *
    299  1.2  matt  * 	Allocate vm space and mapin the I/O address. Use reserved TLB
    300  1.2  matt  * 	mapping if one is found.
    301  1.2  matt  */
    302  1.2  matt void *
    303  1.2  matt mapiodev(paddr_t pa, psize_t len)
    304  1.2  matt {
    305  1.2  matt 	const vsize_t off = pa & PAGE_MASK;
    306  1.2  matt 
    307  1.2  matt 	/*
    308  1.2  matt 	 * See if we have reserved TLB entry for the pa. This needs to be
    309  1.2  matt 	 * true for console as we can't use uvm during early bootstrap.
    310  1.2  matt 	 */
    311  1.2  matt 	void * const p = tlb_mapiodev(pa, len);
    312  1.2  matt 	if (p != NULL)
    313  1.2  matt 		return p;
    314  1.2  matt 
    315  1.2  matt 	if (fake_mapiodev)
    316  1.2  matt 		panic("mapiodev: no TLB entry reserved for %llx+%llx",
    317  1.2  matt 		    (long long)pa, (long long)len);
    318  1.2  matt 
    319  1.2  matt 	pa = trunc_page(pa);
    320  1.2  matt 	len = round_page(off + len);
    321  1.2  matt 	vaddr_t va = uvm_km_alloc(kernel_map, len, 0, UVM_KMF_VAONLY);
    322  1.2  matt 
    323  1.2  matt 	if (va == 0)
    324  1.2  matt 		return NULL;
    325  1.2  matt 
    326  1.2  matt 	for (va += len, pa += len; len > 0; len -= PAGE_SIZE) {
    327  1.2  matt 		va -= PAGE_SIZE;
    328  1.2  matt 		pa -= PAGE_SIZE;
    329  1.2  matt 		pmap_kenter_pa(va, pa, VM_PROT_READ|VM_PROT_WRITE,
    330  1.2  matt 		    PMAP_NOCACHE);
    331  1.2  matt 	}
    332  1.2  matt 	pmap_update(pmap_kernel());
    333  1.2  matt 	return (void *)(va + off);
    334  1.2  matt }
    335  1.2  matt 
    336  1.2  matt void
    337  1.2  matt unmapiodev(vaddr_t va, vsize_t len)
    338  1.2  matt {
    339  1.2  matt 	/* Nothing to do for reserved (ie. not uvm_km_alloc'd) mappings. */
    340  1.2  matt 	if (va < VM_MIN_KERNEL_ADDRESS || va > VM_MAX_KERNEL_ADDRESS) {
    341  1.2  matt 		tlb_unmapiodev(va, len);
    342  1.2  matt 		return;
    343  1.2  matt 	}
    344  1.2  matt 
    345  1.2  matt 	len = round_page((va & PAGE_MASK) + len);
    346  1.2  matt 	va = trunc_page(va);
    347  1.2  matt 
    348  1.2  matt 	pmap_kremove(va, len);
    349  1.2  matt 	uvm_km_free(kernel_map, va, len, UVM_KMF_VAONLY);
    350  1.2  matt }
    351  1.2  matt 
    352  1.2  matt void
    353  1.2  matt cpu_evcnt_attach(struct cpu_info *ci)
    354  1.2  matt {
    355  1.2  matt 	struct cpu_softc * const cpu = ci->ci_softc;
    356  1.2  matt 	const char * const xname = device_xname(ci->ci_dev);
    357  1.2  matt 
    358  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_clock, EVCNT_TYPE_INTR,
    359  1.2  matt 		NULL, xname, "clock");
    360  1.2  matt 	evcnt_attach_dynamic_nozero(&cpu->cpu_ev_late_clock, EVCNT_TYPE_INTR,
    361  1.2  matt 		NULL, xname, "late clock");
    362  1.2  matt 	evcnt_attach_dynamic_nozero(&cpu->cpu_ev_exec_trap_sync, EVCNT_TYPE_TRAP,
    363  1.2  matt 		NULL, xname, "exec pages synced (trap)");
    364  1.2  matt #ifndef __HAVE_FAST_SOFTINTS
    365  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_softclock, EVCNT_TYPE_INTR,
    366  1.2  matt 		NULL, xname, "soft clock");
    367  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_softnet, EVCNT_TYPE_INTR,
    368  1.2  matt 		NULL, xname, "soft net");
    369  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_softserial, EVCNT_TYPE_INTR,
    370  1.2  matt 		NULL, xname, "soft serial");
    371  1.2  matt #endif
    372  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_traps, EVCNT_TYPE_TRAP,
    373  1.2  matt 		NULL, xname, "traps");
    374  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_kdsi, EVCNT_TYPE_TRAP,
    375  1.2  matt 		&ci->ci_ev_traps, xname, "kernel DSI traps");
    376  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_udsi, EVCNT_TYPE_TRAP,
    377  1.2  matt 		&ci->ci_ev_traps, xname, "user DSI traps");
    378  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_udsi_fatal, EVCNT_TYPE_TRAP,
    379  1.2  matt 		&ci->ci_ev_udsi, xname, "user DSI failures");
    380  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_kisi, EVCNT_TYPE_TRAP,
    381  1.2  matt 		&ci->ci_ev_traps, xname, "kernel ISI traps");
    382  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_isi, EVCNT_TYPE_TRAP,
    383  1.2  matt 		&ci->ci_ev_traps, xname, "user ISI traps");
    384  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_isi_fatal, EVCNT_TYPE_TRAP,
    385  1.2  matt 		&ci->ci_ev_isi, xname, "user ISI failures");
    386  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_scalls, EVCNT_TYPE_TRAP,
    387  1.2  matt 		&ci->ci_ev_traps, xname, "system call traps");
    388  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_pgm, EVCNT_TYPE_TRAP,
    389  1.2  matt 		&ci->ci_ev_traps, xname, "PGM traps");
    390  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_fpu, EVCNT_TYPE_TRAP,
    391  1.2  matt 		&ci->ci_ev_traps, xname, "FPU unavailable traps");
    392  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_fpusw, EVCNT_TYPE_MISC,
    393  1.2  matt 		&ci->ci_ev_fpu, xname, "FPU context switches");
    394  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_ali, EVCNT_TYPE_TRAP,
    395  1.2  matt 		&ci->ci_ev_traps, xname, "user alignment traps");
    396  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_ali_fatal, EVCNT_TYPE_TRAP,
    397  1.2  matt 		&ci->ci_ev_ali, xname, "user alignment traps");
    398  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_umchk, EVCNT_TYPE_TRAP,
    399  1.2  matt 		&ci->ci_ev_umchk, xname, "user MCHK failures");
    400  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_vec, EVCNT_TYPE_TRAP,
    401  1.2  matt 		&ci->ci_ev_traps, xname, "SPE unavailable");
    402  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_vecsw, EVCNT_TYPE_MISC,
    403  1.2  matt 	    &ci->ci_ev_vec, xname, "SPE context switches");
    404  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_ipi, EVCNT_TYPE_INTR,
    405  1.2  matt 		NULL, xname, "IPIs");
    406  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_tlbmiss_soft, EVCNT_TYPE_TRAP,
    407  1.2  matt 		&ci->ci_ev_traps, xname, "soft tlb misses");
    408  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_dtlbmiss_hard, EVCNT_TYPE_TRAP,
    409  1.2  matt 		&ci->ci_ev_traps, xname, "data tlb misses");
    410  1.2  matt 	evcnt_attach_dynamic_nozero(&ci->ci_ev_itlbmiss_hard, EVCNT_TYPE_TRAP,
    411  1.2  matt 		&ci->ci_ev_traps, xname, "inst tlb misses");
    412  1.2  matt }
    413  1.2  matt 
    414  1.2  matt uint32_t
    415  1.2  matt cpu_read_4(bus_addr_t a)
    416  1.2  matt {
    417  1.2  matt 	struct cpu_softc * const cpu = curcpu()->ci_softc;
    418  1.2  matt //	printf(" %s(%p, %x, %x)", __func__, cpu->cpu_bst, cpu->cpu_bsh, a);
    419  1.2  matt 	return bus_space_read_4(cpu->cpu_bst, cpu->cpu_bsh, a);
    420  1.2  matt }
    421  1.2  matt 
    422  1.2  matt uint8_t
    423  1.2  matt cpu_read_1(bus_addr_t a)
    424  1.2  matt {
    425  1.2  matt 	struct cpu_softc * const cpu = curcpu()->ci_softc;
    426  1.2  matt //	printf(" %s(%p, %x, %x)", __func__, cpu->cpu_bst, cpu->cpu_bsh, a);
    427  1.2  matt 	return bus_space_read_1(cpu->cpu_bst, cpu->cpu_bsh, a);
    428  1.2  matt }
    429  1.2  matt 
    430  1.2  matt void
    431  1.2  matt cpu_write_4(bus_addr_t a, uint32_t v)
    432  1.2  matt {
    433  1.2  matt 	struct cpu_softc * const cpu = curcpu()->ci_softc;
    434  1.2  matt 	bus_space_write_4(cpu->cpu_bst, cpu->cpu_bsh, a, v);
    435  1.2  matt }
    436  1.2  matt 
    437  1.2  matt void
    438  1.2  matt cpu_write_1(bus_addr_t a, uint8_t v)
    439  1.2  matt {
    440  1.2  matt 	struct cpu_softc * const cpu = curcpu()->ci_softc;
    441  1.2  matt 	bus_space_write_1(cpu->cpu_bst, cpu->cpu_bsh, a, v);
    442  1.2  matt }
    443