From 1eea142b6fff3e9cf61f578ec1af30c71a758195 Mon Sep 17 00:00:00 2001 From: Kip Macy Date: Sat, 18 Nov 2006 07:10:52 +0000 Subject: [PATCH] remove 13 (largely) redundant files and switch to the sparc64/sparc64 version Reviewed by: jb (mentor rwatson) --- sys/conf/files.sun4v | 26 ++- sys/sparc64/sparc64/autoconf.c | 4 + sys/sparc64/sparc64/identcpu.c | 9 +- sys/sparc64/sparc64/mem.c | 13 +- sys/sun4v/include/cache.h | 8 + sys/sun4v/sun4v/autoconf.c | 83 -------- sys/sun4v/sun4v/clock.c | 67 ------ sys/sun4v/sun4v/eeprom.c | 192 ------------------ sys/sun4v/sun4v/elf_machdep.c | 361 --------------------------------- sys/sun4v/sun4v/gdb_machdep.c | 70 ------- sys/sun4v/sun4v/identcpu.c | 106 ---------- sys/sun4v/sun4v/in_cksum.c | 249 ----------------------- sys/sun4v/sun4v/mem.c | 183 ----------------- sys/sun4v/sun4v/ofw_bus.c | 198 ------------------ sys/sun4v/sun4v/ofw_machdep.c | 267 ------------------------ sys/sun4v/sun4v/prof_machdep.c | 83 -------- sys/sun4v/sun4v/rwindow.c | 110 ---------- sys/sun4v/sun4v/sys_machdep.c | 130 ------------ 18 files changed, 41 insertions(+), 2118 deletions(-) delete mode 100644 sys/sun4v/sun4v/autoconf.c delete mode 100644 sys/sun4v/sun4v/clock.c delete mode 100644 sys/sun4v/sun4v/eeprom.c delete mode 100644 sys/sun4v/sun4v/elf_machdep.c delete mode 100644 sys/sun4v/sun4v/gdb_machdep.c delete mode 100644 sys/sun4v/sun4v/identcpu.c delete mode 100644 sys/sun4v/sun4v/in_cksum.c delete mode 100644 sys/sun4v/sun4v/mem.c delete mode 100644 sys/sun4v/sun4v/ofw_bus.c delete mode 100644 sys/sun4v/sun4v/ofw_machdep.c delete mode 100644 sys/sun4v/sun4v/prof_machdep.c delete mode 100644 sys/sun4v/sun4v/rwindow.c delete mode 100644 sys/sun4v/sun4v/sys_machdep.c diff --git a/sys/conf/files.sun4v b/sys/conf/files.sun4v index 8920fe03afd3..1b7974abdca5 100644 --- a/sys/conf/files.sun4v +++ b/sys/conf/files.sun4v @@ -37,20 +37,18 @@ libkern/ffs.c standard libkern/ffsl.c standard libkern/fls.c standard libkern/flsl.c standard -sun4v/sun4v/autoconf.c standard +sparc64/sparc64/autoconf.c standard sun4v/sun4v/bus_machdep.c standard -sun4v/sun4v/clock.c standard +sparc64/sparc64/clock.c standard sun4v/sun4v/counter.c standard sun4v/sun4v/db_disasm.c optional ddb sun4v/sun4v/db_interface.c optional ddb sun4v/sun4v/db_trace.c optional ddb sun4v/sun4v/db_hwwatch.c optional ddb sun4v/sun4v/dump_machdep.c standard -sun4v/sun4v/elf_machdep.c standard +sparc64/sparc64/elf_machdep.c standard sun4v/sun4v/exception.S standard no-obj -sun4v/sun4v/eeprom.c optional eeprom ebus | eeprom fhc | \ - eeprom sbus -sun4v/sun4v/gdb_machdep.c optional gdb +sparc64/sparc64/gdb_machdep.c optional gdb sun4v/sun4v/hv_pci.c optional pci sun4v/sun4v/trap_trace.S optional trap_tracing sparc64/pci/ofw_pci.c optional pci @@ -63,27 +61,27 @@ sparc64/pci/ofw_pci_if.m optional pci sun4v/sun4v/hvcons.c standard sun4v/sun4v/hcall.S standard sun4v/sun4v/hviommu.c standard -sun4v/sun4v/identcpu.c standard -sun4v/sun4v/in_cksum.c optional inet +sparc64/sparc64/identcpu.c standard +sparc64/sparc64/in_cksum.c optional inet sun4v/sun4v/interrupt.S standard no-obj sun4v/sun4v/intr_machdep.c standard sun4v/sun4v/locore.S standard no-obj sun4v/sun4v/machdep.c standard -sun4v/sun4v/mem.c optional mem +sparc64/sparc64/mem.c optional mem sun4v/sun4v/mp_exception.S optional smp sun4v/sun4v/mp_locore.S optional smp sun4v/sun4v/mp_machdep.c optional smp sun4v/sun4v/nexus.c standard sun4v/sun4v/t1_copy.S standard -sun4v/sun4v/ofw_bus.c standard -sun4v/sun4v/ofw_machdep.c standard +sparc64/sparc64/ofw_bus.c standard +sparc64/sparc64/ofw_machdep.c standard sun4v/sun4v/pmap.c standard -sun4v/sun4v/prof_machdep.c optional profiling-routine -sun4v/sun4v/rwindow.c standard +sparc64/sparc64/prof_machdep.c optional profiling-routine +sparc64/sparc64/rwindow.c standard sun4v/sun4v/rtc.c standard sun4v/sun4v/simdisk.c optional simulator sun4v/sun4v/support.S standard -sun4v/sun4v/sys_machdep.c standard +sparc64/sparc64/sys_machdep.c standard sun4v/sun4v/swtch.S standard sun4v/sun4v/tsb.c standard sun4v/sun4v/tte.c standard diff --git a/sys/sparc64/sparc64/autoconf.c b/sys/sparc64/sparc64/autoconf.c index dd8044de95e0..15b8921dae82 100644 --- a/sys/sparc64/sparc64/autoconf.c +++ b/sys/sparc64/sparc64/autoconf.c @@ -27,6 +27,7 @@ */ #include "opt_isa.h" +#include "opt_global.h" #include #include @@ -65,6 +66,9 @@ static void configure(void *dummy) { +#ifdef SUN4V + intr_restore_all(0x16); +#endif root_bus_configure(); #ifdef DEV_ISA if (isa_bus_device != NULL) diff --git a/sys/sparc64/sparc64/identcpu.c b/sys/sparc64/sparc64/identcpu.c index ba2fbf751a2d..cfd0df052f2f 100644 --- a/sys/sparc64/sparc64/identcpu.c +++ b/sys/sparc64/sparc64/identcpu.c @@ -17,7 +17,7 @@ #include #include -char machine[] = "sparc64"; +char machine[] = MACHINE; SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "Machine class"); @@ -25,13 +25,20 @@ static char cpu_model[128]; SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, cpu_model, 0, "Machine model"); +#ifndef SUN4V int cpu_impl; +#endif void setPQL2(int *const size, int *const ways); void setPQL2(int *const size, int *const ways) { +#ifdef SUN4V +/* XXX hardcoding is lame */ + *size = 3*1024; + *ways = 12; +#endif return; } diff --git a/sys/sparc64/sparc64/mem.c b/sys/sparc64/sparc64/mem.c index cb4c4de1f97e..459191ad9cae 100644 --- a/sys/sparc64/sparc64/mem.c +++ b/sys/sparc64/sparc64/mem.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); * might cause illegal aliases to be created for the locked kernel page(s), so * it is not implemented. */ +#include "opt_global.h" #include #include @@ -91,9 +92,11 @@ memrw(struct cdev *dev, struct uio *uio, int flags) vm_paddr_t pa; vm_size_t cnt; vm_page_t m; - int color; int error; int i; +#ifndef SUN4V + int color; +#endif cnt = 0; error = 0; @@ -137,10 +140,12 @@ memrw(struct cdev *dev, struct uio *uio, int flags) ova = kmem_alloc_wait(kernel_map, PAGE_SIZE * DCACHE_COLORS); } - if ((color = m->md.color) == -1) - va = ova; - else +#ifndef SUN4V + if ((color = m->md.color) != -1) va = ova + color * PAGE_SIZE; + else +#endif + va = ova; pmap_qenter(va, &m, 1); error = uiomove((void *)(va + off), cnt, uio); diff --git a/sys/sun4v/include/cache.h b/sys/sun4v/include/cache.h index 8154b273fc1e..9e83f9550116 100644 --- a/sys/sun4v/include/cache.h +++ b/sys/sun4v/include/cache.h @@ -47,6 +47,14 @@ #include +#ifdef SUN4V +#define DCACHE_COLOR_BITS (0) +#else +#define DCACHE_COLOR_BITS (1) +#endif + +#define DCACHE_COLORS (1 << DCACHE_COLOR_BITS) + #define DC_TAG_SHIFT 2 #define DC_VALID_SHIFT 0 diff --git a/sys/sun4v/sun4v/autoconf.c b/sys/sun4v/sun4v/autoconf.c deleted file mode 100644 index b30fbdd2cece..000000000000 --- a/sys/sun4v/sun4v/autoconf.c +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include "opt_isa.h" - -#include -#include -#include -#include -#include - -#ifdef DEV_ISA -#include -extern device_t isa_bus_device; -#endif - -static device_t nexusdev; - -static void configure_first(void *); -static void configure(void *); -static void configure_final(void *); - -SYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL); -/* SI_ORDER_SECOND is hookable */ -SYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL); -/* SI_ORDER_MIDDLE is hookable */ -SYSINIT(configure3, SI_SUB_CONFIGURE, SI_ORDER_ANY, configure_final, NULL); - -/* - * Determine i/o configuration for a machine. - */ -static void -configure_first(void *dummy) -{ - - nexusdev = device_add_child(root_bus, "nexus", 0); -} - -static void -configure(void *dummy) -{ - - intr_restore_all(0x16); - - root_bus_configure(); -#ifdef DEV_ISA - if (isa_bus_device != NULL) - isa_probe_children(isa_bus_device); -#endif -} - -static void -configure_final(void *dummy) -{ - - cninit_finish(); - cold = 0; -} diff --git a/sys/sun4v/sun4v/clock.c b/sys/sun4v/sun4v/clock.c deleted file mode 100644 index 37341fd3ba43..000000000000 --- a/sys/sun4v/sun4v/clock.c +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -#include -#include - -u_long tick_increment; -u_long tick_freq; -u_long tick_MHz; - -void -DELAY(int n) -{ - u_long start, end; - - start = rd(tick); - if (n < 0) - return; - end = start + (u_long)n * tick_MHz; - while (rd(tick) < end) - ; -} - -void -cpu_startprofclock(void) -{ -} - -void -cpu_stopprofclock(void) -{ -} - -int -sysbeep(int pitch, int period) -{ - /* - * XXX: function exists to enable RAID drivers to compile at the moment. - */ - return (0); -} diff --git a/sys/sun4v/sun4v/eeprom.c b/sys/sun4v/sun4v/eeprom.c deleted file mode 100644 index 68390070e78e..000000000000 --- a/sys/sun4v/sun4v/eeprom.c +++ /dev/null @@ -1,192 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * Copyright (c) 1994 Gordon W. Ross - * Copyright (c) 1993 Adam Glass - * Copyright (c) 1996 Paul Kranenburg - * Copyright (c) 1996 - * The President and Fellows of Harvard College. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Harvard University. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Paul Kranenburg. - * This product includes software developed by Harvard University. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)clock.c 8.1 (Berkeley) 6/11/93 - * from: NetBSD: clock.c,v 1.41 2001/07/24 19:29:25 eeh Exp - */ - -#include -__FBSDID("$FreeBSD$"); - -/* - * clock (eeprom) attaches at EBus, FireHose or SBus - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#include - -#include "clock_if.h" - -#define IDPROM_OFFSET 40 - -static devclass_t eeprom_devclass; - -static device_probe_t eeprom_probe; -static device_attach_t eeprom_attach; - -static device_method_t eeprom_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, eeprom_probe), - DEVMETHOD(device_attach, eeprom_attach), - - /* clock interface */ - DEVMETHOD(clock_gettime, mk48txx_gettime), - DEVMETHOD(clock_settime, mk48txx_settime), - - { 0, 0 } -}; - -static driver_t eeprom_driver = { - "eeprom", - eeprom_methods, - sizeof(struct mk48txx_softc), -}; - -DRIVER_MODULE(eeprom, ebus, eeprom_driver, eeprom_devclass, 0, 0); -DRIVER_MODULE(eeprom, fhc, eeprom_driver, eeprom_devclass, 0, 0); -DRIVER_MODULE(eeprom, sbus, eeprom_driver, eeprom_devclass, 0, 0); - -static int -eeprom_probe(device_t dev) -{ - - if (strcmp("eeprom", ofw_bus_get_name(dev)) == 0) { - device_set_desc(dev, "EEPROM/clock"); - return (0); - } - return (ENXIO); -} - -static int -eeprom_attach(device_t dev) -{ - struct mk48txx_softc *sc; - struct resource *res; - struct timespec ts; - uint32_t h; - int error, i, rid; - - sc = device_get_softc(dev); - - mtx_init(&sc->sc_mtx, "eeprom_mtx", NULL, MTX_DEF); - - rid = 0; - res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); - if (res == NULL) { - device_printf(dev, "cannot allocate resources\n"); - error = ENXIO; - goto fail_mtx; - } - sc->sc_bst = rman_get_bustag(res); - sc->sc_bsh = rman_get_bushandle(res); - - if ((sc->sc_model = ofw_bus_get_model(dev)) == NULL) { - device_printf(dev, "cannot determine model\n"); - error = ENXIO; - goto fail_res; - } - - /* Our TOD clock year 0 is 1968 */ - sc->sc_year0 = 1968; - /* Use default register read/write functions. */ - sc->sc_flag = 0; - if ((error = mk48txx_attach(dev)) != 0) { - device_printf(dev, "cannot attach time of day clock\n"); - goto fail_res; - } - - /* - * Get the hostid from the NVRAM. This serves no real purpose other - * than being able to display it below as not all sparc64 models - * have an `eeprom' device and even some that do store the hostid - * elsewhere. The hostid in the NVRAM of the MK48Txx reads all zero - * on the latter models. A generic way to retrieve the hostid is to - * use the `idprom' node. - */ - mtx_lock(&sc->sc_mtx); - h = bus_space_read_1(sc->sc_bst, sc->sc_bsh, sc->sc_nvramsz - - IDPROM_OFFSET + offsetof(struct idprom, id_machine)) << 24; - for (i = 0; i < 3; i++) { - h |= bus_space_read_1(sc->sc_bst, sc->sc_bsh, sc->sc_nvramsz - - IDPROM_OFFSET + offsetof(struct idprom, id_hostid[i])) << - ((2 - i) * 8); - } - mtx_unlock(&sc->sc_mtx); - if (h != 0) - device_printf(dev, "hostid %x\n", (u_int)h); - - if (bootverbose) { - mk48txx_gettime(dev, &ts); - device_printf(dev, "current time: %ld.%09ld\n", (long)ts.tv_sec, - ts.tv_nsec); - } - - return (0); - - fail_res: - bus_release_resource(dev, SYS_RES_MEMORY, rid, res); - fail_mtx: - mtx_destroy(&sc->sc_mtx); - - return (error); -} diff --git a/sys/sun4v/sun4v/elf_machdep.c b/sys/sun4v/sun4v/elf_machdep.c deleted file mode 100644 index 1b9bbc23ece9..000000000000 --- a/sys/sun4v/sun4v/elf_machdep.c +++ /dev/null @@ -1,361 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * Copyright (c) 2000 Eduardo Horvath. - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: NetBSD: mdreloc.c,v 1.5 2001/04/25 12:24:51 kleink Exp - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include "linker_if.h" - -struct sysentvec elf64_freebsd_sysvec = { - SYS_MAXSYSCALL, - sysent, - 0, - 0, - NULL, - 0, - NULL, - NULL, - __elfN(freebsd_fixup), - sendsig, - NULL, - NULL, - NULL, - "FreeBSD ELF64", - __elfN(coredump), - NULL, - MINSIGSTKSZ, - PAGE_SIZE, - VM_MIN_ADDRESS, - VM_MAXUSER_ADDRESS, - USRSTACK, - PS_STRINGS, - VM_PROT_READ | VM_PROT_WRITE, - exec_copyout_strings, - exec_setregs, - NULL -}; - -static Elf64_Brandinfo freebsd_brand_info = { - ELFOSABI_FREEBSD, - EM_SPARCV9, - "FreeBSD", - NULL, - "/libexec/ld-elf.so.1", - &elf64_freebsd_sysvec, - NULL, - 0, - }; - -SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY, - (sysinit_cfunc_t) elf64_insert_brand_entry, - &freebsd_brand_info); - -static Elf64_Brandinfo freebsd_brand_oinfo = { - ELFOSABI_FREEBSD, - EM_SPARCV9, - "FreeBSD", - NULL, - "/usr/libexec/ld-elf.so.1", - &elf64_freebsd_sysvec, - NULL, - 0, - }; - -SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_ANY, - (sysinit_cfunc_t) elf64_insert_brand_entry, - &freebsd_brand_oinfo); - - -void -elf64_dump_thread(struct thread *td __unused, void *dst __unused, - size_t *off __unused) -{ -} - - -/* - * The following table holds for each relocation type: - * - the width in bits of the memory location the relocation - * applies to (not currently used) - * - the number of bits the relocation value must be shifted to the - * right (i.e. discard least significant bits) to fit into - * the appropriate field in the instruction word. - * - flags indicating whether - * * the relocation involves a symbol - * * the relocation is relative to the current position - * * the relocation is for a GOT entry - * * the relocation is relative to the load address - * - */ -#define _RF_S 0x80000000 /* Resolve symbol */ -#define _RF_A 0x40000000 /* Use addend */ -#define _RF_P 0x20000000 /* Location relative */ -#define _RF_G 0x10000000 /* GOT offset */ -#define _RF_B 0x08000000 /* Load address relative */ -#define _RF_U 0x04000000 /* Unaligned */ -#define _RF_SZ(s) (((s) & 0xff) << 8) /* memory target size */ -#define _RF_RS(s) ( (s) & 0xff) /* right shift */ -static int reloc_target_flags[] = { - 0, /* NONE */ - _RF_S|_RF_A| _RF_SZ(8) | _RF_RS(0), /* RELOC_8 */ - _RF_S|_RF_A| _RF_SZ(16) | _RF_RS(0), /* RELOC_16 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* RELOC_32 */ - _RF_S|_RF_A|_RF_P| _RF_SZ(8) | _RF_RS(0), /* DISP_8 */ - _RF_S|_RF_A|_RF_P| _RF_SZ(16) | _RF_RS(0), /* DISP_16 */ - _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(0), /* DISP_32 */ - _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(2), /* WDISP_30 */ - _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(2), /* WDISP_22 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(10), /* HI22 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 22 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 13 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* LO10 */ - _RF_G| _RF_SZ(32) | _RF_RS(0), /* GOT10 */ - _RF_G| _RF_SZ(32) | _RF_RS(0), /* GOT13 */ - _RF_G| _RF_SZ(32) | _RF_RS(10), /* GOT22 */ - _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(0), /* PC10 */ - _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(10), /* PC22 */ - _RF_A|_RF_P| _RF_SZ(32) | _RF_RS(2), /* WPLT30 */ - _RF_SZ(32) | _RF_RS(0), /* COPY */ - _RF_S|_RF_A| _RF_SZ(64) | _RF_RS(0), /* GLOB_DAT */ - _RF_SZ(32) | _RF_RS(0), /* JMP_SLOT */ - _RF_A| _RF_B| _RF_SZ(64) | _RF_RS(0), /* RELATIVE */ - _RF_S|_RF_A| _RF_U| _RF_SZ(32) | _RF_RS(0), /* UA_32 */ - - _RF_A| _RF_SZ(32) | _RF_RS(0), /* PLT32 */ - _RF_A| _RF_SZ(32) | _RF_RS(10), /* HIPLT22 */ - _RF_A| _RF_SZ(32) | _RF_RS(0), /* LOPLT10 */ - _RF_A|_RF_P| _RF_SZ(32) | _RF_RS(0), /* PCPLT32 */ - _RF_A|_RF_P| _RF_SZ(32) | _RF_RS(10), /* PCPLT22 */ - _RF_A|_RF_P| _RF_SZ(32) | _RF_RS(0), /* PCPLT10 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 10 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 11 */ - _RF_S|_RF_A| _RF_SZ(64) | _RF_RS(0), /* 64 */ - _RF_S|_RF_A|/*extra*/ _RF_SZ(32) | _RF_RS(0), /* OLO10 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(42), /* HH22 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(32), /* HM10 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(10), /* LM22 */ - _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(42), /* PC_HH22 */ - _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(32), /* PC_HM10 */ - _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(10), /* PC_LM22 */ - _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(2), /* WDISP16 */ - _RF_S|_RF_A|_RF_P| _RF_SZ(32) | _RF_RS(2), /* WDISP19 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* GLOB_JMP */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 7 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 5 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 6 */ - _RF_S|_RF_A|_RF_P| _RF_SZ(64) | _RF_RS(0), /* DISP64 */ - _RF_A| _RF_SZ(64) | _RF_RS(0), /* PLT64 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(10), /* HIX22 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* LOX10 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(22), /* H44 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(12), /* M44 */ - _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* L44 */ - _RF_S|_RF_A| _RF_SZ(64) | _RF_RS(0), /* REGISTER */ - _RF_S|_RF_A| _RF_U| _RF_SZ(64) | _RF_RS(0), /* UA64 */ - _RF_S|_RF_A| _RF_U| _RF_SZ(16) | _RF_RS(0), /* UA16 */ -}; - -#if 0 -static const char *reloc_names[] = { - "NONE", "RELOC_8", "RELOC_16", "RELOC_32", "DISP_8", - "DISP_16", "DISP_32", "WDISP_30", "WDISP_22", "HI22", - "22", "13", "LO10", "GOT10", "GOT13", - "GOT22", "PC10", "PC22", "WPLT30", "COPY", - "GLOB_DAT", "JMP_SLOT", "RELATIVE", "UA_32", "PLT32", - "HIPLT22", "LOPLT10", "LOPLT10", "PCPLT22", "PCPLT32", - "10", "11", "64", "OLO10", "HH22", - "HM10", "LM22", "PC_HH22", "PC_HM10", "PC_LM22", - "WDISP16", "WDISP19", "GLOB_JMP", "7", "5", "6", - "DISP64", "PLT64", "HIX22", "LOX10", "H44", "M44", - "L44", "REGISTER", "UA64", "UA16" -}; -#endif - -#define RELOC_RESOLVE_SYMBOL(t) ((reloc_target_flags[t] & _RF_S) != 0) -#define RELOC_PC_RELATIVE(t) ((reloc_target_flags[t] & _RF_P) != 0) -#define RELOC_BASE_RELATIVE(t) ((reloc_target_flags[t] & _RF_B) != 0) -#define RELOC_UNALIGNED(t) ((reloc_target_flags[t] & _RF_U) != 0) -#define RELOC_USE_ADDEND(t) ((reloc_target_flags[t] & _RF_A) != 0) -#define RELOC_TARGET_SIZE(t) ((reloc_target_flags[t] >> 8) & 0xff) -#define RELOC_VALUE_RIGHTSHIFT(t) (reloc_target_flags[t] & 0xff) - -static long reloc_target_bitmask[] = { -#define _BM(x) (~(-(1ULL << (x)))) - 0, /* NONE */ - _BM(8), _BM(16), _BM(32), /* RELOC_8, _16, _32 */ - _BM(8), _BM(16), _BM(32), /* DISP8, DISP16, DISP32 */ - _BM(30), _BM(22), /* WDISP30, WDISP22 */ - _BM(22), _BM(22), /* HI22, _22 */ - _BM(13), _BM(10), /* RELOC_13, _LO10 */ - _BM(10), _BM(13), _BM(22), /* GOT10, GOT13, GOT22 */ - _BM(10), _BM(22), /* _PC10, _PC22 */ - _BM(30), 0, /* _WPLT30, _COPY */ - _BM(32), _BM(32), _BM(32), /* _GLOB_DAT, JMP_SLOT, _RELATIVE */ - _BM(32), _BM(32), /* _UA32, PLT32 */ - _BM(22), _BM(10), /* _HIPLT22, LOPLT10 */ - _BM(32), _BM(22), _BM(10), /* _PCPLT32, _PCPLT22, _PCPLT10 */ - _BM(10), _BM(11), -1, /* _10, _11, _64 */ - _BM(10), _BM(22), /* _OLO10, _HH22 */ - _BM(10), _BM(22), /* _HM10, _LM22 */ - _BM(22), _BM(10), _BM(22), /* _PC_HH22, _PC_HM10, _PC_LM22 */ - _BM(16), _BM(19), /* _WDISP16, _WDISP19 */ - -1, /* GLOB_JMP */ - _BM(7), _BM(5), _BM(6) /* _7, _5, _6 */ - -1, -1, /* DISP64, PLT64 */ - _BM(22), _BM(13), /* HIX22, LOX10 */ - _BM(22), _BM(10), _BM(13), /* H44, M44, L44 */ - -1, -1, _BM(16), /* REGISTER, UA64, UA16 */ -#undef _BM -}; -#define RELOC_VALUE_BITMASK(t) (reloc_target_bitmask[t]) - -int -elf_reloc_local(linker_file_t lf, Elf_Addr relocbase, const void *data, - int type, elf_lookup_fn lookup) -{ - const Elf_Rela *rela; - Elf_Addr value; - Elf_Addr *where; - - if (type != ELF_RELOC_RELA) - return (-1); - - rela = (const Elf_Rela *)data; - if (ELF_R_TYPE(rela->r_info) != R_SPARC_RELATIVE) - return (-1); - - value = rela->r_addend + (Elf_Addr)lf->address; - where = (Elf_Addr *)((Elf_Addr)lf->address + rela->r_offset); - - *where = value; - - return (0); -} - -/* Process one elf relocation with addend. */ -int -elf_reloc(linker_file_t lf, Elf_Addr relocbase, const void *data, int type, - elf_lookup_fn lookup) -{ - const Elf_Rela *rela; - Elf_Word *where32; - Elf_Addr *where; - Elf_Size rtype, symidx; - Elf_Addr value; - Elf_Addr mask; - Elf_Addr addr; - - if (type != ELF_RELOC_RELA) - return (-1); - - rela = (const Elf_Rela *)data; - where = (Elf_Addr *)(relocbase + rela->r_offset); - where32 = (Elf_Word *)where; - rtype = ELF_R_TYPE(rela->r_info); - symidx = ELF_R_SYM(rela->r_info); - - if (rtype == R_SPARC_NONE || rtype == R_SPARC_RELATIVE) - return (0); - - if (rtype == R_SPARC_JMP_SLOT || rtype == R_SPARC_COPY || - rtype > R_SPARC_UA16) - return (-1); - - if (RELOC_UNALIGNED(rtype)) - return (-1); - - value = rela->r_addend; - - if (RELOC_RESOLVE_SYMBOL(rtype)) { - addr = lookup(lf, symidx, 1); - if (addr == 0) - return (-1); - value += addr; - } - - if (RELOC_PC_RELATIVE(rtype)) - value -= (Elf_Addr)where; - - if (RELOC_BASE_RELATIVE(rtype)) - value += relocbase; - - mask = RELOC_VALUE_BITMASK(rtype); - value >>= RELOC_VALUE_RIGHTSHIFT(rtype); - value &= mask; - - if (RELOC_TARGET_SIZE(rtype) > 32) { - *where &= ~mask; - *where |= value; - } else { - *where32 &= ~mask; - *where32 |= value; - } - - return (0); -} - -int -elf_cpu_load_file(linker_file_t lf __unused) -{ - - return (0); -} - -int -elf_cpu_unload_file(linker_file_t lf __unused) -{ - - return (0); -} diff --git a/sys/sun4v/sun4v/gdb_machdep.c b/sys/sun4v/sun4v/gdb_machdep.c deleted file mode 100644 index 97e613560511..000000000000 --- a/sys/sun4v/sun4v/gdb_machdep.c +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * Copyright (c) 2004 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -void * -gdb_cpu_getreg(int regnum, size_t *regsz) -{ - static uint64_t synth; - - *regsz = gdb_cpu_regsz(regnum); - switch (regnum) { - /* 0-7: g0-g7 */ - /* 8-15: o0-o7 */ - case 14: - synth = kdb_thrctx->pcb_sp - CCFSZ; - return (&synth); - /* 16-23: l0-l7 */ - /* 24-31: i0-i7 */ - case 30: return (&kdb_thrctx->pcb_sp); - /* 32-63: f0-f31 */ - /* 64-79: f32-f62 (16 double FP) */ - case 80: return (&kdb_thrctx->pcb_pc); - } - return (NULL); -} - -void -gdb_cpu_setreg(int regnum, void *val) -{ - switch (regnum) { - } -} diff --git a/sys/sun4v/sun4v/identcpu.c b/sys/sun4v/sun4v/identcpu.c deleted file mode 100644 index d5dd6e4d07f1..000000000000 --- a/sys/sun4v/sun4v/identcpu.c +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * Initial implementation: - * Copyright (c) 2001 Robert Drehmel - * All rights reserved. - * - * As long as the above copyright statement and this notice remain - * unchanged, you can do what ever you want with this file. - * - * $FreeBSD$ - */ -#include -#include -#include -#include - -#include -#include -#include - -char machine[] = MACHINE; -SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, - machine, 0, "Machine class"); - -static char cpu_model[128]; -SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, - cpu_model, 0, "Machine model"); - -void setPQL2(int *const size, int *const ways); - -void -setPQL2(int *const size, int *const ways) -{ - /* XXX SUN4V_FIXME - this is hardcoded for the T1 - * this info should really be pulled from the machine description - */ - *size = 3*1024; - *ways = 12; -} - -void -cpu_identify(u_long vers, u_int freq, u_int id) -{ - const char *manus; - const char *impls; - - switch (VER_MANUF(vers)) { - case 0x04: - manus = "HAL"; - break; - case 0x13: - case 0x17: - case 0x22: - case 0x3e: - manus = "Sun Microsystems"; - break; - default: - manus = NULL; - break; - } - switch (VER_IMPL(vers)) { - case CPU_IMPL_SPARC64: - impls = "SPARC64"; - break; - case CPU_IMPL_ULTRASPARCI: - impls = "UltraSparc-I"; - break; - case CPU_IMPL_ULTRASPARCII: - impls = "UltraSparc-II"; - break; - case CPU_IMPL_ULTRASPARCIIi: - impls = "UltraSparc-IIi"; - break; - case CPU_IMPL_ULTRASPARCIIe: - /* V9 Manual says `UltraSparc-e'. I assume this is wrong. */ - impls = "UltraSparc-IIe"; - break; - case CPU_IMPL_ULTRASPARCIII: - impls = "UltraSparc-III"; - break; - case CPU_IMPL_ULTRASPARCIIIp: - impls = "UltraSparc-III+"; - break; - case CPU_IMPL_ULTRASPARCIIIi: - impls = "UltraSparc-IIIi"; - break; - default: - impls = NULL; - break; - } - if (manus == NULL || impls == NULL) { - printf( - "CPU: unknown; please e-mail the following value together\n" - " with the exact name of your processor to " - ".\n" - " version register: <0x%lx>\n", vers); - return; - } - - snprintf(cpu_model, sizeof(cpu_model), "%s %s", manus, impls); - printf("cpu%d: %s %s Processor (%d.%02d MHz CPU)\n", id, manus, impls, - (freq + 4999) / 1000000, ((freq + 4999) / 10000) % 100); - if (bootverbose) { - printf(" mask=0x%lx maxtl=%ld maxwin=%ld\n", VER_MASK(vers), - VER_MAXTL(vers), VER_MAXWIN(vers)); - } -} diff --git a/sys/sun4v/sun4v/in_cksum.c b/sys/sun4v/sun4v/in_cksum.c deleted file mode 100644 index 8239b110e772..000000000000 --- a/sys/sun4v/sun4v/in_cksum.c +++ /dev/null @@ -1,249 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/*- - * Copyright (c) 2001 by Thomas Moestl . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * from tahoe: in_cksum.c 1.2 86/01/05 - * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 - * from: FreeBSD: src/sys/i386/i386/in_cksum.c,v 1.22 2000/11/25 - * - * $FreeBSD$ - */ - -#include -#include -#include - -#include -#include -#include - -#include - -/* - * Checksum routine for Internet Protocol family headers. - * - * This routine is very heavily used in the network - * code and should be modified for each CPU to be as fast as possible. - * - * This implementation is a sparc64 version. Most code was taken over and - * adapted from the i386. Some optimizations were changed to achieve (hopefully) - * better performance. - * This uses 64 bit loads, but 32 bit additions due to the lack of a 64-bit - * add-with-carry operation. - */ - -/* - * REDUCE() is actually not used that frequently... maybe a C implementation - * would suffice. - */ -#define REDUCE(sum, tmp) __asm __volatile( \ - "sll %2, 16, %1\n" \ - "addcc %2, %1, %0\n" \ - "srl %0, 16, %0\n" \ - "addc %0, 0, %0" : "=r" (sum), "=r" (tmp) : "0" (sum)) - -/* - * Note that some of these macros depend on the flags being preserved between - * calls, so they should not be intermixed with other C statements. - */ -#define LD64_ADD32(sum, tmp, addr, n, mod) __asm __volatile( \ - "ldx [%3 + " #n "], %1\n" \ - "add" #mod " %2, %1, %0\n" \ - "srlx %1, 32, %1\n" \ - "addccc %0, %1, %0" : "=r" (sum), "=r" (tmp) : "0" (sum), "r" (addr)) - -#define LD32_ADD32(sum, tmp, addr, n, mod) __asm __volatile( \ - "lduw [%3 + " #n "], %1\n" \ - "add" #mod " %2, %1, %0\n" \ - : "=r" (sum), "=r" (tmp) : "0" (sum), "r" (addr)) - -#define MOP(sum) __asm __volatile( \ - "addc %1, 0, %0" : "=r" (sum) : "0" (sum)) - -u_short -in_cksum_skip(struct mbuf *m, int len, int skip) -{ - u_short *w; - unsigned long tmp, sum = 0; - int mlen = 0; - int byte_swapped = 0; - u_short su = 0; - - len -= skip; - for (; skip > 0 && m != NULL; m = m->m_next) { - if (m->m_len > skip) { - mlen = m->m_len - skip; - w = (u_short *)(mtod(m, u_char *) + skip); - goto skip_start; - } else - skip -= m->m_len; - } - - for (; m != NULL && len > 0; m = m->m_next) { - if (m->m_len == 0) - continue; - w = mtod(m, u_short *); - if (mlen == -1) { - /* - * The first byte of this mbuf is the continuation - * of a word spanning between this mbuf and the - * last mbuf. - * - * The high order byte of su is already saved when - * scanning previous mbuf. sum was REDUCEd when we - * found mlen == -1 - */ - sum += su | *(u_char *)w; - w = (u_short *)((u_char *)w + 1); - mlen = m->m_len - 1; - len--; - } else - mlen = m->m_len; -skip_start: - if (len < mlen) - mlen = len; - len -= mlen; - /* - * Force to a 8-byte boundary first so that we can use - * LD64_ADD32. - */ - if (((u_long)w & 7) != 0) { - REDUCE(sum, tmp); - if (((u_long)w & 1) != 0 && mlen >= 1) { - sum <<= 8; - su = *(u_char *)w << 8; - w = (u_short *)((u_char *)w + 1); - mlen--; - byte_swapped = 1; - } - if (((u_long)w & 2) != 0 && mlen >= 2) { - sum += *w++; - mlen -= 2; - } - if (((u_long)w & 4) != 0 && mlen >= 4) { - LD32_ADD32(sum, tmp, w, 0, cc); - MOP(sum); - w += 2; - mlen -= 4; - } - } - /* - * Do as much of the checksum as possible 64 bits at at time. - * In fact, this loop is unrolled to make overhead from - * branches &c small. - */ - for (; mlen >= 64; mlen -= 64) { - LD64_ADD32(sum, tmp, w, 0, cc); - LD64_ADD32(sum, tmp, w, 8, ccc); - LD64_ADD32(sum, tmp, w, 16, ccc); - LD64_ADD32(sum, tmp, w, 24, ccc); - LD64_ADD32(sum, tmp, w, 32, ccc); - LD64_ADD32(sum, tmp, w, 40, ccc); - LD64_ADD32(sum, tmp, w, 48, ccc); - LD64_ADD32(sum, tmp, w, 56, ccc); - MOP(sum); - w += 32; - } - if (mlen >= 32) { - LD64_ADD32(sum, tmp, w, 0, cc); - LD64_ADD32(sum, tmp, w, 8, ccc); - LD64_ADD32(sum, tmp, w, 16, ccc); - LD64_ADD32(sum, tmp, w, 24, ccc); - MOP(sum); - w += 16; - mlen -= 32; - } - if (mlen >= 16) { - LD64_ADD32(sum, tmp, w, 0, cc); - LD64_ADD32(sum, tmp, w, 8, ccc); - MOP(sum); - w += 8; - mlen -= 16; - } - if (mlen >= 8) { - LD64_ADD32(sum, tmp, w, 0, cc); - MOP(sum); - w += 4; - mlen -= 8; - } - REDUCE(sum, tmp); - while ((mlen -= 2) >= 0) - sum += *w++; - if (byte_swapped) { - sum <<= 8; - byte_swapped = 0; - if (mlen == -1) { - su |= *(u_char *)w; - sum += su; - mlen = 0; - } else - mlen = -1; - } else if (mlen == -1) { - /* - * This mbuf has odd number of bytes. - * There could be a word split betwen - * this mbuf and the next mbuf. - * Save the last byte (to prepend to next mbuf). - */ - su = *(u_char *)w << 8; - } - } - - if (len) - printf("%s: out of data by %d\n", __func__, len); - if (mlen == -1) { - /* The last mbuf has odd # of bytes. Follow the - standard (the odd byte is shifted left by 8 bits) */ - sum += su & 0xff00; - } - REDUCE(sum, tmp); - return (~sum & 0xffff); -} diff --git a/sys/sun4v/sun4v/mem.c b/sys/sun4v/sun4v/mem.c deleted file mode 100644 index 6a7b9da959c3..000000000000 --- a/sys/sun4v/sun4v/mem.c +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department, and code derived from software contributed to - * Berkeley by William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah $Hdr: mem.c 1.13 89/10/08$ - * from: @(#)mem.c 7.2 (Berkeley) 5/9/91 - * from: FreeBSD: src/sys/i386/i386/mem.c,v 1.94 2001/09/26 - */ - -#include -__FBSDID("$FreeBSD$"); - -/* - * Memory special file - * - * NOTE: other architectures support mmap()'ing the mem and kmem devices; this - * might cause illegal aliases to be created for the locked kernel page(s), so - * it is not implemented. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -struct mem_range_softc mem_range_softc; - -/* ARGSUSED */ -int -memrw(struct cdev *dev, struct uio *uio, int flags) -{ - struct iovec *iov; - vm_offset_t eva; - vm_offset_t off; - vm_offset_t ova; - vm_offset_t va; - vm_prot_t prot; - vm_paddr_t pa; - vm_size_t cnt; - vm_page_t m; - int error; - int i; - - cnt = 0; - error = 0; - ova = 0; - - GIANT_REQUIRED; - - while (uio->uio_resid > 0 && error == 0) { - iov = uio->uio_iov; - if (iov->iov_len == 0) { - uio->uio_iov++; - uio->uio_iovcnt--; - if (uio->uio_iovcnt < 0) - panic("memrw"); - continue; - } - if (minor(dev) == CDEV_MINOR_MEM) { - pa = uio->uio_offset & ~PAGE_MASK; - if (!is_physical_memory(pa)) { - error = EFAULT; - break; - } - - off = uio->uio_offset & PAGE_MASK; - cnt = PAGE_SIZE - ((vm_offset_t)iov->iov_base & - PAGE_MASK); - cnt = ulmin(cnt, PAGE_SIZE - off); - cnt = ulmin(cnt, iov->iov_len); - - m = NULL; - for (i = 0; phys_avail[i] != 0; i += 2) { - if (pa >= phys_avail[i] && - pa < phys_avail[i + 1]) { - m = PHYS_TO_VM_PAGE(pa); - break; - } - } - - if (m != NULL) { - if (ova == 0) { - ova = kmem_alloc_wait(kernel_map, - PAGE_SIZE); - } - va = ova; - pmap_qenter(va, &m, 1); - error = uiomove((void *)(va + off), cnt, - uio); - pmap_qremove(va, 1); - } else { - va = TLB_PHYS_TO_DIRECT(pa); - error = uiomove((void *)(va + off), cnt, - uio); - } - break; - } - else if (minor(dev) == CDEV_MINOR_KMEM) { - va = trunc_page(uio->uio_offset); - eva = round_page(uio->uio_offset + iov->iov_len); - - /* - * Make sure that all of the pages are currently - * resident so we don't create any zero fill pages. - */ - for (; va < eva; va += PAGE_SIZE) - if (pmap_kextract(va) == 0) - return (EFAULT); - - prot = (uio->uio_rw == UIO_READ) ? VM_PROT_READ : - VM_PROT_WRITE; - va = uio->uio_offset; - if (va < VM_MIN_DIRECT_ADDRESS && - kernacc((void *)va, iov->iov_len, prot) == FALSE) - return (EFAULT); - - error = uiomove((void *)va, iov->iov_len, uio); - break; - } - /* else panic! */ - } - if (ova != 0) - kmem_free_wakeup(kernel_map, ova, PAGE_SIZE); - return (error); -} - -void -dev_mem_md_init(void) -{ -} diff --git a/sys/sun4v/sun4v/ofw_bus.c b/sys/sun4v/sun4v/ofw_bus.c deleted file mode 100644 index f7458dcc62fd..000000000000 --- a/sys/sun4v/sun4v/ofw_bus.c +++ /dev/null @@ -1,198 +0,0 @@ -/*- - * Copyright (C) 1996 Wolfgang Solfrank. - * Copyright (C) 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/*- - * Copyright (c) 2001 - 2003 by Thomas Moestl . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * from: $NetBSD: ofw_machdep.c,v 1.16 2001/07/20 00:07:14 eeh Exp $ - * - * $FreeBSD$ - */ - -/* - * Open Firmware bus support code that is (hopefully) independent from the - * used hardware. - * Maybe this should go into dev/ofw/; there may however be sparc specific - * bits left. - */ - -#include -#include -#include - -#include - -#include - -static int -ofw_bus_searchprop(phandle_t node, char *propname, void *buf, int buflen) -{ - int rv; - - for (; node != 0; node = OF_parent(node)) { - if ((rv = OF_getprop(node, propname, buf, buflen)) != -1) - return (rv); - } - return (-1); -} - -void -ofw_bus_setup_iinfo(phandle_t node, struct ofw_bus_iinfo *ii, int intrsz) -{ - pcell_t addrc; - int msksz; - - if (OF_getprop(node, "#address-cells", &addrc, sizeof(addrc)) == -1) - addrc = 2; - ii->opi_addrc = addrc * sizeof(pcell_t); - - ii->opi_imapsz = OF_getprop_alloc(node, "interrupt-map", 1, - (void **)&ii->opi_imap); - if (ii->opi_imapsz > 0) { - msksz = OF_getprop_alloc(node, "interrupt-map-mask", 1, - (void **)&ii->opi_imapmsk); - /* - * Failure to get the mask is ignored; a full mask is used then. - * Barf on bad mask sizes, however. - */ - if (msksz != -1 && msksz != ii->opi_addrc + intrsz) { - panic("ofw_bus_setup_iinfo: bad interrupt-map-mask " - "property!"); - } - } - -} - -int -ofw_bus_lookup_imap(phandle_t node, struct ofw_bus_iinfo *ii, void *reg, - int regsz, void *pintr, int pintrsz, void *mintr, int mintrsz, - void *maskbuf) -{ - int rv; - - if (ii->opi_imapsz <= 0) - return (0); - KASSERT(regsz >= ii->opi_addrc, - ("ofw_bus_lookup_imap: register size too small: %d < %d", - regsz, ii->opi_addrc)); - rv = OF_getprop(node, "reg", reg, regsz); - if (rv < regsz) - panic("ofw_bus_lookup_imap: could not get reg property"); - return (ofw_bus_search_intrmap(pintr, pintrsz, reg, ii->opi_addrc, - ii->opi_imap, ii->opi_imapsz, ii->opi_imapmsk, maskbuf, mintr, - mintrsz)); -} - -/* - * Map an interrupt using the firmware reg, interrupt-map and - * interrupt-map-mask properties. - * The interrupt property to be mapped must be of size intrsz, and pointed to - * by intr. The regs property of the node for which the mapping is done must - * be passed as regs. This property is an array of register specifications; - * the size of the address part of such a specification must be passed as - * physsz. Only the first element of the property is used. - * imap and imapsz hold the interrupt mask and it's size. - * imapmsk is a pointer to the interrupt-map-mask property, which must have - * a size of physsz + intrsz; it may be NULL, in which case a full mask is - * assumed. - * maskbuf must point to a buffer of length physsz + intrsz. - * The interrupt is returned in result, which must point to a buffer of length - * rintrsz (which gives the expected size of the mapped interrupt). - * Returns 1 if a mapping was found, 0 otherwise. - */ -int -ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz, - void *imap, int imapsz, void *imapmsk, void *maskbuf, void *result, - int rintrsz) -{ - phandle_t parent; - u_int8_t *ref = maskbuf; - u_int8_t *uiintr = intr; - u_int8_t *uiregs = regs; - u_int8_t *uiimapmsk = imapmsk; - u_int8_t *mptr; - pcell_t pintrsz; - int i, rsz, tsz; - - rsz = -1; - if (imapmsk != NULL) { - for (i = 0; i < physsz; i++) - ref[i] = uiregs[i] & uiimapmsk[i]; - for (i = 0; i < intrsz; i++) - ref[physsz + i] = uiintr[i] & uiimapmsk[physsz + i]; - } else { - bcopy(regs, ref, physsz); - bcopy(intr, ref + physsz, intrsz); - } - - mptr = imap; - i = imapsz; - tsz = physsz + intrsz + sizeof(phandle_t) + rintrsz; - while (i > 0) { - KASSERT(i >= tsz, ("ofw_bus_search_intrmap: truncated map")); - bcopy(mptr + physsz + intrsz, &parent, sizeof(parent)); - if (ofw_bus_searchprop(parent, "#interrupt-cells", - &pintrsz, sizeof(pintrsz)) == -1) - pintrsz = 1; /* default */ - pintrsz *= sizeof(pcell_t); - if (pintrsz != rintrsz) - panic("ofw_bus_search_intrmap: expected interrupt cell " - "size incorrect: %d != %d", rintrsz, pintrsz); - if (bcmp(ref, mptr, physsz + intrsz) == 0) { - bcopy(mptr + physsz + intrsz + sizeof(parent), - result, rintrsz); - return (1); - } - mptr += tsz; - i -= tsz; - } - return (0); -} diff --git a/sys/sun4v/sun4v/ofw_machdep.c b/sys/sun4v/sun4v/ofw_machdep.c deleted file mode 100644 index 016b43292245..000000000000 --- a/sys/sun4v/sun4v/ofw_machdep.c +++ /dev/null @@ -1,267 +0,0 @@ -/*- - * Copyright (c) 2001 by Thomas Moestl . - * Copyright (c) 2005 by Marius Strobl . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -/* - * Some Open Firmware helper functions that are likely machine dependent. - */ - -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include - -void -OF_getetheraddr(device_t dev, u_char *addr) -{ - char buf[sizeof("true")]; - phandle_t node; - struct idprom idp; - - if ((node = OF_finddevice("/options")) > 0 && - OF_getprop(node, "local-mac-address?", buf, sizeof(buf)) > 0) { - buf[sizeof(buf) - 1] = '\0'; - if (strcmp(buf, "true") == 0 && - (node = ofw_bus_get_node(dev)) > 0 && - OF_getprop(node, "local-mac-address", addr, - ETHER_ADDR_LEN) == ETHER_ADDR_LEN) - return; - } - - node = OF_peer(0); - if (node <= 0 || OF_getprop(node, "idprom", &idp, sizeof(idp)) == -1) - panic("Could not determine the machine ethernet address"); - bcopy(&idp.id_ether, addr, ETHER_ADDR_LEN); -} - -static __inline uint32_t -phys_hi_mask_space(const char *bus, uint32_t phys_hi) -{ - uint32_t space; - - space = phys_hi; - if (strcmp(bus, "ebus") == 0 || strcmp(bus, "isa") == 0) - space &= 0x1; - else if (strcmp(bus, "pci") == 0) - space &= OFW_PCI_PHYS_HI_SPACEMASK; - /* The phys.hi cells of the other busses only contain space bits. */ - return (space); -} - -/* - * Return the physical address and the bus space to use for a node - * referenced by its package handle and the index of the register bank - * to decode. Intended to be used to together with sparc64_fake_bustag() - * by console drivers in early boot only. - * Works by mapping the address of the node's bank given in the address - * space of its parent upward in the device tree at each bridge along the - * path. - * Currently only really deals with max. 64-bit addresses, i.e. addresses - * consisting of max. 2 phys cells (phys.hi and phys.lo). If we encounter - * a 3 phys cells address (as with PCI addresses) we assume phys.hi can - * be ignored except for the space bits (generally contained in phys.hi) - * and treat phys.mid as phys.hi. - */ -int -OF_decode_addr(phandle_t node, int bank, int *space, bus_addr_t *addr) -{ - char name[32]; - uint64_t cend, cstart, end, phys, sz, start; - pcell_t addrc, szc, paddrc; - phandle_t bus, lbus, pbus; - uint32_t banks[10 * 5]; /* 10 PCI banks */ - uint32_t cspace, spc; - int i, j, nbank; - - /* - * In general the addresses are contained in the "reg" property - * of a node. The first address in the "reg" property of a PCI - * node however is the address of its configuration registers in - * the configuration space of the host bridge. Additional entries - * denote the memory and I/O addresses. For relocatable addresses - * the "reg" property contains the BAR, for non-relocatable - * addresses it contains the absolute PCI address. The PCI-only - * "assigned-addresses" property however always contains the - * absolute PCI addresses. - * The "assigned-addresses" and "reg" properties are arrays of - * address structures consisting of #address-cells 32-bit phys - * cells and #size-cells 32-bit size cells. If a parent lacks - * the "#address-cells" or "#size-cells" property the default - * for #address-cells to use is 2 and for #size-cells 1. - */ - bus = OF_parent(node); - if (bus == 0) - return (ENXIO); - if (OF_getprop(bus, "name", name, sizeof(name)) == -1) - return (ENXIO); - name[sizeof(name) - 1] = '\0'; - if (OF_getprop(bus, "#address-cells", &addrc, sizeof(addrc)) == -1) - addrc = 2; - if (OF_getprop(bus, "#size-cells", &szc, sizeof(szc)) == -1) - szc = 1; - if (addrc < 2 || addrc > 3 || szc < 1 || szc > 2) - return (ENXIO); - if (strcmp(name, "pci") == 0) { - if (addrc > 3) - return (ENXIO); - nbank = OF_getprop(node, "assigned-addresses", &banks, - sizeof(banks)); - } else { - if (addrc > 2) - return (ENXIO); - nbank = OF_getprop(node, "reg", &banks, sizeof(banks)); - } - if (nbank == -1) - return (ENXIO); - nbank /= sizeof(banks[0]) * (addrc + szc); - if (bank < 0 || bank > nbank - 1) - return (ENXIO); - phys = 0; - for (i = 0; i < MIN(2, addrc); i++) - phys |= (uint64_t)banks[(addrc + szc) * bank + addrc - 2 + i] << - 32 * (MIN(2, addrc) - i - 1); - sz = 0; - for (i = 0; i < szc; i++) - sz |= (uint64_t)banks[(addrc + szc) * bank + addrc + i] << - 32 * (szc - i - 1); - start = phys; - end = phys + sz - 1; - spc = phys_hi_mask_space(name, banks[(addrc + szc) * bank]); - - /* - * Map upward in the device tree at every bridge we encounter - * using their "ranges" properties. - * The "ranges" property of a bridge is an array of a structure - * consisting of that bridge's #address-cells 32-bit child-phys - * cells, its parent bridge #address-cells 32-bit parent-phys - * cells and that bridge's #size-cells 32-bit size cells. - * If a bridge doesn't have a "ranges" property no mapping is - * necessary at that bridge. - */ - cspace = 0; - lbus = bus; - while ((pbus = OF_parent(bus)) != 0) { - if (OF_getprop(pbus, "#address-cells", &paddrc, - sizeof(paddrc)) == -1) - paddrc = 2; - if (paddrc < 2 || paddrc > 3) - return (ENXIO); - nbank = OF_getprop(bus, "ranges", &banks, sizeof(banks)); - if (nbank == -1) { - if (OF_getprop(pbus, "name", name, sizeof(name)) == -1) - return (ENXIO); - name[sizeof(name) - 1] = '\0'; - goto skip; - } - if (lbus != bus) { - if (OF_getprop(bus, "#size-cells", &szc, - sizeof(szc)) == -1) - szc = 1; - if (szc < 1 || szc > 2) - return (ENXIO); - } - nbank /= sizeof(banks[0]) * (addrc + paddrc + szc); - for (i = 0; i < nbank; i++) { - cspace = phys_hi_mask_space(name, - banks[(addrc + paddrc + szc) * i]); - if (cspace != spc) - continue; - phys = 0; - for (j = 0; j < MIN(2, addrc); j++) - phys |= (uint64_t)banks[ - (addrc + paddrc + szc) * i + - addrc - 2 + j] << - 32 * (MIN(2, addrc) - j - 1); - sz = 0; - for (j = 0; j < szc; j++) - sz |= (uint64_t)banks[ - (addrc + paddrc + szc) * i + addrc + - paddrc + j] << - 32 * (szc - j - 1); - cstart = phys; - cend = phys + sz - 1; - if (start < cstart || start > cend) - continue; - if (end < cstart || end > cend) - return (ENXIO); - phys = 0; - for (j = 0; j < MIN(2, paddrc); j++) - phys |= (uint64_t)banks[ - (addrc + paddrc + szc) * i + addrc + - paddrc - 2 + j] << - 32 * (MIN(2, paddrc) - j - 1); - start += phys - cstart; - end += phys - cstart; - if (OF_getprop(pbus, "name", name, sizeof(name)) == -1) - return (ENXIO); - name[sizeof(name) - 1] = '\0'; - spc = phys_hi_mask_space(name, - banks[(addrc + paddrc + szc) * i + addrc]); - break; - } - if (i == nbank) - return (ENXIO); - skip: - addrc = paddrc; - lbus = bus; - bus = pbus; - } - - /* Done with mapping. Return the bus space as used by FreeBSD. */ - *addr = start; - if (OF_getprop(lbus, "name", name, sizeof(name)) == -1) - return (ENXIO); - name[sizeof(name) - 1] = '\0'; - if (strcmp(name, "central") == 0) { - *space = UPA_BUS_SPACE; - return (0); - } else if (strcmp(name, "pci") == 0) { - switch (cspace) { - case OFW_PCI_PHYS_HI_SPACE_IO: - *space = PCI_IO_BUS_SPACE; - return (0); - case OFW_PCI_PHYS_HI_SPACE_MEM32: - *space = PCI_MEMORY_BUS_SPACE; - return (0); - } - } else if (strcmp(name, "sbus") == 0) { - *space = SBUS_BUS_SPACE; - return (0); - } - return (ENXIO); -} diff --git a/sys/sun4v/sun4v/prof_machdep.c b/sys/sun4v/sun4v/prof_machdep.c deleted file mode 100644 index 065a1daa44c2..000000000000 --- a/sys/sun4v/sun4v/prof_machdep.c +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * Copyright (c) 1996 Bruce D. Evans. - * Copyright (c) 2002 by Thomas Moestl . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: src/sys/i386/isa/prof_machdep.c,v 1.16 2000/07/04 11:25:19 - * - * $FreeBSD$ - */ - -#ifdef GUPROF - -#include -#include -#include -#include -#include - -#include -#include - -int cputime_bias; - -/* - * Return the time elapsed since the last call. The units are machine- - * dependent. - * XXX: this is not SMP-safe. It should use per-CPU variables; %tick can be - * used though. - */ -int -cputime(void) -{ - u_long count; - int delta; - static u_long prev_count; - - count = rd(tick); - delta = (int)(count - prev_count); - prev_count = count; - return (delta); -} - -/* - * The start and stop routines need not be here since we turn off profiling - * before calling them. They are here for convenience. - */ -void -startguprof(struct gmonparam *gp) -{ - - gp->profrate = tick_freq; - cputime_bias = 0; - cputime(); -} - -void -stopguprof(struct gmonparam *gp) -{ - /* Nothing to do. */ -} - -#endif /* GUPROF */ diff --git a/sys/sun4v/sun4v/rwindow.c b/sys/sun4v/sun4v/rwindow.c deleted file mode 100644 index 5ea877413bd8..000000000000 --- a/sys/sun4v/sun4v/rwindow.c +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Berkeley Software Design Inc's name may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: BSDI: trap.c,v 1.17.2.9 1999/10/19 15:29:52 cp Exp - * $FreeBSD$ - */ - -#include -#include -#include -#include - -#include -#include - -CTASSERT((1 << RW_SHIFT) == sizeof(struct rwindow)); - -int -rwindow_load(struct thread *td, struct trapframe *tf, int n) -{ - struct rwindow rw; - u_long usp; - int error; - int i; - - CTR3(KTR_TRAP, "rwindow_load: td=%p (%s) n=%d", - td, td->td_proc->p_comm, n); - - /* - * In case current window is still only on-chip, push it out; - * if it cannot get all the way out, we cannot continue either. - */ - if ((error = rwindow_save(td)) != 0) - return (error); - usp = tf->tf_out[6]; - for (i = 0; i < n; i++) { - CTR1(KTR_TRAP, "rwindow_load: usp=%#lx", usp); - usp += SPOFF; - if ((error = (usp & 0x7)) != 0) - break; - error = copyin((void *)usp, &rw, sizeof rw); - usp = rw.rw_in[6]; - } - CTR1(KTR_TRAP, "rwindow_load: error=%d", error); - return (error == 0 ? 0 : SIGILL); -} - -int -rwindow_save(struct thread *td) -{ - struct rwindow *rw; - struct pcb *pcb; - u_long *ausp; - u_long usp; - int error; - int i; - - pcb = td->td_pcb; - CTR3(KTR_TRAP, "rwindow_save: td=%p (%s) nsaved=%d", td, - td->td_proc->p_comm, pcb->pcb_nsaved); - - flushw(); - KASSERT(pcb->pcb_nsaved < MAXWIN, - ("rwindow_save: pcb_nsaved > MAXWIN")); - if ((i = pcb->pcb_nsaved) == 0) - return (0); - ausp = pcb->pcb_rwsp; - rw = pcb->pcb_rw; - error = 0; - do { - usp = *ausp; - CTR1(KTR_TRAP, "rwindow_save: usp=%#lx", usp); - usp += SPOFF; - if ((error = (usp & 0x7)) != 0) - break; - error = copyout(rw, (void *)usp, sizeof *rw); - if (error) - break; - ausp++; - rw++; - } while (--i > 0); - CTR1(KTR_TRAP, "rwindow_save: error=%d", error); - if (error == 0) - pcb->pcb_nsaved = 0; - return (error == 0 ? 0 : SIGILL); -} diff --git a/sys/sun4v/sun4v/sys_machdep.c b/sys/sun4v/sun4v/sys_machdep.c deleted file mode 100644 index 9ac5fbc212a4..000000000000 --- a/sys/sun4v/sun4v/sys_machdep.c +++ /dev/null @@ -1,130 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -static int sparc_sigtramp_install(struct thread *td, char *args); -static int sparc_utrap_install(struct thread *td, char *args); - -#ifndef _SYS_SYSPROTO_H_ -struct sysarch_args { - int op; - char *parms; -}; -#endif - -int -sysarch(struct thread *td, struct sysarch_args *uap) -{ - int error; - - mtx_lock(&Giant); - switch (uap->op) { - case SPARC_SIGTRAMP_INSTALL: - error = sparc_sigtramp_install(td, uap->parms); - break; - case SPARC_UTRAP_INSTALL: - error = sparc_utrap_install(td, uap->parms); - break; - default: - error = EINVAL; - break; - } - mtx_unlock(&Giant); - return (error); -} - -static int -sparc_sigtramp_install(struct thread *td, char *args) -{ - struct sparc_sigtramp_install_args sia; - struct proc *p; - int error; - - p = td->td_proc; - if ((error = copyin(args, &sia, sizeof(sia))) != 0) - return (error); - if (sia.sia_old != NULL) { - if (suword(sia.sia_old, (long)p->p_md.md_sigtramp) != 0) - return (EFAULT); - } - p->p_md.md_sigtramp = sia.sia_new; - return (0); -} - -static int -sparc_utrap_install(struct thread *td, char *args) -{ - struct sparc_utrap_install_args uia; - struct sparc_utrap_args ua; - struct md_utrap *ut; - int error; - int i; - - ut = td->td_proc->p_md.md_utrap; - if ((error = copyin(args, &uia, sizeof(uia))) != 0) - return (error); - if (uia.num < 0 || uia.num > UT_MAX || - (uia.handlers == NULL && uia.num > 0)) - return (EINVAL); - for (i = 0; i < uia.num; i++) { - if ((error = copyin(&uia.handlers[i], &ua, sizeof(ua))) != 0) - return (error); - if (ua.type != UTH_NOCHANGE && - (ua.type < 0 || ua.type >= UT_MAX)) - return (EINVAL); - if (ua.old_deferred != NULL) { - if ((error = suword(ua.old_deferred, 0)) != 0) - return (error); - } - if (ua.old_precise != NULL) { - error = suword(ua.old_precise, - ut != NULL ? (long)ut->ut_precise[ua.type] : 0); - if (error != 0) - return (error); - } - if (ua.type != UTH_NOCHANGE) { - if (ut == NULL) { - ut = utrap_alloc(); - td->td_proc->p_md.md_utrap = ut; - } - ut->ut_precise[ua.type] = ua.new_precise; - } - } - return (0); -}