diff options
| author | tsutsui <tsutsui@NetBSD.org> | 2006-10-01 03:53:27 +0000 |
|---|---|---|
| committer | tsutsui <tsutsui@NetBSD.org> | 2006-10-01 03:53:27 +0000 |
| commit | d23b794c9e66f9658ff694c6c19eb7ed65e07523 (patch) | |
| tree | 1ec19358d585ef897d7e4d1f84468295d812a1b6 /sys | |
| parent | 51cc6c40414eaeeb6ac35911eef48bebb97f33d5 (diff) | |
First attempt at bus_space(9) support for sun3 with common sun68k/bus.c:
- make sun3 port use common sun68k files as much as possible
- add temporary options _SUN2_ in std.sun2 until sun3 can share all
sun68k files (autoconf.c and isr.c are not yet)
- move sun68kvme declaration temporary as well from files.sun68k to files.sun2
- rename and move sun68k_find_prom_map() function to MD sources since it
can't be shared with sun3
- add bus tag members to struct confargs and initilize them where appropriate
XXX1: MD bus_dma(9) backends are not implemented (yet).
XXX2: more code (obio etc.) should be shared among sun3, sun3x and sun2.
Diffstat (limited to 'sys')
31 files changed, 508 insertions, 529 deletions
diff --git a/sys/arch/sun2/conf/files.sun2 b/sys/arch/sun2/conf/files.sun2 index e2ae206cbe5..79572621e12 100644 --- a/sys/arch/sun2/conf/files.sun2 +++ b/sys/arch/sun2/conf/files.sun2 @@ -1,4 +1,4 @@ -# $NetBSD: files.sun2,v 1.17 2006/09/30 13:43:08 tsutsui Exp $ +# $NetBSD: files.sun2,v 1.18 2006/10/01 03:53:27 tsutsui Exp $ # # sun2-specific configuration info @@ -33,7 +33,14 @@ file dev/cons.c # Bus types # -# mainbus and VME support brought in by arch/sun68k +device mainbus {} +attach mainbus at root + +# VME support (these should be moved into arch/sun68k) +include "dev/vme/files.vme" +device sun68kvme: vmebus +attach sun68kvme at mainbus +file arch/sun68k/sun68k/vme_sun68k.c sun68kvme # On-board I/O space (required). device obio {addr = -1, [ipl = -1], [vect = -1]} diff --git a/sys/arch/sun2/conf/std.sun2 b/sys/arch/sun2/conf/std.sun2 index 886f44a87d1..d4aacffc9e5 100644 --- a/sys/arch/sun2/conf/std.sun2 +++ b/sys/arch/sun2/conf/std.sun2 @@ -1,8 +1,11 @@ -# $NetBSD: std.sun2,v 1.5 2005/12/11 12:19:16 christos Exp $ +# $NetBSD: std.sun2,v 1.6 2006/10/01 03:53:27 tsutsui Exp $ # Standard information for Sun2 machines. machine sun2 m68k sun68k include "conf/std" # MI standard options +# XXX temporary option until sun3 port migrates to all sun68k stuff +options _SUN2_ + # Standard defines options EXEC_ELF32, EXEC_SCRIPT diff --git a/sys/arch/sun2/dev/zs_any.c b/sys/arch/sun2/dev/zs_any.c index e98fcc7bfe2..d5e94f87462 100644 --- a/sys/arch/sun2/dev/zs_any.c +++ b/sys/arch/sun2/dev/zs_any.c @@ -1,4 +1,4 @@ -/* $NetBSD: zs_any.c,v 1.14 2006/03/28 17:38:28 thorpej Exp $ */ +/* $NetBSD: zs_any.c,v 1.15 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -45,7 +45,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: zs_any.c,v 1.14 2006/03/28 17:38:28 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: zs_any.c,v 1.15 2006/10/01 03:53:27 tsutsui Exp $"); #include "opt_kgdb.h" @@ -180,9 +180,6 @@ zs_console_flags(int promunit, int node, int channel) } #ifdef KGDB -extern int sun68k_find_prom_map(bus_addr_t, bus_type_t, int, - bus_space_handle_t *); - /* * Find a zs mapped by the PROM. Currently this only works to find * zs0 on obio. @@ -200,7 +197,7 @@ zs_find_prom(int unit) * The physical address of zs0 is model-dependent. */ zs0_phys = (cpu_machine_id == ID_SUN2_120 ? 0x002000 : 0x7f2000); - if (sun68k_find_prom_map(zs0_phys, PMAP_OBIO, sizeof(struct zsdevice), + if (find_prom_map(zs0_phys, PMAP_OBIO, sizeof(struct zsdevice), &bh)) return (NULL); diff --git a/sys/arch/sun2/sun2/machdep.c b/sys/arch/sun2/sun2/machdep.c index 615949f8f09..d5f4bd3401f 100644 --- a/sys/arch/sun2/sun2/machdep.c +++ b/sys/arch/sun2/sun2/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.41 2005/12/24 20:07:41 perry Exp $ */ +/* $NetBSD: machdep.c,v 1.42 2006/10/01 03:53:27 tsutsui Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -160,7 +160,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.41 2005/12/24 20:07:41 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.42 2006/10/01 03:53:27 tsutsui Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -1134,3 +1134,67 @@ vmebus_translate(vme_am_t mod, vme_addr_t addr, bus_type_t *btp, *btp = (*bap & 0x800000 ? PMAP_VME8 : PMAP_VME0); return (0); } + +/* + * If we can find a mapping that was established by the PROM, use it. + */ +int +find_prom_map(bus_addr_t pa, bus_type_t iospace, int len, + bus_space_handle_t *hp) +{ + u_long pf; + int pgtype; + u_long va, eva; + int sme; + u_long pte; + int saved_ctx; + + /* + * The mapping must fit entirely within one page. + */ + if ((((u_long)pa & PGOFSET) + len) > PAGE_SIZE) + return EINVAL; + + pf = PA_PGNUM(pa); + pgtype = iospace << PG_MOD_SHIFT; + saved_ctx = kernel_context(); + + /* + * Walk the PROM address space, looking for a page with the + * mapping we want. + */ + for (va = SUN_MONSTART; va < SUN_MONEND; ) { + + /* + * Make sure this segment is mapped. + */ + sme = get_segmap(va); + if (sme == SEGINV) { + va += NBSG; + continue; /* next segment */ + } + + /* + * Walk the pages of this segment. + */ + for(eva = va + NBSG; va < eva; va += PAGE_SIZE) { + pte = get_pte(va); + + if ((pte & (PG_VALID | PG_TYPE)) == + (PG_VALID | pgtype) && + PG_PFNUM(pte) == pf) + { + /* + * Found the PROM mapping. + * note: preserve page offset + */ + *hp = (bus_space_handle_t)(va | + ((u_long)pa & PGOFSET)); + restore_context(saved_ctx); + return 0; + } + } + } + restore_context(saved_ctx); + return ENOENT; +} diff --git a/sys/arch/sun3/conf/files.sun3 b/sys/arch/sun3/conf/files.sun3 index d08b63a8d19..22814810005 100644 --- a/sys/arch/sun3/conf/files.sun3 +++ b/sys/arch/sun3/conf/files.sun3 @@ -1,4 +1,4 @@ -# $NetBSD: files.sun3,v 1.74 2006/05/30 19:19:36 he Exp $ +# $NetBSD: files.sun3,v 1.75 2006/10/01 03:53:27 tsutsui Exp $ # # sun3-specific configuration info @@ -13,7 +13,6 @@ maxusers 2 8 64 file arch/sun3/sun3/bus_subr.c _sun3_ file arch/sun3/sun3/cache.c _sun3_ & havecache file arch/sun3/sun3/control.c _sun3_ -file arch/sun3/sun3/ctrlsp.S _sun3_ file arch/sun3/sun3/dvma.c _sun3_ file arch/sun3/sun3/enable.c _sun3_ file arch/sun3/sun3/locore2.c _sun3_ @@ -37,16 +36,10 @@ file arch/sun3/sun3/db_memrw.c ddb | kgdb file arch/sun3/sun3/fpu.c file arch/sun3/sun3/isr.c file arch/sun3/sun3/leds.c -file arch/sun3/sun3/stub.c file arch/sun3/sun3/sunmon.c file arch/sun3/sun3/sys_machdep.c file arch/sun3/sun3/trap.c -file arch/sun3/sun3/vector.c file arch/m68k/m68k/cacheops.c _sun3x_ -file arch/m68k/m68k/kgdb_machdep.c kgdb -file arch/m68k/m68k/procfs_machdep.c procfs -file arch/m68k/m68k/vm_machdep.c -file dev/sun/disksubr.c include "arch/m68k/fpe/files.fpe" diff --git a/sys/arch/sun3/conf/std.sun3 b/sys/arch/sun3/conf/std.sun3 index 87af9893654..eebe2673e99 100644 --- a/sys/arch/sun3/conf/std.sun3 +++ b/sys/arch/sun3/conf/std.sun3 @@ -1,7 +1,7 @@ -# $NetBSD: std.sun3,v 1.32 2005/12/11 12:19:20 christos Exp $ +# $NetBSD: std.sun3,v 1.33 2006/10/01 03:53:27 tsutsui Exp $ # Standard information for Sun3 machines. -machine sun3 m68k +machine sun3 m68k sun68k include "conf/std" # MI standard options # Machine type to be supported by this kernel. Note: diff --git a/sys/arch/sun3/conf/std.sun3x b/sys/arch/sun3/conf/std.sun3x index 09d42cf7b56..c9a17f61b1c 100644 --- a/sys/arch/sun3/conf/std.sun3x +++ b/sys/arch/sun3/conf/std.sun3x @@ -1,7 +1,7 @@ -# $NetBSD: std.sun3x,v 1.11 2005/12/11 12:19:20 christos Exp $ +# $NetBSD: std.sun3x,v 1.12 2006/10/01 03:53:27 tsutsui Exp $ # Standard information for Sun3X machines. -machine sun3 m68k +machine sun3 m68k sun68k include "conf/std" # MI standard options # Machine type to be supported by this kernel. Note: diff --git a/sys/arch/sun3/include/autoconf.h b/sys/arch/sun3/include/autoconf.h index 8e2a095f464..b8540b58fea 100644 --- a/sys/arch/sun3/include/autoconf.h +++ b/sys/arch/sun3/include/autoconf.h @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.h,v 1.22 2005/12/11 12:19:21 christos Exp $ */ +/* $NetBSD: autoconf.h,v 1.23 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -41,6 +41,8 @@ * (machdep parts of driver/kernel interface) */ +#include <machine/bus.h> + /* * These are the "bus" types, in attach order. * Note tables in bus_subr.c and vme.c that @@ -60,12 +62,18 @@ * This is the "args" parameter to the bus match/attach functions. */ struct confargs { + bus_space_tag_t ca_bustag; + bus_dma_tag_t ca_dmatag; + const char *ca_name; int ca_bustype; /* BUS_OBIO, ... */ - int ca_paddr; /* physical address */ + paddr_t ca_paddr; /* physical address */ int ca_intpri; /* interrupt priority level */ int ca_intvec; /* interrupt vector index */ }; +extern struct sun68k_bus_dma_tag mainbus_dma_tag; +extern struct sun68k_bus_space_tag mainbus_space_tag; + /* Locator aliases */ #define cf_paddr cf_loc[0] #define cf_intpri cf_loc[1] diff --git a/sys/arch/sun3/include/bus.h b/sys/arch/sun3/include/bus.h new file mode 100644 index 00000000000..7d8d73cec99 --- /dev/null +++ b/sys/arch/sun3/include/bus.h @@ -0,0 +1,3 @@ +/* $NetBSD: bus.h,v 1.1 2006/10/01 03:53:27 tsutsui Exp $ */ + +#include <sun68k/bus.h> diff --git a/sys/arch/sun3/include/mon.h b/sys/arch/sun3/include/mon.h index 2247dae1539..874d19b6d47 100644 --- a/sys/arch/sun3/include/mon.h +++ b/sys/arch/sun3/include/mon.h @@ -1,4 +1,4 @@ -/* $NetBSD: mon.h,v 1.27 2005/12/11 12:19:21 christos Exp $ */ +/* $NetBSD: mon.h,v 1.28 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -381,6 +381,11 @@ struct sunromvec { #define SUN3_MONSHORTPAGE 0x0FFFE000 #define SUN3_MONSHORTSEG 0x0FFE0000 +#ifdef _SUN3_ /* XXX */ +#define SUN_MONSTART SUN3_MONSTART +#define SUN_MONEND SUN3_MONEND +#endif /* _SUN3_ */ + /* * Sun3X specific stuff... */ @@ -414,6 +419,11 @@ struct sunromvec { #define SUN3X_PROM_BASE 0xFEFE0000 #define SUN3X_MONEND 0xFF000000 +#ifdef _SUN3X_ /* XXX */ +#define SUN_MONSTART SUN3X_MONSTART +#define SUN_MONEND SUN3X_MONEND +#endif /* _SUN3X_ */ + /* * These define the CPU virtual address range mapped by the * PROM for use as DVMA space. The physical pages mapped in diff --git a/sys/arch/sun3/include/pmap3.h b/sys/arch/sun3/include/pmap3.h index a25cbe3aec3..3d40bfed61a 100644 --- a/sys/arch/sun3/include/pmap3.h +++ b/sys/arch/sun3/include/pmap3.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap3.h,v 1.41 2006/02/16 20:17:15 perry Exp $ */ +/* $NetBSD: pmap3.h,v 1.42 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -41,6 +41,8 @@ * XXX - Does user-level code really see this struct? */ +#include <sys/lock.h> + struct pmap { unsigned char *pm_segmap; /* soft copy of segmap */ int pm_ctxnum; /* MMU context number */ @@ -96,6 +98,7 @@ pmap_remove_all(struct pmap *pmap) * The values below must agree with pte.h such that: * (PMAP_OBIO << PG_MOD_SHIFT) == PGT_OBIO */ +#define PMAP_OBMEM 0x00 /* unused */ #define PMAP_OBIO 0x04 /* tells pmap_enter to use PG_OBIO */ #define PMAP_VME16 0x08 /* etc */ #define PMAP_VME32 0x0C /* etc */ diff --git a/sys/arch/sun3/include/pmap3x.h b/sys/arch/sun3/include/pmap3x.h index 7ecbad9dfd7..b88a7aecfc4 100644 --- a/sys/arch/sun3/include/pmap3x.h +++ b/sys/arch/sun3/include/pmap3x.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap3x.h,v 1.22 2006/02/16 20:17:15 perry Exp $ */ +/* $NetBSD: pmap3x.h,v 1.23 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -41,6 +41,8 @@ * XXX - Does user-level code really see this struct? */ +#include <sys/lock.h> + struct pmap { struct a_tmgr_struct *pm_a_tmgr; /* Level-A table manager */ u_long pm_a_phys; /* MMU level-A phys addr */ @@ -81,6 +83,8 @@ pmap_remove_all(struct pmap *pmap) * Since physical addresses are always aligned, we can use * the low order bits for this. */ +#define PMAP_OBMEM 0x00 /* unused */ +#define PMAP_OBIO 0x00 /* unused */ #define PMAP_VME16 0x10 /* pmap will add the necessary offset */ #define PMAP_VME32 0x20 /* etc. */ #define PMAP_NC 0x40 /* tells pmap_enter to set PTE_CI */ diff --git a/sys/arch/sun3/sun3/autoconf.c b/sys/arch/sun3/sun3/autoconf.c index 09615828486..efaf1bca76b 100644 --- a/sys/arch/sun3/sun3/autoconf.c +++ b/sys/arch/sun3/sun3/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.67 2006/02/21 04:32:38 thorpej Exp $ */ +/* $NetBSD: autoconf.c,v 1.68 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -45,7 +45,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.67 2006/02/21 04:32:38 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.68 2006/10/01 03:53:27 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -150,7 +150,7 @@ bus_print(void *args, const char *name) aprint_normal("%s:", name); if (ca->ca_paddr != -1) - aprint_normal(" addr 0x%x", ca->ca_paddr); + aprint_normal(" addr 0x%lx", ca->ca_paddr); if (ca->ca_intpri != -1) aprint_normal(" ipl %d", ca->ca_intpri); if (ca->ca_intvec != -1) diff --git a/sys/arch/sun3/sun3/bus_subr.c b/sys/arch/sun3/sun3/bus_subr.c index 09b29ebc83e..637beee276a 100644 --- a/sys/arch/sun3/sun3/bus_subr.c +++ b/sys/arch/sun3/sun3/bus_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: bus_subr.c,v 1.14 2005/12/11 12:19:27 christos Exp $ */ +/* $NetBSD: bus_subr.c,v 1.15 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bus_subr.c,v 1.14 2005/12/11 12:19:27 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bus_subr.c,v 1.15 2006/10/01 03:53:27 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -67,7 +67,6 @@ extern vaddr_t tmp_vpages[]; extern int tmp_vpages_inuse; #define OBIO_MASK 0xFFffff -#define PMAP_OBMEM 0 static const struct { int type; diff --git a/sys/arch/sun3/sun3/ctrlsp.S b/sys/arch/sun3/sun3/ctrlsp.S deleted file mode 100644 index 1c461da4604..00000000000 --- a/sys/arch/sun3/sun3/ctrlsp.S +++ /dev/null @@ -1,96 +0,0 @@ -/* $NetBSD: ctrlsp.S,v 1.5 2001/02/22 07:11:12 chs Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Adam Glass. - * - * 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. - */ - -/* - * This is shared with stand/libsa - * XXX - can not include cpu.h there... - */ - -#include <machine/asm.h> -#define FC_CONTROL 3 /* from cpu.h */ - -/* - * unsigned char get_control_byte (char *addr) - */ -ENTRY(get_control_byte) - movc %sfc,%d1 | save sfc - moveq #FC_CONTROL,%d0 | sfc = FC_CONTROL - movec %d0,%sfc - movl %sp@(4),%a0 | src addr - moveq #0,%d0 | get byte - movsb %a0@,%d0 - movc %d1,%sfc | restore sfc - rts - -/* - * unsigned int get_control_word (char *addr) - */ -ENTRY(get_control_word) - movc %sfc,%d1 | save sfc - moveq #FC_CONTROL,%d0 | sfc = FC_CONTROL - movec %d0,%sfc - movl %sp@(4),%a0 | src addr - movsl %a0@,%d0 | get long - movc %d1,%sfc | restore sfc - rts - -/* - * void set_control_byte (char *addr, int value) - */ -ENTRY(set_control_byte) - movc %dfc,%d1 | save dfc - moveq #FC_CONTROL,%d0 | dfc = FC_CONTROL - movc %d0,%dfc - movl %sp@(4),%a0 | addr - movl %sp@(8),%d0 | value - movsb %d0,%a0@ | set byte - movc %d1,%dfc | restore dfc - rts - -/* - * void set_control_word (char *addr, int value) - */ -ENTRY(set_control_word) - movc %dfc,%d1 | save dfc - moveq #FC_CONTROL, %d0 | dfc = FC_CONTROL - movc %d0,%dfc - movl %sp@(4),%a0 | addr - movl %sp@(8),%d0 | value - movsl %d0,%a0@ | set long - movc %d1,%dfc | restore dfc - rts diff --git a/sys/arch/sun3/sun3/dvma.c b/sys/arch/sun3/sun3/dvma.c index 2a8bb24fe3a..6e32a63cad2 100644 --- a/sys/arch/sun3/sun3/dvma.c +++ b/sys/arch/sun3/sun3/dvma.c @@ -1,4 +1,4 @@ -/* $NetBSD: dvma.c,v 1.28 2005/12/11 12:19:27 christos Exp $ */ +/* $NetBSD: dvma.c,v 1.29 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dvma.c,v 1.28 2005/12/11 12:19:27 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dvma.c,v 1.29 2006/10/01 03:53:27 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -53,7 +53,9 @@ __KERNEL_RCSID(0, "$NetBSD: dvma.c,v 1.28 2005/12/11 12:19:27 christos Exp $"); #include <uvm/uvm.h> /* XXX: not _extern ... need uvm_map_create */ +#define _SUN68K_BUS_DMA_PRIVATE #include <machine/autoconf.h> +#include <machine/bus.h> #include <machine/cpu.h> #include <machine/dvma.h> #include <machine/pmap.h> @@ -279,3 +281,26 @@ dvma_mapout(void *dma, int len) seg_dma, seg_len); splx(s); } + +int +_bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs, + int nsegs, bus_size_t size, int flags) +{ + + panic("_bus_dmamap_load_raw(): not implemented yet."); +} + +int +_bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, + bus_size_t buflen, struct proc *p, int flags) +{ + + panic("_bus_dmamap_load(): not implemented yet."); +} + +void +_bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map) +{ + + panic("_bus_dmamap_unload(): not implemented yet."); +} diff --git a/sys/arch/sun3/sun3/isr.c b/sys/arch/sun3/sun3/isr.c index 7368bdf5569..563012b766d 100644 --- a/sys/arch/sun3/sun3/isr.c +++ b/sys/arch/sun3/sun3/isr.c @@ -1,4 +1,4 @@ -/* $NetBSD: isr.c,v 1.50 2005/12/11 12:19:27 christos Exp $ */ +/* $NetBSD: isr.c,v 1.51 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.50 2005/12/11 12:19:27 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.51 2006/10/01 03:53:27 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -59,7 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.50 2005/12/11 12:19:27 christos Exp $"); #include <machine/mon.h> #include <sun3/sun3/machdep.h> -#include <sun3/sun3/vector.h> +#include <sun68k/sun68k/vector.h> extern int intrcnt[]; /* statistics */ diff --git a/sys/arch/sun3/sun3/locore2.c b/sys/arch/sun3/sun3/locore2.c index 09fad38b2ad..6222cf16edd 100644 --- a/sys/arch/sun3/sun3/locore2.c +++ b/sys/arch/sun3/sun3/locore2.c @@ -1,4 +1,4 @@ -/* $NetBSD: locore2.c,v 1.87 2005/12/11 12:19:27 christos Exp $ */ +/* $NetBSD: locore2.c,v 1.88 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: locore2.c,v 1.87 2005/12/11 12:19:27 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: locore2.c,v 1.88 2006/10/01 03:53:27 tsutsui Exp $"); #include "opt_ddb.h" @@ -64,7 +64,7 @@ __KERNEL_RCSID(0, "$NetBSD: locore2.c,v 1.87 2005/12/11 12:19:27 christos Exp $" #include <sun3/sun3/interreg.h> #include <sun3/sun3/machdep.h> #include <sun3/sun3/obmem.h> -#include <sun3/sun3/vector.h> +#include <sun68k/sun68k/vector.h> #include "ksyms.h" diff --git a/sys/arch/sun3/sun3/mainbus.c b/sys/arch/sun3/sun3/mainbus.c index 219e4627ac0..59e671bfec7 100644 --- a/sys/arch/sun3/sun3/mainbus.c +++ b/sys/arch/sun3/sun3/mainbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.14 2005/12/11 12:19:27 christos Exp $ */ +/* $NetBSD: mainbus.c,v 1.15 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.14 2005/12/11 12:19:27 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.15 2006/10/01 03:53:27 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -74,6 +74,13 @@ main_attach(struct device *parent, struct device *self, void *args) printf("\n"); + ca.ca_bustag = &mainbus_space_tag; + ca.ca_dmatag = &mainbus_dma_tag; + ca.ca_name = NULL; + ca.ca_paddr = -1; + ca.ca_intpri = -1; + ca.ca_intvec = -1; + for (i = 0; i < BUS__NTYPES; i++) { ca.ca_bustype = i; (void) config_found(self, &ca, NULL); diff --git a/sys/arch/sun3/sun3/obio.c b/sys/arch/sun3/sun3/obio.c index 9853be7fa7c..47424089a92 100644 --- a/sys/arch/sun3/sun3/obio.c +++ b/sys/arch/sun3/sun3/obio.c @@ -1,4 +1,4 @@ -/* $NetBSD: obio.c,v 1.49 2005/12/11 12:19:27 christos Exp $ */ +/* $NetBSD: obio.c,v 1.50 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.49 2005/12/11 12:19:27 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.50 2006/10/01 03:53:27 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -46,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.49 2005/12/11 12:19:27 christos Exp $"); #include <uvm/uvm_extern.h> #include <machine/autoconf.h> +#include <machine/bus.h> #include <machine/mon.h> #include <machine/pte.h> @@ -59,17 +60,50 @@ static int obio_print(void *, const char *); static int obio_submatch(struct device *, struct cfdata *, const int *, void *); -CFATTACH_DECL(obio, sizeof(struct device), +struct obio_softc { + struct device sc_dev; + bus_space_tag_t sc_bustag; + bus_dma_tag_t sc_dmatag; +}; + +CFATTACH_DECL(obio, sizeof(struct obio_softc), obio_match, obio_attach, NULL, NULL); +static int obio_attached; + +static int obio_bus_map(bus_space_tag_t, bus_type_t, bus_addr_t, bus_size_t, + int, vaddr_t, bus_space_handle_t *); +static paddr_t obio_bus_mmap(bus_space_tag_t, bus_type_t, bus_addr_t, + off_t, int, int); + +static struct sun68k_bus_space_tag obio_space_tag = { + NULL, /* cookie */ + NULL, /* parent bus space tag */ + obio_bus_map, /* bus_space_map */ + NULL, /* bus_space_unmap */ + NULL, /* bus_space_subregion */ + NULL, /* bus_space_barrier */ + obio_bus_mmap, /* bus_space_mmap */ + NULL, /* bus_intr_establish */ + NULL, /* bus_space_peek_N */ + NULL /* bus_space_poke_N */ +}; + static int obio_match(struct device *parent, struct cfdata *cf, void *aux) { struct confargs *ca = aux; + if (obio_attached) + return 0; + if (ca->ca_bustype != BUS_OBIO) - return (0); - return(1); + return 0; + + if (ca->ca_name != NULL && strcmp(cf->cf_name, ca->ca_name) != 0) + return 0; + + return 1; } /* @@ -85,19 +119,29 @@ static void obio_attach(struct device *parent, struct device *self, void *aux) { struct confargs *ca = aux; - int addr; + struct obio_softc *sc = (void *)self; + struct confargs oba; + int addr; + + obio_attached = 1; printf("\n"); + sc->sc_bustag = ca->ca_bustag; + sc->sc_dmatag = ca->ca_dmatag; + + oba = *ca; + oba.ca_bustag = &obio_space_tag; + /* Configure these in order of address. */ for (addr = 0; addr < OBIO_END; addr += OBIO_INCR) { /* Our parent set ca->ca_bustype already. */ - ca->ca_paddr = addr; + oba.ca_paddr = addr; /* These are filled-in by obio_submatch. */ - ca->ca_intpri = -1; - ca->ca_intvec = -1; - (void) config_found_sm_loc(self, "obio", NULL, ca, obio_print, - obio_submatch); + oba.ca_intpri = -1; + oba.ca_intvec = -1; + (void)config_found_sm_loc(self, "obio", NULL, &oba, obio_print, + obio_submatch); } } @@ -228,6 +272,38 @@ obio_find_mapping(paddr_t pa, psize_t sz) } /* + * The similar function with the above but used by bus_space(9) + */ +int +find_prom_map(bus_addr_t pa, bus_type_t iospace, int sz, + bus_space_handle_t *hp) +{ + vsize_t off; + vaddr_t va; + + off = pa & PGOFSET; + pa -= off; + sz += off; + + /* The saved mappings are all one page long. */ + if (sz > PAGE_SIZE) + return EINVAL; + + /* Within our table? */ + if (pa >= SAVE_LAST) + return ENOENT; + + /* Do we have this one? */ + va = (vaddr_t)prom_mappings[pa >> SAVE_SHIFT]; + if (va == 0) + return ENOENT; + + /* Found it! */ + *hp = va + off; + return 0; +} + +/* * This defines the permission bits to put in our PTEs. * Device space is never cached, and the PROM appears to * leave off the "no-cache" bit, so we can do the same. @@ -338,3 +414,23 @@ obio_init(void) */ intreg_init(); } + +int +obio_bus_map(bus_space_tag_t t, bus_type_t btype, bus_addr_t paddr, + bus_size_t size, int flags, vaddr_t vaddr, bus_space_handle_t *hp) +{ + struct obio_softc *sc = t->cookie; + + return bus_space_map2(sc->sc_bustag, PMAP_OBIO, paddr, size, + flags | _SUN68K_BUS_MAP_USE_PROM, vaddr, hp); +} + +paddr_t +obio_bus_mmap(bus_space_tag_t t, bus_type_t btype, bus_addr_t paddr, off_t off, + int prot, int flags) +{ + struct obio_softc *sc = t->cookie; + + return bus_space_mmap2(sc->sc_bustag, PMAP_OBIO, paddr, off, prot, + flags); +} diff --git a/sys/arch/sun3/sun3/obmem.c b/sys/arch/sun3/sun3/obmem.c index a22705fd19b..4654766b273 100644 --- a/sys/arch/sun3/sun3/obmem.c +++ b/sys/arch/sun3/sun3/obmem.c @@ -1,4 +1,4 @@ -/* $NetBSD: obmem.c,v 1.22 2005/12/11 12:19:27 christos Exp $ */ +/* $NetBSD: obmem.c,v 1.23 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -42,36 +42,107 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: obmem.c,v 1.22 2005/12/11 12:19:27 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: obmem.c,v 1.23 2006/10/01 03:53:27 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> #include <sys/device.h> +#include <uvm/uvm_extern.h> + #include <machine/autoconf.h> +#include <machine/bus.h> #include <sun3/sun3/obmem.h> static int obmem_match(struct device *, struct cfdata *, void *); static void obmem_attach(struct device *, struct device *, void *); +struct obmem_softc { + struct device sc_dev; + bus_space_tag_t sc_bustag; + bus_dma_tag_t sc_dmatag; +}; + CFATTACH_DECL(obmem, sizeof(struct device), obmem_match, obmem_attach, NULL, NULL); +static int obmem_attached; + +static int obmem_bus_map(bus_space_tag_t, bus_type_t, bus_addr_t, bus_size_t, + int, vaddr_t, bus_space_handle_t *); +static paddr_t obmem_bus_mmap(bus_space_tag_t, bus_type_t, bus_addr_t, off_t, + int, int); + +static struct sun68k_bus_space_tag obmem_space_tag = { + NULL, /* cookie */ + NULL, /* parent bus space tag */ + obmem_bus_map, /* bus_space_map */ + NULL, /* bus_space_unmap */ + NULL, /* bus_space_subregion */ + NULL, /* bus_space_barrier */ + obmem_bus_mmap, /* bus_space_mmap */ + NULL, /* bus_intr_establish */ + NULL, /* bus_space_peek_N */ + NULL /* bus_space_poke_N */ +}; + static int obmem_match(struct device *parent, struct cfdata *cf, void *aux) { struct confargs *ca = aux; + if (obmem_attached) + return 0; + if (ca->ca_bustype != BUS_OBMEM) - return (0); - return(1); + return 0; + + if (ca->ca_name != NULL && strcmp(cf->cf_name, ca->ca_name) != 0) + return 0; + + return 1; } static void -obmem_attach(struct device *parent, struct device *self, void *args) +obmem_attach(struct device *parent, struct device *self, void *aux) { + struct confargs *ca = aux; + struct obmem_softc *sc = (void *)self; + struct confargs obma; + + obmem_attached = 1; + printf("\n"); + sc->sc_bustag = ca->ca_bustag; + sc->sc_dmatag = ca->ca_dmatag; + + obmem_space_tag.cookie = sc; + obmem_space_tag.parent = sc->sc_bustag; + + obma = *ca; + obma.ca_bustag = &obmem_space_tag; + /* We know ca_bustype == BUS_OBMEM */ - config_search_ia(bus_scan, self, "obmem", args); + config_search_ia(bus_scan, self, "obmem", &obma); +} + +int +obmem_bus_map(bus_space_tag_t t, bus_type_t btype, bus_addr_t paddr, + bus_size_t size, int flags, vaddr_t vaddr, bus_space_handle_t *hp) +{ + struct obmem_softc *sc = t->cookie; + + return bus_space_map2(sc->sc_bustag, PMAP_OBMEM, paddr, size, flags, + vaddr, hp); +} + +paddr_t +obmem_bus_mmap(bus_space_tag_t t, bus_type_t btype, bus_addr_t paddr, off_t off, + int prot, int flags) +{ + struct obmem_softc *sc = t->cookie; + + return bus_space_mmap2(sc->sc_bustag, PMAP_OBMEM, paddr, off, prot, + flags); } diff --git a/sys/arch/sun3/sun3/stub.c b/sys/arch/sun3/sun3/stub.c deleted file mode 100644 index c927473aad7..00000000000 --- a/sys/arch/sun3/sun3/stub.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: stub.c,v 1.21 2005/12/11 12:19:27 christos Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Adam Glass and Gordon W. Ross. - * - * 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. - */ - -/* - * Stubs to supply things needed when some options are OFF. - */ - -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: stub.c,v 1.21 2005/12/11 12:19:27 christos Exp $"); - -#include "opt_ddb.h" - -#include <sys/cdefs.h> -#include <sys/systm.h> - -#ifndef DDB -/* - * When DDB is included, cpu_Debugger() comes from db_interface.c - * otherwise we get the one compiled here. - */ -void -cpu_Debugger(void) -{ - __asm ("trap #15"); -} -#endif /* !DDB */ - diff --git a/sys/arch/sun3/sun3/sunmon.c b/sys/arch/sun3/sun3/sunmon.c index 62f95cd6239..1fc6b2e4899 100644 --- a/sys/arch/sun3/sun3/sunmon.c +++ b/sys/arch/sun3/sun3/sunmon.c @@ -1,4 +1,4 @@ -/* $NetBSD: sunmon.c,v 1.17 2005/12/24 22:45:40 perry Exp $ */ +/* $NetBSD: sunmon.c,v 1.18 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sunmon.c,v 1.17 2005/12/24 22:45:40 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunmon.c,v 1.18 2006/10/01 03:53:27 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -49,7 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: sunmon.c,v 1.17 2005/12/24 22:45:40 perry Exp $"); #include <sun3/sun3/machdep.h> #include <sun3/sun3/interreg.h> -#include <sun3/sun3/vector.h> +#include <sun68k/sun68k/vector.h> static void **sunmon_vbr; static void *sunmon_vcmd; /* XXX: always 0? */ diff --git a/sys/arch/sun3/sun3/vector.c b/sys/arch/sun3/sun3/vector.c deleted file mode 100644 index 997ed5f1097..00000000000 --- a/sys/arch/sun3/sun3/vector.c +++ /dev/null @@ -1,145 +0,0 @@ -/* $NetBSD: vector.c,v 1.25 2005/12/11 12:19:27 christos Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Adam Glass and Gordon W. Ross. - * - * 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. - */ - -/* - * The interrupt vector table. - */ - -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vector.c,v 1.25 2005/12/11 12:19:27 christos Exp $"); - -#include "opt_compat_netbsd.h" - -#include <sys/param.h> -#include <sys/systm.h> - -#include "vector.h" - -#define BADTRAP16 badtrap, badtrap, badtrap, badtrap, \ - badtrap, badtrap, badtrap, badtrap, \ - badtrap, badtrap, badtrap, badtrap, \ - badtrap, badtrap, badtrap, badtrap - -#define fpbsun fpfault -#define fpdz fpfault -#define fpinex fpfault -#define fpoperr fpfault -#define fpovfl fpfault -#define fpsnan fpfault -#define fpunfl fpfault - -void *vector_table[NVECTORS] = { - (void *)0xfffe000, /* 0: NOT USED (reset SP) */ - (void *)0xfef0000, /* 1: NOT USED (reset PC) */ - buserr, /* 2: bus error */ - addrerr, /* 3: address error */ - illinst, /* 4: illegal instruction */ - zerodiv, /* 5: zero divide */ - chkinst, /* 6: CHK instruction */ - trapvinst, /* 7: TRAPV instruction */ - privinst, /* 8: privilege violation */ - trace, /* 9: trace (single-step) */ - illinst, /* 10: line 1010 emulator */ - fpfline, /* 11: line 1111 emulator */ - badtrap, /* 12: unassigned, reserved */ - coperr, /* 13: coprocessor protocol violatio */ - fmterr, /* 14: format error */ - badtrap, /* 15: uninitialized interrupt vecto */ - badtrap, /* 16: unassigned, reserved */ - badtrap, /* 17: unassigned, reserved */ - badtrap, /* 18: unassigned, reserved */ - badtrap, /* 19: unassigned, reserved */ - badtrap, /* 20: unassigned, reserved */ - badtrap, /* 21: unassigned, reserved */ - badtrap, /* 22: unassigned, reserved */ - badtrap, /* 23: unassigned, reserved */ - _isr_autovec, /* 24: spurious interrupt */ - _isr_autovec, /* 25: level 1 interrupt autovector */ - _isr_autovec, /* 26: level 2 interrupt autovector */ - _isr_autovec, /* 27: level 3 interrupt autovector */ - _isr_autovec, /* 28: level 4 interrupt autovector */ - _isr_autovec, /* 29: level 5 interrupt autovector */ - _isr_autovec, /* 30: level 6 interrupt autovector */ - _isr_autovec, /* 31: level 7 interrupt autovector */ - trap0, /* 32: syscalls */ -#ifdef COMPAT_13 - trap1, /* 33: compat_13_sigreturn */ -#else - illinst, -#endif - trap2, /* 34: trace */ -#ifdef COMPAT_16 - trap3, /* 35: compat_16_sigreturn */ -#else - illinst, -#endif - illinst, /* 36: TRAP instruction vector */ - illinst, /* 37: TRAP instruction vector */ - illinst, /* 38: TRAP instruction vector */ - illinst, /* 39: TRAP instruction vector */ - illinst, /* 40: TRAP instruction vector */ - illinst, /* 41: TRAP instruction vector */ - illinst, /* 42: TRAP instruction vector */ - illinst, /* 43: TRAP instruction vector */ - trap12, /* 44: TRAP 12: cachectl */ - illinst, /* 45: TRAP instruction vector */ - illinst, /* 46: TRAP instruction vector */ - trap15, /* 47: TRAP 15: breakpoint */ - fpbsun, /* 48: FPCP branch/set on unordered */ - fpinex, /* 49: FPCP inexact result */ - fpdz, /* 50: FPCP divide by zero */ - fpunfl, /* 51: FPCP underflow */ - fpoperr, /* 52: FPCP operand error */ - fpovfl, /* 53: FPCP overflow */ - fpsnan, /* 54: FPCP signalling NAN */ - fpunsupp, /* 55: FPCP unimplemented data type */ - badtrap, /* 56: unassigned, reserved */ - badtrap, /* 57: unassigned, reserved */ - badtrap, /* 58: unassigned, reserved */ - badtrap, /* 59: unassigned, reserved */ - badtrap, /* 60: unassigned, reserved */ - badtrap, /* 61: unassigned, reserved */ - badtrap, /* 62: unassigned, reserved */ - badtrap, /* 63: unassigned, reserved */ - - /* 64-255: set later by isr_add_vectored() */ - - BADTRAP16, BADTRAP16, BADTRAP16, BADTRAP16, - BADTRAP16, BADTRAP16, BADTRAP16, BADTRAP16, - BADTRAP16, BADTRAP16, BADTRAP16, BADTRAP16, -}; diff --git a/sys/arch/sun3/sun3/vector.h b/sys/arch/sun3/sun3/vector.h deleted file mode 100644 index e55e06165dd..00000000000 --- a/sys/arch/sun3/sun3/vector.h +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: vector.h,v 1.15 2005/12/11 12:19:27 christos Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Adam Glass. - * - * 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. - */ - -#define NVECTORS 256 - -#define AUTOVEC_BASE 0x18 - -extern void *vector_table[]; - -void _isr_autovec(void); - -void addrerr(void); -void badtrap(void); -void buserr(void); -void chkinst(void); -void coperr(void); -void fmterr(void); -void fpfline(void); -void fpunsupp(void); -void illinst(void); -void privinst(void); -void trace(void); -void trap0(void); -void trap1(void); -void trap12(void); -void trap15(void); -void trap2(void); -void trap3(void); -void trapvinst(void); -void zerodiv(void); -void fpfault(void); diff --git a/sys/arch/sun3/sun3x/dvma.c b/sys/arch/sun3/sun3x/dvma.c index 2ade7af8910..b003476e841 100644 --- a/sys/arch/sun3/sun3x/dvma.c +++ b/sys/arch/sun3/sun3x/dvma.c @@ -1,4 +1,4 @@ -/* $NetBSD: dvma.c,v 1.30 2005/12/11 12:19:27 christos Exp $ */ +/* $NetBSD: dvma.c,v 1.31 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dvma.c,v 1.30 2005/12/11 12:19:27 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dvma.c,v 1.31 2006/10/01 03:53:27 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -92,7 +92,9 @@ __KERNEL_RCSID(0, "$NetBSD: dvma.c,v 1.30 2005/12/11 12:19:27 christos Exp $"); #include <uvm/uvm_extern.h> +#define _SUN68K_BUS_DMA_PRIVATE #include <machine/autoconf.h> +#include <machine/bus.h> #include <machine/cpu.h> #include <machine/dvma.h> #include <machine/pmap.h> @@ -292,3 +294,26 @@ dvma_free(void *addr, size_t size) /* XXX: need kmem address to free it... Oh well, we never call this anyway. */ } + +int +_bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs, + int nsegs, bus_size_t size, int flags) +{ + + panic("_bus_dmamap_load_raw(): not implemented yet."); +} + +int +_bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, + bus_size_t buflen, struct proc *p, int flags) +{ + + panic("_bus_dmamap_load(): not implemented yet."); +} + +void +_bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map) +{ + + panic("_bus_dmamap_unload(): not implemented yet."); +} diff --git a/sys/arch/sun3/sun3x/locore2.c b/sys/arch/sun3/sun3x/locore2.c index ae9af6c7a10..1abceab5863 100644 --- a/sys/arch/sun3/sun3x/locore2.c +++ b/sys/arch/sun3/sun3x/locore2.c @@ -1,4 +1,4 @@ -/* $NetBSD: locore2.c,v 1.31 2005/12/11 12:19:27 christos Exp $ */ +/* $NetBSD: locore2.c,v 1.32 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: locore2.c,v 1.31 2005/12/11 12:19:27 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: locore2.c,v 1.32 2006/10/01 03:53:27 tsutsui Exp $"); #include "opt_ddb.h" @@ -62,7 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: locore2.c,v 1.31 2005/12/11 12:19:27 christos Exp $" #include <sun3/sun3/interreg.h> #include <sun3/sun3/machdep.h> -#include <sun3/sun3/vector.h> +#include <sun68k/sun68k/vector.h> /* This is defined in locore.s */ extern char kernel_text[]; diff --git a/sys/arch/sun3/sun3x/obio.c b/sys/arch/sun3/sun3x/obio.c index a716bf79d28..38c2c6a2578 100644 --- a/sys/arch/sun3/sun3x/obio.c +++ b/sys/arch/sun3/sun3x/obio.c @@ -1,4 +1,4 @@ -/* $NetBSD: obio.c,v 1.26 2005/12/11 12:19:27 christos Exp $ */ +/* $NetBSD: obio.c,v 1.27 2006/10/01 03:53:27 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.26 2005/12/11 12:19:27 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.27 2006/10/01 03:53:27 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -46,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.26 2005/12/11 12:19:27 christos Exp $"); #include <uvm/uvm_extern.h> #include <machine/autoconf.h> +#include <machine/bus.h> #include <machine/mon.h> #include <machine/pte.h> @@ -58,17 +59,49 @@ static int obio_print(void *, const char *); static int obio_submatch(struct device *, struct cfdata *, const int *, void *); -CFATTACH_DECL(obio, sizeof(struct device), +struct obio_softc { + struct device sc_dev; + bus_space_tag_t sc_bustag; + bus_dma_tag_t sc_dmatag; +}; +CFATTACH_DECL(obio, sizeof(struct obio_softc), obio_match, obio_attach, NULL, NULL); +static int obio_attached; + +static int obio_bus_map(bus_space_tag_t, bus_type_t, bus_addr_t, bus_size_t, + int, vaddr_t, bus_space_handle_t *); +static paddr_t obio_bus_mmap(bus_space_tag_t, bus_type_t, bus_addr_t, + off_t, int, int); + +static struct sun68k_bus_space_tag obio_space_tag = { + NULL, /* cookie */ + NULL, /* parent bus space tag */ + obio_bus_map, /* bus_space_map */ + NULL, /* bus_space_unmap */ + NULL, /* bus_space_subregion */ + NULL, /* bus_space_barrier */ + obio_bus_mmap, /* bus_space_mmap */ + NULL, /* bus_intr_establish */ + NULL, /* bus_space_peek_N */ + NULL /* bus_space_poke_N */ +}; + static int obio_match(struct device *parent, struct cfdata *cf, void *aux) { struct confargs *ca = aux; + if (obio_attached) + return 0; + if (ca->ca_bustype != BUS_OBIO) - return (0); - return(1); + return 0; + + if (ca->ca_name != NULL && strcmp(cf->cf_name, ca->ca_name) != 0) + return 0; + + return 1; } /* @@ -80,7 +113,7 @@ obio_match(struct device *parent, struct cfdata *cf, void *aux) * In general, anything not already shown here should * be added at or near the end. */ -static int obio_alist[] = { +static paddr_t obio_alist[] = { /* This is used by the Ethernet and SCSI drivers. */ OBIO_IOMMU, @@ -130,19 +163,32 @@ static void obio_attach(struct device *parent, struct device *self, void *aux) { struct confargs *ca = aux; - int i; + struct obio_softc *sc = (void *)self; + struct confargs oba; + int i; + + obio_attached = 1; printf("\n"); + sc->sc_bustag = ca->ca_bustag; + sc->sc_dmatag = ca->ca_dmatag; + + obio_space_tag.cookie = sc; + obio_space_tag.parent = sc->sc_bustag; + + oba = *ca; + oba.ca_bustag = &obio_space_tag; + /* Configure these in the order listed above. */ for (i = 0; i < OBIO_ALIST_LEN; i++) { /* Our parent set ca->ca_bustype already. */ - ca->ca_paddr = obio_alist[i]; + oba.ca_paddr = obio_alist[i]; /* These are filled-in by obio_submatch. */ - ca->ca_intpri = -1; - ca->ca_intvec = -1; - (void) config_found_sm_loc(self, "obio", NULL, ca, obio_print, - obio_submatch); + oba.ca_intpri = -1; + oba.ca_intvec = -1; + (void)config_found_sm_loc(self, "obio", NULL, &oba, obio_print, + obio_submatch); } } @@ -253,6 +299,34 @@ obio_find_mapping(paddr_t pa, psize_t sz) } /* + * The similar function with the above but used by bus_space(9) + */ +int +find_prom_map(bus_addr_t pa, bus_type_t iospace, int sz, + bus_space_handle_t *hp) +{ + int i; + vsize_t off; + + off = pa & PGOFSET; + pa -= off; + sz += off; + + /* The saved mappings are all one page long. */ + if (sz > PAGE_SIZE) + return EINVAL; + + /* Linear search for it. The list is short. */ + for (i = 0; i < PROM_MAP_CNT; i++) { + if (pa == prom_mappings[i].pa) { + *hp = prom_mappings[i].va + off; + return 0; + } + } + return ENOENT; +} + +/* * Search the PROM page tables for OBIO mappings that * we would like to borrow. */ @@ -337,3 +411,23 @@ obio_init(void) */ intreg_init(); } + +int +obio_bus_map(bus_space_tag_t t, bus_type_t btype, bus_addr_t paddr, + bus_size_t size, int flags, vaddr_t vaddr, bus_space_handle_t *hp) +{ + struct obio_softc *sc = t->cookie; + + return bus_space_map2(sc->sc_bustag, PMAP_OBIO, paddr, size, + flags | _SUN68K_BUS_MAP_USE_PROM, vaddr, hp); +} + +paddr_t +obio_bus_mmap(bus_space_tag_t t, bus_type_t btype, bus_addr_t paddr, off_t off, + int prot, int flags) +{ + struct obio_softc *sc = t->cookie; + + return bus_space_mmap2(sc->sc_bustag, PMAP_OBIO, paddr, off, prot, + flags); +} diff --git a/sys/arch/sun68k/conf/files.sun68k b/sys/arch/sun68k/conf/files.sun68k index 459f62a6846..041bf861625 100644 --- a/sys/arch/sun68k/conf/files.sun68k +++ b/sys/arch/sun68k/conf/files.sun68k @@ -1,14 +1,14 @@ -# $NetBSD: files.sun68k,v 1.3 2006/09/30 13:43:08 tsutsui Exp $ +# $NetBSD: files.sun68k,v 1.4 2006/10/01 03:53:28 tsutsui Exp $ # # common sun68k configuration info # # Standard stuff -file arch/sun68k/sun68k/autoconf.c +file arch/sun68k/sun68k/autoconf.c _sun2_ # XXX not yet merged file arch/sun68k/sun68k/bus.c -file arch/sun68k/sun68k/ctrlsp.S -file arch/sun68k/sun68k/isr.c +file arch/sun68k/sun68k/ctrlsp.S !_sun3x_ +file arch/sun68k/sun68k/isr.c _sun2_ # XXX not yet merged file arch/sun68k/sun68k/stub.c file arch/sun68k/sun68k/vector.c @@ -20,13 +20,14 @@ file dev/sun/disksubr.c # # Bus types +# XXX not yet merged # -device mainbus {} -attach mainbus at root +#device mainbus {} +#attach mainbus at root # VME -include "dev/vme/files.vme" -device sun68kvme: vmebus -attach sun68kvme at mainbus -file arch/sun68k/sun68k/vme_sun68k.c sun68kvme +#include "dev/vme/files.vme" +#device sun68kvme: vmebus +#attach sun68kvme at mainbus +#file arch/sun68k/sun68k/vme_sun68k.c sun68kvme diff --git a/sys/arch/sun68k/include/bus.h b/sys/arch/sun68k/include/bus.h index 83dcc8e91b1..6dc65242de5 100644 --- a/sys/arch/sun68k/include/bus.h +++ b/sys/arch/sun68k/include/bus.h @@ -1,4 +1,4 @@ -/* $NetBSD: bus.h,v 1.11 2006/02/16 20:17:15 perry Exp $ */ +/* $NetBSD: bus.h,v 1.12 2006/10/01 03:53:28 tsutsui Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. @@ -789,6 +789,8 @@ bus_space_copy_region_8(bus_space_tag_t t, bus_space_handle_t h1, bus_size_t o1, #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) +int find_prom_map(bus_addr_t, bus_type_t, int, bus_space_handle_t *); + /*--------------------------------*/ /* diff --git a/sys/arch/sun68k/sun68k/bus.c b/sys/arch/sun68k/sun68k/bus.c index 3aeb60cd6a6..484ad6aaa65 100644 --- a/sys/arch/sun68k/sun68k/bus.c +++ b/sys/arch/sun68k/sun68k/bus.c @@ -1,4 +1,4 @@ -/* $NetBSD: bus.c,v 1.16 2006/09/30 13:54:53 tsutsui Exp $ */ +/* $NetBSD: bus.c,v 1.17 2006/10/01 03:53:28 tsutsui Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -160,7 +160,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.16 2006/09/30 13:54:53 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.17 2006/10/01 03:53:28 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -176,6 +176,7 @@ __KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.16 2006/09/30 13:54:53 tsutsui Exp $"); #include <machine/autoconf.h> #include <machine/bus.h> #include <machine/intr.h> +#include <machine/mon.h> #include <machine/pmap.h> #include <sun68k/sun68k/control.h> @@ -491,8 +492,6 @@ struct sun68k_bus_dma_tag mainbus_dma_tag = { /* * Base bus space handlers. */ -int sun68k_find_prom_map(bus_addr_t, bus_type_t, int, - bus_space_handle_t *); static int sun68k_bus_map(bus_space_tag_t, bus_type_t, bus_addr_t, bus_size_t, int, vaddr_t, bus_space_handle_t *); static int sun68k_bus_unmap(bus_space_tag_t, bus_space_handle_t, @@ -510,69 +509,6 @@ static int sun68k_bus_peek(bus_space_tag_t, bus_space_handle_t, static int sun68k_bus_poke(bus_space_tag_t, bus_space_handle_t, bus_size_t, size_t, uint32_t); -/* - * If we can find a mapping that was established by the PROM, use it. - */ -int -sun68k_find_prom_map(bus_addr_t pa, bus_type_t iospace, int len, - bus_space_handle_t *hp) -{ - u_long pf; - int pgtype; - u_long va, eva; - int sme; - u_long pte; - int saved_ctx; - - /* - * The mapping must fit entirely within one page. - */ - if ((((u_long)pa & PGOFSET) + len) > PAGE_SIZE) - return (EINVAL); - - pf = PA_PGNUM(pa); - pgtype = iospace << PG_MOD_SHIFT; - saved_ctx = kernel_context(); - - /* - * Walk the PROM address space, looking for a page with the - * mapping we want. - */ - for (va = SUN_MONSTART; va < SUN_MONEND; ) { - - /* - * Make sure this segment is mapped. - */ - sme = get_segmap(va); - if (sme == SEGINV) { - va += NBSG; - continue; /* next segment */ - } - - /* - * Walk the pages of this segment. - */ - for(eva = va + NBSG; va < eva; va += PAGE_SIZE) { - pte = get_pte(va); - - if ((pte & (PG_VALID | PG_TYPE)) == - (PG_VALID | pgtype) && - PG_PFNUM(pte) == pf) - { - /* - * Found the PROM mapping. - * note: preserve page offset - */ - *hp = (bus_space_handle_t)(va | ((u_long)pa & PGOFSET)); - restore_context(saved_ctx); - return (0); - } - } - } - restore_context(saved_ctx); - return (ENOENT); -} - int sun68k_bus_map(bus_space_tag_t t, bus_type_t iospace, bus_addr_t addr, bus_size_t size, int flags, vaddr_t vaddr, bus_space_handle_t *hp) @@ -585,7 +521,7 @@ sun68k_bus_map(bus_space_tag_t t, bus_type_t iospace, bus_addr_t addr, * and use a PROM mapping. */ if ((flags & _SUN68K_BUS_MAP_USE_PROM) != 0 && - sun68k_find_prom_map(addr, iospace, size, hp) == 0) + find_prom_map(addr, iospace, size, hp) == 0) return (0); /* |
