Index: build.sh =================================================================== RCS file: /cvsroot/src/build.sh,v retrieving revision 1.206 diff -u -p -u -p -r1.206 build.sh --- build.sh 13 Mar 2009 16:23:31 -0000 1.206 +++ build.sh 24 Jul 2009 07:06:18 -0000 @@ -238,6 +238,9 @@ initdefaults() do_iso_image=false do_iso_image_source=false do_params=false + do_mknative_gcc=false + do_mknative_gdb=false + do_mknative_binutils=false # Create scratch directory # @@ -806,7 +809,7 @@ parseoptions() usage ;; - makewrapper|cleandir|obj|tools|build|distribution|release|sets|sourcesets|syspkgs|params) + makewrapper|mknative_gcc|mknative_binutils|mknative_gdb|cleandir|obj|tools|build|distribution|release|sets|sourcesets|syspkgs|params) ;; iso-image) @@ -1364,6 +1367,62 @@ installworld() statusmsg "Successful installworld to ${dir}" } +mknative_base() +{ + buildtools + ${runcmd} cd "${TOP}" + ${runcmd} "${makewrapper}" do-distrib-dirs obj includes || + bomb "Failed to make and populate target system directories" + for dir in lib/csu gnu/lib/crtstuff4 gnu/lib/libgcc4 libc/libc lib/libdes lib + do + ${runcmd} cd "${TOP}/$dir" + ${runcmd} "${makewrapper}" obj includes + ${runcmd} "${makewrapper}" dependall install \ + MKLINT=no MKPROFILE=no MKSHARE=no || + bomb "Failed to build and install in $dir" + ${runcmd} cd "${TOP}" + done +} + +mknative_binutils() +{ + mknative_base + + ${runcmd} cd tools/binutils + ${runcmd} "${makewrapper}" obj || + bomb "Failed to make obj in tools/binutils" + ${runcmd} "${makewrapper}" obj native-binutils || + bomb "Failed to make native configuration for gcc" + statusmsg "mknative_binutils completed" +} + +mknative_gcc() +{ + mknative_base + + ${runcmd} cd tools/gcc + ${runcmd} "${makewrapper}" obj || + bomb "Failed to make obj in tools/gcc" + ${runcmd} "${makewrapper}" bootstrap-libgcc || + bomb "Failed to bootstrap libgcc" + + ${runcmd} cd tools/gcc + ${runcmd} "${makewrapper}" native-gcc || + bomb "Failed to make native configuration for gcc" + statusmsg "mknative_gcc completed" +} + +mknative_gdb() +{ + mknative_base + + ${runcmd} cd tools/gdb + ${runcmd} "${makewrapper}" obj || + bomb "Failed to make obj dir tools/gdb" + ${runcmd} "${makewrapper}" native-gdb || + bomb "Failed to make native configuration for gdb" + statusmsg "mknative_gdb completed" +} main() { @@ -1395,6 +1454,18 @@ main() # no-op ;; + mknative_binutils) + mknative_binutils + ;; + + mknative_gcc) + mknative_gcc + ;; + + mknative_gdb) + mknative_gdb + ;; + tools) buildtools ;; Index: gnu/dist/gcc4/gcc/config.gcc =================================================================== RCS file: /cvsroot/src/gnu/dist/gcc4/gcc/config.gcc,v retrieving revision 1.19 diff -u -p -u -p -r1.19 config.gcc --- gnu/dist/gcc4/gcc/config.gcc 11 Oct 2008 05:03:43 -0000 1.19 +++ gnu/dist/gcc4/gcc/config.gcc 24 Jul 2009 07:06:20 -0000 @@ -861,7 +861,7 @@ hppa*-*-linux* | parisc*-*-linux*) fi ;; hppa*-*-netbsd* | parisc*-*-netbsd*) - target_cpu_default="MASK_PA_11" + target_cpu_default="MASK_PA_11|MASK_NO_SPACE_REGS" tm_file="${tm_file} dbxelf.h elfos.h svr4.h netbsd.h netbsd-elf.h \ pa/pa-netbsd.h pa/pa32-regs.h pa/pa32-netbsd.h" tmake_file="${tmake_file} pa/t-netbsd" Index: gnu/dist/gdb6/gdb/sparc64nbsd-tdep.c =================================================================== RCS file: /cvsroot/src/gnu/dist/gdb6/gdb/sparc64nbsd-tdep.c,v retrieving revision 1.1.1.2 diff -u -p -u -p -r1.1.1.2 sparc64nbsd-tdep.c --- gnu/dist/gdb6/gdb/sparc64nbsd-tdep.c 2 Jul 2006 20:15:12 -0000 1.1.1.2 +++ gnu/dist/gdb6/gdb/sparc64nbsd-tdep.c 24 Jul 2009 07:06:20 -0000 @@ -237,6 +237,89 @@ sparc64nbsd_sigtramp_frame_sniffer (stru return NULL; } +static void +sparc64nbsd_sigtramp_cache_init (const struct tramp_frame *, + struct frame_info *, + struct trad_frame_cache *, + CORE_ADDR); +#if 0 +/* Under NetBSD/alpha signal handler invocations can be identified by the + designated code sequence that is used to return from a signal handler. + In particular, the return address of a signal handler points to the + following code sequences. */ +static const struct tramp_frame alphanbsd_sigtramp_sc1 = +{ + SIGTRAMP_FRAME, + 4, + { + { 0xa61e0000, 0xffffffff }, /* ldq a0, 0(sp) */ + { 0x23de0010, 0xffffffff }, /* lda sp, 16(sp) */ + { 0x201f0127, 0xffffffff }, /* lda v0, 295 */ + { 0x00000083, 0xffffffff }, /* call_pal callsys */ + { TRAMP_SENTINEL_INSN, -1 } + }, + alphanbsd_sigtramp_cache_init +}; +#endif + +/* The siginfo signal trampoline for NetBSD/sparc64 introduced in 2.0 */ +static const struct tramp_frame sparc64nbsd_sigtramp_si2 = +{ + SIGTRAMP_FRAME, + 4, + { + { 0x9003a92f, -1 }, /* add %sp, 0x92f, %o0 */ + { 0x82102134, -1 }, /* mov 0x134, %g1 */ + { 0x91d02000, -1 }, /* ta 0 */ + { 0x82102001, -1 }, /* mov 1, %g1*/ + { 0x91d02000, -1 }, /* ta 0 */ + { 0x01000000, -1 }, /* nop */ + { 0x01000000, -1 }, /* nop */ + { 0x01000000, -1 }, /* nop */ + { 0x81c3e008, -1 }, /* retl */ + { 0xae03c017, -1 }, /* add %o7, %l7, %l7 */ + { TRAMP_SENTINEL_INSN, -1 } + }, + sparc64nbsd_sigtramp_cache_init +}; + +static void +sparc64nbsd_sigtramp_cache_init (const struct tramp_frame *self, + struct frame_info *next_frame, + struct trad_frame_cache *this_cache, + CORE_ADDR func) +{ + struct gdbarch *gdbarch = get_frame_arch (next_frame); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + CORE_ADDR addr, sp; + int i; + + sp = frame_unwind_register_unsigned (next_frame, SP_REGNUM); + + +[%sp + BIAS] struct frame +[%sp + BIAS + CC64FSZ] siginfo_t +[%sp + BIAS + CC64FSZ + 128] ucontext_t + + /* get the ucontext pointer */ + addr = sp + 128 + 56; + + + for (i = 0; i < 32; i++, addr += ALPHA_REGISTER_SIZE) + { + trad_frame_set_reg_addr (this_cache, i, addr); + } + trad_frame_set_reg_addr (this_cache, ALPHA_PC_REGNUM, addr); + + /* Construct the frame ID using the function start. */ + trad_frame_set_id (this_cache, frame_id_build (sp, func)); +} + + + + + + static void sparc64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) Index: gnu/dist/gdb6/gdb/testsuite/gdb.asm/asm-source.exp =================================================================== RCS file: /cvsroot/src/gnu/dist/gdb6/gdb/testsuite/gdb.asm/asm-source.exp,v retrieving revision 1.1.1.2 diff -u -p -u -p -r1.1.1.2 asm-source.exp --- gnu/dist/gdb6/gdb/testsuite/gdb.asm/asm-source.exp 2 Jul 2006 20:16:45 -0000 1.1.1.2 +++ gnu/dist/gdb6/gdb/testsuite/gdb.asm/asm-source.exp 24 Jul 2009 07:06:21 -0000 @@ -146,6 +146,14 @@ switch -glob -- [istarget] { set asm-arch pa set debug-flags "-gdwarf-2" } + "hppa-*-netbsd*" { + set asm-arch pa + set debug-flags "-gdwarf-2" + } + "hppa-*-netbsd*" { + set asm-arch pa + set debug-flags "-gdwarf-2" + } "hppa64-*-hpux*" { set asm-arch pa64 set debug-flags "-gdwarf-2" @@ -162,6 +170,7 @@ if { "${asm-arch}" == "" } { # On NetBSD/ELF we need a special NetBSD-identifying note section. if { [istarget "*-*-netbsdelf*"] + || [istarget "hppa-*-netbsd*"] || [istarget "mips*-*-netbsd*"] || [istarget "powerpc-*-netbsd*"] || [istarget "x86_64-*-netbsd*"] } then { Index: lib/libc/arch/hppa/SYS.h =================================================================== RCS file: /cvsroot/src/lib/libc/arch/hppa/SYS.h,v retrieving revision 1.6 diff -u -p -u -p -r1.6 SYS.h --- lib/libc/arch/hppa/SYS.h 18 Nov 2007 13:25:39 -0000 1.6 +++ lib/libc/arch/hppa/SYS.h 24 Jul 2009 07:06:21 -0000 @@ -45,7 +45,8 @@ #define SYSCALL(x) !\ stw %rp, HPPA_FRAME_ERP(%sr0,%sp) !\ ldil L%SYSCALLGATE, %r1 !\ - ble 4(%sr7, %r1) !\ + mtsp %r0, %sr2 !\ + ble 4(%sr2, %r1) !\ ldi __CONCAT(SYS_,x), %t1 !\ .import __cerror, code !\ comb,<> %r0, %t1, __cerror !\ @@ -62,7 +63,8 @@ SYSEXIT(x) SYSENTRY(x) !\ stw %rp, HPPA_FRAME_ERP(%sr0,%sp) !\ ldil L%SYSCALLGATE, %r1 !\ - ble 4(%sr7, %r1) !\ + mtsp %r0, %sr2 !\ + ble 4(%sr2, %r1) !\ ldi __CONCAT(SYS_,y), %t1 !\ ldw HPPA_FRAME_ERP(%sr0,%sp), %rp !\ bv %r0(%rp) !\ Index: lib/libc/arch/hppa/gen/__sigsetjmp14.S =================================================================== RCS file: /cvsroot/src/lib/libc/arch/hppa/gen/__sigsetjmp14.S,v retrieving revision 1.2 diff -u -p -u -p -r1.2 __sigsetjmp14.S --- lib/libc/arch/hppa/gen/__sigsetjmp14.S 28 Apr 2008 20:22:55 -0000 1.2 +++ lib/libc/arch/hppa/gen/__sigsetjmp14.S 24 Jul 2009 07:06:21 -0000 @@ -49,7 +49,7 @@ /* grab _JBLEN */ #include -ENTRY(__sigsetjmp14,0) +LEAF_ENTRY(__sigsetjmp14) stw %arg1, (_JBLEN * 4)(%arg0) ; save mask at end of area add,<> %r0, %arg0, %r0 b,n _setjmp @@ -57,7 +57,7 @@ ENTRY(__sigsetjmp14,0) EXIT(__sigsetjmp14) -ENTRY(__siglongjmp14,0) +LEAF_ENTRY(__siglongjmp14) ldw (_JBLEN * 4)(%arg0), %r1 add,<> %r0, %r1, %r0 b,n _longjmp Index: lib/libc/arch/hppa/gen/flt_rounds.c =================================================================== RCS file: /cvsroot/src/lib/libc/arch/hppa/gen/flt_rounds.c,v retrieving revision 1.4 diff -u -p -u -p -r1.4 flt_rounds.c --- lib/libc/arch/hppa/gen/flt_rounds.c 24 Dec 2005 21:42:32 -0000 1.4 +++ lib/libc/arch/hppa/gen/flt_rounds.c 24 Jul 2009 07:06:21 -0000 @@ -26,6 +26,6 @@ __flt_rounds(void) { uint64_t fpsr; - __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr)); + __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr) : "memory"); return map[(fpsr >> 41) & 0x03]; } Index: lib/libc/arch/hppa/gen/fpgetmask.c =================================================================== RCS file: /cvsroot/src/lib/libc/arch/hppa/gen/fpgetmask.c,v retrieving revision 1.4 diff -u -p -u -p -r1.4 fpgetmask.c --- lib/libc/arch/hppa/gen/fpgetmask.c 24 Dec 2005 21:42:32 -0000 1.4 +++ lib/libc/arch/hppa/gen/fpgetmask.c 24 Jul 2009 07:06:21 -0000 @@ -19,6 +19,6 @@ fpgetmask(void) { uint64_t fpsr; - __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr)); + __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr) : "memory"); return ((fpsr >> 32) & 0x1f); } Index: lib/libc/arch/hppa/gen/fpgetround.c =================================================================== RCS file: /cvsroot/src/lib/libc/arch/hppa/gen/fpgetround.c,v retrieving revision 1.4 diff -u -p -u -p -r1.4 fpgetround.c --- lib/libc/arch/hppa/gen/fpgetround.c 24 Dec 2005 21:42:32 -0000 1.4 +++ lib/libc/arch/hppa/gen/fpgetround.c 24 Jul 2009 07:06:21 -0000 @@ -19,6 +19,6 @@ fpgetround(void) { uint64_t fpsr; - __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr)); + __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr) : "memory"); return ((fpsr >> 41) & 0x3); } Index: lib/libc/arch/hppa/gen/fpgetsticky.c =================================================================== RCS file: /cvsroot/src/lib/libc/arch/hppa/gen/fpgetsticky.c,v retrieving revision 1.4 diff -u -p -u -p -r1.4 fpgetsticky.c --- lib/libc/arch/hppa/gen/fpgetsticky.c 24 Dec 2005 21:42:32 -0000 1.4 +++ lib/libc/arch/hppa/gen/fpgetsticky.c 24 Jul 2009 07:06:21 -0000 @@ -19,6 +19,6 @@ fpgetsticky(void) { uint64_t fpsr; - __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr)); + __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr) : "memory"); return ((fpsr >> 59) & 0x1f); } Index: lib/libc/arch/hppa/sys/__vfork14.S =================================================================== RCS file: /cvsroot/src/lib/libc/arch/hppa/sys/__vfork14.S,v retrieving revision 1.5 diff -u -p -u -p -r1.5 __vfork14.S --- lib/libc/arch/hppa/sys/__vfork14.S 28 Apr 2008 20:22:56 -0000 1.5 +++ lib/libc/arch/hppa/sys/__vfork14.S 24 Jul 2009 07:06:21 -0000 @@ -32,7 +32,7 @@ #include #include "SYS.h" -ENTRY(__vfork14, 0) +ENTRY(__vfork14,0) /* * NB: __vfork14 is a tricky syscall. We can't save * any values on the stack, because the stack will be @@ -56,7 +56,8 @@ ENTRY(__vfork14, 0) copy %rp, %t4 ldil L%SYSCALLGATE, %r1 - ble 4(%sr7, %r1) + mtsp %r0, %sr2 + ble 4(%sr2, %r1) ldi SYS___vfork14, %t1 comb,<> %r0, %t1, __cerror copy %t4, %rp Index: lib/libc/arch/hppa/sys/brk.S =================================================================== RCS file: /cvsroot/src/lib/libc/arch/hppa/sys/brk.S,v retrieving revision 1.3 diff -u -p -u -p -r1.3 brk.S --- lib/libc/arch/hppa/sys/brk.S 6 Oct 2003 05:30:21 -0000 1.3 +++ lib/libc/arch/hppa/sys/brk.S 24 Jul 2009 07:06:21 -0000 @@ -51,7 +51,7 @@ __minbrk: .long end -ENTRY(_brk,0) +LEAF_ENTRY(_brk) #ifdef PIC addil LT%__minbrk, %r19 ldw RT%__minbrk(%r1), %r1 Index: lib/libc/arch/hppa/sys/fork.S =================================================================== RCS file: /cvsroot/src/lib/libc/arch/hppa/sys/fork.S,v retrieving revision 1.3 diff -u -p -u -p -r1.3 fork.S --- lib/libc/arch/hppa/sys/fork.S 6 Oct 2003 05:30:21 -0000 1.3 +++ lib/libc/arch/hppa/sys/fork.S 24 Jul 2009 07:06:21 -0000 @@ -39,7 +39,7 @@ RCSID("$NetBSD: fork.S,v 1.3 2003/10/06 05:30:21 matt Exp $") #endif /* LIBC_SCCS and not lint */ -ENTRY(__fork,0) +LEAF_ENTRY(__fork) SYSCALL(fork) addi -1, %ret1, %ret1 bv %r0(%rp) Index: lib/libc/arch/hppa/sys/getcontext.S =================================================================== RCS file: /cvsroot/src/lib/libc/arch/hppa/sys/getcontext.S,v retrieving revision 1.4 diff -u -p -u -p -r1.4 getcontext.S --- lib/libc/arch/hppa/sys/getcontext.S 28 Apr 2008 20:22:56 -0000 1.4 +++ lib/libc/arch/hppa/sys/getcontext.S 24 Jul 2009 07:06:21 -0000 @@ -40,7 +40,7 @@ WEAK_ALIAS(getcontext, _getcontext) #define _OFFSETOF_UC_GREGS (10 * 4) #define SZREG 4 -ENTRY(_getcontext, 0) +LEAF_ENTRY(_getcontext) SYSCALL(getcontext) stw %rp, (_OFFSETOF_UC_GREGS + _REG_PCOQH * SZREG)(%arg0) ldo 4(%rp), %r1 Index: lib/libc/arch/hppa/sys/pipe.S =================================================================== RCS file: /cvsroot/src/lib/libc/arch/hppa/sys/pipe.S,v retrieving revision 1.3 diff -u -p -u -p -r1.3 pipe.S --- lib/libc/arch/hppa/sys/pipe.S 6 Oct 2003 05:30:21 -0000 1.3 +++ lib/libc/arch/hppa/sys/pipe.S 24 Jul 2009 07:06:21 -0000 @@ -47,7 +47,7 @@ WEAK_ALIAS(pipe, _pipe) #endif -ENTRY(_pipe,0) +LEAF_ENTRY(_pipe) stw %arg0, HPPA_FRAME_ARG(0)(%sp) SYSCALL(pipe) ldw HPPA_FRAME_ARG(0)(%sp), %arg0 Index: lib/libpthread_dbg/pthread_dbg.c =================================================================== RCS file: /cvsroot/src/lib/libpthread_dbg/pthread_dbg.c,v retrieving revision 1.40 diff -u -p -u -p -r1.40 pthread_dbg.c --- lib/libpthread_dbg/pthread_dbg.c 7 Mar 2008 22:27:07 -0000 1.40 +++ lib/libpthread_dbg/pthread_dbg.c 24 Jul 2009 07:06:21 -0000 @@ -216,6 +216,7 @@ int td_thr_info(td_thread_t *thread, td_thread_info_t *info) { int tmp, val; + lwpid_t lid; val = READ(thread->proc, thread->addr, &tmp, sizeof(tmp)); if (val != 0) @@ -226,6 +227,11 @@ td_thr_info(td_thread_t *thread, td_thre info->thread_addr = thread->addr; if ((val = READ(thread->proc, + thread->addr + offsetof(struct __pthread_st, pt_lid), + &lid, sizeof(lid))) != 0) + return val; + info->thread_lid = lid; + if ((val = READ(thread->proc, thread->addr + offsetof(struct __pthread_st, pt_state), &tmp, sizeof(tmp))) != 0) return val; Index: lib/libpthread_dbg/pthread_dbg.h =================================================================== RCS file: /cvsroot/src/lib/libpthread_dbg/pthread_dbg.h,v retrieving revision 1.5 diff -u -p -u -p -r1.5 pthread_dbg.h --- lib/libpthread_dbg/pthread_dbg.h 2 Jun 2004 21:18:25 -0000 1.5 +++ lib/libpthread_dbg/pthread_dbg.h 24 Jul 2009 07:06:21 -0000 @@ -67,7 +67,8 @@ typedef struct td_thread_info_st { int thread_errno; sigset_t thread_sigmask; sigset_t thread_sigpending; - long pad[32]; + lwpid_t thread_lid; /* LWP id */ + long pad[31]; } td_thread_info_t; #define TD_STATE_UNKNOWN 0 Index: share/man/man4/com.4 =================================================================== RCS file: /cvsroot/src/share/man/man4/com.4,v retrieving revision 1.14 diff -u -p -u -p -r1.14 com.4 --- share/man/man4/com.4 13 May 2009 12:40:37 -0000 1.14 +++ share/man/man4/com.4 24 Jul 2009 07:06:22 -0000 @@ -60,6 +60,10 @@ .Ss HP 9000/300 and 400 Series .Cd "com* at dio? scode ?" .Cd "com* at frodo? offset ?" +.Ss HP 9000/700 and 800 Series +.Cd "com* at dino?" +.Cd "com* at gsc?" +.Cd "com* at ssio?" .Ss IBM PowerPC 4xx .Cd "com* at opb?" .Ss SPARC Index: share/man/man4/man4.hp700/asp.4 =================================================================== RCS file: /cvsroot/src/share/man/man4/man4.hp700/asp.4,v retrieving revision 1.1 diff -u -p -u -p -r1.1 asp.4 --- share/man/man4/man4.hp700/asp.4 22 Sep 2004 16:38:26 -0000 1.1 +++ share/man/man4/man4.hp700/asp.4 24 Jul 2009 07:06:22 -0000 @@ -25,7 +25,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd April 1, 1999 +.Dd April 5, 2008 .Dt ASP 4 hp700 .Os .Sh NAME @@ -73,7 +73,7 @@ bus controller: .It 720, 730, 750 .It -735/* +735/*, 755 (ASP2) .It 742i .It Index: share/man/man4/man4.hp700/gsc.4 =================================================================== RCS file: /cvsroot/src/share/man/man4/man4.hp700/gsc.4,v retrieving revision 1.1 diff -u -p -u -p -r1.1 gsc.4 --- share/man/man4/man4.hp700/gsc.4 22 Sep 2004 16:38:26 -0000 1.1 +++ share/man/man4/man4.hp700/gsc.4 24 Jul 2009 07:06:22 -0000 @@ -100,7 +100,7 @@ These are listed in .Xr pci 4 , .Xr eisa 4 , or -.Xr isa 4 , +.Xr isa 4 . .Sh SEE ALSO .Xr asp 4 , .Xr cpu 4 , Index: share/man/man9/pmap.9 =================================================================== RCS file: /cvsroot/src/share/man/man9/pmap.9,v retrieving revision 1.37 diff -u -p -u -p -r1.37 pmap.9 --- share/man/man9/pmap.9 9 Dec 2008 20:49:40 -0000 1.37 +++ share/man/man9/pmap.9 24 Jul 2009 07:06:23 -0000 @@ -301,8 +301,8 @@ and .Fn pmap_kremove functions so that the .Nm -implementation need not block interrupts when manipulating data -structures or holding locks. +implementation need not block interrupts nor hold locks when manipulating +data structures. .Pp Also note that the modified/referenced information must be tracked on a per-page basis; they are not attributes of a mapping, but attributes Index: share/mk/bsd.lib.mk =================================================================== RCS file: /cvsroot/src/share/mk/bsd.lib.mk,v retrieving revision 1.298 diff -u -p -u -p -r1.298 bsd.lib.mk --- share/mk/bsd.lib.mk 10 Apr 2009 16:16:12 -0000 1.298 +++ share/mk/bsd.lib.mk 24 Jul 2009 07:06:23 -0000 @@ -483,7 +483,6 @@ lib${LIB}_pic.a:: ${SOBJS} __archivebuil lib${LIB}_g.a:: ${GOBJS} __archivebuild - _LIBLDOPTS= .if ${SHLIBDIR} != "/usr/lib" _LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \ @@ -514,6 +513,11 @@ LDADD+= -lgcc_pic .if ${LIBISCXX} != "no" LIBCC:= ${CXX} +.if ${USE_LIBSTDCXX} == "no" +_SUPCXX= -lsupc++ -lm +.else +_SUPCXX= -lstdc++ -lm +.endif .else LIBCC:= ${CC} .endif Index: sys/arch/arm/arm32/cpuswitch.S =================================================================== RCS file: /cvsroot/src/sys/arch/arm/arm32/cpuswitch.S,v retrieving revision 1.59 diff -u -p -u -p -r1.59 cpuswitch.S --- sys/arch/arm/arm32/cpuswitch.S 19 Nov 2008 06:34:21 -0000 1.59 +++ sys/arch/arm/arm32/cpuswitch.S 24 Jul 2009 07:06:23 -0000 @@ -345,6 +345,7 @@ ENTRY(lwp_trampoline) */ bl _C_LABEL(lwp_startup) +ENTRY(setfunc_trampoline) mov r0, r5 mov r1, sp mov lr, pc Index: sys/arch/arm/arm32/vm_machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/arm/arm32/vm_machdep.c,v retrieving revision 1.49 diff -u -p -u -p -r1.49 vm_machdep.c --- sys/arch/arm/arm32/vm_machdep.c 14 Mar 2009 21:04:05 -0000 1.49 +++ sys/arch/arm/arm32/vm_machdep.c 24 Jul 2009 07:06:24 -0000 @@ -79,6 +79,7 @@ int process_read_regs(struct proc *p, st int process_read_fpregs(struct proc *p, struct fpreg *regs); void lwp_trampoline(void); +void setfunc_trampoline(void); /* * Special compilation symbols: @@ -112,7 +113,7 @@ cpu_setfunc(struct lwp *l, void (*func)( sf->sf_r4 = (u_int)func; sf->sf_r5 = (u_int)arg; sf->sf_sp = (u_int)tf; - sf->sf_pc = (u_int)lwp_trampoline; + sf->sf_pc = (u_int)setfunc_trampoline; pcb->pcb_un.un_32.pcb32_sp = (u_int)sf; } @@ -133,6 +134,7 @@ cpu_lwp_fork(struct lwp *l1, struct lwp void (*func)(void *), void *arg) { struct pcb *pcb = &l2->l_addr->u_pcb; + struct switchframe *sf; struct trapframe *tf; #ifdef PMAP_DEBUG @@ -200,7 +202,13 @@ cpu_lwp_fork(struct lwp *l1, struct lwp if (stack != NULL) tf->tf_usr_sp = (u_int)stack + stacksize; - cpu_setfunc(l2, func, arg); + sf = (struct switchframe *)tf - 1; + + sf->sf_r4 = (u_int)func; + sf->sf_r5 = (u_int)arg; + sf->sf_sp = (u_int)tf; + sf->sf_pc = (u_int)lwp_trampoline; + pcb->pcb_un.un_32.pcb32_sp = (u_int)sf; } /* Index: sys/arch/ews4800mips/sbd/if_iee_sbdio.c =================================================================== RCS file: /cvsroot/src/sys/arch/ews4800mips/sbd/if_iee_sbdio.c,v retrieving revision 1.9 diff -u -p -u -p -r1.9 if_iee_sbdio.c --- sys/arch/ews4800mips/sbd/if_iee_sbdio.c 10 May 2009 04:26:19 -0000 1.9 +++ sys/arch/ews4800mips/sbd/if_iee_sbdio.c 24 Jul 2009 07:06:24 -0000 @@ -147,12 +147,12 @@ iee_sbdio_cmd(struct iee_softc *sc, uint int iee_sbdio_reset(struct iee_softc *sc) { -#define IEE_ISCP_BUSSY 0x1 +#define IEE_ISCP_BUSY 0x1 int n, retry = 8; uint32_t cmd, ack; /* Make sure the busy byte is set and the cache is flushed. */ - SC_ISCP(sc)->iscp_bussy = IEE_ISCP_BUSSY; + SC_ISCP(sc)->iscp_busy = IEE_ISCP_BUSY; IEE_ISCPSYNC(sc, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); /* Setup the PORT Command with pointer to SCP. */ @@ -168,7 +168,7 @@ iee_sbdio_reset(struct iee_softc *sc) /* Wait for the chip to initialize and read SCP and ISCP. */ for (n = 0 ; n < retry; n++) { IEE_ISCPSYNC(sc, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); - ack = SC_ISCP(sc)->iscp_bussy; + ack = SC_ISCP(sc)->iscp_busy; IEE_ISCPSYNC(sc, BUS_DMASYNC_PREREAD); if (ack != IEE_ISCP_BUSSY) { break; Index: sys/arch/hp700/conf/GENERIC =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/conf/GENERIC,v retrieving revision 1.90 diff -u -p -u -p -r1.90 GENERIC --- sys/arch/hp700/conf/GENERIC 5 Jun 2009 07:35:29 -0000 1.90 +++ sys/arch/hp700/conf/GENERIC 24 Jul 2009 07:06:24 -0000 @@ -72,7 +72,7 @@ options DDB # in-kernel debugger options DDB_HISTORY_SIZE=512 # enable history editing in DDB #options KGDB # remote debugger #options KGDB_DEVNAME="\"com\"",KGDBADDR=0xf0822000,KGDBRATE=9600 -#makeoptions DEBUG="-g" # compile full symbol table +makeoptions DEBUG="-g" # compile full symbol table # Compatibility options options COMPAT_20 # compatability with NetBSD 2.0, @@ -105,7 +105,7 @@ file-system UMAPFS # NULLFS + uid and file-system UNION # union file system file-system CODA # Coda File System; also needs vcoda (below) file-system PTYFS # /dev/pts/N support -#file-system TMPFS # Efficient memory file-system +file-system TMPFS # Efficient memory file-system #file-system UDF # experimental - OSTA UDF CD/DVD file-system # File system options @@ -156,6 +156,7 @@ options IPFILTER_LOOKUP # ippool(8) sup # These options enable verbose messages for several subsystems. # Warning, these may compile large string tables into the kernel! options GSCVERBOSE # verbose GSC device autoconfig messages +options PCIVERBOSE # verbose PCI device autoconfig messages options EISAVERBOSE # verbose EISA device autoconfig messages options MIIVERBOSE # verbose PHY autoconfig messages options SCSIVERBOSE # human readable SCSI error messages @@ -227,6 +228,8 @@ power0 at mainbus0 # power/fail manager # STI graphics sti* at mainbus0 # [H]CRX-{8,24,48}[Z] and Visualize graphics sti* at phantomas? # [H]CRX-{8,24,48}[Z] and Visualize graphics +sti* at uturn? +sti* at pci? # EG-PCI, FX* # Basic Bus Support lasi* at mainbus0 # LASI host adapter ( LSI PN??? ) @@ -250,30 +253,30 @@ gsc* at wax? # {725,715}/{64,80,100}, #weisa* at gsc? # C*, B* # Uturn/U2 IOA -#uturn0 at mainbus0 # U2/UTurn Runway IOA -#uturn1 at mainbus0 -#lasi* at uturn? # LASI on [CJ]* -#dino* at uturn? # PCI bus bridge -#sti* at uturn? # -#wax* at uturn? # Wax on C* - -#gecko* at uturn? # GeckoBOA -#lasi* at gecko? # LASI -#dino* at gecko? # PCI bus bridge -#wax* at gecko? # Wax GSC to GSC Bus Adapter +uturn0 at mainbus0 # U2/UTurn Runway IOA +uturn1 at mainbus0 +lasi* at uturn? # LASI on [CJ]* +dino* at uturn? # PCI bus bridge +sti* at uturn? # +wax* at uturn? # Wax on C* + +gecko* at uturn? # GeckoBOA +lasi* at gecko? # LASI +dino* at gecko? # PCI bus bridge +wax* at gecko? # Wax GSC to GSC Bus Adapter # Astro memory & I/O controller -#astro* at mainbus0 # Astro memory & I/O controller -#elroy* at astro? +astro* at mainbus0 # Astro memory & I/O controller +elroy* at astro? # PCI bus support -#pci* at elroy? +pci* at elroy? pci* at dino? com* at dino? ppb* at pci? dev ? function ? pci* at ppb? -#ssio* at pci? +ssio* at pci? # EISA bus support eisa* at mongoose? @@ -335,9 +338,10 @@ lpt* at puc? port ? # || ports on "uni # GSC SCSI controllers oosiop* at gsc? # NCR 53c700 osiop* at gsc? flags 0x00000 # NCR 53c710 -siop* at gsc? irq 3 # NCR 53c720 (Fast/Wide) -siop* at mainbus0 irq 3 # NCR 53c720 (Fast/Wide) -siop* at phantomas? irq 3 # NCR 53c720 (Fast/Wide) +siop* at gsc? # NCR 53c720 (Fast/Wide) +siop* at mainbus0 # NCR 53c720 (Fast/Wide) +siop* at phantomas? # NCR 53c720 (Fast/Wide) +siop* at uturn? # NCR 53c720 (Fast/Wide) # PCI SCSI controllers adv* at pci? dev ? function ? # AdvanSys 1200[A,B], 9xx[U,UA] SCSI Index: sys/arch/hp700/conf/Makefile.hp700 =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/conf/Makefile.hp700,v retrieving revision 1.15 diff -u -p -u -p -r1.15 Makefile.hp700 --- sys/arch/hp700/conf/Makefile.hp700 8 May 2009 09:33:57 -0000 1.15 +++ sys/arch/hp700/conf/Makefile.hp700 24 Jul 2009 07:06:24 -0000 @@ -31,8 +31,16 @@ GENASSYM_CONF= ${HP700}/hp700/genassym.c ## ## (2) compile settings ## +.if ${IDENT:M-DHP7000_CPU} != "" +CFLAGS+= -mpa-risc-1-0 +.elif ${IDENT:M-DHP8*_CPU} != "" +CFLAGS+= -mpa-risc-2-0 +.else +CFLAGS+= -mpa-risc-1-1 +.endif + CPPFLAGS+= -Dhppa -Dhp700 -CFLAGS+= -mpa-risc-1-1 -msoft-float -mdisable-fpregs +CFLAGS+= -msoft-float -mdisable-fpregs .include "${HPPA}/spmath/Makefile.inc" Index: sys/arch/hp700/conf/files.hp700 =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/conf/files.hp700,v retrieving revision 1.22 diff -u -p -u -p -r1.22 files.hp700 --- sys/arch/hp700/conf/files.hp700 28 May 2009 08:41:29 -0000 1.22 +++ sys/arch/hp700/conf/files.hp700 24 Jul 2009 07:06:24 -0000 @@ -146,7 +146,8 @@ file arch/hp700/dev/elroy.c elroy file arch/hp700/dev/apic.c elroy attach sti at gedoens with sti_gedoens -file arch/hp700/dev/sti_sgc.c sti_gedoens +file arch/hp700/dev/sti_sgc.c sti_gedoens +file arch/hp700/dev/sti_pci_machdep.c sti_pci attach siop at gedoens with siop_gedoens file arch/hp700/dev/siop_sgc.c siop_gedoens Index: sys/arch/hp700/dev/apic.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/dev/apic.c,v retrieving revision 1.3 diff -u -p -u -p -r1.3 apic.c --- sys/arch/hp700/dev/apic.c 7 May 2009 15:34:49 -0000 1.3 +++ sys/arch/hp700/dev/apic.c 24 Jul 2009 07:06:25 -0000 @@ -241,16 +241,14 @@ apic_intr(void *v) if (iv->handler(iv->arg)) { if (iv->cnt) iv->cnt->ev_count++; - else - claimed = 1; + /* Signal EOI. */ + elroy_write32(&r->apic_eoi, + htole32((31 - APIC_INT_IRQ(iv->ih)) & APIC_ENT0_VEC)); + claimed = 1; } iv = iv->next; } - /* Signal EOI. */ - elroy_write32(&r->apic_eoi, - htole32((31 - APIC_INT_IRQ(iv->ih)) & APIC_ENT0_VEC)); - return (claimed); } @@ -260,15 +258,10 @@ apic_intr(void *v) void apic_get_int_tbl(struct elroy_softc *sc) { - struct pdc_pat_io_num int_tbl_sz PDC_ALIGNMENT; - struct pdc_pat_pci_rt int_tbl[MAX_INT_TBL_SZ] PDC_ALIGNMENT; + static struct pdc_pat_io_num int_tbl_sz PDC_ALIGNMENT; + static struct pdc_pat_pci_rt int_tbl[MAX_INT_TBL_SZ] PDC_ALIGNMENT; size_t size; - /* - * XXX int_tbl should not be allocated on the stack, but we need a - * 1:1 mapping, and malloc doesn't provide that. - */ - if (pdc_call((iodcio_t)pdc, 0, PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL_SZ, &int_tbl_sz, 0, 0, 0, 0, 0)) return; Index: sys/arch/hp700/dev/astro.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/dev/astro.c,v retrieving revision 1.5 diff -u -p -u -p -r1.5 astro.c --- sys/arch/hp700/dev/astro.c 8 May 2009 09:33:57 -0000 1.5 +++ sys/arch/hp700/dev/astro.c 24 Jul 2009 07:06:25 -0000 @@ -730,14 +730,13 @@ iommu_enter(struct astro_softc *sc, bus_ } #endif - mtsp(HPPA_SID_KERNEL, 1); - __asm volatile("lci 0(%%sr1, %1), %0" : "=r" (ci) : "r" (va)); + lci(va, ci); tte = (pa & IOTTE_PAMASK) | ((ci >> 12) & IOTTE_CI); tte |= IOTTE_V; *tte_ptr = htole64(tte); - __asm volatile("fdc 0(%%sr1, %0)\n\tsync" : : "r" (tte_ptr)); + fdcache(HPPA_SID_KERNEL, *tte_ptr, sizeof(*tte_ptr)); } /* Index: sys/arch/hp700/dev/com_dino.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/dev/com_dino.c,v retrieving revision 1.8 diff -u -p -u -p -r1.8 com_dino.c --- sys/arch/hp700/dev/com_dino.c 18 May 2009 05:13:26 -0000 1.8 +++ sys/arch/hp700/dev/com_dino.c 24 Jul 2009 07:06:25 -0000 @@ -42,6 +42,8 @@ #include #include +#include + void *dino_intr_establish(void *sc, int irq, int pri, int (*handler)(void *v), void *arg); @@ -138,7 +140,7 @@ com_dino_attach(device_t parent, device_ com_attach_subr(sc); - ca->ca_irq = 10; + ca->ca_irq = DINO_INTR_COM; sc_comdino->sc_ih = dino_intr_establish(sc_dino, ca->ca_irq, IPL_TTY, comintr, sc); Index: sys/arch/hp700/dev/cpudevs =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/dev/cpudevs,v retrieving revision 1.5 diff -u -p -u -p -r1.5 cpudevs --- sys/arch/hp700/dev/cpudevs 30 Apr 2009 07:01:26 -0000 1.5 +++ sys/arch/hp700/dev/cpudevs 24 Jul 2009 07:06:25 -0000 @@ -205,8 +205,8 @@ board HP782_J2240 0x5b5 782/J2240 (Summi board HP800K 0x5b6 800/K580 (DragonHawk U+ 240 DC3) #board HP800K? 0x5b7 800/K380 (DragonHawk U+ 240 DC3-) #board 0x5b8 SPP2250 240MHz processor -board HP821 0x5b9 821/D350/R350 (UltraLight 1w U+/240) -board HP800D 0x5ba 800/D390/R390 (UltraLight 2w U+/240) +board HP821 0x5b9 821/D350/R350 (UltraLight 1w U+/240) # {HPHW_NPROC,0x5B9,0x4,0x81,"UL 1w U+/240 (350/550)"}, matt's d390 +board HP800D 0x5ba 800/D390/R390 (UltraLight 2w U+/240) # {HPHW_NPROC,0x5BA,0x4,0x91,"UL 2w U+/240 (350/550)"}, board HP785_C3000 0x5bb 785/C3000 (AllegroHigh W) board HP785_B1000 0x5bc 785/B1000 (AllegroLow W) board HP785_J5000 0x5bd 785/J5000 (Forte W 2w) Index: sys/arch/hp700/dev/dino.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/dev/dino.c,v retrieving revision 1.14 diff -u -p -u -p -r1.14 dino.c --- sys/arch/hp700/dev/dino.c 23 Jul 2009 13:34:26 -0000 1.14 +++ sys/arch/hp700/dev/dino.c 24 Jul 2009 07:06:26 -0000 @@ -1,9 +1,9 @@ /* $NetBSD: dino.c,v 1.14 2009/07/23 13:34:26 skrll Exp $ */ -/* $OpenBSD: dino.c,v 1.5 2004/02/13 20:39:31 mickey Exp $ */ +/* $OpenBSD: dino.c,v 1.25 2009/03/30 21:24:57 kettenis Exp $ */ /* - * Copyright (c) 2003 Michael Shalayeff + * Copyright (c) 2003-2005 Michael Shalayeff * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,56 +56,14 @@ __KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.1 #include #include +#include + #define DINO_MEM_CHUNK 0x800000 +#define DINO_MEM_WINDOW (2 * DINO_MEM_CHUNK) /* from machdep.c */ extern struct extent *hp700_io_extent; -struct dino_regs { - uint32_t pad0; /* 0x000 */ - uint32_t iar0; /* 0x004 rw intr addr reg 0 */ - uint32_t iodc; /* 0x008 rw iodc data/addr */ - uint32_t irr0; /* 0x00c r intr req reg 0 */ - uint32_t iar1; /* 0x010 rw intr addr reg 1 */ - uint32_t irr1; /* 0x014 r intr req reg 1 */ - uint32_t imr; /* 0x018 rw intr mask reg */ - uint32_t ipr; /* 0x01c rw intr pending reg */ - uint32_t toc_addr; /* 0x020 rw TOC addr reg */ - uint32_t icr; /* 0x024 rw intr control reg */ - uint32_t ilr; /* 0x028 r intr level reg */ - uint32_t pad1; /* 0x02c */ - uint32_t io_command; /* 0x030 w command register */ - uint32_t io_status; /* 0x034 r status register */ - uint32_t io_control; /* 0x038 rw control register */ - uint32_t pad2; /* 0x03c AUX registers follow */ - uint32_t io_gsc_err_addr;/* 0x040 GSC error address */ - uint32_t io_err_info; /* 0x044 error info register */ - uint32_t io_pci_err_addr;/* 0x048 PCI error address */ - uint32_t pad3[4]; /* 0x04c */ - uint32_t io_fbb_en; /* 0x05c fast back2back enable reg */ - uint32_t io_addr_en; /* 0x060 address enable reg */ - uint32_t pci_addr; /* 0x064 PCI conf/io/mem addr reg */ - uint32_t pci_conf_data; /* 0x068 PCI conf data reg */ - uint32_t pci_io_data; /* 0x06c PCI io data reg */ - uint32_t pci_mem_data; /* 0x070 PCI memory data reg */ - uint32_t pad4[0x740/4]; /* 0x074 */ - uint32_t gsc2x_config; /* 0x7b4 GSC2X config reg */ - uint32_t pad5[0x48/4]; /* 0x7b8: BSRS registers follow */ - uint32_t gmask; /* 0x800 GSC arbitration mask */ - uint32_t pamr; /* 0x804 PCI arbitration mask */ - uint32_t papr; /* 0x808 PCI arbitration priority */ - uint32_t damode; /* 0x80c PCI arbitration mode */ - uint32_t pcicmd; /* 0x810 PCI command register */ - uint32_t pcists; /* 0x814 PCI status register */ - uint32_t pad6; /* 0x818 */ - uint32_t mltim; /* 0x81c PCI master latency timer */ - uint32_t brdg_feat; /* 0x820 PCI bridge feature enable */ - uint32_t pciror; /* 0x824 PCI read optimization reg */ - uint32_t pciwor; /* 0x828 PCI write optimization reg */ - uint32_t pad7; /* 0x82c */ - uint32_t tltim; /* 0x830 PCI target latency reg */ -}; - struct dino_softc { device_t sc_dv; @@ -114,7 +72,6 @@ struct dino_softc { struct hp700_int_reg sc_int_reg; bus_space_tag_t sc_bt; bus_space_handle_t sc_bh; - bus_space_handle_t sc_memh; bus_dma_tag_t sc_dmat; volatile struct dino_regs *sc_regs; @@ -125,6 +82,8 @@ struct dino_softc { struct hppa_bus_space_tag sc_memt; int sc_memrefcount[30]; struct hppa_bus_dma_tag sc_dmatag; + + uint32_t sc_ioshadow; /* XXX */ }; int dinomatch(device_t, struct cfdata *, void *); @@ -134,7 +93,6 @@ static void dino_callback(device_t, stru CFATTACH_DECL_NEW(dino, sizeof(struct dino_softc), dinomatch, dinoattach, NULL, NULL); - void dino_attach_hook(device_t, device_t, struct pcibus_attach_args *); void dino_enable_bus(struct dino_softc *, int); @@ -329,9 +287,18 @@ dino_conf_read(void *v, pcitag_t tag, in struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; pcireg_t data; + uint32_t pamr; + + /* fix arbitration errata by disabling all pci devs on config read */ + pamr = r->pamr; + r->pamr = 0; r->pci_addr = tag | reg; data = r->pci_conf_data; + + /* restore arbitration */ + r->pamr = pamr; + return le32toh(data); } @@ -341,28 +308,34 @@ dino_conf_write(void *v, pcitag_t tag, i struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; pcireg_t data1; + uint32_t pamr; - /* fix coalescing config writes errata by interleaving w/ a read */ - r->pci_addr = tag | PCI_ID_REG; - data1 = r->pci_conf_data; + /* fix arbitration errata by disabling all pci devs on config read */ + pamr = r->pamr; + r->pamr = 0; r->pci_addr = tag | reg; r->pci_conf_data = htole32(data); + /* fix coalescing config and io writes by interleaving w/ a read */ r->pci_addr = tag | PCI_ID_REG; data1 = r->pci_conf_data; + + /* restore arbitration */ + r->pamr = pamr; } int dino_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) { - pci_chipset_tag_t pc = pa->pa_pc; - pcitag_t tag = pa->pa_tag; - pcireg_t reg; - - reg = pci_conf_read(pc, tag, PCI_INTERRUPT_REG); - *ihp = PCI_INTERRUPT_LINE(reg); - return *ihp < 0; + int line = pa->pa_intrline; + + if (line == 0xff) + return 1; + + *ihp = line; + + return 0; } const char * @@ -383,6 +356,7 @@ dino_intr_establish(void *v, pci_intr_ha { struct dino_softc *sc = v; + return hp700_intr_establish(sc->sc_dv, pri, handler, arg, &sc->sc_int_reg, ih); } @@ -394,36 +368,6 @@ dino_intr_disestablish(void *v, void *co } -#if NCARDBUS > 0 -void * -dino_alloc_parent(device_t self, struct pci_attach_args *pa, int io) -{ - struct dino_softc *sc = pa->pa_pc->_cookie; - struct extent *ex; - bus_space_tag_t tag; - bus_addr_t start; - bus_size_t size; - - if (io) { - ex = sc->sc_ioex; - tag = pa->pa_iot; - start = 0xa000; - size = 0x1000; - } else { - ex = hp700_io_extent; - tag = pa->pa_memt; - start = ex->ex_start; /* XXX or 0xf0800000? */ - size = DINO_MEM_CHUNK; - } - - if (extent_alloc_subregion(ex, start, ex->ex_end, size, size, - EX_NOBOUNDARY, EX_NOWAIT, &start)) - return NULL; - extent_free(ex, start, size, EX_NOWAIT); - return rbus_new_root_share(tag, ex, start, size, start); -} -#endif - int dino_iomap(void *v, bus_addr_t bpa, bus_size_t size, int flags, bus_space_handle_t *bshp) @@ -509,7 +453,7 @@ dino_memalloc(void *v, bus_addr_t rstart int i, error; /* - * Allow allocation only when PCI MEM is already maped. + * Allow allocation only when PCI MEM is already mapped. * Needed to avoid allocation of I/O space used by devices that * have no driver in the current kernel. * Dino can map PCI MEM in the range 0xf0800000..0xff800000 only. @@ -563,12 +507,45 @@ dino_barrier(void *v, bus_space_handle_t sync_caches(); } +#if NCARDBUS > 0 +void * +dino_alloc_parent(device_t self, struct pci_attach_args *pa, int io) +{ + struct dino_softc *sc = pa->pa_pc->_cookie; + struct extent *ex; + bus_space_tag_t tag; + bus_addr_t start; + bus_size_t size; + + if (io) { + ex = sc->sc_ioex; + tag = pa->pa_iot; + start = 0xa000; + size = 0x1000; + } else { + ex = hp700_io_extent; + tag = pa->pa_memt; + start = ex->ex_start; /* XXX or 0xf0800000? */ + size = DINO_MEM_CHUNK; + } + + if (extent_alloc_subregion(ex, start, ex->ex_end, size, size, + EX_NOBOUNDARY, EX_NOWAIT, &start)) + return NULL; + extent_free(ex, start, size, EX_NOWAIT); + return rbus_new_root_share(tag, ex, start, size, start); +} +#endif + void* dino_vaddr(void *v, bus_space_handle_t h) { struct dino_softc *sc = v; - return bus_space_vaddr(sc->sc_bt, h); + if (h & 0xf0000000) + return bus_space_vaddr(sc->sc_bt, h); + else + return NULL; } paddr_t @@ -587,7 +564,7 @@ dino_r1(void *v, bus_space_handle_t h, b struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; return *((volatile uint8_t *)&r->pci_io_data + (h & 3)); } } @@ -596,24 +573,20 @@ uint16_t dino_r2(void *v, bus_space_handle_t h, bus_size_t o) { volatile uint16_t *p; - volatile uint16_t d; h += o; - if (h & 0xf0000000) { + if (h & 0xf0000000) p = (volatile uint16_t *)h; - d = le16toh(*p); - } else { + else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile uint16_t *)&r->pci_io_data; if (h & 2) p++; - d = le16toh(*p); } - - return d; + return le16toh(*p); } uint32_t @@ -655,7 +628,7 @@ dino_w1(void *v, bus_space_handle_t h, b struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; *((volatile uint8_t *)&r->pci_io_data + (h & 3)) = vv; } } @@ -672,7 +645,7 @@ dino_w2(void *v, bus_space_handle_t h, b struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile uint16_t *)&r->pci_io_data; if (h & 2) p++; @@ -702,7 +675,7 @@ dino_w8(void *v, bus_space_handle_t h, b { h += o; if (h & 0xf0000000) - *(volatile uint64_t *)h = vv; + *(volatile uint64_t *)h = htole64(vv); else panic("dino_w8: not implemented"); } @@ -720,7 +693,7 @@ dino_rm_1(void *v, bus_space_handle_t h, struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile uint8_t *)&r->pci_io_data + (h & 3); } @@ -740,7 +713,7 @@ dino_rm_2(void *v, bus_space_handle_t h, struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile uint16_t *)&r->pci_io_data; if (h & 2) p++; @@ -788,7 +761,7 @@ dino_wm_1(void *v, bus_space_handle_t h, struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile uint8_t *)&r->pci_io_data + (h & 3); } @@ -808,7 +781,7 @@ dino_wm_2(void *v, bus_space_handle_t h, struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile uint16_t *)&r->pci_io_data; if (h & 2) p++; @@ -856,7 +829,7 @@ dino_sm_1(void *v, bus_space_handle_t h, struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile uint8_t *)&r->pci_io_data + (h & 3); } @@ -876,7 +849,7 @@ dino_sm_2(void *v, bus_space_handle_t h, struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile uint16_t *)&r->pci_io_data; if (h & 2) p++; @@ -925,12 +898,13 @@ dino_rrm_2(void *v, bus_space_handle_t h struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile uint16_t *)&r->pci_io_data; if (h & 2) p++; } + c /= 2; while (c--) *a++ = *p; } @@ -952,6 +926,7 @@ dino_rrm_4(void *v, bus_space_handle_t h p = (volatile uint32_t *)&r->pci_io_data; } + c /= 4; while (c--) *a++ = *p; } @@ -976,12 +951,13 @@ dino_wrm_2(void *v, bus_space_handle_t h struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile uint16_t *)&r->pci_io_data; if (h & 2) p++; } + c /= 2; while (c--) *p = *a++; } @@ -1003,6 +979,7 @@ dino_wrm_4(void *v, bus_space_handle_t h p = (volatile uint32_t *)&r->pci_io_data; } + c /= 4; while (c--) *p = *a++; } @@ -1028,12 +1005,10 @@ dino_rr_1(void *v, bus_space_handle_t h, struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; - while (c--) { + for (; c--; h++) { + r->pci_addr = h; p = (volatile uint8_t *)&r->pci_io_data + (h & 3); *a++ = *p; - if (!(++h & 3)) - r->pci_addr = h; } } } @@ -1041,26 +1016,26 @@ dino_rr_1(void *v, bus_space_handle_t h, void dino_rr_2(void *v, bus_space_handle_t h, bus_size_t o, uint16_t *a, bus_size_t c) { - volatile uint16_t *p; + volatile uint16_t *p, data; h += o; if (h & 0xf0000000) { p = (volatile uint16_t *)h; - while (c--) - *a++ = le16toh(*p++); + while (c--) { + data = *p++; + *a++ = le16toh(data); + } } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; - while (c--) { + for (; c--; h += 2) { + r->pci_addr = h; p = (volatile uint16_t *)&r->pci_io_data; if (h & 2) p++; - *a++ = le16toh(*p); - h += 2; - if (!(h & 2)) - r->pci_addr = h; + data = *p; + *a++ = le16toh(data); } } } @@ -1068,20 +1043,23 @@ dino_rr_2(void *v, bus_space_handle_t h, void dino_rr_4(void *v, bus_space_handle_t h, bus_size_t o, uint32_t *a, bus_size_t c) { - volatile uint32_t *p; + volatile uint32_t *p, data; h += o; if (h & 0xf0000000) { p = (volatile uint32_t *)h; - while (c--) - *a++ = le32toh(*p++); + while (c--) { + data = *p++; + *a++ = le32toh(data); + } } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; for (; c--; h += 4) { r->pci_addr = h; - *a++ = le32toh(r->pci_io_data); + data = r->pci_io_data; + *a++ = le32toh(data); } } } @@ -1106,12 +1084,10 @@ dino_wr_1(void *v, bus_space_handle_t h, struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; - while (c--) { + for (; c--; h++) { + r->pci_addr = h; p = (volatile uint8_t *)&r->pci_io_data + (h & 3); *p = *a++; - if (!(++h & 3)) - r->pci_addr = h; } } } @@ -1119,26 +1095,26 @@ dino_wr_1(void *v, bus_space_handle_t h, void dino_wr_2(void *v, bus_space_handle_t h, bus_size_t o, const uint16_t *a, bus_size_t c) { - volatile uint16_t *p; + volatile uint16_t *p, data; h += o; if (h & 0xf0000000) { p = (volatile uint16_t *)h; - while (c--) - *p++ = htole16(*a++); + while (c--) { + data = *a++; + *p++ = htole16(data); + } } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; - while (c--) { + for (; c--; h += 2) { + r->pci_addr = h; p = (volatile uint16_t *)&r->pci_io_data; if (h & 2) p++; - *p = htole16(*a++); - h += 2; - if (!(h & 2)) - r->pci_addr = h; + data = *a++; + *p = htole16(data); } } } @@ -1146,20 +1122,23 @@ dino_wr_2(void *v, bus_space_handle_t h, void dino_wr_4(void *v, bus_space_handle_t h, bus_size_t o, const uint32_t *a, bus_size_t c) { - volatile uint32_t *p; + volatile uint32_t *p, data; h += o; if (h & 0xf0000000) { p = (volatile uint32_t *)h; - while (c--) - *p++ = htole32(*a++); + while (c--) { + data = *a++; + *p++ = htole32(data); + } } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; for (; c--; h += 4) { r->pci_addr = h; - r->pci_io_data = htole32(*a++); + data = *a++; + r->pci_io_data = htole32(data); } } } @@ -1176,6 +1155,7 @@ dino_rrr_2(void *v, bus_space_handle_t h { volatile uint16_t *p; + c /= 2; h += o; if (h & 0xf0000000) { p = (volatile uint16_t *)h; @@ -1185,15 +1165,12 @@ dino_rrr_2(void *v, bus_space_handle_t h struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; - while (c--) { + for (; c--; h += 2) { + r->pci_addr = h; p = (volatile uint16_t *)&r->pci_io_data; if (h & 2) p++; *a++ = *p; - h += 2; - if (!(h & 2)) - r->pci_addr = h; } } } @@ -1204,6 +1181,7 @@ dino_rrr_4(void *v, bus_space_handle_t h { volatile uint32_t *p; + c /= 4; h += o; if (h & 0xf0000000) { p = (volatile uint32_t *)h; @@ -1233,6 +1211,7 @@ dino_wrr_2(void *v, bus_space_handle_t h { volatile uint16_t *p; + c /= 2; h += o; if (h & 0xf0000000) { p = (volatile uint16_t *)h; @@ -1242,15 +1221,12 @@ dino_wrr_2(void *v, bus_space_handle_t h struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; - while (c--) { + for (; c--; h += 2) { + r->pci_addr = h; p = (volatile uint16_t *)&r->pci_io_data; if (h & 2) p++; *p = *a++; - h += 2; - if (!(h & 2)) - r->pci_addr = h; } } } @@ -1261,6 +1237,7 @@ dino_wrr_4(void *v, bus_space_handle_t h { volatile uint32_t *p; + c /= 4; h += o; if (h & 0xf0000000) { p = (volatile uint32_t *)h; @@ -1298,12 +1275,10 @@ dino_sr_1(void *v, bus_space_handle_t h, struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; - while (c--) { + for (; c--; h++) { + r->pci_addr = h; p = (volatile uint8_t *)&r->pci_io_data + (h & 3); *p = vv; - if (!(++h & 3)) - r->pci_addr = h; } } } @@ -1314,23 +1289,21 @@ dino_sr_2(void *v, bus_space_handle_t h, volatile uint16_t *p; h += o; + vv = htole16(vv); if (h & 0xf0000000) { p = (volatile uint16_t *)h; while (c--) - *p++ = htole16(vv); + *p++ = vv; } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; - while (c--) { + for (; c--; h += 2) { + r->pci_addr = h; p = (volatile uint16_t *)&r->pci_io_data; if (h & 2) p++; - *p = htole16(vv); - h += 2; - if (!(h & 2)) - r->pci_addr = h; + *p = vv; } } } @@ -1341,17 +1314,18 @@ dino_sr_4(void *v, bus_space_handle_t h, volatile uint32_t *p; h += o; + vv = htole32(vv); if (h & 0xf0000000) { p = (volatile uint32_t *)h; while (c--) - *p++ = htole32(vv); + *p++ = vv; } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; for (; c--; h += 4) { r->pci_addr = h; - r->pci_io_data = htole32(vv); + r->pci_io_data = vv; } } } @@ -1574,6 +1548,10 @@ dinomatch(device_t parent, cfdata_t cfda ca->ca_type.iodc_sv_model != HPPA_BRIDGE_DINO) return 0; + /* do not match on the elroy family */ + if (ca->ca_type.iodc_model == 0x78) + return 0; + /* Make sure we have an IRQ. */ if (ca->ca_irq == HP700CF_IRQ_UNDEF) ca->ca_irq = hp700_intr_allocate_bit(&int_reg_cpu); @@ -1588,7 +1566,7 @@ dinoattach(device_t parent, device_t sel struct confargs *ca = (struct confargs *)aux, nca; struct pcibus_attach_args pba; volatile struct dino_regs *r; - const char *p; + const char *p = NULL; u_int data; int s, ver; @@ -1607,17 +1585,25 @@ dinoattach(device_t parent, device_t sel } sc->sc_regs = r = (volatile struct dino_regs *)sc->sc_bh; -#ifdef trust_the_firmware_to_proper_initialize_everything + r->pciror = 0; + r->pciwor = 0; r->io_addr_en = 0; + r->gmask &= ~1; /* allow GSC bus req */ + r->brdg_feat &= ~0xf00; + r->brdg_feat |= 3; +#ifdef trust_the_firmware_to_proper_initialize_everything r->io_control = 0x80; r->pamr = 0; r->papr = 0; r->io_fbb_en |= 1; r->damode = 0; - r->gmask &= ~1; /* allow GSC bus req */ - r->pciror = 0; - r->pciwor = 0; r->brdg_feat = 0xc0000000; + r->mltim = 0x40 /* 64 clocks */ + r->tltim = 0x8c /* 12 clocks */ + + /* PCI reset */ + r->pcicmd = 0x6f; + DELAY(10000); /* 10ms for reset to settle */ #endif snprintf(sc->sc_ioexname, sizeof(sc->sc_ioexname), @@ -1631,10 +1617,12 @@ dinoattach(device_t parent, device_t sel /* interrupts guts */ s = splhigh(); - r->icr = 0; r->imr = ~0; data = r->irr0; + data = r->irr1; r->imr = 0; + __asm __volatile ("" ::: "memory"); + r->icr = 0; r->iar0 = cpu_gethpa(0) | (31 - ca->ca_irq); splx(s); /* Establish the interrupt register. */ @@ -1654,8 +1642,11 @@ dinoattach(device_t parent, device_t sel ver = (ca->ca_type.iodc_model << 4) | (ca->ca_type.iodc_revision >> 4); switch (ver) { - case 0x05d: p = "Dino"; /* j2240 */ - case 0x680: p = "Dino"; + case 0x05d: + p = "Dino(card)"; /* j2240 */ + case 0x680: + if (!p) + p = "Dino"; switch (data >> 16) { case 0x6800: ver = 0x20; break; case 0x6801: ver = 0x21; break; Index: sys/arch/hp700/dev/mem.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/dev/mem.c,v retrieving revision 1.21 diff -u -p -u -p -r1.21 mem.c --- sys/arch/hp700/dev/mem.c 9 May 2009 11:39:30 -0000 1.21 +++ sys/arch/hp700/dev/mem.c 24 Jul 2009 07:06:27 -0000 @@ -236,8 +236,10 @@ memattach(device_t parent, device_t self ((struct vi_ctrl *)&vic)->eisa_den = 1; ((struct vi_ctrl *)&vic)->core_prf = 1; - if (settimeout && ((struct vi_ctrl *)&vic)->vsc_tout == 0) - ((struct vi_ctrl *)&vic)->vsc_tout = 850; /* clks */ + if (settimeout && + ((struct vi_ctrl *)&vic)->vsc_tout == 0) + /* clks */ + ((struct vi_ctrl *)&vic)->vsc_tout = 850; sc->sc_vp->vi_control = vic; Index: sys/arch/hp700/dev/sti_pci_machdep.c =================================================================== RCS file: sys/arch/hp700/dev/sti_pci_machdep.c diff -N sys/arch/hp700/dev/sti_pci_machdep.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/arch/hp700/dev/sti_pci_machdep.c 24 Jul 2009 07:06:27 -0000 @@ -0,0 +1,77 @@ +/* $OpenBSD: sti_pci_machdep.c,v 1.2 2009/04/10 17:11:27 miod Exp $ */ + +/* + * Copyright (c) 2007, 2009 Miodrag Vallat. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice, this permission notice, and the disclaimer below + * appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include + +#include +#include + +#include + +int sti_pci_is_console(struct pci_attach_args *, bus_addr_t *); + +int +sti_pci_is_console(struct pci_attach_args *paa, bus_addr_t *bases) +{ + u_int32_t cf; + bus_addr_t addr; + int bar; + int rc; + + /* + * PAGE0 console information will point to one of our BARs, + * but depending on the particular sti model, this might not + * be the BAR mapping the rom (region #0). + * + * For example, on Visualize FXe, regions #0, #2 and #3 are + * mapped by BAR 0x18, while region #1 is mapped by BAR 0x10, + * which matches PAGE0 console address. + * + * Rather than trying to be smart, reread the region->BAR array + * again, and compare the BAR mapping region #1 against PAGE0 + * values, we simply try all the valid BARs; if any of them + * matches what PAGE0 says, then we are the console, and it + * doesn't matter which BAR matched. + */ + for (bar = PCI_MAPREG_START; bar <= PCI_MAPREG_PPB_END; ) { + cf = pci_conf_read(paa->pa_pc, paa->pa_tag, bar); + + if (PCI_MAPREG_TYPE(cf) == PCI_MAPREG_TYPE_IO) { + rc = pci_io_find(paa->pa_pc, paa->pa_tag, bar, &addr, + NULL); + bar += 4; + } else { + rc = pci_mem_find(paa->pa_pc, paa->pa_tag, bar, &addr, + NULL, NULL); + if (PCI_MAPREG_MEM_TYPE(cf) == + PCI_MAPREG_MEM_TYPE_64BIT) + bar += 8; + else + bar += 4; + } + + if (rc == 0 && + (hppa_hpa_t)addr == (hppa_hpa_t)PAGE0->mem_cons.pz_hpa) + return 1; + } + + return 0; +} Index: sys/arch/hp700/dev/uturn.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/dev/uturn.c,v retrieving revision 1.5 diff -u -p -u -p -r1.5 uturn.c --- sys/arch/hp700/dev/uturn.c 24 May 2009 06:53:34 -0000 1.5 +++ sys/arch/hp700/dev/uturn.c 24 Jul 2009 07:06:27 -0000 @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -53,6 +54,173 @@ struct uturn_softc { struct uturn_regs volatile *sc_regs; }; + +#define U2_IOA_RUNWAY 0x580 +#define U2_BC_GSC 0x501 +#define UTURN_IOA_RUNWAY 0x581 +#define UTURN_BC_GSC 0x502 + +#define IOA_NORMAL_MODE 0x00020080 /* IO_CONTROL to turn on CCIO */ +#define CMD_TLB_DIRECT_WRITE 35 /* IO_COMMAND for I/O TLB Writes */ +#define CMD_TLB_PURGE 33 /* IO_COMMAND to Purge I/O TLB entry */ + +struct ioa_registers { + /* Runway Supervisory Set */ + int32_t unused1[12]; + uint32_t io_command; /* Offset 12 */ + uint32_t io_status; /* Offset 13 */ + uint32_t io_control; /* Offset 14 */ + int32_t unused2[1]; + + /* Runway Auxiliary Register Set */ + uint32_t io_err_resp; /* Offset 0 */ + uint32_t io_err_info; /* Offset 1 */ + uint32_t io_err_req; /* Offset 2 */ + uint32_t io_err_resp_hi; /* Offset 3 */ + uint32_t io_tlb_entry_m; /* Offset 4 */ + uint32_t io_tlb_entry_l; /* Offset 5 */ + uint32_t unused3[1]; + uint32_t io_pdir_base; /* Offset 7 */ + uint32_t io_io_low_hv; /* Offset 8 */ + uint32_t io_io_high_hv; /* Offset 9 */ + uint32_t unused4[1]; + uint32_t io_chain_id_mask; /* Offset 11 */ + uint32_t unused5[2]; + uint32_t io_io_low; /* Offset 14 */ + uint32_t io_io_high; /* Offset 15 */ +}; + + +/* +** IOA Registers +** ------------- +** +** Runway IO_CONTROL Register (+0x38) +** +** The Runway IO_CONTROL register controls the forwarding of transactions. +** +** | 0 ... 13 | 14 15 | 16 ... 21 | 22 | 23 24 | 25 ... 31 | +** | HV | TLB | reserved | HV | mode | reserved | +** +** o mode field indicates the address translation of transactions +** forwarded from Runway to GSC+: +** Mode Name Value Definition +** Off (default) 0 Opaque to matching addresses. +** Include 1 Transparent for matching addresses. +** Peek 3 Map matching addresses. +** +** + "Off" mode: Runway transactions which match the I/O range +** specified by the IO_IO_LOW/IO_IO_HIGH registers will be ignored. +** + "Include" mode: all addresses within the I/O range specified +** by the IO_IO_LOW and IO_IO_HIGH registers are transparently +** forwarded. This is the I/O Adapter's normal operating mode. +** + "Peek" mode: used during system configuration to initialize the +** GSC+ bus. Runway Write_Shorts in the address range specified by +** IO_IO_LOW and IO_IO_HIGH are forwarded through the I/O Adapter +** *AND* the GSC+ address is remapped to the Broadcast Physical +** Address space by setting the 14 high order address bits of the +** 32 bit GSC+ address to ones. +** +** o TLB field affects transactions which are forwarded from GSC+ to Runway. +** "Real" mode is the poweron default. +** +** TLB Mode Value Description +** Real 0 No TLB translation. Address is directly mapped and the +** virtual address is composed of selected physical bits. +** Error 1 Software fills the TLB manually. +** Normal 2 IOA fetches IO TLB misses from IO PDIR (in host memory). +** +** +** IO_IO_LOW_HV +0x60 (HV dependent) +** IO_IO_HIGH_HV +0x64 (HV dependent) +** IO_IO_LOW +0x78 (Architected register) +** IO_IO_HIGH +0x7c (Architected register) +** +** IO_IO_LOW and IO_IO_HIGH set the lower and upper bounds of the +** I/O Adapter address space, respectively. +** +** 0 ... 7 | 8 ... 15 | 16 ... 31 | +** 11111111 | 11111111 | address | +** +** Each LOW/HIGH pair describes a disjoint address space region. +** (2 per GSC+ port). Each incoming Runway transaction address is compared +** with both sets of LOW/HIGH registers. If the address is in the range +** greater than or equal to IO_IO_LOW and less than IO_IO_HIGH the transaction +** for forwarded to the respective GSC+ bus. +** Specify IO_IO_LOW equal to or greater than IO_IO_HIGH to avoid specifying +** an address space region. +** +** In order for a Runway address to reside within GSC+ extended address space: +** Runway Address [0:7] must identically compare to 8'b11111111 +** Runway Address [8:11] must be equal to IO_IO_LOW(_HV)[16:19] +** Runway Address [12:23] must be greater than or equal to +** IO_IO_LOW(_HV)[20:31] and less than IO_IO_HIGH(_HV)[20:31]. +** Runway Address [24:39] is not used in the comparison. +** +** When the Runway transaction is forwarded to GSC+, the GSC+ address is +** as follows: +** GSC+ Address[0:3] 4'b1111 +** GSC+ Address[4:29] Runway Address[12:37] +** GSC+ Address[30:31] 2'b00 +** +** All 4 Low/High registers must be initialized (by PDC) once the lower bus +** is interrogated and address space is defined. The operating system will +** modify the architectural IO_IO_LOW and IO_IO_HIGH registers following +** the PDC initialization. However, the hardware version dependent IO_IO_LOW +** and IO_IO_HIGH registers should not be subsequently altered by the OS. +** +** Writes to both sets of registers will take effect immediately, bypassing +** the queues, which ensures that subsequent Runway transactions are checked +** against the updated bounds values. However reads are queued, introducing +** the possibility of a read being bypassed by a subsequent write to the same +** register. This sequence can be avoided by having software wait for read +** returns before issuing subsequent writes. +*/ + +#if 0 + +struct ioc { + struct ioa_registers __iomem *ioc_regs; /* I/O MMU base address */ + u8 *res_map; /* resource map, bit == pdir entry */ + u64 *pdir_base; /* physical base address */ + u32 pdir_size; /* bytes, function of IOV Space size */ + u32 res_hint; /* next available IOVP - + circular search */ + u32 res_size; /* size of resource map in bytes */ + spinlock_t res_lock; + +#ifdef CCIO_SEARCH_TIME +#define CCIO_SEARCH_SAMPLE 0x100 + unsigned long avg_search[CCIO_SEARCH_SAMPLE]; + unsigned long avg_idx; /* current index into avg_search */ +#endif +#ifdef CCIO_MAP_STATS + unsigned long used_pages; + unsigned long msingle_calls; + unsigned long msingle_pages; + unsigned long msg_calls; + unsigned long msg_pages; + unsigned long usingle_calls; + unsigned long usingle_pages; + unsigned long usg_calls; + unsigned long usg_pages; +#endif + unsigned short cujo20_bug; + + /* STUFF We don't need in performance path */ + u32 chainid_shift; /* specify bit location of chain_id */ + struct ioc *next; /* Linked list of discovered iocs */ + const char *name; /* device name from firmware */ + unsigned int hw_path; /* the hardware path this ioc is associatd with */ + struct pci_dev *fake_pci_dev; /* the fake pci_dev for non-pci devs */ + struct resource mmio_region[2]; /* The "routed" MMIO regions */ +}; + +static struct ioc *ioc_list; +static int ioc_count; + +#endif + int uturnmatch(device_t, cfdata_t, void *); void uturnattach(device_t, device_t, void *); static void uturn_callback(device_t self, struct confargs *ca); @@ -85,6 +253,7 @@ uturnattach(device_t parent, device_t se struct confargs *ca = aux, nca; struct uturn_softc *sc = device_private(self); bus_space_handle_t ioh; + struct iomod *srs; if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) { aprint_error(": can't map IO space\n"); @@ -99,14 +268,14 @@ uturnattach(device_t parent, device_t se ca->ca_type.iodc_revision & 0xf); /* keep it real */ - ((struct iomod *)ioh)->io_control = 0x80; + srs = bus_space_vaddr(ca->ca_iot, ioh); + srs->io_control = 0x80; /* - * U2/UTurn is actually a combination of an Upper Bus - * Converter (UBC) and a Lower Bus Converter (LBC). This - * driver attaches to the UBC; the LBC isn't very interesting, - * so we skip it. This is easy, since it always is module 63, - * hence the MAXMODBUS - 1 below. + * U2/UTurn is actually a combination of an Upper Bus Converter (UBC) + * and a Lower Bus Converter (LBC). This driver attaches to the UBC; + * the LBC isn't very interesting, so we skip it. This is easy, since + * it always is module 63, hence the MAXMODBUS - 1 below. */ nca = *ca; nca.ca_hpabase = 0; @@ -125,7 +294,7 @@ uturnattach(device_t parent, device_t se case HPPA_BOARD_HP800D: case HPPA_BOARD_HP821: - nca.ca_hpabase = ((struct iomod *)ioh)->io_io_low << 16; + nca.ca_hpabase = srs->io_io_low << 16; pdc_scanbus(self, &nca, uturn_callback); break; default: Index: sys/arch/hp700/gsc/gscbus.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/gsc/gscbus.c,v retrieving revision 1.15 diff -u -p -u -p -r1.15 gscbus.c --- sys/arch/hp700/gsc/gscbus.c 7 May 2009 15:34:49 -0000 1.15 +++ sys/arch/hp700/gsc/gscbus.c 24 Jul 2009 07:06:27 -0000 @@ -153,8 +153,8 @@ gscattach(device_t parent, device_t self aprint_normal("\n"); /* Add the I/O subsystem's interrupt register. */ - ga->ga_int_reg->int_reg_dev = parent->dv_xname; - sc->sc_ih = hp700_intr_establish(sc->sc_dev, IPL_NONE, NULL, + ga->ga_int_reg->int_reg_dev = device_xname(parent); + sc->sc_ih = hp700_intr_establish(sc->sc_dev, IPL_NONE, NULL, ga->ga_int_reg, &int_reg_cpu, ga->ga_irq); ga->ga_ca.ca_nmodules = MAXMODBUS; Index: sys/arch/hp700/gsc/if_iee_gsc.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/gsc/if_iee_gsc.c,v retrieving revision 1.15 diff -u -p -u -p -r1.15 if_iee_gsc.c --- sys/arch/hp700/gsc/if_iee_gsc.c 24 May 2009 06:53:35 -0000 1.15 +++ sys/arch/hp700/gsc/if_iee_gsc.c 24 Jul 2009 07:06:27 -0000 @@ -82,7 +82,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_iee_gsc.c #define IEE_GSC_RESET 0 #define IEE_GSC_PORT 4 #define IEE_GSC_CHANATT 8 -#define IEE_ISCP_BUSSY 0x1 +#define IEE_ISCP_BUSY 0x1 /* autoconfig stuff */ static int iee_gsc_match(device_t, cfdata_t, void *); @@ -142,8 +142,8 @@ iee_gsc_reset(struct iee_softc *sc) uint32_t cmd; uint16_t ack; - /* Make sure the bussy byte is set and the cache is flushed. */ - SC_ISCP(sc)->iscp_bussy = IEE_ISCP_BUSSY; + /* Make sure the busy byte is set and the cache is flushed. */ + SC_ISCP(sc)->iscp_busy = IEE_ISCP_BUSY; IEE_ISCPSYNC(sc, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); /* Setup the PORT Command with pointer to SCP. */ cmd = IEE_PORT_SCP | IEE_PHYS_SHMEM(sc->sc_scp_off); @@ -170,9 +170,9 @@ iee_gsc_reset(struct iee_softc *sc) /* Wait for the chip to initialize and read SCP and ISCP. */ for (n = 0 ; n < 1000; n++) { IEE_ISCPSYNC(sc, BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE); - ack = SC_ISCP(sc)->iscp_bussy; + ack = SC_ISCP(sc)->iscp_busy; IEE_ISCPSYNC(sc, BUS_DMASYNC_PREREAD); - if (ack != IEE_ISCP_BUSSY) + if (ack != IEE_ISCP_BUSY) break; DELAY(100); } @@ -181,8 +181,8 @@ iee_gsc_reset(struct iee_softc *sc) (sc->sc_iee_cmd)(sc, IEE_SCB_ACK); return 0; } - printf("%s: iee_gsc_reset timeout bussy=0x%x\n", - device_xname(sc->sc_dev), SC_ISCP(sc)->iscp_bussy); + printf("%s: iee_gsc_reset timeout busy=0x%x\n", + device_xname(sc->sc_dev), SC_ISCP(sc)->iscp_busy); return -1; } Index: sys/arch/hp700/hp700/autoconf.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/hp700/autoconf.c,v retrieving revision 1.29 diff -u -p -u -p -r1.29 autoconf.c --- sys/arch/hp700/hp700/autoconf.c 8 May 2009 09:33:58 -0000 1.29 +++ sys/arch/hp700/hp700/autoconf.c 24 Jul 2009 07:06:27 -0000 @@ -120,7 +120,11 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v #include #include -register_t kpsw = PSW_Q | PSW_P | PSW_C | PSW_D; +register_t kpsw = + PSW_Q | /* Interrupt State Collection Enable */ + PSW_P | /* Protection Identifier Validation Enable */ + PSW_C | /* Instruction Address Translation Enable */ + PSW_D; /* Data Address Translation Enable */ /* * LED blinking thing Index: sys/arch/hp700/hp700/genassym.cf =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/hp700/genassym.cf,v retrieving revision 1.18 diff -u -p -u -p -r1.18 genassym.cf --- sys/arch/hp700/hp700/genassym.cf 7 May 2009 15:34:49 -0000 1.18 +++ sys/arch/hp700/hp700/genassym.cf 24 Jul 2009 07:06:28 -0000 @@ -179,6 +179,7 @@ struct lwp member L_PROC l_proc member L_CPU l_cpu member L_ADDR l_addr +member L_FLAG l_flag member L_PRIORITY l_priority member L_STAT l_stat member L_WCHAN l_wchan Index: sys/arch/hp700/hp700/locore.S =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/hp700/locore.S,v retrieving revision 1.35 diff -u -p -u -p -r1.35 locore.S --- sys/arch/hp700/hp700/locore.S 3 Jun 2009 21:08:51 -0000 1.35 +++ sys/arch/hp700/hp700/locore.S 24 Jul 2009 07:06:28 -0000 @@ -175,7 +175,7 @@ hppa_vtop: /* a vtop translation table .block 4 #endif - .text + .section .text .import kernel_setup, entry /* @@ -555,7 +555,7 @@ EXIT(pdc_call) /* * int spllower(int ncpl); */ -ENTRY(spllower,64) +ENTRY(spllower, HPPA_FRAME_SIZE) ldil L%ipending, %r1 ldw R%ipending(%r1), %r1 ; load ipending ldil L%cpl, %t1 @@ -770,7 +770,6 @@ EXIT(cpu_die) * struct lwp * * cpu_switchto(struct lwp *curl, struct lwp *newl) */ - .align 32 ENTRY(cpu_switchto,128) /* start stack calling convention */ stw %rp, HPPA_FRAME_CRP(%sp) @@ -785,15 +784,13 @@ ENTRY(cpu_switchto,128) switch_error: copy %t1, %arg1 - ldil L%panic, %r1 - ldil L%Lcspstr, %arg0 - ldo R%panic(%r1), %r1 - ldo R%Lcspstr(%arg0), %arg0 - .call - blr %r0, %rp - bv,n %r0(%r1) - nop -Lcspstr: + ldil L%$cspstr, %arg0 + ldo R%$cspstr(%arg0), %arg0 + + CALL(panic, %r1) + /* no return */ + +$cspstr: .asciz "cpu_switchto: 0x%08x stack/len 0x%08x" .align 8 @@ -886,6 +883,11 @@ switch_exited: ldo -(HPPA_FRAME_SIZE+16*4)(%sp), %r3 + ldil L%lwp_trampoline, %t1 + ldo R%lwp_trampoline(%t1), %t1 + ldw HPPA_FRAME_CRP(%r3), %rp + comb,=,n %rp, %t1, switch_trampoline + ldw 1*4(%r3), %r4 ldw 2*4(%r3), %r5 ldw 3*4(%r3), %r6 @@ -902,6 +904,10 @@ switch_exited: ldw 14*4(%r3), %r17 ldw 15*4(%r3), %r18 + ldw L_FLAG(%arg1), %t1 + bb,< %t1, 22, switch_return /* LW_SYSTEM is 0x00000200 */ + +switch_trampoline: /* * Check for restartable atomic sequences (RAS) */ Index: sys/arch/hp700/hp700/machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/hp700/machdep.c,v retrieving revision 1.69 diff -u -p -u -p -r1.69 machdep.c --- sys/arch/hp700/hp700/machdep.c 29 May 2009 08:44:29 -0000 1.69 +++ sys/arch/hp700/hp700/machdep.c 24 Jul 2009 07:06:29 -0000 @@ -839,8 +839,25 @@ cpu_model_cpuid(int hvers) return hpcxt; } return hpc_unknown; +#if 0 + hpc_unknown, + hpcx, /* PA7000 (x) PA 1.0 */ + hpcxs, /* PA7000 (s) PA 1.1a */ + hpcxt, /* PA7100 (t) PA 1.1b */ + hpcxl, /* PA7100LC (l) PA 1.1c */ + hpcxtp, /* PA7200 (t') PA 1.1d */ + hpcxl2, /* PA7300LC (l2) PA 1.1e */ + hpcxu, /* PA8000 (u) PA 2.0 */ + hpcxup, /* PA8200 (u+) PA 2.0 */ + hpcxw, /* PA8500 (w) PA 2.0 */ + hpcxwp, /* PA8600 (w+) PA 2.0 */ + hpcxw2, /* PA8700 (piranha) PA 2.0 */ + mako /* PA8800 (mako) PA 2.0 */ +#endif + } + void cpu_startup(void) { @@ -1991,4 +2008,3 @@ module_init_md(void) { } #endif /* MODULAR */ - Index: sys/arch/hp700/hp700/mainbus.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/hp700/mainbus.c,v retrieving revision 1.53 diff -u -p -u -p -r1.53 mainbus.c --- sys/arch/hp700/hp700/mainbus.c 23 Jul 2009 13:34:26 -0000 1.53 +++ sys/arch/hp700/hp700/mainbus.c 24 Jul 2009 07:06:30 -0000 @@ -29,10 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* $OpenBSD: mainbus.c,v 1.13 2001/09/19 20:50:56 mickey Exp $ */ +/* $OpenBSD: mainbus.c,v 1.74 2009/04/20 00:42:06 oga Exp $ */ /* - * Copyright (c) 1998-2000 Michael Shalayeff + * Copyright (c) 1998-2004 Michael Shalayeff * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,11 +43,6 @@ * 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 Michael Shalayeff. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -85,9 +80,23 @@ __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v #include #include #include +#include static struct pdc_hpa pdc_hpa PDC_ALIGNMENT; +#ifdef MBUSDEBUG + +#define DPRINTF(s) do { \ + if (mbusdebug) \ + printf s; \ +} while(0) + +int mbusdebug = 0; +#else +#define DPRINTF(s) /* */ +#endif + + struct mainbus_softc { device_t sc_dv; @@ -177,64 +186,92 @@ int mbus_add_mapping(bus_addr_t bpa, bus_size_t size, int flags, bus_space_handle_t *bshp) { - u_int frames; -#ifdef USE_BTLB - vsize_t btlb_size; - int error; -#endif /* USE_BTLB */ + static uint32_t bmm[0x4000/32]; /* XXXNH */ + vaddr_t pa, spa, epa; + vsize_t len; + int flex; + + DPRINTF(("\n%s(%x,%x,%scachable,%p)\n", __func__, + (int)bpa, (int)size, flags? "" : "non", bshp)); - /* - * We must be called with a page-aligned address in - * I/O space, and with a multiple of the page size. - */ - KASSERT((bpa & PGOFSET) == 0); KASSERT(bpa >= HPPA_IOSPACE); - KASSERT((size & PGOFSET) == 0); + KASSERT(!(flags & BUS_SPACE_MAP_CACHEABLE)); /* - * Assume that this will succeed. + * Mappings are established in HPPA_FLEX_SIZE units, + * either with BTLB, or regular mappings of the whole area. */ - *bshp = bpa; + for (pa = bpa ; size != 0; pa = epa) { + flex = HPPA_FLEX(pa); + spa = pa & HPPA_FLEX_MASK; + epa = spa + HPPA_FLEX_SIZE; /* may wrap to 0... */ - /* - * Loop while there is space left to map. - */ - frames = size >> PGSHIFT; - while (frames > 0) { + size -= min(size, HPPA_FLEX_SIZE - (pa - spa)); + + /* do need a new mapping? */ + if (bmm[flex / 32] & (1 << (flex % 32))) { + DPRINTF(("+++ already b-mapped flex=%x, mask=%x\n", + flex, bmm[flex / 32])); + continue; + } + + DPRINTF(("%s: adding flex=%x %x-%x, ", __func__, flex, spa, + epa - 1)); + + while (spa != epa) { + len = epa - spa; - /* - * If this mapping is more than eight pages long, - * try to add a BTLB entry. - */ #ifdef USE_BTLB - if (frames > 8 && - frames >= hppa_btlb_size_min) { - btlb_size = frames; + XXX + /* + * Try to map with a BTLB first (might map + * much more than what we are requesting + * for, and cross HPPA_FLEX boundaries). + * + * Note that this code assumes that + * BTLB size are a power of two, so if + * the size is larger than HPPA_FLEX_SIZE + * it will span an integral number of + * HPPA_FLEX_SIZE slots. + */ + if (btlb_size > hppa_btlb_size_max) btlb_size = hppa_btlb_size_max; + if (len > pdc_btlb.max_size << PGSHIFT) + len = pdc_btlb.max_size << PGSHIFT; + + btlb_size <<= PGSHIFT; - error = hppa_btlb_insert(pmap_kernel()->pmap_space, - bpa, bpa, &btlb_size, - pmap_kernel()->pmap_pid | + error = hppa_btlb_insert(pmap_kernel()->pmap_space, + spa, spa, &len, pmap_kernel()->pmap_pid | pmap_prot(pmap_kernel(), VM_PROT_READ | VM_PROT_WRITE)); - if (error == 0) { - bpa += btlb_size; - frames -= (btlb_size >> PGSHIFT); + if (error == 0) { + pa = spa + len; /* may wrap to 0... */ + + DPRINTF(("--- %x/%x, %x-%x ", + flex, HPPA_FLEX(pa - 1), spa, pa - 1)); + + /* register all ranges */ + for (; flex <= HPPA_FLEX(pa - 1); flex++) { + + DPRINTF(("mask %x ", flex)); + bmm[flex / 32] |= (1 << (flex % 32)); + } + if (len > epa - spa) + spa = epa; + else + spa = pa; continue; } - else if (error != ENOMEM) - return error; - } #endif /* USE_BTLB */ - - /* - * Enter another single-page mapping. - */ - pmap_kenter_pa(bpa, bpa, VM_PROT_READ | VM_PROT_WRITE); - bpa += PAGE_SIZE; - frames--; + DPRINTF(("kenter 0x%x-0x%x", (int)spa, (int)epa)); + for (; spa != epa; spa += PAGE_SIZE) + pmap_kenter_pa(spa, spa, + VM_PROT_READ | VM_PROT_WRITE); + } } + *bshp = bpa; /* Success. */ return 0; } @@ -252,14 +289,7 @@ mbus_remove_mapping(bus_space_handle_t b int error; #endif /* USE_BTLB */ - /* - * We must be called with a page-aligned address in - * I/O space, and with a multiple of the page size. - */ bpa = *bpap = bsh; - KASSERT((bpa & PGOFSET) == 0); - KASSERT(bpa >= HPPA_IOSPACE); - KASSERT((size & PGOFSET) == 0); /* * Loop while there is space left to unmap. @@ -307,7 +337,6 @@ mbus_map(void *v, bus_addr_t bpa, bus_si bus_space_handle_t *bshp) { int error; - bus_size_t offset; /* * We must only be called with addresses in I/O space. @@ -315,14 +344,6 @@ mbus_map(void *v, bus_addr_t bpa, bus_si KASSERT(bpa >= HPPA_IOSPACE); /* - * Page-align the I/O address and size. - */ - offset = (bpa & PGOFSET); - bpa -= offset; - size += offset; - size = round_page(size); - - /* * Allocate the region of I/O space. */ error = extent_alloc_region(hp700_io_extent, bpa, size, EX_NOWAIT); @@ -333,11 +354,10 @@ mbus_map(void *v, bus_addr_t bpa, bus_si * Map the region of I/O space. */ error = mbus_add_mapping(bpa, size, flags, bshp); - *bshp |= offset; if (error) { + printf ("bus_space_map: pa 0x%lx, size 0x%lx\n", + bpa, size); if (extent_free(hp700_io_extent, bpa, size, EX_NOWAIT)) { - printf ("bus_space_map: pa 0x%lx, size 0x%lx\n", - bpa, size); printf ("bus_space_map: can't free region\n"); } } @@ -348,19 +368,10 @@ mbus_map(void *v, bus_addr_t bpa, bus_si void mbus_unmap(void *v, bus_space_handle_t bsh, bus_size_t size) { - bus_size_t offset; bus_addr_t bpa; int error; /* - * Page-align the bus_space handle and size. - */ - offset = bsh & PGOFSET; - bsh -= offset; - size += offset; - size = round_page(size); - - /* * Unmap the region of I/O space. */ error = mbus_remove_mapping(bsh, size, &bpa); @@ -390,18 +401,20 @@ mbus_alloc(void *v, bus_addr_t rstart, b rend > hp700_io_extent->ex_end) panic("bus_space_alloc: bad region start/end"); +#if 0 /* * Force the allocated region to be page-aligned. */ if (align < PAGE_SIZE) align = PAGE_SIZE; size = round_page(size); +#endif /* * Allocate the region of I/O space. */ error = extent_alloc_subregion1(hp700_io_extent, rstart, rend, size, - align, 0, boundary, EX_NOWAIT, &bpa); + align, 0, boundary, EX_NOWAIT, &bpa); if (error) return (error); @@ -410,9 +423,9 @@ mbus_alloc(void *v, bus_addr_t rstart, b */ error = mbus_add_mapping(bpa, size, flags, bshp); if (error) { - if (extent_free(hp700_io_extent, bpa, size, EX_NOWAIT)) { printf("bus_space_alloc: pa 0x%lx, size 0x%lx\n", bpa, size); + if (extent_free(hp700_io_extent, bpa, size, EX_NOWAIT)) { printf("bus_space_alloc: can't free region\n"); } } @@ -1178,8 +1191,14 @@ mbus_dmamem_alloc(void *v, bus_size_t si * Allocate physical pages from the VM system. */ TAILQ_INIT(mlist); - error = uvm_pglistalloc(size, low, high, 0, 0, - mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); +/* 45678901234567890123456789012345678901234567890123456789012345678901234567 */ +#if 1 + error = uvm_pglistalloc(size, low, high, 0, 0, mlist, nsegs, + (flags & BUS_DMA_NOWAIT) == 0); +#else + error = uvm_pglistalloc(size, low, high, alignment, boundry, mlist, + 1, (flags & BUS_DMA_NOWAIT) == 0); +#endif /* * If the allocation failed, and this is a 24-bit @@ -1205,6 +1224,7 @@ mbus_dmamem_alloc(void *v, bus_size_t si return (0); } } + /* If we don't have the pages. */ if (error) { @@ -1262,6 +1282,7 @@ mbus_dmamem_free(void *v, bus_dma_segmen * Return the list of physical pages back to the VM system. */ if (segs[0]._ds_mlist != NULL) { + /* XXXNH is this page accessed with PA==VA??? */ uvm_pglistfree(segs[0]._ds_mlist); free(segs[0]._ds_mlist, M_DEVBUF); } else { @@ -1280,10 +1301,12 @@ mbus_dmamem_map(void *v, bus_dma_segment { struct vm_page *pg; struct pglist *pglist; +#if 0 vaddr_t va; paddr_t pa; const uvm_flag_t kmflags = (flags & BUS_DMA_NOWAIT) != 0 ? UVM_KMF_NOWAIT : 0; +#endif size = round_page(size); @@ -1294,6 +1317,19 @@ mbus_dmamem_map(void *v, bus_dma_segment *kvap = (void *)segs[0]._ds_va; return (0); } +#if 1 + else { + pglist = segs[0]._ds_mlist; + pg = TAILQ_FIRST(pglist); + segs[0]._ds_va = segs[0].ds_addr = VM_PAGE_TO_PHYS(pg); + segs[0].ds_len = size; + *kvap = (void *)segs[0]._ds_va; + + TAILQ_FOREACH(pg, pglist, pageq.queue) + /* XXX for now */ + pmap_changebit(pg, PTE_PROT(TLB_UNCACHEABLE), 0); + } +#else /* Get a chunk of kernel virtual space. */ va = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_VAONLY | kmflags); @@ -1313,6 +1349,8 @@ mbus_dmamem_map(void *v, bus_dma_segment va += PAGE_SIZE; size -= PAGE_SIZE; } +#endif + pmap_update(); return (0); } @@ -1340,7 +1378,9 @@ mbus_dmamem_unmap(void *v, void *kva, si size = round_page(size); pmap_kremove((vaddr_t)kva, size); pmap_update(pmap_kernel()); +#if 0 uvm_km_free(kernel_map, (vaddr_t)kva, size, UVM_KMF_VAONLY); +#endif } /* @@ -1523,8 +1563,12 @@ mbattach(device_t parent, device_t self, * XXX fredette - this may be a copout, or it may * be a great idea. I'm not sure which yet. */ - if (bus_space_map(&hppa_bustag, pdc_hpa.hpa, 0 - pdc_hpa.hpa, 0, &ioh)) - panic("mbattach: can't map mainbus IO space"); + printf("mapping 0x%08x %zu\n", (int)pdc_hpa.hpa, (size_t)(~0LU - pdc_hpa.hpa + 1)); + + /* map all the way till the end of the memory */ + if (bus_space_map(&hppa_bustag, pdc_hpa.hpa, + (~0LU - pdc_hpa.hpa + 1), 0, &ioh)) + panic("mbattach: cannot map mainbus IO space"); /* * Local-Broadcast the HPA to all modules on the bus Index: sys/arch/hp700/hp700/pim.h =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/hp700/pim.h,v retrieving revision 1.4 diff -u -p -u -p -r1.4 pim.h --- sys/arch/hp700/hp700/pim.h 17 May 2009 18:21:29 -0000 1.4 +++ sys/arch/hp700/hp700/pim.h 24 Jul 2009 07:06:30 -0000 @@ -190,7 +190,16 @@ struct hp700_pim_checks { #define PIM_BUS_PIV (1 << 7) #define PIM_BUS_BSV (1 << 6) #define PIM_BUS_STAT(bc) ((bc) & 0x3f) -#define PIM_BUS_BITS "\020\026RSV\025RQV\010PIV\007BSV" +#define PIM_BUS_BITS \ + "\177\020" /* New bitmask format */ \ + "b\025RSV\0" /* bit 21 */ \ + "b\024RQV\0" /* bit 20 */ \ + "f\020\004VAR\0" /* bit 16 .. 19 */ \ + "f\014\004TYPE\0" /* bit 12 .. 15 */ \ + "f\010\004SIZE\0" /* bit 8 .. 11 */ \ + "b\007PIV\0" \ + "b\006BSV\0" \ + "f\000\006STAT\0" /* bit 0 .. 5 */ /* The Assist Check word. */ uint32_t pim_check_assist; Index: sys/arch/hp700/include/cpu.h =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/include/cpu.h,v retrieving revision 1.34 diff -u -p -u -p -r1.34 cpu.h --- sys/arch/hp700/include/cpu.h 3 Jun 2009 21:08:51 -0000 1.34 +++ sys/arch/hp700/include/cpu.h 24 Jul 2009 07:06:30 -0000 @@ -153,10 +153,12 @@ extern register_t kpsw; * referenced in generic code */ +/* PA2.0 aliasing */ + #define HPPA_PGALIAS 0x00100000 -#define HPPA_PGAMASK 0xfff00000 +#define HPPA_PGAMASK 0xfff00000 /* bits 0-11 not used in index */ #define HPPA_PGAOFF 0x000fffff -#define HPPA_SPAMASK 0xf0f0f000 +#define HPPA_SPAMASK 0xf0f0f000 /* bits 0-3,8-11,16-19 not used */ #define HPPA_IOSPACE 0xf0000000 #define HPPA_IOLEN 0x10000000 Index: sys/arch/hp700/include/iomod.h =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/include/iomod.h,v retrieving revision 1.6 diff -u -p -u -p -r1.6 iomod.h --- sys/arch/hp700/include/iomod.h 27 May 2009 09:30:14 -0000 1.6 +++ sys/arch/hp700/include/iomod.h 24 Jul 2009 07:06:31 -0000 @@ -124,6 +124,7 @@ #define MAXMODBUS ((int)(FPA_IOMOD)) /* maximum modules/bus */ #define HPPA_FLEX_MASK 0xFFFC0000 /* (see below) */ +#define HPPA_FLEX_SIZE (~HPPA_FLEX_MASK + 1) #define HPPA_FLEX(a) (((a) & HPPA_FLEX_MASK) >> 18) /* size of HPA space for any device */ Index: sys/arch/hppa/hppa/copy.S =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/hppa/copy.S,v retrieving revision 1.12 diff -u -p -u -p -r1.12 copy.S --- sys/arch/hppa/hppa/copy.S 24 May 2009 09:17:59 -0000 1.12 +++ sys/arch/hppa/hppa/copy.S 24 Jul 2009 07:06:31 -0000 @@ -169,22 +169,20 @@ LEAF_ENTRY(spstrcpy) stw %t2, PCB_ONFAULT+U_PCB(%r31) ldw HPPA_FRAME_ARG(4)(%sp), %ret1 /* size */ - mfsp %sr2, %ret0 /* XXX need this? */ mtsp %arg0, %sr1 - mtsp %arg2, %sr2 + mtsp %arg2, %sr3 copy %arg1, %arg0 /* save src */ L$spstrcpy_loop: comb,=,n %r0, %ret1, L$spstrcpy_exit ldbs,ma 1(%sr1, %arg1), %t1 - stbs,ma %t1, 1(%sr2, %arg3) + stbs,ma %t1, 1(%sr3, %arg3) comb,<> %r0, %t1, L$spstrcpy_loop ldo -1(%ret1), %ret1 L$spstrcpy_exit: /* reset fault handler */ stw %r0, PCB_ONFAULT+U_PCB(%r31) - mtsp %r0, %sr2 /* XXX need this? */ sub %arg1, %arg0, %arg1 ldw HPPA_FRAME_ARG(5)(%sp), %arg0 /* rsize */ comiclr,= 0, %arg0, %r0 @@ -325,7 +323,7 @@ ENTRY(hppa_ktext_stw, HPPA_FRAME_SIZE) bv,n %r0(%rp) EXIT(hppa_ktext_stw) -ENTRY(hppa_ktext_stb, HPPA_FRAME_SIZE) +ENTRY(hppa_ktext_stb, 0) /* * Make the deposit location for the byte in the Index: sys/arch/hppa/hppa/hppa_machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/hppa/hppa_machdep.c,v retrieving revision 1.17 diff -u -p -u -p -r1.17 hppa_machdep.c --- sys/arch/hppa/hppa/hppa_machdep.c 1 Jun 2009 07:10:14 -0000 1.17 +++ sys/arch/hppa/hppa/hppa_machdep.c 24 Jul 2009 07:06:31 -0000 @@ -50,6 +50,12 @@ __KERNEL_RCSID(0, "$NetBSD: hppa_machdep /* the following is used externally (sysctl_hw) */ char machine_arch[] = MACHINE_ARCH; /* from */ +#ifdef CACHE_DEBUG +struct cache_debug cd_log[CACHE_DEBUG_LOG_MAX]; +int cd_first = 0; +int cd_last = 0; +#endif + /* * XXX fredette - much of the TLB trap handler setup should * probably be moved here from hp700/hp700/machdep.c, seeing @@ -305,12 +311,12 @@ cpu_setmcontext(struct lwp *l, const mco tf->tf_iioq_tail |= HPPA_PC_PRIV_USER; } -#if 0 tf->tf_sr0 = gr[_REG_SR0]; tf->tf_sr1 = gr[_REG_SR1]; tf->tf_sr2 = gr[_REG_SR2]; tf->tf_sr3 = gr[_REG_SR3]; tf->tf_sr4 = gr[_REG_SR4]; +#if 0 tf->tf_cr26 = gr[_REG_CR26]; tf->tf_cr27 = gr[_REG_CR27]; #endif @@ -355,18 +361,52 @@ hppa_ras(struct lwp *l) } } +/* + * Preempt the current process if in interrupt from user mode, + * or after the current trap/syscall if in system mode. + */ void cpu_need_resched(struct cpu_info *ci, int flags) { +#if defined(MULTIPROCESSOR) bool immed = (flags & RESCHED_IMMED) != 0; +#endif /* defined(MULTIPROCESSOR) */ + +#if defined(MULTIPROCESSOR) + aston(ci->ci_data.cpu_onproc); +#else + setsoftast(); +#endif /* defined(MULTIPROCESSOR) */ - if (ci->ci_want_resched && !immed) - return; ci->ci_want_resched = 1; #ifdef MULTIPROCESSOR if (ci->ci_curlwp != ci->ci_data.cpu_idlelwp) { - /* aston(ci->ci_curlwp); */ - setsoftast(); +#if defined(MULTIPROCESSOR) + if (immed && ci != curcpu()) { + /* XXXNH IPI */; + } +#endif /* defined(MULTIPROCESSOR) */ } #endif } + +#ifdef DEBUG_CACHE +void dump_cache_debug(void); + +void +dump_cache_debug(void) +{ + int i = cd_first; + + _fdcache(HPPA_KERNEL_SID, cd_log, sizeof(cd_log)); + + do { + printf("%d %p [%d:%08x->%08xlx) %zu\n", cd_log[i].cd_type, + cd_log[i].cd_caller, cd_log[i].cd_space, (int) cd_log[i].cd_va, + cd_log[i].cd_va + cd_log[i].cd_sz, cd_log[i].cd_sz); + + if (++i >= CACHE_DEBUG_LOG_MAX) + i = 0; + } while (i != cd_last); +} +#endif Index: sys/arch/hppa/hppa/pmap.c =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/hppa/pmap.c,v retrieving revision 1.49 diff -u -p -u -p -r1.49 pmap.c --- sys/arch/hppa/hppa/pmap.c 30 Apr 2009 07:01:27 -0000 1.49 +++ sys/arch/hppa/hppa/pmap.c 24 Jul 2009 07:06:33 -0000 @@ -64,6 +64,28 @@ * Hewlett-Packard, February 1994, Third Edition */ +/* + * HPPA physical map management code. + * + * History: + * + * This pmap was ported to NetBSD from the OpenBSD pmap by Nick Hudson + * with assistance from Matt Fleming. The port included addition of + * non-equivalent alias handling. + * + * The BTLB handling code came from Matt Fredette in the original + * NetBSD/hp700 pmap. + * + * Notes: + * All page table access is done via VA == PA mappings. This simplifies + * the trap handler / pmap code considerably as the trap handler run in + * physical mode. + * + * The kernel page table pages are statically allocated in + * pmap_bootstrap() and are never freed. + */ + + #include __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.49 2009/04/30 07:01:27 skrll Exp $"); @@ -90,6 +112,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.4 #include #endif +#define PMAPDEBUG #ifdef PMAPDEBUG #define static /**/ @@ -121,8 +144,10 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.4 #define PDB_POOL 0x00040000 #define PDB_ALIAS 0x00080000 int pmapdebug = 0 +#if 1 | PDB_INIT | PDB_FOLLOW +#else | PDB_VP | PDB_PV | PDB_ENTER @@ -131,6 +156,7 @@ int pmapdebug = 0 | PDB_PROTECT | PDB_PHYS | PDB_ALIAS +#endif ; #else #define DPRINTF(l,s) /* */ @@ -147,6 +173,7 @@ struct pool pmap_pool; struct pool pmap_pv_pool; int pmap_pvlowat = 252; bool pmap_initialized = false; +struct pv_entry *kpvs; static kmutex_t pmaps_lock; @@ -197,8 +224,11 @@ static inline void pmap_pte_set(volatile static inline pt_entry_t pmap_vp_find(pmap_t, vaddr_t); +static inline struct pv_entry *pmap_kpv_alloc(vaddr_t); +static inline void pmap_kpv_free(struct pv_entry *); static inline struct pv_entry *pmap_pv_alloc(void); static inline void pmap_pv_free(struct pv_entry *); + static inline void pmap_pv_enter(struct vm_page *, struct pv_entry *, pmap_t, vaddr_t , struct vm_page *, u_int); static inline struct pv_entry *pmap_pv_remove(struct vm_page *, pmap_t, @@ -229,6 +259,28 @@ static bool __changebit(struct vm_page * #define pmap_pvh_attrs(a) \ (((a) & (PVF_MOD|PVF_REF|PVF_WRITE|PVF_UNCACHEABLE)) ^ PVF_REF) +/* + * Locking: (stolen from the alpha pmap) + * + * * pmap_main_lock - This lock is used to prevent deadlock and/or + * provide mutex access to the pmap module. Most operations lock + * the pmap first, then PV lists as needed. However, some operations, + * such as pmap_page_protect(), lock the PV lists before locking + * the pmaps. To prevent deadlock, we require a mutex lock on the + * pmap module if locking in the PV->pmap direction. This is + * implemented by acquiring a (shared) read lock on pmap_main_lock + * if locking pmap->PV and a (exclusive) write lock if locking in + * the PV->pmap direction. Since only one thread can hold a write + * lock at a time, this provides the mutex. + */ + +krwlock_t pmap_main_lock; + +#define PMAP_MAP_TO_HEAD_LOCK() rw_enter(&pmap_main_lock, RW_READER) +#define PMAP_MAP_TO_HEAD_UNLOCK() rw_exit(&pmap_main_lock) +#define PMAP_HEAD_TO_MAP_LOCK() rw_enter(&pmap_main_lock, RW_WRITER) +#define PMAP_HEAD_TO_MAP_UNLOCK() rw_exit(&pmap_main_lock) + #define PMAP_LOCK(pm) \ do { \ if ((pm) != pmap_kernel()) \ @@ -256,7 +308,14 @@ pmap_pagealloc(struct uvm_object *obj, v void pmap_pagefree(struct vm_page *pg) { - fdcache(HPPA_SID_KERNEL, VM_PAGE_TO_PHYS(pg), PAGE_SIZE); + paddr_t pa = VM_PAGE_TO_PHYS(pg); + + pdcache(HPPA_SID_KERNEL, VM_PAGE_TO_PHYS(pg), PAGE_SIZE); + + /* XXXNH PA2.0 only */ + pdtlb(HPPA_SID_KERNEL, pa); + pitlb(HPPA_SID_KERNEL, pa); + uvm_pagefree(pg); } @@ -493,8 +552,9 @@ pmap_dump_pv(paddr_t pa) printf("pg %p attr 0x%08x aliases %d\n", pg, pg->mdpage.pvh_attrs, pg->mdpage.pvh_aliases); for (pve = pg->mdpage.pvh_list; pve; pve = pve->pv_next) - printf("%x:%lx\n", pve->pv_pmap->pm_space, - pve->pv_va & PV_VAMASK); + printf("%x:%lx %s\n", pve->pv_pmap->pm_space, + pve->pv_va & PV_VAMASK, + (pve->pv_va & PV_KENTER) ? "unmanaged" : ""); mutex_exit(&pg->mdpage.pvh_lock); } #endif @@ -523,7 +583,7 @@ pmap_check_alias(struct vm_page *pg, str /* we should only be looking if we're not PVF_NC */ KASSERT((pg->mdpage.pvh_attrs & PVF_NC) == 0); - KASSERT(mutex_owned(&pg->mdpage.pvh_lock)); + KASSERT((va & PV_KENTER) || mutex_owned(&pg->mdpage.pvh_lock)); if (ptep) { attrs = pmap_pvh_attrs(*ptep); @@ -609,6 +669,35 @@ pmap_check_alias(struct vm_page *pg, str } /* + * This allocates and returns a new struct pv_entry for unmanaged mappings. + */ +static inline struct pv_entry * +pmap_kpv_alloc(vaddr_t va) +{ + struct pv_entry *pv; + + pv = &kpvs[(va - SYSCALLGATE) / PAGE_SIZE]; + + DPRINTF(PDB_FOLLOW|PDB_PV, ("%s: va 0x%08x %p\n", __func__, (int)va, +pv)); + + return (pv); +} + +static inline void +pmap_kpv_free(struct pv_entry *pv) +{ + + DPRINTF(PDB_FOLLOW|PDB_PV, ("%s: %p\n", __func__, pv)); + KASSERT(pv->pv_pmap == pmap_kernel()); + pv->pv_pmap = NULL; + pv->pv_va = 0; + pv->pv_ptp = NULL; + pv->pv_next = NULL; + +} + +/* * This allocates and returns a new struct pv_entry. */ static inline struct pv_entry * @@ -643,7 +732,7 @@ pmap_pv_enter(struct vm_page *pg, struct DPRINTF(PDB_FOLLOW|PDB_PV, ("%s(%p, %p, %p, 0x%x, %p, 0x%x)\n", __func__, pg, pve, pm, (int)va, pdep, flags)); - KASSERT(mutex_owned(&pg->mdpage.pvh_lock)); + KASSERT((flags & PV_KENTER) || mutex_owned(&pg->mdpage.pvh_lock)); pve->pv_pmap = pm; pve->pv_va = va | flags; @@ -657,11 +746,12 @@ pmap_pv_remove(struct vm_page *pg, pmap_ { struct pv_entry **pve, *pv; - KASSERT(mutex_owned(&pg->mdpage.pvh_lock)); + KASSERT((va & PV_KENTER) || mutex_owned(&pg->mdpage.pvh_lock)); for (pv = *(pve = &pg->mdpage.pvh_list); pv; pv = *(pve = &(*pve)->pv_next)) - if (pv->pv_pmap == pmap && (pv->pv_va & PV_VAMASK) == va) { + if (pv->pv_pmap == pmap && + (pv->pv_va & PV_VAMASK) == (va & PV_VAMASK)) { *pve = pv->pv_next; break; } @@ -688,6 +778,7 @@ pmap_bootstrap(vaddr_t vstart) vsize_t btlb_entry_min, btlb_entry_max, btlb_entry_got; paddr_t ksrx, kerx, ksro, kero, ksrw, kerw; paddr_t phys_start, phys_end; + size_t nkpvs; extern int usebtlb; /* Provided by the linker script */ @@ -799,6 +890,7 @@ pmap_bootstrap(vaddr_t vstart) va = HPPA_IOBEGIN; /* now map the pde for the physmem */ memset((void *)addr, 0, PAGE_SIZE); + fdcache(HPPA_SID_KERNEL, addr, PAGE_SIZE); DPRINTF(PDB_INIT|PDB_VP, ("%s: pde premap 0x%08x 0x%08x\n", __func__, (int)va, (int)addr)); @@ -807,6 +899,20 @@ pmap_bootstrap(vaddr_t vstart) } /* + * Pre-allocate enough space for a struct pv_entry array big enough + * for all of KVA. + */ + + nkpvs = ((VM_MAX_KERNEL_ADDRESS - SYSCALLGATE) / PAGE_SIZE); + + kpvs = (struct pv_entry *)addr; + addr = (vaddr_t)(kpvs + nkpvs); + addr = round_page(addr); + + DPRINTF(PDB_INIT, ("%s: kpvs [%p..0x%8x)\n", __func__, kpvs, + (int)addr)); + + /* * At this point we've finished reserving memory for the kernel. */ /* XXXNH */ @@ -1578,7 +1684,9 @@ __changebit(struct vm_page *pg, u_int se struct pv_entry *pve; int res; +/* KASSERT(mutex_owned(&pg->mdpage.pvh_lock)); +*/ KASSERT(((set | clear) & ~(PVF_MOD|PVF_REF|PVF_UNCACHEABLE|PVF_WRITE)) == 0); @@ -1718,27 +1826,29 @@ pmap_flush_page(struct vm_page *pg, bool pdcache(pve->pv_pmap->pm_space, va, PAGE_SIZE); else fdcache(pve->pv_pmap->pm_space, va, PAGE_SIZE); + pdtlb(pve->pv_pmap->pm_space, va); + pitlb(pve->pv_pmap->pm_space, va); } mutex_exit(&pg->mdpage.pvh_lock); } /* - * pmap_zero_page(pa) + * pmap_zero_page(pg) * * Zeros the specified page. */ void pmap_zero_page(paddr_t pa) { - struct vm_page *pg = PHYS_TO_VM_PAGE(pa); - DPRINTF(PDB_FOLLOW|PDB_PHYS, ("%s(%x)\n", __func__, (int)pa)); - KASSERT(pg->mdpage.pvh_list == NULL); + KASSERT(PHYS_TO_VM_PAGE(pa)->mdpage.pvh_list == NULL); - pmap_flush_page(pg, true); memset((void *)pa, 0, PAGE_SIZE); fdcache(HPPA_SID_KERNEL, pa, PAGE_SIZE); + pdtlb(HPPA_SID_KERNEL, pa); + ficache(HPPA_SID_KERNEL, pa, PAGE_SIZE); + pitlb(HPPA_SID_KERNEL, pa); } /* @@ -1750,7 +1860,9 @@ void pmap_copy_page(paddr_t spa, paddr_t dpa) { struct vm_page *srcpg = PHYS_TO_VM_PAGE(spa); +#ifdef DEBUG struct vm_page *dstpg = PHYS_TO_VM_PAGE(dpa); +#endif DPRINTF(PDB_FOLLOW|PDB_PHYS, ("%s(%x, %x)\n", __func__, (int)spa, (int)dpa)); @@ -1758,12 +1870,17 @@ pmap_copy_page(paddr_t spa, paddr_t dpa) KASSERT(dstpg->mdpage.pvh_list == NULL); pmap_flush_page(srcpg, false); - pmap_flush_page(dstpg, true); memcpy((void *)dpa, (void *)spa, PAGE_SIZE); pdcache(HPPA_SID_KERNEL, spa, PAGE_SIZE); fdcache(HPPA_SID_KERNEL, dpa, PAGE_SIZE); + pdtlb(HPPA_SID_KERNEL, spa); + pdtlb(HPPA_SID_KERNEL, dpa); + ficache(HPPA_SID_KERNEL, spa, PAGE_SIZE); + ficache(HPPA_SID_KERNEL, dpa, PAGE_SIZE); + pitlb(HPPA_SID_KERNEL, spa); + pitlb(HPPA_SID_KERNEL, dpa); } void @@ -1787,9 +1904,9 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, v DPRINTF(PDB_FOLLOW|PDB_ENTER, ("%s(%x, %x, %x)\n", __func__, (int)va, (int)pa, prot)); - if (!(pde = pmap_pde_get(pmap_kernel()->pm_pdir, va)) && - !(pde = pmap_pde_alloc(pmap_kernel(), va, NULL))) - panic("pmap_kenter_pa: cannot allocate pde for va=0x%lx", va); + pde = pmap_pde_get(pmap_kernel()->pm_pdir, va); + KASSERT(pde); + opte = pmap_pte_get(pde, va); pte = pa | PTE_PROT(TLB_WIRED | TLB_REFTRAP | pmap_prot(pmap_kernel(), prot & VM_PROT_ALL)); @@ -1808,27 +1925,18 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, v KASSERT(pa < HPPA_IOBEGIN); - mutex_enter(&pg->mdpage.pvh_lock); - if (prot & PMAP_NC) pg->mdpage.pvh_attrs |= PVF_NC; else { struct pv_entry *pve; - pve = pmap_pv_alloc(); - if (!pve) - panic("%s: no pv entries available", - __func__); - DPRINTF(PDB_FOLLOW|PDB_ENTER, - ("%s(%x, %x, %x) TLB_KENTER\n", __func__, - (int)va, (int)pa, pte)); + pve = pmap_kpv_alloc(va); + KASSERT(pve != NULL); pmap_pv_enter(pg, pve, pmap_kernel(), va, NULL, PV_KENTER); - pmap_check_alias(pg, pve, va, &pte); + pmap_check_alias(pg, pve, va | PV_KENTER, &pte); } - - mutex_exit(&pg->mdpage.pvh_lock); } } pmap_pte_set(pde, va, pte); @@ -1898,19 +2006,16 @@ pmap_kremove(vaddr_t va, vsize_t size) pmap_pte_set(pde, va, 0); if (pmap_initialized && (pg = PHYS_TO_VM_PAGE(PTE_PAGE(pte)))) { - mutex_enter(&pg->mdpage.pvh_lock); - - pve = pmap_pv_remove(pg, pmap, va); + pve = pmap_pv_remove(pg, pmap, va | PV_KENTER); + KASSERT(pve != NULL); if ((pg->mdpage.pvh_attrs & PVF_NC) == 0) - pmap_check_alias(pg, pg->mdpage.pvh_list, va, - NULL); - - pg->mdpage.pvh_attrs &= ~PVF_NC; + pmap_check_alias(pg, pg->mdpage.pvh_list, + va | PV_KENTER, NULL); + else + pg->mdpage.pvh_attrs &= ~PVF_NC; - mutex_exit(&pg->mdpage.pvh_lock); - if (pve != NULL) - pmap_pv_free(pve); + pmap_kpv_free(pve); } } DPRINTF(PDB_FOLLOW|PDB_REMOVE, ("%s: leaving\n", __func__)); Index: sys/arch/hppa/hppa/process_machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/hppa/process_machdep.c,v retrieving revision 1.11 diff -u -p -u -p -r1.11 process_machdep.c --- sys/arch/hppa/hppa/process_machdep.c 30 Apr 2009 15:34:24 -0000 1.11 +++ sys/arch/hppa/hppa/process_machdep.c 24 Jul 2009 07:06:33 -0000 @@ -49,11 +49,14 @@ __KERNEL_RCSID(0, "$NetBSD: process_mach #include +int nhdebug2 = 0; int process_read_regs(struct lwp *l, struct reg *regs) { struct trapframe *tf = l->l_md.md_regs; +if (nhdebug2) +printf("%s: pc=%08x ret0=%08x(%p) ipsw=%08x r22=%08x\n", __func__, tf->tf_iioq_head, tf->tf_ret0, &tf->tf_ret0, tf->tf_ipsw, tf->tf_t1); regs->r_regs[ 0] = tf->tf_ipsw; regs->r_regs[ 1] = tf->tf_r1; regs->r_regs[ 2] = tf->tf_rp; @@ -171,6 +174,8 @@ process_write_regs(struct lwp *l, const tf->tf_sr2 = regs->r_sr2; tf->tf_sr3 = regs->r_sr3; tf->tf_sr4 = regs->r_sr4; +if (nhdebug2) +printf("%s: pc=%08x ret0=%08x(%p) ipsw=%08x r22=%08x\n", __func__, tf->tf_iioq_head, tf->tf_ret0, &tf->tf_ret0, tf->tf_ipsw, tf->tf_t1); return 0; } Index: sys/arch/hppa/hppa/sigcode.S =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/hppa/sigcode.S,v retrieving revision 1.6 diff -u -p -u -p -r1.6 sigcode.S --- sys/arch/hppa/hppa/sigcode.S 11 Dec 2005 12:17:37 -0000 1.6 +++ sys/arch/hppa/hppa/sigcode.S 24 Jul 2009 07:06:33 -0000 @@ -110,14 +110,16 @@ L$sigcode_bounce: /* Make a SYS___sigreturn14 system call. */ copy %r3, %arg0 ldil L%SYSCALLGATE, %r1 + mtsp %r0, %sr2 .call - ble 4(%sr7, %r1) + ble 4(%sr2, %r1) ldi SYS_compat_16___sigreturn14, %t1 /* Make a SYS_exit system call. */ copy %ret0, %arg0 ldil L%SYSCALLGATE, %r1 + mtsp %r0, %sr2 .call - ble 4(%sr7, %r1) + ble 4(%sr2, %r1) ldi SYS_exit, %t1 ALTENTRY(esigcode) EXIT(sigcode) Index: sys/arch/hppa/hppa/support.S =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/hppa/support.S,v retrieving revision 1.5 diff -u -p -u -p -r1.5 support.S --- sys/arch/hppa/hppa/support.S 11 Dec 2005 12:17:37 -0000 1.5 +++ sys/arch/hppa/hppa/support.S 24 Jul 2009 07:06:33 -0000 @@ -78,7 +78,11 @@ * void fdcache(pa_space_t sp, vaddr_t va, vsize_t size); */ .import dcache_stride, data +#ifdef DEBUG_CACHE +LEAF_ENTRY(_fdcache) +#else LEAF_ENTRY(fdcache) +#endif ldil L%dcache_stride,%t1 ldw R%dcache_stride(%t1), %arg3 @@ -131,7 +135,11 @@ EXIT(fdcache) * void pdcache(pa_space_t sp, vaddr_t va, vsize_t size); */ .import dcache_stride, data +#ifdef DEBUG_CACHE +LEAF_ENTRY(_pdcache) +#else LEAF_ENTRY(pdcache) +#endif ldil L%dcache_stride,%t1 ldw R%dcache_stride(%t1), %arg3 @@ -184,7 +192,11 @@ EXIT(pdcache) * void ficache(pa_space_t sp, vaddr_t va, vsize_t size); */ .import icache_stride, data +#ifdef DEBUG_CACHE +LEAF_ENTRY(_ficache) +#else LEAF_ENTRY(ficache) +#endif ldil L%icache_stride,%t1 ldw R%icache_stride(%t1), %arg3 Index: sys/arch/hppa/hppa/trap.S =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/hppa/trap.S,v retrieving revision 1.30 diff -u -p -u -p -r1.30 trap.S --- sys/arch/hppa/hppa/trap.S 24 May 2009 09:17:59 -0000 1.30 +++ sys/arch/hppa/hppa/trap.S 24 Jul 2009 07:06:34 -0000 @@ -189,7 +189,29 @@ bsd_syscall: nop ! nop ! nop ! nop .size gateway_page, .-gateway_page +#if 0 + /* This function MUST be located at 0xe0 for glibc's threading + mechanism to work. DO NOT MOVE THIS CODE EVER! */ +set_thread_pointer: + gate L$set_tls,%r0 + + depi 3, 31, 2, %r31 /* Ensure we return into user mode. */ + +L$set_tls: + be 0(%sr7,%r31) /* return to user space */ + mtctl %arg0, TR_TLS + + /* Increase the chance of trapping if random jumps occur to this + address, fill from 0xf0 to 0x100 */ + .rept 4 + KILL_INSN + .endr +#endif + + +/* .align NBPG +*/ .export gateway_page_end, entry gateway_page_end: @@ -214,7 +236,6 @@ syscall_entry: * WHAT ARE WE RELYING ON? * */ - /* t2 = curlwp PCB */ mfctl CR_CURLWP, %t3 ldw L_ADDR(%sr1, %t3), %t2 /* XXX can use ,sl */ @@ -232,13 +253,14 @@ syscall_entry: stw %t1, TF_R22 -TRAPFRAME_SIZEOF(%sr1, %t3) /* syscall # */ copy %sp, %t4 - /* gotta save the args, in case we gonna restart */ + /* gotta save the %args, in case we gonna restart */ stw %arg3, TF_R23 -TRAPFRAME_SIZEOF(%sr1, %t3) stw %arg2, TF_R24 -TRAPFRAME_SIZEOF(%sr1, %t3) stw %arg1, TF_R25 -TRAPFRAME_SIZEOF(%sr1, %t3) stw %arg0, TF_R26 -TRAPFRAME_SIZEOF(%sr1, %t3) stw %r27, TF_R27 -TRAPFRAME_SIZEOF(%sr1, %t3) /* dp */ stw %sp, TF_R30 -TRAPFRAME_SIZEOF(%sr1, %t3) /* user stack */ + copy %t3, %sp /* * Make space for the syscall arguments. @@ -340,7 +362,7 @@ syscall_entry: * Save the rest of the CPU context */ - /* XXXNH: Should do a be 0(%sr1, %r31) instead of rfi when possible */ + /* XXXNH: Should really do a be 0(%sr1, %r31) instead of rfi when possible */ ldo 4(%r31), %arg1 stw %r31, TF_IIOQH-TRAPFRAME_SIZEOF(%sr1, %t3) stw %arg1, TF_IIOQT-TRAPFRAME_SIZEOF(%sr1, %t3) @@ -349,6 +371,7 @@ syscall_entry: stw %arg0, TF_IISQH-TRAPFRAME_SIZEOF(%sr1, %t3) stw %arg0, TF_IISQT-TRAPFRAME_SIZEOF(%sr1, %t3) + /* XXXNH: Why CR20/CR21? */ stw %arg0, TF_CR20-TRAPFRAME_SIZEOF(%sr1, %t3) stw %r31, TF_CR21-TRAPFRAME_SIZEOF(%sr1, %t3) Index: sys/arch/hppa/hppa/trap.c =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/hppa/trap.c,v retrieving revision 1.59 diff -u -p -u -p -r1.59 trap.c --- sys/arch/hppa/hppa/trap.c 30 Apr 2009 07:01:27 -0000 1.59 +++ sys/arch/hppa/hppa/trap.c 24 Jul 2009 07:06:35 -0000 @@ -189,6 +189,7 @@ struct trapframe *sanity_frame; struct lwp *sanity_lwp; int sanity_checked = 0; void frame_sanity_check(int, int, struct trapframe *, struct lwp *); +void trap_dump_trapframe(struct trapframe *); #endif @@ -211,8 +212,12 @@ userret(struct lwp *l, register_t pc, u_ { struct proc *p = l->l_proc; - if (curcpu()->ci_want_resched) { - preempt(); + if (astpending) { + astpending = 0; + uvmexp.softs++; + + if (curcpu()->ci_want_resched) + preempt(); } mi_userret(l); @@ -472,6 +477,7 @@ out: "sp 0x%x pc 0x%x\n", where, type, sanity_frame, sanity_lwp, sanity_checked, tf->tf_sp, tf->tf_iioq_head); + trap_dump_trapframe(sanity_frame); (void) trap_kdebug(T_IBREAK, 0, tf); sanity_frame = NULL; sanity_lwp = NULL; @@ -1374,9 +1380,8 @@ startlwp(void *arg) err = cpu_setmcontext(l, &uc->uc_mcontext, uc->uc_flags); #if DIAGNOSTIC - if (err) { + if (err) printf("Error %d from cpu_setmcontext.", err); - } #endif pool_put(&lwp_uc_pool, uc); @@ -1391,3 +1396,44 @@ upcallret(struct lwp *l) { userret(l, l->l_md.md_regs->tf_iioq_head, 0); } + +void trap_dump_trapframe(struct trapframe *); +void +trap_dump_trapframe(struct trapframe *tf) +{ + printf("General registers\n"); + printf("r00-03 %08x %08x %08x %08x\n", 0, tf->tf_r1, tf->tf_rp, tf->tf_r3); + printf("r04-07 %08x %08x %08x %08x\n", tf->tf_r4, tf->tf_r5, tf->tf_r6, tf->tf_r7); + printf("r08-11 %08x %08x %08x %08x\n", tf->tf_r8, tf->tf_r9, tf->tf_r10, tf->tf_r11); + printf("r12-15 %08x %08x %08x %08x\n", tf->tf_r12, tf->tf_r13, tf->tf_r14, tf->tf_r15); + printf("r16-19 %08x %08x %08x %08x\n", tf->tf_r16, tf->tf_r17, tf->tf_r18, tf->tf_t4); + printf("r20-23 %08x %08x %08x %08x\n", tf->tf_t3, tf->tf_t2, tf->tf_t1, tf->tf_arg3); + printf("r24-27 %08x %08x %08x %08x\n", tf->tf_arg2, tf->tf_arg1, tf->tf_arg0, tf->tf_dp); + printf("r28-31 %08x %08x %08x %08x\n", tf->tf_ret0, tf->tf_ret1, tf->tf_sp, tf->tf_r31); + printf("\n"); + printf("Space registers\n"); + printf("s00-03 %08x %08x %08x %08x\n", tf->tf_sr0, tf->tf_sr1, tf->tf_sr2, tf->tf_sr3); + printf("s04-07 %08x %08x %08x %08x\n", tf->tf_sr4, tf->tf_sr5, tf->tf_sr6, tf->tf_sr7); + printf("\n"); + printf("Instruction queues\n"); + printf("iisq: %08x %08x\niioq: %08x %08x\n", tf->tf_iisq_head, tf->tf_iisq_tail, tf->tf_iioq_head, tf->tf_iioq_tail); + printf("\n"); + printf("Interrupt state\n"); + printf("isr: %08x\nior: %08x\niir: %08x\n", tf->tf_isr, tf->tf_ior, tf->tf_iir); + printf("\n"); + printf("Other state\n"); + printf("eiem: %08x\n", tf->tf_eiem); + printf("ipsw: %08x\n", tf->tf_ipsw); + printf("flags: %08x\n", tf->tf_flags); + printf("sar: %08x\n", tf->tf_sar); + printf("pidr1: %08x\n", tf->tf_pidr1); /* cr8 */ + printf("pidr2: %08x\n", tf->tf_pidr2); /* cr9 */ + printf("pidr3: %08x\n", tf->tf_pidr3); /* cr12 */ + printf("pidr4: %08x\n", tf->tf_pidr4); /* cr13 */ + printf("rctr: %08x\n", tf->tf_rctr); /* cr0 */ + printf("ccr: %08x\n", tf->tf_ccr); /* cr10 */ + printf("eirr: %08x\n", tf->tf_eirr); /* cr23 - DDB */ + printf("vtop: %08x\n", tf->tf_vtop); /* cr25 - DDB */ + printf("cr28: %08x\n", tf->tf_cr28); /* - DDB */ + printf("cr30: %08x\n", tf->tf_cr30); /* uaddr */ +} Index: sys/arch/hppa/hppa/vm_machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/hppa/vm_machdep.c,v retrieving revision 1.36 diff -u -p -u -p -r1.36 vm_machdep.c --- sys/arch/hppa/hppa/vm_machdep.c 3 Jun 2009 21:08:51 -0000 1.36 +++ sys/arch/hppa/hppa/vm_machdep.c 24 Jul 2009 07:06:35 -0000 @@ -55,6 +55,7 @@ void cpu_swapin(struct lwp *l) { struct trapframe *tf = l->l_md.md_regs; + bool ok; vaddr_t pcb = (vaddr_t)l->l_addr; #ifdef DIAGNOSTIC vaddr_t maxsp = pcb + USPACE; @@ -65,8 +66,13 @@ cpu_swapin(struct lwp *l) * Stash the physical for the pcb of U for later perusal */ l->l_addr->u_pcb.pcb_uva = pcb; - tf->tf_cr30 = kvtop((void *)pcb); + + ok = pmap_extract(pmap_kernel(), l->l_addr->u_pcb.pcb_uva, + (paddr_t *)&tf->tf_cr30); + KASSERT(ok); + fdcache(HPPA_SID_KERNEL, pcb, sizeof(l->l_addr->u_pcb)); + /* XXXNH - purge cache (and TLBs on PA2.0??? */ #ifdef DIAGNOSTIC /* Create the kernel stack red zone. */ @@ -129,8 +135,8 @@ cpu_lwp_fork(struct lwp *l1, struct lwp cpu_swapin(l2); /* Load all of the user's space registers. */ - tf->tf_sr0 = tf->tf_sr1 = tf->tf_sr3 = tf->tf_sr2 = - tf->tf_sr4 = tf->tf_sr5 = tf->tf_sr6 = space; + tf->tf_sr0 = tf->tf_sr1 = tf->tf_sr2 = + tf->tf_sr4 = tf->tf_sr5 = tf->tf_sr6 = tf->tf_sr7 = space; tf->tf_iisq_head = tf->tf_iisq_tail = space; /* Load the protection registers */ @@ -140,7 +146,7 @@ cpu_lwp_fork(struct lwp *l1, struct lwp * theoretically these could be inherited from the father, * but just in case. */ - tf->tf_sr7 = HPPA_SID_KERNEL; + tf->tf_sr2 = HPPA_SID_KERNEL; mfctl(CR_EIEM, tf->tf_eiem); tf->tf_ipsw = PSW_C | PSW_Q | PSW_P | PSW_D | PSW_I /* | PSW_L */ | (kpsw & PSW_O); Index: sys/arch/hppa/include/cpufunc.h =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/include/cpufunc.h,v retrieving revision 1.11 diff -u -p -u -p -r1.11 cpufunc.h --- sys/arch/hppa/include/cpufunc.h 30 Apr 2009 07:01:27 -0000 1.11 +++ sys/arch/hppa/include/cpufunc.h 24 Jul 2009 07:06:35 -0000 @@ -92,6 +92,11 @@ static __inline register_t ldsid(vaddr_t #define ssm(v,r) __asm volatile("ssm %1,%0": "=r" (r): "i" (v)) #define rsm(v,r) __asm volatile("rsm %1,%0": "=r" (r): "i" (v)) + +/* XXX load a space register with HPPA_SID_KERNEL ? */ +#define lci(v,r) __asm volatile("lci 0(%%sr0, %1), %0" : "=r" (ci) : "r" (va)) + + /* Move to system mask. Old value of system mask is returned. */ static __inline register_t mtsm(register_t mask) { register_t ret; @@ -165,9 +170,85 @@ pdtlbe(pa_space_t sp, vaddr_t va) #ifdef _KERNEL extern int (*cpu_hpt_init)(vaddr_t, vsize_t); -void ficache(pa_space_t, vaddr_t, vsize_t); -void fdcache(pa_space_t, vaddr_t, vsize_t); -void pdcache(pa_space_t, vaddr_t, vsize_t); +#ifdef DEBUG_CACHE +void _ficache(pa_space_t sp, vaddr_t va, vsize_t size); +void _fdcache(pa_space_t sp, vaddr_t va, vsize_t size); +void _pdcache(pa_space_t sp, vaddr_t va, vsize_t size); + +struct cache_debug { + int cd_type; + void *cd_caller; + pa_space_t cd_space; + vaddr_t cd_va; + vsize_t cd_sz; +}; + +extern struct cache_debug cd_log[]; +extern int cd_first; +extern int cd_last; + +#define CACHE_DEBUG_LOG_MAX 4096 + +static inline int +cd_next(void) +{ + if (++cd_last >= CACHE_DEBUG_LOG_MAX) + cd_last = 0; + + if (cd_first == cd_last && ++cd_first >= CACHE_DEBUG_LOG_MAX) + cd_first = 0; + + return cd_first; +} + +static inline void +ficache(pa_space_t sp, vaddr_t va, vsize_t size) +{ + int x = cd_next(); + + cd_log[x].cd_type = 0; + cd_log[x].cd_caller = __builtin_return_address(0); + cd_log[x].cd_space = sp; + cd_log[x].cd_va = va; + cd_log[x].cd_sz = size; + + _ficache(sp, va, size); +} + +static inline void +fdcache(pa_space_t sp, vaddr_t va, vsize_t size) +{ + int x = cd_next(); + + cd_log[x].cd_type = 1; + cd_log[x].cd_caller = __builtin_return_address(0); + cd_log[x].cd_space = sp; + cd_log[x].cd_va = va; + cd_log[x].cd_sz = size; + + _fdcache(sp, va, size); +} + +static inline void +pdcache(pa_space_t sp, vaddr_t va, vsize_t size) +{ + int x = cd_next(); + + cd_log[x].cd_type = 2; + cd_log[x].cd_caller = __builtin_return_address(0); + cd_log[x].cd_space = sp; + cd_log[x].cd_va = va; + cd_log[x].cd_sz = size; + + _pdcache(sp, va, size); +} + +#else +void ficache(pa_space_t sp, vaddr_t va, vsize_t size); +void fdcache(pa_space_t sp, vaddr_t va, vsize_t size); +void pdcache(pa_space_t sp, vaddr_t va, vsize_t size); +#endif + void fcacheall(void); void ptlball(void); hppa_hpa_t cpu_gethpa(int); Index: sys/arch/hppa/include/db_machdep.h =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/include/db_machdep.h,v retrieving revision 1.7 diff -u -p -u -p -r1.7 db_machdep.h --- sys/arch/hppa/include/db_machdep.h 7 Apr 2007 08:38:28 -0000 1.7 +++ sys/arch/hppa/include/db_machdep.h 24 Jul 2009 07:06:35 -0000 @@ -113,8 +113,26 @@ static __inline int inst_trap_return(u_i return (ins & 0xfc001fc0) == 0x00000ca0; } +#if 1 /* NetBSD */ #define db_clear_single_step(r) ((r)->tf_ipsw &= ~PSW_R) #define db_set_single_step(r) ((r)->tf_ipsw |= PSW_R) +#else /* OpenBSD */ +#define SOFTWARE_SSTEP 1 +#define SOFTWARE_SSTEP_EMUL 1 + +static __inline db_addr_t +next_instr_address(db_addr_t addr, int b) +{ + return (addr + 4); +} + +#define branch_taken(ins,pc,f,regs) branch_taken1(ins, pc, regs) +static __inline db_addr_t +branch_taken1(int ins, db_addr_t pc, db_regs_t *regs) +{ + return (pc); +} +#endif int db_valid_breakpoint(db_addr_t); int kdb_trap(int, int, db_regs_t *); Index: sys/arch/hppa/include/lock.h =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/include/lock.h,v retrieving revision 1.16 diff -u -p -u -p -r1.16 lock.h --- sys/arch/hppa/include/lock.h 28 Apr 2008 20:23:23 -0000 1.16 +++ sys/arch/hppa/include/lock.h 24 Jul 2009 07:06:35 -0000 @@ -85,9 +85,13 @@ __sync(void) static __inline void __cpu_simple_lock_init(__cpu_simple_lock_t *alp) { - alp->csl_lock[0] = alp->csl_lock[1] = + volatile unsigned long *__aptr = __SIMPLELOCK_ALIGN(alp); + + alp->csl_lock[0] = alp->csl_lock[1] = alp->csl_lock[2] = alp->csl_lock[3] = - __SIMPLELOCK_RAW_UNLOCKED; + 0xdeadbeef; + + *__aptr =__SIMPLELOCK_RAW_UNLOCKED; __sync(); } Index: sys/arch/hppa/include/param.h =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/include/param.h,v retrieving revision 1.13 diff -u -p -u -p -r1.13 param.h --- sys/arch/hppa/include/param.h 30 Apr 2009 07:01:27 -0000 1.13 +++ sys/arch/hppa/include/param.h 24 Jul 2009 07:06:35 -0000 @@ -96,7 +96,7 @@ /* * Size of kernel malloc arena in logical pages */ -#define NKMEMPAGES_MIN_DEFAULT ((16 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MIN_DEFAULT ((4 * 1024 * 1024) >> PAGE_SHIFT) #define NKMEMPAGES_MAX_DEFAULT ((16 * 1024 * 1024) >> PAGE_SHIFT) /* Index: sys/arch/hppa/include/pmap.h =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/include/pmap.h,v retrieving revision 1.21 diff -u -p -u -p -r1.21 pmap.h --- sys/arch/hppa/include/pmap.h 24 May 2009 06:53:35 -0000 1.21 +++ sys/arch/hppa/include/pmap.h 24 Jul 2009 07:06:36 -0000 @@ -121,6 +121,9 @@ static inline vaddr_t hppa_map_poolpage( static inline paddr_t hppa_unmap_poolpage(vaddr_t va) { pdcache(HPPA_SID_KERNEL, va, PAGE_SIZE); + pdtlb(HPPA_SID_KERNEL, va); + ficache(HPPA_SID_KERNEL, va, PAGE_SIZE); + pitlb(HPPA_SID_KERNEL, va); return (paddr_t)va; } Index: sys/arch/hppa/include/vmparam.h =================================================================== RCS file: /cvsroot/src/sys/arch/hppa/include/vmparam.h,v retrieving revision 1.14 diff -u -p -u -p -r1.14 vmparam.h --- sys/arch/hppa/include/vmparam.h 30 Apr 2009 07:01:27 -0000 1.14 +++ sys/arch/hppa/include/vmparam.h 24 Jul 2009 07:06:36 -0000 @@ -53,7 +53,7 @@ #define MAXTSIZ (0x40000000) /* max text size */ #endif #ifndef DFLDSIZ -#define DFLDSIZ (16*1024*1024) /* initial data size limit */ +#define DFLDSIZ (128*1024*1024) /* initial data size limit */ #endif #ifndef MAXDSIZ #define MAXDSIZ (USRSTACK-MAXTSIZ) /* max data size */ Index: sys/arch/i386/stand/mbr/mbr.S =================================================================== RCS file: /cvsroot/src/sys/arch/i386/stand/mbr/mbr.S,v retrieving revision 1.20 diff -u -p -u -p -r1.20 mbr.S --- sys/arch/i386/stand/mbr/mbr.S 28 Nov 2008 18:18:16 -0000 1.20 +++ sys/arch/i386/stand/mbr/mbr.S 24 Jul 2009 07:06:36 -0000 @@ -223,7 +223,7 @@ next_ptn: /* output menu item */ movw $prefix, %si incb (%si) - call message /* menu number */ + ;call message /* menu number */ mov (%si), %si /* ':' << 8 | '1' + count */ shl $2, %si /* const + count * 4 */ #define CONST (4 * ((':' << 8) + '1' - ((KEY_PTN1 - KEY_DISK1) & 0xff))) @@ -234,7 +234,7 @@ next_ptn: #endif #undef CONST mov %bx, %si - call message_crlf /* prompt */ + ;call message_crlf /* prompt */ #endif 4: add $0x10, %bp Index: sys/arch/i386/stand/mbr/mbr_bootsel/Makefile =================================================================== RCS file: /cvsroot/src/sys/arch/i386/stand/mbr/mbr_bootsel/Makefile,v retrieving revision 1.3 diff -u -p -u -p -r1.3 Makefile --- sys/arch/i386/stand/mbr/mbr_bootsel/Makefile 11 Dec 2005 12:17:49 -0000 1.3 +++ sys/arch/i386/stand/mbr/mbr_bootsel/Makefile 24 Jul 2009 07:06:36 -0000 @@ -2,6 +2,7 @@ PROG= mbr_bootsel AFLAGS+= -DBOOTSEL +AFLAGS+= -DNO_BANNER AFLAGS+= -DTERSE_ERROR AFLAGS+= -DBOOTSEL_FLAGS=MBR_BS_ACTIVE Index: sys/arch/sparc64/conf/kern.ldscript =================================================================== RCS file: /cvsroot/src/sys/arch/sparc64/conf/kern.ldscript,v retrieving revision 1.10 diff -u -p -u -p -r1.10 kern.ldscript --- sys/arch/sparc64/conf/kern.ldscript 17 Oct 2007 19:57:28 -0000 1.10 +++ sys/arch/sparc64/conf/kern.ldscript 24 Jul 2009 07:06:36 -0000 @@ -102,7 +102,11 @@ SECTIONS . = ALIGN(64 / 8); _end = . ; PROVIDE (end = .); - /* Stabs debugging sections. */ + /* These must appear regardless of . */ + .note.netbsd.ident : + { + KEEP(*(.note.netbsd.ident)); + } .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } @@ -110,19 +114,12 @@ SECTIONS .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) } - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to the beginning - of the section so we begin them at 0. */ - /* DWARF 1 */ .debug 0 : { *(.debug) } .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ .debug_info 0 : { *(.debug_info) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } @@ -130,14 +127,8 @@ SECTIONS .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } - /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } - /* These must appear regardless of . */ - .note.netbsd.ident : - { - KEEP(*(.note.netbsd.ident)); - } } Index: sys/compat/sa/compat_sa.c =================================================================== RCS file: /cvsroot/src/sys/compat/sa/compat_sa.c,v retrieving revision 1.10 diff -u -p -u -p -r1.10 compat_sa.c --- sys/compat/sa/compat_sa.c 16 Apr 2009 07:42:28 -0000 1.10 +++ sys/compat/sa/compat_sa.c 24 Jul 2009 07:06:38 -0000 @@ -43,6 +43,8 @@ #include "opt_sa.h" __KERNEL_RCSID(0, "$NetBSD: compat_sa.c,v 1.10 2009/04/16 07:42:28 skrll Exp $"); +#define QUEUEDEBUG 1 + #include #include #include @@ -114,7 +116,7 @@ static inline int sast_compare(struct sa static int sa_increaseconcurrency(struct lwp *, int); #endif static void sa_switchcall(void *); -static void sa_neverrun(void *); +static void sa_cache_lingerer(void *); static int sa_newcachelwp(struct lwp *, struct sadata_vp *); static void sa_makeupcalls(struct lwp *, struct sadata_upcall *); @@ -127,6 +129,8 @@ static void sa_upcall_getstate(union sau void sa_putcachelwp(struct proc *, struct lwp *); struct lwp *sa_getcachelwp(struct proc *, struct sadata_vp *); static void sa_setrunning(struct lwp *); +static u_int sa_lwpcache_unsleep(lwp_t *, bool); +static u_int sa_lwpublk_unsleep(lwp_t *, bool); #define SA_DEBUG @@ -139,9 +143,17 @@ int sadebug = 0; #define DPRINTFN(n,x) #endif -static syncobj_t sa_sobj = { +static syncobj_t sa_lwpcache_sobj = { + SOBJ_SLEEPQ_FIFO, + sa_lwpcache_unsleep, + sleepq_changepri, + sleepq_lendpri, + syncobj_noowner, +}; + +static syncobj_t sa_lwpublk_sobj = { SOBJ_SLEEPQ_FIFO, - sleepq_unsleep, + sa_lwpublk_unsleep, sleepq_changepri, sleepq_lendpri, syncobj_noowner, @@ -159,6 +171,10 @@ static const char *sa_lwpwoken_wmesg = " (l)->l_pflag ^= (f); \ } while (/*CONSTCOND*/ 0) +#define SA_LWP_SHOULD_EXIT(l, p) \ + (((l)->l_flag & (LW_WEXIT|LW_WCORE)) \ + || ((p)->p_sflag & (PS_WCORE|PS_WEXIT))) + RB_PROTOTYPE(sasttree, sastack, sast_node, sast_compare); RB_GENERATE(sasttree, sastack, sast_node, sast_compare); @@ -879,7 +895,7 @@ sa_increaseconcurrency(struct lwp *l, in mutex_exit(&vp->savp_mutex); lwp_lock(l2); l2->l_savp = l->l_savp; - cpu_setfunc(l2, sa_neverrun, NULL); + cpu_setfunc(l2, sa_cache_lingerer, NULL); lwp_unlock(l2); mutex_enter(&l->l_savp->savp_mutex); sa_putcachelwp(p, l2); @@ -1480,7 +1496,7 @@ sa_switch(struct lwp *l) DPRINTFN(4,("sa_switch(%d.%d VP %d)\n", p->p_pid, l->l_lid, vp->savp_lwp ? vp->savp_lwp->l_lid : 0)); - if ((l->l_flag & LW_WEXIT) || (p->p_sflag & (PS_WCORE | PS_WEXIT))) { + if (SA_LWP_SHOULD_EXIT(l, p)) { mi_switch(l); return; } @@ -1575,7 +1591,6 @@ sa_switch(struct lwp *l) */ l2 = sa_getcachelwp(p, vp); if (l2 == NULL) { - /* XXXSMP */ /* No upcall for you! */ /* XXX The consequences of this are more subtle and * XXX the recovery from this situation deserves @@ -1583,9 +1598,15 @@ sa_switch(struct lwp *l) */ /* XXXUPSXXX Should only happen with concurrency > 1 */ + /* + * WRS: can also happen if SIGCONT or SIGSTOP woke + * (all) our cached thread(s) and it/they haven't + * haven't gotten back to sleep yet. + */ + if (vp->savp_sleeper_upcall == NULL) + vp->savp_sleeper_upcall = sau; mutex_exit(&vp->savp_mutex); mi_switch(l); - sadata_upcall_free(sau); return; } @@ -1607,7 +1628,7 @@ sa_switch(struct lwp *l) */ if ((l->l_flag & LP_SA_PAGEFAULT) && sa_pagefault(l, &sau->sau_event.ss_captured.ss_ctx) != 0) { - cpu_setfunc(l2, sa_neverrun, NULL); + cpu_setfunc(l2, sa_cache_lingerer, NULL); sa_putcachelwp(p, l2); /* uvm_lwp_hold from sa_getcachelwp */ mutex_exit(&vp->savp_mutex); DPRINTFN(4,("sa_switch(%d.%d) Pagefault\n", @@ -1671,20 +1692,45 @@ sa_switch(struct lwp *l) } /* - * sa_neverrun + * sa_cache_lingerer * - * Routine for threads that have never run. Calls lwp_exit. - * New, never-run cache threads get pointed at this routine, which just runs - * and calls lwp_exit(). + * Routine for threads that have never run. Hangs around until + * either the lwp gets used (and gets set to a differet routine) or + * the process exits. Since our sleep is interruptable, we have to + * catch when the signal code wakes us (usually in resoinse to a SIGCONT). + * If we get woken too soon, just put ourselves back to sleep. */ static void -sa_neverrun(void *arg) +sa_cache_lingerer(void *arg) { struct lwp *l; + struct proc *p; + struct sadata_vp *vp; + sleepq_t *sq; + int f; l = curlwp; + p = l->l_proc; + + vp = l->l_savp; + sq = &vp->savp_lwpcache; - DPRINTFN(1,("sa_neverrun(%d.%d %x) exiting\n", l->l_proc->p_pid, + while (!(SA_LWP_SHOULD_EXIT(l, p))) { + /* Not time to go, back to sleep with us */ + mutex_enter(&vp->savp_mutex); +printf("sa_cache_lingerer(%d.%d) cachecount %d\n", l->l_proc->p_pid, l->l_lid,vp->savp_lwpcache_count); + sleepq_enter(&vp->savp_woken, l, &vp->savp_mutex); + sleepq_enqueue(sq, (void *)sq, sa_lwpcache_wmesg, &sa_lwpcache_sobj); + vp->savp_lwpcache_count++; + SA_LWP_STATE_LOCK(l, f); + l->l_flag &= ~LW_PENDSIG; + sleepq_block(0, true); +DPRINTF(("sa_cache_lingerer(%d.%d): back out, l %p \n", l->l_proc->p_pid, + l->l_lid, l)); + SA_LWP_STATE_UNLOCK(l, f); + } + + DPRINTFN(1,("sa_cache_lingerer(%d.%d %x) exiting\n", l->l_proc->p_pid, l->l_lid, l->l_flag)); lwp_exit(l); @@ -1716,7 +1762,7 @@ sa_switchcall(void *arg) lwp_lock(l2); KASSERT(vp->savp_lwp == l2); - if ((l2->l_flag & LW_WEXIT) || (p->p_sflag & (PS_WCORE | PS_WEXIT))) { + if (SA_LWP_SHOULD_EXIT(l2, p)) { lwp_unlock(l2); sadata_upcall_free(sau); lwp_exit(l2); @@ -1823,7 +1869,7 @@ sa_newcachelwp(struct lwp *l, struct sad } error = lwp_create(l, p, uaddr, inmem, 0, NULL, 0, - sa_neverrun, NULL, &l2, l->l_class); + sa_cache_lingerer, NULL, &l2, l->l_class); if (error) { uvm_uarea_free(uaddr, curcpu()); return error; @@ -1872,8 +1918,7 @@ sa_putcachelwp(struct proc *p, struct lw p->p_nlwps--; l->l_prflag |= LPR_DETACHED; #endif - l->l_flag |= LW_SA; - membar_producer(); + l->l_flag |= (LW_SA | LW_SINTR); DPRINTFN(5,("sa_putcachelwp(%d.%d) Adding LWP %d to cache\n", p->p_pid, curlwp->l_lid, l->l_lid)); @@ -1888,11 +1933,11 @@ sa_putcachelwp(struct proc *p, struct lw /* * XXXWRS: Following is a hand-rolled call of the form: - * sleepq_enqueue(sq, (void *)sq, "lwpcache", sa_sobj); but + * sleepq_enqueue(sq, (void *)sq, "lwpcache", sa_lwpcache_sobj); but * hand-done since l might not be curlwp. */ - l->l_syncobj = &sa_sobj; + l->l_syncobj = &sa_lwpcache_sobj; l->l_wchan = sq; l->l_sleepq = sq; l->l_wmesg = sa_lwpcache_wmesg; @@ -1901,7 +1946,38 @@ sa_putcachelwp(struct proc *p, struct lw l->l_sleeperr = 0; vp->savp_lwpcache_count++; - sleepq_insert(sq, l, &sa_sobj); + sleepq_insert(sq, l, &sa_lwpcache_sobj); + membar_producer(); +} + +/* + * sa_{lwpcache,lwpblk}_unsleep + * + * Another part of the kernel wants to wake up a thread + * in one of our special sleep queues. Since we keep a + * count of threads we've put in said queues, adjust it + * as part of removing it. + */ +static u_int +sa_lwpcache_unsleep(lwp_t *l, bool cleanup) +{ + DPRINTFN(3,("sa_lwpcache_unsleep(%d.%d), flags %x count %d\n", + l->l_proc->p_pid, l->l_lid, + l->l_flag, l->l_savp->savp_lwpcache_count)); + KASSERT(l->l_savp->savp_lwpcache_count > 0); + l->l_savp->savp_lwpcache_count--; + return sleepq_unsleep(l, cleanup); +} + +static u_int +sa_lwpublk_unsleep(lwp_t *l, bool cleanup) +{ + DPRINTFN(3,("sa_lwpcache_unsleep(%d.%d), flags %x count %d\n", + l->l_proc->p_pid, l->l_lid, + l->l_flag, l->l_savp->savp_woken_count)); + KASSERT(l->l_savp->savp_woken_count > 0); + l->l_savp->savp_woken_count--; + return sleepq_unsleep(l, cleanup); } /* @@ -1916,7 +1992,9 @@ sa_getcachelwp(struct proc *p, struct sa sleepq_t *sq = &vp->savp_lwpcache; KASSERT(mutex_owned(&vp->savp_mutex)); - KASSERT(vp->savp_lwpcache_count > 0); + + if (vp->savp_lwpcache_count == 0) + return NULL; vp->savp_lwpcache_count--; l= TAILQ_FIRST(sq); @@ -1931,7 +2009,7 @@ sa_getcachelwp(struct proc *p, struct sa l->l_syncobj = &sched_syncobj; l->l_wchan = NULL; l->l_sleepq = NULL; - l->l_flag &= ~LW_SINTR; + l->l_flag &= ~(LW_SINTR | LW_PENDSIG); #if 0 /* Not now, for now leave lwps in lwp list */ LIST_INSERT_HEAD(&p->p_lwps, l, l_sibling); @@ -2071,6 +2149,9 @@ sa_upcall_userret(struct lwp *l) * we deliver the call. */ l2 = TAILQ_FIRST(&vp->savp_woken); +DPRINTF(("sa_userret got l2 %p on count %d\n", l2, vp->savp_woken_count)); +DPRINTF(("sa_userret(%d.%d): just pulled l %p id %d mutex good %d\n", l->l_proc->p_pid, + l->l_lid, l2, l2->l_lid, l2->l_mutex == &vp->savp_mutex)); TAILQ_REMOVE(&vp->savp_woken, l2, l_sleepchain); vp->savp_woken_count--; mutex_exit(&vp->savp_mutex); @@ -2078,8 +2159,7 @@ sa_upcall_userret(struct lwp *l) DPRINTFN(9,("sa_upcall_userret(%d.%d) using stack %p\n", l->l_proc->p_pid, l->l_lid, sast->sast_stack.ss_sp)); - if ((l->l_flag & LW_WEXIT) - || (p->p_sflag & (PS_WCORE | PS_WEXIT))) { + if (SA_LWP_SHOULD_EXIT(l, p)) { lwp_exit(l); /* NOTREACHED */ } @@ -2088,8 +2168,7 @@ sa_upcall_userret(struct lwp *l) p->p_pid, l->l_lid, l2->l_lid)); sau = sadata_upcall_alloc(1); - if ((l->l_flag & LW_WEXIT) - || (p->p_sflag & (PS_WCORE | PS_WEXIT))) { + if (SA_LWP_SHOULD_EXIT(l, p)) { sadata_upcall_free(sau); lwp_exit(l); /* NOTREACHED */ @@ -2106,7 +2185,7 @@ sa_upcall_userret(struct lwp *l) l2->l_wchan = sq; l2->l_wmesg = sa_lwpcache_wmesg; vp->savp_lwpcache_count++; - sleepq_insert(sq, l2, &sa_sobj); + sleepq_insert(sq, l2, &sa_lwpcache_sobj); /* uvm_lwp_hold from sa_unblock_userret */ } else if (sast) sa_setstackfree(sast, sa); @@ -2216,7 +2295,6 @@ sa_makeupcalls(struct lwp *l, struct sad sas[2] = &sau->sau_interrupted.ss_captured.ss_sa; nint = 1; } -#if 0 /* For now, limit ourselves to one unblock at once. */ if (sau->sau_type == SA_UPCALL_UNBLOCKED) { mutex_enter(&vp->savp_mutex); @@ -2224,7 +2302,6 @@ sa_makeupcalls(struct lwp *l, struct sad mutex_exit(&vp->savp_mutex); /* XXX WRS Need to limit # unblocks we copy out at once! */ } -#endif /* Copy out the activation's ucontext */ up = (void *)STACK_ALLOC(stack, ucsize); @@ -2299,8 +2376,9 @@ sa_makeupcalls(struct lwp *l, struct sad sq = &vp->savp_lwpcache; l2->l_wchan = sq; l2->l_wmesg = sa_lwpcache_wmesg; + cpu_setfunc(l2, sa_cache_lingerer, NULL); vp->savp_lwpcache_count++; - sleepq_insert(sq, l2, &sa_sobj); + sleepq_insert(sq, l2, &sa_lwpcache_sobj); /* uvm_lwp_hold from sa_unblock_userret */ mutex_exit(&vp->savp_mutex); @@ -2401,13 +2479,13 @@ sa_unblock_userret(struct lwp *l) struct proc *p; struct sadata *sa; struct sadata_vp *vp; - int swapper; + int swapper, do_once = 1; p = l->l_proc; sa = p->p_sa; vp = l->l_savp; - if ((l->l_flag & LW_WEXIT) || (p->p_sflag & (PS_WCORE | PS_WEXIT))) + if (SA_LWP_SHOULD_EXIT(l, p)) return; if ((l->l_flag & LW_SA_BLOCKING) == 0) @@ -2419,6 +2497,7 @@ sa_unblock_userret(struct lwp *l) p = l->l_proc; sa = p->p_sa; vp = l->l_savp; +retry: vp_lwp = vp->savp_lwp; l2 = NULL; swapper = 0; @@ -2536,8 +2615,13 @@ sa_unblock_userret(struct lwp *l) */ sleepq_enter(&vp->savp_woken, l, &vp->savp_mutex); sleepq_enqueue(&vp->savp_woken, &vp->savp_woken, sa_lwpwoken_wmesg, - &sa_sobj); - uvm_lwp_hold(l); + &sa_lwpublk_sobj); + l->l_flag |= LW_SINTR; + l->l_flag &= ~LW_PENDSIG; + if (do_once) { + uvm_lwp_hold(l); + do_once = 0; + } vp->savp_woken_count++; //l->l_stat = LSSUSPENDED; mi_switch(l); @@ -2551,6 +2635,21 @@ sa_unblock_userret(struct lwp *l) * In the normal lwp lifecycle, cpu_setfunc() will make this lwp * run in a different routine by the time we next run. */ + +printf("unblock back from miswitch\n"); + if (!(SA_LWP_SHOULD_EXIT(l, p))) { + /* + * Not time to go, back to sleep with us. However + * the blessed LWP may need a wakeup again to notice + * us. So try this routine again. + */ + DPRINTFN(3,("sa_unblock_userret(%d.%d) going around again" + ", flags %x, vp %d\n", l->l_proc->p_pid, l->l_lid, + l->l_flag, vp_lwp->l_lid)); + goto retry; + } + +printf("unblock exiting\n"); lwp_exit(l); /* NOTREACHED */ } Index: sys/dev/ic/i82596.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/i82596.c,v retrieving revision 1.27 diff -u -p -u -p -r1.27 i82596.c --- sys/dev/ic/i82596.c 13 May 2009 13:12:06 -0000 1.27 +++ sys/dev/ic/i82596.c 24 Jul 2009 07:06:39 -0000 @@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: i82596.c,v 1 /* autoconfig and device stuff */ #include +#include #include #include #include "locators.h" @@ -81,6 +82,16 @@ __KERNEL_RCSID(0, "$NetBSD: i82596.c,v 1 #include #include +#define I82596_DEBUG +#ifdef I82596_DEBUG +#define DPRINTF(x) if (i82596_debug > 0) printf x +#define DPRINTFN(n, x) if (i82596_debug >= (n)) printf x +int i82596_debug = 0; +#else +#define DPRINTF(x) +#define DPRINTFN(n, x) +#endif + /* Supported chip variants */ const char *i82596_typenames[] = { "unknown", "DX/SX", "CA" }; @@ -565,8 +576,6 @@ iee_cb_setup(struct iee_softc *sc, uint3 ifp->if_timer = 5; } - - void iee_attach(struct iee_softc *sc, uint8_t *eth_addr, int *media, int nmedia, int defmedia) @@ -684,10 +693,40 @@ iee_attach(struct iee_softc *sc, uint8_t } sc->sc_tx_timeout = 0; sc->sc_setup_timeout = 0; + (sc->sc_iee_reset)(sc); } - +#ifdef I82596_DEBUG +SYSCTL_SETUP(sysctl_i82596, "sysctl iee(4) subtree setup") +{ + int rc; + const struct sysctlnode *rnode; + const struct sysctlnode *cnode; + + if ((rc = sysctl_createv(clog, 0, NULL, &rnode, + CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw", NULL, + NULL, 0, NULL, 0, CTL_HW, CTL_EOL)) != 0) + goto err; + + if ((rc = sysctl_createv(clog, 0, &rnode, &rnode, + CTLFLAG_PERMANENT, CTLTYPE_NODE, "iee", + SYSCTL_DESCR("iee global controls"), + NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0) + goto err; + + /* control debugging printfs */ + if ((rc = sysctl_createv(clog, 0, &rnode, &cnode, + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, + "debug", SYSCTL_DESCR("Enable debugging output"), + NULL, 0, &i82596_debug, 0, CTL_CREATE, CTL_EOL)) != 0) + goto err; + + return; +err: + aprint_error("%s: sysctl_createv failed (rc = %d)\n", __func__, rc); +} +#endif /* I82596_DEBUG */ void iee_detach(struct iee_softc *sc, int flags) @@ -704,8 +743,6 @@ iee_detach(struct iee_softc *sc, int fla bus_dmamem_free(sc->sc_dmat, &sc->sc_dma_segs, sc->sc_dma_rsegs); } - - /* media change and status callback */ int iee_mediachange(struct ifnet *ifp) @@ -717,8 +754,6 @@ iee_mediachange(struct ifnet *ifp) return 0; } - - void iee_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmreq) { @@ -728,8 +763,6 @@ iee_mediastatus(struct ifnet *ifp, struc (sc->sc_mediastatus)(ifp, ifmreq); } - - /* initiate output routine */ void iee_start(struct ifnet *ifp) Index: sys/dev/ic/i82596var.h =================================================================== RCS file: /cvsroot/src/sys/dev/ic/i82596var.h,v retrieving revision 1.14 diff -u -p -u -p -r1.14 i82596var.h --- sys/dev/ic/i82596var.h 10 May 2009 04:26:19 -0000 1.14 +++ sys/dev/ic/i82596var.h 24 Jul 2009 07:06:39 -0000 @@ -39,7 +39,7 @@ enum i82596_types { I82596_UNKNOWN, I825 -/* System Configuration Pointer */ +/* -W: System Configuration Pointer */ struct iee_scp { volatile uint16_t scp_pad1; volatile uint16_t scp_sysbus; /* Sysbus Byte */ @@ -49,18 +49,19 @@ struct iee_scp { -/* Intermediate System Configuration Pointer */ +/* RW: Intermediate System Configuration Pointer */ struct iee_iscp { - volatile uint16_t iscp_bussy; /* Even Word, bits 0..15 */ + volatile uint16_t iscp_busy; /* RW: Even Word, bits 0..15 */ volatile uint16_t iscp_pad; /* Odd Word, bits 16..32 */ - volatile uint32_t iscp_scb_addr; /* address of SCB */ + volatile uint32_t iscp_scb_addr; /* -W: address of SCB */ } __packed; /* System Control Block */ struct iee_scb { - volatile uint16_t scb_status; /* Status Bits */ + volatile uint16_t scb_status; /* R-: Status Bits */ +/* CACHELINE - above is written by the chip, below is written by the cpu */ volatile uint16_t scb_cmd; /* Command Bits */ volatile uint32_t scb_cmd_blk_addr; /* Command Block Address */ volatile uint32_t scb_rfa_addr; /* Receive Frame Area Address */ @@ -80,6 +81,7 @@ struct iee_scb { /* Command Block */ struct iee_cb { volatile uint16_t cb_status; /* Status Bits */ +/* CACHELINE - above is written by the chip, below is written by the cpu */ volatile uint16_t cb_cmd; /* Command Bits */ volatile uint32_t cb_link_addr; /* Link Address to next CMD */ union { @@ -103,20 +105,22 @@ struct iee_cb { } __packed; - /* Transmit Buffer Descriptor */ struct iee_tbd { volatile uint16_t tbd_size; /* Size of buffer & Flags */ volatile uint16_t tbd_pad; volatile uint32_t tbd_link_addr; /* Link Address to next RFD */ volatile uint32_t tbd_tb_addr; /* Transmit Buffer Address */ +#if 0 + uint16_t tbd_pad2; /* XXXNH Align to half word */ +#endif } __packed; - /* Receive Frame Descriptor */ struct iee_rfd { volatile uint16_t rfd_status; /* Status Bits */ +/* CACHELINE - above is written by the chip, below is written by the cpu */ volatile uint16_t rfd_cmd; /* Command Bits */ volatile uint32_t rfd_link_addr; /* Link Address to next RFD */ volatile uint32_t rfd_rbd_addr; /* Address of first free RBD */ @@ -132,7 +136,8 @@ struct iee_rfd { /* Receive Buffer Descriptor */ struct iee_rbd { - volatile uint16_t rbd_count; /* Actual Cont of bytes */ + volatile uint16_t rbd_count; /* Actual Count of bytes */ +/* CACHELINE - above is written by the chip, below is written by the cpu */ volatile uint16_t rbd_pad1; volatile uint32_t rbd_next_rbd; /* Address of Next RBD */ volatile uint32_t rbd_rb_addr; /* Receive Buffer Address */ @@ -274,7 +279,3 @@ struct iee_softc { void iee_attach(struct iee_softc *, uint8_t *, int *, int, int); void iee_detach(struct iee_softc *, int); int iee_intr(void *); - - - - Index: sys/dev/ic/sti.c =================================================================== RCS file: /cvsroot/src/sys/dev/ic/sti.c,v retrieving revision 1.10 diff -u -p -u -p -r1.10 sti.c --- sys/dev/ic/sti.c 7 May 2009 15:34:50 -0000 1.10 +++ sys/dev/ic/sti.c 24 Jul 2009 07:06:40 -0000 @@ -855,4 +855,3 @@ sti_alloc_attr(void *v, int fg, int bg, return 0; } - Index: sys/dev/ic/stireg.h =================================================================== RCS file: /cvsroot/src/sys/dev/ic/stireg.h,v retrieving revision 1.2 diff -u -p -u -p -r1.2 stireg.h --- sys/dev/ic/stireg.h 11 Dec 2005 12:21:28 -0000 1.2 +++ sys/dev/ic/stireg.h 24 Jul 2009 07:06:40 -0000 @@ -1,6 +1,6 @@ -/* $NetBSD: stireg.h,v 1.2 2005/12/11 12:21:28 christos Exp $ */ +/* $NetBSD: stireg.h,v 1.2 2005/12/11 12:21:28 christos Exp $ */ -/* $OpenBSD: stireg.h,v 1.8 2003/08/19 02:52:38 mickey Exp $ */ +/* $OpenBSD: stireg.h,v 1.13 2009/01/28 17:37:40 miod Exp $ */ /* * Copyright (c) 2000 Michael Shalayeff @@ -56,6 +56,13 @@ #define STI_END 13 #define STI_CODECNT 16 +#define STI_CODEBASE_MAIN 0x40 +#define STI_CODEBASE_ALT 0x80 + +#define STI_CODEBASE_PA STI_CODEBASE_MAIN +#define STI_CODEBASE_M68K STI_CODEBASE_ALT +#define STI_CODEBASE_PA64 STI_CODEBASE_ALT + /* sti returns */ #define STI_OK 0 #define STI_FAIL -1 @@ -66,12 +73,12 @@ #define STI_BADREENTLVL 1 /* bad reentry level */ #define STI_NOREGIONSDEF 2 /* region table is not setup */ #define STI_ILLNPLANES 3 /* invalid num of text planes */ -#define STI_ILLINDEX 4 /* invalid fond index */ +#define STI_ILLINDEX 4 /* invalid font index */ #define STI_ILLLOC 5 /* invalid font location */ #define STI_ILLCOLOUR 6 /* invalid colour */ #define STI_ILLBLKMVFROM 7 /* invalid from in blkmv */ #define STI_ILLBLKMVTO 8 /* invalid to in blkmv */ -#define STI_ILLBLKMVSIZE 9 /* invalid siz in blkmv */ +#define STI_ILLBLKMVSIZE 9 /* invalid size in blkmv */ #define STI_BEIUNSUPP 10 /* bus error ints unsupported */ #define STI_UNXPBE 11 /* unexpected bus error */ #define STI_UNXHWF 12 /* unexpected hardware failure */ @@ -106,8 +113,6 @@ #define STI_COLOUR_BLUE 6 #define STI_COLOUR_MAGENTA 7 -#pragma pack(1) - /* LSB high */ struct sti_dd { u_int32_t dd_type; /* 0x00 device type */ @@ -155,7 +160,9 @@ struct sti_dd { servers w/o accel */ u_int32_t dd_pacode[16]; /* 0x40 routines for pa-risc */ u_int32_t dd_altcode[16]; /* 0x80 routines for m68k/i386 */ -}; +} __packed; + +#define STI_REVISION(maj, min) (((maj) << 4) | ((min) & 0x0f)) /* after the last region there is one indirect list ptr */ struct sti_region { @@ -165,7 +172,7 @@ struct sti_region { u_int btlb : 1; /* should use BTLB if available */ u_int last : 1; /* last region in the list */ u_int length :14; /* size in pages */ -}; +} __packed; struct sti_font { u_int16_t first; @@ -180,7 +187,7 @@ struct sti_font { u_int8_t uheight; u_int8_t uoffset; u_int8_t unused[2]; -}; +} __packed; struct sti_fontcfg { u_int16_t first; @@ -191,7 +198,23 @@ struct sti_fontcfg { u_int8_t bpc; u_int8_t uheight; u_int8_t uoffset; -}; +} __packed; + +typedef struct sti_mon { + u_int32_t width: 12; + u_int32_t height: 12; + u_int32_t hz: 7; /* low 7 bits of refresh rate */ + u_int32_t flat: 1; /* flatpanel */ + u_int32_t vesa: 1; /* vesa mode */ + u_int32_t grey: 1; /* greyscale */ + u_int32_t dblbuf: 1; /* double buffered */ + u_int32_t user: 1; /* user-defined mode */ + u_int32_t stereo: 1; /* stereo display */ + u_int32_t sam: 1; /* ? */ + u_int32_t : 15; + u_int32_t hz_upper: 3; /* upper 3 bits of refresh rate */ + u_int32_t font: 8; /* rom font index */ +} __packed *sti_mon_t; typedef struct sti_ecfg { u_int8_t current_monitor; @@ -200,7 +223,7 @@ typedef struct sti_ecfg { u_int32_t freq_ref; u_int32_t *addr; /* memory block of size dd_stimemreq */ void *future; -} *sti_ecfg_t; +} __packed *sti_ecfg_t; typedef struct sti_cfg { u_int32_t text_planes; @@ -214,7 +237,7 @@ typedef struct sti_cfg { u_int32_t reent_level; u_int32_t *save_addr; sti_ecfg_t ext_cfg; -} *sti_cfg_t; +} __packed *sti_cfg_t; /* routine types */ @@ -240,25 +263,25 @@ typedef struct sti_initflags { #define STI_INITF_SCMT 0x00040000 /* change current monitor type */ #define STI_INITF_RIE 0x00020000 /* retain int enables */ void *future; -} *sti_initflags_t; +} __packed *sti_initflags_t; typedef struct sti_einitin { u_int8_t mon_type; u_int8_t pad; u_int16_t inflight; /* possible on pci */ void *future; -} *sti_einitin_t; +} __packed *sti_einitin_t; typedef struct sti_initin { u_int32_t text_planes; /* number of planes for text */ sti_einitin_t ext_in; -} *sti_initin_t; +} __packed *sti_initin_t; typedef struct sti_initout { int32_t errno; u_int32_t text_planes; /* number of planes used for text */ void *future; -} *sti_initout_t; +} __packed *sti_initout_t; STI_DEP(init); @@ -268,17 +291,17 @@ typedef struct sti_mgmtflags { #define STI_MGMTF_SAVE 0x40000000 #define STI_MGMTF_RALL 0x20000000 /* restore all display planes */ void *future; -} *sti_mgmtflags_t; +} __packed *sti_mgmtflags_t; typedef struct sti_mgmtin { void *addr; void *future; -} *sti_mgmtin_t; +} __packed *sti_mgmtin_t; typedef struct sti_mgmtout { int32_t errno; void *future; -} *sti_mgmtout_t; +} __packed *sti_mgmtout_t; STI_DEP(mgmt); @@ -287,7 +310,7 @@ typedef struct sti_unpmvflags { #define STI_UNPMVF_WAIT 0x80000000 #define STI_UNPMVF_NTXT 0x40000000 /* intp non-text planes */ void *future; -} *sti_unpmvflags_t; +} __packed *sti_unpmvflags_t; typedef struct sti_unpmvin { u_int32_t *font_addr; /* font */ @@ -296,12 +319,12 @@ typedef struct sti_unpmvin { u_int8_t bg_colour; u_int16_t x, y; void *future; -} *sti_unpmvin_t; +} __packed *sti_unpmvin_t; typedef struct sti_unpmvout { u_int32_t errno; void *future; -} *sti_unpmvout_t; +} __packed *sti_unpmvout_t; STI_DEP(unpmv); @@ -312,7 +335,7 @@ typedef struct sti_blkmvflags { #define STI_BLKMVF_CLR 0x20000000 /* clear on move */ #define STI_BLKMVF_NTXT 0x10000000 /* move in non-text planes */ void *future; -} *sti_blkmvflags_t; +} __packed *sti_blkmvflags_t; typedef struct sti_blkmvin { u_int8_t fg_colour; @@ -321,12 +344,12 @@ typedef struct sti_blkmvin { u_int16_t width, height; u_int16_t pad; void *future; -} *sti_blkmvin_t; +} __packed *sti_blkmvin_t; typedef struct sti_blkmvout { u_int32_t errno; void *future; -} *sti_blkmvout_t; +} __packed *sti_blkmvout_t; STI_DEP(blkmv); @@ -335,17 +358,17 @@ typedef struct sti_testflags { #define STI_TESTF_WAIT 0x80000000 #define STI_TESTF_ETST 0x40000000 void *future; -} *sti_testflags_t; +} __packed *sti_testflags_t; typedef struct sti_testin { void *future; -} *sti_testin_t; +} __packed *sti_testin_t; typedef struct sti_testout { u_int32_t errno; u_int32_t result; void *future; -} *sti_testout_t; +} __packed *sti_testout_t; STI_DEP(test); @@ -366,7 +389,7 @@ typedef struct sti_exhdlflags { #define STI_EXHDLF_EIC 0x00080000 /* end int cycle */ #define STI_EXHDLF_RIE 0x00040000 /* reset do not clear int enables */ void *future; -} *sti_exhdlflags_t; +} __packed *sti_exhdlflags_t; typedef struct sti_eexhdlin { u_int32_t eim_addr; @@ -374,7 +397,7 @@ typedef struct sti_eexhdlin { u_int32_t iem; /* enable mask */ u_int32_t icm; /* clear mask */ void *future; -} *sti_eexhdlin_t; +} __packed *sti_eexhdlin_t; typedef struct sti_exhdlint { u_int32_t flags; @@ -387,12 +410,12 @@ typedef struct sti_exhdlint { #define STI_EXHDLINT_BDC 0x02000000 /* buffered dma complete */ #define STI_EXHDLINT_UDPC 0x01000000 /* unbuf priv dma complete */ #define STI_EXHDLINT_BDPC 0x00800000 /* buffered priv dma complete */ -} *sti_exhdlint_t; +} __packed *sti_exhdlint_t; typedef struct sti_exhdlin { sti_exhdlint_t addr; sti_eexhdlin_t ext; -} *sti_exhdlin_t; +} __packed *sti_exhdlin_t; typedef struct sti_eexhdlout { u_int32_t eim_addr; @@ -400,7 +423,7 @@ typedef struct sti_eexhdlout { u_int32_t iem; /* enable mask */ u_int32_t icm; /* clear mask */ void *future; -} *sti_eexhdlout_t; +} __packed *sti_eexhdlout_t; typedef struct sti_exhdlout { u_int32_t errno; @@ -409,7 +432,7 @@ typedef struct sti_exhdlout { #define STI_EXHDLO_IP 0x40000000 /* there is int pending */ #define STI_EXHDLO_IE 0x20000000 /* global enable set */ sti_eexhdlout_t ext; -} *sti_exhdlout_t; +} __packed *sti_exhdlout_t; STI_DEP(exhdl); @@ -417,17 +440,17 @@ typedef struct sti_inqconfflags { u_int32_t flags; #define STI_INQCONFF_WAIT 0x80000000 void *future; -} *sti_inqconfflags_t; +} __packed *sti_inqconfflags_t; typedef struct sti_inqconfin { void *future; -} *sti_inqconfin_t; +} __packed *sti_inqconfin_t; typedef struct sti_einqconfout { u_int32_t crt_config[3]; u_int32_t crt_hw[3]; void *future; -} *sti_einqconfout_t; +} __packed *sti_einqconfout_t; typedef struct sti_inqconfout { u_int32_t errno; @@ -437,7 +460,7 @@ typedef struct sti_inqconfout { u_int32_t planes; u_int8_t name[STI_DEVNAME_LEN]; u_int32_t attributes; -#define STI_INQCONF_Y2X 0x0001 /* pixel is higher tan wider */ +#define STI_INQCONF_Y2X 0x0001 /* pixel is higher than wider */ #define STI_INQCONF_HWBLKMV 0x0002 /* hw blkmv is present */ #define STI_INQCONF_AHW 0x0004 /* adv hw accel */ #define STI_INQCONF_INT 0x0008 /* can interrupt */ @@ -454,7 +477,7 @@ typedef struct sti_inqconfout { "\020\001y2x\002hwblkmv\003ahw\004int\005gonoff\006aonoff\007vary"\ "\010oddb\011flush\012dma\013vdma\016yuv1\017yuv2" sti_einqconfout_t ext; -} *sti_inqconfout_t; +} __packed *sti_inqconfout_t; STI_DEP(inqconf); @@ -462,18 +485,18 @@ typedef struct sti_scmentflags { u_int32_t flags; #define STI_SCMENTF_WAIT 0x80000000 void *future; -} *sti_scmentflags_t; +} __packed *sti_scmentflags_t; typedef struct sti_scmentin { u_int32_t entry; u_int32_t value; void *future; -} *sti_scmentin_t; +} __packed *sti_scmentin_t; typedef struct sti_scmentout { u_int32_t errno; void *future; -} *sti_scmentout_t; +} __packed *sti_scmentout_t; STI_DEP(scment); @@ -486,7 +509,7 @@ typedef struct sti_dmacflags { #define STI_DMACF_MRK 0x08000000 /* write a marker */ #define STI_DMACF_ABRT 0x04000000 /* abort dma xfer */ void *future; -} *sti_dmacflags_t; +} __packed *sti_dmacflags_t; typedef struct sti_dmacin { u_int32_t pa_upper; @@ -495,12 +518,12 @@ typedef struct sti_dmacin { u_int32_t mrk_data; u_int32_t mrk_off; void *future; -} *sti_dmacin_t; +} __packed *sti_dmacin_t; typedef struct sti_dmacout { u_int32_t errno; void *future; -} *sti_dmacout_t; +} __packed *sti_dmacout_t; STI_DEP(dmac); @@ -516,7 +539,7 @@ typedef struct sti_flowcflags { #define STI_FLOWCF_CSWC 0x01000000 /* cs write coarse */ #define STI_FLOWCF_CSWQ 0x00800000 /* cs write fifo */ void *future; -} *sti_flowcflags_t; +} __packed *sti_flowcflags_t; typedef struct sti_flowcin { u_int32_t retry; @@ -527,14 +550,14 @@ typedef struct sti_flowcin { u_int32_t cscv; /* cs coarse value */ u_int32_t csqc; /* cs fifo count */ void *future; -} *sti_flowcin_t; +} __packed *sti_flowcin_t; typedef struct sti_flowcout { u_int32_t errno; u_int32_t retry_result; u_int32_t fifo_size; void *future; -} *sti_flowcout_t; +} __packed *sti_flowcout_t; STI_DEP(flowc); @@ -543,19 +566,19 @@ typedef struct sti_utimingflags { #define STI_UTIMF_WAIT 0x80000000 #define STI_UTIMF_HKS 0x40000000 /* has kbuf_size */ void *future; -} *sti_utimingflags_t; +} __packed *sti_utimingflags_t; typedef struct sti_utimingin { void *data; void *kbuf; void *future; -} *sti_utimingin_t; +} __packed *sti_utimingin_t; typedef struct sti_utimingout { u_int32_t errno; u_int32_t kbuf_size; /* buffer required size */ void *future; -} *sti_utimingout_t; +} __packed *sti_utimingout_t; STI_DEP(utiming); @@ -568,17 +591,17 @@ typedef struct sti_pmgrflags { #define STI_UTIMF_BUFF 0x02000000 #define STI_UTIMF_IBUFF 0x01000000 void *future; -} *sti_pmgrflags_t; +} __packed *sti_pmgrflags_t; typedef struct sti_pmgrin { u_int32_t reserved[4]; void *future; -} *sti_pmgrin_t; +} __packed *sti_pmgrin_t; typedef struct sti_pmgrout { int32_t errno; void *future; -} *sti_pmgrout_t; +} __packed *sti_pmgrout_t; STI_DEP(pmgr); @@ -586,21 +609,19 @@ typedef struct sti_utilflags { u_int32_t flags; #define STI_UTILF_ROOT 0x80000000 /* was called as root */ void *future; -} *sti_utilflags_t; +} __packed *sti_utilflags_t; typedef struct sti_utilin { u_int32_t in_size; u_int32_t out_size; u_int8_t *buf; -} *sti_utilin_t; +} __packed *sti_utilin_t; typedef struct sti_utilout { int32_t errno; void *future; -} *sti_utilout_t; +} __packed *sti_utilout_t; STI_DEP(util); -#pragma pack() - #endif /* _IC_STIREG_H_ */ Index: sys/dev/ic/stivar.h =================================================================== RCS file: /cvsroot/src/sys/dev/ic/stivar.h,v retrieving revision 1.3 diff -u -p -u -p -r1.3 stivar.h --- sys/dev/ic/stivar.h 7 May 2009 15:34:50 -0000 1.3 +++ sys/dev/ic/stivar.h 24 Jul 2009 07:06:40 -0000 @@ -31,6 +31,75 @@ #ifndef _IC_STIVAR_H_ #define _IC_STIVAR_H_ +struct sti_softc; + +/* + * STI ROM information - one per device + */ +struct sti_rom { + struct sti_softc *rom_softc; /* backpointer to device */ + int rom_devtype; + + bus_space_tag_t iot, memt; /* XXX iot unused */ + bus_space_handle_t romh; + bus_addr_t *bases; + + struct sti_dd rom_dd; /* in word format */ + + vaddr_t rom_code; + sti_init_t init; + sti_mgmt_t mgmt; + sti_unpmv_t unpmv; + sti_blkmv_t blkmv; + sti_test_t test; + sti_exhdl_t exhdl; + sti_inqconf_t inqconf; + sti_scment_t scment; + sti_dmac_t dmac; + sti_flowc_t flowc; + sti_utiming_t utiming; + sti_pmgr_t pmgr; + sti_util_t util; +}; + +/* + * STI screen information - one per head + */ +struct sti_screen { + struct sti_rom *scr_rom; + +#ifdef notyet + u_int scr_flags; +#endif + + int scr_bpp; + + struct sti_font scr_curfont; + struct sti_cfg scr_cfg; + struct sti_ecfg scr_ecfg; + u_int8_t name[STI_DEVNAME_LEN]; + + void *scr_romfont; /* ROM font copy in memory... */ + u_int scr_fontmaxcol;/* ...or in off-screen area */ + u_int scr_fontbase; + + u_int8_t scr_rcmap[STI_NCMAP], + scr_gcmap[STI_NCMAP], + scr_bcmap[STI_NCMAP]; + + u_int16_t fbheight, fbwidth; + u_int16_t oheight, owidth; /* offscreen size */ + bus_addr_t fbaddr; + bus_size_t fblen; + + /* wsdisplay information */ + int scr_nscreens; + u_int scr_wsmode; + struct wsscreen_descr scr_wsd; + struct wsscreen_descr *scr_scrlist[1]; + struct wsscreen_list scr_screenlist; +}; + struct sti_softc { device_t sc_dev; void *sc_ih; Index: sys/dev/pci/files.pci =================================================================== RCS file: /cvsroot/src/sys/dev/pci/files.pci,v retrieving revision 1.316 diff -u -p -u -p -r1.316 files.pci --- sys/dev/pci/files.pci 21 Jun 2009 20:15:26 -0000 1.316 +++ sys/dev/pci/files.pci 24 Jul 2009 07:06:41 -0000 @@ -409,6 +409,10 @@ file dev/ic/bt485.c tga file dev/ic/bt463.c tga file dev/ic/ibm561.c tga +# HP Visualize +attach sti at pci with sti_pci +file dev/pci/sti_pci.c sti_pci + # Integraphics Systems IGA168x and CyberPro framebuffers (linear non-VGA mode) # device declaration in sys/conf/files attach igsfb at pci with igsfb_pci Index: sys/dev/pci/if_iwi.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_iwi.c,v retrieving revision 1.81 diff -u -p -u -p -r1.81 if_iwi.c --- sys/dev/pci/if_iwi.c 6 May 2009 09:25:15 -0000 1.81 +++ sys/dev/pci/if_iwi.c 24 Jul 2009 07:06:42 -0000 @@ -81,10 +81,12 @@ __KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1 #include #include +#undef NHnotyet + #ifdef IWI_DEBUG #define DPRINTF(x) if (iwi_debug > 0) printf x #define DPRINTFN(n, x) if (iwi_debug >= (n)) printf x -int iwi_debug = 4; +int iwi_debug = 5; #else #define DPRINTF(x) #define DPRINTFN(n, x) @@ -157,6 +159,9 @@ static void iwi_stop(struct ifnet *, int static int iwi_getrfkill(struct iwi_softc *); static void iwi_led_set(struct iwi_softc *, uint32_t, int); static void iwi_sysctlattach(struct iwi_softc *); +#ifdef IWI_DEBUG +static void iwi_error_log(struct iwi_softc *); +#endif /* * Supported rates for 802.11a/b/g modes (in 500Kbps unit). @@ -184,6 +189,20 @@ MEM_READ_4(struct iwi_softc *sc, uint32_ return CSR_READ_4(sc, IWI_CSR_INDIRECT_DATA); } +#ifdef IWI_DEBUG +static void +MEM_CPY(struct iwi_softc *sc, void *dst, uint32_t base, size_t sz) +{ + KASSERT(sz % 4 == 0); + int j; + + uint32_t *p = dst; + + for (j = 0; j < sz / 4; j++) + p[j] = MEM_READ_4(sc, base + j * sizeof(uint32_t)); +} +#endif + CFATTACH_DECL_NEW(iwi, sizeof (struct iwi_softc), iwi_match, iwi_attach, iwi_detach, NULL); @@ -297,7 +316,9 @@ iwi_attach(device_t parent, device_t sel IEEE80211_C_MONITOR | /* monitor mode supported */ IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ - IEEE80211_C_SHSLOT | /* short slot time supported */ +#ifdef NHnotyey + IEEE80211_C_WEP | /* h/w WEP supported */ +#endif IEEE80211_C_WPA | /* 802.11i */ IEEE80211_C_WME; /* 802.11e */ @@ -415,6 +436,7 @@ iwi_attach(device_t parent, device_t sel } #if NBPFILTER > 0 + /* XXX NH s/64/IEEE80211_RADIOTAP_HDRLEN/ ? */ bpfattach2(ifp, DLT_IEEE802_11_RADIO, sizeof (struct ieee80211_frame) + 64, &sc->sc_drvbpf); @@ -1216,6 +1238,24 @@ iwi_frame_intr(struct iwi_softc *sc, str if (ic->ic_state == IEEE80211_S_SCAN) iwi_fix_channel(ic, m); + wh = mtod(m, struct ieee80211_frame *); +#ifdef NHnotyet + if ((wh->i_fc[1] & IEEE80211_FC1_WEP) && + ic->ic_opmode != IEEE80211_M_MONITOR) { + /* + * Hardware decrypts the frame itself but leaves the WEP bit + * set in the 802.11 header and doesn't remove the IV and CRC + * fields. + */ + wh->i_fc[1] &= ~IEEE80211_FC1_WEP; + memmove((char *)wh + IEEE80211_WEP_IVLEN + + IEEE80211_WEP_KIDLEN, wh, sizeof (struct ieee80211_frame)); + m_adj(m, IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN); + m_adj(m, -IEEE80211_WEP_CRCLEN); + wh = mtod(m, struct ieee80211_frame *); + } +#endif + #if NBPFILTER > 0 if (sc->sc_drvbpf != NULL) { struct iwi_rx_radiotap_header *tap = &sc->sc_rxtap; @@ -1232,7 +1272,6 @@ iwi_frame_intr(struct iwi_softc *sc, str bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_rxtap_len, m); } #endif - wh = mtod(m, struct ieee80211_frame *); ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh); /* Send the frame to the upper layer */ @@ -1350,6 +1389,7 @@ iwi_cmd_intr(struct iwi_softc *sc) hw = CSR_READ_4(sc, IWI_CSR_CMD_RIDX); + DPRINTFN(5, ("%s: hw = %d, sc->cmdq.next = %d\n", device_xname(sc->sc_dev), hw, sc->cmdq.next)); bus_dmamap_sync(sc->sc_dmat, sc->cmdq.desc_map, sc->cmdq.next * IWI_CMD_DESC_SIZE, IWI_CMD_DESC_SIZE, BUS_DMASYNC_POSTWRITE); @@ -1359,6 +1399,7 @@ iwi_cmd_intr(struct iwi_softc *sc) sc->cmdq.next = (sc->cmdq.next + 1) % sc->cmdq.count; if (--sc->cmdq.queued > 0) { + DPRINTFN(5, ("%s: %s kicking %d\n", device_xname(sc->sc_dev), __func__, (sc->cmdq.next + 1) % sc->cmdq.count)); CSR_WRITE_4(sc, IWI_CSR_CMD_WIDX, (sc->cmdq.next + 1) % sc->cmdq.count); } } @@ -1471,7 +1512,11 @@ iwi_intr(void *arg) if (r & IWI_INTR_RADIO_OFF) { DPRINTF(("radio transmitter off\n")); sc->sc_ic.ic_ifp->if_flags &= ~IFF_UP; +#ifdef IWI_DEBUG + iwi_error_log(sc); +#endif iwi_stop(&sc->sc_if, 1); + return (1); } @@ -1522,8 +1567,10 @@ iwi_cmd(struct iwi_softc *sc, uint8_t ty sc->cmdq.cur = (sc->cmdq.cur + 1) % sc->cmdq.count; - if (++sc->cmdq.queued == 1) + if (++sc->cmdq.queued == 1) { + DPRINTFN(5, ("%s: %s kicking %d\n", device_xname(sc->sc_dev), __func__, sc->cmdq.cur)); CSR_WRITE_4(sc, IWI_CSR_CMD_WIDX, sc->cmdq.cur); + } return async ? 0 : tsleep(desc, 0, "iwicmd", hz); } @@ -1671,13 +1718,18 @@ iwi_tx_start(struct ifnet *ifp, struct m if (!noack && !IEEE80211_IS_MULTICAST(desc->wh.i_addr1)) desc->flags |= IWI_DATA_FLAG_NEED_ACK; -#if 0 - if (ic->ic_flags & IEEE80211_F_PRIVACY) { - desc->wh.i_fc[1] |= IEEE80211_FC1_WEP; - desc->wep_txkey = ic->ic_crypto.cs_def_txkey; - } else +#ifdef NHnotyet + if (desc->wh.i_fc[1] & IEEE80211_FC1_WEP) { + desc->wep_txkey = ic->ic_crypto.cs_def_txkey | + (ic->ic_crypto.cs_nw_keys[ic->ic_crypto.cs_def_txkey].wk_keylen <= 5) ? + IWI_DATA_KEY_WEP40 : IWI_DATA_KEY_WEP104; + } else { #endif desc->flags |= IWI_DATA_FLAG_NO_WEP; + desc->wep_txkey = 0; +#ifdef NHnotyet + } +#endif if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) desc->flags |= IWI_DATA_FLAG_SHPREAMBLE; @@ -2539,9 +2591,11 @@ iwi_auth_and_assoc(struct iwi_softc *sc) if (ic->ic_curmode == IEEE80211_MODE_11G) config.use_protection = 1; config.answer_pbreq = (ic->ic_opmode == IEEE80211_M_IBSS) ? 1 : 0; + +#ifndef NHnotyet config.disable_unicast_decryption = 1; config.disable_multicast_decryption = 1; - +#endif DPRINTF(("Configuring adapter\n")); error = iwi_cmd(sc, IWI_CMD_SET_CONFIGURATION, &config, sizeof config, 1); @@ -2939,6 +2993,159 @@ iwi_led_set(struct iwi_softc *sc, uint32 return; } +#ifdef IWI_DEBUG +/* + * XXX Needs rewriting + */ +static void +iwi_error_log(struct iwi_softc *sc) +{ + uint32_t b, n; + int i; + + static const char *const msg[] = { + "no error", + "failed", + "memory range low", + "memory range high", + "bad parameter", + "checksum", + "NMI", + "bad database", + "allocation failed", + "DMA underrun", + "DMA status", + "DINO", + "EEPROM", + "device assert", + "fatal" + }; + + b = CSR_READ_4(sc, IWI_CSR_ERRORLOG); + n = MEM_READ_4(sc, b); + + b += 4; + + for (i = 0; i < n ; i++) { + struct iwi_error fw_error; + + MEM_CPY(sc, &fw_error, b, sizeof(fw_error)); + + printf("%s: %s\n", device_xname(sc->sc_dev), + msg[fw_error.type]); + + b += sizeof(fw_error); + } + +} + +#if 0 + + + +struct ipw_error_elem { + u32 desc; + u32 time; + u32 blink1; + u32 blink2; + u32 link1; + u32 link2; + u32 data; +}; + +struct ipw_event { + u32 event; + u32 time; + u32 data; +} __attribute__ ((packed)); + +struct ipw_fw_error { + unsigned long jiffies; + u32 status; + u32 config; + u32 elem_len; + u32 log_len; + struct ipw_error_elem *elem; + struct ipw_event *log; + u8 payload[0]; +} __attribute__ ((packed)); + + + + +static inline u32 ipw_get_event_log_len(struct ipw_priv *priv) +{ + /* length = 1st dword in log */ + return ipw_read_reg32(priv, ipw_read32(priv, IPW_EVENT_LOG)); +} + + + +static struct ipw_fw_error *ipw_alloc_error_log(struct ipw_priv *priv) +{ + struct ipw_fw_error *error; + u32 log_len = ipw_get_event_log_len(priv); + u32 base = ipw_read32(priv, IPW_ERROR_LOG); + u32 elem_len = ipw_read_reg32(priv, base); + + error = kmalloc(sizeof(*error) + + sizeof(*error->elem) * elem_len + + sizeof(*error->log) * log_len, GFP_ATOMIC); + if (!error) { + IPW_ERROR("Memory allocation for firmware error log " + "failed.\n"); + return NULL; + } + error->jiffies = jiffies; + error->status = priv->status; + error->config = priv->config; + error->elem_len = elem_len; + error->log_len = log_len; + error->elem = (struct ipw_error_elem *)error->payload; + error->log = (struct ipw_event *)(error->elem + elem_len); + + ipw_capture_event_log(priv, log_len, error->log); + + if (elem_len) + ipw_read_indirect(priv, base + sizeof(base), (u8 *) error->elem, + sizeof(*error->elem) * elem_len); + + return error; +} + + + +static void ipw_dump_error_log(struct ipw_priv *priv, + struct ipw_fw_error *error) +{ + u32 i; + + if (!error) { + IPW_ERROR("Error allocating and capturing error log. " + "Nothing to dump.\n"); + return; + } + + IPW_ERROR("Start IPW Error Log Dump:\n"); + IPW_ERROR("Status: 0x%08X, Config: %08X\n", + error->status, error->config); + + for (i = 0; i < error->elem_len; i++) + IPW_ERROR("%s %i 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n", + ipw_error_desc(error->elem[i].desc), + error->elem[i].time, + error->elem[i].blink1, + error->elem[i].blink2, + error->elem[i].link1, + error->elem[i].link2, error->elem[i].data); + for (i = 0; i < error->log_len; i++) + IPW_ERROR("%i\t0x%08x\t%i\n", + error->log[i].time, + error->log[i].data, error->log[i].event); +} +#endif +#endif + SYSCTL_SETUP(sysctl_hw_iwi_accept_eula_setup, "sysctl hw.iwi.accept_eula") { const struct sysctlnode *rnode; Index: sys/dev/pci/if_iwn.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_iwn.c,v retrieving revision 1.31 diff -u -p -u -p -r1.31 if_iwn.c --- sys/dev/pci/if_iwn.c 12 May 2009 08:23:00 -0000 1.31 +++ sys/dev/pci/if_iwn.c 24 Jul 2009 07:06:44 -0000 @@ -606,6 +606,12 @@ iwn_dma_contig_free(struct iwn_dma_info { if (dma->map != NULL) { if (dma->vaddr != NULL) { +#if 0 + /* XXXNH */ + bus_dmamap_sync(dma->tag, dma->map, 0, + dma->map->dm_mapsize, + BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE); +#endif bus_dmamap_unload(dma->tag, dma->map); bus_dmamem_unmap(dma->tag, dma->vaddr, dma->size); bus_dmamem_free(dma->tag, &dma->seg, 1); @@ -799,6 +805,10 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, /* Rx buffers are aligned on a 256-byte boundary */ ring->desc[i] = htole32(rbuf->paddr >> 8); } +#if 0 + bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, 0, + ring->desc_dma.map.dm_size, BUS_DMASYNC_PREREAD); +#endif return 0; @@ -862,6 +872,10 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, goto fail; } ring->desc = p; +#if 0 + bus_dmamap_sync(sc->sc_dmat, ring->desc_dma.map, 0, + ring->desc_dma.map.dm_size, BUS_DMASYNC_PREWRITE); +#endif error = iwn_dma_contig_alloc(sc->sc_dmat, &ring->cmd_dma, &p, count * sizeof (struct iwn_tx_cmd), 4, BUS_DMA_NOWAIT); @@ -870,6 +884,10 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, goto fail; } ring->cmd = p; +#if 0 + bus_dmamap_sync(sc->sc_dmat, ring->cmd_dma.map, 0, + ring->cmd_dma.map.dm_size, BUS_DMASYNC_PREWRITE); +#endif ring->data = malloc(count * sizeof (struct iwn_tx_data), M_DEVBUF, M_NOWAIT); @@ -890,6 +908,10 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, aprint_error_dev(sc->sc_dev, "could not create tx buf DMA map\n"); goto fail; } +#if 0 + bus_dmamap_sync(sc->sc_dmat, data->map, 0, data->map.dm_size, + BUS_DMASYNC_PREWRITE); +#endif } return 0; @@ -1733,6 +1755,7 @@ iwn_notif_intr(struct iwn_softc *sc) struct iwn_rx_desc *desc; uint16_t hw; + /* XXXNH bus_dmamap_sync on shared */ hw = le16toh(sc->shared->closed_count); /* @@ -1773,6 +1796,11 @@ iwn_notif_intr(struct iwn_softc *sc) data = &sc->rxq.data[sc->rxq.cur]; desc = (void *)data->m->m_ext.ext_buf; +#if 0 + bus_dmamap_sync(sc->sc_dmat, desc->, BUS_DMASYNC_POSTREAD); +#endif + + DPRINTFN(4,("rx notification qid=%x idx=%d flags=%x type=%d " "len=%d\n", desc->qid, desc->idx, desc->flags, desc->type, le32toh(desc->len))); @@ -2053,8 +2081,8 @@ iwn_tx_data(struct iwn_softc *sc, struct flags = IWN_TX_AUTO_SEQ; if (!noack && !IEEE80211_IS_MULTICAST(wh->i_addr1)){ flags |= IWN_TX_NEED_ACK; - }else if (m0->m_pkthdr.len + IEEE80211_CRC_LEN > ic->ic_rtsthreshold) - flags |= (IWN_TX_NEED_RTS | IWN_TX_FULL_TXOP); + } else if (m0->m_pkthdr.len + IEEE80211_CRC_LEN > ic->ic_rtsthreshold) + flags |= IWN_TX_NEED_RTS | IWN_TX_FULL_TXOP; if (IEEE80211_IS_MULTICAST(wh->i_addr1) || (type != IEEE80211_FC0_TYPE_DATA)) Index: sys/dev/pci/if_iwnreg.h =================================================================== RCS file: /cvsroot/src/sys/dev/pci/if_iwnreg.h,v retrieving revision 1.5 diff -u -p -u -p -r1.5 if_iwnreg.h --- sys/dev/pci/if_iwnreg.h 13 Nov 2008 12:04:09 -0000 1.5 +++ sys/dev/pci/if_iwnreg.h 24 Jul 2009 07:06:45 -0000 @@ -66,7 +66,7 @@ #define IWN_RX_WIDX 0x1bc8 #define IWN_RX_CONFIG 0x1c00 #define IWN_RX_STATUS 0x1c44 -#define IWN_TX_CONFIG(qid) (0x1d00 + (qid) * 32) +#define IWN_TX_CONFIG(qid) (0x1d00 + (qid) * 32) /* IWL_FH_TCSR_CHNL_TX_CONFIG_REG */ #define IWN_TX_STATUS 0x1eb0 #define IWN_SRAM_BASE 0xa02c00 Index: sys/dev/pci/sti_pci.c =================================================================== RCS file: sys/dev/pci/sti_pci.c diff -N sys/dev/pci/sti_pci.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/dev/pci/sti_pci.c 24 Jul 2009 07:06:45 -0000 @@ -0,0 +1,392 @@ +/* $NetBSD$ */ + +/* $OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $ */ + +/* + * Copyright (c) 2006, 2007 Miodrag Vallat. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice, this permission notice, and the disclaimer below + * appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include + +int sti_pci_match(device_t, void *, void *); +void sti_pci_attach(device_t, struct device *, void *); + +struct sti_pci_softc { + struct sti_softc sc_base; + + pci_chipset_tag_t sc_pc; + pcitag_t sc_tag; + + bus_space_handle_t sc_romh; +}; + +CFATTACH_DECL_NEW(sti_pci, sizeof(struct sti_pci_softc), + sti_pci_match, sti_pci_attach, NULL, NULL); + +#if 0 +const struct pci_matchid sti_pci_devices[] = { + { PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_EG }, + { PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX2 }, + { PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX4 }, + { PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX6 }, + { PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FXE }, +}; +#endif + +int sti_readbar(struct sti_softc *, struct pci_attach_args *, u_int, int); +int sti_check_rom(struct sti_pci_softc *, struct pci_attach_args *); +void sti_pci_enable_rom(struct sti_softc *); +void sti_pci_disable_rom(struct sti_softc *); + +int sti_pci_is_console(struct pci_attach_args *, bus_addr_t *); + +int +sti_pci_match(struct device *parent, void *cf, void *aux) +{ + struct pci_attach_args *paa = aux; + + if (PCI_VENDOR(paa->pa_id) != PCI_VENDOR_HP) + return 0; + + if (PCI_PRODUCT(paa->pa_id) == PCI_PRODUCT_HP_VISUALIZE_EG || + PCI_PRODUCT(paa->pa_id) == PCI_PRODUCT_HP_VISUALIZE_FX2 || + PCI_PRODUCT(paa->pa_id) == PCI_PRODUCT_HP_VISUALIZE_FX4 || + PCI_PRODUCT(paa->pa_id) == PCI_PRODUCT_HP_VISUALIZE_FXE) + return 1; + + return 0; +} + +void +sti_pci_attach(device_t parent, device_t self, void *aux) +{ + struct sti_pci_softc *spc = device_private(self); + struct pci_attach_args *paa = aux; + + spc->sc_pc = paa->pa_pc; + spc->sc_tag = paa->pa_tag; + spc->sc_base.sc_enable_rom = sti_pci_enable_rom; + spc->sc_base.sc_disable_rom = sti_pci_disable_rom; + +/* XXX */ + aprint_normal("\n"); + + if (sti_check_rom(spc, paa) != 0) + return; + +/* XXX */ + aprint_normal("%s", device_xname(self)); + if (sti_pci_is_console(paa, spc->sc_base.bases) != 0) + spc->sc_base.sc_flags |= STI_CONSOLE; + if (sti_attach_common(&spc->sc_base, paa->pa_iot, paa->pa_memt, + spc->sc_romh, STI_CODEBASE_MAIN) == 0) + startuphook_establish(sti_end_attach, spc); +} + +/* + * Grovel the STI ROM image. + */ +int +sti_check_rom(struct sti_pci_softc *spc, struct pci_attach_args *pa) +{ + struct sti_softc *sc = &spc->sc_base; + pcireg_t address, mask; + bus_space_handle_t romh; + bus_size_t romsize, subsize, stiromsize; + bus_addr_t selected, offs, suboffs; + u_int32_t tmp; + int i; + int rc; + + /* sort of inline sti_pci_enable_rom(sc) */ + address = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_ROM_REG); + pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_ROM_REG, ~PCI_ROM_ENABLE); + mask = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_ROM_REG); + address |= PCI_ROM_ENABLE; + pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_ROM_REG, address); + sc->sc_flags |= STI_ROM_ENABLED; + + /* + * Map the complete ROM for now. + */ + + romsize = PCI_ROM_SIZE(mask); + rc = bus_space_map(pa->pa_memt, PCI_ROM_ADDR(address), romsize, + 0, &romh); + sti_pci_disable_rom(sc); + if (rc != 0) { + printf("%s: can't map PCI ROM (%d)\n", + sc->sc_dev.dv_xname, rc); + goto fail2; + } + + /* + * Iterate over the ROM images, pick the best candidate. + */ + + selected = (bus_addr_t)-1; + for (offs = 0; offs < romsize; offs += subsize) { + sti_pci_enable_rom(sc); + /* + * Check for a valid ROM header. + */ + tmp = bus_space_read_4(pa->pa_memt, romh, offs + 0); + tmp = letoh32(tmp); + if (tmp != 0x55aa0000) { + sti_pci_disable_rom(sc); + if (offs == 0) { + printf("%s: invalid PCI ROM header signature" + " (%08x)\n", + sc->sc_dev.dv_xname, tmp); + rc = EINVAL; + } + break; + } + + /* + * Check ROM type. + */ + tmp = bus_space_read_4(pa->pa_memt, romh, offs + 4); + tmp = letoh32(tmp); + if (tmp != 0x00000001) { /* 1 == STI ROM */ + sti_pci_disable_rom(sc); + if (offs == 0) { + printf("%s: invalid PCI ROM type (%08x)\n", + sc->sc_dev.dv_xname, tmp); + rc = EINVAL; + } + break; + } + + subsize = (bus_addr_t)bus_space_read_2(pa->pa_memt, romh, + offs + 0x0c); + subsize <<= 9; + +#ifdef STIDEBUG + sti_pci_disable_rom(sc); + printf("ROM offset %08x size %08x type %08x", + offs, subsize, tmp); + sti_pci_enable_rom(sc); +#endif + + /* + * Check for a valid ROM data structure. + * We do not need it except to know what architecture the ROM + * code is for. + */ + + suboffs = offs +(bus_addr_t)bus_space_read_2(pa->pa_memt, romh, + offs + 0x18); + tmp = bus_space_read_4(pa->pa_memt, romh, suboffs + 0); + tmp = letoh32(tmp); + if (tmp != 0x50434952) { /* PCIR */ + sti_pci_disable_rom(sc); + if (offs == 0) { + printf("%s: invalid PCI data signature" + " (%08x)\n", + sc->sc_dev.dv_xname, tmp); + rc = EINVAL; + } else { +#ifdef STIDEBUG + printf(" invalid PCI data signature %08x\n", + tmp); +#endif + continue; + } + } + + tmp = bus_space_read_1(pa->pa_memt, romh, suboffs + 0x14); + sti_pci_disable_rom(sc); +#ifdef STIDEBUG + printf(" code %02x", tmp); +#endif + + switch (tmp) { +#ifdef __hppa__ + case 0x10: + if (selected == (bus_addr_t)-1) + selected = offs; + break; +#endif +#ifdef __i386__ + case 0x00: + if (selected == (bus_addr_t)-1) + selected = offs; + break; +#endif + default: +#ifdef STIDEBUG + printf(" (wrong architecture)"); +#endif + break; + } + +#ifdef STIDEBUG + if (selected == offs) + printf(" -> SELECTED"); + printf("\n"); +#endif + } + + if (selected == (bus_addr_t)-1) { + if (rc == 0) { + printf("%s: found no ROM with correct microcode" + " architecture\n", sc->sc_dev.dv_xname); + rc = ENOEXEC; + } + goto fail; + } + + /* + * Read the STI region BAR assignments. + */ + + sti_pci_enable_rom(sc); + offs = selected + + (bus_addr_t)bus_space_read_2(pa->pa_memt, romh, selected + 0x0e); + for (i = 0; i < STI_REGION_MAX; i++) { + rc = sti_readbar(sc, pa, i, + bus_space_read_1(pa->pa_memt, romh, offs + i)); + if (rc != 0) + goto fail; + } + + /* + * Find out where the STI ROM itself lies, and its size. + */ + + offs = selected + + (bus_addr_t)bus_space_read_4(pa->pa_memt, romh, selected + 0x08); + stiromsize = (bus_addr_t)bus_space_read_4(pa->pa_memt, romh, + offs + 0x18); + stiromsize = letoh32(stiromsize); + sti_pci_disable_rom(sc); + + /* + * Replace our mapping with a smaller mapping of only the area + * we are interested in. + */ + + bus_space_unmap(pa->pa_memt, romh, romsize); + rc = bus_space_map(pa->pa_memt, PCI_ROM_ADDR(address) + offs, + stiromsize, 0, &spc->sc_romh); + if (rc != 0) { + printf("%s: can't map STI ROM (%d)\n", + sc->sc_dev.dv_xname, rc); + goto fail2; + } + + return (0); + +fail: + bus_space_unmap(pa->pa_memt, romh, romsize); +fail2: + sti_pci_disable_rom(sc); + + return (rc); +} + +/* + * Decode a BAR register. + */ +int +sti_readbar(struct sti_softc *sc, struct pci_attach_args *pa, u_int region, + int bar) +{ + bus_addr_t addr; + bus_size_t size; + u_int32_t cf; + int rc; + + if (bar == 0) { + sc->bases[region] = 0; + return (0); + } + +#ifdef DIAGNOSTIC + if (bar < PCI_MAPREG_START || bar > PCI_MAPREG_PPB_END) { + sti_pci_disable_rom(sc); + printf("%s: unexpected bar %02x for region %d\n", + sc->sc_dev.dv_xname, bar, region); + sti_pci_enable_rom(sc); + } +#endif + + cf = pci_conf_read(pa->pa_pc, pa->pa_tag, bar); + + if (PCI_MAPREG_TYPE(cf) == PCI_MAPREG_TYPE_IO) + rc = pci_io_find(pa->pa_pc, pa->pa_tag, bar, &addr, &size); + else + rc = pci_mem_find(pa->pa_pc, pa->pa_tag, bar, &addr, &size, + NULL); + + if (rc != 0) { + sti_pci_disable_rom(sc); + printf("%s: invalid bar %02x for region %d\n", + sc->sc_dev.dv_xname, bar, region); + sti_pci_enable_rom(sc); + return (rc); + } + + sc->bases[region] = addr; + return (0); +} + +/* + * Enable PCI ROM. + */ +void +sti_pci_enable_rom(struct sti_softc *sc) +{ + struct sti_pci_softc *spc = (struct sti_pci_softc *)sc; + pcireg_t address; + + if (!ISSET(sc->sc_flags, STI_ROM_ENABLED)) { + address = pci_conf_read(spc->sc_pc, spc->sc_tag, PCI_ROM_REG); + address |= PCI_ROM_ENABLE; + pci_conf_write(spc->sc_pc, spc->sc_tag, PCI_ROM_REG, address); + SET(sc->sc_flags, STI_ROM_ENABLED); + } +} + +/* + * Disable PCI ROM. + */ +void +sti_pci_disable_rom(struct sti_softc *sc) +{ + struct sti_pci_softc *spc = (struct sti_pci_softc *)sc; + pcireg_t address; + + if (ISSET(sc->sc_flags, STI_ROM_ENABLED)) { + address = pci_conf_read(spc->sc_pc, spc->sc_tag, PCI_ROM_REG); + address &= ~PCI_ROM_ENABLE; + pci_conf_write(spc->sc_pc, spc->sc_tag, PCI_ROM_REG, address); + + CLR(sc->sc_flags, STI_ROM_ENABLED); + } +} Index: sys/dev/usb/ucycom.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/ucycom.c,v retrieving revision 1.28 diff -u -p -u -p -r1.28 ucycom.c --- sys/dev/usb/ucycom.c 24 Jul 2009 06:58:24 -0000 1.28 +++ sys/dev/usb/ucycom.c 24 Jul 2009 07:06:46 -0000 @@ -66,7 +66,7 @@ __KERNEL_RCSID(0, "$NetBSD: ucycom.c,v 1 #ifdef UCYCOM_DEBUG #define DPRINTF(x) if (ucycomdebug) logprintf x #define DPRINTFN(n, x) if (ucycomdebug > (n)) logprintf x -int ucycomdebug = 0; +int ucycomdebug = 20; #else #define DPRINTF(x) #define DPRINTFN(n,x) @@ -122,6 +122,7 @@ struct ucycom_softc { size_t sc_olen; /* output report length */ uint8_t *sc_obuf; + int sc_wlen; /* settings */ uint32_t sc_baud; @@ -150,6 +151,7 @@ const struct cdevsw ucycom_cdevsw = { Static int ucycomparam(struct tty *, struct termios *); Static void ucycomstart(struct tty *); +Static void ucycomwritecb(usbd_xfer_handle, usbd_private_handle, usbd_status); Static void ucycom_intr(struct uhidev *, void *, u_int); Static int ucycom_configure(struct ucycom_softc *, uint32_t, uint8_t); Static void tiocm_to_ucycom(struct ucycom_softc *, u_long, int); @@ -162,12 +164,15 @@ Static void ucycom_rts(struct ucycom_sof Static void ucycom_cleanup(struct ucycom_softc *sc); #ifdef UCYCOM_DEBUG +#if 0 Static void ucycom_get_cfg(struct ucycom_softc *); #endif +#endif Static const struct usb_devno ucycom_devs[] = { { USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_USBRS232 }, { USB_VENDOR_DELORME, USB_PRODUCT_DELORME_EARTHMATE }, + { USB_VENDOR_DELORME, USB_PRODUCT_DELORME_EARTHMATE_LT20 }, }; #define ucycom_lookup(v, p) usb_lookup(ucycom_devs, v, p) @@ -444,8 +449,9 @@ ucycomstart(struct tty *tp) { struct ucycom_softc *sc = device_lookup_private(&ucycom_cd, UCYCOMUNIT(tp->t_dev)); + usbd_status err; u_char *data; - int cnt, len, err, s; + int cnt, len, s; if (sc->sc_dying) return; @@ -540,7 +546,7 @@ ucycomstart(struct tty *tp) sc->sc_olen)); goto out; } - splx(s); + sc->sc_wlen = len; #ifdef UCYCOM_DEBUG if (ucycomdebug > 5) { @@ -555,26 +561,64 @@ ucycomstart(struct tty *tp) } } #endif - err = uhidev_write(sc->sc_hdev.sc_parent, sc->sc_obuf, sc->sc_olen); + DPRINTFN(4,("ucycomstart: %d chars\n", len)); + usbd_setup_xfer(sc->sc_hdev.sc_parent->sc_oxfer, + sc->sc_hdev.sc_parent->sc_opipe, (usbd_private_handle)sc, + sc->sc_obuf, sc->sc_olen, 0 /* USBD_NO_COPY */, USBD_NO_TIMEOUT, + ucycomwritecb); - if (err) { - DPRINTF(("ucycomstart: error doing uhidev_write = %d\n", err)); - } + /* What can we do on error? */ + err = usbd_transfer(sc->sc_hdev.sc_parent->sc_oxfer); #ifdef UCYCOM_DEBUG - ucycom_get_cfg(sc); + if (err != USBD_IN_PROGRESS) + DPRINTF(("ucycomstart: err=%s\n", usbd_errstr(err))); #endif - DPRINTFN(4,("ucycomstart: req %d chars did %d chars\n", cnt, len)); - s = spltty(); +out: + splx(s); +} + +Static void +ucycomwritecb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status) +{ + struct ucycom_softc *sc = (struct ucycom_softc *)p; + struct tty *tp = sc->sc_tty; + usbd_status stat; + int len, s; + + if (status == USBD_CANCELLED || sc->sc_dying) + goto error; + + if (status) { + DPRINTF(("ucycomwritecb: status=%d\n", status)); + usbd_clear_endpoint_stall(sc->sc_hdev.sc_parent->sc_opipe); + /* XXX we should restart after some delay. */ + goto error; + } + + usbd_get_xfer_status(xfer, NULL, NULL, &len, &stat); + + if (status != USBD_NORMAL_COMPLETION) { + DPRINTFN(4,("ucycomwritecb: status = %d\n", status)); + goto error; + } + + DPRINTFN(4,("ucycomwritecb: did %d/%d chars\n", sc->sc_wlen, len)); + + s = spltty(); CLR(tp->t_state, TS_BUSY); if (ISSET(tp->t_state, TS_FLUSH)) CLR(tp->t_state, TS_FLUSH); else - ndflush(&tp->t_outq, len); + ndflush(&tp->t_outq, sc->sc_wlen); (*tp->t_linesw->l_start)(tp); + splx(s); + return; -out: +error: + s = spltty(); + CLR(tp->t_state, TS_BUSY); splx(s); } @@ -1035,6 +1079,7 @@ ucycom_set_status(struct ucycom_softc *s } #ifdef UCYCOM_DEBUG +#if 0 Static void ucycom_get_cfg(struct ucycom_softc *sc) { @@ -1053,6 +1098,7 @@ ucycom_get_cfg(struct ucycom_softc *sc) (cfg & UCYCOM_STOP_MASK) ? 2 : 1, cfg)); } #endif +#endif Static void ucycom_cleanup(struct ucycom_softc *sc) Index: sys/kern/kern_exit.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_exit.c,v retrieving revision 1.222 diff -u -p -u -p -r1.222 kern_exit.c --- sys/kern/kern_exit.c 28 Jun 2009 11:42:43 -0000 1.222 +++ sys/kern/kern_exit.c 24 Jul 2009 07:06:46 -0000 @@ -589,34 +589,33 @@ exit_lwps(struct lwp *l) p = l->l_proc; KASSERT(mutex_owned(p->p_lock)); -#ifdef KERN_SA +#if 0 if (p->p_sa != NULL) { - struct sadata_vp *vp; SLIST_FOREACH(vp, &p->p_sa->sa_vps, savp_next) { /* - * Make SA-cached LWPs normal process interruptable - * so that the exit code can wake them. Locking - * savp_mutex locks all the lwps on this vp that - * we need to adjust. + * Make SA-cached LWPs normal process runnable + * LWPs so that they'll also self-destruct. */ - mutex_enter(&vp->savp_mutex); DPRINTF(("exit_lwps: Making cached LWPs of %d on " - "VP %d interruptable: ", p->p_pid, vp->savp_id)); - TAILQ_FOREACH(l2, &vp->savp_lwpcache, l_sleepchain) { - l2->l_flag |= LW_SINTR; - DPRINTF(("%d ", l2->l_lid)); - } - DPRINTF(("\n")); + "VP %d runnable: ", p->p_pid, vp->savp_id)); + while ((l2 = sa_getcachelwp(p, vp)) != 0) { + lwp_lock(l2); + l2->l_flag = (l2->l_flag & ~LW_SA) | LW_WEXIT; + l2->l_priority = MAXPRI_USER; /* XXX WRS needs thought */ - DPRINTF(("exit_lwps: Making unblocking LWPs of %d on " - "VP %d interruptable: ", p->p_pid, vp->savp_id)); - TAILQ_FOREACH(l2, &vp->savp_woken, l_sleepchain) { - vp->savp_woken_count--; - l2->l_flag |= LW_SINTR; + /* setrunnable() will release the mutex. */ + setrunnable(l2); DPRINTF(("%d ", l2->l_lid)); } DPRINTF(("\n")); - mutex_exit(&vp->savp_mutex); + + /* + * Clear wokenq, the LWPs on the queue will + * run below. Workes as these threads are still + * on the p_lwps list (even though they are no longer + * counted). + */ + TAILQ_INIT(&vp->savp_woken); } } #endif Index: sys/kern/kern_lwp.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_lwp.c,v retrieving revision 1.132 diff -u -p -u -p -r1.132 kern_lwp.c --- sys/kern/kern_lwp.c 10 Jul 2009 23:07:54 -0000 1.132 +++ sys/kern/kern_lwp.c 24 Jul 2009 07:06:47 -0000 @@ -1729,6 +1729,8 @@ lwp_ctl_exit(void) lcp->lcp_kaddr + PAGE_SIZE); kmem_free(lcp, LWPCTL_LCPAGE_SZ); } + /* XXXNH */ + /* lp_uao vs lp->lp_uva */ if (lp->lp_uao != NULL) { uvm_unmap(&p->p_vmspace->vm_map, lp->lp_uva, Index: sys/kern/sys_process.c =================================================================== RCS file: /cvsroot/src/sys/kern/sys_process.c,v retrieving revision 1.147 diff -u -p -u -p -r1.147 sys_process.c --- sys/kern/sys_process.c 28 Jun 2009 11:42:07 -0000 1.147 +++ sys/kern/sys_process.c 24 Jul 2009 07:06:48 -0000 @@ -685,6 +685,7 @@ sys_ptrace(struct lwp *l, const struct s error = ESRCH; break; } + /* XXXNH - this can be a LSZOMB!!! */ lwp_addref(lt); mutex_exit(t->p_lock); } @@ -728,6 +729,7 @@ sys_ptrace(struct lwp *l, const struct s error = ESRCH; break; } + /* XXXNH - this can be a LSZOMB!!! */ lwp_addref(lt); mutex_exit(t->p_lock); } Index: sys/miscfs/genfs/genfs_io.c =================================================================== RCS file: /cvsroot/src/sys/miscfs/genfs/genfs_io.c,v retrieving revision 1.20 diff -u -p -u -p -r1.20 genfs_io.c --- sys/miscfs/genfs/genfs_io.c 18 Apr 2009 15:40:33 -0000 1.20 +++ sys/miscfs/genfs/genfs_io.c 24 Jul 2009 07:06:49 -0000 @@ -674,6 +674,7 @@ out: uvm_pagezero(pg); } if (pg->flags & PG_RELEASED) { + /* XXXNH is this page accessed with PA==VA??? */ uvm_pagefree(pg); continue; } @@ -1099,6 +1100,7 @@ retry: */ nextpg = TAILQ_NEXT(tpg, listq.queue); + /* XXXNH is this page accessed with PA==VA??? */ uvm_pagefree(tpg); if (pagedaemon) uvmexp.pdfreed++; Index: sys/sys/exec_elf.h =================================================================== RCS file: /cvsroot/src/sys/sys/exec_elf.h,v retrieving revision 1.97 diff -u -p -u -p -r1.97 exec_elf.h --- sys/sys/exec_elf.h 22 May 2009 21:44:50 -0000 1.97 +++ sys/sys/exec_elf.h 24 Jul 2009 07:06:49 -0000 @@ -328,7 +328,8 @@ typedef struct { #define PT_NOTE 4 /* Auxiliary information */ #define PT_SHLIB 5 /* Reserved, unspecified semantics */ #define PT_PHDR 6 /* Entry for header table itself */ -#define PT_NUM 7 +#define PT_TLS 7 /* TLS initialisation image */ +#define PT_NUM 8 #define PT_LOOS 0x60000000 /* OS-specific range */ #define PT_HIOS 0x6fffffff @@ -389,6 +390,8 @@ typedef struct { #define SHT_DYNSYM 11 /* Symbol table for dynamic linker */ #define SHT_NUM 12 +#define SHT_TLS (1 << 10) /* 0x00000400 */ + #define SHT_LOOS 0x60000000 /* Operating system specific range */ #define SHT_SUNW_VERDEF 0x6ffffffd /* Versions defined by file */ #define SHT_SUNW_VERNEED 0x6ffffffe /* Versions needed by file */ @@ -450,7 +453,9 @@ typedef struct { #define STT_FUNC 2 /* Associated with a function */ #define STT_SECTION 3 /* Associated with a section */ #define STT_FILE 4 /* Associated with a file name */ -#define STT_NUM 5 +#define STT_COMMON 5 /* XXX Research */ +#define STT_TLS 6 +#define STT_NUM 7 /* XXX Needed */ #define STT_LOOS 10 /* Operating system specific range */ #define STT_HIOS 12 Index: tools/binutils/Makefile =================================================================== RCS file: /cvsroot/src/tools/binutils/Makefile,v retrieving revision 1.12 diff -u -p -u -p -r1.12 Makefile --- tools/binutils/Makefile 19 Nov 2007 05:54:03 -0000 1.12 +++ tools/binutils/Makefile 24 Jul 2009 07:06:49 -0000 @@ -18,6 +18,8 @@ INSTALL_TARGET+=install-gprof .include "${.CURDIR}/../Makefile.gnuhost" +HOST_CC+= -O0 -g + CCADDFLAGS= -I${DESTDIR}/usr/include -L${DESTDIR}/lib -L${DESTDIR}/usr/lib -B${DESTDIR}/usr/lib/ NEWCONFIGDIR?= ${.CURDIR}/../..