From: downsj Date: Sun, 12 Jan 1997 15:12:06 +0000 (+0000) Subject: Mostly sync to NetBSD-current of 011196. Compiles, links, boots to single X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1c7df8d3c3b1e0785dd4a1a35043719c227e2f67;p=openbsd Mostly sync to NetBSD-current of 011196. Compiles, links, boots to single user. KNOWN NOT WORKING: * DIO-II devices * Dynamic executables NOT EVEN TRIED: * New config support --- diff --git a/sys/arch/hp300/DOC/Debug.tips b/sys/arch/hp300/DOC/Debug.tips index e0f7d88f547..d55d4350ba7 100644 --- a/sys/arch/hp300/DOC/Debug.tips +++ b/sys/arch/hp300/DOC/Debug.tips @@ -1,3 +1,4 @@ +$OpenBSD: Debug.tips,v 1.2 1997/01/12 15:12:08 downsj Exp $ $NetBSD: Debug.tips,v 1.2 1994/10/26 07:22:49 cgd Exp $ NOTE: this description applies to the hp300 system with the old BSD diff --git a/sys/arch/hp300/DOC/HPMMU.notes b/sys/arch/hp300/DOC/HPMMU.notes index eba243ad72a..be817ab9784 100644 --- a/sys/arch/hp300/DOC/HPMMU.notes +++ b/sys/arch/hp300/DOC/HPMMU.notes @@ -1,3 +1,4 @@ +$OpenBSD: HPMMU.notes,v 1.2 1997/01/12 15:12:09 downsj Exp $ $NetBSD: HPMMU.notes,v 1.2 1994/10/26 07:22:51 cgd Exp $ Overview: diff --git a/sys/arch/hp300/DOC/Options b/sys/arch/hp300/DOC/Options index 2bfd60d8645..0a522b44605 100644 --- a/sys/arch/hp300/DOC/Options +++ b/sys/arch/hp300/DOC/Options @@ -1,4 +1,5 @@ -$NetBSD: Options,v 1.3 1994/10/26 07:22:52 cgd Exp $ +$OpenBSD: Options,v 1.2 1997/01/12 15:12:10 downsj Exp $ +$NetBSD: Options,v 1.5 1996/10/13 16:52:40 christos Exp $ Here is a list of hp300 specific kernel compilation options and what they mean: diff --git a/sys/arch/hp300/DOC/Pmap.notes b/sys/arch/hp300/DOC/Pmap.notes index ad0cbc973cc..a494683c49a 100644 --- a/sys/arch/hp300/DOC/Pmap.notes +++ b/sys/arch/hp300/DOC/Pmap.notes @@ -1,3 +1,4 @@ +$OpenBSD: Pmap.notes,v 1.2 1997/01/12 15:12:10 downsj Exp $ $NetBSD: Pmap.notes,v 1.2 1994/10/26 07:22:54 cgd Exp $ Following are some observations about the the BSD hp300 pmap module that diff --git a/sys/arch/hp300/DOC/README b/sys/arch/hp300/DOC/README index 057983b8487..044c85f40ab 100644 --- a/sys/arch/hp300/DOC/README +++ b/sys/arch/hp300/DOC/README @@ -1,3 +1,4 @@ +$OpenBSD: README,v 1.2 1997/01/12 15:12:11 downsj Exp $ $NetBSD: README,v 1.2 1994/10/26 07:22:55 cgd Exp $ This directory contains random snippets related to various hp300 issues. diff --git a/sys/arch/hp300/DOC/TODO.dev b/sys/arch/hp300/DOC/TODO.dev index 3a55d5fc29b..acd5b490e81 100644 --- a/sys/arch/hp300/DOC/TODO.dev +++ b/sys/arch/hp300/DOC/TODO.dev @@ -1,3 +1,4 @@ +$OpenBSD: TODO.dev,v 1.2 1997/01/12 15:12:11 downsj Exp $ $NetBSD: TODO.dev,v 1.2 1994/10/26 07:22:57 cgd Exp $ [ this is old -- mike ] diff --git a/sys/arch/hp300/DOC/TODO.hp300 b/sys/arch/hp300/DOC/TODO.hp300 index 53030e217af..7c5ea196302 100644 --- a/sys/arch/hp300/DOC/TODO.hp300 +++ b/sys/arch/hp300/DOC/TODO.hp300 @@ -1,3 +1,4 @@ +$OpenBSD: TODO.hp300,v 1.2 1997/01/12 15:12:12 downsj Exp $ $NetBSD: TODO.hp300,v 1.2 1994/10/26 07:22:59 cgd Exp $ 1. Create and use an interrupt stack. diff --git a/sys/arch/hp300/Makefile b/sys/arch/hp300/Makefile index c388caca1a4..fd475ee6e56 100644 --- a/sys/arch/hp300/Makefile +++ b/sys/arch/hp300/Makefile @@ -1,5 +1,5 @@ +# $OpenBSD: Makefile,v 1.2 1997/01/12 15:12:06 downsj Exp $ # $NetBSD: Makefile,v 1.5 1995/08/04 07:40:31 thorpej Exp $ - # @(#)Makefile 7.3 (Berkeley) 6/9/91 # Makefile for hp300 tags file and boot blocks diff --git a/sys/arch/hp300/conf/DISKLESS b/sys/arch/hp300/conf/DISKLESS index 58e4791aeb2..24cd82c4969 100644 --- a/sys/arch/hp300/conf/DISKLESS +++ b/sys/arch/hp300/conf/DISKLESS @@ -1,4 +1,5 @@ -# $NetBSD: DISKLESS,v 1.5 1995/12/29 17:12:50 thorpej Exp $ +# $OpenBSD: DISKLESS,v 1.8 1997/01/12 15:12:13 downsj Exp $ +# $NetBSD: DISKLESS,v 1.11 1996/12/11 09:10:38 thorpej Exp $ # # Diskless HP 9000/300-series workstation. # @@ -50,6 +51,8 @@ options NMBCLUSTERS="512" # Just a little extra options FPSP # floating point interface for 68040 options USELEDS # make the lights twinkle #options PANICBUTTON # two fast s on HIL dump kernel +options UK_KEYBOARD # include United Kingdom HIL keymap +options SE_KEYBOARD # include Swedish HIL keymap # # HP-UX binary compatibility. @@ -57,6 +60,8 @@ options USELEDS # make the lights twinkle # options COMPAT_HPUX # HP-UX binary compatibility +#options "COMPAT_M68K4K" # compat. with NetBSD/m68k4k binaries + # Debugging options options DDB # Kernel Dynamic Debugger diff --git a/sys/arch/hp300/conf/GENERIC b/sys/arch/hp300/conf/GENERIC index a1810cabe53..1719102e1a0 100644 --- a/sys/arch/hp300/conf/GENERIC +++ b/sys/arch/hp300/conf/GENERIC @@ -1,4 +1,5 @@ -# $NetBSD: GENERIC,v 1.9 1996/02/24 00:54:53 thorpej Exp $ +# $OpenBSD: GENERIC,v 1.10 1997/01/12 15:12:13 downsj Exp $ +# $NetBSD: GENERIC,v 1.16 1996/12/11 09:10:40 thorpej Exp $ # # Generic kernel - one size fits all. # @@ -56,6 +57,8 @@ options USELEDS # make the lights twinkle options COMPAT_NOLABEL # defaults for unlabeled disks #options PANICBUTTON # two fast s on HIL dump kernel #options CONSCODE="9" # force console at this select code +options UK_KEYBOARD # include United Kingdom HIL keymap +options SE_KEYBOARD # include Swedish HIL keymap # # HP-UX binary compatibility. @@ -66,8 +69,6 @@ options COMPAT_HPUX # HP-UX binary compatibility # Debugging options options DDB # Kernel Dynamic Debugger -# If the kernel isn't named `GENERIC', uncomment the line below. -#options GENERIC # Generic swap support config bsd swap generic master hpib0 at scode7 diff --git a/sys/arch/hp300/conf/Makefile.hp300 b/sys/arch/hp300/conf/Makefile.hp300 index 60e1d4ad7b6..25db7e22268 100644 --- a/sys/arch/hp300/conf/Makefile.hp300 +++ b/sys/arch/hp300/conf/Makefile.hp300 @@ -1,6 +1,7 @@ -# $NetBSD: Makefile.hp300,v 1.39 1996/05/11 16:12:02 mycroft Exp $ +# $OpenBSD: Makefile.hp300,v 1.10 1997/01/12 15:12:14 downsj Exp $ +# $NetBSD: Makefile.hp300,v 1.45 1996/12/01 06:12:30 jonathan Exp $ -# Makefile for NetBSD +# Makefile for OpenBSD # # This makefile is constructed from a machine description: # config machineid @@ -21,22 +22,28 @@ # DEBUG is set to -g if debugging. # PROF is set to -pg if profiling. -AS?= as CC?= cc -CPP?= cpp LD?= ld -STRIP?= strip -d -TOUCH?= touch -f -c +MKDEP?= mkdep +STRIP?= strip +COPTS?= -O2 # source tree is located via $S relative to the compilation directory S= ../../../.. HP300= ../.. -INCLUDES= -I. -I$S/arch -I$S -CPPFLAGS= ${INCLUDES} ${IDENT} -D_KERNEL -Dmc68020 -Dhp300 -DFPCOPROC -CFLAGS= ${DEBUG} -O2 -Werror -msoft-float +INCLUDES= -I. -I$S/arch -I$S -nostdinc +CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL \ + -Dmc68020 -Dhp300 -DFPCOPROC +CWARNFLAGS= -Werror +CFLAGS= ${DEBUG} ${COPTS} ${CWARNFLAGS} -msoft-float AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE LINKFLAGS= -n -Ttext 0 -e start +STRIPFLAGS= -d + +HOSTED_CC= ${CC} +HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//} +HOSTED_CFLAGS= ${CFLAGS} ### find out what to use for libkern .include "$S/lib/libkern/Makefile.inc" @@ -57,19 +64,13 @@ LIBCOMPAT= ${COMPATLIB_PROF} ### for the Motorola 68040 Floating Point Software Product .include "$S/arch/m68k/fpsp/Makefile.inc" -# compile rules: rules are named ${TYPE}_${SUFFIX}${CONFIG_DEP} -# where TYPE is NORMAL, DRIVER, or PROFILE}; SUFFIX is the file suffix, -# capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file -# is marked as config-dependent. +# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or +# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file). NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< -NORMAL_C_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} -c $< - -DRIVER_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< -DRIVER_C_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} -c $< - NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< -NORMAL_S_C= ${CC} ${AFLAGS} ${CPPFLAGS} ${PARAM} -c $< + +HOSTED_C= ${HOSTED_CC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $< %OBJS @@ -95,9 +96,9 @@ DEBUG?= LINKFLAGS+= -X SYSTEM_LD_TAIL+=; \ echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \ - echo ${STRIP} $@; ${STRIP} $@ + echo ${STRIP} ${STRIPFLAGS} $@; ${STRIP} ${STRIPFLAGS} $@ .else -LINKFLAGS+= -x +LINKFLAGS+= -S .endif %LOAD @@ -109,14 +110,14 @@ genassym: genassym.o ${CC} -o $@ genassym.o genassym.o: ${HP300}/hp300/genassym.c - ${NORMAL_C_C} + ${HOSTED_C} param.c: $S/conf/param.c rm -f param.c cp $S/conf/param.c . param.o: param.c Makefile - ${NORMAL_C_C} + ${NORMAL_C} ioconf.o: ioconf.c ${NORMAL_C} @@ -131,7 +132,7 @@ clean:: [Ee]rrs linterrs makelinks genassym genassym.o assym.h lint: - @lint -hbxncez -DGENERIC -Dvolatile= ${CPPFLAGS} ${PARAM} -UKGDB \ + @lint -hbxncez -DGENERIC -Dvolatile= ${CPPFLAGS} -UKGDB \ ${HP300}/hp300/Locore.c ${CFILES} ${HP300}/hp300/swapgeneric.c \ ioconf.c param.c | \ grep -v 'static function .* unused' @@ -151,12 +152,13 @@ SRCS= ${HP300}/hp300/locore.s \ param.c ioconf.c ${CFILES} ${SFILES} depend:: .depend .depend: ${SRCS} assym.h param.c - mkdep ${AFLAGS} ${CPPFLAGS} ${HP300}/hp300/locore.s - mkdep -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} + ${MKDEP} ${AFLAGS} ${CPPFLAGS} ${HP300}/hp300/locore.s + ${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} -if test -n "${SFILES}"; then \ - mkdep -a ${AFLAGS} ${CPPFLAGS} ${SFILES}; \ + ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}; \ fi - mkdep -a ${CFLAGS} ${CPPFLAGS} ${PARAM} ${HP300}/hp300/genassym.c + ${MKDEP} -a ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} \ + ${HP300}/hp300/genassym.c # depend on root or device configuration diff --git a/sys/arch/hp300/conf/NEWCONFIG b/sys/arch/hp300/conf/NEWCONFIG new file mode 100644 index 00000000000..7c0344eea65 --- /dev/null +++ b/sys/arch/hp300/conf/NEWCONFIG @@ -0,0 +1,148 @@ +# $OpenBSD: NEWCONFIG,v 1.1 1997/01/12 15:12:14 downsj Exp $ +# $NetBSD: NEWCONFIG,v 1.1 1996/12/17 08:40:56 thorpej Exp $ +# +# "Generic" kernel for new-style config. +# + +# Include attributes common to all hp300s +include "arch/hp300/conf/std.hp300" + +# Support for various CPU types +options HP320 +options HP330 # includes 318, 319 +options HP340 +options HP350 +options HP360 +options HP370 +options HP375 # includes 345, 400t, 400s +options HP380 # includes 425t, 425s, 433s + +# Need to set locally +maxusers 32 + +# Standard system options +options COMPAT_43 # compatibility with 4.3BSD interfaces +options COMPAT_44 # compatibility with 4.4BSD binaries +options COMPAT_09 # compatibility with NetBSD 0.9 +options COMPAT_10 # compatibility with NetBSD 1.0 +options COMPAT_11 # compatibility with NetBSD 1.1 +options COMPAT_12 # compatibility with NetBSD 1.2 +options SYSVSHM # System V-style shared memory +options SYSVSEM # System V-style semaphores +options SYSVMSG # System V-style message queues +options KTRACE # system call tracing support +options "NKMEMCLUSTERS=1024" # # 4K pages in kernel malloc pool + +# Filesystem options +options FIFO # POSIX fifo support (in all filesystems) +options FFS,QUOTA # fast filesystem with user and group quotas +options CD9660 # CD-ROM ISO-9660 filesystem +options NFSSERVER # Network filesystem server +options NFSCLIENT # Network filesystem client +options UNION # Union filesystem (req. for FDESC) +options KERNFS # kernel data-structure filesystem +options FDESC # user file descriptor filesystem +options PROCFS # /proc filesystem +options MFS # Memory-based filesystem + +# Networking options +options INET # Internet protocols +options GATEWAY # IP forwarding + larger mb_map +options MROUTING # Multicast routing +options TCP_COMPAT_42 # compatibility with 4.2BSD TCP/IP + +# Options for HP hardware +options FPSP # floating point interface for 68040 +options USELEDS # make the lights twinkle +options COMPAT_NOLABEL # defaults for unlabeled disks +#options PANICBUTTON # two fast s on HIL dump kernel +#options CONSCODE="9" # force console at this select code +options UK_KEYBOARD # include United Kingdom HIL keymap +options SE_KEYBOARD # include Swedish HIL keymap + +# This option enables a different copyin/copyout that uses page +# mapping for large copies. +#options MAPPEDCOPY # different copyin/copyout for large copies + +# +# HP-UX binary compatibility. +# NOTE: THIS IS STILL VERY EXPERIMENTAL. YOUR MILEAGE MAY VARY. +# +options COMPAT_HPUX # HP-UX binary compatibility + +options COMPAT_M68K4K # compat. with NetBSD/m68k4k binaries + +# Debugging options +options DIAGNOSTIC # Extra kernel sanity checks +#options DEBUG # Enable misc. kernel debugging code +options DDB # Kernel Dynamic Debugger + +config netbsd swap generic + +mainbus0 at root # root "bus" + +intio0 at mainbus0 # internal i/o space +dio0 at mainbus0 # DIO/DIO-II bus + +# Davinci framebuffer +dvbox* at intio? +dvbox* at dio? scode ? + +# Gatorbox framebuffer +gbox* at intio? +gbox* at dio? scode ? + +# Hyperion framebuffer +hyper* at dio? scode ? + +# Renaissance framebuffer +rbox* at intio? +rbox* at dio? scode ? + +# Topcat/catseye framebuffers +topcat* at intio? +topcat* at dio? scode ? + +# Framebuffer abstraction +grf* at dvbox? +grf* at gbox? +grf* at hyper? +grf* at rbox? +grf* at topcat? + +# Internal Terminal Emulator +ite* at grf? + +dca0 at dio? scode 9 flags 1 # DCA serial interfaces +dca* at dio? scode ? + +dcm* at dio? scode ? flags 0xe # DCM 4- or 8-port serial interfaces + +le* at dio? scode ? # LANCE ethernet interfaces + +#nhpib0 at dio? scode 7 # slow internal HP-IB +#nhpib* at dio? scode ? + +#fhpib* at dio? scode ? # `fast' HP-IB + +#hpibbus* at nhpib? +#hpibbus* at fhpib? + +#rd* at hpibbus? slave ? punit ? # HP-IB disks +#ct* at hpibbus? slave ? punit ? # HP-IB cartridge tapes +#mt* at hpibbus? slave ? punit ? # HP-IB 9-track tape +#ppi0 at hpibbus0 slave 5 punit 0 # HP-IB plotter + +#oscsi* at dio? scode ? # Old HP SCSI + +#sd* at oscsi? target ? lun ? # SCSI disks +#st* at oscsi? target ? lun ? # SCSI tapes +#ac* at oscsi? target ? lun ? # SCSI changers + +pseudo-device pty 64 # pseudo ptys +pseudo-device sl 4 # SLIP network interfaces +pseudo-device ppp 4 # PPP network interfaces +pseudo-device bpfilter 16 # Berkeley packet filter +pseudo-device vnd 4 # vnode pseudo-disks +pseudo-device ccd 4 # concatenated disk devices +pseudo-device loop # loopback network interface diff --git a/sys/arch/hp300/conf/files.hp300 b/sys/arch/hp300/conf/files.hp300 new file mode 100644 index 00000000000..0c00099075e --- /dev/null +++ b/sys/arch/hp300/conf/files.hp300 @@ -0,0 +1,186 @@ +# $OpenBSD: files.hp300,v 1.1 1997/01/12 15:12:15 downsj Exp $ +# $NetBSD: files.hp300,v 1.20 1996/12/17 08:40:57 thorpej Exp $ +# +# hp300-specific configuration info + +# maxpartitions must be the first item in files.${ARCH} +maxpartitions 8 + +maxusers 2 8 64 + +# NOTE! The order of these lines is significant! Don't change them +# unless you absolutely know what you're doing! + +# Frame buffer attribute +define grfdev { } + +# Frame buffer devices +device dvbox: grfdev +file arch/hp300/dev/grf_dv.c dvbox needs-flag + +device gbox: grfdev +file arch/hp300/dev/grf_gb.c gbox needs-flag + +device hyper: grfdev +file arch/hp300/dev/grf_hy.c hyper needs-flag + +device rbox: grfdev +file arch/hp300/dev/grf_rb.c rbox needs-flag + +device topcat: grfdev +file arch/hp300/dev/grf_tc.c topcat needs-flag + +# `grf' framebuffer abstraction +device grf { } +attach grf at grfdev +file arch/hp300/dev/grf.c grf needs-flag +file arch/hp300/dev/grf_subr.c grf + +# Internal Terminal Emulator +device ite +attach ite at grf +file arch/hp300/dev/ite.c ite needs-flag +file arch/hp300/dev/ite_subr.c ite + +# +# Mainbus +# + +device mainbus { } +attach mainbus at root + +# +# Internal i/o space +# + +device intio { } +attach intio at mainbus +file arch/hp300/dev/intio.c intio + +# Internal i/o framebuffer attachments +attach dvbox at intio with dvbox_intio +attach gbox at intio with gbox_intio +attach rbox at intio with rbox_intio +attach topcat at intio with topcat_intio + +# +# DIO bus +# + +device dio { scode = -1 } +attach dio at mainbus +file arch/hp300/dev/dio.c dio + +# DIO framebuffer attachments +attach dvbox at dio with dvbox_dio +attach gbox at dio with gbox_dio +attach hyper at dio with hyper_dio +attach rbox at dio with rbox_dio +attach topcat at dio with topcat_dio + +# DCA serial interface +device dca: tty +attach dca at dio +file arch/hp300/dev/dca.c dca needs-flag + +# DCM serial interface +device dcm: tty +attach dcm at dio +file arch/hp300/dev/dcm.c dcm needs-flag + +# LANCE ethernet +attach le at dio +file arch/hp300/dev/if_le.c le + +# HP-IB interfaces +define hpibdev { } + +device nhpib: hpibdev +attach nhpib at dio +file arch/hp300/dev/nhpib.c nhpib + +device fhpib: hpibdev +attach fhpib at dio +file arch/hp300/dev/fhpib.c fhpib + +# HP-IB bus layer +device hpibbus { slave = -1, punit = -1 } +attach hpibbus at hpibdev +file arch/hp300/dev/hpib.c hpibbus + +# HP-IB devices +device ct: tape +attach ct at hpibbus +file arch/hp300/dev/ct.c ct needs-flag + +device mt: tape +attach mt at hpibbus +file arch/hp300/dev/mt.c mt needs-flag + +device rd: disk +attach rd at hpibbus +file arch/hp300/dev/rd.c rd needs-flag +file arch/hp300/dev/rd_compat.c rd # XXX + +device ppi +attach ppi at hpibbus +file arch/hp300/dev/ppi.c ppi needs-flag + +# Old HP SCSI layer +device oscsi { target = -1, lun = -1 } +attach oscsi at dio +file arch/hp300/dev/scsi.c scsi + +# Old HP SCSI devices +device sd: disk +attach sd at oscsi +file arch/hp300/dev/sd.c sd needs-flag +file arch/hp300/dev/sd_compat.c sd # XXX + +device st: tape +attach st at oscsi +file arch/hp300/dev/st.c st needs-flag + +device ac +attach ac at oscsi +file arch/hp300/dev/ac.c ac needs-flag + +# Human (Hilarious) Interface Loop +# XXX should be a real device +file arch/hp300/dev/hil.c +file arch/hp300/dev/hil_keymaps.c + +# +# Non-device files +# + +file arch/hp300/hp300/autoconf.c +file arch/hp300/hp300/clock.c +file arch/hp300/hp300/conf.c +file arch/hp300/hp300/db_memrw.c ddb | kgdb +file arch/hp300/hp300/dkbad.c +file arch/hp300/hp300/kgdb_glue.c kgdb compile-with "${NORMAL_C} -fno-defer-pop" +file arch/hp300/hp300/kgdb_stub.c kgdb +file arch/hp300/hp300/machdep.c +file arch/hp300/hp300/isr.c +file arch/hp300/hp300/mem.c +file arch/hp300/hp300/pmap.c +file arch/hp300/hp300/pmap_bootstrap.c +file arch/hp300/hp300/sys_machdep.c +file arch/hp300/hp300/trap.c +file arch/hp300/hp300/vm_machdep.c +file arch/hp300/hp300/disksubr.c +file arch/hp300/dev/dma.c + +file arch/m68k/m68k/copy.s + +file dev/cons.c +file dev/cninit.c + +file kludge_for_in_proto.c hy needs-flag + +# +# HP-UX binary compatibility +# +include "compat/hpux/files.hpux" +file arch/hp300/hp300/hpux_machdep.c compat_hpux diff --git a/sys/arch/hp300/conf/files.hp300.oldconf b/sys/arch/hp300/conf/files.hp300.oldconf index e2d1f5f1a27..78e592c6f3e 100644 --- a/sys/arch/hp300/conf/files.hp300.oldconf +++ b/sys/arch/hp300/conf/files.hp300.oldconf @@ -1,12 +1,14 @@ -# $NetBSD: files.hp300.oldconf,v 1.26.4.1 1996/06/10 06:51:58 thorpej Exp $ +# $OpenBSD: files.hp300.oldconf,v 1.6 1997/01/12 15:12:15 downsj Exp $ +# $NetBSD: files.hp300.oldconf,v 1.30 1997/01/05 04:41:48 thorpej Exp $ # arch/hp300/hp300/autoconf.c standard arch/hp300/hp300/clock.c standard arch/hp300/hp300/conf.c standard +arch/hp300/hp300/db_memrw.c optional ddb arch/hp300/hp300/dkbad.c standard arch/hp300/hp300/kgdb_glue.c optional kgdb compile-with "${NORMAL_C} -fno-defer-pop" arch/hp300/hp300/kgdb_stub.c optional kgdb -arch/hp300/hp300/machdep.c standard config-dependent +arch/hp300/hp300/machdep.c standard arch/hp300/hp300/isr.c standard arch/hp300/hp300/mem.c standard arch/hp300/hp300/pmap.c standard @@ -15,6 +17,7 @@ arch/hp300/hp300/sys_machdep.c standard arch/hp300/hp300/trap.c standard arch/hp300/hp300/vm_machdep.c standard arch/hp300/hp300/disksubr.c standard +arch/hp300/dev/dio.c standard arch/hp300/dev/grf_conf.c optional grf arch/hp300/dev/grf_dv.c optional grf needs-count # XXX? d-d? arch/hp300/dev/grf_gb.c optional grf needs-count # XXX? d-d? @@ -46,7 +49,6 @@ arch/hp300/dev/hil_keymaps.c standard arch/hp300/dev/ite.c optional ite needs-count # XXX? d-d? arch/hp300/dev/ite_subr.c optional ite needs-count # XXX? d-d? arch/m68k/m68k/copy.s standard -arch/m68k/m68k/db_memrw.c optional ddb dev/cons.c standard dev/cninit.c standard thisisfor_in_proto.c optional hy diff --git a/sys/arch/hp300/conf/std.hp300 b/sys/arch/hp300/conf/std.hp300 new file mode 100644 index 00000000000..144419845ef --- /dev/null +++ b/sys/arch/hp300/conf/std.hp300 @@ -0,0 +1,17 @@ +# $OpenBSD: std.hp300,v 1.1 1997/01/12 15:12:16 downsj Exp $ +# $NetBSD: std.hp300,v 1.1 1996/12/17 08:40:58 thorpej Exp $ +# +# Options/devices that all hp300s should have +# + +machine hp300 m68k + +# XXX new config glue, for now +options NEWCONFIG + +options SWAPPAGER # swap pager (anonymous and swap space) +options VNODEPAGER # vnode pager (mapped files) +options DEVPAGER # device pager (mapped devices) + +options EXEC_AOUT # support for exec'ing a.out +options EXEC_SCRIPT # support for #! scripts diff --git a/sys/arch/hp300/dev/Makefile b/sys/arch/hp300/dev/Makefile new file mode 100644 index 00000000000..9d0c418ba17 --- /dev/null +++ b/sys/arch/hp300/dev/Makefile @@ -0,0 +1,8 @@ +# $OpenBSD: Makefile,v 1.1 1997/01/12 15:12:17 downsj Exp $ +# $NetBSD: Makefile,v 1.1 1996/12/17 08:40:59 thorpej Exp $ + +AWK= awk + +diodevs.h diodevs_data.h: diodevs devlist2h.awk + /bin/rm -f diodevs.h diodevs_data.h + ${AWK} -f devlist2h.awk diodevs diff --git a/sys/arch/hp300/dev/ac.c b/sys/arch/hp300/dev/ac.c index c90eb0875ae..1e6c54544cc 100644 --- a/sys/arch/hp300/dev/ac.c +++ b/sys/arch/hp300/dev/ac.c @@ -1,4 +1,5 @@ -/* $NetBSD: ac.c,v 1.4 1996/02/14 02:43:54 thorpej Exp $ */ +/* $OpenBSD: ac.c,v 1.4 1997/01/12 15:12:17 downsj Exp $ +/* $NetBSD: ac.c,v 1.6 1996/10/13 03:14:05 christos Exp $ */ /* * Copyright (c) 1991 University of Utah. diff --git a/sys/arch/hp300/dev/acioctl.h b/sys/arch/hp300/dev/acioctl.h index 1d9544e595c..1c09209f210 100644 --- a/sys/arch/hp300/dev/acioctl.h +++ b/sys/arch/hp300/dev/acioctl.h @@ -1,3 +1,4 @@ +/* $OpenBSD: acioctl.h,v 1.2 1997/01/12 15:12:18 downsj Exp $ */ /* $NetBSD: acioctl.h,v 1.2 1994/10/26 07:23:25 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/acvar.h b/sys/arch/hp300/dev/acvar.h index 8ed78882806..e3dac326867 100644 --- a/sys/arch/hp300/dev/acvar.h +++ b/sys/arch/hp300/dev/acvar.h @@ -1,3 +1,4 @@ +/* $OpenBSD: acvar.h,v 1.2 1997/01/12 15:12:19 downsj Exp $ */ /* $NetBSD: acvar.h,v 1.2 1994/10/26 07:23:27 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/ct.c b/sys/arch/hp300/dev/ct.c index 374a66222af..596375523f8 100644 --- a/sys/arch/hp300/dev/ct.c +++ b/sys/arch/hp300/dev/ct.c @@ -1,4 +1,5 @@ -/* $NetBSD: ct.c,v 1.15 1996/02/14 02:44:02 thorpej Exp $ */ +/* $OpenBSD: ct.c,v 1.5 1997/01/12 15:12:19 downsj Exp $ */ +/* $NetBSD: ct.c,v 1.18 1996/10/14 07:14:11 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -167,6 +168,9 @@ ctattach(hd) sc->sc_dq.dq_slave = hd->hp_slave; sc->sc_dq.dq_driver = &ctdriver; sc->sc_flags |= CTF_ALIVE; + + /* XXX Set device class. */ + hd->hp_dev.dv_class = DV_TAPE; } int diff --git a/sys/arch/hp300/dev/ctreg.h b/sys/arch/hp300/dev/ctreg.h index 42b93735620..2ba97fb73b6 100644 --- a/sys/arch/hp300/dev/ctreg.h +++ b/sys/arch/hp300/dev/ctreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: ctreg.h,v 1.4 1997/01/12 15:12:20 downsj Exp $ */ /* $NetBSD: ctreg.h,v 1.6 1996/02/09 18:00:35 scottr Exp $ */ /* diff --git a/sys/arch/hp300/dev/dca.c b/sys/arch/hp300/dev/dca.c index f81f6a60d58..6d13a06bef3 100644 --- a/sys/arch/hp300/dev/dca.c +++ b/sys/arch/hp300/dev/dca.c @@ -1,4 +1,5 @@ -/* $NetBSD: dca.c,v 1.23.4.1 1996/06/06 15:39:09 thorpej Exp $ */ +/* $OpenBSD: dca.c,v 1.6 1997/01/12 15:12:21 downsj Exp $ */ +/* $NetBSD: dca.c,v 1.31 1996/12/17 08:41:00 thorpej Exp $ */ /* * Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved. @@ -36,9 +37,6 @@ * @(#)dca.c 8.2 (Berkeley) 1/12/94 */ -#include "dca.h" -#if NDCA > 0 - /* * Driver for the 98626/98644/internal serial interface on hp300/hp400, * based on the National Semiconductor INS8250/NS16550AF/WD16C552 UARTs. @@ -61,24 +59,28 @@ #include #include #include +#include #include #include #include +#ifndef NEWCONFIG #include +#endif + +#include +#include +#include #include #include -int dcamatch(); -void dcaattach(); -struct driver dcadriver = { - dcamatch, dcaattach, "dca", -}; - struct dca_softc { + struct device sc_dev; /* generic device glue */ +#ifndef NEWCONFIG struct hp_device *sc_hd; /* device info */ +#endif struct dcadevice *sc_dca; /* pointer to hardware */ struct tty *sc_tty; /* our tty instance */ int sc_oflows; /* overflow counter */ @@ -92,12 +94,33 @@ struct dca_softc { #define DCA_HASFIFO 0x0004 /* indicates unit has FIFO */ #define DCA_ISCONSOLE 0x0008 /* indicates unit is console */ -} dca_softc[NDCA]; +}; + +#ifdef NEWCONFIG +int dcamatch __P((struct device *, struct cfdata *, void *)); +void dcaattach __P((struct device *, struct device *, void *)); + +struct cfattach dca_ca = { + sizeof(struct dca_softc), dcamatch, dcaattach +}; + +struct cfdriver dca_cd = { + NULL, "dca", DV_TTY +}; +#else /* ! NEWCONFIG */ +int dcamatch(); +void dcaattach(); +struct driver dcadriver = { + dcamatch, dcaattach, "dca", +}; + +#include "dca.h" +struct dca_softc dca_softc[NDCA]; +#endif /* NEWCONFIG */ void dcastart(); int dcaparam(); int dcaintr __P((void *)); -int ndca = NDCA; int dcadefaultrate = TTYDEF_SPEED; int dcamajor; @@ -146,6 +169,26 @@ long dcamintcount[16]; void dcainit __P((struct dcadevice *, int)); +#ifdef NEWCONFIG +int +dcamatch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + switch (da->da_id) { + case DIO_DEVICE_ID_DCA0: + case DIO_DEVICE_ID_DCA0REM: + case DIO_DEVICE_ID_DCA1: + case DIO_DEVICE_ID_DCA1REM: + return (1); + } + + return (0); +} +#else /* ! NEWCONFIG */ int dcamatch(hd) register struct hp_device *hd; @@ -164,7 +207,21 @@ dcamatch(hd) return (1); } +#endif /* NEWCONFIG */ +#ifdef NEWCONFIG +void +dcaattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct dca_softc *sc = (struct dca_softc *)self; + struct dio_attach_args *da = aux; + struct dcadevice *dca; + int unit = self->dv_unit; + int scode = da->da_scode; + int ipl; +#else /* ! NEWCONFIG */ void dcaattach(hd) register struct hp_device *hd; @@ -172,8 +229,12 @@ dcaattach(hd) int unit = hd->hp_unit; struct dcadevice *dca = (struct dcadevice *)hd->hp_addr; struct dca_softc *sc = &dca_softc[unit]; + int scode = hd->hp_args->hw_sc; + int ipl = hd->hp_ipl; +#endif /* NEWCONFIG */ - if (hd->hp_args->hw_sc == conscode) { + if (scode == conscode) { + dca = (struct dcadevice *)conaddr; sc->sc_flags |= DCA_ISCONSOLE; DELAY(100000); @@ -182,8 +243,29 @@ dcaattach(hd) * the console probe, so we have to fixup cn_dev here. */ cn_tab->cn_dev = makedev(dcamajor, unit); + } else { +#ifdef NEWCONFIG + dca = (struct dcadevice *)iomap(dio_scodetopa(da->da_scode), + da->da_size); + if (dca == NULL) { + printf("\n%s: can't map registers\n", + sc->sc_dev.dv_xname); + return; + } +#endif /* NEWCONFIG */ } + sc->sc_dca = dca; + +#ifdef NEWCONFIG + ipl = DIO_IPL(dca); + printf(" ipl %d", ipl); +#else /* ! NEWCONFIG */ + /* XXX Set the device class. */ + hd->hp_dev.dv_class = DV_TTY; + bcopy(&hd->hp_dev, &sc->sc_dev, sizeof(struct device)); +#endif /* NEWCONFIG */ + dca->dca_reset = 0xFF; DELAY(100); @@ -193,14 +275,16 @@ dcaattach(hd) if ((dca->dca_iir & IIR_FIFO_MASK) == IIR_FIFO_MASK) sc->sc_flags |= DCA_HASFIFO; - sc->sc_dca = dca; - /* Establish interrupt handler. */ - isrlink(dcaintr, sc, hd->hp_ipl, + (void) isrlink(dcaintr, sc, ipl, (sc->sc_flags & DCA_HASFIFO) ? ISRPRI_TTY : ISRPRI_TTYNOBUF); sc->sc_flags |= DCA_ACTIVE; +#ifdef NEWCONFIG + if (self->dv_cfdata->cf_flags) +#else if (hd->hp_flags) +#endif sc->sc_flags |= DCA_SOFTCAR; /* Enable interrupts. */ @@ -234,11 +318,11 @@ dcaattach(hd) * Print prefix of device name, * let kgdb_connect print the rest. */ - printf("%s: ", sc->sc_hd->hp_xname); + printf("%s: ", sc->sc_dev.dv_xname); kgdb_connect(1); } else printf("%s: kgdb enabled\n", - sc->sc_hd->hp_xname); + sc->sc_dev.dv_xname); } } #endif @@ -258,10 +342,16 @@ dcaopen(dev, flag, mode, p) u_char code; int s, error = 0; +#ifdef NEWCONFIG + if (unit >= dca_cd.cd_ndevs || + (sc = dca_cd.cd_devs[unit]) == NULL) + return (ENXIO); +#else if (unit >= NDCA) return (ENXIO); - sc = &dca_softc[unit]; +#endif /* NEWCONFIG */ + if ((sc->sc_flags & DCA_ACTIVE) == 0) return (ENXIO); @@ -355,7 +445,12 @@ dcaclose(dev, flag, mode, p) unit = DCAUNIT(dev); +#ifdef NEWCONFIG + sc = dca_cd.cd_devs[unit]; +#else sc = &dca_softc[unit]; +#endif + dca = sc->sc_dca; tp = sc->sc_tty; (*linesw[tp->t_line].l_close)(tp, flag); @@ -390,10 +485,17 @@ dcaread(dev, uio, flag) int flag; { int unit = DCAUNIT(dev); - struct dca_softc *sc = &dca_softc[unit]; - struct tty *tp = sc->sc_tty; + struct dca_softc *sc; + struct tty *tp; int error, of; + +#ifdef NEWCONFIG + sc = dca_cd.cd_devs[unit]; +#else + sc = &dca_softc[unit]; +#endif + tp = sc->sc_tty; of = sc->sc_oflows; error = (*linesw[tp->t_line].l_read)(tp, uio, flag); /* @@ -401,7 +503,7 @@ dcaread(dev, uio, flag) * at interrupt time just exacerbates the problem. */ if (sc->sc_oflows != of) - log(LOG_WARNING, "%s: silo overflow\n", sc->sc_hd->hp_xname); + log(LOG_WARNING, "%s: silo overflow\n", sc->sc_dev.dv_xname); return (error); } @@ -411,7 +513,12 @@ dcawrite(dev, uio, flag) struct uio *uio; int flag; { +#ifdef NEWCONFIG + struct dca_softc *sc = dca_cd.cd_devs[DCAUNIT(dev)]; + struct tty *tp = sc->sc_tty; +#else struct tty *tp = dca_softc[DCAUNIT(dev)].sc_tty; +#endif return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); } @@ -420,8 +527,13 @@ struct tty * dcatty(dev) dev_t dev; { +#ifdef NEWCONFIG + struct dca_softc *sc = dca_cd.cd_devs[DCAUNIT(dev)]; +#else + struct dca_softc *sc = &dca_softc[DCAUNIT(dev)]; +#endif - return (dca_softc[DCAUNIT(dev)].sc_tty); + return (sc->sc_tty); } int @@ -429,7 +541,7 @@ dcaintr(arg) void *arg; { struct dca_softc *sc = arg; - int unit = sc->sc_hd->hp_unit; + int unit = sc->sc_dev.dv_unit; register struct dcadevice *dca = sc->sc_dca; register struct tty *tp = sc->sc_tty; register u_char code; @@ -512,7 +624,7 @@ dcaintr(arg) if (code & IIR_NOPEND) return (1); log(LOG_WARNING, "%s: weird interrupt: 0x%x\n", - sc->sc_hd->hp_xname, code); + sc->sc_dev.dv_xname, code); /* fall through */ case IIR_MLSC: dcamint(sc); @@ -591,7 +703,11 @@ dcaioctl(dev, cmd, data, flag, p) struct proc *p; { int unit = DCAUNIT(dev); +#ifdef NEWCONFIG + struct dca_softc *sc = dca_cd.cd_devs[unit]; +#else struct dca_softc *sc = &dca_softc[unit]; +#endif struct tty *tp = sc->sc_tty; struct dcadevice *dca = sc->sc_dca; int error; @@ -680,7 +796,11 @@ dcaparam(tp, t) register struct termios *t; { int unit = DCAUNIT(tp->t_dev); +#ifdef NEWCONFIG + struct dca_softc *sc = dca_cd.cd_devs[unit]; +#else struct dca_softc *sc = &dca_softc[unit]; +#endif struct dcadevice *dca = sc->sc_dca; int cfcr, cflag = t->c_cflag; int ospeed = ttspeedtab(t->c_ospeed, dcaspeedtab); @@ -756,7 +876,11 @@ dcastart(tp) register struct tty *tp; { int s, c, unit = DCAUNIT(tp->t_dev); +#ifdef NEWCONFIG + struct dca_softc *sc = dca_cd.cd_devs[unit]; +#else struct dca_softc *sc = &dca_softc[unit]; +#endif struct dcadevice *dca = sc->sc_dca; s = spltty(); @@ -795,7 +919,7 @@ out: * Stop output on a line. */ /*ARGSUSED*/ -int +void dcastop(tp, flag) register struct tty *tp; int flag; @@ -871,8 +995,9 @@ dcainit(dca, rate) dca->dca_ier = rate >> 8; dca->dca_cfcr = CFCR_8BITS; dca->dca_ier = IER_ERXRDY | IER_ETXRDY; - dca->dca_fifo = FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_14; - dca->dca_mcr |= MCR_IEN; + dca->dca_fifo = + FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_1; + dca->dca_mcr = MCR_DTR | MCR_RTS; DELAY(100); stat = dca->dca_iir; splx(s); @@ -1030,4 +1155,3 @@ dcacnputc(dev, c) stat = dca_cn->dca_iir; splx(s); } -#endif /* NDCA > 0 */ diff --git a/sys/arch/hp300/dev/dcareg.h b/sys/arch/hp300/dev/dcareg.h index b2ee8e5cef6..4cf68db4002 100644 --- a/sys/arch/hp300/dev/dcareg.h +++ b/sys/arch/hp300/dev/dcareg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: dcareg.h,v 1.4 1997/01/12 15:12:21 downsj Exp $ */ /* $NetBSD: dcareg.h,v 1.6 1996/02/24 00:55:02 thorpej Exp $ */ /* diff --git a/sys/arch/hp300/dev/dcm.c b/sys/arch/hp300/dev/dcm.c index a124effeb8f..5f211ba768b 100644 --- a/sys/arch/hp300/dev/dcm.c +++ b/sys/arch/hp300/dev/dcm.c @@ -1,4 +1,5 @@ -/* $NetBSD: dcm.c,v 1.27.4.1 1996/06/06 15:39:11 thorpej Exp $ */ +/* $OpenBSD: dcm.c,v 1.6 1997/01/12 15:12:22 downsj Exp $ */ +/* $NetBSD: dcm.c,v 1.34 1996/12/17 08:41:01 thorpej Exp $ */ /* * Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved. @@ -49,8 +50,6 @@ * Test console support. */ -#include "dcm.h" -#if NDCM > 0 /* * 98642/MUX */ @@ -65,13 +64,20 @@ #include #include #include +#include #include #include #include +#ifndef NEWCONFIG #include +#endif + +#include +#include +#include #include #include @@ -79,12 +85,6 @@ #define DEFAULT_BAUD_RATE 9600 #endif -int dcmmatch(), dcmparam(); -void dcmattach(), dcmstart(); -struct driver dcmdriver = { - dcmmatch, dcmattach, "dcm", -}; - struct speedtab dcmspeedtab[] = { 0, BR_0, 50, BR_50, @@ -223,7 +223,10 @@ static char iconv[16] = { #define NDCMPORT 4 struct dcm_softc { + struct device sc_dev; /* generic device glue */ +#ifndef NEWCONFIG struct hp_device *sc_hd; /* device info */ +#endif struct dcmdevice *sc_dcm; /* pointer to hardware */ struct tty *sc_tty[NDCMPORT]; /* our tty instances */ struct modemreg *sc_modem[NDCMPORT]; /* modem control */ @@ -249,71 +252,98 @@ struct dcm_softc { #ifdef DCMSTATS struct dcmstats sc_stats; /* metrics gathering */ #endif -} dcm_softc[NDCM]; +}; + +#ifdef NEWCONFIG +int dcmmatch __P((struct device *, struct cfdata *, void *)); +void dcmattach __P((struct device *, struct device *, void *)); + +struct cfattach dcm_ca = { + sizeof(struct dcm_softc), dcmmatch, dcmattach +}; + +struct cfdriver dcm_cd = { + NULL, "dcm", DV_TTY +}; +#else /* ! NEWCONFIG */ +int dcmmatch(); +void dcmattach(); + +struct driver dcmdriver = { + dcmmatch, dcmattach, "dcm", +}; + +#include "dcm.h" +struct dcm_softc dcm_softc[NDCM]; +#endif /* NEWCONFIG */ + +int dcmparam(); +void dcmstart(); void dcminit __P((struct dcmdevice *, int, int)); int dcmintr __P((void *)); +int dcmselftest __P((struct dcm_softc *)); + +#ifdef NEWCONFIG +int +dcmmatch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + switch (da->da_id) { + case DIO_DEVICE_ID_DCM: + case DIO_DEVICE_ID_DCMREM: + return (1); + } + + return (0); +} +#else /* ! NEWCONFIG */ int dcmmatch(hd) register struct hp_device *hd; { struct dcm_softc *sc = &dcm_softc[hd->hp_unit]; - struct dcmdevice *dcm; - int i, timo = 0; - int s, brd, mbits; + struct dcmdevice *dcm = (struct dcmdevice *)hd->hp_addr; - dcm = (struct dcmdevice *)hd->hp_addr; if ((dcm->dcm_rsid & 0x1f) != DCMID) return (0); - brd = hd->hp_unit; - sc->sc_hd = hd; hd->hp_ipl = DCMIPL(dcm->dcm_ic); - - /* - * Empirically derived self-test magic - */ - s = spltty(); - dcm->dcm_rsid = DCMRS; - DELAY(50000); /* 5000 is not long enough */ - dcm->dcm_rsid = 0; - dcm->dcm_ic = IC_IE; - dcm->dcm_cr = CR_SELFT; - while ((dcm->dcm_ic & IC_IR) == 0) - if (++timo == 20000) - return (0); - DELAY(50000); /* XXX why is this needed ???? */ - while ((dcm->dcm_iir & IIR_SELFT) == 0) - if (++timo == 400000) - return (0); - DELAY(50000); /* XXX why is this needed ???? */ - if (dcm->dcm_stcon != ST_OK) { - if (hd->hp_args->hw_sc != conscode) - printf("dcm%d: self test failed: %x\n", - brd, dcm->dcm_stcon); - return (0); - } - dcm->dcm_ic = IC_ID; - splx(s); - - return (1); } +#endif /* NEWCONFIG */ +#ifdef NEWCONFIG +void +dcmattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct dcm_softc *sc = (struct dcm_softc *)self; + struct dio_attach_args *da = aux; + struct dcmdevice *dcm; + int brd = self->dv_unit; + int scode = da->da_scode; + int i, mbits, ipl; +#else /* ! NEWCONFIG */ void dcmattach(hd) register struct hp_device *hd; { struct dcm_softc *sc = &dcm_softc[hd->hp_unit]; - struct dcmdevice *dcm; - int i, timo = 0; - int s, brd, mbits; - - dcm = sc->sc_dcm = (struct dcmdevice *)hd->hp_addr; - - brd = hd->hp_unit; - if (hd->hp_args->hw_sc == conscode) { + struct dcmdevice *dcm = (struct dcmdevice *)hd->hp_addr; + int brd = hd->hp_unit; + int scode = hd->hp_args->hw_sc; + int i, mbits, ipl = hd->hp_ipl; +#endif /* NEWCONFIG */ + + if (scode == conscode) { + dcm = (struct dcmdevice *)conaddr; sc->sc_flags |= DCM_ISCONSOLE; /* @@ -322,17 +352,48 @@ dcmattach(hd) * Note that we always assume port 1 on the board. */ cn_tab->cn_dev = makedev(dcmmajor, (brd << 2) | DCMCONSPORT); + } else { +#ifdef NEWCONFIG + dcm = (struct dcmdevice *)iomap(dio_scodetopa(da->da_scode), + da->da_size); + if (dcm == NULL) { + printf("\n%s: can't map registers\n", + sc->sc_dev.dv_xname); + return; + } +#endif + } + + sc->sc_dcm = dcm; + +#ifdef NEWCONFIG + ipl = DIO_IPL(dcm); + printf(" ipl %d", ipl); +#else /* ! NEWCONFIG */ + /* XXX Set the device class. */ + hd->hp_dev.dv_class = DV_TTY; + bcopy(&hd->hp_dev, &sc->sc_dev, sizeof(struct device)); +#endif /* NEWCONFIG */ + + if (dcmselftest(sc)) { + printf("\n%s: self-test failed\n", sc->sc_dev.dv_xname); + return; } /* Extract configuration info from flags. */ +#ifdef NEWCONFIG + sc->sc_softCAR = self->dv_cfdata->cf_flags & DCM_SOFTCAR; + sc->sc_flags = self->dv_cfdata->cf_flags & DCM_FLAGMASK; +#else sc->sc_softCAR = (hd->hp_flags & DCM_SOFTCAR); sc->sc_flags = (hd->hp_flags & DCM_FLAGMASK); +#endif /* NEWCONFIG */ /* Mark our unit as configured. */ sc->sc_flags |= DCM_ACTIVE; /* Establish the interrupt handler. */ - isrlink(dcmintr, sc, hd->hp_ipl, ISRPRI_TTY); + (void) isrlink(dcmintr, sc, ipl, ISRPRI_TTY); if (dcmistype == DIS_TIMER) dcmsetischeme(brd, DIS_RESET|DIS_TIMER); @@ -381,18 +442,18 @@ dcmattach(hd) dcminit(dcm, DCMPORT(DCMUNIT(kgdb_dev)), kgdb_rate); if (kgdb_debug_init) { - printf("%s port %d: ", sc->sc_hd->hp_xname, + printf("%s port %d: ", sc->sc_dev.dv_xname, DCMPORT(DCMUNIT(kgdb_dev))); kgdb_connect(1); } else printf("%s port %d: kgdb enabled\n", - sc->sc_hd->hp_xname, + sc->sc_dev.dv_xname, DCMPORT(DCMUNIT(kgdb_dev))); } /* end could be replaced */ -#endif +#endif /* KGDB_CHEAT */ } -#endif +#endif /* KGDB */ } /* ARGSUSED */ @@ -411,10 +472,16 @@ dcmopen(dev, flag, mode, p) brd = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + if (brd >= dcm_cd.cd_ndevs || port >= NDCMPORT || + (sc = dcm_cd.cd_devs[brd]) == NULL) + return (ENXIO); +#else /* ! NEWCONFIG */ if ((brd >= NDCM) || (port >= NDCMPORT)) return (ENXIO); - sc = &dcm_softc[brd]; +#endif /* NEWCONFIG */ + if ((sc->sc_flags & DCM_ACTIVE) == 0) return (ENXIO); @@ -468,7 +535,7 @@ dcmopen(dev, flag, mode, p) #ifdef DEBUG if (dcmdebug & DDB_MODEM) printf("%s: dcmopen port %d softcarr %c\n", - sc->sc_hd->hp_xname, port, + sc->sc_dev.dv_xname, port, (tp->t_state & TS_CARR_ON) ? '1' : '0'); #endif @@ -490,7 +557,7 @@ dcmopen(dev, flag, mode, p) #ifdef DEBUG if (dcmdebug & DDB_OPENCLOSE) printf("%s port %d: dcmopen: st %x fl %x\n", - sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags); + sc->sc_dev.dv_xname, port, tp->t_state, tp->t_flags); #endif if (error == 0) error = (*linesw[tp->t_line].l_open)(dev, tp); @@ -513,7 +580,11 @@ dcmclose(dev, flag, mode, p) board = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif tp = sc->sc_tty[port]; (*linesw[tp->t_line].l_close)(tp, flag); @@ -526,7 +597,7 @@ dcmclose(dev, flag, mode, p) #ifdef DEBUG if (dcmdebug & DDB_OPENCLOSE) printf("%s port %d: dcmclose: st %x fl %x\n", - sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags); + sc->sc_dev.dv_xname, port, tp->t_state, tp->t_flags); #endif splx(s); ttyclose(tp); @@ -552,7 +623,11 @@ dcmread(dev, uio, flag) board = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif tp = sc->sc_tty[port]; return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); @@ -572,7 +647,11 @@ dcmwrite(dev, uio, flag) board = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif tp = sc->sc_tty[port]; return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); @@ -589,7 +668,11 @@ dcmtty(dev) board = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif return (sc->sc_tty[port]); } @@ -601,7 +684,7 @@ dcmintr(arg) struct dcm_softc *sc = arg; struct dcmdevice *dcm = sc->sc_dcm; struct dcmischeme *dis = &sc->sc_scheme; - int brd = sc->sc_hd->hp_unit; + int brd = sc->sc_dev.dv_unit; int code, i; int pcnd[4], mcode, mcnd[4]; @@ -631,7 +714,7 @@ dcmintr(arg) #ifdef DEBUG if (dcmdebug & DDB_INTR) { printf("%s: dcmintr: iir %x pc %x/%x/%x/%x ", - sc->sc_hd->hp_xname, code, pcnd[0], pcnd[1], + sc->sc_dev.dv_xname, code, pcnd[0], pcnd[1], pcnd[2], pcnd[3]); printf("miir %x mc %x/%x/%x/%x\n", mcode, mcnd[0], mcnd[1], mcnd[2], mcnd[3]); @@ -773,7 +856,7 @@ dcmreadbuf(sc, port) #ifdef DEBUG if (dcmdebug & DDB_INPUT) printf("%s port %d: dcmreadbuf: c%x('%c') s%x f%x h%x t%x\n", - sc->sc_hd->hp_xname, port, + sc->sc_dev.dv_xname, port, c&0xFF, c, stat&0xFF, tp->t_flags, head, pp->r_tail); #endif @@ -784,7 +867,7 @@ dcmreadbuf(sc, port) #ifdef DEBUG if (dcmdebug & (DDB_INPUT|DDB_SIOERR)) printf("%s port %d: dcmreadbuf: err: c%x('%c') s%x\n", - sc->sc_hd->hp_xname, port, + sc->sc_dev.dv_xname, port, stat, c&0xFF, c); #endif if (stat & (RD_BD | RD_FE)) @@ -794,11 +877,11 @@ dcmreadbuf(sc, port) else if (stat & RD_OVF) log(LOG_WARNING, "%s port %d: silo overflow\n", - sc->sc_hd->hp_xname, port); + sc->sc_dev.dv_xname, port); else if (stat & RD_OE) log(LOG_WARNING, "%s port %d: uart overflow\n", - sc->sc_hd->hp_xname, port); + sc->sc_dev.dv_xname, port); } (*linesw[tp->t_line].l_rint)(c, tp); } @@ -838,7 +921,7 @@ dcmmint(sc, port, mcnd) #ifdef DEBUG if (dcmdebug & DDB_MODEM) printf("%s port %d: dcmmint: mcnd %x mcndlast %x\n", - sc->sc_hd->hp_xname, port, mcnd, sc->sc_mcndlast[port]); + sc->sc_dev.dv_xname, port, mcnd, sc->sc_mcndlast[port]); #endif delta = mcnd ^ sc->sc_mcndlast[port]; sc->sc_mcndlast[port] = mcnd; @@ -882,14 +965,18 @@ dcmioctl(dev, cmd, data, flag, p) port = DCMPORT(unit); board = DCMBOARD(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif dcm = sc->sc_dcm; tp = sc->sc_tty[port]; #ifdef DEBUG if (dcmdebug & DDB_IOCTL) printf("%s port %d: dcmioctl: cmd %x data %x flag %x\n", - sc->sc_hd->hp_xname, port, cmd, *data, flag); + sc->sc_dev.dv_xname, port, cmd, *data, flag); #endif error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); if (error >= 0) @@ -997,7 +1084,11 @@ dcmparam(tp, t) board = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif dcm = sc->sc_dcm; /* check requested parameters */ @@ -1036,7 +1127,7 @@ dcmparam(tp, t) #ifdef DEBUG if (dcmdebug & DDB_PARAM) printf("%s port %d: dcmparam: cflag %x mode %x speed %d uperch %d\n", - sc->sc_hd->hp_xname, port, cflag, mode, tp->t_ospeed, + sc->sc_dev.dv_xname, port, cflag, mode, tp->t_ospeed, DCM_USPERCH(tp->t_ospeed)); #endif @@ -1084,7 +1175,11 @@ dcmstart(tp) board = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif dcm = sc->sc_dcm; s = spltty(); @@ -1094,7 +1189,7 @@ dcmstart(tp) #ifdef DEBUG if (dcmdebug & DDB_OUTPUT) printf("%s port %d: dcmstart: state %x flags %x outcc %d\n", - sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags, + sc->sc_dev.dv_xname, port, tp->t_state, tp->t_flags, tp->t_outq.c_cc); #endif if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) @@ -1176,7 +1271,7 @@ again: #ifdef DEBUG if (dcmdebug & DDB_INTR) printf("%s port %d: dcmstart(%d): head %x tail %x outqcc %d\n", - sc->sc_hd->hp_xname, port, head, tail, tp->t_outq.c_cc); + sc->sc_dev.dv_xname, port, head, tail, tp->t_outq.c_cc); #endif out: #ifdef DCMSTATS @@ -1192,7 +1287,7 @@ out: /* * Stop output on a line. */ -int +void dcmstop(tp, flag) register struct tty *tp; int flag; @@ -1222,13 +1317,18 @@ dcmmctl(dev, bits, how) unit = DCMUNIT(dev); brd = DCMBOARD(unit); port = DCMPORT(unit); + +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[brd]; +#else sc = &dcm_softc[brd]; +#endif dcm = sc->sc_dcm; #ifdef DEBUG if (dcmdebug & DDB_MODEM) printf("%s port %d: dcmmctl: bits 0x%x how %x\n", - sc->sc_hd->hp_xname, port, bits, how); + sc->sc_dev.dv_xname, port, bits, how); #endif s = spltty(); @@ -1272,7 +1372,11 @@ dcmmctl(dev, bits, how) dcmsetischeme(brd, flags) int brd, flags; { +#ifdef NEWCONFIG + struct dcm_softc *sc = dcm_cd.cd_devs[brd]; +#else struct dcm_softc *sc = &dcm_softc[brd]; +#endif struct dcmdevice *dcm = sc->sc_dcm; struct dcmischeme *dis = &sc->sc_scheme; int i; @@ -1282,11 +1386,11 @@ dcmsetischeme(brd, flags) #ifdef DEBUG if (dcmdebug & DDB_INTSCHM) printf("%s: dcmsetischeme(%d): cur %d, ints %d, chars %d\n", - sc->sc_hd->hp_xname, perchar, dis->dis_perchar, + sc->sc_dev.dv_xname, perchar, dis->dis_perchar, dis->dis_intr, dis->dis_char); if ((flags & DIS_RESET) == 0 && perchar == dis->dis_perchar) { printf("%s: dcmsetischeme: redundent request %d\n", - sc->sc_hd->hp_xname, perchar); + sc->sc_dev.dv_xname, perchar); return; } #endif @@ -1368,6 +1472,45 @@ dcminit(dcm, port, rate) splx(s); } +/* + * Empirically derived self-test magic + */ +int +dcmselftest(sc) + struct dcm_softc *sc; +{ + struct dcmdevice *dcm = sc->sc_dcm; + int i, timo = 0; + int s, brd, mbits; + + s = spltty(); + dcm->dcm_rsid = DCMRS; + DELAY(50000); /* 5000 is not long enough */ + dcm->dcm_rsid = 0; + dcm->dcm_ic = IC_IE; + dcm->dcm_cr = CR_SELFT; + while ((dcm->dcm_ic & IC_IR) == 0) + if (++timo == 20000) + return (1); + DELAY(50000); /* XXX why is this needed ???? */ + while ((dcm->dcm_iir & IIR_SELFT) == 0) + if (++timo == 400000) + return (1); + DELAY(50000); /* XXX why is this needed ???? */ + if (dcm->dcm_stcon != ST_OK) { +#if 0 + if (hd->hp_args->hw_sc != conscode) + printf("dcm%d: self test failed: %x\n", + brd, dcm->dcm_stcon); +#endif + return (1); + } + dcm->dcm_ic = IC_ID; + splx(s); + + return (0); +} + /* * Following are all routines needed for DCM to act as console */ @@ -1558,4 +1701,3 @@ dcmcnputc(dev, c) } splx(s); } -#endif /* NDCM > 0 */ diff --git a/sys/arch/hp300/dev/dcmreg.h b/sys/arch/hp300/dev/dcmreg.h index d27cfbcf264..4c7fe75e63d 100644 --- a/sys/arch/hp300/dev/dcmreg.h +++ b/sys/arch/hp300/dev/dcmreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: dcmreg.h,v 1.3 1997/01/12 15:12:23 downsj Exp $ */ /* $NetBSD: dcmreg.h,v 1.5 1996/02/24 00:55:05 thorpej Exp $ */ /* diff --git a/sys/arch/hp300/dev/device.h b/sys/arch/hp300/dev/device.h index ca2861e45df..32dee0bf48b 100644 --- a/sys/arch/hp300/dev/device.h +++ b/sys/arch/hp300/dev/device.h @@ -1,4 +1,5 @@ -/* $NetBSD: device.h,v 1.7 1996/02/14 02:44:14 thorpej Exp $ */ +/* $OpenBSD: device.h,v 1.4 1997/01/12 15:12:24 downsj Exp $ */ +/* $NetBSD: device.h,v 1.9 1996/10/20 23:47:40 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -35,6 +36,8 @@ * @(#)device.h 8.1 (Berkeley) 6/10/93 */ +#include + struct driver { int (*d_match)(); void (*d_attach)(); @@ -64,6 +67,7 @@ struct hp_ctlr { int hp_ipl; struct hp_hw *hp_args; char hp_xname[8]; + struct device hp_dev; }; struct hp_device { @@ -78,9 +82,12 @@ struct hp_device { int hp_alive; int hp_ipl; struct hp_hw *hp_args; - char hp_xname[8]; + struct device hp_dev; }; +/* XXX until the code is cleaed up */ +#define hp_xname hp_dev.dv_xname + /* XXX This needs to die. */ struct devqueue { struct devqueue *dq_forw; @@ -129,6 +136,6 @@ struct devqueue { extern struct hp_hw sc_table[]; extern struct hp_ctlr hp_cinit[]; extern struct hp_device hp_dinit[]; -extern caddr_t sctova(), sctopa(), iomap(); +extern caddr_t sctopa(), iomap(); #endif #endif diff --git a/sys/arch/hp300/dev/devlist2h.awk b/sys/arch/hp300/dev/devlist2h.awk new file mode 100644 index 00000000000..db29dec28b9 --- /dev/null +++ b/sys/arch/hp300/dev/devlist2h.awk @@ -0,0 +1,167 @@ +#! /usr/bin/awk -f +# +# $OpenBSD: devlist2h.awk,v 1.1 1997/01/12 15:12:24 downsj Exp $ +# $NetBSD: devlist2h.awk,v 1.1 1996/12/17 08:41:02 thorpej Exp $ +# +# Copyright (c) 1996 Jason R. Thorpe. All rights reserved. +# Copyright (c) 1995, 1996 Christopher G. Demetriou +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by Christopher G. Demetriou. +# 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 +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +BEGIN { + ndevices = 0 + fbid = 0 + dfile="diodevs_data.h" + hfile="diodevs.h" +} +NR == 1 { + VERSION = $0 + gsub("\\$", "", VERSION) + + printf("/*\n") > dfile + printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \ + > dfile + printf(" *\n") > dfile + printf(" * generated from:\n") > dfile + printf(" *\t%s\n", VERSION) > dfile + printf(" */\n") > dfile + + printf("/*\n") > hfile + printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \ + > hfile + printf(" *\n") > hfile + printf(" * generated from:\n") > hfile + printf(" *\t%s\n", VERSION) > hfile + printf(" */\n") > hfile + + next +} +$1 == "device" { + ndevices++ + + devices[ndevices, 1] = $2 # nickname + devices[ndevices, 2] = $3 # dio primary id + devices[ndevices, 3] = "0" # dio secondary id + devices[ndevices, 4] = $4 # number of select codes + # used by device + + # if this is the framebuffer entry, save the primary id + if ($2 == "FRAMEBUFFER") { + fbid = $3; + } + + # emit device primary id + printf("\n#define\tDIO_DEVICE_ID_%s\t%s\n", devices[ndevices, 1], \ + devices[ndevices, 2]) > hfile + + # emit description + printf("#define\tDIO_DEVICE_DESC_%s\t\"", devices[ndevices, 1]) \ + > hfile + + f = 5; + + while (f <= NF) { + printf("%s", $f) > hfile + if (f < NF) + printf(" ") > hfile + f++; + } + printf("\"\n") > hfile + + next +} +$1 == "framebuffer" { + ndevices++ + + devices[ndevices, 1] = $2 # nickname + devices[ndevices, 2] = fbid # dio primary id + devices[ndevices, 3] = $3 # dio secondary id + devices[ndevices, 4] = $4 # number of select codes + # used by device + + # emit device secondary id + printf("\n#define\tDIO_DEVICE_SECID_%s\t%s\n", devices[ndevices, 1], \ + devices[ndevices, 3]) > hfile + + # emit description + printf("#define\tDIO_DEVICE_DESC_%s\t\"", devices[ndevices, 1]) \ + > hfile + + f = 5; + + while (f <= NF) { + printf("%s", $f) > hfile + if (f < NF) + printf(" ") > hfile + f++; + } + printf("\"\n") > hfile + + next +} +{ + if ($0 == "") + blanklines++ + if (blanklines != 2 && blanklines != 3) + print $0 > hfile + if (blanklines < 2) + print $0 > dfile +} +END { + # emit device count + + printf("\n") > dfile + printf("#define DIO_NDEVICES\t%d\n", ndevices) > dfile + + # emit select code size table + + printf("\n") > dfile + + printf("struct dio_devdata dio_devdatas[] = {\n") > dfile + for (i = 1; i <= ndevices; i++) { + printf("\t{ %s,\t%s,\t%s },\n", devices[i, 2], + devices[i, 3], devices[i, 4]) > dfile + } + + printf("};\n") > dfile + + # emit description table + + printf("\n") > dfile + printf("#ifdef DIOVERBOSE\n") > dfile + + printf("struct dio_devdesc dio_devdescs[] = {\n") > dfile + + for (i = 1; i <= ndevices; i++) { + printf("\t{ %s,\t%s,\tDIO_DEVICE_DESC_%s },\n", + devices[i, 2], devices[i, 3], devices[i, 1]) > dfile + } + + printf("};\n") > dfile + + printf("#endif /* DIOVERBOSE */\n") > dfile +} diff --git a/sys/arch/hp300/dev/dio.c b/sys/arch/hp300/dev/dio.c new file mode 100644 index 00000000000..ee64e36c33f --- /dev/null +++ b/sys/arch/hp300/dev/dio.c @@ -0,0 +1,307 @@ +/* $OpenBSD: dio.c,v 1.1 1997/01/12 15:12:25 downsj Exp $ */ +/* $NetBSD: dio.c,v 1.1 1996/12/17 08:41:02 thorpej Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Autoconfiguration and mapping support for the DIO bus. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +extern caddr_t internalhpib; + +int dio_scodesize __P((struct dio_attach_args *)); +char *dio_devinfo __P((struct dio_attach_args *, char *, size_t)); + +#ifdef NEWCONFIG +int diomatch __P((struct device *, struct cfdata *, void *)); +void dioattach __P((struct device *, struct device *, void *)); +int dioprint __P((void *, const char *)); +int diosubmatch __P((struct device *, struct cfdata *, void *)); + +struct cfattach dio_ca = { + sizeof(struct device), diomatch, dioattach +}; + +struct cfdriver dio_cd = { + NULL, "dio", DV_DULL +}; + +int +diomatch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + static int dio_matched = 0; + + /* Allow only one instance. */ + if (dio_matched) + return (0); + + dio_matched = 1; + return (1); +} + +void +dioattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct dio_attach_args da; + caddr_t pa, va; + int scode, scmax, didmap, scodesize; + + scmax = DIO_SCMAX(machineid); + printf("\n"); + + for (scode = 0; scode < scmax; ) { + if (DIO_INHOLE(scode)) { + scode++; + continue; + } + + didmap = 0; + + /* + * Temporarily map the space corresponding to + * the current select code unless: + * - this is the internal hpib select code, + * - this is the console select code. + */ + pa = dio_scodetopa(scode); + if (scode == conscode) + va = conaddr; + else if ((scode == 7) && internalhpib) + va = internalhpib = (caddr_t)IIOV(pa); + else { + va = iomap(pa, NBPG); + if (va == NULL) { + printf("%s: can't map scode %d\n", scode); + scode++; + continue; + } + didmap = 1; + } + + /* Check for hardware. */ + if (badaddr(va)) { + if (didmap) + iounmap(va, NBPG); + scode++; + continue; + } + + /* Fill out attach args. */ + bzero(&da, sizeof(da)); + da.da_scode = scode; + da.da_id = DIO_ID(va); + + if (DIO_ISFRAMEBUFFER(da.da_id)) + da.da_secid = DIO_SECID(va); + + da.da_size = DIO_SIZE(scode, va); + scodesize = dio_scodesize(&da); + if (DIO_ISDIO(scode)) + da.da_size *= scodesize; + + /* No longer need the device to be mapped. */ + if (didmap) + iounmap(va, NBPG); + + /* Attach matching device. */ + config_found_sm(self, &da, dioprint, diosubmatch); + scode += scodesize; + } +} + +int +diosubmatch(parent, cf, aux) + struct device *parent; + struct cfdata *cf; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (cf->diocf_scode != DIO_UNKNOWN_SCODE && + cf->diocf_scode != da->da_scode) + return (0); + + return ((*cf->cf_attach->ca_match)(parent, cf, aux)); +} + +int +dioprint(aux, pnp) + void *aux; + const char *pnp; +{ + struct dio_attach_args *da = aux; + char buf[128]; + + if (pnp) + printf("%s at %s", dio_devinfo(da, buf, sizeof(buf)), pnp); + printf(" scode %d", da->da_scode); + return (UNCONF); +} +#endif /* NEWCONFIG */ + +/* + * Convert a select code to a system physical address. + */ +void * +dio_scodetopa(scode) + int scode; +{ + u_long rval; + + if (scode == 7 && internalhpib) + rval = DIO_IHPIBADDR; + else if (DIO_ISDIO(scode)) + rval = DIO_BASE + (scode * DIO_DEVSIZE); + else if (DIO_ISDIOII(scode)) + rval = DIOII_BASE + (scode * DIOII_DEVSIZE); + else + rval = 0; + + return ((void *)rval); +} + +/* + * Return the select code size for this device, defaulting to 1 + * if we don't know what kind of device we have. + */ +int +dio_scodesize(da) + struct dio_attach_args *da; +{ + int i; + + /* + * Deal with lame internal HP-IB controllers which don't have + * consistent/reliable device ids. + */ + if (da->da_scode == 7 && internalhpib) + return (1); + + /* + * Find the dio_devdata matchind the primary id. + * If we're a framebuffer, we also check the secondary id. + */ + for (i = 0; i < DIO_NDEVICES; i++) { + if (da->da_id == dio_devdatas[i].dd_id) { + if (DIO_ISFRAMEBUFFER(da->da_id)) { + if (da->da_secid == dio_devdatas[i].dd_secid) { + goto foundit; + } + } else { + foundit: + return (dio_devdatas[i].dd_nscode); + } + } + } + + /* + * Device is unknown. Print a warning and assume a default. + */ + printf("WARNING: select code size unknown for id = 0x%x secid = 0x%x\n", + da->da_id, da->da_secid); + return (1); +} + +/* + * Return a reasonable description of a DIO device. + */ +char * +dio_devinfo(da, buf, buflen) + struct dio_attach_args *da; + char *buf; + size_t buflen; +{ + int i; + + bzero(buf, buflen); + + /* + * Deal with lame internal HP-IB controllers which don't have + * consistent/reliable device ids. + */ + if (da->da_scode == 7 && internalhpib) { + sprintf(buf, DIO_DEVICE_DESC_IHPIB); + return (buf); + } + +#ifdef DIOVERBOSE + /* + * Find the description matching our primary id. + * If we're a framebuffer, we also check the secondary id. + */ + for (i = 0; i < DIO_NDEVICES; i++) { + if (da->da_id == dio_devdescs[i].dd_id) { + if (DIO_ISFRAMEBUFFER(da->da_id)) { + if (da->da_secid == dio_devdescs[i].dd_secid) { + goto foundit; + } + } else { + foundit: + sprintf(buf, "%s", dio_devdescs[i].dd_desc); + return (buf); + } + } + } +#endif /* DIOVERBOSE */ + + /* + * Device is unknown. Construct something reasonable. + */ + sprintf(buf, "device id = 0x%x secid = 0x%x", + da->da_id, da->da_secid); + return (buf); +} diff --git a/sys/arch/hp300/dev/diodevs b/sys/arch/hp300/dev/diodevs new file mode 100644 index 00000000000..5df0b035ddd --- /dev/null +++ b/sys/arch/hp300/dev/diodevs @@ -0,0 +1,104 @@ +$OpenBSD: diodevs,v 1.1 1997/01/12 15:12:25 downsj Exp $ +$NetBSD: diodevs,v 1.1 1996/12/17 08:41:03 thorpej Exp $ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * List of known DIO devices + */ + +/* Devices we have drivers for. */ + +device DCA0 0x02 1 98644A serial +device DCA0REM 0x82 1 98644A serial +device DCA1 0x42 1 98644A serial +device DCA1REM 0xc2 1 98644A serial + +device DCM 0x05 1 98642A serial MUX +device DCMREM 0x85 1 98642A serial MUX + +device LAN 0x15 1 98643A LAN + +device FHPIB 0x08 1 98625A/98625B HP-IB +device NHPIB 0x80 1 98624A HP-IB +device IHPIB 0x00 1 internal HP-IB + +device SCSI0 0x07 1 98625A SCSI +device SCSI1 0x27 1 98625A SCSI +device SCSI2 0x47 1 98625A SCSI +device SCSI3 0x67 1 98625A SCSI + +/* Framebuffer devices; same primary ID, different secondary IDs. */ + +device FRAMEBUFFER 0x39 1 bitmapped display + +framebuffer GATORBOX 0x01 1 98700/98710 (\"gatorbox\") display +framebuffer TOPCAT 0x02 1 98544/98545/98547 (\"topcat\") display +framebuffer RENASSIANCE 0x04 2 98720/98721 (\"renassiance\") display +framebuffer LRCATSEYE 0x05 1 low-res catseye display +framebuffer HRCCATSEYE 0x06 1 high-res color catseye display +framebuffer HRMCATSEYE 0x07 1 high-res mono catseye display +framebuffer DAVINCI 0x08 2 98730/98731 (\"davinci\") display +framebuffer XXXCATSEYE 0x09 1 catseye display +framebuffer HYPERION 0x0e 1 A1096A (\"hyperion\") display + +/* Unsupported framebuffers. */ + +framebuffer XGENESIS 0x0b 1 x-genesis display +framebuffer TIGER 0x0c 1 tiger display +framebuffer YGENESIS 0x0d 1 y-genesis display + +/* Devices not yet supported. Descriptions are lacking. */ + +device MISC0 0x03 1 98622A +device MISC1 0x04 1 98623A +device PARALLEL 0x06 1 internal parallel +device MISC2 0x09 1 98287A keyboard +device MISC3 0x0a 1 HP98635A floating point accelerator +device MISC4 0x0b 1 timer +device MISC5 0x12 1 98640A +device MISC6 0x16 1 98659A +device MISC7 0x19 1 237 display +device MISC8 0x1a 4 quad-wide card +device MISC9 0x1b 1 98253A +device MISC10 0x1c 1 98627A +device MISC11 0x1d 1 98633A +device MISC12 0x1e 1 98259A +device MISC13 0x1f 1 8741 +device VME 0x31 2 98577A VME adapter +device DCL 0x34 1 98628A serial +device DCLREM 0xb4 1 98628A serial diff --git a/sys/arch/hp300/dev/diodevs.h b/sys/arch/hp300/dev/diodevs.h new file mode 100644 index 00000000000..297f4dda8aa --- /dev/null +++ b/sys/arch/hp300/dev/diodevs.h @@ -0,0 +1,192 @@ +/* + * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. + * + * generated from: + * NetBSD: diodevs,v 1.1 1996/12/17 08:41:03 thorpej Exp + */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + +#define DIO_DEVICE_ID_DCA0 0x02 +#define DIO_DEVICE_DESC_DCA0 "98644A serial" + +#define DIO_DEVICE_ID_DCA0REM 0x82 +#define DIO_DEVICE_DESC_DCA0REM "98644A serial" + +#define DIO_DEVICE_ID_DCA1 0x42 +#define DIO_DEVICE_DESC_DCA1 "98644A serial" + +#define DIO_DEVICE_ID_DCA1REM 0xc2 +#define DIO_DEVICE_DESC_DCA1REM "98644A serial" + + +#define DIO_DEVICE_ID_DCM 0x05 +#define DIO_DEVICE_DESC_DCM "98642A serial MUX" + +#define DIO_DEVICE_ID_DCMREM 0x85 +#define DIO_DEVICE_DESC_DCMREM "98642A serial MUX" + + +#define DIO_DEVICE_ID_LAN 0x15 +#define DIO_DEVICE_DESC_LAN "98643A LAN" + + +#define DIO_DEVICE_ID_FHPIB 0x08 +#define DIO_DEVICE_DESC_FHPIB "98625A/98625B HP-IB" + +#define DIO_DEVICE_ID_NHPIB 0x80 +#define DIO_DEVICE_DESC_NHPIB "98624A HP-IB" + +#define DIO_DEVICE_ID_IHPIB 0x00 +#define DIO_DEVICE_DESC_IHPIB "internal HP-IB" + + +#define DIO_DEVICE_ID_SCSI0 0x07 +#define DIO_DEVICE_DESC_SCSI0 "98625A SCSI" + +#define DIO_DEVICE_ID_SCSI1 0x27 +#define DIO_DEVICE_DESC_SCSI1 "98625A SCSI" + +#define DIO_DEVICE_ID_SCSI2 0x47 +#define DIO_DEVICE_DESC_SCSI2 "98625A SCSI" + +#define DIO_DEVICE_ID_SCSI3 0x67 +#define DIO_DEVICE_DESC_SCSI3 "98625A SCSI" + +/* Framebuffer devices; same primary ID, different secondary IDs. */ + + +#define DIO_DEVICE_ID_FRAMEBUFFER 0x39 +#define DIO_DEVICE_DESC_FRAMEBUFFER "bitmapped display" + + +#define DIO_DEVICE_SECID_GATORBOX 0x01 +#define DIO_DEVICE_DESC_GATORBOX "98700/98710 (\"gatorbox\") display" + +#define DIO_DEVICE_SECID_TOPCAT 0x02 +#define DIO_DEVICE_DESC_TOPCAT "98544/98545/98547 (\"topcat\") display" + +#define DIO_DEVICE_SECID_RENASSIANCE 0x04 +#define DIO_DEVICE_DESC_RENASSIANCE "98720/98721 (\"renassiance\") display" + +#define DIO_DEVICE_SECID_LRCATSEYE 0x05 +#define DIO_DEVICE_DESC_LRCATSEYE "low-res catseye display" + +#define DIO_DEVICE_SECID_HRCCATSEYE 0x06 +#define DIO_DEVICE_DESC_HRCCATSEYE "high-res color catseye display" + +#define DIO_DEVICE_SECID_HRMCATSEYE 0x07 +#define DIO_DEVICE_DESC_HRMCATSEYE "high-res mono catseye display" + +#define DIO_DEVICE_SECID_DAVINCI 0x08 +#define DIO_DEVICE_DESC_DAVINCI "98730/98731 (\"davinci\") display" + +#define DIO_DEVICE_SECID_XXXCATSEYE 0x09 +#define DIO_DEVICE_DESC_XXXCATSEYE "catseye display" + +#define DIO_DEVICE_SECID_HYPERION 0x0e +#define DIO_DEVICE_DESC_HYPERION "A1096A (\"hyperion\") display" + +/* Unsupported framebuffers. */ + + +#define DIO_DEVICE_SECID_XGENESIS 0x0b +#define DIO_DEVICE_DESC_XGENESIS "x-genesis display" + +#define DIO_DEVICE_SECID_TIGER 0x0c +#define DIO_DEVICE_DESC_TIGER "tiger display" + +#define DIO_DEVICE_SECID_YGENESIS 0x0d +#define DIO_DEVICE_DESC_YGENESIS "y-genesis display" + +/* Devices not yet supported. Descriptions are lacking. */ + + +#define DIO_DEVICE_ID_MISC0 0x03 +#define DIO_DEVICE_DESC_MISC0 "98622A" + +#define DIO_DEVICE_ID_MISC1 0x04 +#define DIO_DEVICE_DESC_MISC1 "98623A" + +#define DIO_DEVICE_ID_PARALLEL 0x06 +#define DIO_DEVICE_DESC_PARALLEL "internal parallel" + +#define DIO_DEVICE_ID_MISC2 0x09 +#define DIO_DEVICE_DESC_MISC2 "98287A keyboard" + +#define DIO_DEVICE_ID_MISC3 0x0a +#define DIO_DEVICE_DESC_MISC3 "HP98635A floating point accelerator" + +#define DIO_DEVICE_ID_MISC4 0x0b +#define DIO_DEVICE_DESC_MISC4 "timer" + +#define DIO_DEVICE_ID_MISC5 0x12 +#define DIO_DEVICE_DESC_MISC5 "98640A" + +#define DIO_DEVICE_ID_MISC6 0x16 +#define DIO_DEVICE_DESC_MISC6 "98659A" + +#define DIO_DEVICE_ID_MISC7 0x19 +#define DIO_DEVICE_DESC_MISC7 "237 display" + +#define DIO_DEVICE_ID_MISC8 0x1a +#define DIO_DEVICE_DESC_MISC8 "quad-wide card" + +#define DIO_DEVICE_ID_MISC9 0x1b +#define DIO_DEVICE_DESC_MISC9 "98253A" + +#define DIO_DEVICE_ID_MISC10 0x1c +#define DIO_DEVICE_DESC_MISC10 "98627A" + +#define DIO_DEVICE_ID_MISC11 0x1d +#define DIO_DEVICE_DESC_MISC11 "98633A" + +#define DIO_DEVICE_ID_MISC12 0x1e +#define DIO_DEVICE_DESC_MISC12 "98259A" + +#define DIO_DEVICE_ID_MISC13 0x1f +#define DIO_DEVICE_DESC_MISC13 "8741" + +#define DIO_DEVICE_ID_VME 0x31 +#define DIO_DEVICE_DESC_VME "98577A VME adapter" + +#define DIO_DEVICE_ID_DCL 0x34 +#define DIO_DEVICE_DESC_DCL "98628A serial" + +#define DIO_DEVICE_ID_DCLREM 0xb4 +#define DIO_DEVICE_DESC_DCLREM "98628A serial" diff --git a/sys/arch/hp300/dev/diodevs_data.h b/sys/arch/hp300/dev/diodevs_data.h new file mode 100644 index 00000000000..9ada75170fe --- /dev/null +++ b/sys/arch/hp300/dev/diodevs_data.h @@ -0,0 +1,142 @@ +/* + * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. + * + * generated from: + * NetBSD: diodevs,v 1.1 1996/12/17 08:41:03 thorpej Exp + */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#define DIO_NDEVICES 45 + +struct dio_devdata dio_devdatas[] = { + { 0x02, 0, 1 }, + { 0x82, 0, 1 }, + { 0x42, 0, 1 }, + { 0xc2, 0, 1 }, + { 0x05, 0, 1 }, + { 0x85, 0, 1 }, + { 0x15, 0, 1 }, + { 0x08, 0, 1 }, + { 0x80, 0, 1 }, + { 0x00, 0, 1 }, + { 0x07, 0, 1 }, + { 0x27, 0, 1 }, + { 0x47, 0, 1 }, + { 0x67, 0, 1 }, + { 0x39, 0, 1 }, + { 0x39, 0x01, 1 }, + { 0x39, 0x02, 1 }, + { 0x39, 0x04, 2 }, + { 0x39, 0x05, 1 }, + { 0x39, 0x06, 1 }, + { 0x39, 0x07, 1 }, + { 0x39, 0x08, 2 }, + { 0x39, 0x09, 1 }, + { 0x39, 0x0e, 1 }, + { 0x39, 0x0b, 1 }, + { 0x39, 0x0c, 1 }, + { 0x39, 0x0d, 1 }, + { 0x03, 0, 1 }, + { 0x04, 0, 1 }, + { 0x06, 0, 1 }, + { 0x09, 0, 1 }, + { 0x0a, 0, 1 }, + { 0x0b, 0, 1 }, + { 0x12, 0, 1 }, + { 0x16, 0, 1 }, + { 0x19, 0, 1 }, + { 0x1a, 0, 4 }, + { 0x1b, 0, 1 }, + { 0x1c, 0, 1 }, + { 0x1d, 0, 1 }, + { 0x1e, 0, 1 }, + { 0x1f, 0, 1 }, + { 0x31, 0, 2 }, + { 0x34, 0, 1 }, + { 0xb4, 0, 1 }, +}; + +#ifdef DIOVERBOSE +struct dio_devdesc dio_devdescs[] = { + { 0x02, 0, DIO_DEVICE_DESC_DCA0 }, + { 0x82, 0, DIO_DEVICE_DESC_DCA0REM }, + { 0x42, 0, DIO_DEVICE_DESC_DCA1 }, + { 0xc2, 0, DIO_DEVICE_DESC_DCA1REM }, + { 0x05, 0, DIO_DEVICE_DESC_DCM }, + { 0x85, 0, DIO_DEVICE_DESC_DCMREM }, + { 0x15, 0, DIO_DEVICE_DESC_LAN }, + { 0x08, 0, DIO_DEVICE_DESC_FHPIB }, + { 0x80, 0, DIO_DEVICE_DESC_NHPIB }, + { 0x00, 0, DIO_DEVICE_DESC_IHPIB }, + { 0x07, 0, DIO_DEVICE_DESC_SCSI0 }, + { 0x27, 0, DIO_DEVICE_DESC_SCSI1 }, + { 0x47, 0, DIO_DEVICE_DESC_SCSI2 }, + { 0x67, 0, DIO_DEVICE_DESC_SCSI3 }, + { 0x39, 0, DIO_DEVICE_DESC_FRAMEBUFFER }, + { 0x39, 0x01, DIO_DEVICE_DESC_GATORBOX }, + { 0x39, 0x02, DIO_DEVICE_DESC_TOPCAT }, + { 0x39, 0x04, DIO_DEVICE_DESC_RENASSIANCE }, + { 0x39, 0x05, DIO_DEVICE_DESC_LRCATSEYE }, + { 0x39, 0x06, DIO_DEVICE_DESC_HRCCATSEYE }, + { 0x39, 0x07, DIO_DEVICE_DESC_HRMCATSEYE }, + { 0x39, 0x08, DIO_DEVICE_DESC_DAVINCI }, + { 0x39, 0x09, DIO_DEVICE_DESC_XXXCATSEYE }, + { 0x39, 0x0e, DIO_DEVICE_DESC_HYPERION }, + { 0x39, 0x0b, DIO_DEVICE_DESC_XGENESIS }, + { 0x39, 0x0c, DIO_DEVICE_DESC_TIGER }, + { 0x39, 0x0d, DIO_DEVICE_DESC_YGENESIS }, + { 0x03, 0, DIO_DEVICE_DESC_MISC0 }, + { 0x04, 0, DIO_DEVICE_DESC_MISC1 }, + { 0x06, 0, DIO_DEVICE_DESC_PARALLEL }, + { 0x09, 0, DIO_DEVICE_DESC_MISC2 }, + { 0x0a, 0, DIO_DEVICE_DESC_MISC3 }, + { 0x0b, 0, DIO_DEVICE_DESC_MISC4 }, + { 0x12, 0, DIO_DEVICE_DESC_MISC5 }, + { 0x16, 0, DIO_DEVICE_DESC_MISC6 }, + { 0x19, 0, DIO_DEVICE_DESC_MISC7 }, + { 0x1a, 0, DIO_DEVICE_DESC_MISC8 }, + { 0x1b, 0, DIO_DEVICE_DESC_MISC9 }, + { 0x1c, 0, DIO_DEVICE_DESC_MISC10 }, + { 0x1d, 0, DIO_DEVICE_DESC_MISC11 }, + { 0x1e, 0, DIO_DEVICE_DESC_MISC12 }, + { 0x1f, 0, DIO_DEVICE_DESC_MISC13 }, + { 0x31, 0, DIO_DEVICE_DESC_VME }, + { 0x34, 0, DIO_DEVICE_DESC_DCL }, + { 0xb4, 0, DIO_DEVICE_DESC_DCLREM }, +}; +#endif /* DIOVERBOSE */ diff --git a/sys/arch/hp300/dev/dioreg.h b/sys/arch/hp300/dev/dioreg.h new file mode 100644 index 00000000000..a5d096dbd5b --- /dev/null +++ b/sys/arch/hp300/dev/dioreg.h @@ -0,0 +1,141 @@ +/* $OpenBSD: dioreg.h,v 1.1 1997/01/12 15:12:26 downsj Exp $ */ +/* $NetBSD: dioreg.h,v 1.1 1996/12/17 08:41:04 thorpej Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Portions of this file are derived from software contributed to Berkeley + * by the Systems Programming Group of the University of Utah Computer + * Science Department. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Register definitions for the DIO and DIO-II bus. + */ + +/* + * DIO/DIO-II device registers, offsets from base of device. All + * registers are 8-bit. + */ +#define DIO_IDOFF 0x01 /* primary device id */ +#define DIO_IPLOFF 0x03 /* interrupt level */ +#define DIO_SECIDOFF 0x15 /* secondary device id */ +#define DIOII_SIZEOFF 0x101 /* device size */ + +/* + * System physical addresses of some `special' DIO devices. + */ +#define DIO_IHPIBADDR 0x478000 /* internal HP-IB; select code 7 */ + +/* + * DIO ranges from select codes 0-63 at physical addresses given by: + * 0x600000 + (sc - 32) * 0x10000 + * DIO cards are addressed in the range 0-31 [0x600000-0x800000) for + * their control space and the remaining areas, [0x200000-0x400000) and + * [0x800000-0x1000000), are for additional space required by a card; + * e.g. a display framebuffer. + * + * DIO-II ranges from select codes 132-255 at physical addresses given by: + * 0x1000000 + (sc - 132) * 0x400000 + * The address range of DIO-II space is thus [0x1000000-0x20000000). + * + * DIO/DIO-II space is too large to map in its entirety, instead devices + * are mapped into kernel virtual address space allocated from a range + * of EIOMAPSIZE pages (vmparam.h) starting at ``extiobase''. + */ +#define DIO_BASE 0x600000 /* start of DIO space */ +#define DIO_END 0x1000000 /* end of DIO space */ +#define DIO_DEVSIZE 0x10000 /* size of a DIO device */ + +#define DIOII_BASE 0x01000000 /* start of DIO-II space */ +#define DIOII_END 0x20000000 /* end of DIO-II space */ +#define DIOII_DEVSIZE 0x00400000 /* size of a DIO-II device */ + +/* + * Find the highest select code for a given machine; HP320 doesn't + * have DIO-II. + */ +#define DIO_SCMAX(machineid) ((machineid) == HP_320 ? 32 : 256) + +/* + * Macro that returns true if a select code lies within + * the select code `hole'. + */ +#define DIO_INHOLE(scode) ((scode) >= 32 && (scode) < 132) + +/* + * Macros to determine if device is DIO or DIO-II. + */ +#define DIO_ISDIO(scode) ((scode) >= 0 && (scode) < 32) +#define DIO_ISDIOII(scode) ((scode) >= 132 && (scode) < 256) + +/* + * Macro to determine if device is a framebuffer, given the + * primary id of the device. We key off this to determine if + * we should look at secondary id and ignore interrupt level. + */ +#define DIO_ISFRAMEBUFFER(id) \ + ((id) == DIO_DEVICE_ID_FRAMEBUFFER) + +/* + * Macro to extract primary and decondary device ids, given + * the base address of the device. + */ +#define DIO_ID(base) \ + (*((u_int8_t *)((u_long)(base) + DIO_IDOFF))) +#define DIO_SECID(base) \ + (*((u_int8_t *)((u_long)(base) + DIO_SECIDOFF))) + +/* + * Macro to extract the interrupt level, given the + * base address of the device. + */ +#define DIO_IPL(base) \ + ((((*((u_int8_t *)((u_long)(base) + DIO_IPLOFF))) >> 4) & 0x03) + 3) + +/* + * Macro to compute the size of a DIO-II device's address + * space, given the base address of the device. + */ +#define DIOII_SIZE(base) \ + ((int)((*((u_int8_t *)((u_long)(base) + DIOII_SIZEOFF)) + 1) \ + * 0x100000)) + +/* + * Given a select code and device base address, compute + * the size of the DIO/DIO-II device. + */ +#define DIO_SIZE(scode, base) \ + (DIO_ISDIOII((scode)) ? DIOII_SIZE((base)) : DIO_DEVSIZE) diff --git a/sys/arch/hp300/dev/diovar.h b/sys/arch/hp300/dev/diovar.h new file mode 100644 index 00000000000..d2c22432c17 --- /dev/null +++ b/sys/arch/hp300/dev/diovar.h @@ -0,0 +1,80 @@ +/* $OpenBSD: diovar.h,v 1.1 1997/01/12 15:12:27 downsj Exp $ */ +/* $NetBSD: diovar.h,v 1.1 1996/12/17 08:41:05 thorpej Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Autoconfiguration definitions and prototypes for the DIO bus. + */ + +/* + * Arguments used to attach a device to the DIO bus. + */ +struct dio_attach_args { + int da_scode; /* select code */ + int da_size; /* size of address space */ + u_int8_t da_id; /* primary device id */ + u_int8_t da_secid; /* secondary device id */ +}; + +/* + * This structure is used by the autoconfiguration code to lookup + * the size of a DIO device (not all use one select code). + */ +struct dio_devdata { + u_int8_t dd_id; /* primary device id */ + u_int8_t dd_secid; /* secondary device id */ + int dd_nscode; /* number of select codes */ +}; + +/* + * This structure is used by the autoconfiguration code to print + * a textual description of a device. + */ +struct dio_devdesc { + u_int8_t dd_id; /* primary device id */ + u_int8_t dd_secid; /* secondary device id */ + const char *dd_desc; /* description */ +}; + +#define diocf_scode cf_loc[0] + +#define DIO_UNKNOWN_SCODE -1 + +#ifdef _KERNEL +void *dio_scodetopa __P((int)); +#endif /* _KERNEL */ diff --git a/sys/arch/hp300/dev/dma.c b/sys/arch/hp300/dev/dma.c index 17820334441..ebfa5901534 100644 --- a/sys/arch/hp300/dev/dma.c +++ b/sys/arch/hp300/dev/dma.c @@ -1,7 +1,8 @@ -/* $NetBSD: dma.c,v 1.7 1996/02/14 02:44:17 thorpej Exp $ */ +/* $OpenBSD: dma.c,v 1.4 1997/01/12 15:12:28 downsj Exp $ */ +/* $NetBSD: dma.c,v 1.10 1996/12/09 03:09:51 thorpej Exp $ */ /* - * Copyright (c) 1995 Jason R. Thorpe. + * Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved. * Copyright (c) 1982, 1990, 1993 * The Regents of the University of California. All rights reserved. * @@ -54,7 +55,6 @@ #include -extern void isrlink(); extern void _insque(); extern void _remque(); extern u_int kvtop(); @@ -89,6 +89,8 @@ struct dma_softc { struct dmareg *sc_dmareg; /* pointer to our hardware */ struct dma_channel sc_chan[NDMACHAN]; /* 2 channels */ char sc_type; /* A, B, or C */ + int sc_ipl; /* our interrupt level */ + void *sc_ih; /* interrupt cookie */ } Dma_softc; /* types */ @@ -140,7 +142,7 @@ dmainit() * * XXX Don't know how to easily differentiate the A and B cards, * so we just hope nobody has an A card (A cards will work if - * DMAINTLVL is set to 3). + * splbio works out to ipl 3). */ if (badbaddr((char *)&dma->dma_id[2])) { rev = 'B'; @@ -181,8 +183,31 @@ dmainit() printf("%s: 98620%c, 2 channels, %d bit\n", sc->sc_xname, rev, (rev == 'B') ? 16 : 32); - /* Establish the interrupt handler */ - isrlink(dmaintr, sc, DMAINTLVL, ISRPRI_BIO); + /* + * Defer hooking up our interrupt until the first + * DMA-using controller has hooked up theirs. + */ + sc->sc_ih = NULL; +} + +/* + * Compute the ipl and (re)establish the interrupt handler + * for the DMA controller. + */ +void +dmacomputeipl() +{ + struct dma_softc *sc = &Dma_softc; + + if (sc->sc_ih != NULL) + isrunlink(sc->sc_ih); + + /* + * Our interrupt level must be as high as the highest + * device using DMA (i.e. splbio). + */ + sc->sc_ipl = PSLTOIPL(hp300_bioipl); + sc->sc_ih = isrlink(dmaintr, sc, sc->sc_ipl, ISRPRI_BIO); } int @@ -342,7 +367,7 @@ dmago(unit, addr, count, flags) /* * Set up the command word based on flags */ - dc->dm_cmd = DMA_ENAB | DMA_IPL(DMAINTLVL) | DMA_START; + dc->dm_cmd = DMA_ENAB | DMA_IPL(sc->sc_ipl) | DMA_START; if ((flags & DMAGO_READ) == 0) dc->dm_cmd |= DMA_WRT; if (flags & DMAGO_LWORD) diff --git a/sys/arch/hp300/dev/dmareg.h b/sys/arch/hp300/dev/dmareg.h index 3a6ae6538f9..1e94ae6c069 100644 --- a/sys/arch/hp300/dev/dmareg.h +++ b/sys/arch/hp300/dev/dmareg.h @@ -1,4 +1,5 @@ -/* $NetBSD: dmareg.h,v 1.6 1995/12/02 02:46:49 thorpej Exp $ */ +/* $OpenBSD: dmareg.h,v 1.3 1997/01/12 15:12:28 downsj Exp $ */ +/* $NetBSD: dmareg.h,v 1.7 1996/12/09 06:18:13 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -73,9 +74,6 @@ struct dmareg { /* The hp300 has 2 DMA channels. */ #define NDMACHAN 2 -/* intr level must be >= level of any device using dma. i.e., splbio */ -#define DMAINTLVL 5 - /* addresses */ #define DMA_BASE IIOV(0x500000) diff --git a/sys/arch/hp300/dev/dmavar.h b/sys/arch/hp300/dev/dmavar.h index 412db731c55..cd814185f6e 100644 --- a/sys/arch/hp300/dev/dmavar.h +++ b/sys/arch/hp300/dev/dmavar.h @@ -1,4 +1,5 @@ -/* $NetBSD: dmavar.h,v 1.5 1995/03/28 18:16:03 jtc Exp $ */ +/* $OpenBSD: dmavar.h,v 1.2 1997/01/12 15:12:29 downsj Exp $ */ +/* $NetBSD: dmavar.h,v 1.6 1996/12/09 03:09:51 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -50,4 +51,5 @@ #ifdef _KERNEL extern void dmago(), dmafree(); extern int dmareq(); +extern void dmacomputeipl __P((void)); #endif diff --git a/sys/arch/hp300/dev/fhpib.c b/sys/arch/hp300/dev/fhpib.c index 1a73c0462a5..af421d6f542 100644 --- a/sys/arch/hp300/dev/fhpib.c +++ b/sys/arch/hp300/dev/fhpib.c @@ -1,4 +1,5 @@ -/* $NetBSD: fhpib.c,v 1.11 1996/05/18 23:56:59 thorpej Exp $ */ +/* $OpenBSD: fhpib.c,v 1.5 1997/01/12 15:12:29 downsj Exp $ */ +/* $NetBSD: fhpib.c,v 1.13 1996/10/13 03:14:10 christos Exp $ */ /* * Copyright (c) 1982, 1990, 1993 diff --git a/sys/arch/hp300/dev/fhpibreg.h b/sys/arch/hp300/dev/fhpibreg.h index d9e5add5a9f..1aa1d45a781 100644 --- a/sys/arch/hp300/dev/fhpibreg.h +++ b/sys/arch/hp300/dev/fhpibreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: fhpibreg.h,v 1.2 1997/01/12 15:12:30 downsj Exp $ */ /* $NetBSD: fhpibreg.h,v 1.4 1994/10/26 07:23:45 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/grf.c b/sys/arch/hp300/dev/grf.c index bc4c09a799c..8f3abe5bbcb 100644 --- a/sys/arch/hp300/dev/grf.c +++ b/sys/arch/hp300/dev/grf.c @@ -1,4 +1,5 @@ -/* $NetBSD: grf.c,v 1.17 1996/02/24 00:55:07 thorpej Exp $ */ +/* $OpenBSD: grf.c,v 1.4 1997/01/12 15:12:31 downsj Exp $ */ +/* $NetBSD: grf.c,v 1.22 1997/01/10 00:07:27 scottr Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -48,9 +49,6 @@ * Hardware access is through the machine dependent grf switch routines. */ -#include "grf.h" -#if NGRF > 0 - #include #include #include @@ -58,6 +56,8 @@ #include #include #include +#include +#include #include #include @@ -82,11 +82,30 @@ extern struct emul emul_hpux; #if NITE > 0 #include #else -#define iteon(u,f) +#define iteon(u,f) 0 /* normally returns int */ #define iteoff(u,f) #endif /* NITE > 0 */ +/* prototypes for the devsw entry points */ +cdev_decl(grf); + +#ifdef NEWCONFIG +int grfmatch __P((struct device *, struct cfdata *, void *)); +void grfattach __P((struct device *, struct device *, void *)); + +struct cfattach grf_ca = { + sizeof(struct grf_softc), grfmatch, grfattach +}; + +struct cfdriver grf_cd = { + NULL, "grf", DV_DULL +}; + +int grfprint __P((void *, const char *)); +#else /* ! NEWCONFIG */ +#include "grf.h" struct grf_softc grf_softc[NGRF]; +#endif /* NEWCONFIG */ /* * Frambuffer state information, statically allocated for benefit @@ -102,7 +121,50 @@ int grfdebug = 0; #define GDB_LOCK 0x08 #endif +#ifdef NEWCONFIG +int +grfmatch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + + return (1); +} + +void +grfattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grf_softc *sc = (struct grf_softc *)self; + struct grfdev_attach_args *ga = aux; + + printf("\n"); + + sc->sc_data = ga->ga_data; + sc->sc_scode = ga->ga_scode; /* XXX */ + + /* Attach an ITE. */ + (void)config_found(self, aux, grfprint); +} + +int +grfprint(aux, pnp) + void *aux; + const char *pnp; +{ + + /* Only ITEs can attach to GRFs, easy... */ + if (pnp) + printf("ite at %s", pnp); + + return (UNCONF); +} +#endif /* NEWCONFIG */ + /*ARGSUSED*/ +int grfopen(dev, flags, mode, p) dev_t dev; int flags, mode; @@ -113,10 +175,16 @@ grfopen(dev, flags, mode, p) struct grf_data *gp; int error = 0; +#ifdef NEWCONFIG + if (unit >= grf_cd.cd_ndevs || + (sc = grf_cd.cd_devs[unit]) == NULL) + return (ENXIO); +#else if (unit >= NGRF) return(ENXIO); - sc = &grf_softc[unit]; +#endif + gp = sc->sc_data; if ((gp->g_flags & GF_ALIVE) == 0) @@ -152,6 +220,7 @@ grfopen(dev, flags, mode, p) } /*ARGSUSED*/ +int grfclose(dev, flags, mode, p) dev_t dev; int flags, mode; @@ -161,10 +230,12 @@ grfclose(dev, flags, mode, p) struct grf_softc *sc; struct grf_data *gp; - if (unit >= NGRF) - return(ENXIO); - +#ifdef NEWCONFIG + sc = grf_cd.cd_devs[unit]; +#else sc = &grf_softc[unit]; +#endif + gp = sc->sc_data; if ((gp->g_flags & GF_ALIVE) == 0) @@ -179,9 +250,11 @@ grfclose(dev, flags, mode, p) } /*ARGSUSED*/ +int grfioctl(dev, cmd, data, flag, p) dev_t dev; - int cmd, flag; + u_long cmd; + int flag; caddr_t data; struct proc *p; { @@ -189,10 +262,12 @@ grfioctl(dev, cmd, data, flag, p) struct grf_data *gp; int error, unit = GRFUNIT(dev); - if (unit >= NGRF) - return(ENXIO); - +#ifdef NEWCONFIG + sc = grf_cd.cd_devs[unit]; +#else sc = &grf_softc[unit]; +#endif + gp = sc->sc_data; if ((gp->g_flags & GF_ALIVE) == 0) @@ -234,9 +309,11 @@ grfioctl(dev, cmd, data, flag, p) } /*ARGSUSED*/ -grfselect(dev, rw) +int +grfselect(dev, rw, p) dev_t dev; int rw; + struct proc *p; { if (rw == FREAD) return(0); @@ -244,11 +321,18 @@ grfselect(dev, rw) } /*ARGSUSED*/ +int grfmmap(dev, off, prot) dev_t dev; int off, prot; { - return(grfaddr(&grf_softc[GRFUNIT(dev)], off)); +#ifdef NEWCONFIG + struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)]; +#else + struct grf_softc *sc = &grf_softc[GRFUNIT(dev)]; +#endif + + return (grfaddr(sc, off)); } int @@ -259,7 +343,11 @@ grfon(dev) struct grf_softc *sc; struct grf_data *gp; +#ifdef NEWCONFIG + sc = grf_cd.cd_devs[unit]; +#else sc = &grf_softc[unit]; +#endif gp = sc->sc_data; /* @@ -282,7 +370,11 @@ grfoff(dev) struct grf_data *gp; int error; +#ifdef NEWCONFIG + sc = grf_cd.cd_devs[unit]; +#else sc = &grf_softc[unit]; +#endif gp = sc->sc_data; (void) grfunmap(dev, (caddr_t)0, curproc); @@ -290,7 +382,7 @@ grfoff(dev) (dev&GRFOVDEV) ? GM_GRFOVOFF : GM_GRFOFF, (caddr_t)0); /* XXX: see comment for iteoff above */ - (void) iteon(sc->sc_ite->sc_data, 2); + iteon(sc->sc_ite->sc_data, 2); return(error); } @@ -321,13 +413,18 @@ grfaddr(sc, off) #ifdef COMPAT_HPUX /*ARGSUSED*/ +int hpuxgrfioctl(dev, cmd, data, flag, p) dev_t dev; int cmd, flag; caddr_t data; struct proc *p; { +#ifdef NEWCONFIG + struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)]; +#else struct grf_softc *sc = &grf_softc[GRFUNIT(dev)]; +#endif struct grf_data *gp = sc->sc_data; int error; @@ -479,6 +576,7 @@ grflock(gp, block) return(0); } +int grfunlock(gp) struct grf_data *gp; { @@ -515,23 +613,34 @@ grfunlock(gp) * XXX: This may give the wrong result for remote stats of other * machines where device 10 exists. */ +int grfdevno(dev) dev_t dev; { int unit = GRFUNIT(dev); - struct grf_softc *sc = &grf_softc[unit]; - struct grf_data *gp = sc->sc_data; + struct grf_softc *sc; + struct grf_data *gp; int newdev; - if (unit >= NGRF || (gp->g_flags&GF_ALIVE) == 0) - return(bsdtohpuxdev(dev)); +#ifdef NEWCONFIG + if (unit >= grf_cd.cd_ndevs || + (sc = grf_cd.cd_devs[unit]) == NULL) + return (bsdtohpuxdev(dev)); +#else + if (unit >= NGRF) + return (bsdtohpuxdev(dev)); + sc = &grf_softc[unit]; +#endif + + gp = sc->sc_data; + if ((gp->g_flags & GF_ALIVE) == 0) + return (bsdtohpuxdev(dev)); + /* magic major number */ newdev = 12 << 24; /* now construct minor number */ - if (gp->g_display.gd_regaddr != (caddr_t)GRFIADDR) { - int sc = patosc(gp->g_display.gd_regaddr); - newdev |= (sc << 16) | 0x200; - } + if (gp->g_display.gd_regaddr != (caddr_t)GRFIADDR) + newdev |= (sc->sc_scode << 16) | 0x200; if (dev & GRFIMDEV) newdev |= 0x02; else if (dev & GRFOVDEV) @@ -545,12 +654,17 @@ grfdevno(dev) #endif /* COMPAT_HPUX */ +int grfmap(dev, addrp, p) dev_t dev; caddr_t *addrp; struct proc *p; { +#ifdef NEWCONFIG + struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)]; +#else struct grf_softc *sc = &grf_softc[GRFUNIT(dev)]; +#endif struct grf_data *gp = sc->sc_data; int len, error; struct vnode vn; @@ -583,7 +697,11 @@ grfunmap(dev, addr, p) caddr_t addr; struct proc *p; { +#ifdef NEWCONFIG + struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)]; +#else struct grf_softc *sc = &grf_softc[GRFUNIT(dev)]; +#endif struct grf_data *gp = sc->sc_data; vm_size_t size; int rv; @@ -601,6 +719,7 @@ grfunmap(dev, addr, p) } #ifdef COMPAT_HPUX +int iommap(dev, addrp) dev_t dev; caddr_t *addrp; @@ -613,6 +732,7 @@ iommap(dev, addrp) return(EINVAL); } +int iounmmap(dev, addr) dev_t dev; caddr_t addr; @@ -728,5 +848,3 @@ grflckunmmap(dev, addr) return(EINVAL); } #endif /* COMPAT_HPUX */ - -#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_conf.c b/sys/arch/hp300/dev/grf_conf.c index 3bbafb6cc19..3d0dae6bb12 100644 --- a/sys/arch/hp300/dev/grf_conf.c +++ b/sys/arch/hp300/dev/grf_conf.c @@ -1,4 +1,9 @@ -/* $NetBSD: grf_conf.c,v 1.3 1996/02/24 00:55:08 thorpej Exp $ */ +/* $OpenBSD: grf_conf.c,v 1.3 1997/01/12 15:12:31 downsj Exp $ */ +/* $NetBSD: grf_conf.c,v 1.4 1996/12/17 08:41:06 thorpej Exp $ */ + +/* + * XXX This file is old config only! + */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -50,6 +55,7 @@ #if NGRF > 0 #include +#include #include /* XXX */ #include diff --git a/sys/arch/hp300/dev/grf_dv.c b/sys/arch/hp300/dev/grf_dv.c index ef1946fa244..eab98b4e939 100644 --- a/sys/arch/hp300/dev/grf_dv.c +++ b/sys/arch/hp300/dev/grf_dv.c @@ -1,4 +1,5 @@ -/* $NetBSD: grf_dv.c,v 1.7 1996/03/03 16:48:56 thorpej Exp $ */ +/* $OpenBSD: grf_dv.c,v 1.3 1997/01/12 15:12:32 downsj Exp $ */ +/* $NetBSD: grf_dv.c,v 1.9 1996/12/17 08:41:07 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -43,9 +44,6 @@ * @(#)grf_dv.c 8.4 (Berkeley) 1/12/94 */ -#include "grf.h" -#if NGRF > 0 - /* * Graphics routines for the DaVinci, HP98730/98731 Graphics system. */ @@ -56,12 +54,17 @@ #include #include #include +#include #include #include #include +#include +#include +#include + #include #include #include @@ -76,9 +79,29 @@ int dv_init __P((struct grf_data *, int, caddr_t)); int dv_mode __P((struct grf_data *, int, caddr_t)); void dv_reset __P((struct dvboxfb *)); +#ifdef NEWCONFIG +int dvbox_intio_match __P((struct device *, struct cfdata *, void *)); +void dvbox_intio_attach __P((struct device *, struct device *, void *)); + +int dvbox_dio_match __P((struct device *, struct cfdata *, void *)); +void dvbox_dio_attach __P((struct device *, struct device *, void *)); + +struct cfattach dvbox_intio_ca = { + sizeof(struct grfdev_softc), dvbox_intio_match, dvbox_intio_attach +}; + +struct cfattach dvbox_dio_ca = { + sizeof(struct grfdev_softc), dvbox_dio_match, dvbox_dio_attach +}; + +struct cfdriver dvbox_cd = { + NULL, "dvbox", DV_DULL +}; +#endif /* NEWCONFIG */ + /* DaVinci grf switch */ struct grfsw dvbox_grfsw = { - GID_DAVINCI, GRFDAVINCI, "davinci", dv_init, dv_mode + GID_DAVINCI, GRFDAVINCI, "dvbox", dv_init, dv_mode }; #if NITE > 0 @@ -98,6 +121,83 @@ struct itesw dvbox_itesw = { }; #endif /* NITE > 0 */ +#ifdef NEWCONFIG +int +dvbox_intio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct intio_attach_args *ia = aux; + struct grfreg *grf; + + grf = (struct grfreg *)IIOV(GRFIADDR); + if (badaddr((caddr_t)grf)) + return (0); + + if (grf->gr_id == DIO_DEVICE_ID_FRAMEBUFFER && + grf->gr_id2 == DIO_DEVICE_SECID_DAVINCI) { + ia->ia_addr = (caddr_t)GRFIADDR; + return (1); + } + + return (0); +} + +void +dvbox_intio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + caddr_t grf; + + grf = (caddr_t)IIOV(GRFIADDR); + sc->sc_scode = -1; /* XXX internal i/o */ + + grfdev_attach(sc, dv_init, grf, &dvbox_grfsw); +} + +int +dvbox_dio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER && + da->da_secid == DIO_DEVICE_SECID_DAVINCI) + return (1); + + return (0); +} + +void +dvbox_dio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + struct dio_attach_args *da = aux; + caddr_t grf; + + sc->sc_scode = da->da_scode; + if (sc->sc_scode == conscode) + grf = conaddr; + else { + grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size); + if (grf == 0) { + printf("%s: can't map framebuffer\n", + sc->sc_dev.dv_xname); + return; + } + } + + grfdev_attach(sc, dv_init, grf, &dvbox_grfsw); +} +#endif /* NEWCONFIG */ + /* * Initialize hardware. * Must point g_display at a grfinfo structure describing the hardware. @@ -112,7 +212,7 @@ dv_init(gp, scode, addr) register struct dvboxfb *dbp; struct grfinfo *gi = &gp->g_display; int fboff; - extern caddr_t sctopa(), iomap(); + extern caddr_t iomap(); /* * If the console has been initialized, and it was us, there's @@ -123,7 +223,7 @@ dv_init(gp, scode, addr) if (ISIIOVA(addr)) gi->gd_regaddr = (caddr_t) IIOP(addr); else - gi->gd_regaddr = sctopa(scode); + gi->gd_regaddr = dio_scodetopa(scode); gi->gd_regsize = 0x20000; gi->gd_fbwidth = (dbp->fbwmsb << 8) | dbp->fbwlsb; gi->gd_fbheight = (dbp->fbhmsb << 8) | dbp->fbhlsb; @@ -618,7 +718,6 @@ void dvboxcninit(cp) struct consdev *cp; { - struct ite_data *ip = &ite_cn; struct grf_data *gp = &grf_cn; /* @@ -634,16 +733,9 @@ dvboxcninit(cp) gp->g_flags = GF_ALIVE; /* - * Set up required ite data and initialize ite. + * Initialize the terminal emulator. */ - ip->isw = &dvbox_itesw; - ip->grf = gp; - ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS; - ip->attrbuf = console_attributes; - iteinit(ip); - - kbd_ite = ip; /* XXX */ + itecninit(gp, &dvbox_itesw); } #endif /* NITE > 0 */ -#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_dvreg.h b/sys/arch/hp300/dev/grf_dvreg.h index 29cd2854849..d156424416b 100644 --- a/sys/arch/hp300/dev/grf_dvreg.h +++ b/sys/arch/hp300/dev/grf_dvreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: grf_dvreg.h,v 1.2 1997/01/12 15:12:33 downsj Exp $ */ /* $NetBSD: grf_dvreg.h,v 1.5 1994/10/26 07:23:50 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/grf_gb.c b/sys/arch/hp300/dev/grf_gb.c index a443c74693a..f7aac480613 100644 --- a/sys/arch/hp300/dev/grf_gb.c +++ b/sys/arch/hp300/dev/grf_gb.c @@ -1,4 +1,5 @@ -/* $NetBSD: grf_gb.c,v 1.7 1996/03/03 16:48:58 thorpej Exp $ */ +/* $OpenBSD: grf_gb.c,v 1.3 1997/01/12 15:12:33 downsj Exp $ */ +/* $NetBSD: grf_gb.c,v 1.9 1996/12/17 08:41:08 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -43,9 +44,6 @@ * @(#)grf_gb.c 8.4 (Berkeley) 1/12/94 */ -#include "grf.h" -#if NGRF > 0 - /* * Graphics routines for the Gatorbox. * @@ -60,12 +58,17 @@ #include #include #include +#include #include #include #include +#include +#include +#include + #include #include #include @@ -86,6 +89,26 @@ int gb_init __P((struct grf_data *gp, int, caddr_t)); int gb_mode __P((struct grf_data *gp, int, caddr_t)); void gb_microcode __P((struct gboxfb *)); +#ifdef NEWCONFIG +int gbox_intio_match __P((struct device *, struct cfdata *, void *)); +void gbox_intio_attach __P((struct device *, struct device *, void *)); + +int gbox_dio_match __P((struct device *, struct cfdata *, void *)); +void gbox_dio_attach __P((struct device *, struct device *, void *)); + +struct cfattach gbox_intio_ca = { + sizeof(struct grfdev_softc), gbox_intio_match, gbox_intio_attach +}; + +struct cfattach gbox_dio_ca = { + sizeof(struct grfdev_softc), gbox_dio_match, gbox_dio_attach +}; + +struct cfdriver gbox_cd = { + NULL, "gbox", DV_DULL +}; +#endif /* NEWCONFIG */ + /* Gatorbox grf switch */ struct grfsw gbox_grfsw = { GID_GATORBOX, GRFGATOR, "gatorbox", gb_init, gb_mode @@ -108,6 +131,83 @@ struct itesw gbox_itesw = { }; #endif /* NITE > 0 */ +#ifdef NEWCONFIG +int +gbox_intio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct intio_attach_args *ia = aux; + struct grfreg *grf; + + grf = (struct grfreg *)IIOV(GRFIADDR); + if (badaddr((caddr_t)grf)) + return (0); + + if (grf->gr_id == DIO_DEVICE_ID_FRAMEBUFFER && + grf->gr_id2 == DIO_DEVICE_SECID_GATORBOX) { + ia->ia_addr = (caddr_t)GRFIADDR; + return (1); + } + + return (0); +} + +void +gbox_intio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + caddr_t grf; + + grf = (caddr_t)IIOV(GRFIADDR); + sc->sc_scode = -1; /* XXX internal i/o */ + + grfdev_attach(sc, gb_init, grf, &gbox_grfsw); +} + +int +gbox_dio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER && + da->da_secid == DIO_DEVICE_SECID_GATORBOX) + return (1); + + return (0); +} + +void +gbox_dio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + struct dio_attach_args *da = aux; + caddr_t grf; + + sc->sc_scode = da->da_scode; + if (sc->sc_scode == conscode) + grf = conaddr; + else { + grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size); + if (grf == 0) { + printf("%s: can't map framebuffer\n", + sc->sc_dev.dv_xname); + return; + } + } + + grfdev_attach(sc, gb_init, grf, &gbox_grfsw); +} +#endif /* NEWCONFIG */ + /* * Initialize hardware. * Must point g_display at a grfinfo structure describing the hardware. @@ -123,7 +223,7 @@ gb_init(gp, scode, addr) struct grfinfo *gi = &gp->g_display; u_char *fbp, save; int fboff; - extern caddr_t sctopa(), iomap(); + extern caddr_t iomap(); /* * If the console has been initialized, and it was us, there's @@ -134,7 +234,7 @@ gb_init(gp, scode, addr) if (ISIIOVA(addr)) gi->gd_regaddr = (caddr_t) IIOP(addr); else - gi->gd_regaddr = sctopa(scode); + gi->gd_regaddr = dio_scodetopa(scode); gi->gd_regsize = 0x10000; gi->gd_fbwidth = 1024; /* XXX */ gi->gd_fbheight = 1024; /* XXX */ @@ -568,7 +668,6 @@ void gboxcninit(cp) struct consdev *cp; { - struct ite_data *ip = &ite_cn; struct grf_data *gp = &grf_cn; /* @@ -584,16 +683,9 @@ gboxcninit(cp) gp->g_flags = GF_ALIVE; /* - * Set up required ite data and initialize ite. + * Initialize the terminal emulator. */ - ip->isw = &gbox_itesw; - ip->grf = gp; - ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS; - ip->attrbuf = console_attributes; - iteinit(ip); - - kbd_ite = ip; /* XXX */ + itecninit(gp, &gbox_itesw); } #endif /* NITE > 0 */ -#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_gbreg.h b/sys/arch/hp300/dev/grf_gbreg.h index e93a16d216a..187aeb2a9f4 100644 --- a/sys/arch/hp300/dev/grf_gbreg.h +++ b/sys/arch/hp300/dev/grf_gbreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: grf_gbreg.h,v 1.2 1997/01/12 15:12:34 downsj Exp $ */ /* $NetBSD: grf_gbreg.h,v 1.4 1994/10/26 07:23:53 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/grf_hy.c b/sys/arch/hp300/dev/grf_hy.c index 9598a9d4da5..4a4155c5e42 100644 --- a/sys/arch/hp300/dev/grf_hy.c +++ b/sys/arch/hp300/dev/grf_hy.c @@ -1,4 +1,5 @@ -/* $NetBSD: grf_hy.c,v 1.5 1996/03/03 16:49:00 thorpej Exp $ */ +/* $OpenBSD: grf_hy.c,v 1.3 1997/01/12 15:12:35 downsj Exp $ */ +/* $NetBSD: grf_hy.c,v 1.7 1996/12/17 08:41:09 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -44,9 +45,6 @@ * @(#)grf_hy.c 8.4 (Berkeley) 1/12/94 */ -#include "grf.h" -#if NGRF > 0 - /* * Graphics routines for HYPERION frame buffer */ @@ -58,12 +56,17 @@ #include #include #include +#include #include #include #include +#include +#include +#include + #include #include #include @@ -80,6 +83,19 @@ int hy_init __P((struct grf_data *gp, int, caddr_t)); int hy_mode __P((struct grf_data *gp, int, caddr_t)); void hyper_ite_fontinit __P((struct ite_data *)); +#ifdef NEWCONFIG +int hyper_dio_match __P((struct device *, struct cfdata *, void *)); +void hyper_dio_attach __P((struct device *, struct device *, void *)); + +struct cfattach hyper_dio_ca = { + sizeof(struct grfdev_softc), hyper_dio_match, hyper_dio_attach +}; + +struct cfdriver hyper_cd = { + NULL, "hyper", DV_DULL +}; +#endif /* NEWCONFIG */ + /* Hyperion grf switch */ struct grfsw hyper_grfsw = { GID_HYPERION, GRFHYPERION, "hyperion", hy_init, hy_mode @@ -103,6 +119,47 @@ struct itesw hyper_itesw = { }; #endif /* NITE > 0 */ +#ifdef NEWCONFIG +int +hyper_dio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER && + da->da_secid == DIO_DEVICE_SECID_HYPERION) + return (1); + + return (0); +} + +void +hyper_dio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + struct dio_attach_args *da = aux; + caddr_t grf; + + sc->sc_scode = da->da_scode; + if (sc->sc_scode == conscode) + grf = conaddr; + else { + grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size); + if (grf == 0) { + printf("%s: can't map framebuffer\n", + sc->sc_dev.dv_xname); + return; + } + } + + grfdev_attach(sc, hy_init, grf, &hyper_grfsw); +} +#endif /* NEWCONFIG */ + /* * Initialize hardware. * Must fill in the grfinfo structure in g_softc. @@ -117,7 +174,7 @@ hy_init(gp, scode, addr) register struct hyboxfb *hy = (struct hyboxfb *) addr; struct grfinfo *gi = &gp->g_display; int fboff; - extern caddr_t sctopa(), iomap(); + extern caddr_t iomap(); /* * If the console has been initialized, and it was us, there's @@ -127,7 +184,7 @@ hy_init(gp, scode, addr) if (ISIIOVA(addr)) gi->gd_regaddr = (caddr_t) IIOP(addr); else - gi->gd_regaddr = sctopa(scode); + gi->gd_regaddr = dio_scodetopa(scode); gi->gd_regsize = 0x20000; gi->gd_fbwidth = (hy->fbwmsb << 8) | hy->fbwlsb; gi->gd_fbheight = (hy->fbhmsb << 8) | hy->fbhlsb; @@ -764,7 +821,6 @@ void hypercninit(cp) struct consdev *cp; { - struct ite_data *ip = &ite_cn; struct grf_data *gp = &grf_cn; /* @@ -780,16 +836,9 @@ hypercninit(cp) gp->g_flags = GF_ALIVE; /* - * Set up required ite data and initialize ite. + * Initialize the terminal emulator. */ - ip->isw = &hyper_itesw; - ip->grf = gp; - ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS; - ip->attrbuf = console_attributes; - iteinit(ip); - - kbd_ite = ip; /* XXX */ + itecninit(gp, &hyper_itesw); } #endif /* NITE > 0 */ -#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_hyreg.h b/sys/arch/hp300/dev/grf_hyreg.h index 556399e31c0..9e23836fc8a 100644 --- a/sys/arch/hp300/dev/grf_hyreg.h +++ b/sys/arch/hp300/dev/grf_hyreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: grf_hyreg.h,v 1.2 1997/01/12 15:12:35 downsj Exp $ */ /* $NetBSD: grf_hyreg.h,v 1.2 1994/10/26 07:23:57 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/grf_machdep.c b/sys/arch/hp300/dev/grf_machdep.c index 5792f6cc14d..aed8e6c91dc 100644 --- a/sys/arch/hp300/dev/grf_machdep.c +++ b/sys/arch/hp300/dev/grf_machdep.c @@ -1,4 +1,9 @@ -/* $NetBSD: grf_machdep.c,v 1.4 1996/02/24 00:55:13 thorpej Exp $ */ +/* $OpenBSD: grf_machdep.c,v 1.4 1997/01/12 15:12:36 downsj Exp $ */ +/* $NetBSD: grf_machdep.c,v 1.7 1996/12/17 08:41:09 thorpej Exp $ */ + +/* + * XXX This file is old config only! + */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -125,6 +130,8 @@ grfattach(hd) else isconsole = 0; + sc->sc_scode = scode; + printf(": %d x %d ", gp->g_display.gd_dwidth, gp->g_display.gd_dheight); if (gp->g_display.gd_colors == 2) diff --git a/sys/arch/hp300/dev/grf_rb.c b/sys/arch/hp300/dev/grf_rb.c index d06d7d72f79..ba5e98f0313 100644 --- a/sys/arch/hp300/dev/grf_rb.c +++ b/sys/arch/hp300/dev/grf_rb.c @@ -1,4 +1,5 @@ -/* $NetBSD: grf_rb.c,v 1.7 1996/03/03 16:49:02 thorpej Exp $ */ +/* $OpenBSD: grf_rb.c,v 1.3 1997/01/12 15:12:36 downsj Exp $ */ +/* $NetBSD: grf_rb.c,v 1.9 1996/12/17 08:41:10 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -43,9 +44,6 @@ * @(#)grf_rb.c 8.4 (Berkeley) 1/12/94 */ -#include "grf.h" -#if NGRF > 0 - /* * Graphics routines for the Renaissance, HP98720 Graphics system. */ @@ -56,12 +54,17 @@ #include #include #include +#include #include #include #include +#include +#include +#include + #include #include #include @@ -75,6 +78,26 @@ int rb_init __P((struct grf_data *gp, int, caddr_t)); int rb_mode __P((struct grf_data *gp, int, caddr_t)); +#ifdef NEWCONFIG +int rbox_intio_match __P((struct device *, struct cfdata *, void *)); +void rbox_intio_attach __P((struct device *, struct device *, void *)); + +int rbox_dio_match __P((struct device *, struct cfdata *, void *)); +void rbox_dio_attach __P((struct device *, struct device *, void *)); + +struct cfattach rbox_intio_ca = { + sizeof(struct grfdev_softc), rbox_intio_match, rbox_intio_attach +}; + +struct cfattach rbox_dio_ca = { + sizeof(struct grfdev_softc), rbox_dio_match, rbox_dio_attach +}; + +struct cfdriver rbox_cd = { + NULL, "rbox", DV_DULL +}; +#endif /* NEWCONFIG */ + /* Renaissance grf switch */ struct grfsw rbox_grfsw = { GID_RENAISSANCE, GRFRBOX, "renaissance", rb_init, rb_mode @@ -97,6 +120,83 @@ struct itesw rbox_itesw = { }; #endif /* NITE > 0 */ +#ifdef NEWCONFIG +int +rbox_intio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct intio_attach_args *ia = aux; + struct grfreg *grf; + + grf = (struct grfreg *)IIOV(GRFIADDR); + if (badaddr((caddr_t)grf)) + return (0); + + if (grf->gr_id == DIO_DEVICE_ID_FRAMEBUFFER && + grf->gr_id2 == DIO_DEVICE_SECID_RENASSIANCE) { + ia->ia_addr = (caddr_t)GRFIADDR; + return (1); + } + + return (0); +} + +void +rbox_intio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + caddr_t grf; + + grf = (caddr_t)IIOV(GRFIADDR); + sc->sc_scode = -1; /* XXX internal i/o */ + + grfdev_attach(sc, rb_init, grf, &rbox_grfsw); +} + +int +rbox_dio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER && + da->da_secid == DIO_DEVICE_SECID_RENASSIANCE) + return (1); + + return (0); +} + +void +rbox_dio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + struct dio_attach_args *da = aux; + caddr_t grf; + + sc->sc_scode = da->da_scode; + if (sc->sc_scode == conscode) + grf = conaddr; + else { + grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size); + if (grf == 0) { + printf("%s: can't map framebuffer\n", + sc->sc_dev.dv_xname); + return; + } + } + + grfdev_attach(sc, rb_init, grf, &rbox_grfsw); +} +#endif /* NEWCONFIG */ + /* * Initialize hardware. * Must point g_display at a grfinfo structure describing the hardware. @@ -111,7 +211,7 @@ rb_init(gp, scode, addr) register struct rboxfb *rbp; struct grfinfo *gi = &gp->g_display; int fboff; - extern caddr_t sctopa(), iomap(); + extern caddr_t iomap(); /* * If the console has been initialized, and it was us, there's @@ -122,7 +222,7 @@ rb_init(gp, scode, addr) if (ISIIOVA(addr)) gi->gd_regaddr = (caddr_t) IIOP(addr); else - gi->gd_regaddr = sctopa(scode); + gi->gd_regaddr = dio_scodetopa(scode); gi->gd_regsize = 0x20000; gi->gd_fbwidth = (rbp->fbwmsb << 8) | rbp->fbwlsb; gi->gd_fbheight = (rbp->fbhmsb << 8) | rbp->fbhlsb; @@ -565,7 +665,6 @@ void rboxcninit(cp) struct consdev *cp; { - struct ite_data *ip = &ite_cn; struct grf_data *gp = &grf_cn; /* @@ -581,16 +680,9 @@ rboxcninit(cp) gp->g_flags = GF_ALIVE; /* - * Set up required ite data and initialize ite. + * Initialize the terminal emulator. */ - ip->isw = &rbox_itesw; - ip->grf = gp; - ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS; - ip->attrbuf = console_attributes; - iteinit(ip); - - kbd_ite = ip; /* XXX */ + itecninit(gp, &rbox_itesw); } #endif /* NITE > 0 */ -#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_rbreg.h b/sys/arch/hp300/dev/grf_rbreg.h index 890302713a9..98686b9eb5c 100644 --- a/sys/arch/hp300/dev/grf_rbreg.h +++ b/sys/arch/hp300/dev/grf_rbreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: grf_rbreg.h,v 1.2 1997/01/12 15:12:37 downsj Exp $ */ /* $NetBSD: grf_rbreg.h,v 1.4 1994/10/26 07:24:03 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/grf_subr.c b/sys/arch/hp300/dev/grf_subr.c new file mode 100644 index 00000000000..3f2b845daf0 --- /dev/null +++ b/sys/arch/hp300/dev/grf_subr.c @@ -0,0 +1,123 @@ +/* $OpenBSD: grf_subr.c,v 1.1 1997/01/12 15:12:38 downsj Exp $ */ +/* $NetBSD: grf_subr.c,v 1.1 1996/12/17 08:41:11 thorpej Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Subroutines common to all framebuffer devices. + */ + +#include +#include +#include +#include + +#include +#include + +#include +#include + +int grfdevprint __P((void *, const char *)); + +void +grfdev_attach(sc, init, regs, sw) + struct grfdev_softc *sc; + int (*init) __P((struct grf_data *, int, caddr_t)); + caddr_t regs; + struct grfsw *sw; +{ + struct grfdev_attach_args ga; + struct grf_data *gp; + int isconsole; + + isconsole = (sc->sc_scode == conscode); + + if (isconsole) + sc->sc_data = gp = &grf_cn; + else { + sc->sc_data = gp = + (struct grf_data *)malloc(sizeof(struct grf_data), + M_DEVBUF, M_NOWAIT); + if (sc->sc_data == NULL) { + printf("\n%s: can't allocate grf data\n", + sc->sc_dev.dv_xname); + return; + } + bzero(sc->sc_data, sizeof(struct grf_data)); + + /* Initialize the framebuffer hardware. */ + if ((*init)(sc->sc_data, sc->sc_scode, regs) == 0) { + printf("\n%s: init failed\n", + sc->sc_dev.dv_xname); + free(sc->sc_data, M_DEVBUF); + return; + } + + gp->g_sw = sw; + gp->g_display.gd_id = gp->g_sw->gd_swid; + } + + /* Announce ourselves. */ + printf(": %d x %d ", gp->g_display.gd_dwidth, + gp->g_display.gd_dheight); + if (gp->g_display.gd_colors == 2) + printf("monochrome"); + else + printf("%d color", gp->g_display.gd_colors); + printf(" %s display\n", gp->g_sw->gd_desc); + + /* Attach a grf. */ + ga.ga_scode = sc->sc_scode; /* XXX */ + ga.ga_isconsole = isconsole; + ga.ga_data = (void *)sc->sc_data; + (void)config_found(&sc->sc_dev, &ga, grfdevprint); +} + +int +grfdevprint(aux, pnp) + void *aux; + const char *pnp; +{ + struct grfdev_attach_args *ga = aux; + + /* Only grf's can attach to grfdev's... easy. */ + if (pnp) + printf("grf at %s", pnp); + + return (UNCONF); +} diff --git a/sys/arch/hp300/dev/grf_tc.c b/sys/arch/hp300/dev/grf_tc.c index fdde9bbaea4..65eae4683d5 100644 --- a/sys/arch/hp300/dev/grf_tc.c +++ b/sys/arch/hp300/dev/grf_tc.c @@ -1,4 +1,5 @@ -/* $NetBSD: grf_tc.c,v 1.7 1996/03/03 16:49:04 thorpej Exp $ */ +/* $OpenBSD: grf_tc.c,v 1.3 1997/01/12 15:12:38 downsj Exp $ */ +/* $NetBSD: grf_tc.c,v 1.9 1996/12/17 08:41:12 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -43,9 +44,6 @@ * @(#)grf_tc.c 8.4 (Berkeley) 1/12/94 */ -#include "grf.h" -#if NGRF > 0 - /* * Graphics routines for TOPCAT and CATSEYE frame buffers */ @@ -56,12 +54,17 @@ #include #include #include +#include #include #include #include +#include +#include +#include + #include #include #include @@ -75,6 +78,28 @@ int tc_init __P((struct grf_data *, int, caddr_t)); int tc_mode __P((struct grf_data *, int, caddr_t)); +#ifdef NEWCONFIG +void topcat_common_attach __P((struct grfdev_softc *, caddr_t, u_int8_t)); + +int topcat_intio_match __P((struct device *, struct cfdata *, void *)); +void topcat_intio_attach __P((struct device *, struct device *, void *)); + +int topcat_dio_match __P((struct device *, struct cfdata *, void *)); +void topcat_dio_attach __P((struct device *, struct device *, void *)); + +struct cfattach topcat_intio_ca = { + sizeof(struct grfdev_softc), topcat_intio_match, topcat_intio_attach +}; + +struct cfattach topcat_dio_ca = { + sizeof(struct grfdev_softc), topcat_dio_match, topcat_dio_attach +}; + +struct cfdriver topcat_cd = { + NULL, "topcat", DV_DULL +}; +#endif /* NEWCONFIG */ + /* Topcat (bobcat) grf switch */ struct grfsw topcat_grfsw = { GID_TOPCAT, GRFBOBCAT, "topcat", tc_init, tc_mode @@ -112,6 +137,139 @@ struct itesw topcat_itesw = { }; #endif /* NITE > 0 */ +#ifdef NEWCONFIG +int +topcat_intio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct intio_attach_args *ia = aux; + struct grfreg *grf; + + grf = (struct grfreg *)IIOV(GRFIADDR); + + if (badaddr((caddr_t)grf)) + return (0); + + if (grf->gr_id == DIO_DEVICE_ID_FRAMEBUFFER) { + switch (grf->gr_id2) { + case DIO_DEVICE_SECID_TOPCAT: + case DIO_DEVICE_SECID_LRCATSEYE: + case DIO_DEVICE_SECID_HRCCATSEYE: + case DIO_DEVICE_SECID_HRMCATSEYE: +#if 0 + case DIO_DEVICE_SECID_XXXCATSEYE: +#endif + ia->ia_addr = (caddr_t)GRFIADDR; + return (1); + } + } + + return (0); +} + +void +topcat_intio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + struct grfreg *grf; + + grf = (struct grfreg *)IIOV(GRFIADDR); + sc->sc_scode = -1; /* XXX internal i/o */ + + topcat_common_attach(sc, (caddr_t)grf, grf->gr_id2); +} + +int +topcat_dio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER) { + switch (da->da_secid) { + case DIO_DEVICE_SECID_TOPCAT: + case DIO_DEVICE_SECID_LRCATSEYE: + case DIO_DEVICE_SECID_HRCCATSEYE: + case DIO_DEVICE_SECID_HRMCATSEYE: +#if 0 + case DIO_DEVICE_SECID_XXXCATSEYE: +#endif + return (1); + } + } + + return (0); +} + +void +topcat_dio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + struct dio_attach_args *da = aux; + caddr_t grf; + + sc->sc_scode = da->da_scode; + if (sc->sc_scode == conscode) + grf = conaddr; + else { + grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size); + if (grf == 0) { + printf("%s: can't map framebuffer\n", + sc->sc_dev.dv_xname); + return; + } + } + + topcat_common_attach(sc, grf, da->da_secid); +} + +void +topcat_common_attach(sc, grf, secid) + struct grfdev_softc *sc; + caddr_t grf; + u_int8_t secid; +{ + struct grfsw *sw; + + switch (secid) { + case DIO_DEVICE_SECID_TOPCAT: + sw = &topcat_grfsw; + break; + + case DIO_DEVICE_SECID_LRCATSEYE: + sw = &lrcatseye_grfsw; + break; + + case DIO_DEVICE_SECID_HRCCATSEYE: + sw = &hrcatseye_grfsw; + break; + + case DIO_DEVICE_SECID_HRMCATSEYE: + sw = &hrmcatseye_grfsw; + break; +#if 0 + case DIO_DEVICE_SECID_XXXCATSEYE: + sw = XXX? + break; +#endif + default: + printf("%s: unkown device 0x%x\n", + sc->sc_dev.dv_xname, secid); + panic("topcat_common_attach"); + } + + grfdev_attach(sc, tc_init, grf, sw); +} +#endif /* NEWCONFIG */ + /* * Initialize hardware. * Must fill in the grfinfo structure in g_softc. @@ -128,7 +286,6 @@ tc_init(gp, scode, addr) volatile u_char *fbp; u_char save; int fboff; - extern caddr_t sctopa(); /* * If the console has been initialized, and it was us, there's @@ -138,7 +295,7 @@ tc_init(gp, scode, addr) if (ISIIOVA(addr)) gi->gd_regaddr = (caddr_t) IIOP(addr); else - gi->gd_regaddr = sctopa(scode); + gi->gd_regaddr = dio_scodetopa(scode); gi->gd_regsize = 0x10000; gi->gd_fbwidth = (tp->fbwmsb << 8) | tp->fbwlsb; gi->gd_fbheight = (tp->fbhmsb << 8) | tp->fbhlsb; @@ -626,7 +783,6 @@ void topcatcninit(cp) struct consdev *cp; { - struct ite_data *ip = &ite_cn; struct grf_data *gp = &grf_cn; struct grfreg *grf = (struct grfreg *)conaddr; @@ -663,16 +819,9 @@ topcatcninit(cp) gp->g_flags = GF_ALIVE; /* - * Set up required ite data and initialize ite. + * Initialize the terminal emulator. */ - ip->isw = &topcat_itesw; - ip->grf = gp; - ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS; - ip->attrbuf = console_attributes; - iteinit(ip); - - kbd_ite = ip; /* XXX */ + itecninit(gp, &topcat_itesw); } #endif /* NITE > 0 */ -#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_tcreg.h b/sys/arch/hp300/dev/grf_tcreg.h index 38c7dd825ce..b3146f0100c 100644 --- a/sys/arch/hp300/dev/grf_tcreg.h +++ b/sys/arch/hp300/dev/grf_tcreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: grf_tcreg.h,v 1.2 1997/01/12 15:12:39 downsj Exp $ */ /* $NetBSD: grf_tcreg.h,v 1.6 1994/10/26 07:24:06 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/grfioctl.h b/sys/arch/hp300/dev/grfioctl.h index 1d186584cc8..4467860af9b 100644 --- a/sys/arch/hp300/dev/grfioctl.h +++ b/sys/arch/hp300/dev/grfioctl.h @@ -1,3 +1,4 @@ +/* $OpenBSD: grfioctl.h,v 1.2 1997/01/12 15:12:40 downsj Exp $ */ /* $NetBSD: grfioctl.h,v 1.5 1994/10/26 07:24:08 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/grfreg.h b/sys/arch/hp300/dev/grfreg.h index d80205fffd6..e69b02df4bc 100644 --- a/sys/arch/hp300/dev/grfreg.h +++ b/sys/arch/hp300/dev/grfreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: grfreg.h,v 1.2 1997/01/12 15:12:40 downsj Exp $ */ /* $NetBSD: grfreg.h,v 1.2 1994/10/26 07:24:09 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/grfvar.h b/sys/arch/hp300/dev/grfvar.h index f6f02a0158f..ac6a5d51db9 100644 --- a/sys/arch/hp300/dev/grfvar.h +++ b/sys/arch/hp300/dev/grfvar.h @@ -1,4 +1,5 @@ -/* $NetBSD: grfvar.h,v 1.7 1996/02/24 00:55:18 thorpej Exp $ */ +/* $OpenBSD: grfvar.h,v 1.3 1997/01/12 15:12:41 downsj Exp $ */ +/* $NetBSD: grfvar.h,v 1.8 1996/12/17 08:41:12 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -77,10 +78,28 @@ struct grfsw { }; struct grf_softc { + struct device sc_dev; /* generic device info */ + int sc_scode; /* select code; for grfdevno() */ struct grf_data *sc_data; /* display state information */ struct ite_softc *sc_ite; /* pointer to ite; may be NULL */ }; +struct grfdev_softc { + struct device sc_dev; /* generic device info */ + struct grf_data *sc_data; /* generic grf data */ + int sc_scode; /* select code, -1 for intio */ +}; + +/* + * Set up by the hardware driver, and passed all the way down to + * the ITE, if appropriate. + */ +struct grfdev_attach_args { + int ga_scode; /* XXX select code, -1 for intio */ + int ga_isconsole; /* from hardware; is console? */ + void *ga_data; /* hardware-dependent data */ +}; + /* flags */ #define GF_ALIVE 0x01 #define GF_OPEN 0x02 @@ -105,7 +124,15 @@ struct grf_softc { #ifdef _KERNEL extern struct grf_data grf_cn; /* grf_data for console device */ +#ifndef NEWCONFIG extern struct grf_softc grf_softc[]; extern struct grfsw *grfsw[]; extern int ngrfsw; -#endif +#endif /* ! NEWCONFIG */ + +#ifdef NEWCONFIG +void grfdev_attach __P((struct grfdev_softc *, + int (*init)(struct grf_data *, int, caddr_t), + caddr_t, struct grfsw *)); +#endif /* NEWCONFIG */ +#endif /* _KERNEL */ diff --git a/sys/arch/hp300/dev/hil.c b/sys/arch/hp300/dev/hil.c index bf93d1eec0a..fc159f1fe9d 100644 --- a/sys/arch/hp300/dev/hil.c +++ b/sys/arch/hp300/dev/hil.c @@ -1,4 +1,5 @@ -/* $NetBSD: hil.c,v 1.22 1996/02/14 02:44:24 thorpej Exp $ */ +/* $OpenBSD: hil.c,v 1.8 1997/01/12 15:12:41 downsj Exp $ */ +/* $NetBSD: hil.c,v 1.29 1996/10/14 07:09:41 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -93,6 +94,13 @@ int hildebug = 0; extern struct emul emul_hpux; #endif +/* XXX ITE interface */ +char *kbd_keymap; +char *kbd_shiftmap; +char *kbd_ctrlmap; +char *kbd_ctrlshiftmap; +char **kbd_stringmap; + /* symbolic sleep message strings */ char hilin[] = "hilin"; @@ -103,6 +111,10 @@ hilsoftinit(unit, hilbase) register struct hil_softc *hilp = &hil_softc[unit]; register int i; + /* XXX ITE interface */ + extern char *us_keymap, *us_shiftmap, *us_ctrlmap, + *us_ctrlshiftmap, **us_stringmap; + #ifdef DEBUG if (hildebug & HDB_FOLLOW) printf("hilsoftinit(%d, %x)\n", unit, hilbase); @@ -117,7 +129,6 @@ hilsoftinit(unit, hilbase) hilp->hl_cmdbp = hilp->hl_cmdbuf; hilp->hl_pollbp = hilp->hl_pollbuf; hilp->hl_kbddev = 0; - hilp->hl_kbdlang = KBD_DEFAULT; hilp->hl_kbdflags = 0; /* * Clear all queues and device associations with queues @@ -130,6 +141,18 @@ hilsoftinit(unit, hilbase) for (i = 0; i < NHILD; i++) hilp->hl_device[i].hd_qmask = 0; hilp->hl_device[HILLOOPDEV].hd_flags = (HIL_ALIVE|HIL_PSEUDO); + + /* + * Set up default keyboard language. We always default + * to US ASCII - it seems to work OK for non-recognized + * keyboards. + */ + hilp->hl_kbdlang = KBD_DEFAULT; + kbd_keymap = us_keymap; /* XXX */ + kbd_shiftmap = us_shiftmap; /* XXX */ + kbd_ctrlmap = us_ctrlmap; /* XXX */ + kbd_ctrlshiftmap = us_ctrlshiftmap; /* XXX */ + kbd_stringmap = us_stringmap; /* XXX */ } hilinit(unit, hilbase) @@ -681,6 +704,7 @@ hilmmap(dev, off, prot) } /*ARGSUSED*/ +int hilselect(dev, rw, p) dev_t dev; int rw; @@ -691,7 +715,7 @@ hilselect(dev, rw, p) register struct hiliqueue *qp; register int mask; int s, device; - + if (rw == FWRITE) return (1); device = HILUNIT(dev); @@ -831,10 +855,6 @@ hil_process_int(hilp, stat, c) } } -#if (defined(DDB) || defined(DEBUG)) && !defined(PANICBUTTON) -#define PANICBUTTON -#endif - /* * Optimized macro to compute: * eq->head == (eq->tail + 1) % eq->size @@ -857,20 +877,6 @@ hilevent(hilp) int s, len0; long tenths; -#ifdef PANICBUTTON - static int first; - extern int panicbutton; - - cp = hilp->hl_pollbuf; - if (panicbutton && (*cp & HIL_KBDDATA)) { - if (*++cp == 0x4E) - first = 1; - else if (first && *cp == 0x46 && !panicstr) - panic("are we having fun yet?"); - else - first = 0; - } -#endif #ifdef DEBUG if (hildebug & HDB_EVENTS) { printf("hilevent: dev %d pollbuf: ", hilp->hl_actdev); @@ -1127,28 +1133,86 @@ kbddisable(unit) { } +/* + * The following chunk of code implements HIL console keyboard + * support. + */ + +struct hil_dev *hilkbd_cn_device; +char *kbd_cn_keymap; +char *kbd_cn_shiftmap; +char *kbd_cn_ctrlmap; + /* * XXX: read keyboard directly and return code. * Used by console getchar routine. Could really screw up anybody * reading from the keyboard in the normal, interrupt driven fashion. */ -kbdgetc(unit, statp) - int unit, *statp; +int +kbdgetc(statp) + int *statp; { - struct hil_softc *hilp = &hil_softc[unit]; - register struct hil_dev *hildevice = hilp->hl_addr; register int c, stat; int s; + if (hilkbd_cn_device == NULL) + return (0); + + /* + * XXX needs to be splraise because we could be called + * XXX at splhigh, e.g. in DDB. + */ s = splhil(); - while (((stat = READHILSTAT(hildevice)) & HIL_DATA_RDY) == 0) + while (((stat = READHILSTAT(hilkbd_cn_device)) & HIL_DATA_RDY) == 0) ; - c = READHILDATA(hildevice); + c = READHILDATA(hilkbd_cn_device); splx(s); *statp = stat; - return(c); + return (c); } +/* + * Perform basic initialization of the HIL keyboard, suitable + * for early console use. + */ +void +kbdcninit() +{ + struct hil_dev *h = HILADDR; /* == VA (see hilreg.h) */ + struct kbdmap *km; + u_char lang; + + /* XXX from hil_keymaps.c */ + extern char *us_keymap, *us_shiftmap, *us_ctrlmap; + + hilkbd_cn_device = h; + + /* Default to US-ASCII keyboard. */ + kbd_cn_keymap = us_keymap; + kbd_cn_shiftmap = us_shiftmap; + kbd_cn_ctrlmap = us_ctrlmap; + + HILWAIT(h); + WRITEHILCMD(h, HIL_SETARR); + HILWAIT(h); + WRITEHILDATA(h, ar_format(KBD_ARR)); + HILWAIT(h); + WRITEHILCMD(h, HIL_READKBDLANG); + HILDATAWAIT(h); + lang = READHILDATA(h); + for (km = kbd_map; km->kbd_code; km++) { + if (km->kbd_code == lang) { + kbd_cn_keymap = km->kbd_keymap; + kbd_cn_shiftmap = km->kbd_shiftmap; + kbd_cn_ctrlmap = km->kbd_ctrlmap; + } + } + HILWAIT(h); + WRITEHILCMD(h, HIL_INTON); +} + +/* End of HIL console keyboard code. */ + /* * Recoginize and clear keyboard generated NMIs. * Returns 1 if it was ours, 0 otherwise. Note that we cannot use @@ -1335,7 +1399,7 @@ hilconfig(hilp) if (hilp->hl_kbdlang != KBD_SPECIAL) { struct kbdmap *km; - for (km = kbd_map; km->kbd_code; km++) + for (km = kbd_map; km->kbd_code; km++) { if (km->kbd_code == db) { hilp->hl_kbdlang = db; /* XXX */ @@ -1344,7 +1408,14 @@ hilconfig(hilp) kbd_ctrlmap = km->kbd_ctrlmap; kbd_ctrlshiftmap = km->kbd_ctrlshiftmap; kbd_stringmap = km->kbd_stringmap; + break; } + } + if (km->kbd_code == 0) { + printf( + "hilconfig: unknown keyboard type 0x%x, using default\n", + db); + } } splx(s); } diff --git a/sys/arch/hp300/dev/hil_keymaps.c b/sys/arch/hp300/dev/hil_keymaps.c index 03f8174dc95..a9b65e5b91f 100644 --- a/sys/arch/hp300/dev/hil_keymaps.c +++ b/sys/arch/hp300/dev/hil_keymaps.c @@ -1,3 +1,4 @@ +/* $OpenBSD: hil_keymaps.c,v 1.3 1997/01/12 15:12:42 downsj Exp $ */ /* $NetBSD: hil_keymaps.c,v 1.6 1995/12/06 22:13:23 thorpej Exp $ */ /* diff --git a/sys/arch/hp300/dev/hilioctl.h b/sys/arch/hp300/dev/hilioctl.h index c01b97855fc..54c7ba453c4 100644 --- a/sys/arch/hp300/dev/hilioctl.h +++ b/sys/arch/hp300/dev/hilioctl.h @@ -1,3 +1,4 @@ +/* $OpenBSD: hilioctl.h,v 1.2 1997/01/12 15:12:43 downsj Exp $ */ /* $NetBSD: hilioctl.h,v 1.6 1994/10/26 07:24:14 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/hilreg.h b/sys/arch/hp300/dev/hilreg.h index dd793af3cc7..0b09598d0b9 100644 --- a/sys/arch/hp300/dev/hilreg.h +++ b/sys/arch/hp300/dev/hilreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: hilreg.h,v 1.2 1997/01/12 15:12:44 downsj Exp $ */ /* $NetBSD: hilreg.h,v 1.5 1994/10/26 07:24:15 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/hilvar.h b/sys/arch/hp300/dev/hilvar.h index 078268a514a..6db06e20042 100644 --- a/sys/arch/hp300/dev/hilvar.h +++ b/sys/arch/hp300/dev/hilvar.h @@ -1,3 +1,4 @@ +/* $OpenBSD: hilvar.h,v 1.3 1997/01/12 15:12:44 downsj Exp $ */ /* $NetBSD: hilvar.h,v 1.11 1995/12/11 19:41:47 thorpej Exp $ */ /* diff --git a/sys/arch/hp300/dev/hpib.c b/sys/arch/hp300/dev/hpib.c index 4d39539f24f..fd8f0b969c8 100644 --- a/sys/arch/hp300/dev/hpib.c +++ b/sys/arch/hp300/dev/hpib.c @@ -1,4 +1,5 @@ -/* $NetBSD: hpib.c,v 1.9 1996/05/17 15:09:39 thorpej Exp $ */ +/* $OpenBSD: hpib.c,v 1.5 1997/01/12 15:12:45 downsj Exp $ */ +/* $NetBSD: hpib.c,v 1.12 1996/12/09 03:16:27 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -135,7 +136,8 @@ hpibattach(hc) hs->sc_sq.dq_forw = hs->sc_sq.dq_back = &hs->sc_sq; /* Establish the interrupt handler. */ - isrlink(hpibintr, hs, hc->hp_ipl, ISRPRI_BIO); + (void) isrlink(hpibintr, hs, hc->hp_ipl, ISRPRI_BIO); + dmacomputeipl(); /* Reset the controller, display what we've seen, and we're done. */ hpibreset(hc->hp_unit); diff --git a/sys/arch/hp300/dev/hpibvar.h b/sys/arch/hp300/dev/hpibvar.h index 3e1f6a3abed..81bf17c5579 100644 --- a/sys/arch/hp300/dev/hpibvar.h +++ b/sys/arch/hp300/dev/hpibvar.h @@ -1,3 +1,4 @@ +/* $OpenBSD: hpibvar.h,v 1.4 1997/01/12 15:12:45 downsj Exp $ */ /* $NetBSD: hpibvar.h,v 1.8 1996/02/14 02:44:31 thorpej Exp $ */ /* diff --git a/sys/arch/hp300/dev/if_le.c b/sys/arch/hp300/dev/if_le.c index 7c17d759f20..14e6a47e5c5 100644 --- a/sys/arch/hp300/dev/if_le.c +++ b/sys/arch/hp300/dev/if_le.c @@ -1,4 +1,5 @@ -/* $NetBSD: if_le.c,v 1.31 1996/05/09 21:11:47 thorpej Exp $ */ +/* $OpenBSD: if_le.c,v 1.6 1997/01/12 15:12:46 downsj Exp $ */ +/* $NetBSD: if_le.c,v 1.36 1996/12/17 08:41:13 thorpej Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -55,6 +56,7 @@ #include #endif +#include #include #include @@ -64,24 +66,39 @@ #include #endif +#ifndef NEWCONFIG #include +#endif #include #include +#include +#include +#include #include #include +#ifdef NEWCONFIG +int lematch __P((struct device *, struct cfdata *, void *)); +void leattach __P((struct device *, struct device *, void *)); + +struct cfattach le_ca = { + sizeof(struct le_softc), lematch, leattach +}; +#else /* ! NEWCONFIG */ #include "le.h" struct le_softc le_softc[NLE]; int lematch __P((struct hp_device *)); void leattach __P((struct hp_device *)); -int leintr __P((void *)); struct driver ledriver = { lematch, leattach, "le", }; +#endif /* NEWCONFIG */ + +int leintr __P((void *)); /* offsets for: ID, REGS, MEM, NVRAM */ int lestd[] = { 0, 0x4000, 0x8000, 0xC008 }; @@ -123,6 +140,20 @@ lerdcsr(sc, port) return (val); } +#ifdef NEWCONFIG +int +lematch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (da->da_id == DIO_DEVICE_ID_LAN) + return (1); + return (0); +} +#else /* ! NEWCONFIG */ int lematch(hd) struct hp_device *hd; @@ -139,32 +170,62 @@ lematch(hd) return (1); } +#endif /* NEWCONFIG */ /* * Interface exists: make available by filling in network interface * record. System will initialize the interface when it is ready * to accept packets. */ +#ifdef NEWCONFIG +void +leattach(parent, self, aux) + struct device *parent, *self; + void *aux; +#else /* ! NEWCONFIG */ void leattach(hd) struct hp_device *hd; +#endif /* NEWCONFIG */ { register struct lereg0 *ler0; +#ifdef NEWCONFIG + struct dio_attach_args *da = aux; + struct le_softc *lesc = (struct le_softc *)self; + caddr_t addr; +#else struct le_softc *lesc = &le_softc[hd->hp_unit]; + caddr_t addr = hd->hp_addr; +#endif /* NEWCONFIG */ struct am7990_softc *sc = &lesc->sc_am7990; char *cp; - int i; + int i, ipl; + +#ifdef NEWCONFIG + addr = iomap(dio_scodetopa(da->da_scode), da->da_size); + if (addr == 0) { + printf("\n%s: can't map LANCE registers\n", + sc->sc_dev.dv_xname); + return; + } +#endif /* NEWCONFIG */ - ler0 = lesc->sc_r0 = (struct lereg0 *)(lestd[0] + (int)hd->hp_addr); + ler0 = lesc->sc_r0 = (struct lereg0 *)(lestd[0] + (int)addr); ler0->ler0_id = 0xFF; DELAY(100); +#ifdef NEWCONFIG + ipl = DIO_IPL(addr); + printf(" ipl %d", ipl); +#else /* ! NEWCONFIG */ /* XXXX kluge for now */ - sc->sc_dev.dv_unit = hd->hp_unit; - sprintf(sc->sc_dev.dv_xname, "%s%d", le_cd.cd_name, hd->hp_unit); + hd->hp_dev.dv_class = DV_IFNET; + bcopy(&hd->hp_dev, &sc->sc_dev, sizeof(struct device)); + ipl = hd->hp_ipl; +#endif /* NEWCONFIG */ - lesc->sc_r1 = (struct lereg1 *)(lestd[1] + (int)hd->hp_addr); - sc->sc_mem = (void *)(lestd[2] + (int)hd->hp_addr); + lesc->sc_r1 = (struct lereg1 *)(lestd[1] + (int)addr); + sc->sc_mem = (void *)(lestd[2] + (int)addr); sc->sc_conf3 = LE_C3_BSWP; sc->sc_addr = 0; sc->sc_memsize = 16384; @@ -172,7 +233,7 @@ leattach(hd) /* * Read the ethernet address off the board, one nibble at a time. */ - cp = (char *)(lestd[3] + (int)hd->hp_addr); + cp = (char *)(lestd[3] + (int)addr); for (i = 0; i < sizeof(sc->sc_arpcom.ac_enaddr); i++) { sc->sc_arpcom.ac_enaddr[i] = (*++cp & 0xF) << 4; cp++; @@ -193,7 +254,7 @@ leattach(hd) am7990_config(sc); /* Establish the interrupt handler. */ - isrlink(leintr, sc, hd->hp_ipl, ISRPRI_NET); + (void) isrlink(leintr, sc, ipl, ISRPRI_NET); ler0->ler0_status = LE_IE; } diff --git a/sys/arch/hp300/dev/if_lereg.h b/sys/arch/hp300/dev/if_lereg.h index b745ad6ee06..7bb7fcc24c9 100644 --- a/sys/arch/hp300/dev/if_lereg.h +++ b/sys/arch/hp300/dev/if_lereg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: if_lereg.h,v 1.3 1997/01/12 15:12:46 downsj Exp $ */ /* $NetBSD: if_lereg.h,v 1.8 1995/12/10 00:49:36 mycroft Exp $ */ /* diff --git a/sys/arch/hp300/dev/if_levar.h b/sys/arch/hp300/dev/if_levar.h index 40d64ab8e1f..7e1f2f7523f 100644 --- a/sys/arch/hp300/dev/if_levar.h +++ b/sys/arch/hp300/dev/if_levar.h @@ -1,4 +1,5 @@ -/* $NetBSD: if_levar.h,v 1.4 1996/05/07 00:58:00 thorpej Exp $ */ +/* $OpenBSD: if_levar.h,v 1.3 1997/01/12 15:12:47 downsj Exp $ */ +/* $NetBSD: if_levar.h,v 1.5 1996/12/17 08:41:14 thorpej Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -49,7 +50,9 @@ struct le_softc { struct am7990_softc sc_am7990; /* glue to MI code */ +#ifndef NEWCONFIG struct hp_device *sc_hd; +#endif struct isr sc_isr; struct lereg0 *sc_r0; /* DIO registers */ struct lereg1 *sc_r1; /* LANCE registers */ diff --git a/sys/arch/hp300/dev/intio.c b/sys/arch/hp300/dev/intio.c new file mode 100644 index 00000000000..af6a5a1bb02 --- /dev/null +++ b/sys/arch/hp300/dev/intio.c @@ -0,0 +1,115 @@ +/* $OpenBSD: intio.c,v 1.1 1997/01/12 15:12:47 downsj Exp $ */ +/* $NetBSD: intio.c,v 1.1 1996/12/17 08:41:15 thorpej Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Autoconfiguration support for hp300 internal i/o space. + */ + +#include +#include +#include + +#include + +int intiomatch __P((struct device *, struct cfdata *, void *)); +void intioattach __P((struct device *, struct device *, void *)); +int intioprint __P((void *, const char *)); +int intiosearch __P((struct device *, struct cfdata *, void *)); + +struct cfattach intio_ca = { + sizeof(struct device), intiomatch, intioattach +}; + +struct cfdriver intio_cd = { + NULL, "intio", DV_DULL +}; + +int +intiomatch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + static int intio_matched = 0; + + /* Allow only one instance. */ + if (intio_matched) + return (0); + + intio_matched = 1; + return (1); +} + +void +intioattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + + printf("\n"); + + /* Search for and attach children. */ + config_search(intiosearch, self, NULL); +} + +int +intioprint(aux, pnp) + void *aux; + const char *pnp; +{ + struct intio_attach_args *ia = aux; + + if (ia->ia_addr != 0) + printf(" addr %p", ia->ia_addr); + return (UNCONF); +} + +int +intiosearch(parent, cf, aux) + struct device *parent; + struct cfdata *cf; + void *aux; +{ + struct intio_attach_args ia; + + bzero(&ia, sizeof(ia)); + if ((*cf->cf_attach->ca_match)(parent, cf, &ia) > 0) + config_attach(parent, cf, &ia, intioprint); + return (0); +} diff --git a/sys/arch/hp300/dev/intiovar.h b/sys/arch/hp300/dev/intiovar.h new file mode 100644 index 00000000000..e6dc6dbc0e2 --- /dev/null +++ b/sys/arch/hp300/dev/intiovar.h @@ -0,0 +1,50 @@ +/* $OpenBSD: intiovar.h,v 1.1 1997/01/12 15:12:48 downsj Exp $ */ +/* $NetBSD: intiovar.h,v 1.1 1996/12/17 08:41:15 thorpej Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Autoconfiguration definitions and prototypes for the hp300 + * internal i/o space. + */ + +/* + * Arguments used to attach a device to the internal i/o space. + */ +struct intio_attach_args { + caddr_t ia_addr; /* physical address */ +}; diff --git a/sys/arch/hp300/dev/iotypes.h b/sys/arch/hp300/dev/iotypes.h index e088f61ef94..c21e717af95 100644 --- a/sys/arch/hp300/dev/iotypes.h +++ b/sys/arch/hp300/dev/iotypes.h @@ -1,3 +1,4 @@ +/* $OpenBSD: iotypes.h,v 1.2 1997/01/12 15:12:48 downsj Exp $ */ /* $NetBSD: iotypes.h,v 1.2 1994/10/26 07:24:24 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/ite.c b/sys/arch/hp300/dev/ite.c index a2416c6d8ca..4217dce8d07 100644 --- a/sys/arch/hp300/dev/ite.c +++ b/sys/arch/hp300/dev/ite.c @@ -1,4 +1,5 @@ -/* $NetBSD: ite.c,v 1.29.4.1 1996/06/06 15:39:12 thorpej Exp $ */ +/* $OpenBSD: ite.c,v 1.6 1997/01/12 15:12:49 downsj Exp $ */ +/* $NetBSD: ite.c,v 1.34 1996/12/17 08:41:16 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -48,12 +49,6 @@ * This is a very rudimentary. Much more can be abstracted out of * the hardware dependent routines. */ -#include "ite.h" -#if NITE > 0 - -#include "grf.h" -#undef NITE -#define NITE NGRF #include #include @@ -62,6 +57,7 @@ #include #include #include +#include #include @@ -90,9 +86,23 @@ */ int iteburst = 64; -int nite = NITE; struct ite_data *kbd_ite = NULL; -struct ite_softc ite_softc[NITE]; + +#ifdef NEWCONFIG +int itematch __P((struct device *, struct cfdata *, void *)); +void iteattach __P((struct device *, struct device *, void *)); + +struct cfattach ite_ca = { + sizeof(struct ite_softc), itematch, iteattach +}; + +struct cfdriver ite_cd = { + NULL, "ite", DV_TTY +}; +#else /* ! NEWCONFIG */ +#include "grf.h" +struct ite_softc ite_softc[NGRF]; +#endif /* NEWCONFIG */ /* * Terminal emulator state information, statically allocated @@ -116,7 +126,7 @@ void itestart __P((struct tty *)); * found. Secondary displays alloc the attribute buffer as needed. * Size is based on a 68x128 display, which is currently our largest. */ -u_char console_attributes[0x2200]; +u_char ite_console_attributes[0x2200]; #define ite_erasecursor(ip, sp) { \ if ((ip)->flags & ITE_CURSORON) \ @@ -131,6 +141,57 @@ u_char console_attributes[0x2200]; (*(sp)->ite_cursor)((ip), MOVE_CURSOR); \ } +#ifdef NEWCONFIG +int +itematch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + + return (1); +} + +void +iteattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct ite_softc *ite = (struct ite_softc *)self; + struct grf_softc *grf = (struct grf_softc *)parent; + struct grfdev_attach_args *ga = aux; + + /* Allocate the ite_data. */ + if (ga->ga_isconsole) { + ite->sc_data = &ite_cn; + printf(": console"); + + /* + * We didn't know which unit this would be during + * the console probe, so we have to fixup cn_dev here. + */ + cn_tab->cn_dev = makedev(ite_major(), self->dv_unit); + } else { + ite->sc_data = + (struct ite_data *)malloc(sizeof(struct ite_data), + M_DEVBUF, M_NOWAIT); + if (ite->sc_data == NULL) { + printf("\n%s: malloc for ite_data failed\n", + ite->sc_dev.dv_xname); + return; + } + bzero(ite->sc_data, sizeof(struct ite_data)); + } + + /* + * Cross-reference the ite and the grf. + */ + ite->sc_grf = grf; + grf->sc_ite = ite; + + printf("\n"); +} +#else /* ! NEWCONFIG */ /* * Dummy for pseudo-device config. */ @@ -182,6 +243,7 @@ ite_attach_grf(unit, isconsole) printf("ite%d at grf%d: attached\n", unit, unit); } +#endif /* NEWCONFIG */ /* * Perform functions necessary to setup device as a terminal emulator. @@ -290,11 +352,22 @@ iteopen(dev, mode, devtype, p) { int unit = ITEUNIT(dev); struct tty *tp; - struct ite_softc *sc = &ite_softc[unit]; - struct ite_data *ip = sc->sc_data; + struct ite_softc *sc; + struct ite_data *ip; int error; int first = 0; +#ifdef NEWCONFIG + if (unit >= ite_cd.cd_ndevs || + (sc = ite_cd.cd_devs[unit]) == NULL) + return (ENXIO); +#else + if (unit >= NGRF) + return (ENXIO); + sc = &ite_softc[unit]; +#endif + ip = sc->sc_data; + if (ip->tty == NULL) { tp = ip->tty = ttymalloc(); tty_attach(tp); @@ -338,7 +411,11 @@ iteclose(dev, flag, mode, p) int flag, mode; struct proc *p; { +#ifdef NEWCONFIG + struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)]; +#else struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; +#endif struct ite_data *ip = sc->sc_data; struct tty *tp = ip->tty; @@ -359,7 +436,11 @@ iteread(dev, uio, flag) struct uio *uio; int flag; { +#ifdef NEWCONFIG + struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)]; +#else struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; +#endif struct tty *tp = sc->sc_data->tty; return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); @@ -371,7 +452,11 @@ itewrite(dev, uio, flag) struct uio *uio; int flag; { +#ifdef NEWCONFIG + struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)]; +#else struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; +#endif struct tty *tp = sc->sc_data->tty; return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); @@ -381,7 +466,11 @@ struct tty * itetty(dev) dev_t dev; { +#ifdef NEWCONFIG + struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)]; +#else struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; +#endif return (sc->sc_data->tty); } @@ -394,7 +483,11 @@ iteioctl(dev, cmd, addr, flag, p) int flag; struct proc *p; { +#ifdef NEWCONFIG + struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)]; +#else struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; +#endif struct ite_data *ip = sc->sc_data; struct tty *tp = ip->tty; int error; @@ -417,7 +510,11 @@ itestart(tp) struct ite_softc *sc; struct ite_data *ip; +#ifdef NEWCONFIG + sc = ite_cd.cd_devs[ITEUNIT(tp->t_dev)]; +#else sc = &ite_softc[ITEUNIT(tp->t_dev)]; +#endif ip = sc->sc_data; /* @@ -937,6 +1034,31 @@ ite_major() * framebuffer drivers. */ +void +itecninit(gp, isw) + struct grf_data *gp; + struct itesw *isw; +{ + extern void kbdcninit __P((void)); /* XXX */ + struct ite_data *ip = &ite_cn; + + /* + * Set up required ite data and initialize ite. + */ + ip->isw = isw; + ip->grf = gp; + ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS; + ip->attrbuf = ite_console_attributes; + iteinit(ip); + + /* + * Initialize the console keyboard. + */ + kbdcninit(); + + kbd_ite = ip; /* XXX */ +} + /*ARGSUSED*/ int itecngetc(dev) @@ -945,16 +1067,16 @@ itecngetc(dev) register int c; int stat; - c = kbdgetc(0, &stat); /* XXX always read from keyboard 0 for now */ + c = kbdgetc(&stat); switch ((stat >> KBD_SSHIFT) & KBD_SMASK) { case KBD_SHIFT: - c = kbd_shiftmap[c & KBD_CHARMASK]; + c = kbd_cn_shiftmap[c & KBD_CHARMASK]; break; case KBD_CTRL: - c = kbd_ctrlmap[c & KBD_CHARMASK]; + c = kbd_cn_ctrlmap[c & KBD_CHARMASK]; break; case KBD_KEY: - c = kbd_keymap[c & KBD_CHARMASK]; + c = kbd_cn_keymap[c & KBD_CHARMASK]; break; default: c = 0; @@ -979,4 +1101,3 @@ itecnputc(dev, c) } iteputchar(c, ip); } -#endif diff --git a/sys/arch/hp300/dev/ite_dv.c b/sys/arch/hp300/dev/ite_dv.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/sys/arch/hp300/dev/ite_gb.c b/sys/arch/hp300/dev/ite_gb.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/sys/arch/hp300/dev/ite_hy.c b/sys/arch/hp300/dev/ite_hy.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/sys/arch/hp300/dev/ite_rb.c b/sys/arch/hp300/dev/ite_rb.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/sys/arch/hp300/dev/ite_subr.c b/sys/arch/hp300/dev/ite_subr.c index dcf26adae6d..fdfba6aa83c 100644 --- a/sys/arch/hp300/dev/ite_subr.c +++ b/sys/arch/hp300/dev/ite_subr.c @@ -1,4 +1,5 @@ -/* $NetBSD: ite_subr.c,v 1.6 1996/02/24 00:55:29 thorpej Exp $ */ +/* $OpenBSD: ite_subr.c,v 1.3 1997/01/12 15:12:51 downsj Exp $ */ +/* $NetBSD: ite_subr.c,v 1.7 1996/12/17 08:41:17 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -42,15 +43,13 @@ * @(#)ite_subr.c 8.2 (Berkeley) 1/12/94 */ -#include "ite.h" -#if NITE > 0 - #include #include #include #include #include #include +#include #include #include @@ -152,4 +151,3 @@ ite_writeglyph(ip, fbmem, glyphp) fbmem += ip->fbwidth; } } -#endif diff --git a/sys/arch/hp300/dev/ite_tc.c b/sys/arch/hp300/dev/ite_tc.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/sys/arch/hp300/dev/itereg.h b/sys/arch/hp300/dev/itereg.h index f3e7a767ef2..3ccb0c0f88e 100644 --- a/sys/arch/hp300/dev/itereg.h +++ b/sys/arch/hp300/dev/itereg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: itereg.h,v 1.2 1997/01/12 15:12:52 downsj Exp $ */ /* $NetBSD: itereg.h,v 1.5 1994/10/26 07:24:39 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/itevar.h b/sys/arch/hp300/dev/itevar.h index 53e43760f17..2bff7f73c50 100644 --- a/sys/arch/hp300/dev/itevar.h +++ b/sys/arch/hp300/dev/itevar.h @@ -1,4 +1,5 @@ -/* $NetBSD: itevar.h,v 1.9 1996/02/24 00:55:31 thorpej Exp $ */ +/* $OpenBSD: itevar.h,v 1.5 1997/01/12 15:12:52 downsj Exp $ */ +/* $NetBSD: itevar.h,v 1.12 1997/01/09 01:07:59 scottr Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -42,6 +43,7 @@ * @(#)itevar.h 8.1 (Berkeley) 6/10/93 */ +#ifdef _KERNEL #define ITEUNIT(dev) minor(dev) #define getbyte(ip, offset) \ @@ -88,9 +90,11 @@ struct itesw { }; struct ite_softc { + struct device sc_dev; /* generic device info */ struct ite_data *sc_data; /* terminal state info */ struct grf_softc *sc_grf; /* pointer to framebuffer */ }; +#endif /* Flags */ #define ITE_ALIVE 0x01 /* hardware exists */ @@ -192,7 +196,6 @@ extern struct ite_data ite_cn; /* ite_data for console device */ extern struct ite_data *kbd_ite; /* XXX */ extern struct ite_softc ite_softc[]; extern struct itesw itesw[]; -extern u_char console_attributes[]; extern int nitesw; /* ite.c prototypes */ @@ -200,6 +203,7 @@ void ite_attach_grf __P((int, int)); int iteon __P((struct ite_data *, int)); void iteoff __P((struct ite_data *, int)); void itefilter __P((char, char)); +void itecninit __P((struct grf_data *, struct itesw *)); int ite_major __P((void)); /* ite_subr.c prototypes */ diff --git a/sys/arch/hp300/dev/kbdmap.h b/sys/arch/hp300/dev/kbdmap.h index 38511760c51..c48ce3adcea 100644 --- a/sys/arch/hp300/dev/kbdmap.h +++ b/sys/arch/hp300/dev/kbdmap.h @@ -1,4 +1,5 @@ -/* $NetBSD: kbdmap.h,v 1.6 1995/12/06 22:13:26 thorpej Exp $ */ +/* $OpenBSD: kbdmap.h,v 1.3 1997/01/12 15:12:53 downsj Exp $ */ +/* $NetBSD: kbdmap.h,v 1.7 1996/10/05 05:22:11 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -58,11 +59,16 @@ struct kbdmap { #ifdef _KERNEL /* XXX: ITE interface */ -char *kbd_keymap; -char *kbd_shiftmap; -char *kbd_ctrlmap; -char *kbd_ctrlshiftmap; -char **kbd_stringmap; +extern char *kbd_keymap; +extern char *kbd_shiftmap; +extern char *kbd_ctrlmap; +extern char *kbd_ctrlshiftmap; +extern char **kbd_stringmap; + +/* XXX: itecngetc() interface */ +extern char *kbd_cn_keymap; +extern char *kbd_cn_shiftmap; +extern char *kbd_cn_ctrlmap; extern struct kbdmap kbd_map[]; #endif diff --git a/sys/arch/hp300/dev/maskbits.h b/sys/arch/hp300/dev/maskbits.h index 4c943283027..948197c36e1 100644 --- a/sys/arch/hp300/dev/maskbits.h +++ b/sys/arch/hp300/dev/maskbits.h @@ -1,3 +1,4 @@ +/* $OpenBSD: maskbits.h,v 1.2 1997/01/12 15:12:53 downsj Exp $ */ /* $NetBSD: maskbits.h,v 1.2 1994/10/26 07:24:43 cgd Exp $ */ /*- diff --git a/sys/arch/hp300/dev/mt.c b/sys/arch/hp300/dev/mt.c index 7f4574b8eee..a1bd5d77b1c 100644 --- a/sys/arch/hp300/dev/mt.c +++ b/sys/arch/hp300/dev/mt.c @@ -1,4 +1,5 @@ -/* $NetBSD: mt.c,v 1.3 1996/02/14 02:44:40 thorpej Exp $ */ +/* $OpenBSD: mt.c,v 1.4 1997/01/12 15:12:54 downsj Exp $ */ +/* $NetBSD: mt.c,v 1.6 1996/10/14 07:14:18 thorpej Exp $ */ /* * Copyright (c) 1992, The University of Utah and @@ -149,6 +150,9 @@ mtattach(hd) sc->sc_dq.dq_unit = unit; sc->sc_dq.dq_slave = slave; sc->sc_dq.dq_driver = &mtdriver; + + /* XXX Set device class. */ + hd->hp_dev.dv_class = DV_TAPE; } /* diff --git a/sys/arch/hp300/dev/mtreg.h b/sys/arch/hp300/dev/mtreg.h index 1a14952fff2..84fb799ae81 100644 --- a/sys/arch/hp300/dev/mtreg.h +++ b/sys/arch/hp300/dev/mtreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: mtreg.h,v 1.2 1997/01/12 15:12:55 downsj Exp $ */ /* $NetBSD: mtreg.h,v 1.1 1995/10/02 00:28:22 thorpej Exp $ */ /* diff --git a/sys/arch/hp300/dev/nhpib.c b/sys/arch/hp300/dev/nhpib.c index e1e7f7c9c70..edf606177d7 100644 --- a/sys/arch/hp300/dev/nhpib.c +++ b/sys/arch/hp300/dev/nhpib.c @@ -1,4 +1,5 @@ -/* $NetBSD: nhpib.c,v 1.11 1996/05/18 23:57:01 thorpej Exp $ */ +/* $OpenBSD: nhpib.c,v 1.5 1997/01/12 15:12:56 downsj Exp $ */ +/* $NetBSD: nhpib.c,v 1.13 1996/10/13 03:14:19 christos Exp $ */ /* * Copyright (c) 1982, 1990, 1993 diff --git a/sys/arch/hp300/dev/nhpibreg.h b/sys/arch/hp300/dev/nhpibreg.h index 495546a84e8..e80cdabfaa8 100644 --- a/sys/arch/hp300/dev/nhpibreg.h +++ b/sys/arch/hp300/dev/nhpibreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: nhpibreg.h,v 1.2 1997/01/12 15:12:56 downsj Exp $ */ /* $NetBSD: nhpibreg.h,v 1.5 1995/01/07 10:30:15 mycroft Exp $ */ /* diff --git a/sys/arch/hp300/dev/ppi.c b/sys/arch/hp300/dev/ppi.c index 9560cd4d93a..8a3a5cddc57 100644 --- a/sys/arch/hp300/dev/ppi.c +++ b/sys/arch/hp300/dev/ppi.c @@ -1,4 +1,5 @@ -/* $NetBSD: ppi.c,v 1.8 1996/02/14 02:44:49 thorpej Exp $ */ +/* $OpenBSD: ppi.c,v 1.4 1997/01/12 15:12:57 downsj Exp $ */ +/* $NetBSD: ppi.c,v 1.10 1996/10/13 03:14:20 christos Exp $ */ /* * Copyright (c) 1982, 1990, 1993 diff --git a/sys/arch/hp300/dev/ppiioctl.h b/sys/arch/hp300/dev/ppiioctl.h index c5d6ea01f9e..52d0dcf3cff 100644 --- a/sys/arch/hp300/dev/ppiioctl.h +++ b/sys/arch/hp300/dev/ppiioctl.h @@ -1,3 +1,4 @@ +/* $OpenBSD: ppiioctl.h,v 1.2 1997/01/12 15:12:58 downsj Exp $ */ /* $NetBSD: ppiioctl.h,v 1.4 1994/10/26 07:24:48 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/rd.c b/sys/arch/hp300/dev/rd.c index 8e42519d2f5..e34026ff1b3 100644 --- a/sys/arch/hp300/dev/rd.c +++ b/sys/arch/hp300/dev/rd.c @@ -1,4 +1,5 @@ -/* $NetBSD: rd.c,v 1.20.4.1 1996/06/06 16:22:01 thorpej Exp $ */ +/* $OpenBSD: rd.c,v 1.7 1997/01/12 15:12:58 downsj Exp $ */ +/* $NetBSD: rd.c,v 1.26 1997/01/07 09:29:32 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -274,6 +275,9 @@ rdattach(hd) if (rddebug & RDB_ERROR) rderrthresh = 0; #endif + + /* XXX Set device class. */ + hd->hp_dev.dv_class = DV_DISK; } int @@ -486,7 +490,7 @@ rdopen(dev, flags, mode, p) { register int unit = rdunit(dev); register struct rd_softc *rs = &rd_softc[unit]; - int error, mask; + int error, mask, part; if (unit >= NRD || (rs->sc_flags & RDF_ALIVE) == 0) return(ENXIO); @@ -511,12 +515,27 @@ rdopen(dev, flags, mode, p) return(error); } - mask = 1 << rdpart(dev); - if (mode == S_IFCHR) + part = rdpart(dev); + mask = 1 << part; + + /* Check that the partition exists. */ + if (part != RAW_PART && + (part > rs->sc_dkdev.dk_label->d_npartitions || + rs->sc_dkdev.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) + return (ENXIO); + + /* Ensure only one open at a time. */ + switch (mode) { + case S_IFCHR: rs->sc_dkdev.dk_copenmask |= mask; - else + break; + case S_IFBLK: rs->sc_dkdev.dk_bopenmask |= mask; - rs->sc_dkdev.dk_openmask |= mask; + break; + } + rs->sc_dkdev.dk_openmask = + rs->sc_dkdev.dk_copenmask | rs->sc_dkdev.dk_bopenmask; + return(0); } @@ -568,6 +587,7 @@ rdstrategy(bp) register struct partition *pinfo; register daddr_t bn; register int sz, s; + int offset; #ifdef DEBUG if (rddebug & RDB_FOLLOW) @@ -578,30 +598,41 @@ rdstrategy(bp) bn = bp->b_blkno; sz = howmany(bp->b_bcount, DEV_BSIZE); pinfo = &rs->sc_dkdev.dk_label->d_partitions[rdpart(bp->b_dev)]; - if (bn < 0 || bn + sz > pinfo->p_size) { - sz = pinfo->p_size - bn; - if (sz == 0) { - bp->b_resid = bp->b_bcount; - goto done; - } - if (sz < 0) { - bp->b_error = EINVAL; - goto bad; + + /* Don't perform partition translation on RAW_PART. */ + offset = (rdpart(bp->b_dev) == RAW_PART) ? 0 : pinfo->p_offset; + + if (rdpart(bp->b_dev) != RAW_PART) { + /* + * XXX This block of code belongs in + * XXX bounds_check_with_label() + */ + + if (bn < 0 || bn + sz > pinfo->p_size) { + sz = pinfo->p_size - bn; + if (sz == 0) { + bp->b_resid = bp->b_bcount; + goto done; + } + if (sz < 0) { + bp->b_error = EINVAL; + goto bad; + } + bp->b_bcount = dbtob(sz); } - bp->b_bcount = dbtob(sz); - } - /* - * Check for write to write protected label - */ - if (bn + pinfo->p_offset <= LABELSECTOR && + /* + * Check for write to write protected label + */ + if (bn + offset <= LABELSECTOR && #if LABELSECTOR != 0 - bn + pinfo->p_offset + sz > LABELSECTOR && + bn + offset + sz > LABELSECTOR && #endif - !(bp->b_flags & B_READ) && !(rs->sc_flags & RDF_WLABEL)) { - bp->b_error = EROFS; - goto bad; + !(bp->b_flags & B_READ) && !(rs->sc_flags & RDF_WLABEL)) { + bp->b_error = EROFS; + goto bad; + } } - bp->b_cylin = bn + pinfo->p_offset; + bp->b_cylin = bn + offset; s = splbio(); disksort(dp, bp); if (dp->b_active == 0) { @@ -1115,75 +1146,108 @@ rdprinterr(str, err, tab) } #endif +static int rddoingadump; /* simple mutex */ + /* * Non-interrupt driven, non-dma dump routine. */ int -rddump(dev) +rddump(dev, blkno, va, size) dev_t dev; + daddr_t blkno; + caddr_t va; + size_t size; { - int part = rdpart(dev); - int unit = rdunit(dev); - register struct rd_softc *rs = &rd_softc[unit]; - register struct hp_device *hp = rs->sc_hd; - register struct partition *pinfo; - register daddr_t baddr; - register int maddr, pages, i; + int sectorsize; /* size of a disk sector */ + int nsects; /* number of sectors in partition */ + int sectoff; /* sector offset of partition */ + int totwrt; /* total number of sectors left to write */ + int nwrt; /* current number of sectors to write */ + int unit, part; + struct rd_softc *rs; + struct hp_device *hp; + struct disklabel *lp; char stat; - extern int lowram, dumpsize; -#ifdef DEBUG - extern int pmapdebug; - pmapdebug = 0; -#endif - /* is drive ok? */ - if (unit >= NRD || (rs->sc_flags & RDF_ALIVE) == 0) + /* Check for recursive dump; if so, punt. */ + if (rddoingadump) + return (EFAULT); + rddoingadump = 1; + + /* Decompose unit and partition. */ + unit = rdunit(dev); + part = rdpart(dev); + + /* Make sure dump device is ok. */ + if (unit >= NRD) + return (ENXIO); + rs = &rd_softc[unit]; + if ((rs->sc_flags & RDF_ALIVE) == 0) return (ENXIO); - pinfo = &rs->sc_dkdev.dk_label->d_partitions[part]; - /* dump parameters in range? */ - if (dumplo < 0 || dumplo >= pinfo->p_size || - pinfo->p_fstype != FS_SWAP) + hp = rs->sc_hd; + + /* + * Convert to disk sectors. Request must be a multiple of size. + */ + lp = rs->sc_dkdev.dk_label; + sectorsize = lp->d_secsize; + if ((size % sectorsize) != 0) + return (EFAULT); + totwrt = size / sectorsize; + blkno = dbtob(blkno) / sectorsize; /* blkno in DEV_BSIZE units */ + + nsects = lp->d_partitions[part].p_size; + sectoff = lp->d_partitions[part].p_offset; + + /* Check transfer bounds against partition size. */ + if ((blkno < 0) || (blkno + totwrt) > nsects) return (EINVAL); - pages = dumpsize; - if (dumplo + ctod(pages) > pinfo->p_size) - pages = dtoc(pinfo->p_size - dumplo); - maddr = lowram; - baddr = dumplo + pinfo->p_offset; - /* HPIB idle? */ - if (!hpibreq(&rs->sc_dq)) { - hpibreset(hp->hp_ctlr); - rdreset(rs, rs->sc_hd); - printf("[ drive %d reset ] ", unit); - } - for (i = 0; i < pages; i++) { -#define NPGMB (1024*1024/NBPG) - /* print out how many Mbs we have dumped */ - if (i && (i % NPGMB) == 0) - printf("%d ", i / NPGMB); -#undef NPBMG + + /* Offset block number to start of partition. */ + blkno += sectoff; + + while (totwrt > 0) { + nwrt = totwrt; /* XXX */ +#ifndef RD_DUMP_NOT_TRUSTED + /* + * Fill out and send HPIB command. + */ rs->sc_ioc.c_unit = C_SUNIT(rs->sc_punit); rs->sc_ioc.c_volume = C_SVOL(0); rs->sc_ioc.c_saddr = C_SADDR; rs->sc_ioc.c_hiaddr = 0; - rs->sc_ioc.c_addr = RDBTOS(baddr); + rs->sc_ioc.c_addr = RDBTOS(blkno); rs->sc_ioc.c_nop2 = C_NOP; rs->sc_ioc.c_slen = C_SLEN; - rs->sc_ioc.c_len = NBPG; + rs->sc_ioc.c_len = nwrt * sectorsize; rs->sc_ioc.c_cmd = C_WRITE; hpibsend(hp->hp_ctlr, hp->hp_slave, C_CMD, &rs->sc_ioc.c_unit, sizeof(rs->sc_ioc)-2); if (hpibswait(hp->hp_ctlr, hp->hp_slave)) return (EIO); - pmap_enter(pmap_kernel(), (vm_offset_t)vmmap, maddr, - VM_PROT_READ, TRUE); - hpibsend(hp->hp_ctlr, hp->hp_slave, C_EXEC, vmmap, NBPG); + + /* + * Send the data. + */ + hpibsend(hp->hp_ctlr, hp->hp_slave, C_EXEC, va, + nwrt * sectorsize); (void) hpibswait(hp->hp_ctlr, hp->hp_slave); hpibrecv(hp->hp_ctlr, hp->hp_slave, C_QSTAT, &stat, 1); if (stat) return (EIO); - maddr += NBPG; - baddr += ctod(1); +#else /* RD_DUMP_NOT_TRUSTED */ + /* Let's just talk about this first... */ + printf("%s: dump addr %p, blk %d\n", hp->hp_xname, + va, blkno); + delay(500 * 1000); /* half a second */ +#endif /* RD_DUMP_NOT_TRUSTED */ + + /* update block count */ + totwrt -= nwrt; + blkno += nwrt; + va += sectorsize * nwrt; } + rddoingadump = 0; return (0); } #endif diff --git a/sys/arch/hp300/dev/rd_compat.c b/sys/arch/hp300/dev/rd_compat.c index 4adea53bcbd..ed607f2dbbc 100644 --- a/sys/arch/hp300/dev/rd_compat.c +++ b/sys/arch/hp300/dev/rd_compat.c @@ -1,3 +1,4 @@ +/* $OpenBSD: rd_compat.c,v 1.4 1997/01/12 15:12:59 downsj Exp $ */ /* $NetBSD: rd_compat.c,v 1.5 1996/01/07 22:02:14 thorpej Exp $ */ /* diff --git a/sys/arch/hp300/dev/rdreg.h b/sys/arch/hp300/dev/rdreg.h index 65cf20a4569..ad1c9ccf478 100644 --- a/sys/arch/hp300/dev/rdreg.h +++ b/sys/arch/hp300/dev/rdreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: rdreg.h,v 1.4 1997/01/12 15:13:00 downsj Exp $ */ /* $NetBSD: rdreg.h,v 1.7 1996/02/09 18:00:37 scottr Exp $ */ /* diff --git a/sys/arch/hp300/dev/rdvar.h b/sys/arch/hp300/dev/rdvar.h index d7bd8637184..064a544503d 100644 --- a/sys/arch/hp300/dev/rdvar.h +++ b/sys/arch/hp300/dev/rdvar.h @@ -1,4 +1,5 @@ -/* $NetBSD: rdvar.h,v 1.4.4.1 1996/06/06 16:22:03 thorpej Exp $ */ +/* $OpenBSD: rdvar.h,v 1.5 1997/01/12 15:13:00 downsj Exp $ */ +/* $NetBSD: rdvar.h,v 1.5 1996/06/06 16:17:42 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. diff --git a/sys/arch/hp300/dev/scsi.c b/sys/arch/hp300/dev/scsi.c index 942e4a51fe6..ba9d7c0f1a8 100644 --- a/sys/arch/hp300/dev/scsi.c +++ b/sys/arch/hp300/dev/scsi.c @@ -1,4 +1,5 @@ -/* $NetBSD: scsi.c,v 1.10 1996/05/18 23:57:03 thorpej Exp $ */ +/* $OpenBSD: scsi.c,v 1.5 1997/01/12 15:13:01 downsj Exp $ */ +/* $NetBSD: scsi.c,v 1.13 1996/12/09 03:16:26 thorpej Exp $ */ /* * Copyright (c) 1990, 1993 @@ -68,7 +69,6 @@ #define SCSI_DATA_WAIT 10000 /* wait per data in/out step */ #define SCSI_INIT_WAIT 50000 /* wait per step (both) during init */ -extern void isrlink(); extern void _insque(); extern void _remque(); @@ -262,7 +262,8 @@ scsiattach(hc) hs->sc_sq.dq_forw = hs->sc_sq.dq_back = &hs->sc_sq; /* Establish the interrupt handler. */ - isrlink(scsiintr, hs, hc->hp_ipl, ISRPRI_BIO); + (void) isrlink(scsiintr, hs, hc->hp_ipl, ISRPRI_BIO); + dmacomputeipl(); /* Reset the controller. */ scsireset(hc->hp_unit); diff --git a/sys/arch/hp300/dev/scsireg.h b/sys/arch/hp300/dev/scsireg.h index 571861ebcab..2ddbc961f4f 100644 --- a/sys/arch/hp300/dev/scsireg.h +++ b/sys/arch/hp300/dev/scsireg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: scsireg.h,v 1.2 1997/01/12 15:13:02 downsj Exp $ */ /* $NetBSD: scsireg.h,v 1.4 1994/10/26 07:24:59 cgd Exp $ */ /* diff --git a/sys/arch/hp300/dev/scsivar.h b/sys/arch/hp300/dev/scsivar.h index 6f7db737286..a9226295744 100644 --- a/sys/arch/hp300/dev/scsivar.h +++ b/sys/arch/hp300/dev/scsivar.h @@ -1,3 +1,4 @@ +/* $OpenBSD: scsivar.h,v 1.3 1997/01/12 15:13:02 downsj Exp $ */ /* $NetBSD: scsivar.h,v 1.5 1995/12/02 18:22:14 thorpej Exp $ */ /* diff --git a/sys/arch/hp300/dev/sd.c b/sys/arch/hp300/dev/sd.c index 75121b1b6dc..713833396f3 100644 --- a/sys/arch/hp300/dev/sd.c +++ b/sys/arch/hp300/dev/sd.c @@ -1,4 +1,5 @@ -/* $NetBSD: sd.c,v 1.22.4.1 1996/06/06 16:22:04 thorpej Exp $ */ +/* $OpenBSD: sd.c,v 1.6 1997/01/12 15:13:03 downsj Exp $ */ +/* $NetBSD: sd.c,v 1.28 1997/01/07 09:29:30 thorpej Exp $ */ /* * Copyright (c) 1990, 1993 @@ -366,6 +367,9 @@ sdattach(hd) disk_attach(&sc->sc_dkdev); sc->sc_flags |= SDF_ALIVE; + + /* XXX Set device class. */ + hd->hp_dev.dv_class = DV_DISK; } void @@ -579,7 +583,7 @@ sdopen(dev, flags, mode, p) { register int unit = sdunit(dev); register struct sd_softc *sc = &sd_softc[unit]; - int error, mask; + int error, mask, part; if (unit >= NSD || (sc->sc_flags & SDF_ALIVE) == 0) return(ENXIO); @@ -604,12 +608,27 @@ sdopen(dev, flags, mode, p) return(error); } - mask = 1 << sdpart(dev); - if (mode == S_IFCHR) + part = sdpart(dev); + mask = 1 << part; + + /* Check that the partition exists. */ + if (part != RAW_PART && + (part >= sc->sc_dkdev.dk_label->d_npartitions || + sc->sc_dkdev.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) + return (ENXIO); + + /* Ensure only one open at a time. */ + switch (mode) { + case S_IFCHR: sc->sc_dkdev.dk_copenmask |= mask; - else + break; + case S_IFBLK: sc->sc_dkdev.dk_bopenmask |= mask; - sc->sc_dkdev.dk_openmask |= mask; + break; + } + sc->sc_dkdev.dk_openmask = + sc->sc_dkdev.dk_copenmask | sc->sc_dkdev.dk_bopenmask; + return(0); } @@ -760,6 +779,7 @@ sdstrategy(bp) register struct partition *pinfo; register daddr_t bn; register int sz, s; + int offset; if (sc->sc_format_pid >= 0) { if (sc->sc_format_pid != curproc->p_pid) { /* XXX */ @@ -775,28 +795,40 @@ sdstrategy(bp) bn = bp->b_blkno; sz = howmany(bp->b_bcount, DEV_BSIZE); pinfo = &sc->sc_dkdev.dk_label->d_partitions[sdpart(bp->b_dev)]; - if (bn < 0 || bn + sz > pinfo->p_size) { - sz = pinfo->p_size - bn; - if (sz == 0) { - bp->b_resid = bp->b_bcount; - goto done; - } - if (sz < 0) { - bp->b_error = EINVAL; - goto bad; + + /* Don't perform partition translation on RAW_PART. */ + offset = (sdpart(bp->b_dev) == RAW_PART) ? 0 : pinfo->p_offset; + + if (sdpart(bp->b_dev) != RAW_PART) { + /* + * XXX This block of code belongs in + * XXX bounds_check_with_label() + */ + + if (bn < 0 || bn + sz > pinfo->p_size) { + sz = pinfo->p_size - bn; + if (sz == 0) { + bp->b_resid = bp->b_bcount; + goto done; + } + if (sz < 0) { + bp->b_error = EINVAL; + goto bad; + } + bp->b_bcount = dbtob(sz); } - bp->b_bcount = dbtob(sz); - } - /* - * Check for write to write protected label - */ - if (bn + pinfo->p_offset <= LABELSECTOR && + /* + * Check for write to write protected label + */ + if (bn + offset <= LABELSECTOR && #if LABELSECTOR != 0 - bn + pinfo->p_offset + sz > LABELSECTOR && + bn + offset + sz > LABELSECTOR && #endif - !(bp->b_flags & B_READ) && !(sc->sc_flags & SDF_WLABEL)) { - bp->b_error = EROFS; - goto bad; + !(bp->b_flags & B_READ) && + !(sc->sc_flags & SDF_WLABEL)) { + bp->b_error = EROFS; + goto bad; + } } /* * Non-aligned or partial-block transfers handled specially. @@ -806,7 +838,7 @@ sdstrategy(bp) sdlblkstrat(bp, sc->sc_blksize); goto done; } - bp->b_cylin = (bn + pinfo->p_offset) >> sc->sc_bshift; + bp->b_cylin = (bn + offset) >> sc->sc_bshift; } s = splbio(); disksort(dp, bp); @@ -1216,60 +1248,93 @@ sdsize(dev) return (psize); } +static int sddoingadump; /* simple mutex */ + /* * Non-interrupt driven, non-dma dump routine. */ int -sddump(dev) +sddump(dev, blkno, va, size) dev_t dev; + daddr_t blkno; + caddr_t va; + size_t size; { - int part = sdpart(dev); - int unit = sdunit(dev); - register struct sd_softc *sc = &sd_softc[unit]; - register struct hp_device *hp = sc->sc_hd; - register struct partition *pinfo; - register daddr_t baddr; - register int maddr; - register int pages, i; - int stat; - extern int lowram, dumpsize; - - /* is drive ok? */ - if (unit >= NSD || (sc->sc_flags & SDF_ALIVE) == 0) + int sectorsize; /* size of a disk sector */ + int nsects; /* number of sectors in partition */ + int sectoff; /* sector offset of partition */ + int totwrt; /* total number of sectors left to write */ + int nwrt; /* current number of sectors to write */ + int unit, part; + struct sd_softc *sc; + struct hp_device *hp; + struct disklabel *lp; + daddr_t baddr; + char stat; + + /* Check for recursive dump; if so, punt. */ + if (sddoingadump) + return (EFAULT); + sddoingadump = 1; + + /* Decompose unit and partition. */ + unit = sdunit(dev); + part = sdpart(dev); + + /* Make sure device is ok. */ + if (unit >= NSD) + return (ENXIO); + sc = &sd_softc[unit]; + if ((sc->sc_flags & SDF_ALIVE) == 0) return (ENXIO); - pinfo = &sc->sc_dkdev.dk_label->d_partitions[part]; - /* dump parameters in range? */ - if (dumplo < 0 || dumplo >= pinfo->p_size || - pinfo->p_fstype != FS_SWAP) + hp = sc->sc_hd; + + /* + * Convert to disk sectors. Request must be a multiple of size. + */ + lp = sc->sc_dkdev.dk_label; + sectorsize = lp->d_secsize; + if ((size % sectorsize) != 0) + return (EFAULT); + totwrt = size / sectorsize; + blkno = dbtob(blkno) / sectorsize; /* blkno in DEV_BSIZE units */ + + nsects = lp->d_partitions[part].p_size; + sectoff = lp->d_partitions[part].p_offset; + + /* Check transfer bounds against partition size. */ + if ((blkno < 0) || (blkno + totwrt) > nsects) return (EINVAL); - pages = dumpsize; - if (dumplo + ctod(pages) > pinfo->p_size) - pages = dtoc(pinfo->p_size - dumplo); - maddr = lowram; - baddr = dumplo + pinfo->p_offset; - /* scsi bus idle? */ - if (!scsireq(&sc->sc_dq)) { - scsireset(hp->hp_ctlr); - sdreset(sc, sc->sc_hd); - printf("[ drive %d reset ] ", unit); - } - for (i = 0; i < pages; i++) { -#define NPGMB (1024*1024/NBPG) - /* print out how many Mbs we have dumped */ - if (i && (i % NPGMB) == 0) - printf("%d ", i / NPGMB); -#undef NPBMG - pmap_enter(pmap_kernel(), (vm_offset_t)vmmap, maddr, - VM_PROT_READ, TRUE); + + /* Offset block number to start of partition. */ + blkno += sectoff; + + while (totwrt > 0) { + nwrt = totwrt; /* XXX */ +#ifndef SD_DUMP_NOT_TRUSTED + /* + * Send the data. Note the `0' argument for bshift; + * we've done the necessary conversion above. + */ stat = scsi_tt_write(hp->hp_ctlr, hp->hp_slave, sc->sc_punit, - vmmap, NBPG, baddr, sc->sc_bshift); + va, nwrt * sectorsize, blkno, 0); if (stat) { - printf("sddump: scsi write error 0x%x\n", stat); + printf("\nsddump: scsi write error 0x%x\n", stat); return (EIO); } - maddr += NBPG; - baddr += ctod(1); +#else /* SD_DUMP_NOT_TRUSTED */ + /* Lets just talk about it first. */ + printf("%s: dump addr %p, blk %d\n", hp->hp_xname, + va, blkno); + delay(500 * 1000); /* half a second */ +#endif /* SD_DUMP_NOT_TRUSTED */ + + /* update block count */ + totwrt -= nwrt; + blkno += nwrt; + va += sectorsize * nwrt; } + sddoingadump = 0; return (0); } #endif diff --git a/sys/arch/hp300/dev/sd_compat.c b/sys/arch/hp300/dev/sd_compat.c index 60e25a63b81..a05e9e5f663 100644 --- a/sys/arch/hp300/dev/sd_compat.c +++ b/sys/arch/hp300/dev/sd_compat.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sd_compat.c,v 1.3 1997/01/12 15:13:04 downsj Exp $ */ /* $NetBSD: sd_compat.c,v 1.4 1996/01/07 22:02:20 thorpej Exp $ */ /* diff --git a/sys/arch/hp300/dev/sdvar.h b/sys/arch/hp300/dev/sdvar.h index fbdf0025bb7..a91895cf127 100644 --- a/sys/arch/hp300/dev/sdvar.h +++ b/sys/arch/hp300/dev/sdvar.h @@ -1,4 +1,5 @@ -/* $NetBSD: sdvar.h,v 1.4.4.1 1996/06/06 16:22:06 thorpej Exp $ */ +/* $OpenBSD: sdvar.h,v 1.5 1997/01/12 15:13:04 downsj Exp $ */ +/* $NetBSD: sdvar.h,v 1.5 1996/06/06 16:17:45 thorpej Exp $ */ /* * Copyright (c) 1990, 1993 diff --git a/sys/arch/hp300/dev/st.c b/sys/arch/hp300/dev/st.c index f73e4c886dc..2a9f5d19ec2 100644 --- a/sys/arch/hp300/dev/st.c +++ b/sys/arch/hp300/dev/st.c @@ -1,4 +1,5 @@ -/* $NetBSD: st.c,v 1.14.4.1 1996/06/10 06:45:33 thorpej Exp $ */ +/* $OpenBSD: st.c,v 1.5 1997/01/12 15:13:05 downsj Exp $ */ +/* $NetBSD: st.c,v 1.18 1996/10/14 07:14:21 thorpej Exp $ */ /* * Copyright (c) 1990 University of Utah. @@ -257,6 +258,9 @@ stattach(hd) sc->sc_dq.dq_driver = &stdriver; sc->sc_blkno = 0; sc->sc_flags = STF_ALIVE; + + /* XXX Set device class. */ + hd->hp_dev.dv_class = DV_TAPE; } int diff --git a/sys/arch/hp300/dev/stvar.h b/sys/arch/hp300/dev/stvar.h index 3f432610dd7..5c32757078d 100644 --- a/sys/arch/hp300/dev/stvar.h +++ b/sys/arch/hp300/dev/stvar.h @@ -1,3 +1,4 @@ +/* $OpenBSD: stvar.h,v 1.2 1997/01/12 15:13:06 downsj Exp $ */ /* $NetBSD: stvar.h,v 1.4 1994/10/26 07:25:14 cgd Exp $ */ /* diff --git a/sys/arch/hp300/hp300/Locore.c b/sys/arch/hp300/hp300/Locore.c index eb429bfa1f8..f09e94b58cd 100644 --- a/sys/arch/hp300/hp300/Locore.c +++ b/sys/arch/hp300/hp300/Locore.c @@ -1,4 +1,5 @@ -/* $NetBSD: Locore.c,v 1.12 1996/02/02 18:05:55 mycroft Exp $ */ +/* $OpenBSD: Locore.c,v 1.4 1997/01/12 15:13:09 downsj Exp $ */ +/* $NetBSD: Locore.c,v 1.16 1996/11/06 20:19:29 cgd Exp $ */ /* * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. @@ -327,9 +328,6 @@ scanc(size, cp, table, mask) /*ARGSUSED*/ skpc(mask, size, cp) int mask; int size; char *cp; { return (0); } -/*ARGSUSED*/ -locc(mask, size, cp) int mask; char *cp; unsigned size; { return (0); } - /*ARGSUSED*/ ffs(v) long v; { return (0); } diff --git a/sys/arch/hp300/hp300/autoconf.c b/sys/arch/hp300/hp300/autoconf.c index 2c063e27e86..dadf64fb4ef 100644 --- a/sys/arch/hp300/hp300/autoconf.c +++ b/sys/arch/hp300/hp300/autoconf.c @@ -1,4 +1,5 @@ -/* $NetBSD: autoconf.c,v 1.20 1996/05/18 01:39:57 thorpej Exp $ */ +/* $OpenBSD: autoconf.c,v 1.7 1997/01/12 15:13:10 downsj Exp $ */ +/* $NetBSD: autoconf.c,v 1.29 1996/12/17 08:41:19 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -10,6 +11,18 @@ * the Systems Programming Group of the University of Utah Computer * Science Department. * + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -44,111 +57,1298 @@ */ /* - * Setup the system to run on the current machine. - * - * Configure() is called at boot time. Available - * devices are determined (from possibilities mentioned in ioconf.c), - * and the drivers are initialized. + * Setup the system to run on the current machine. + * + * Configure() is called at boot time. Available + * devices are determined (from possibilities mentioned in ioconf.c), + * and the drivers are initialized. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +/* + * The following several variables are related to + * the configuration process, and are used in initializing + * the machine. + */ +int cold; /* if 1, still working on cold-start */ + +/* XXX must be allocated statically because of early console init */ +struct map extiomap[EIOMAPSIZE/16]; + +extern caddr_t internalhpib; +extern char *extiobase; + +/* The boot device. */ +struct device *booted_device; + +/* The device we mount as root. */ +struct device *root_device; + +/* How we were booted. */ +u_int bootdev; + +/* + * This information is built during the autoconfig process. + * A little explanation about the way this works is in order. + * + * device_register() links all devices into dev_data_list. + * If the device is an hpib controller, it is also linked + * into dev_data_list_hpib. If the device is a scsi controller, + * it is also linked into dev_data_list_scsi. + * + * dev_data_list_hpib and dev_data_list_scsi are sorted + * by select code, from lowest to highest. + * + * After autoconfiguration is complete, we need to determine + * which device was the boot device. The boot block assigns + * controller unit numbers in order of select code. Thus, + * providing the controller is configured in the kernel, we + * can determine our version of controller unit number from + * the sorted hpib/scsi list. + * + * At this point, we know the controller (device type + * encoded in bootdev tells us "scsi disk", or "hpib tape", + * etc.). The next step is to find the device which + * has the following properties: + * + * - A child of the boot controller. + * - Same slave as encoded in bootdev. + * - Same physical unit as encoded in bootdev. + * + * Later, after we've set the root device in stone, we + * reverse the process to re-encode bootdev so it can be + * passed back to the boot block. + */ +struct dev_data { + LIST_ENTRY(dev_data) dd_list; /* dev_data_list */ + LIST_ENTRY(dev_data) dd_clist; /* ctlr list */ + struct device *dd_dev; /* device described by this entry */ + int dd_scode; /* select code of device */ + int dd_slave; /* ...or slave */ + int dd_punit; /* and punit... */ +}; +typedef LIST_HEAD(, dev_data) ddlist_t; +ddlist_t dev_data_list; /* all dev_datas */ +ddlist_t dev_data_list_hpib; /* hpib controller dev_datas */ +ddlist_t dev_data_list_scsi; /* scsi controller dev_datas */ + +#if 1 /* XXX for now */ +struct scsi_link { + int target; + int lun; +}; + +struct scsibus_attach_args { + struct scsi_link *sa_scsi_link; +}; + +struct hpib_attach_args { + int ha_slave; + int ha_punit; +}; +#endif /* XXX */ + +#ifndef NEWCONFIG /* XXX */ +struct hp_hw sc_table[MAXCTLRS]; + +#ifdef DEBUG +int acdebug = 0; +#endif + +struct devicelist alldevs; +struct evcntlist allevents; + +struct dio_attach_args hp300_dio_attach_args; +struct scsi_link hp300_scsi_link; +struct scsibus_attach_args hp300_scsibus_attach_args; +struct hpib_attach_args hp300_hpib_attach_args; +#endif /* ! NEWCONFIG */ + +void setroot __P((void)); +void swapconf __P((void)); +void findbootdev __P((void)); +void findbootdev_slave __P((ddlist_t *, int, int, int)); +void setbootdev __P((void)); + +static struct dev_data *dev_data_lookup __P((struct device *)); +static void dev_data_insert __P((struct dev_data *, ddlist_t *)); + +static struct device *parsedisk __P((char *str, int len, int defpart, + dev_t *devp)); +static struct device *getdisk __P((char *str, int len, int defpart, + dev_t *devp)); +static int findblkmajor __P((struct device *dv)); +static char *findblkname __P((int)); +static int getstr __P((char *cp, int size)); + +#ifdef NEWCONFIG +int mainbusmatch __P((struct device *, struct cfdata *, void *)); +void mainbusattach __P((struct device *, struct device *, void *)); +int mainbussearch __P((struct device *, struct cfdata *, void *)); + +struct cfattach mainbus_ca = { + sizeof(struct device), mainbusmatch, mainbusattach +}; + +struct cfdriver mainbus_cd = { + NULL, "mainbus", DV_DULL +}; + +int +mainbusmatch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + static int mainbus_matched = 0; + + /* Allow only one instance. */ + if (mainbus_matched) + return (0); + + mainbus_matched = 1; + return (1); +} + +void +mainbusattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + + printf("\n"); + + /* Search for and attach children. */ + config_search(mainbussearch, self, NULL); +} + +int +mainbussearch(parent, cf, aux) + struct device *parent; + struct cfdata *cf; + void *aux; +{ + + if ((*cf->cf_attach->ca_match)(parent, cf, NULL) > 0) + config_attach(parent, cf, NULL, NULL); + return (0); +} +#endif /* NEWCONFIG */ + +/* + * Determine the device configuration for the running system. + */ +void +configure() +{ + register struct hp_hw *hw; + int found; + + /* + * Initialize the dev_data_lists. + */ + LIST_INIT(&dev_data_list); + LIST_INIT(&dev_data_list_hpib); + LIST_INIT(&dev_data_list_scsi); + + /* Initialize the interrupt system. */ + isrinit(); + + /* + * XXX Enable interrupts. We have to do this now so that the + * XXX HIL configures. + */ + (void)spl0(); + + /* + * XXX: these should be consolidated into some kind of table + */ + hilsoftinit(0, HILADDR); + hilinit(0, HILADDR); + dmainit(); + +#ifdef NEWCONFIG + (void)splhigh(); + if (config_rootfound("mainbus", "mainbus") == NULL) + panic("no mainbus found"); + (void)spl0(); +#else + /* + * Find out what hardware is attached to the machine. + */ + find_devs(); + + /* + * Look over each hardware device actually found and attempt + * to match it with an ioconf.c table entry. + */ + for (hw = sc_table; hw->hw_type; hw++) { + if (HW_ISCTLR(hw)) + found = find_controller(hw); + else + found = find_device(hw); + + if (!found) { + extern char *dio_devinfo __P((struct dio_attach_args *, + char *, size_t)); + int sc = hw->hw_sc; + char descbuf[80]; + + bzero(&hp300_dio_attach_args, + sizeof(hp300_dio_attach_args)); + hp300_dio_attach_args.da_scode = sc; + hp300_dio_attach_args.da_id = hw->hw_id; + hp300_dio_attach_args.da_secid = hw->hw_secid; + printf("%s", dio_devinfo(&hp300_dio_attach_args, + descbuf, sizeof(descbuf))); + if (sc >= 0 && sc < 256) + printf(" at scode %d", sc); + else + printf(" csr at 0x%lx", (u_long)hw->hw_pa); + printf(" not configured\n"); + } + } +#endif /* NEWCONFIG */ + + isrprintlevels(); + + /* + * Find boot device. + */ + if ((bootdev & B_MAGICMASK) != B_DEVMAGIC) { + printf("WARNING: boot program didn't supply boot device.\n"); + printf("Please update your boot program.\n"); + } else { + findbootdev(); + if (booted_device == NULL) { + printf("WARNING: can't find match for bootdev:\n"); + printf( + "type = %d, ctlr = %d, slave = %d, punit = %d, part = %d\n", + B_TYPE(bootdev), B_ADAPTOR(bootdev), + B_CONTROLLER(bootdev), B_UNIT(bootdev), + B_PARTITION(bootdev)); + bootdev = 0; /* invalidate bootdev */ + } else { + printf("boot device: %s\n", booted_device->dv_xname); + } + } + + setroot(); + swapconf(); + + /* + * Set bootdev based on how we mounted root. + * This is given to the boot program when we reboot. + */ + setbootdev(); + + cold = 0; +} + +/********************************************************************** + * Code to find and set the boot device + **********************************************************************/ + +/* + * Register a device. We're passed the device and the arguments + * used to attach it. This is used to find the boot device. + */ +void +device_register(dev, aux) + struct device *dev; + void *aux; +{ + struct dev_data *dd; + static int seen_netdevice; + + /* + * Allocate a dev_data structure and fill it in. + * This means making some tests twice, but we don't + * care; this doesn't really have to be fast. + * + * Note that we only really care about devices that + * we can mount as root. + */ + dd = (struct dev_data *)malloc(sizeof(struct dev_data), + M_DEVBUF, M_NOWAIT); + if (dd == NULL) + panic("device_register: can't allocate dev_data"); + bzero(dd, sizeof(struct dev_data)); + + dd->dd_dev = dev; + + /* + * BOOTROM and boot program can really only understand + * using the lowest select code network interface, + * so we ignore all but the first. + */ + if (dev->dv_class == DV_IFNET && seen_netdevice == 0) { + struct dio_attach_args *da = aux; + + seen_netdevice = 1; + dd->dd_scode = da->da_scode; + goto linkup; + } + + if (bcmp(dev->dv_xname, "hpib", 4) == 0 || + bcmp(dev->dv_xname, "scsi", 4) == 0) { + struct dio_attach_args *da = aux; + + dd->dd_scode = da->da_scode; + goto linkup; + } + + if (bcmp(dev->dv_xname, "rd", 2) == 0) { + struct hpib_attach_args *ha = aux; + + dd->dd_slave = ha->ha_slave; + dd->dd_punit = ha->ha_punit; + goto linkup; + } + + if (bcmp(dev->dv_xname, "sd", 2) == 0) { + struct scsibus_attach_args *sa = aux; + + dd->dd_slave = sa->sa_scsi_link->target; + dd->dd_punit = sa->sa_scsi_link->lun; + goto linkup; + } + + /* + * Didn't need the dev_data. + */ + free(dd, M_DEVBUF); + return; + + linkup: + LIST_INSERT_HEAD(&dev_data_list, dd, dd_list); + + if (bcmp(dev->dv_xname, "hpib", 4) == 0) { + dev_data_insert(dd, &dev_data_list_hpib); + return; + } + + if (bcmp(dev->dv_xname, "scsi", 4) == 0) { + dev_data_insert(dd, &dev_data_list_scsi); + return; + } +} + +/* + * Configure swap space and related parameters. + */ +void +swapconf() +{ + struct swdevt *swp; + int nblks, maj; + + for (swp = swdevt; swp->sw_dev != NODEV; swp++) { + maj = major(swp->sw_dev); + if (maj > nblkdev) + break; + if (bdevsw[maj].d_psize) { + nblks = (*bdevsw[maj].d_psize)(swp->sw_dev); + if (nblks != -1 && + (swp->sw_nblks == 0 || swp->sw_nblks > nblks)) + swp->sw_nblks = nblks; + swp->sw_nblks = ctod(dtoc(swp->sw_nblks)); + } + } + dumpconf(); +} + +struct nam2blk { + char *name; + int maj; +} nam2blk[] = { + { "ct", 0 }, + { "rd", 2 }, + { "sd", 4 }, +}; + +static int +findblkmajor(dv) + struct device *dv; +{ + char *name = dv->dv_xname; + register int i; + + for (i = 0; i < sizeof(nam2blk) / sizeof(nam2blk[0]); ++i) + if (strncmp(name, nam2blk[i].name, strlen(nam2blk[0].name)) + == 0) + return (nam2blk[i].maj); + return (-1); +} + +static char * +findblkname(maj) + int maj; +{ + register int i; + + for (i = 0; i < sizeof(nam2blk) / sizeof(nam2blk[0]); ++i) + if (maj == nam2blk[i].maj) + return (nam2blk[i].name); + return (NULL); +} + +static struct device * +getdisk(str, len, defpart, devp) + char *str; + int len, defpart; + dev_t *devp; +{ + register struct device *dv; + + if ((dv = parsedisk(str, len, defpart, devp)) == NULL) { + printf("use one of:"); + for (dv = alldevs.tqh_first; dv != NULL; + dv = dv->dv_list.tqe_next) { + if (dv->dv_class == DV_DISK) + printf(" %s[a-h]", dv->dv_xname); +#ifdef NFSCLIENT + if (dv->dv_class == DV_IFNET) + printf(" %s", dv->dv_xname); +#endif + } + printf(" halt\n"); + } + return (dv); +} + +static struct device * +parsedisk(str, len, defpart, devp) + char *str; + int len, defpart; + dev_t *devp; +{ + register struct device *dv; + register char *cp, c; + int majdev, part; + + if (len == 0) + return (NULL); + + if (len == 4 && !strcmp(str, "halt")) + boot(RB_HALT); + + cp = str + len - 1; + c = *cp; + if (c >= 'a' && c <= ('a' + MAXPARTITIONS - 1)) { + part = c - 'a'; + *cp = '\0'; + } else + part = defpart; + + for (dv = alldevs.tqh_first; dv != NULL; dv = dv->dv_list.tqe_next) { + if (dv->dv_class == DV_DISK && + strcmp(str, dv->dv_xname) == 0) { + majdev = findblkmajor(dv); + if (majdev < 0) + panic("parsedisk"); + *devp = MAKEDISKDEV(majdev, dv->dv_unit, part); + break; + } +#ifdef NFSCLIENT + if (dv->dv_class == DV_IFNET && + strcmp(str, dv->dv_xname) == 0) { + *devp = NODEV; + break; + } +#endif + } + + *cp = c; + return (dv); +} + +/* + * Attempt to find the device from which we were booted. + * If we can do so, and not instructed not to do so, + * change rootdev to correspond to the load device. + * + * XXX Actually, swap and root must be on the same type of device, + * (ie. DV_DISK or DV_IFNET) because of how (*mountroot) is written. + * That should be fixed. + */ +void +setroot() +{ + struct swdevt *swp; + struct device *dv; + register int len; + dev_t nrootdev, nswapdev = NODEV; + char buf[128], *rootdevname; + extern int (*mountroot) __P((void)); + dev_t temp; + struct device *bootdv, *rootdv, *swapdv; + int bootpartition = 0; +#ifdef NFSCLIENT + extern char *nfsbootdevname; + extern int nfs_mountroot __P((void)); +#endif +#ifdef FFS + extern int ffs_mountroot __P((void)); +#endif + + bootdv = booted_device; + + /* + * If 'swap generic' and we couldn't determine root device, + * ask the user. + */ + if (mountroot == NULL && bootdv == NULL) + boothowto |= RB_ASKNAME; + + /* + * If bootdev is bogus, ask the user anyhow. + */ + if (bootdev == 0) + boothowto |= RB_ASKNAME; + else + bootpartition = B_PARTITION(bootdev); + + /* + * If we booted from tape, ask the user. + */ + if (bootdv != NULL && bootdv->dv_class == DV_TAPE) + boothowto |= RB_ASKNAME; + + if (boothowto & RB_ASKNAME) { + for (;;) { + printf("root device"); + if (bootdv != NULL) { + printf(" (default %s", bootdv->dv_xname); + if (bootdv->dv_class == DV_DISK) + printf("%c", bootpartition + 'a'); + printf(")"); + } + printf(": "); + len = getstr(buf, sizeof(buf)); + if (len == 0 && bootdv != NULL) { + strcpy(buf, bootdv->dv_xname); + len = strlen(buf); + } + if (len > 0 && buf[len - 1] == '*') { + buf[--len] = '\0'; + dv = getdisk(buf, len, 1, &nrootdev); + if (dv != NULL) { + rootdv = dv; + nswapdev = nrootdev; + goto gotswap; + } + } + dv = getdisk(buf, len, bootpartition, &nrootdev); + if (dv != NULL) { + rootdv = dv; + break; + } + } + + /* + * Because swap must be on the same device type as root, + * for network devices this is easy. + */ + if (rootdv->dv_class == DV_IFNET) { + swapdv = NULL; + goto gotswap; + } + for (;;) { + printf("swap device"); + printf(" (default %s", rootdv->dv_xname); + if (rootdv->dv_class == DV_DISK) + printf("b"); + printf(")"); + printf(": "); + len = getstr(buf, sizeof(buf)); + if (len == 0) { + switch (rootdv->dv_class) { + case DV_IFNET: + nswapdev = NODEV; + break; + case DV_DISK: + nswapdev = MAKEDISKDEV(major(nrootdev), + DISKUNIT(nrootdev), 1); + break; + case DV_TAPE: + case DV_TTY: + case DV_DULL: + case DV_CPU: + break; + } + swapdv = rootdv; + break; + } + dv = getdisk(buf, len, 1, &nswapdev); + if (dv) { + if (dv->dv_class == DV_IFNET) + nswapdev = NODEV; + swapdv = dv; + break; + } + } + gotswap: + rootdev = nrootdev; + dumpdev = nswapdev; + swdevt[0].sw_dev = nswapdev; + swdevt[1].sw_dev = NODEV; + } else if (mountroot == NULL) { + int majdev; + + /* + * "swap generic" + */ + majdev = findblkmajor(bootdv); + if (majdev >= 0) { + /* + * Root and swap are on a disk. + */ + rootdv = swapdv = bootdv; + rootdev = MAKEDISKDEV(majdev, bootdv->dv_unit, + bootpartition); + nswapdev = dumpdev = + MAKEDISKDEV(majdev, bootdv->dv_unit, 1); + } else { + /* + * Root and swap are on a net. + */ + rootdv = swapdv = bootdv; + nswapdev = dumpdev = NODEV; + } + swdevt[0].sw_dev = nswapdev; + swdevt[1].sw_dev = NODEV; + } else { + /* + * `root DEV swap DEV': honor rootdev/swdevt. + * rootdev/swdevt/mountroot already properly set. + */ + +#ifdef NFSCLIENT + if (mountroot == nfs_mountroot) { + struct dev_data *dd; + /* + * `root on nfs'. Find the first network + * interface. + */ + for (dd = dev_data_list.lh_first; + dd != NULL; dd = dd->dd_list.le_next) { + if (dd->dd_dev->dv_class == DV_IFNET) { + /* Got it! */ + break; + } + } + if (dd == NULL) { + printf("no network interface for NFS root"); + panic("setroot"); + } + root_device = dd->dd_dev; + return; + } +#endif + rootdevname = findblkname(major(rootdev)); + if (rootdevname == NULL) { + printf("unknown root device major 0x%x\n", rootdev); + panic("setroot"); + } + bzero(buf, sizeof(buf)); + sprintf(buf, "%s%d", rootdevname, DISKUNIT(rootdev)); + + for (dv = alldevs.tqh_first; dv != NULL; + dv = dv->dv_list.tqe_next) { + if (strcmp(buf, dv->dv_xname) == 0) { + root_device = dv; + break; + } + } + if (dv == NULL) { + printf("device %s (0x%x) not configured\n", + buf, rootdev); + panic("setroot"); + } + + return; + } + + root_device = rootdv; + + switch (rootdv->dv_class) { +#ifdef NFSCLIENT + case DV_IFNET: + mountroot = nfs_mountroot; + nfsbootdevname = rootdv->dv_xname; + return; +#endif +#ifdef FFS + case DV_DISK: + mountroot = ffs_mountroot; + printf("root on %s%c", rootdv->dv_xname, + DISKPART(rootdev) + 'a'); + if (nswapdev != NODEV) + printf(" swap on %s%c", swapdv->dv_xname, + DISKPART(nswapdev) + 'a'); + printf("\n"); + break; +#endif + default: + printf("can't figure root, hope your kernel is right\n"); + return; + } + + /* + * Make the swap partition on the root drive the primary swap. + */ + temp = NODEV; + for (swp = swdevt; swp->sw_dev != NODEV; swp++) { + if (major(rootdev) == major(swp->sw_dev) && + DISKUNIT(rootdev) == DISKUNIT(swp->sw_dev)) { + temp = swdevt[0].sw_dev; + swdevt[0].sw_dev = swp->sw_dev; + swp->sw_dev = temp; + break; + } + } + if (swp->sw_dev == NODEV) + return; + + /* + * If dumpdev was the same as the old primary swap device, move + * it to the new primary swap device. + */ + if (temp == dumpdev) + dumpdev = swdevt[0].sw_dev; + +} + +static int +getstr(cp, size) + register char *cp; + register int size; +{ + register char *lp; + register int c; + register int len; + + lp = cp; + len = 0; + for (;;) { + c = cngetc(); + switch (c) { + case '\n': + case '\r': + printf("\n"); + *lp++ = '\0'; + return (len); + case '\b': + case '\177': + case '#': + if (len) { + --len; + --lp; + printf("\b \b"); + } + continue; + case '@': + case 'u'&037: + len = 0; + lp = cp; + printf("\n"); + continue; + default: + if (len + 1 >= size || c < ' ') { + printf("\007"); + continue; + } + printf("%c", c); + ++len; + *lp++ = c; + } + } +} + +void +findbootdev() +{ + int type, ctlr, slave, punit; + int scsiboot, hpibboot, netboot; + struct dev_data *dd; + + booted_device = NULL; + + if ((bootdev & B_MAGICMASK) != B_DEVMAGIC) + return; + + type = B_TYPE(bootdev); + ctlr = B_ADAPTOR(bootdev); + slave = B_CONTROLLER(bootdev); + punit = B_UNIT(bootdev); + + scsiboot = (type == 4); /* sd major */ + hpibboot = (type == 0 || type == 2); /* ct/rd major */ + netboot = (type == 6); /* le - special */ + + /* + * Check for network boot first, since it's a little + * different. The BOOTROM/boot program can only boot + * off of the first (lowest select code) ethernet + * device. device_register() knows this and only + * registers one DV_IFNET. This is a safe assumption + * since the code that finds devices on the DIO bus + * always starts at scode 0 and works its way up. + */ + if (netboot) { + for (dd = dev_data_list.lh_first; dd != NULL; + dd = dd->dd_list.le_next) { + if (dd->dd_dev->dv_class == DV_IFNET) { + /* + * Found it! + */ + booted_device = dd->dd_dev; + break; + } + } + return; + } + + /* + * Check for HP-IB boots next. + */ + if (hpibboot) { + findbootdev_slave(&dev_data_list_hpib, ctlr, + slave, punit); + if (booted_device == NULL) + return; + + /* + * Sanity check. + */ + if ((type == 0 && bcmp(booted_device->dv_xname, "ct", 2)) || + (type == 2 && bcmp(booted_device->dv_xname, "rd", 2))) { + printf("WARNING: boot device/type mismatch!\n"); + printf("device = %s, type = %d\n", + booted_device->dv_xname, type); + booted_device = NULL; + } + return; + } + + /* + * Check for SCSI boots last. + */ + if (scsiboot) { + findbootdev_slave(&dev_data_list_scsi, ctlr, + slave, punit); + if (booted_device == NULL) + return; + + /* + * Sanity check. + */ + if ((type == 4 && bcmp(booted_device->dv_xname, "sd", 2))) { + printf("WARNING: boot device/type mismatch!\n"); + printf("device = %s, type = %d\n", + booted_device->dv_xname, type); + booted_device = NULL; + } + return; + } + + /* Oof! */ + printf("WARNING: UNKNOWN BOOT DEVICE TYPE = %d\n", type); +} + +void +findbootdev_slave(ddlist, ctlr, slave, punit) + ddlist_t *ddlist; + int ctlr, slave, punit; +{ + struct dev_data *cdd, *dd; + + /* + * Find the booted controller. + */ + for (cdd = ddlist->lh_first; ctlr != 0 && cdd != NULL; + cdd = cdd->dd_clist.le_next) + ctlr--; + if (cdd == NULL) { + /* + * Oof, couldn't find it... + */ + return; + } + + /* + * Now find the device with the right slave/punit + * that's a child of the controller. + */ + for (dd = dev_data_list.lh_first; dd != NULL; + dd = dd->dd_list.le_next) { + if (dd->dd_dev->dv_parent == cdd->dd_dev && + dd->dd_slave == slave && + dd->dd_punit == punit) { + /* + * Found it! + */ + booted_device = dd->dd_dev; + break; + } + } +} + +void +setbootdev() +{ + struct dev_data *cdd, *dd; + int type, ctlr; + + /* + * Note our magic numbers for type: + * + * 0 == ct + * 2 == rd + * 4 == sd + * 6 == le + * + * Allare bdevsw major numbers, except for le, which + * is just special. + * + * We can't mount root on a tape, so we ignore those. + */ + + /* + * Start with a clean slate. + */ + bootdev = 0; + + dd = dev_data_lookup(root_device); + + /* + * If the root device is network, we're done + * early. + */ + if (root_device->dv_class == DV_IFNET) { + bootdev = MAKEBOOTDEV(6, 0, 0, 0, 0); + goto out; + } + + /* + * Determine device type. + */ + if (bcmp(root_device->dv_xname, "rd", 2) == 0) + type = 2; + else if (bcmp(root_device->dv_xname, "sd", 2) == 0) + type = 4; + else { + printf("WARNING: strange root device!\n"); + goto out; + } + + /* + * Get parent's info. + */ + cdd = dev_data_lookup(root_device->dv_parent); + switch (type) { + case 2: + for (cdd = dev_data_list_hpib.lh_first, ctlr = 0; + cdd != NULL; cdd = cdd->dd_clist.le_next, ctlr++) { + if (cdd->dd_dev == root_device->dv_parent) { + /* + * Found it! + */ + bootdev = MAKEBOOTDEV(type, + ctlr, dd->dd_slave, dd->dd_punit, + DISKPART(rootdev)); + break; + } + } + break; + + case 4: + for (cdd = dev_data_list_scsi.lh_first, ctlr = 0; + cdd != NULL; cdd = cdd->dd_clist.le_next, ctlr++) { + if (cdd->dd_dev == root_device->dv_parent) { + /* + * Found it! + */ + bootdev = MAKEBOOTDEV(type, + ctlr, dd->dd_slave, dd->dd_punit, + DISKPART(rootdev)); + break; + } + } + break; + } + + out: + /* Don't need this anymore. */ + for (dd = dev_data_list.lh_first; dd != NULL; ) { + cdd = dd; + dd = dd->dd_list.le_next; + free(cdd, M_DEVBUF); + } +} + +/* + * Return the dev_data corresponding to the given device. + */ +static struct dev_data * +dev_data_lookup(dev) + struct device *dev; +{ + struct dev_data *dd; + + for (dd = dev_data_list.lh_first; dd != NULL; dd = dd->dd_list.le_next) + if (dd->dd_dev == dev) + return (dd); + + panic("dev_data_lookup"); +} + +/* + * Insert a dev_data into the provided list, sorted by select code. */ +static void +dev_data_insert(dd, ddlist) + struct dev_data *dd; + ddlist_t *ddlist; +{ + struct dev_data *de; -#include -#include -#include -#include -#include -#include -#include -#include -#include +#ifdef DIAGNOSTIC + if (dd->dd_scode < 0 || dd->dd_scode > 255) { + printf("bogus select code for %s\n", dd->dd_dev->dv_xname); + panic("dev_data_insert"); + } +#endif -#include + de = ddlist->lh_first; -#include -#include -#include -#include + /* + * Just insert at head if list is empty. + */ + if (de == NULL) { + LIST_INSERT_HEAD(ddlist, dd, dd_clist); + return; + } -#include + /* + * Traverse the list looking for a device who's select code + * is greater than ours. When we find it, insert ourselves + * into the list before it. + */ + for (; de->dd_clist.le_next != NULL; de = de->dd_clist.le_next) { + if (de->dd_scode > dd->dd_scode) { + LIST_INSERT_BEFORE(de, dd, dd_clist); + return; + } + } -#include -#include -#include + /* + * Our select code is greater than everyone else's. We go + * onto the end. + */ + LIST_INSERT_AFTER(de, dd, dd_clist); +} + +/********************************************************************** + * Code to find and initialize the console + **********************************************************************/ /* - * The following several variables are related to - * the configuration process, and are used in initializing - * the machine. + * Scan all select codes, passing the corresponding VA to (*func)(). + * (*func)() is a driver-specific routine that looks for the console + * hardware. */ -int cold; /* if 1, still working on cold-start */ -struct hp_hw sc_table[MAXCTLRS]; +void +console_scan(func, arg) + int (*func) __P((int, caddr_t, void *)); + void *arg; +{ + int size, scode, sctop; + caddr_t pa, va; -/* XXX must be allocated statically because of early console init */ -struct map extiomap[EIOMAPSIZE/16]; + /* + * Scan all select codes. Check each location for some + * hardware. If there's something there, call (*func)(). + */ + sctop = DIO_SCMAX(machineid); + for (scode = 0; scode < sctop; ++scode) { + /* + * Abort mission if console has been forced. + */ + if (conforced) + return; -extern caddr_t internalhpib; -extern char *extiobase; + /* + * Skip over the select code hole and + * the internal HP-IB controller. + */ + if (((scode >= 32) && (scode < 132)) || + ((scode == 7) && internalhpib)) + continue; -#ifdef DEBUG -int acdebug = 0; -#endif + /* Map current PA. */ + pa = dio_scodetopa(scode); + va = iomap(pa, NBPG); + if (va == 0) + continue; -#ifndef NEWCONFIG /* XXX */ -struct devicelist alldevs; -struct evcntlist allevents; -#endif + /* Check to see if hardware exists. */ + if (badaddr(va)) { + iounmap(va, NBPG); + continue; + } + + /* + * Hardware present, call callback. Driver returns + * size of region to map if console probe successful + * and worthwhile. + */ + size = (*func)(scode, va, arg); + iounmap(va, NBPG); + if (size) { + /* Free last mapping. */ + if (convasize) + iounmap(conaddr, convasize); + convasize = 0; + + /* Remap to correct size. */ + va = iomap(pa, size); + if (va == 0) + continue; + + /* Save this state for next time. */ + conscode = scode; + conaddr = va; + convasize = size; + } + } +} /* - * Determine mass storage and memory configuration for a machine. + * Special version of cninit(). Actually, crippled somewhat. + * This version lets the drivers assign cn_tab. */ -configure() +void +hp300_cninit() { - register struct hp_hw *hw; - int found; + struct consdev *cp; + extern struct consdev constab[]; + + cn_tab = NULL; /* - * Find out what hardware is attached to the machine. - * XXX goes away with new config. + * Call all of the console probe functions. */ - find_devs(); + for (cp = constab; cp->cn_probe; cp++) + (*cp->cn_probe)(cp); /* - * XXX: these should be consolidated into some kind of table + * No console, we can handle it. */ - hilsoftinit(0, HILADDR); - hilinit(0, HILADDR); - isrinit(); - dmainit(); + if (cn_tab == NULL) + return; /* - * Look over each hardware device actually found and attempt - * to match it with an ioconf.c table entry. + * Turn on the console. */ - for (hw = sc_table; hw->hw_type; hw++) { - if (HW_ISCTLR(hw)) - found = find_controller(hw); - else - found = find_device(hw); + (*cn_tab->cn_init)(cn_tab); +} - if (!found) { - int sc = patosc(hw->hw_pa); +/********************************************************************** + * Mapping functions + **********************************************************************/ - printf("unconfigured card id %x ", hw->hw_id); - if (sc < 256) - printf("at sc%d\n", sc); - else - printf("csr at %x\n", sc); - } - } +/* + * Allocate/deallocate a cache-inhibited range of kernel virtual address + * space mapping the indicated physical address range [pa - pa+size) + */ +caddr_t +iomap(pa, size) + caddr_t pa; + int size; +{ + int ix, npf; + caddr_t kva; -#if GENERIC - if ((boothowto & RB_ASKNAME) == 0) - setroot(); - setconf(); -#else - setroot(); +#ifdef DEBUG + if (((int)pa & PGOFSET) || (size & PGOFSET)) + panic("iomap: unaligned"); #endif - swapconf(); - cold = 0; + npf = btoc(size); + ix = rmalloc(extiomap, npf); + if (ix == 0) + return(0); + kva = extiobase + ctob(ix-1); + physaccess(kva, pa, size, PG_RW|PG_CI); + return(kva); +} + +/* + * Unmap a previously mapped device. + */ +void +iounmap(kva, size) + caddr_t kva; + int size; +{ + int ix; + +#ifdef DEBUG + if (((int)kva & PGOFSET) || (size & PGOFSET)) + panic("iounmap: unaligned"); + if (kva < extiobase || kva >= extiobase + ctob(EIOMAPSIZE)) + panic("iounmap: bad address"); +#endif + physunaccess(kva, size); + ix = btoc(kva - extiobase) + 1; + rmfree(extiomap, btoc(size), ix); +} + +/********************************************************************** + * Old-style device configuration code + **********************************************************************/ + +#ifndef NEWCONFIG + +/* + * Duplicate of the same in subr_autoconf.c + */ +void +config_init() +{ + + TAILQ_INIT(&alldevs); + TAILQ_INIT(&allevents); } #define dr_type(d, s) \ @@ -223,18 +1423,23 @@ find_controller(hw) if ((*hc->hp_driver->d_match)(hc)) { hc->hp_alive = 1; - /* Set up external name. */ - bzero(hc->hp_xname, sizeof(hc->hp_xname)); - sprintf(hc->hp_xname, "%s%d", hc->hp_driver->d_name, + /* + * Fill in fake device structure. + */ + bzero(&hc->hp_dev, sizeof(hc->hp_dev)); + hc->hp_dev.dv_unit = hc->hp_unit; + sprintf(hc->hp_dev.dv_xname, "%s%d", hc->hp_driver->d_name, hc->hp_unit); + hc->hp_dev.dv_class = DV_DULL; /* all controllers are dull */ + TAILQ_INSERT_TAIL(&alldevs, &hc->hp_dev, dv_list); /* Print what we've found. */ printf("%s at ", hc->hp_xname); - sc = patosc(hw->hw_pa); - if (sc < 256) - printf("scode%d", sc); + sc = hw->hw_sc; + if (sc >= 0 && sc < 256) + printf("scode %d", sc); else - printf("addr 0x%x,", sc); + printf("addr 0x%lx,", (u_long)hw->hw_pa); printf(" ipl %d", hc->hp_ipl); if (hc->hp_flags) printf(" flags 0x%x", hc->hp_flags); @@ -244,6 +1449,14 @@ find_controller(hw) * newline for us. */ (*hc->hp_driver->d_attach)(hc); + + /* + * Register device. Do this after attach because + * we need dv_class. + */ + hp300_dio_attach_args.da_scode = sc; + device_register(&hc->hp_dev, &hp300_dio_attach_args); + find_slaves(hc); /* XXX do this in attach? */ } else hc->hp_addr = oaddr; @@ -326,18 +1539,27 @@ find_device(hw) if ((*hd->hp_driver->d_match)(hd)) { hd->hp_alive = 1; - /* Set up external name. */ - bzero(hd->hp_xname, sizeof(hd->hp_xname)); - sprintf(hd->hp_xname, "%s%d", hd->hp_driver->d_name, + /* + * Fill in fake device structure. + */ + bzero(&hd->hp_dev, sizeof(sizeof hd->hp_dev)); + hd->hp_dev.dv_unit = hd->hp_unit; + sprintf(hd->hp_dev.dv_xname, "%s%d", hd->hp_driver->d_name, hd->hp_unit); + /* + * Default to dull, driver attach will override if + * necessary. + */ + hd->hp_dev.dv_class = DV_DULL; + TAILQ_INSERT_TAIL(&alldevs, &hd->hp_dev, dv_list); /* Print what we've found. */ printf("%s at ", hd->hp_xname); - sc = patosc(hw->hw_pa); - if (sc < 256) - printf("scode%d", sc); + sc = hw->hw_sc; + if (sc >= 0 && sc < 256) + printf("scode %d", sc); else - printf("addr 0x%x", sc); + printf("addr 0x%lx", (u_long)hw->hw_pa); if (hd->hp_ipl) printf(" ipl %d", hd->hp_ipl); if (hd->hp_flags) @@ -348,6 +1570,13 @@ find_device(hw) * newline for us. */ (*hd->hp_driver->d_attach)(hd); + + /* + * Register device. Do this after attach because we + * need dv_class. + */ + hp300_dio_attach_args.da_scode = sc; + device_register(&hd->hp_dev, &hp300_dio_attach_args); } else hd->hp_addr = oaddr; return(1); @@ -497,23 +1726,37 @@ find_busslaves(hc, startslave, endslave) if (acdebug) printf("found\n"); #endif - /* Set up external name. */ - bzero(hd->hp_xname, sizeof(hd->hp_xname)); - sprintf(hd->hp_xname, "%s%d", + /* + * Fill in fake device strcuture. + */ + bzero(&hd->hp_dev, sizeof(hd->hp_dev)); + hd->hp_dev.dv_unit = hd->hp_unit; + sprintf(hd->hp_dev.dv_xname, "%s%d", hd->hp_driver->d_name, hd->hp_unit); + /* + * Default to dull, driver attach will + * override if necessary. + */ + hd->hp_dev.dv_class = DV_DULL; + hd->hp_dev.dv_parent = &hc->hp_dev; + TAILQ_INSERT_TAIL(&alldevs, &hd->hp_dev, + dv_list); - /* Print what we've found. */ - printf("%s at %s slave %d", + /* + * Print what we've found. Note that + * for `slave' devices, the flags are + * overloaded with the phys. unit + * locator. They aren't used for anything + * else, so we always treat them as + * such. This is a hack to make things + * a little more clear to folks configuring + * kernels and reading boot messages. + */ + printf("%s at %s slave %d punit %d", hd->hp_xname, hc->hp_xname, - hd->hp_slave); - if (hd->hp_flags) - printf(" flags 0x%x", hd->hp_flags); + hd->hp_slave, hd->hp_flags); hd->hp_alive = 1; - if (hd->hp_dk && dkn < DK_NDRIVE) - hd->hp_dk = dkn++; - else - hd->hp_dk = -1; rescan = 1; /* @@ -521,6 +1764,26 @@ find_busslaves(hc, startslave, endslave) * It will print the newline for us. */ (*hd->hp_driver->d_attach)(hd); + + /* + * Register device. Do this after attach + * because we need dv_class. + */ + if (dr_type(hc->hp_driver, "scsi")) { + hp300_scsi_link.target = hd->hp_slave; + hp300_scsi_link.lun = hd->hp_flags; + hp300_scsibus_attach_args.sa_scsi_link= + &hp300_scsi_link; + device_register(&hd->hp_dev, + &hp300_scsibus_attach_args); + } else { + hp300_hpib_attach_args.ha_slave = + hd->hp_slave; + hp300_hpib_attach_args.ha_punit = + hd->hp_flags; + device_register(&hd->hp_dev, + &hp300_hpib_attach_args); + } } else { #ifdef DEBUG if (acdebug) @@ -574,58 +1837,6 @@ find_busslaves(hc, startslave, endslave) #undef LASTSLAVE } -caddr_t -sctopa(sc) - register int sc; -{ - register caddr_t addr; - - if (sc == 7 && internalhpib) - addr = internalhpib; - else if (sc < 32) - addr = (caddr_t) (DIOBASE + sc * DIOCSIZE); - else if (sc >= 132) - addr = (caddr_t) (DIOIIBASE + (sc - 132) * DIOIICSIZE); - else - addr = 0; - return(addr); -} - -patosc(addr) - register caddr_t addr; -{ - if (addr == (caddr_t)0x478000) - return(7); - if (addr >= (caddr_t)DIOBASE && addr < (caddr_t)DIOTOP) - return(((unsigned)addr - DIOBASE) / DIOCSIZE); - if (addr >= (caddr_t)DIOIIBASE && addr < (caddr_t)DIOIITOP) - return(((unsigned)addr - DIOIIBASE) / DIOIICSIZE + 132); - return((int)addr); -} - -caddr_t -sctova(sc) - register int sc; -{ - register struct hp_hw *hw; - - for (hw = sc_table; hw->hw_type; hw++) - if (sc == hw->hw_sc) - return(hw->hw_kva); - return((caddr_t)sc); -} - -vatosc(addr) - register caddr_t addr; -{ - register struct hp_hw *hw; - - for (hw = sc_table; hw->hw_type; hw++) - if (addr == hw->hw_kva) - return(hw->hw_sc); - return((int)addr); -} - same_hw_device(hw, hd) struct hp_hw *hw; struct hp_device *hd; @@ -662,107 +1873,6 @@ same_hw_device(hw, hd) char notmappedmsg[] = "WARNING: no space to map IO card, ignored\n"; -/* - * Scan all select codes, passing the corresponding VA to (*func)(). - * (*func)() is a driver-specific routine that looks for the console - * hardware. - */ -void -console_scan(func, arg) - int (*func) __P((int, caddr_t, void *)); - void *arg; -{ - int size, scode, sctop; - caddr_t pa, va; - - /* - * Scan all select codes. Check each location for some - * hardware. If there's something there, call (*func)(). - */ - sctop = (machineid == HP_320) ? 32 : 256; - for (scode = 0; scode < sctop; ++scode) { - /* - * Abort mission if console has been forced. - */ - if (conforced) - return; - - /* - * Skip over the select code hole and - * the internal HP-IB controller. - */ - if (((scode >= 32) && (scode < 132)) || - ((scode == 7) && internalhpib)) - continue; - - /* Map current PA. */ - pa = sctopa(scode); - va = iomap(pa, NBPG); - if (va == 0) - continue; - - /* Check to see if hardware exists. */ - if (badaddr(va)) { - iounmap(va, NBPG); - continue; - } - - /* - * Hardware present, call callback. Driver returns - * size of region to map if console probe successful - * and worthwhile. - */ - size = (*func)(scode, va, arg); - iounmap(va, NBPG); - if (size) { - /* Free last mapping. */ - if (convasize) - iounmap(conaddr, convasize); - convasize = 0; - - /* Remap to correct size. */ - va = iomap(pa, size); - if (va == 0) - continue; - - /* Save this state for next time. */ - conscode = scode; - conaddr = va; - convasize = size; - } - } -} - -/* - * Special version of cninit(). Actually, crippled somewhat. - * This version lets the drivers assign cn_tab. - */ -void -hp300_cninit() -{ - struct consdev *cp; - extern struct consdev constab[]; - - cn_tab = NULL; - - /* - * Call all of the console probe functions. - */ - for (cp = constab; cp->cn_probe; cp++) - (*cp->cn_probe)(cp); - - /* - * No console, we can handle it. - */ - if (cn_tab == NULL) - return; - - /* - * Turn on the console. - */ - (*cn_tab->cn_init)(cn_tab); -} - /* * Scan the IO space looking for devices. */ @@ -777,12 +1887,12 @@ find_devs() /* * Probe all select codes + internal display addr */ - sctop = machineid == HP_320 ? 32 : 256; + sctop = DIO_SCMAX(machineid); for (sc = -1; sc < sctop; sc++) { /* * Invalid select codes */ - if (sc >= 32 && sc < 132) + if ((sc >= 32 && sc < 132) || sc > 187) /* XXX */ continue; if (sc == -1) { @@ -790,7 +1900,7 @@ find_devs() addr = (caddr_t) IIOV(hw->hw_pa); didmap = 0; } else if (sc == 7 && internalhpib) { - hw->hw_pa = (caddr_t) 0x478000; + hw->hw_pa = (caddr_t)DIO_IHPIBADDR; addr = internalhpib = (caddr_t) IIOV(hw->hw_pa); didmap = 0; } else if (sc == conscode) { @@ -798,11 +1908,11 @@ find_devs() * If this is the console, it's already been * mapped, and the address is known. */ - hw->hw_pa = sctopa(sc); + hw->hw_pa = dio_scodetopa(sc); addr = conaddr; didmap = 0; } else { - hw->hw_pa = sctopa(sc); + hw->hw_pa = dio_scodetopa(sc); addr = iomap(hw->hw_pa, NBPG); if (addr == 0) { printf(notmappedmsg); @@ -815,14 +1925,14 @@ find_devs() iounmap(addr, NBPG); continue; } - id_reg = (u_char *) addr; - if (sc >= 132) - hw->hw_size = (id_reg[0x101] + 1) * 0x100000; - else - hw->hw_size = DIOCSIZE; + + hw->hw_size = DIO_SIZE(sc, addr); hw->hw_kva = addr; - hw->hw_id = id_reg[1]; + hw->hw_id = DIO_ID(addr); + if (DIO_ISFRAMEBUFFER(hw->hw_id)) + hw->hw_secid = DIO_SECID(addr); hw->hw_sc = sc; + /* * Internal HP-IB on some machines (345/375) doesn't return * consistant id info so we use the info gleaned from the @@ -1014,194 +2124,4 @@ find_devs() hw++; } } - -/* - * Allocate/deallocate a cache-inhibited range of kernel virtual address - * space mapping the indicated physical address range [pa - pa+size) - */ -caddr_t -iomap(pa, size) - caddr_t pa; - int size; -{ - int ix, npf; - caddr_t kva; - -#ifdef DEBUG - if (((int)pa & PGOFSET) || (size & PGOFSET)) - panic("iomap: unaligned"); -#endif - npf = btoc(size); - ix = rmalloc(extiomap, npf); - if (ix == 0) - return(0); - kva = extiobase + ctob(ix-1); - physaccess(kva, pa, size, PG_RW|PG_CI); - return(kva); -} - -void -iounmap(kva, size) - caddr_t kva; - int size; -{ - int ix; - -#ifdef DEBUG - if (((int)kva & PGOFSET) || (size & PGOFSET)) - panic("iounmap: unaligned"); - if (kva < extiobase || kva >= extiobase + ctob(EIOMAPSIZE)) - panic("iounmap: bad address"); -#endif - physunaccess(kva, size); - ix = btoc(kva - extiobase) + 1; - rmfree(extiomap, btoc(size), ix); -} - -/* - * Configure swap space and related parameters. - */ -swapconf() -{ - register struct swdevt *swp; - register int nblks; - - for (swp = swdevt; swp->sw_dev != NODEV; swp++) - if (bdevsw[major(swp->sw_dev)].d_psize) { - nblks = - (*bdevsw[major(swp->sw_dev)].d_psize)(swp->sw_dev); - if (nblks != -1 && - (swp->sw_nblks == 0 || swp->sw_nblks > nblks)) - swp->sw_nblks = nblks; - } - dumpconf(); -} - -#define DOSWAP /* Change swdevt and dumpdev too */ -u_long bootdev; /* should be dev_t, but not until 32 bits */ - -static char devname[][2] = { - 0,0, /* 0 = ct */ - 0,0, /* 1 = xx */ - 'r','d', /* 2 = rd */ - 0,0, /* 3 = sw */ - 's','d', /* 4 = rd */ -}; - -#define PARTITIONMASK 0x7 -#define PARTITIONSHIFT 3 - -/* - * Attempt to find the device from which we were booted. - * If we can do so, and not instructed not to do so, - * change rootdev to correspond to the load device. - */ -setroot() -{ - register struct hp_ctlr *hc; - register struct hp_device *hd; - int majdev, mindev, unit, part, controller, adaptor; - dev_t temp, orootdev; - struct swdevt *swp; - - if (boothowto & RB_DFLTROOT || (bootdev == 0) || - (bootdev & B_MAGICMASK) != (u_long)B_DEVMAGIC) - return; - majdev = B_TYPE(bootdev); - if (majdev >= sizeof(devname) / sizeof(devname[0])) - return; - adaptor = B_ADAPTOR(bootdev); - controller = B_CONTROLLER(bootdev); - part = B_PARTITION(bootdev); - unit = B_UNIT(bootdev); - /* - * First, find the controller type which supports this device. - */ - for (hd = hp_dinit; hd->hp_driver; hd++) - if (hd->hp_driver->d_name[0] == devname[majdev][0] && - hd->hp_driver->d_name[1] == devname[majdev][1]) - break; - if (hd->hp_driver == 0) - return; - /* - * Next, find the "controller" (bus adaptor) of that type - * corresponding to the adaptor number. - */ - for (hc = hp_cinit; hc->hp_driver; hc++) - if (hc->hp_alive && hc->hp_unit == adaptor && - hc->hp_driver == hd->hp_cdriver) - break; - if (hc->hp_driver == 0) - return; - /* - * Finally, find the "device" (controller or slave) in question - * attached to that "controller". - */ - for (hd = hp_dinit; hd->hp_driver; hd++) - if (hd->hp_alive && hd->hp_slave == controller && - hd->hp_cdriver == hc->hp_driver && - hd->hp_ctlr == hc->hp_unit) - break; - if (hd->hp_driver == 0) - return; - /* - * XXX note that we are missing one level, the unit, here. - * Most HP drives come with one controller per disk. There - * are some older drives (e.g. 7946) which have two units - * on the same controller but those are typically a disk as - * unit 0 and a tape as unit 1. This would have to be - * rethought if you ever wanted to boot from other than unit 0. - */ - if (unit != 0) - printf("WARNING: using device at unit 0 of controller\n"); - - mindev = hd->hp_unit; - /* - * Form a new rootdev - */ - mindev = (mindev << PARTITIONSHIFT) + part; - orootdev = rootdev; - rootdev = makedev(majdev, mindev); - /* - * If the original rootdev is the same as the one - * just calculated, don't need to adjust the swap configuration. - */ - if (rootdev == orootdev) - return; - - printf("Changing root device to %c%c%d%c\n", - devname[majdev][0], devname[majdev][1], - mindev >> PARTITIONSHIFT, part + 'a'); - -#ifdef DOSWAP - mindev &= ~PARTITIONMASK; - for (swp = swdevt; swp->sw_dev != NODEV; swp++) { - if (majdev == major(swp->sw_dev) && - mindev == (minor(swp->sw_dev) & ~PARTITIONMASK)) { - temp = swdevt[0].sw_dev; - swdevt[0].sw_dev = swp->sw_dev; - swp->sw_dev = temp; - break; - } - } - if (swp->sw_dev == NODEV) - return; - - /* - * If dumpdev was the same as the old primary swap - * device, move it to the new primary swap device. - */ - if (temp == dumpdev) - dumpdev = swdevt[0].sw_dev; -#endif -} - -#ifndef NEWCONFIG /* XXX */ -void -config_init() -{ - - TAILQ_INIT(&alldevs); - TAILQ_INIT(&allevents); -} -#endif +#endif /* ! NEWCONFIG */ diff --git a/sys/arch/hp300/hp300/clock.c b/sys/arch/hp300/hp300/clock.c index 09615a6e7a7..f96a8f2ee3b 100644 --- a/sys/arch/hp300/hp300/clock.c +++ b/sys/arch/hp300/hp300/clock.c @@ -1,4 +1,5 @@ -/* $NetBSD: clock.c,v 1.14 1996/05/18 23:30:12 thorpej Exp $ */ +/* $OpenBSD: clock.c,v 1.3 1997/01/12 15:13:11 downsj Exp $ */ +/* $NetBSD: clock.c,v 1.18 1996/10/13 03:14:27 christos Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -164,6 +165,14 @@ hp300_calibrate_delay() asm volatile(" movpw %0@(5),%1" : : "a" (clk), "d" (intvl)); } + /* + * Make sure the clock interrupt is disabled. Otherwise, + * we can end up calling hardclock() before proc0 is set up, + * causing a bad pointer deref. + */ + clk->clk_cr2 = CLK_CR1; + clk->clk_cr1 = CLK_RESET; + /* * Sanity check the delay_divisor value. If we totally lost, * assume a 50MHz CPU; @@ -344,7 +353,7 @@ inittodr(base) /* XXX */ if (!bbcinited) { - if (badbaddr(&BBCADDR->hil_stat)) + if (badbaddr((caddr_t)&BBCADDR->hil_stat)) printf("WARNING: no battery clock\n"); else bbcaddr = BBCADDR; diff --git a/sys/arch/hp300/hp300/clockioctl.h b/sys/arch/hp300/hp300/clockioctl.h index bb098a70255..5f77ba3fa1d 100644 --- a/sys/arch/hp300/hp300/clockioctl.h +++ b/sys/arch/hp300/hp300/clockioctl.h @@ -1,3 +1,4 @@ +/* $OpenBSD: clockioctl.h,v 1.2 1997/01/12 15:13:12 downsj Exp $ */ /* $NetBSD: clockioctl.h,v 1.5 1994/10/26 07:25:25 cgd Exp $ */ /* diff --git a/sys/arch/hp300/hp300/clockreg.h b/sys/arch/hp300/hp300/clockreg.h index 7a80286b1e7..fa76e6122dc 100644 --- a/sys/arch/hp300/hp300/clockreg.h +++ b/sys/arch/hp300/hp300/clockreg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: clockreg.h,v 1.2 1997/01/12 15:13:13 downsj Exp $ */ /* $NetBSD: clockreg.h,v 1.5 1994/10/26 07:25:26 cgd Exp $ */ /* diff --git a/sys/arch/hp300/hp300/conf.c b/sys/arch/hp300/hp300/conf.c index 20a3251d289..4729c304fd4 100644 --- a/sys/arch/hp300/hp300/conf.c +++ b/sys/arch/hp300/hp300/conf.c @@ -1,4 +1,5 @@ -/* $NetBSD: conf.c,v 1.31 1996/03/14 21:26:28 christos Exp $ */ +/* $OpenBSD: conf.c,v 1.9 1997/01/12 15:13:13 downsj Exp $ */ +/* $NetBSD: conf.c,v 1.34 1996/12/17 08:41:20 thorpej Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -43,14 +44,6 @@ #include #include -int ttselect __P((dev_t, int, struct proc *)); - -#ifndef LKM -#define lkmenodev enodev -#else -int lkmenodev(); -#endif - #include "ct.h" bdev_decl(ct); #include "mt.h" @@ -145,12 +138,6 @@ dev_decl(filedesc,open); cdev_decl(bpf); #include "tun.h" cdev_decl(tun); -#ifdef LKM -#define NLKM 1 -#else -#define NLKM 0 -#endif -cdev_decl(lkm); cdev_decl(random); struct cdevsw cdevsw[] = @@ -275,6 +262,24 @@ chrtoblk(dev) return (makedev(blkmaj, minor(dev))); } +/* + * Convert a character device number to a block device number. + */ +dev_t +blktochr(dev) + dev_t dev; +{ + int blkmaj = major(dev); + int i; + + if (blkmaj >= nblkdev) + return (NODEV); + for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++) + if (blkmaj == chrtoblktbl[i]) + return (makedev(i, minor(dev))); + return (NODEV); +} + /* * This entire table could be autoconfig()ed but that would mean that * the kernel's idea of the console would be out of sync with that of @@ -308,22 +313,46 @@ cons_decl(rbox); #define topcatcnpollc nullcnpollc cons_decl(topcat); -#define dcacnpollc nullcnpollc +#define dcacnpollc nullcnpollc cons_decl(dca); -#define dcmcnpollc nullcnpollc +#define dcmcnpollc nullcnpollc cons_decl(dcm); +#ifdef NEWCONFIG +#include "dvbox.h" +#include "gbox.h" +#include "hyper.h" +#include "rbox.h" +#include "topcat.h" +#else /* ! NEWCONFIG */ +#if NGRF > 0 +#define NDVBOX 1 +#define NGBOX 1 +#define NHYPER 1 +#define NRBOX 1 +#define NTOPCAT 1 +#endif /* NGRF > 0 */ +#endif /* NEWCONFIG */ + struct consdev constab[] = { #if NITE > 0 -#if NGRF > 0 /* XXX */ +#if NDVBOX > 0 cons_init(dvbox), +#endif +#if NGBOX > 0 cons_init(gbox), +#endif +#if NHYPER > 0 cons_init(hyper), +#endif +#if NRBOX > 0 cons_init(rbox), - cons_init(topcat), #endif +#if NTOPCAT > 0 + cons_init(topcat), #endif +#endif /* NITE > 0 */ #if NDCA > 0 cons_init(dca), #endif diff --git a/sys/arch/hp300/hp300/db_memrw.c b/sys/arch/hp300/hp300/db_memrw.c new file mode 100644 index 00000000000..fbe6458d70a --- /dev/null +++ b/sys/arch/hp300/hp300/db_memrw.c @@ -0,0 +1,225 @@ +/* $OpenBSD: db_memrw.c,v 1.1 1997/01/12 15:13:14 downsj Exp $ */ +/* $NetBSD: db_memrw.c,v 1.2 1996/12/09 17:38:27 thorpej Exp $ */ + +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Gordon W. Ross and Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Interface to the debugger for virtual memory read/write. + * This file is shared by DDB and KGDB, and must work even + * when only KGDB is included (thus no db_printf calls). + * + * To write in the text segment, we have to first make + * the page writable, do the write, then restore the PTE. + * For writes outside the text segment, and all reads, + * just do the access -- if it causes a fault, the debugger + * will recover with a longjmp to an appropriate place. + * + * ALERT! If you want to access device registers with a + * specific size, then the read/write functions have to + * make sure to do the correct sized pointer access. + * + * Modified from sun3 version for hp300 (and probably other m68ks, too) + * by Jason R. Thorpe . + */ + +#include +#include +#include + +#include + +#include +#include +#include + +#include + +static void db_write_text __P((vm_offset_t, size_t, char *)); + +/* + * Read bytes from kernel address space for debugger. + * This used to check for valid PTEs, but now that + * traps in DDB work correctly, "Just Do It!" + */ +void +db_read_bytes(addr, size, data) + vm_offset_t addr; + register size_t size; + register char *data; +{ + register char *src = (char*)addr; + + if (size == 4) { + *((int*)data) = *((int*)src); + return; + } + + if (size == 2) { + *((short*)data) = *((short*)src); + return; + } + + while (size > 0) { + --size; + *data++ = *src++; + } +} + +/* + * Write bytes somewhere in kernel text. + * Makes text page writable temporarily. + * We're probably a little to cache-paranoid. + */ +static void +db_write_text(addr, size, data) + vm_offset_t addr; + register size_t size; + register char *data; +{ + register char *dst, *odst; + pt_entry_t *pte, oldpte, tmppte; + vm_offset_t pgva; + int limit; + + if (size == 0) + return; + + dst = (char *)addr; + + do { + /* + * Get the VA for the page. + */ + pgva = hp300_trunc_page((u_long)dst); + + /* + * Save this destination address, for TLB + * flush. + */ + odst = dst; + + /* + * Compute number of bytes that can be written + * with this mapping and subtract it from the + * total size. + */ + limit = NBPG - ((u_long)dst & PGOFSET); + if (limit > size) + limit = size; + size -= limit; + +#ifdef M68K_MMU_HP + /* + * Flush the supervisor side of the VAC to + * prevent a cache hit on the old, read-only PTE. + * XXX Is this really necessary, or am I just + * paranoid? + */ + if (ectype == EC_VIRT) + DCIS(); +#endif + + /* + * Make the page writable. Note the mapping is + * cache-inhibited to save hair. + */ + pte = kvtopte(pgva); + oldpte = *pte; + + if ((oldpte & PG_V) == 0) { + printf(" address %p not a valid page\n", dst); + return; + } + + tmppte = (oldpte & ~PG_RO) | PG_RW | PG_CI; + *pte = tmppte; + TBIS((vm_offset_t)odst); + + /* + * Page is now writable. Do as much access as we + * can in this page. + */ + for (; limit > 0; limit--) + *dst++ = *data++; + + /* + * Restore the old PTE. + */ + *pte = oldpte; + TBIS((vm_offset_t)odst); + } while (size != 0); + + /* + * Invalidate the instruction cache so our changes + * take effect. + */ + ICIA(); +} + +/* + * Write bytes to kernel address space for debugger. + */ +extern char kernel_text[], etext[]; +void +db_write_bytes(addr, size, data) + vm_offset_t addr; + register size_t size; + register char *data; +{ + register char *dst = (char *)addr; + + /* If any part is in kernel text, use db_write_text() */ + if ((dst < etext) && ((dst + size) > kernel_text)) { + db_write_text(addr, size, data); + return; + } + + if (size == 4) { + *((int*)dst) = *((int*)data); + return; + } + + if (size == 2) { + *((short*)dst) = *((short*)data); + return; + } + + while (size > 0) { + --size; + *dst++ = *data++; + } +} diff --git a/sys/arch/hp300/hp300/disksubr.c b/sys/arch/hp300/hp300/disksubr.c index 5690b4d0329..d96bdf81ba5 100644 --- a/sys/arch/hp300/hp300/disksubr.c +++ b/sys/arch/hp300/hp300/disksubr.c @@ -1,3 +1,4 @@ +/* $OpenBSD: disksubr.c,v 1.3 1997/01/12 15:13:14 downsj Exp $ */ /* $NetBSD: disksubr.c,v 1.8 1996/02/02 19:50:26 scottr Exp $ */ /* @@ -48,6 +49,13 @@ #define b_cylinder b_resid +void +dk_establish(dk, dev) + struct disk *dk; + struct device *dev; +{ +} + /* * Attempt to read a disk label from a device using the indicated stategy * routine. The label must be partly set up before this: secpercyl and diff --git a/sys/arch/hp300/hp300/dkbad.c b/sys/arch/hp300/hp300/dkbad.c index c938396db16..f504e699b9b 100644 --- a/sys/arch/hp300/hp300/dkbad.c +++ b/sys/arch/hp300/hp300/dkbad.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dkbad.c,v 1.2 1997/01/12 15:13:15 downsj Exp $ */ /* $NetBSD: dkbad.c,v 1.4 1994/10/26 07:25:33 cgd Exp $ */ /* diff --git a/sys/arch/hp300/hp300/genassym.c b/sys/arch/hp300/hp300/genassym.c index 123869881cf..95919bf5208 100644 --- a/sys/arch/hp300/hp300/genassym.c +++ b/sys/arch/hp300/hp300/genassym.c @@ -1,4 +1,5 @@ -/* $NetBSD: genassym.c,v 1.19 1996/05/17 15:20:55 thorpej Exp $ */ +/* $OpenBSD: genassym.c,v 1.5 1997/01/12 15:13:16 downsj Exp $ */ +/* $NetBSD: genassym.c,v 1.21 1996/10/05 07:11:44 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -96,7 +97,7 @@ flush() main() { - /* CPU types */ + /* CPU options */ #ifdef M68020 def("M68020", 1); #endif @@ -107,18 +108,25 @@ main() def("M68040", 1); #endif - /* MMU types */ + /* MMU options */ #ifdef M68K_MMU_MOTOROLA def("M68K_MMU_MOTOROLA", 1); #endif #ifdef M68K_MMU_HP def("M68K_MMU_HP", 1); #endif + + /* MMU types */ def("MMU_68040", MMU_68040); def("MMU_68030", MMU_68030); def("MMU_HP", MMU_HP); def("MMU_68851", MMU_68851); + /* CPU types */ + def("CPU_68020", CPU_68020); + def("CPU_68030", CPU_68030); + def("CPU_68040", CPU_68040); + /* values for machineid */ def("HP_320", HP_320); def("HP_330", HP_330); @@ -245,6 +253,7 @@ main() off("FR_SP", struct frame, f_regs[15]); off("FR_HW", struct frame, f_sr); off("FR_ADJ", struct frame, f_stackadj); + def("FR_SIZE", sizeof(struct trapframe)); /* system calls */ def("SYS_exit", SYS_exit); diff --git a/sys/arch/hp300/hp300/hpux_machdep.c b/sys/arch/hp300/hp300/hpux_machdep.c index 10bf2ed1cff..0133d4fe14d 100644 --- a/sys/arch/hp300/hp300/hpux_machdep.c +++ b/sys/arch/hp300/hp300/hpux_machdep.c @@ -1,4 +1,5 @@ -/* $NetBSD: hpux_machdep.c,v 1.2 1996/02/14 02:56:45 thorpej Exp $ */ +/* $OpenBSD: hpux_machdep.c,v 1.3 1997/01/12 15:13:16 downsj Exp $ */ +/* $NetBSD: hpux_machdep.c,v 1.5 1996/10/14 06:51:50 thorpej Exp $ */ /* * Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved. @@ -51,6 +52,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/arch/hp300/hp300/isr.c b/sys/arch/hp300/hp300/isr.c index 5b284c86c53..62a42ed8ee9 100644 --- a/sys/arch/hp300/hp300/isr.c +++ b/sys/arch/hp300/hp300/isr.c @@ -1,13 +1,12 @@ -/* $NetBSD: isr.c,v 1.1 1996/02/14 02:56:48 thorpej Exp $ */ +/* $OpenBSD: isr.c,v 1.2 1997/01/12 15:13:17 downsj Exp $ */ +/* $NetBSD: isr.c,v 1.5 1996/12/09 17:38:25 thorpej Exp $ */ -/* - * Copyright (c) 1995, 1996 Jason R. Thorpe. +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. * All rights reserved. * - * Portions: - * Copyright (c) 1994 Gordon W. Ross. - * Copyright (c) 1993 Adam Glass. - * All rights reserved. + * This code is derived from software contributed to The NetBSD Foundation + * by Adam Glass, Gordon W. Ross, and Jason R. Thorpe. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -18,24 +17,24 @@ * 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 acknowledgements: - * This product includes software developed by Adam Glass. - * This product includes software developed for the NetBSD Project - * by Jason R. Thorpe. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ /* @@ -46,16 +45,21 @@ #include #include #include -#include #include +#include + #include typedef LIST_HEAD(, isr) isr_list_t; isr_list_t isr_list[NISR]; +u_short hp300_bioipl, hp300_netipl, hp300_ttyipl, hp300_impipl; + extern int intrcnt[]; /* from locore.s */ +void isrcomputeipl __P((void)); + void isrinit() { @@ -65,13 +69,90 @@ isrinit() for (i = 0; i < NISR; ++i) { LIST_INIT(&isr_list[i]); } + + /* Default interrupt priorities. */ + hp300_bioipl = hp300_netipl = hp300_ttyipl = hp300_impipl = + (PSL_S|PSL_IPL3); +} + +/* + * Scan all of the ISRs, recomputing the interrupt levels for the spl*() + * calls. This doesn't have to be fast. + */ +void +isrcomputeipl() +{ + struct isr *isr; + int ipl; + + /* Start with low values. */ + hp300_bioipl = hp300_netipl = hp300_ttyipl = hp300_impipl = + (PSL_S|PSL_IPL3); + + for (ipl = 0; ipl < NISR; ipl++) { + for (isr = isr_list[ipl].lh_first; isr != NULL; + isr = isr->isr_link.le_next) { + /* + * Bump up the level for a given priority, + * if necessary. + */ + switch (isr->isr_priority) { + case ISRPRI_BIO: + if (ipl > PSLTOIPL(hp300_bioipl)) + hp300_bioipl = IPLTOPSL(ipl); + break; + + case ISRPRI_NET: + if (ipl > PSLTOIPL(hp300_netipl)) + hp300_netipl = IPLTOPSL(ipl); + break; + + case ISRPRI_TTY: + case ISRPRI_TTYNOBUF: + if (ipl > PSLTOIPL(hp300_ttyipl)) + hp300_ttyipl = IPLTOPSL(ipl); + break; + + default: + printf("priority = %d\n", isr->isr_priority); + panic("isrcomputeipl: bad priority"); + } + } + } + + /* + * Enforce `bio <= net <= tty <= imp' + */ + + if (hp300_netipl < hp300_bioipl) + hp300_netipl = hp300_bioipl; + + if (hp300_ttyipl < hp300_netipl) + hp300_ttyipl = hp300_netipl; + + if (hp300_impipl < hp300_ttyipl) + hp300_impipl = hp300_ttyipl; +} + +void +isrprintlevels() +{ + +#ifdef DEBUG + printf("psl: bio = 0x%x, net = 0x%x, tty = 0x%x, imp = 0x%x\n", + hp300_bioipl, hp300_netipl, hp300_ttyipl, hp300_impipl); +#endif + + printf("interrupt levels: bio = %d, net = %d, tty = %d\n", + PSLTOIPL(hp300_bioipl), PSLTOIPL(hp300_netipl), + PSLTOIPL(hp300_ttyipl)); } /* * Establish an interrupt handler. * Called by driver attach functions. */ -void +void * isrlink(func, arg, ipl, priority) int (*func) __P((void *)); void *arg; @@ -120,7 +201,7 @@ isrlink(func, arg, ipl, priority) list = &isr_list[ipl]; if (list->lh_first == NULL) { LIST_INSERT_HEAD(list, newisr, isr_link); - return; + goto compute; } /* @@ -132,7 +213,7 @@ isrlink(func, arg, ipl, priority) curisr = curisr->isr_link.le_next) { if (newisr->isr_priority > curisr->isr_priority) { LIST_INSERT_BEFORE(curisr, newisr, isr_link); - return; + goto compute; } } @@ -141,6 +222,25 @@ isrlink(func, arg, ipl, priority) * on the end. */ LIST_INSERT_AFTER(curisr, newisr, isr_link); + + compute: + /* Compute new interrupt levels. */ + isrcomputeipl(); + return (newisr); +} + +/* + * Disestablish an interrupt handler. + */ +void +isrunlink(arg) + void *arg; +{ + struct isr *isr = arg; + + LIST_REMOVE(isr, isr_link); + free(isr, M_DEVBUF); + isrcomputeipl(); } /* diff --git a/sys/arch/hp300/hp300/isr.h b/sys/arch/hp300/hp300/isr.h index 3bf7d404388..09723c5d5fa 100644 --- a/sys/arch/hp300/hp300/isr.h +++ b/sys/arch/hp300/hp300/isr.h @@ -1,4 +1,5 @@ -/* $NetBSD: isr.h,v 1.6 1996/02/28 01:03:53 thorpej Exp $ */ +/* $OpenBSD: isr.h,v 1.3 1997/01/12 15:13:18 downsj Exp $ */ +/* $NetBSD: isr.h,v 1.7 1996/12/09 03:04:47 thorpej Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -55,12 +56,23 @@ struct isr { /* * ISR priorities. These are not the same as interrupt levels. + * These serve 2 purposes: + * - properly order ISRs in the list + * - compute levels for spl*() calls. */ #define ISRPRI_BIO 0 #define ISRPRI_NET 1 #define ISRPRI_TTY 2 #define ISRPRI_TTYNOBUF 3 +/* + * Convert PSL values to IPLs and vice-versa. + */ +#define PSLTOIPL(x) (((x) >> 8) & 0xf) +#define IPLTOPSL(x) ((((x) & 0xf) << 8) | PSL_S) + void isrinit __P((void)); -void isrlink __P((int (*)(void *), void *, int, int)); +void *isrlink __P((int (*)(void *), void *, int, int)); +void isrunlink __P((void *)); void isrdispatch __P((int)); +void isrprintlevels __P((void)); diff --git a/sys/arch/hp300/hp300/kgdb_glue.c b/sys/arch/hp300/hp300/kgdb_glue.c index b6a3345ed23..2b22e83025e 100644 --- a/sys/arch/hp300/hp300/kgdb_glue.c +++ b/sys/arch/hp300/hp300/kgdb_glue.c @@ -1,3 +1,4 @@ +/* $OpenBSD: kgdb_glue.c,v 1.2 1997/01/12 15:13:18 downsj Exp $ */ /* $NetBSD: kgdb_glue.c,v 1.2 1994/10/26 07:25:39 cgd Exp $ */ /* diff --git a/sys/arch/hp300/hp300/kgdb_proto.h b/sys/arch/hp300/hp300/kgdb_proto.h index 9ac6638cb31..f03ec8288e1 100644 --- a/sys/arch/hp300/hp300/kgdb_proto.h +++ b/sys/arch/hp300/hp300/kgdb_proto.h @@ -1,3 +1,4 @@ +/* $OpenBSD: kgdb_proto.h,v 1.2 1997/01/12 15:13:19 downsj Exp $ */ /* $NetBSD: kgdb_proto.h,v 1.2 1994/10/26 07:25:40 cgd Exp $ */ /*- diff --git a/sys/arch/hp300/hp300/kgdb_stub.c b/sys/arch/hp300/hp300/kgdb_stub.c index c68ab7e8ea1..00dfa2bfa82 100644 --- a/sys/arch/hp300/hp300/kgdb_stub.c +++ b/sys/arch/hp300/hp300/kgdb_stub.c @@ -1,4 +1,5 @@ -/* $NetBSD: kgdb_stub.c,v 1.3 1995/04/12 08:30:40 mycroft Exp $ */ +/* $OpenBSD: kgdb_stub.c,v 1.2 1997/01/12 15:13:20 downsj Exp $ */ +/* $NetBSD: kgdb_stub.c,v 1.6 1996/10/13 03:14:30 christos Exp $ */ /* * Copyright (c) 1990, 1993 @@ -49,7 +50,7 @@ */ #ifdef KGDB #ifndef lint -static char rcsid[] = "$NetBSD: kgdb_stub.c,v 1.3 1995/04/12 08:30:40 mycroft Exp $"; +static char rcsid[] = "$NetBSD: kgdb_stub.c,v 1.6 1996/10/13 03:14:30 christos Exp $"; #endif #include @@ -206,26 +207,18 @@ computeSignal(type) switch (type) { case T_BUSERR: - sigval = SIGBUS; - break; case T_ADDRERR: sigval = SIGBUS; break; case T_ILLINST: + case T_PRIVINST: sigval = SIGILL; break; case T_ZERODIV: - sigval = SIGFPE; - break; case T_CHKINST: - sigval = SIGFPE; - break; case T_TRAPVINST: sigval = SIGFPE; break; - case T_PRIVINST: - sigval = SIGILL; - break; case T_TRACE: sigval = SIGTRAP; break; @@ -239,8 +232,6 @@ computeSignal(type) sigval = SIGILL; break; case T_FPERR: - sigval = SIGFPE; - break; case T_COPERR: sigval = SIGFPE; break; diff --git a/sys/arch/hp300/hp300/led.h b/sys/arch/hp300/hp300/led.h index 231a072b41d..b7d928b4f81 100644 --- a/sys/arch/hp300/hp300/led.h +++ b/sys/arch/hp300/hp300/led.h @@ -1,4 +1,5 @@ -/* $NetBSD: led.h,v 1.3 1995/03/28 18:16:24 jtc Exp $ */ +/* $OpenBSD: led.h,v 1.2 1997/01/12 15:13:20 downsj Exp $ */ +/* $NetBSD: led.h,v 1.4 1996/10/05 09:18:22 thorpej Exp $ */ /* * Copyright (c) 1992 University of Utah. @@ -52,4 +53,6 @@ #ifdef _KERNEL extern char *ledaddr; extern int inledcontrol; + +void ledcontrol __P((int, int, int)); #endif diff --git a/sys/arch/hp300/hp300/locore.s b/sys/arch/hp300/hp300/locore.s index 0b0fcfab7c7..3e0f077c3b3 100644 --- a/sys/arch/hp300/hp300/locore.s +++ b/sys/arch/hp300/hp300/locore.s @@ -1,6 +1,8 @@ -/* $NetBSD: locore.s,v 1.53 1996/05/17 16:32:28 thorpej Exp $ */ +/* $OpenBSD: locore.s,v 1.7 1997/01/12 15:13:22 downsj Exp $ */ +/* $NetBSD: locore.s,v 1.62 1996/11/06 20:19:30 cgd Exp $ */ /* + * Copyright (c) 1994, 1995 Gordon W. Ross * Copyright (c) 1988 University of Utah. * Copyright (c) 1980, 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -55,6 +57,11 @@ .globl _kernel_text _kernel_text: +/* + * Clear and skip the first page of text; it will not be mapped. + */ + .fill NBPG/4,4,0 + /* * Temporary stack for a variety of purposes. * Try and make this the first thing is the data segment so it @@ -68,18 +75,6 @@ tmpstk: #include .text -/* - * This is where we wind up if the kernel jumps to location 0. - * (i.e. a bogus PC) This is known to immediately follow the vector - * table and is hence at 0x400 (see reset vector in vectors.s). - */ - .globl _panic - pea Ljmp0panic - jbsr _panic - /* NOTREACHED */ -Ljmp0panic: - .asciz "kernel jump to zero" - .even /* * Do a dump. @@ -98,6 +93,11 @@ _doadump: .globl _trap, _nofault, _longjmp _buserr: + /* + * XXX TODO: look at the mac68k _buserr and generalize + * XXX the saving of the fault address so this routine + * XXX can be shared. + */ tstl _nofault | device probe? jeq Lberr | no, handle as usual movl _nofault,sp@- | yes, @@ -191,12 +191,31 @@ Lbe10: tstl _mmutype | HP MMU? jeq Lbehpmmu | yes, skip movl d1,a0 | fault address - ptestr #1,a0@,#7 | do a table search + movl sp@,d0 | function code from ssw + btst #8,d0 | data fault? + jne Lbe10a + movql #1,d0 | user program access FC + | (we dont separate data/program) + btst #5,a1@ | supervisor mode? + jeq Lbe10a | if no, done + movql #5,d0 | else supervisor program access +Lbe10a: + ptestr d0,a0@,#7 | do a table search pmove psr,sp@ | save result - btst #7,sp@ | bus error bit set? - jeq Lismerr | no, must be MMU fault - clrw sp@ | yes, re-clear pad word - jra Lisberr | and process as normal bus error + movb sp@,d1 + btst #2,d1 | invalid? (incl. limit viol and berr) + jeq Lmightnotbemerr | no -> wp check + btst #7,d1 | is it MMU table berr? + jeq Lismerr | no, must be fast + jra Lisberr1 | real bus err needs not be fast +Lmightnotbemerr: + btst #3,d1 | write protect bit set? + jeq Lisberr1 | no, must be bus error + movl sp@,d0 | ssw into low word of d0 + andw #0xc0,d0 | write protect is set on page: + cmpw #0x40,d0 | was it read cycle? + jeq Lisberr1 | yes, was not WPE, must be bus err + jra Lismerr | no, must be mem err Lbehpmmu: #endif #if defined(M68K_MMU_HP) @@ -213,6 +232,8 @@ Lismerr: Lisaerr: movl #T_ADDRERR,sp@- | mark address error jra Ltrapnstkadj | and deal with it +Lisberr1: + clrw sp@ | re-clear pad word Lisberr: movl #T_BUSERR,sp@- | mark bus error Ltrapnstkadj: @@ -291,6 +312,11 @@ _fpfault: movl _curpcb,a0 | current pcb lea a0@(PCB_FPCTX),a0 | address of FP savearea fsave a0@ | save state +#if defined(M68040) || defined(M68060) + /* always null state frame on 68040, 68060 */ + cmpl #MMU_68040,_mmutype + jle Lfptnull +#endif tstb a0@ | null state frame? jeq Lfptnull | yes, safe clrw d0 | no, need to tweak BIU @@ -444,46 +470,101 @@ _trap12: lea sp@(12),sp | pop args jra rei | all done +/* + * Trace (single-step) trap. Kernel-mode is special. + * User mode traps are simply passed on to trap(). + */ +_trace: + clrl sp@- | stack adjust count + moveml #0xFFFF,sp@- + moveq #T_TRACE,d0 + movw sp@(FR_HW),d1 | get PSW + andw #PSL_S,d1 | from system mode? + jne kbrkpt | yes, kernel breakpoint + jra fault | no, user-mode fault + /* * Trap 15 is used for: - * - KGDB traps + * - GDB breakpoints (in user programs) + * - KGDB breakpoints (in the kernel) * - trace traps for SUN binaries (not fully supported yet) - * We just pass it on and let trap() sort it all out + * User mode traps are simply passed to trap(). */ _trap15: - clrl sp@- + clrl sp@- | stack adjust count moveml #0xFFFF,sp@- -#ifdef KGDB moveq #T_TRAP15,d0 movw sp@(FR_HW),d1 | get PSW - andw #PSL_S,d1 | from user mode? - jeq fault | yes, just a regular fault - movl d0,sp@- - .globl _kgdb_trap_glue - jbsr _kgdb_trap_glue | returns if no debugger - addl #4,sp -#endif - moveq #T_TRAP15,d0 - jra fault + andw #PSL_S,d1 | from system mode? + jne kbrkpt | yes, kernel breakpoint + jra fault | no, user-mode fault -/* - * Hit a breakpoint (trap 1 or 2) instruction. - * Push the code and treat as a normal fault. - */ -_trace: - clrl sp@- - moveml #0xFFFF,sp@- +kbrkpt: | Kernel-mode breakpoint or trace trap. (d0=trap_type) + | Save the system sp rather than the user sp. + movw #PSL_HIGHIPL,sr | lock out interrupts + lea sp@(FR_SIZE),a6 | Save stack pointer + movl a6,sp@(FR_SP) | from before trap + + | If were are not on tmpstk switch to it. + | (so debugger can change the stack pointer) + movl a6,d1 + cmpl #tmpstk,d1 + jls Lbrkpt2 | already on tmpstk + | Copy frame to the temporary stack + movl sp,a0 | a0=src + lea tmpstk-96,a1 | a1=dst + movl a1,sp | sp=new frame + moveq #FR_SIZE,d1 +Lbrkpt1: + movl a0@+,a1@+ + subql #4,d1 + bgt Lbrkpt1 + +Lbrkpt2: + | Call the trap handler for the kernel debugger. + | Do not call trap() to do it, so that we can + | set breakpoints in trap() if we want. We know + | the trap type is either T_TRACE or T_BREAKPOINT. + | If we have both DDB and KGDB, let KGDB see it first, + | because KGDB will just return 0 if not connected. + | Save args in d2, a2 + movl d0,d2 | trap type + movl sp,a2 | frame ptr #ifdef KGDB - moveq #T_TRACE,d0 - movw sp@(FR_HW),d1 | get SSW - andw #PSL_S,d1 | from user mode? - jeq fault | no, regular fault - movl d0,sp@- - jbsr _kgdb_trap_glue | returns if no debugger - addl #4,sp + | Let KGDB handle it (if connected) + movl a2,sp@- | push frame ptr + movl d2,sp@- | push trap type + jbsr _kgdb_trap | handle the trap + addql #8,sp | pop args + cmpl #0,d0 | did kgdb handle it? + jne Lbrkpt3 | yes, done #endif - moveq #T_TRACE,d0 - jra fault +#ifdef DDB + | Let DDB handle it + movl a2,sp@- | push frame ptr + movl d2,sp@- | push trap type + jbsr _kdb_trap | handle the trap + addql #8,sp | pop args +#if 0 /* not needed on hp300 */ + cmpl #0,d0 | did ddb handle it? + jne Lbrkpt3 | yes, done +#endif +#endif + /* Sun 3 drops into PROM here. */ +Lbrkpt3: + | The stack pointer may have been modified, or + | data below it modified (by kgdb push call), + | so push the hardware frame at the current sp + | before restoring registers and returning. + + movl sp@(FR_SP),a0 | modified sp + lea sp@(FR_SIZE),a1 | end of our frame + movl a1@-,a0@- | copy 2 longs with + movl a1@-,a0@- | ... predecrement + movl a0,sp@(FR_SP) | sp = h/w frame + moveml sp@+,#0x7FFF | restore all but sp + movl sp@,sp | ... and sp + rte | all done /* Use common m68k sigreturn */ #include @@ -689,8 +770,11 @@ Lnosir: Ldorte: rte | real return -#define RELOC(var, ar) \ - lea var,ar; \ +/* + * Macro to relocate a symbol, used before MMU is enabled. + */ +#define RELOC(var, ar) \ + lea var,ar; \ addl a5,ar /* @@ -724,6 +808,24 @@ start: movl #CACHE_OFF,d0 movc d0,cacr | clear and disable on-chip cache(s) +/* check for internal HP-IB in SYSFLAG */ + btst #5,0xfffffed2 | internal HP-IB? + jeq Lhaveihpib | yes, have HP-IB just continue + RELOC(_internalhpib, a0) + movl #0,a0@ | no, clear associated address +Lhaveihpib: + + RELOC(_boothowto, a0) | save reboot flags + movl d7,a0@ + RELOC(_bootdev, a0) | and boot device + movl d6,a0@ + + /* + * All data registers are now free. All address registers + * except a5 are free. a5 is used by the RELOC() macro, + * and cannot be used until after the MMU is enabled. + */ + /* determine our CPU/MMU combo - check for all regardless of kernel config */ movl #INTIOBASE+MMUBASE,a1 movl #0x200,d0 | data freeze bit @@ -733,6 +835,8 @@ start: jeq Lnot68030 | yes, we have 68020/68040 RELOC(_mmutype, a0) | no, we have 68030 movl #MMU_68030,a0@ | set to reflect 68030 PMMU + RELOC(_cputype, a0) + movl #CPU_68030,a0@ | and 68030 CPU RELOC(_machineid, a0) movl #0x80,a1@(MMUCMD) | set magic cookie movl a1@(MMUCMD),d0 | read it back @@ -768,6 +872,8 @@ Lnot68030: movec d0,cacr | before we access any data RELOC(_mmutype, a0) movl #MMU_68040,a0@ | with a 68040 MMU + RELOC(_cputype, a0) + movl #CPU_68040,a0@ | and a 68040 CPU RELOC(_ectype, a0) movl #EC_NONE,a0@ | and no cache (for now XXX) RELOC(_machineid, a0) @@ -881,7 +987,20 @@ Lcodecopy: jcs Lcodecopy | no, keep going jmp MAXADDR | go for it! + /* + * BEGIN MMU TRAMPOLINE. This section of code is not + * executed in-place. It's copied to the last page + * of RAM (mapped va == pa) and executed there. + */ + Lhighcode: + /* + * Set up the vector table, and race to get the MMU + * enabled. + */ + movl #_vectab,d0 | set Vector Base Register + movc d0,vbr + RELOC(_mmutype, a0) tstl a0@ | HP MMU? jeq Lhpmmu3 | yes, skip @@ -905,6 +1024,7 @@ Lhighcode: Lmotommu2: movl #MMU_IEN+MMU_FPE,INTIOBASE+MMUBASE+MMUCMD | enable 68881 and i-cache + RELOC(_prototc, a2) movl #0x82c0aa00,a2@ | value to load TC with pmove a2@,tc | load it jmp Lenab1 @@ -914,21 +1034,22 @@ Lhpmmu3: jmp Lenab1 | jmp to mapped code Lehighcode: + /* + * END MMU TRAMPOLINE. Address register a5 is now free. + */ + /* * Should be running mapped from this point on */ Lenab1: -/* check for internal HP-IB in SYSFLAG */ - btst #5,0xfffffed2 | internal HP-IB? - jeq Lfinish | yes, have HP-IB just continue - clrl _internalhpib | no, clear associated address -Lfinish: /* select the software page size now */ lea tmpstk,sp | temporary stack jbsr _vm_set_page_size | select software page size /* set kernel stack, user SP, and initial pcb */ movl _proc0paddr,a1 | get proc0 pcb addr lea a1@(USPACE-4),sp | set kernel stack to end of area + lea _proc0,a2 | initialize proc0.p_addr so that + movl a1,a2@(P_ADDR) | we don't deref NULL in trap() movl #USRSTACK-4,a2 movl a2,usp | init user SP movl a1,_curpcb | proc0 is running @@ -949,14 +1070,9 @@ Lfinish: MMUADDR(a0) orl #MMU_CEN,a0@(MMUCMD) | turn on external cache Lnocache0: -/* final setup for C code */ - movl #_vectab,d0 | set Vector Base Register - movc d0,vbr - jbsr _isrinit | be ready for stray ints - jbsr _hp300_calibrate_delay | calibrate delay - movw #PSL_LOWIPL,sr | lower SPL - movl d7,_boothowto | save reboot flags - movl d6,_bootdev | and boot device +/* Final setup for call to main(). */ + jbsr _isrinit | initialize interrupt handlers + jbsr _hp300_calibrate_delay | calibrate delay() loop /* * Create a fake exception frame so that cpu_fork() can copy it. @@ -973,6 +1089,13 @@ Lnocache0: jra _main | main() + pea Lmainreturned | Yow! Main returned! + jbsr _panic + /* NOTREACHED */ +Lmainreturned: + .asciz "main() returned" + .even + .globl _proc_trampoline _proc_trampoline: movl a3,sp@- @@ -1070,10 +1193,10 @@ ENTRY(longjmp) /* * The following primitives manipulate the run queues. _whichqs tells which * of the 32 queues _qs have processes in them. Setrunqueue puts processes - * into queues, Remrq removes them from queues. The running process is on - * no queue, other processes are on a queue related to p->p_priority, divided - * by 4 actually to shrink the 0-127 range of priorities into the 32 available - * queues. + * into queues, remrunqueue removes them from queues. The running process is + * on no queue, other processes are on a queue related to p->p_priority, + * divided by 4 actually to shrink the 0-127 range of priorities into the 32 + * available queues. */ .globl _whichqs,_qs,_cnt,_panic @@ -1913,6 +2036,13 @@ LmotommuE: #endif jmp MAXADDR+8 | jump to last page +#define DOREBOOT \ + /* Reset Vector Base Register to what PROM expects. */ \ + movl #0,d0; \ + movc d0,vbr; \ + /* Jump to REQ_REBOOT */ \ + jmp 0x1A4; + Lbootcode: lea MAXADDR+0x800,sp | physical SP in case of NMI #if defined(M68040) @@ -1922,7 +2052,7 @@ Lbootcode: movc d0,cacr | caches off .long 0x4e7b0003 | movc d0,tc movl d2,MAXADDR+NBPG-4 | restore old high page contents - jmp 0x1A4 | goto REQ_REBOOT + DOREBOOT LmotommuF: #endif #if defined(M68K_MMU_MOTOROLA) @@ -1930,29 +2060,33 @@ LmotommuF: jeq LhpmmuB | yes, skip movl #0,a0@ | value for pmove to TC (turn off MMU) pmove a0@,tc | disable MMU - jmp 0x1A4 | goto REQ_REBOOT + DOREBOOT LhpmmuB: #endif #if defined(M68K_MMU_HP) MMUADDR(a0) movl #0xFFFF0000,a0@(MMUCMD) | totally disable MMU movl d2,MAXADDR+NBPG-4 | restore old high page contents - jmp 0x1A4 | goto REQ_REBOOT + DOREBOOT #endif Lebootcode: +#undef DOREBOOT + .data - .globl _machineid + .globl _machineid,_mmutype,_cputype,_ectype,_protorp,_prototc _machineid: - .long 0 | default to 320 - .globl _mmutype,_protorp + .long HP_320 | default to 320 _mmutype: - .long 0 | default to HP MMU + .long MMU_HP | default to HP MMU +_cputype: + .long CPU_68020 | default to 68020 CPU +_ectype: + .long EC_NONE | external cache type, default to none _protorp: .long 0,0 | prototype root pointer - .globl _ectype -_ectype: - .long 0 | external cache type, default to none +_prototc: + .long 0 | prototype translation control .globl _internalhpib _internalhpib: .long 1 | has internal HP-IB, default to yes @@ -1963,7 +2097,7 @@ _cold: _want_resched: .long 0 .globl _intiobase, _intiolimit, _extiobase, _CLKbase, _MMUbase - .globl _proc0paddr + .globl _proc0paddr, _pagezero _proc0paddr: .long 0 | KVA of proc0 u-area _intiobase: @@ -1976,6 +2110,8 @@ _CLKbase: .long 0 | KVA of base of clock registers _MMUbase: .long 0 | KVA of base of HP MMU registers +_pagezero: + .long 0 | PA of first page of kernel text #ifdef USELEDS heartbeat: .long 0 | clock ticks since last pulse of heartbeat diff --git a/sys/arch/hp300/hp300/machdep.c b/sys/arch/hp300/hp300/machdep.c index 01195a65679..0d8bd360f18 100644 --- a/sys/arch/hp300/hp300/machdep.c +++ b/sys/arch/hp300/hp300/machdep.c @@ -1,4 +1,5 @@ -/* $NetBSD: machdep.c,v 1.66 1996/05/18 23:30:09 thorpej Exp $ */ +/* $OpenBSD: machdep.c,v 1.9 1997/01/12 15:13:23 downsj Exp $ */ +/* $NetBSD: machdep.c,v 1.77 1996/12/11 16:49:23 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -123,6 +124,22 @@ extern short exframesize[]; extern struct emul emul_hpux; #endif +/* prototypes for local functions */ +caddr_t allocsys __P((caddr_t)); +void parityenable __P((void)); +int parityerror __P((struct frame *)); +int parityerrorfind __P((void)); +void identifycpu __P((void)); +void initcpu __P((void)); +void ledinit __P((void)); +void dumpmem __P((int *, int, int)); +char *hexstr __P((int, int)); + +/* functions called from locore.s */ +void dumpsys __P((void)); +void straytrap __P((int, u_short)); +void nmihand __P((struct frame)); + /* * Select code of console. Set to -1 if console is on * "internal" framebuffer. @@ -186,16 +203,12 @@ consinit() void cpu_startup() { + extern char *etext; register unsigned i; - register caddr_t v, firstaddr; - int base, residual; + register caddr_t v; + int base, residual, sz; vm_offset_t minaddr, maxaddr; vm_size_t size; -#ifdef BUFFERS_UNMANAGED - vm_offset_t bufmemp; - caddr_t buffermem; - int ix; -#endif #ifdef DEBUG extern int pmapdebug; int opmapdebug = pmapdebug; @@ -217,94 +230,18 @@ cpu_startup() */ printf(version); identifycpu(); - printf("real mem = %d\n", ctob(physmem)); + printf("real mem = %d\n", ctob(physmem)); /* - * Allocate space for system data structures. - * The first available real memory address is in "firstaddr". - * The first available kernel virtual address is in "v". - * As pages of kernel virtual memory are allocated, "v" is incremented. - * As pages of memory are allocated and cleared, - * "firstaddr" is incremented. - * An index into the kernel page table corresponding to the - * virtual memory address maintained in "v" is kept in "mapaddr". + * Find out how much space we need, allocate it, + * and the give everything true virtual addresses. */ - /* - * Make two passes. The first pass calculates how much memory is - * needed and allocates it. The second pass assigns virtual - * addresses to the various data structures. - */ - firstaddr = 0; -again: - v = (caddr_t)firstaddr; + size = (vm_size_t)allocsys((caddr_t)0); + if ((v = (caddr_t)kmem_alloc(kernel_map, round_page(size))) == 0) + panic("startup: no room for tables"); + if ((allocsys(v) - v) != size) + panic("startup: talbe size inconsistency"); -#define valloc(name, type, num) \ - (name) = (type *)v; v = (caddr_t)((name)+(num)) -#define valloclim(name, type, num, lim) \ - (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num))) -#ifdef REAL_CLISTS - valloc(cfree, struct cblock, nclist); -#endif - valloc(callout, struct callout, ncallout); - valloc(swapmap, struct map, nswapmap = maxproc * 2); -#ifdef SYSVSHM - valloc(shmsegs, struct shmid_ds, shminfo.shmmni); -#endif -#ifdef SYSVSEM - valloc(sema, struct semid_ds, seminfo.semmni); - valloc(sem, struct sem, seminfo.semmns); - /* This is pretty disgusting! */ - valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int)); -#endif -#ifdef SYSVMSG - valloc(msgpool, char, msginfo.msgmax); - valloc(msgmaps, struct msgmap, msginfo.msgseg); - valloc(msghdrs, struct msg, msginfo.msgtql); - valloc(msqids, struct msqid_ds, msginfo.msgmni); -#endif - - /* - * Determine how many buffers to allocate. - * Since HPs tend to be long on memory and short on disk speed, - * we allocate more buffer space than the BSD standard of - * use 10% of memory for the first 2 Meg, 5% of remaining. - * We just allocate a flat 10%. Insure a minimum of 16 buffers. - * We allocate 1/2 as many swap buffer headers as file i/o buffers. - */ - if (bufpages == 0) - bufpages = physmem / 10 / CLSIZE; - if (nbuf == 0) { - nbuf = bufpages; - if (nbuf < 16) - nbuf = 16; - } - if (nswbuf == 0) { - nswbuf = (nbuf / 2) &~ 1; /* force even */ - if (nswbuf > 256) - nswbuf = 256; /* sanity */ - } - valloc(swbuf, struct buf, nswbuf); - valloc(buf, struct buf, nbuf); - /* - * End of first pass, size has been calculated so allocate memory - */ - if (firstaddr == 0) { - size = (vm_size_t)(v - firstaddr); - firstaddr = (caddr_t) kmem_alloc(kernel_map, round_page(size)); - if (firstaddr == 0) - panic("startup: no room for tables"); -#ifdef BUFFERS_UNMANAGED - buffermem = (caddr_t) kmem_alloc(kernel_map, bufpages*CLBYTES); - if (buffermem == 0) - panic("startup: no room for buffers"); -#endif - goto again; - } - /* - * End of second pass, addresses have been assigned - */ - if ((vm_size_t)(v - firstaddr) != size) - panic("startup: table size inconsistency"); /* * Now allocate buffers proper. They are different than the above * in that they usually occupy more virtual memory than physical. @@ -318,9 +255,6 @@ again: panic("startup: cannot allocate buffers"); base = bufpages / nbuf; residual = bufpages % nbuf; -#ifdef BUFFERS_UNMANAGED - bufmemp = (vm_offset_t) buffermem; -#endif for (i = 0; i < nbuf; i++) { vm_size_t curbufsize; vm_offset_t curbuf; @@ -334,36 +268,9 @@ again: */ curbuf = (vm_offset_t)buffers + i * MAXBSIZE; curbufsize = CLBYTES * (i < residual ? base+1 : base); -#ifdef BUFFERS_UNMANAGED - /* - * Move the physical pages over from buffermem. - */ - for (ix = 0; ix < curbufsize/CLBYTES; ix++) { - vm_offset_t pa; - - pa = pmap_extract(pmap_kernel(), bufmemp); - if (pa == 0) - panic("startup: unmapped buffer"); - pmap_remove(pmap_kernel(), bufmemp, bufmemp+CLBYTES); - pmap_enter(pmap_kernel(), - (vm_offset_t)(curbuf + ix * CLBYTES), - pa, VM_PROT_READ|VM_PROT_WRITE, TRUE); - bufmemp += CLBYTES; - } -#else vm_map_pageable(buffer_map, curbuf, curbuf+curbufsize, FALSE); vm_map_simplify(buffer_map, curbuf); -#endif } -#ifdef BUFFERS_UNMANAGED -#if 0 - /* - * We would like to free the (now empty) original address range - * but too many bad things will happen if we try. - */ - kmem_free(kernel_map, (vm_offset_t)buffermem, bufpages*CLBYTES); -#endif -#endif /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. @@ -399,6 +306,28 @@ again: printf("avail mem = %d\n", ptoa(cnt.v_free_count)); printf("using %d buffers containing %d bytes of memory\n", nbuf, bufpages * CLBYTES); + + /* + * Tell the VM system that page 0 isn't mapped. + * + * XXX This is bogus; should just fix KERNBASE and + * XXX VM_MIN_KERNEL_ADDRESS, but not right now. + */ + if (vm_map_protect(kernel_map, 0, NBPG, VM_PROT_NONE, TRUE) + != KERN_SUCCESS) + panic("can't mark page 0 off-limits"); + + /* + * Tell the VM system that writing to kernel text isn't allowed. + * If we don't, we might end up COW'ing the text segment! + * + * XXX Should be hp300_trunc_page(&kernel_text) instead + * XXX of NBPG. + */ + if (vm_map_protect(kernel_map, NBPG, hp300_round_page(&etext), + VM_PROT_READ|VM_PROT_EXECUTE, TRUE) != KERN_SUCCESS) + panic("can't protect kernel text"); + /* * Set up CPU-specific registers, cache, etc. */ @@ -415,6 +344,71 @@ again: configure(); } +/* + * Allocate space for system data structures. We are given + * a starting virtual address and we return a final virtual + * address; along the way we set each data structure pointer. + * + * We call allocsys() with 0 to find out how much space we want, + * allocate that much and fill it with zeroes, and the call + * allocsys() again with the correct base virtual address. + */ +caddr_t +allocsys(v) + register caddr_t v; +{ + +#define valloc(name, type, num) \ + (name) = (type *)v; v = (caddr_t)((name)+(num)) +#define valloclim(name, type, num, lim) \ + (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num))) + +#ifdef REAL_CLISTS + valloc(cfree, struct cblock, nclist); +#endif + valloc(callout, struct callout, ncallout); + valloc(swapmap, struct map, nswapmap = maxproc * 2); +#ifdef SYSVSHM + valloc(shmsegs, struct shmid_ds, shminfo.shmmni); +#endif +#ifdef SYSVSEM + valloc(sema, struct semid_ds, seminfo.semmni); + valloc(sem, struct sem, seminfo.semmns); + /* This is pretty disgusting! */ + valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int)); +#endif +#ifdef SYSVMSG + valloc(msgpool, char, msginfo.msgmax); + valloc(msgmaps, struct msgmap, msginfo.msgseg); + valloc(msghdrs, struct msg, msginfo.msgtql); + valloc(msqids, struct msqid_ds, msginfo.msgmni); +#endif + + /* + * Determine how many buffers to allocate. Since HPs tend + * to be long on memory and short on disk speed, we allocate + * more buffer space than the BSD standard of 10% of memory + * for the first 2 Meg, 5% of the remaining. We just allocate + * a flag 10%. Insure a minimum of 16 buffers. We allocate + * 1/2 as many swap buffer headers as file i/o buffers. + */ + if (bufpages == 0) + bufpages = physmem / 10 / CLSIZE; + if (nbuf == 0) { + nbuf = bufpages; + if (nbuf < 16) + nbuf = 16; + } + if (nswbuf == 0) { + nswbuf = (nbuf / 2) &~ 1; /* force even */ + if (nswbuf > 256) + nswbuf = 256; /* sanity */ + } + valloc(swbuf, struct buf, nswbuf); + valloc(buf, struct buf, nbuf); + return (v); +} + /* * Set registers on exec. * XXX Should clear registers except sp, pc, @@ -492,6 +486,7 @@ setregs(p, pack, stack, retval) char cpu_model[120]; extern char version[]; +void identifycpu() { char *t, *mc; @@ -603,6 +598,7 @@ identifycpu() /* * machine dependent system variables. */ +int cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) int *name; u_int namelen; @@ -641,6 +637,7 @@ char *ledaddr; /* * Map the LED page and setup the KVA to access it. */ +void ledinit() { extern caddr_t ledbase; @@ -659,6 +656,7 @@ ledinit() * They are expensive and we really don't need to be that precise. * Besides we would like to be able to profile this routine. */ +void ledcontrol(ons, offs, togs) register int ons, offs, togs; { @@ -1209,14 +1207,23 @@ dumpconf() } /* - * Doadump comes here after turning off memory management and - * getting on the dump stack, either when called above, or by - * the auto-restart code. + * Dump physical memory onto the dump device. Called by doadump() + * in locore.s or by boot() here in machdep.c */ +void dumpsys() { - + daddr_t blkno; /* current block to write */ + /* dump routine */ + int (*dump) __P((dev_t, daddr_t, caddr_t, size_t)); + int pg; /* page being dumped */ + vm_offset_t maddr; /* PA being dumped */ + int error; /* error code from (*dump)() */ + + /* Don't put dump messages in msgbuf. */ msgbufmapped = 0; + + /* Make sure dump device is valid. */ if (dumpdev == NODEV) return; if (dumpsize == 0) { @@ -1224,37 +1231,60 @@ dumpsys() if (dumpsize == 0) return; } - printf("\ndumping to dev %x, offset %d\n", dumpdev, dumplo); + if (dumplo < 0) + return; + dump = bdevsw[major(dumpdev)].d_dump; + blkno = dumplo; + + printf("\ndumping to dev 0x%x, offset %d\n", dumpdev, dumplo); printf("dump "); - switch ((*bdevsw[major(dumpdev)].d_dump)(dumpdev)) { + maddr = lowram; + for (pg = 0; pg < dumpsize; pg++) { +#define NPGMB (1024*1024/NBPG) + /* print out how many MBs we have dumped */ + if (pg && (pg % NPGMB) == 0) + printf("%d ", pg / NPGMB); +#undef NPGMB + pmap_enter(pmap_kernel(), (vm_offset_t)vmmap, maddr, + VM_PROT_READ, TRUE); - case ENXIO: - printf("device bad\n"); - break; + error = (*dump)(dumpdev, blkno, vmmap, NBPG); + switch (error) { + case 0: + maddr += NBPG; + blkno += btodb(NBPG); + break; - case EFAULT: - printf("device not ready\n"); - break; + case ENXIO: + printf("device bad\n"); + return; - case EINVAL: - printf("area improper\n"); - break; + case EFAULT: + printf("device not ready\n"); + return; - case EIO: - printf("i/o error\n"); - break; + case EINVAL: + printf("area improper\n"); + return; - case EINTR: - printf("aborted from console\n"); - break; + case EIO: + printf("i/o error\n"); + return; - default: - printf("succeeded\n"); - break; + case EINTR: + printf("aborted from console\n"); + return; + + default: + printf("error %d\n", error); + return; + } } + printf("succeeded\n"); } +void initcpu() { #ifdef MAPPEDCOPY @@ -1278,6 +1308,7 @@ initcpu() #endif } +void straytrap(pc, evec) int pc; u_short evec; @@ -1286,17 +1317,17 @@ straytrap(pc, evec) evec & 0xFFF, pc); } +/* XXX should change the interface, and make one badaddr() function */ + int *nofault; +int badaddr(addr) register caddr_t addr; { register int i; label_t faultbuf; -#ifdef lint - i = *addr; if (i) return(0); -#endif nofault = (int *) &faultbuf; if (setjmp((label_t *)nofault)) { nofault = (int *) 0; @@ -1307,15 +1338,13 @@ badaddr(addr) return(0); } +int badbaddr(addr) register caddr_t addr; { register int i; label_t faultbuf; -#ifdef lint - i = *addr; if (i) return(0); -#endif nofault = (int *) &faultbuf; if (setjmp((label_t *)nofault)) { nofault = (int *) 0; @@ -1326,14 +1355,16 @@ badbaddr(addr) return(0); } -#if (defined(DDB) || defined(DEBUG)) && !defined(PANICBUTTON) -#define PANICBUTTON -#endif - #ifdef PANICBUTTON +/* + * Declare these so they can be patched. + */ int panicbutton = 1; /* non-zero if panic buttons are enabled */ -int crashandburn = 0; -int candbdelay = 50; /* give em half a second */ +int candbdiv = 2; /* give em half a second (hz / candbdiv) */ + +void candbtimer __P((void *)); + +int crashandburn; void candbtimer(arg) @@ -1342,47 +1373,67 @@ candbtimer(arg) crashandburn = 0; } -#endif +#endif /* PANICBUTTON */ + +static int innmihand; /* simple mutex */ /* * Level 7 interrupts can be caused by the keyboard or parity errors. */ +void nmihand(frame) struct frame frame; { + + /* Prevent unwanted recursion. */ + if (innmihand) + return; + innmihand = 1; + + /* Check for keyboard ++. */ if (kbdnmi()) { -#ifdef PANICBUTTON - static int innmihand = 0; + printf("Got a keyboard NMI"); /* - * Attempt to reduce the window of vulnerability for recursive - * NMIs (e.g. someone holding down the keyboard reset button). + * We can: + * + * - enter DDB + * + * - Start the crashandburn sequence + * + * - Ignore it. */ - if (innmihand == 0) { - innmihand = 1; - printf("Got a keyboard NMI\n"); - innmihand = 0; - } #ifdef DDB + printf(": entering debugger\n"); Debugger(); #else +#ifdef PANICBUTTON if (panicbutton) { if (crashandburn) { crashandburn = 0; - panic(panicstr ? - "forced crash, nosync" : "forced crash"); + printf(": CRASH AND BURN!\n"); + panic("forced crash"); + } else { + /* Start the crashandburn sequence */ + printf("\n"); + crashandburn = 1; + timeout(candbtimer, NULL, hz / candbdiv); } - crashandburn++; - timeout(candbtimer, (void *)0, candbdelay); - } -#endif /* DDB */ + } else #endif /* PANICBUTTON */ - return; + printf(": ignoring\n"); +#endif /* DDB */ + + goto nmihand_out; /* no more work to do */ } + if (parityerror(&frame)) return; /* panic?? */ printf("unexpected level 7 interrupt ignored\n"); + + nmihand_out: + innmihand = 0; } /* @@ -1397,6 +1448,7 @@ int ignorekperr = 0; /* ignore kernel parity errors */ /* * Enable parity detection */ +void parityenable() { label_t faultbuf; @@ -1404,23 +1456,20 @@ parityenable() nofault = (int *) &faultbuf; if (setjmp((label_t *)nofault)) { nofault = (int *) 0; -#ifdef DEBUG printf("No parity memory\n"); -#endif return; } *PARREG = 1; nofault = (int *) 0; gotparmem = 1; -#ifdef DEBUG printf("Parity detection enabled\n"); -#endif } /* * Determine if level 7 interrupt was caused by a parity error * and deal with it if it was. Returns 1 if it was a parity error. */ +int parityerror(fp) struct frame *fp; { @@ -1433,7 +1482,7 @@ parityerror(fp) printf("parity error after panic ignored\n"); return(1); } - if (!findparerror()) + if (!parityerrorfind()) printf("WARNING: transient parity error ignored\n"); else if (USERMODE(fp->f_sr)) { printf("pid %d: parity error\n", curproc->p_pid); @@ -1455,7 +1504,8 @@ parityerror(fp) * Yuk! There has got to be a better way to do this! * Searching all of memory with interrupts blocked can lead to disaster. */ -findparerror() +int +parityerrorfind() { static label_t parcatch; static int looking = 0; @@ -1513,6 +1563,7 @@ done: return(found); } +void regdump(fp, sbytes) struct frame *fp; /* must not be register */ int sbytes; @@ -1520,7 +1571,6 @@ regdump(fp, sbytes) static int doingdump = 0; register int i; int s; - extern char *hexstr(); if (doingdump) return; @@ -1556,12 +1606,12 @@ regdump(fp, sbytes) #define KSADDR ((int *)((u_int)curproc->p_addr + USPACE - NBPG)) +void dumpmem(ptr, sz, ustack) register int *ptr; int sz, ustack; { register int i, val; - extern char *hexstr(); for (i = 0; i < sz; i++) { if ((i & 7) == 0) @@ -1702,6 +1752,6 @@ cpu_exec_aout_prep_m68k4k(p, epp) epp->ep_daddr + execp->a_data, NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); - return exec_aout_setup_stack(p, epp); + return exec_setup_stack(p, epp); } #endif /* COMPAT_M68K4K */ diff --git a/sys/arch/hp300/hp300/mem.c b/sys/arch/hp300/hp300/mem.c index 5d0d20f3494..9c976a692ab 100644 --- a/sys/arch/hp300/hp300/mem.c +++ b/sys/arch/hp300/hp300/mem.c @@ -1,3 +1,4 @@ +/* $OpenBSD: mem.c,v 1.2 1997/01/12 15:13:24 downsj Exp $ */ /* $NetBSD: mem.c,v 1.13 1995/04/10 13:10:51 mycroft Exp $ */ /* diff --git a/sys/arch/hp300/hp300/pmap.c b/sys/arch/hp300/hp300/pmap.c index 8bef13a6290..2c30c432451 100644 --- a/sys/arch/hp300/hp300/pmap.c +++ b/sys/arch/hp300/hp300/pmap.c @@ -1,4 +1,5 @@ -/* $NetBSD: pmap.c,v 1.24 1995/12/11 17:09:14 thorpej Exp $ */ +/* $OpenBSD: pmap.c,v 1.3 1997/01/12 15:13:25 downsj Exp $ */ +/* $NetBSD: pmap.c,v 1.27 1996/10/13 03:14:32 christos Exp $ */ /* * Copyright (c) 1991, 1993 @@ -44,7 +45,7 @@ * * Supports: * 68020 with HP MMU models 320, 350 - * 68020 with 68551 MMU models 318, 319, 330 (all untested) + * 68020 with 68551 MMU models 318, 319, 330 * 68030 with on-chip MMU models 340, 360, 370, 345, 375, 400 * 68040 with on-chip MMU models 380, 425, 433 * diff --git a/sys/arch/hp300/hp300/pmap_bootstrap.c b/sys/arch/hp300/hp300/pmap_bootstrap.c index c7d8b3fa2c2..09239664880 100644 --- a/sys/arch/hp300/hp300/pmap_bootstrap.c +++ b/sys/arch/hp300/hp300/pmap_bootstrap.c @@ -1,4 +1,5 @@ -/* $NetBSD: pmap_bootstrap.c,v 1.9 1995/12/11 17:09:16 thorpej Exp $ */ +/* $OpenBSD: pmap_bootstrap.c,v 1.3 1997/01/12 15:13:26 downsj Exp $ */ +/* $NetBSD: pmap_bootstrap.c,v 1.10 1996/10/14 08:05:37 thorpej Exp $ */ /* * Copyright (c) 1991, 1993 @@ -56,6 +57,7 @@ extern char *extiobase, *proc0paddr; extern st_entry_t *Sysseg; extern pt_entry_t *Sysptmap, *Sysmap; extern vm_offset_t CLKbase, MMUbase; +extern vm_offset_t pagezero; extern int maxmem, physmem; extern vm_offset_t avail_start, avail_end, virtual_avail, virtual_end; @@ -247,8 +249,8 @@ pmap_bootstrap(nextpa, firstpa) while (pte < epte) { *pte++ = PG_NV; } - /* - * Initialize the last to point to point to the page + /* + * Initialize the last to point to the page * table page allocated earlier. */ *pte = lkptpa | PG_RW | PG_CI | PG_V; @@ -302,16 +304,22 @@ pmap_bootstrap(nextpa, firstpa) epte = &pte[nptpages * NPTEPG]; while (pte < epte) *pte++ = PG_NV; + /* - * Validate PTEs for kernel text (RO) + * Save the physical address of `page zero'. This is + * a page of memory at the beginning of kernel text + * not mapped at VA 0. But, we might want to use it + * for something later. */ - pte = &((u_int *)kptpa)[hp300_btop(KERNBASE)]; + RELOC(pagezero, vm_offset_t) = firstpa; + + /* + * Validate PTEs for kernel text (RO). The first page + * of kernel text remains invalid; see locore.s + */ + pte = &((u_int *)kptpa)[hp300_btop(KERNBASE + NBPG)]; epte = &pte[hp300_btop(hp300_trunc_page(&etext))]; -#if defined(KGDB) || defined(DDB) - protopte = firstpa | PG_RW | PG_V; /* XXX RW for now */ -#else - protopte = firstpa | PG_RO | PG_V; -#endif + protopte = (firstpa + NBPG) | PG_RO | PG_V; while (pte < epte) { *pte++ = protopte; protopte += NBPG; diff --git a/sys/arch/hp300/hp300/swapgeneric.c b/sys/arch/hp300/hp300/swapgeneric.c index 59bc7698e88..fa9f1e0e8a9 100644 --- a/sys/arch/hp300/hp300/swapgeneric.c +++ b/sys/arch/hp300/hp300/swapgeneric.c @@ -1,8 +1,9 @@ -/* $NetBSD: swapgeneric.c,v 1.12 1995/09/24 02:18:11 thorpej Exp $ */ +/* $OpenBSD: swapgeneric.c,v 1.2 1997/01/12 15:13:27 downsj Exp $ */ +/* $NetBSD: swapgeneric.c,v 1.15 1996/10/14 07:20:27 thorpej Exp $ */ -/* - * Copyright (c) 1982, 1986 Regents of the University of California. - * All rights reserved. +/*- + * Copyright (c) 1994 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -14,8 +15,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -32,216 +33,22 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)swapgeneric.c 7.5 (Berkeley) 5/7/91 + * @(#)swapgeneric.c 8.2 (Berkeley) 3/21/94 + */ + +/* + * fake swapgeneric.c -- should do this differently. */ #include #include -#include -#include -#include -#include -#include - -#include "sd.h" -#include "rd.h" -#include "le.h" - -/* - * Generic configuration; all in one - */ +int (*mountroot) __P((void *)) = NULL; /* tells autoconf.c that we are "generic" */ dev_t rootdev = NODEV; -dev_t argdev = NODEV; dev_t dumpdev = NODEV; -int nswap; -struct swdevt swdevt[] = { - { -1, 1, 0 }, - { NODEV, 0, 0 }, -}; -int dmmin, dmmax, dmtext; - -#if NRD > 0 -extern struct driver rddriver; -#endif -#if NSD > 0 -extern struct driver sddriver; -#endif -#if NLE > 0 -extern struct driver ledriver; -#endif - -extern struct hp_ctlr hp_cinit[]; -extern struct hp_device hp_dinit[]; - -extern u_long bootdev; -static int no_mountroot __P((void)); - -#ifdef FFS -extern int ffs_mountroot(); -#else -#define ffs_mountroot no_mountroot -#endif /* FFS */ - -#ifdef NFSCLIENT -extern char *nfsbootdevname; /* from nfs_boot.c */ -extern int nfs_mountroot(); /* nfs_vfsops.c */ -static char nfsbootdevname_buf[128]; -#else -static char *nfsbootdevname; -#define nfs_mountroot no_mountroot -#endif /* NFSCLIENT */ - -/* XXX: should eventually ask for root fs type. */ - -struct genericconf { - caddr_t gc_driver; - char *gc_name; - dev_t gc_root; - int (*gc_mountroot)(); -} genericconf[] = { -#if NRD > 0 - { (caddr_t)&rddriver, "rd", makedev(2, 0), ffs_mountroot }, -#endif -#if NSD > 0 - { (caddr_t)&sddriver, "sd", makedev(4, 0), ffs_mountroot }, -#endif -#if NLE > 0 - { (caddr_t)&ledriver, "le", NODEV, nfs_mountroot }, -#endif - { 0 }, +struct swdevt swdevt[] = { + { NODEV, 0, 0 }, /* to be filled in */ + { NODEV, 0, 0 } }; - -int (*mountroot)() = ffs_mountroot; - -setconf() -{ - register struct hp_ctlr *hc; - register struct hp_device *hd; - register struct genericconf *gc; - register char *cp; - int unit, swaponroot = 0; - - if (rootdev != NODEV) - goto doswap; - unit = 0; - if (boothowto & RB_ASKNAME) { - char name[128]; -retry: - printf("root device? "); - gets(name); - for (gc = genericconf; gc->gc_driver; gc++) - if (gc->gc_name[0] == name[0] && - gc->gc_name[1] == name[1]) - goto gotit; - printf("use one of:"); - for (gc = genericconf; gc->gc_driver; gc++) - printf(" %s?", gc->gc_name); - printf("\n"); - goto retry; -gotit: - cp = &name[1]; - if (*++cp < '0' || *cp > '9') { - printf("bad/missing unit number\n"); - goto retry; - } - while (*cp >= '0' && *cp <= '9') - unit = 10 * unit + *cp++ - '0'; - if (*cp == '*') - swaponroot++; - -#ifdef NFSCLIENT - if (gc->gc_root == NODEV) { - /* - * Tell nfs_mountroot if it's a network interface. - */ - bzero(nfsbootdevname_buf, sizeof(nfsbootdevname_buf)); - sprintf(nfsbootdevname_buf, "%s%d", gc->gc_name, unit); - nfsbootdevname = nfsbootdevname_buf; - } -#endif /* NFSCLIENT */ - goto found; - } - for (gc = genericconf; gc->gc_driver; gc++) { - if (bootdev == 0 && gc->gc_root != NODEV) - continue; - for (hd = hp_dinit; hd->hp_driver; hd++) { - if (hd->hp_alive == 0) - continue; - if (hd->hp_unit == 0 && hd->hp_driver == - (struct driver *)gc->gc_driver) { - printf("root on %s0\n", hd->hp_driver->d_name); - goto found; - } - } - } - printf("No suitable root, halting.\n"); - asm("stop #0x2700"); -found: - if (gc->gc_root != NODEV) - gc->gc_root = makedev(major(gc->gc_root), unit*8); - mountroot = gc->gc_mountroot; /* XXX: should ask for fs type. */ - rootdev = gc->gc_root; -doswap: - if (rootdev == NODEV) - swdevt[0].sw_dev = argdev = dumpdev = NODEV; - else { - /* - * Primary swap is always in the `b' partition. - */ - swdevt[0].sw_dev = argdev = dumpdev = - MAKEDISKDEV(major(rootdev), DISKUNIT(rootdev), 1); - /* swap size and dumplo set during autoconfigure */ - if (swaponroot) - rootdev = dumpdev; - } -} - -gets(cp) - char *cp; -{ - register char *lp; - register c; - - lp = cp; - for (;;) { - cnputc(c = cngetc()); - switch (c) { - case '\n': - case '\r': - *lp++ = '\0'; - return; - case '\b': - case '\177': - if (lp > cp) { - lp--; - cnputc(' '); - cnputc('\b'); - } - continue; - case '#': - lp--; - if (lp < cp) - lp = cp; - continue; - case '@': - case 'u'&037: - lp = cp; - cnputc('\n'); - continue; - default: - *lp++ = c; - } - } -} - -static int -no_mountroot() -{ - - printf("root/swap configuration error, halting.\n"); - asm("stop #0x2700"); - /* NOTREACHED */ -} diff --git a/sys/arch/hp300/hp300/sys_machdep.c b/sys/arch/hp300/hp300/sys_machdep.c index 9f1823e1401..89852d1ed5c 100644 --- a/sys/arch/hp300/hp300/sys_machdep.c +++ b/sys/arch/hp300/hp300/sys_machdep.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sys_machdep.c,v 1.3 1997/01/12 15:13:27 downsj Exp $ */ /* $NetBSD: sys_machdep.c,v 1.13 1995/12/11 17:09:17 thorpej Exp $ */ /* diff --git a/sys/arch/hp300/hp300/trap.c b/sys/arch/hp300/hp300/trap.c index ebc9a5dac3b..b4909292aaa 100644 --- a/sys/arch/hp300/hp300/trap.c +++ b/sys/arch/hp300/hp300/trap.c @@ -1,4 +1,5 @@ -/* $NetBSD: trap.c,v 1.40 1995/12/11 17:09:18 thorpej Exp $ */ +/* $OpenBSD: trap.c,v 1.4 1997/01/12 15:13:28 downsj Exp $ */ +/* $NetBSD: trap.c,v 1.47 1996/10/14 20:06:31 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -67,8 +68,26 @@ #ifdef COMPAT_HPUX #include +extern struct emul emul_hpux; #endif +#ifdef COMPAT_SUNOS +#include +extern struct emul emul_sunos; +#endif + +int writeback __P((struct frame *fp, int docachepush)); +void trap __P((int type, u_int code, u_int v, struct frame frame)); +void syscall __P((register_t code, struct frame frame)); + +#ifdef DEBUG +void dumpssw __P((u_short)); +void dumpwb __P((int, u_short, u_int, u_int)); +#endif + +static inline void userret __P((struct proc *p, struct frame *fp, + u_quad_t oticks, u_int faultaddr, int fromtrap)); + char *trap_type[] = { "Bus error", "Address error", @@ -91,11 +110,12 @@ int trap_types = sizeof trap_type / sizeof trap_type[0]; * Size of various exception stack frames (minus the standard 8 bytes) */ short exframesize[] = { - FMT0SIZE, /* type 0 - normal (68020/030/040) */ + FMT0SIZE, /* type 0 - normal (68020/030/040/060) */ FMT1SIZE, /* type 1 - throwaway (68020/030/040) */ - FMT2SIZE, /* type 2 - normal 6-word (68020/030/040) */ - FMT3SIZE, /* type 3 - FP post-instruction (68040) */ - -1, -1, -1, /* type 4-6 - undefined */ + FMT2SIZE, /* type 2 - normal 6-word (68020/030/040/060) */ + FMT3SIZE, /* type 3 - FP post-instruction (68040/060) */ + FMT4SIZE, /* type 4 - access error/fp disabled (68060) */ + -1, -1, /* type 5-6 - undefined */ FMT7SIZE, /* type 7 - access error (68040) */ 58, /* type 8 - bus fault (68010) */ FMT9SIZE, /* type 9 - coprocessor mid-instruction (68020/030) */ @@ -104,25 +124,44 @@ short exframesize[] = { -1, -1, -1, -1 /* type C-F - undefined */ }; +#ifdef M68060 +#define KDFAULT_060(c) (cputype == CPU_68060 && ((c) & FSLW_TM_SV)) +#define WRFAULT_060(c) (cputype == CPU_68060 && ((c) & FSLW_RW_W)) +#else +#define KDFAULT_060(c) 0 +#define WRFAULT_060(c) 0 +#endif + #ifdef M68040 -#define KDFAULT(c) (mmutype == MMU_68040 ? \ - ((c) & SSW4_TMMASK) == SSW4_TMKD : \ - ((c) & (SSW_DF|FC_SUPERD)) == (SSW_DF|FC_SUPERD)) -#define WRFAULT(c) (mmutype == MMU_68040 ? \ - ((c) & SSW4_RW) == 0 : \ - ((c) & (SSW_DF|SSW_RW)) == SSW_DF) +#define KDFAULT_040(c) (cputype == CPU_68040 && \ + ((c) & SSW4_TMMASK) == SSW4_TMKD) +#define WRFAULT_040(c) (cputype == CPU_68040 && \ + ((c) & SSW4_RW) == 0) +#else +#define KDFAULT_040(c) 0 +#define WRFAULT_040(c) 0 +#endif + +#if defined(M68030) || defined(M68020) +#define KDFAULT_OTH(c) (cputype <= CPU_68030 && \ + ((c) & (SSW_DF|SSW_FCMASK)) == (SSW_DF|FC_SUPERD)) +#define WRFAULT_OTH(c) (cputype <= CPU_68030 && \ + ((c) & (SSW_DF|SSW_RW)) == SSW_DF) #else -#define KDFAULT(c) (((c) & (SSW_DF|SSW_FCMASK)) == (SSW_DF|FC_SUPERD)) -#define WRFAULT(c) (((c) & (SSW_DF|SSW_RW)) == SSW_DF) +#define KDFAULT_OTH(c) 0 +#define WRFAULT_OTH(c) 0 #endif +#define KDFAULT(c) (KDFAULT_060(c) || KDFAULT_040(c) || KDFAULT_OTH(c)) +#define WRFAULT(c) (WRFAULT_060(c) || WRFAULT_040(c) || WRFAULT_OTH(c)) + #ifdef DEBUG int mmudebug = 0; int mmupid = -1; #define MDB_FOLLOW 1 #define MDB_WBFOLLOW 2 #define MDB_WBFAILED 4 -#define MDB_ISPID(p) (p) == mmupid +#define MDB_ISPID(p) ((p) == mmupid) #endif /* @@ -183,7 +222,7 @@ again: * we just return to the user without sucessfully completing * the writebacks. Maybe we should just drop the sucker? */ - if (mmutype == MMU_68040 && fp->f_format == FMT7) { + if (cputype == CPU_68040 && fp->f_format == FMT7) { if (beenhere) { #ifdef DEBUG if (mmudebug & MDB_WBFAILED) @@ -209,6 +248,7 @@ again: * System calls are broken out for efficiency. */ /*ARGSUSED*/ +void trap(type, code, v, frame) int type; unsigned code; @@ -216,20 +256,23 @@ trap(type, code, v, frame) struct frame frame; { extern char fubail[], subail[]; -#ifdef DDB - extern char trap0[], trap1[], trap2[], trap12[], trap15[], illinst[]; -#endif register struct proc *p; - register int i; + register int i, s; u_int ucode; u_quad_t sticks; -#ifdef COMPAT_HPUX - extern struct emul emul_hpux; -#endif cnt.v_trap++; p = curproc; ucode = 0; + + /* I have verified that this DOES happen! -gwr */ + if (p == NULL) + p = &proc0; +#ifdef DIAGNOSTIC + if (p->p_addr == NULL) + panic("trap: no pcb"); +#endif + if (USERMODE(frame.f_sr)) { type |= T_USER; sticks = p->p_sticks; @@ -238,28 +281,51 @@ trap(type, code, v, frame) switch (type) { default: -dopanic: - printf("trap type %d, code = %x, v = %x\n", type, code, v); + dopanic: + printf("trap type %d, code = 0x%x, v = 0x%x\n", type, code, v); + printf("%s program counter = 0x%x\n", + (type & T_USER) ? "user" : "kernel", frame.f_pc); + /* + * Let the kernel debugger see the trap frame that + * caused us to panic. This is a convenience so + * one can see registers at the point of failure. + */ + s = splhigh(); +#ifdef KGDB + /* If connected, step or cont returns 1 */ + if (kgdb_trap(type, &frame)) + goto kgdb_cont; +#endif #ifdef DDB - if (kdb_trap(type, &frame)) - return; + (void) kdb_trap(type, &frame); +#endif + kgdb_cont: + splx(s); + if (panicstr) { + printf("trap during panic!\n"); +#ifdef DEBUG + /* XXX should be a machine-dependent hook */ + printf("(press a key)\n"); (void)cngetc(); #endif + } regdump(&frame, 128); type &= ~T_USER; - if ((unsigned)type < trap_types) + if ((u_int)type < trap_types) panic(trap_type[type]); panic("trap"); case T_BUSERR: /* kernel bus error */ - if (!p->p_addr->u_pcb.pcb_onfault) + if (p->p_addr->u_pcb.pcb_onfault == 0) goto dopanic; + /* FALLTHROUGH */ + + copyfault: /* * If we have arranged to catch this fault in any of the * copy to/from user space routines, set PC to return to * indicated location and set flag informing buserror code * that it may need to clean up stack frame. */ -copyfault: frame.f_stackadj = exframesize[frame.f_format]; frame.f_format = frame.f_vector = 0; frame.f_pc = (int) p->p_addr->u_pcb.pcb_onfault; @@ -386,34 +452,39 @@ copyfault: * XXX: Trace traps are a nightmare. * * HP-UX uses trap #1 for breakpoints, - * HPBSD uses trap #2, + * NetBSD/m68k uses trap #2, * SUN 3.x uses trap #15, - * KGDB uses trap #15 (for kernel breakpoints; handled elsewhere). + * DDB and KGDB uses trap #15 (for kernel breakpoints; + * handled elsewhere). * - * HPBSD and HP-UX traps both get mapped by locore.s into T_TRACE. + * NetBSD and HP-UX traps both get mapped by locore.s into T_TRACE. * SUN 3.x traps get passed through as T_TRAP15 and are not really * supported yet. + * + * XXX: We should never get kernel-mode T_TRACE or T_TRAP15 + * XXX: because locore.s now gives them special treatment. */ case T_TRACE: /* kernel trace trap */ - case T_TRAP15: /* SUN trace trap */ -#ifdef DDB - if (type == T_TRAP15 || - ((caddr_t)frame.f_pc != trap0 && - (caddr_t)frame.f_pc != trap1 && - (caddr_t)frame.f_pc != trap2 && - (caddr_t)frame.f_pc != trap12 && - (caddr_t)frame.f_pc != trap15 && - (caddr_t)frame.f_pc != illinst)) { - if (kdb_trap(type, &frame)) - return; - } + case T_TRAP15: /* kernel breakpoint */ +#ifdef DEBUG + printf("unexpected kernel trace trap, type = %d\n", type); + printf("program counter = 0x%x\n", frame.f_pc); #endif frame.f_sr &= ~PSL_T; - i = SIGTRAP; - break; + return; case T_TRACE|T_USER: /* user trace trap */ case T_TRAP15|T_USER: /* SUN user trace trap */ +#ifdef COMPAT_SUNOS + /* + * XXX This comment/code is not consistent XXX + * SunOS seems to use Trap #2 for some obscure + * fpu operations. So far, just ignore it, but + * DONT trap on it.. + */ + if (p->p_emul == &emul_sunos) + goto out; +#endif frame.f_sr &= ~PSL_T; i = SIGTRAP; break; @@ -492,22 +563,26 @@ copyfault: * The last can occur during an exec() copyin where the * argument space is lazy-allocated. */ - if (type == T_MMUFLT && - (!p->p_addr->u_pcb.pcb_onfault || KDFAULT(code))) + if ((type & T_USER) == 0 && + ((p->p_addr->u_pcb.pcb_onfault == 0) || KDFAULT(code))) map = kernel_map; else - map = &vm->vm_map; + map = vm ? &vm->vm_map : kernel_map; + if (WRFAULT(code)) ftype = VM_PROT_READ | VM_PROT_WRITE; else ftype = VM_PROT_READ; + va = trunc_page((vm_offset_t)v); -#ifdef DEBUG + if (map == kernel_map && va == 0) { - printf("trap: bad kernel access at %x\n", v); + printf("trap: bad kernel %s access at 0x%x\n", + (ftype & VM_PROT_WRITE) ? "read/write" : + "read", v); goto dopanic; } -#endif + #ifdef COMPAT_HPUX if (ISHPMMADDR(va)) { vm_offset_t bva; @@ -534,7 +609,8 @@ copyfault: * the current limit and we need to reflect that as an access * error. */ - if ((caddr_t)va >= vm->vm_maxsaddr && map != kernel_map) { + if ((vm != NULL && (caddr_t)va >= vm->vm_maxsaddr) + && map != kernel_map) { if (rv == KERN_SUCCESS) { unsigned nss; @@ -547,7 +623,7 @@ copyfault: if (rv == KERN_SUCCESS) { if (type == T_MMUFLT) { #ifdef M68040 - if (mmutype == MMU_68040) + if (cputype == CPU_68040) (void) writeback(&frame, 1); #endif return; @@ -593,6 +669,7 @@ char wberrstr[] = "WARNING: pid %d(%s) writeback [%s] failed, pc=%x fa=%x wba=%x wbd=%x\n"; #endif +int writeback(fp, docachepush) struct frame *fp; int docachepush; @@ -827,6 +904,7 @@ writeback(fp, docachepush) } #ifdef DEBUG +void dumpssw(ssw) register u_short ssw; { @@ -853,6 +931,7 @@ dumpssw(ssw) f7tm[ssw & SSW4_TMMASK]); } +void dumpwb(num, s, a, d) int num; u_short s; @@ -878,6 +957,7 @@ dumpwb(num, s, a, d) /* * Process a system call. */ +void syscall(code, frame) register_t code; struct frame frame; @@ -889,9 +969,6 @@ syscall(code, frame) size_t argsize; register_t args[8], rval[2]; u_quad_t sticks; -#ifdef COMPAT_SUNOS - extern struct emul emul_sunos; -#endif cnt.v_syscall++; if (!USERMODE(frame.f_sr)) diff --git a/sys/arch/hp300/hp300/vectors.s b/sys/arch/hp300/hp300/vectors.s index d3fb0afed70..15e47cf82a7 100644 --- a/sys/arch/hp300/hp300/vectors.s +++ b/sys/arch/hp300/hp300/vectors.s @@ -1,4 +1,5 @@ -| $NetBSD: vectors.s,v 1.9 1996/05/18 00:52:53 thorpej Exp $ +| $OpenBSD: vectors.s,v 1.4 1997/01/12 15:13:29 downsj Exp $ +| $NetBSD: vectors.s,v 1.10 1996/10/14 22:11:18 thorpej Exp $ | Copyright (c) 1988 University of Utah | Copyright (c) 1990, 1993 @@ -47,7 +48,7 @@ .globl _vectab _vectab: - .long 0x4ef80400 /* 0: jmp 0x400:w (unused reset SSP) */ + .long 0 /* 0: NOT USED (reset SSP) */ .long 0 /* 1: NOT USED (reset PC) */ .long _buserr /* 2: bus error */ .long _addrerr /* 3: address error */ diff --git a/sys/arch/hp300/hp300/vm_machdep.c b/sys/arch/hp300/hp300/vm_machdep.c index 38efee9b6bf..b0a6ad9e39f 100644 --- a/sys/arch/hp300/hp300/vm_machdep.c +++ b/sys/arch/hp300/hp300/vm_machdep.c @@ -1,3 +1,4 @@ +/* $OpenBSD: vm_machdep.c,v 1.6 1997/01/12 15:13:29 downsj Exp $ */ /* $NetBSD: vm_machdep.c,v 1.30 1996/05/09 21:26:08 scottr Exp $ */ /* diff --git a/sys/arch/hp300/include/ansi.h b/sys/arch/hp300/include/ansi.h index 7a35c82f58e..a17e8bfcaf6 100644 --- a/sys/arch/hp300/include/ansi.h +++ b/sys/arch/hp300/include/ansi.h @@ -1,3 +1,4 @@ +/* $OpenBSD: ansi.h,v 1.2 1997/01/12 15:13:30 downsj Exp $ */ /* $NetBSD: ansi.h,v 1.4 1994/10/26 07:26:16 cgd Exp $ */ /* Just use the common m68k definition */ diff --git a/sys/arch/hp300/include/asm.h b/sys/arch/hp300/include/asm.h index a933e25f844..cf9ef23de52 100644 --- a/sys/arch/hp300/include/asm.h +++ b/sys/arch/hp300/include/asm.h @@ -1,3 +1,4 @@ +/* $OpenBSD: asm.h,v 1.2 1997/01/12 15:13:31 downsj Exp $ */ /* $NetBSD: asm.h,v 1.2 1994/10/26 07:26:18 cgd Exp $ */ #include diff --git a/sys/arch/hp300/include/autoconf.h b/sys/arch/hp300/include/autoconf.h index 01f3daf9125..2267128ad1e 100644 --- a/sys/arch/hp300/include/autoconf.h +++ b/sys/arch/hp300/include/autoconf.h @@ -1,3 +1,4 @@ +/* $OpenBSD: autoconf.h,v 1.2 1997/01/12 15:13:31 downsj Exp $ */ /* $NetBSD: autoconf.h,v 1.3 1996/03/03 16:49:17 thorpej Exp $ */ /*- diff --git a/sys/arch/hp300/include/cdefs.h b/sys/arch/hp300/include/cdefs.h index 3b2ffb44b55..ae4d3bb01f5 100644 --- a/sys/arch/hp300/include/cdefs.h +++ b/sys/arch/hp300/include/cdefs.h @@ -1,3 +1,4 @@ +/* $OpenBSD: cdefs.h,v 1.2 1997/01/12 15:13:32 downsj Exp $ */ /* $NetBSD: cdefs.h,v 1.1 1995/01/19 01:41:56 jtc Exp $ */ #ifndef _MACHINE_CDEFS_H_ diff --git a/sys/arch/hp300/include/cpu.h b/sys/arch/hp300/include/cpu.h index 0fa81ad6fdd..495520dbc2d 100644 --- a/sys/arch/hp300/include/cpu.h +++ b/sys/arch/hp300/include/cpu.h @@ -1,4 +1,5 @@ -/* $NetBSD: cpu.h,v 1.19 1996/05/17 15:37:07 thorpej Exp $ */ +/* $OpenBSD: cpu.h,v 1.5 1997/01/12 15:13:33 downsj Exp $ */ +/* $NetBSD: cpu.h,v 1.21 1996/10/07 06:29:30 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -49,6 +50,11 @@ * Exported definitions unique to hp300/68k cpu support. */ +/* + * Get common m68k CPU definitions. + */ +#include + /* * definitions of cpu-dependent requirements * referenced in generic code @@ -196,28 +202,25 @@ extern unsigned char ssir; #define HP_380 7 /* 25Mhz 68040 */ #define HP_433 8 /* 33Mhz 68040 */ -/* values for mmutype (assigned for quick testing) */ -#define MMU_68040 -2 /* 68040 on-chip MMU */ -#define MMU_68030 -1 /* 68030 on-chip subset of 68851 */ -#define MMU_HP 0 /* HP proprietary */ -#define MMU_68851 1 /* Motorola 68851 */ - -/* values for ectype */ -#define EC_PHYS -1 /* external physical address cache */ -#define EC_NONE 0 /* no external cache */ -#define EC_VIRT 1 /* external virtual address cache */ - #ifdef _KERNEL extern int machineid; /* CPU model */ -extern int mmutype; /* MMU on this host */ -extern int ectype; /* External cache type */ extern int cpuspeed; /* CPU speed, in MHz */ extern char *intiobase, *intiolimit; extern void (*vectab[]) __P((void)); +struct frame; + +/* locore.s functions */ void doboot __P((void)) __attribute__((__noreturn__)); +void ecacheon __P((void)); +void ecacheoff __P((void)); + +/* machdep.c functions */ +int badaddr __P((caddr_t)); +int badbaddr __P((caddr_t)); +void regdump __P((struct frame *, int)); /* what is this supposed to do? i.e. how is it different than startrtclock? */ #define enablertclock() @@ -296,66 +299,4 @@ void doboot __P((void)) #define MMU_FAULT (MMU_PTF|MMU_PF|MMU_WPF|MMU_BERR) #define MMU_ENAB (MMU_UMEN|MMU_SMEN|MMU_IEN|MMU_FPE) -/* - * 68851 and 68030 MMU - */ -#define PMMU_LVLMASK 0x0007 -#define PMMU_INV 0x0400 -#define PMMU_WP 0x0800 -#define PMMU_ALV 0x1000 -#define PMMU_SO 0x2000 -#define PMMU_LV 0x4000 -#define PMMU_BE 0x8000 -#define PMMU_FAULT (PMMU_WP|PMMU_INV) - -/* - * 68040 MMU - */ -#define MMU4_RES 0x001 -#define MMU4_TTR 0x002 -#define MMU4_WP 0x004 -#define MMU4_MOD 0x010 -#define MMU4_CMMASK 0x060 -#define MMU4_SUP 0x080 -#define MMU4_U0 0x100 -#define MMU4_U1 0x200 -#define MMU4_GLB 0x400 -#define MMU4_BE 0x800 - -/* 680X0 function codes */ -#define FC_USERD 1 /* user data space */ -#define FC_USERP 2 /* user program space */ -#define FC_PURGE 3 /* HPMMU: clear TLB entries */ -#define FC_SUPERD 5 /* supervisor data space */ -#define FC_SUPERP 6 /* supervisor program space */ -#define FC_CPU 7 /* CPU space */ - -/* fields in the 68020 cache control register */ -#define IC_ENABLE 0x0001 /* enable instruction cache */ -#define IC_FREEZE 0x0002 /* freeze instruction cache */ -#define IC_CE 0x0004 /* clear instruction cache entry */ -#define IC_CLR 0x0008 /* clear entire instruction cache */ - -/* additional fields in the 68030 cache control register */ -#define IC_BE 0x0010 /* instruction burst enable */ -#define DC_ENABLE 0x0100 /* data cache enable */ -#define DC_FREEZE 0x0200 /* data cache freeze */ -#define DC_CE 0x0400 /* clear data cache entry */ -#define DC_CLR 0x0800 /* clear entire data cache */ -#define DC_BE 0x1000 /* data burst enable */ -#define DC_WA 0x2000 /* write allocate */ - -#define CACHE_ON (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE) -#define CACHE_OFF (DC_CLR|IC_CLR) -#define CACHE_CLR (CACHE_ON) -#define IC_CLEAR (DC_WA|DC_BE|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE) -#define DC_CLEAR (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_ENABLE) - -/* 68040 cache control register */ -#define IC4_ENABLE 0x8000 /* instruction cache enable bit */ -#define DC4_ENABLE 0x80000000 /* data cache enable bit */ - -#define CACHE4_ON (IC4_ENABLE|DC4_ENABLE) -#define CACHE4_OFF (0) - #endif /* _HP300_CPU_H_ */ diff --git a/sys/arch/hp300/include/db_machdep.h b/sys/arch/hp300/include/db_machdep.h index 856c91dd32b..bf3b49e5752 100644 --- a/sys/arch/hp300/include/db_machdep.h +++ b/sys/arch/hp300/include/db_machdep.h @@ -1,3 +1,4 @@ +/* $OpenBSD: db_machdep.h,v 1.2 1997/01/12 15:13:33 downsj Exp $ */ /* $NetBSD: db_machdep.h,v 1.2 1994/10/26 07:26:21 cgd Exp $ */ /* Just use the common m68k definition */ diff --git a/sys/arch/hp300/include/disklabel.h b/sys/arch/hp300/include/disklabel.h index 8e008d95c3e..883ac3b1005 100644 --- a/sys/arch/hp300/include/disklabel.h +++ b/sys/arch/hp300/include/disklabel.h @@ -1,3 +1,4 @@ +/* $OpenBSD: disklabel.h,v 1.2 1997/01/12 15:13:34 downsj Exp $ */ /* $NetBSD: disklabel.h,v 1.1 1994/10/14 18:26:39 cgd Exp $ */ /* diff --git a/sys/arch/hp300/include/exec.h b/sys/arch/hp300/include/exec.h index c38c46f767e..393d2fe01f6 100644 --- a/sys/arch/hp300/include/exec.h +++ b/sys/arch/hp300/include/exec.h @@ -1,3 +1,4 @@ +/* $OpenBSD: exec.h,v 1.7 1997/01/12 15:13:34 downsj Exp $ */ /* $NetBSD: exec.h,v 1.10 1995/11/20 01:15:26 thorpej Exp $ */ /* diff --git a/sys/arch/hp300/include/float.h b/sys/arch/hp300/include/float.h index c9f45e98615..c0e220eac0e 100644 --- a/sys/arch/hp300/include/float.h +++ b/sys/arch/hp300/include/float.h @@ -1,3 +1,4 @@ +/* $OpenBSD: float.h,v 1.2 1997/01/12 15:13:35 downsj Exp $ */ /* $NetBSD: float.h,v 1.7 1995/06/20 20:45:34 jtc Exp $ */ #ifndef _MACHINE_FLOAT_H_ diff --git a/sys/arch/hp300/include/frame.h b/sys/arch/hp300/include/frame.h index cc15f6df635..fc372d5c7e8 100644 --- a/sys/arch/hp300/include/frame.h +++ b/sys/arch/hp300/include/frame.h @@ -1,3 +1,4 @@ +/* $OpenBSD: frame.h,v 1.2 1997/01/12 15:13:35 downsj Exp $ */ /* $NetBSD: frame.h,v 1.6 1994/10/26 07:26:26 cgd Exp $ */ #include diff --git a/sys/arch/hp300/include/hpux_machdep.h b/sys/arch/hp300/include/hpux_machdep.h index e56155c00bc..35dc0172934 100644 --- a/sys/arch/hp300/include/hpux_machdep.h +++ b/sys/arch/hp300/include/hpux_machdep.h @@ -1,3 +1,4 @@ +/* $OpenBSD: hpux_machdep.h,v 1.3 1997/01/12 15:13:36 downsj Exp $ */ /* $NetBSD: hpux_machdep.h,v 1.3 1996/02/28 01:05:57 thorpej Exp $ */ /*- diff --git a/sys/arch/hp300/include/ieeefp.h b/sys/arch/hp300/include/ieeefp.h index 8d6941e81b5..0f5193f345f 100644 --- a/sys/arch/hp300/include/ieeefp.h +++ b/sys/arch/hp300/include/ieeefp.h @@ -1,3 +1,4 @@ +/* $OpenBSD: ieeefp.h,v 1.2 1997/01/12 15:13:36 downsj Exp $ */ /* $NetBSD: ieeefp.h,v 1.2 1995/04/16 16:47:08 jtc Exp $ */ /* Just use the common m68k definition */ diff --git a/sys/arch/hp300/include/limits.h b/sys/arch/hp300/include/limits.h index b05789b6024..1ed49de2d47 100644 --- a/sys/arch/hp300/include/limits.h +++ b/sys/arch/hp300/include/limits.h @@ -1,3 +1,4 @@ +/* $OpenBSD: limits.h,v 1.2 1997/01/12 15:13:37 downsj Exp $ */ /* $NetBSD: limits.h,v 1.7 1994/10/26 07:26:27 cgd Exp $ */ /* Just use the common m68k definition */ diff --git a/sys/arch/hp300/include/mtpr.h b/sys/arch/hp300/include/mtpr.h index b18f2a508a6..98a81be12be 100644 --- a/sys/arch/hp300/include/mtpr.h +++ b/sys/arch/hp300/include/mtpr.h @@ -1,3 +1,4 @@ +/* $OpenBSD: mtpr.h,v 1.2 1997/01/12 15:13:37 downsj Exp $ */ /* $NetBSD: mtpr.h,v 1.4 1994/10/26 07:26:29 cgd Exp $ */ /* diff --git a/sys/arch/hp300/include/param.h b/sys/arch/hp300/include/param.h index 6b7edddb9f9..d6f4b852f76 100644 --- a/sys/arch/hp300/include/param.h +++ b/sys/arch/hp300/include/param.h @@ -1,4 +1,5 @@ -/* $NetBSD: param.h,v 1.26 1996/05/17 15:38:08 thorpej Exp $ */ +/* $OpenBSD: param.h,v 1.5 1997/01/12 15:13:38 downsj Exp $ */ +/* $NetBSD: param.h,v 1.27 1996/12/09 03:04:48 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -163,12 +164,23 @@ #define spl6() _spl(PSL_S|PSL_IPL6) #define spl7() _spl(PSL_S|PSL_IPL7) +#if defined(_KERNEL) && !defined(_LOCORE) +/* + * These four globals contain the appropriate PSL_S|PSL_IPL? values + * to raise interrupt priority to the requested level. + */ +extern unsigned short hp300_bioipl; +extern unsigned short hp300_netipl; +extern unsigned short hp300_ttyipl; +extern unsigned short hp300_impipl; +#endif /* _KERNEL && !_LOCORE */ + #define splsoftclock() spl1() #define splsoftnet() spl1() -#define splbio() spl5() -#define splnet() spl5() -#define spltty() spl5() -#define splimp() spl5() +#define splbio() _spl(hp300_bioipl) +#define splnet() _spl(hp300_netipl) +#define spltty() _spl(hp300_ttyipl) +#define splimp() _spl(hp300_impipl) #define splclock() spl6() #define splstatclock() spl6() #define splvm() spl6() diff --git a/sys/arch/hp300/include/pcb.h b/sys/arch/hp300/include/pcb.h index 796cca53790..01f3fe17664 100644 --- a/sys/arch/hp300/include/pcb.h +++ b/sys/arch/hp300/include/pcb.h @@ -1,3 +1,4 @@ +/* $OpenBSD: pcb.h,v 1.2 1997/01/12 15:13:38 downsj Exp $ */ /* $NetBSD: pcb.h,v 1.8 1995/05/12 12:55:17 mycroft Exp $ */ /* diff --git a/sys/arch/hp300/include/pmap.h b/sys/arch/hp300/include/pmap.h index 13de98c2a0d..3637780c2a0 100644 --- a/sys/arch/hp300/include/pmap.h +++ b/sys/arch/hp300/include/pmap.h @@ -1,3 +1,4 @@ +/* $OpenBSD: pmap.h,v 1.3 1997/01/12 15:13:39 downsj Exp $ */ /* $NetBSD: pmap.h,v 1.10 1995/12/11 17:09:23 thorpej Exp $ */ /* diff --git a/sys/arch/hp300/include/proc.h b/sys/arch/hp300/include/proc.h index 5eb1cad8d9c..ce6790006e0 100644 --- a/sys/arch/hp300/include/proc.h +++ b/sys/arch/hp300/include/proc.h @@ -1,3 +1,4 @@ +/* $OpenBSD: proc.h,v 1.2 1997/01/12 15:13:40 downsj Exp $ */ /* $NetBSD: proc.h,v 1.6 1994/10/26 07:26:35 cgd Exp $ */ /* diff --git a/sys/arch/hp300/include/profile.h b/sys/arch/hp300/include/profile.h index 82294239a1b..644a9fdfeaa 100644 --- a/sys/arch/hp300/include/profile.h +++ b/sys/arch/hp300/include/profile.h @@ -1,3 +1,4 @@ +/* $OpenBSD: profile.h,v 1.2 1997/01/12 15:13:40 downsj Exp $ */ /* $NetBSD: profile.h,v 1.2 1994/10/26 07:26:38 cgd Exp $ */ #include diff --git a/sys/arch/hp300/include/psl.h b/sys/arch/hp300/include/psl.h index 970687c2315..12ece870daa 100644 --- a/sys/arch/hp300/include/psl.h +++ b/sys/arch/hp300/include/psl.h @@ -1,3 +1,4 @@ +/* $OpenBSD: psl.h,v 1.2 1997/01/12 15:13:41 downsj Exp $ */ /* $NetBSD: psl.h,v 1.5 1994/10/26 07:26:39 cgd Exp $ */ #include diff --git a/sys/arch/hp300/include/pte.h b/sys/arch/hp300/include/pte.h index 65c526ce5af..188c36a10c0 100644 --- a/sys/arch/hp300/include/pte.h +++ b/sys/arch/hp300/include/pte.h @@ -1,3 +1,4 @@ +/* $OpenBSD: pte.h,v 1.2 1997/01/12 15:13:41 downsj Exp $ */ /* $NetBSD: pte.h,v 1.4 1994/10/26 07:26:40 cgd Exp $ */ /* diff --git a/sys/arch/hp300/include/ptrace.h b/sys/arch/hp300/include/ptrace.h index 76f781843e3..d7682944e9e 100644 --- a/sys/arch/hp300/include/ptrace.h +++ b/sys/arch/hp300/include/ptrace.h @@ -1,3 +1,4 @@ +/* $OpenBSD: ptrace.h,v 1.2 1997/01/12 15:13:42 downsj Exp $ */ /* $NetBSD: ptrace.h,v 1.2 1994/10/26 07:26:42 cgd Exp $ */ /* Just use the common m68k definition */ diff --git a/sys/arch/hp300/include/reg.h b/sys/arch/hp300/include/reg.h index 492b059d862..125fddf9825 100644 --- a/sys/arch/hp300/include/reg.h +++ b/sys/arch/hp300/include/reg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: reg.h,v 1.2 1997/01/12 15:13:42 downsj Exp $ */ /* $NetBSD: reg.h,v 1.9 1994/10/26 07:26:43 cgd Exp $ */ #ifndef _MACHINE_REG_H_ diff --git a/sys/arch/hp300/include/setjmp.h b/sys/arch/hp300/include/setjmp.h index 0e4a4b56978..d3e4e17d501 100644 --- a/sys/arch/hp300/include/setjmp.h +++ b/sys/arch/hp300/include/setjmp.h @@ -1,3 +1,4 @@ +/* $OpenBSD: setjmp.h,v 1.2 1997/01/12 15:13:43 downsj Exp $ */ /* $NetBSD: setjmp.h,v 1.1 1994/12/20 10:36:38 cgd Exp $ */ #include diff --git a/sys/arch/hp300/include/signal.h b/sys/arch/hp300/include/signal.h index 5787071f7aa..3703f702862 100644 --- a/sys/arch/hp300/include/signal.h +++ b/sys/arch/hp300/include/signal.h @@ -1,3 +1,4 @@ +/* $OpenBSD: signal.h,v 1.2 1997/01/12 15:13:43 downsj Exp $ */ /* $NetBSD: signal.h,v 1.3 1994/10/26 07:26:44 cgd Exp $ */ /* Just use the common m68k definition */ diff --git a/sys/arch/hp300/include/stdarg.h b/sys/arch/hp300/include/stdarg.h index 07f10c65ee5..89cf018016a 100644 --- a/sys/arch/hp300/include/stdarg.h +++ b/sys/arch/hp300/include/stdarg.h @@ -1,3 +1,4 @@ +/* $OpenBSD: stdarg.h,v 1.2 1997/01/12 15:13:44 downsj Exp $ */ /* $NetBSD: stdarg.h,v 1.4 1994/10/26 07:26:45 cgd Exp $ */ /* Just use the common m68k definition */ diff --git a/sys/arch/hp300/include/trap.h b/sys/arch/hp300/include/trap.h index 071e33d0575..bd17be38436 100644 --- a/sys/arch/hp300/include/trap.h +++ b/sys/arch/hp300/include/trap.h @@ -1,3 +1,4 @@ +/* $OpenBSD: trap.h,v 1.2 1997/01/12 15:13:44 downsj Exp $ */ /* $NetBSD: trap.h,v 1.6 1994/10/26 07:26:47 cgd Exp $ */ #include diff --git a/sys/arch/hp300/include/types.h b/sys/arch/hp300/include/types.h index 6f78747c1a6..17526a9e308 100644 --- a/sys/arch/hp300/include/types.h +++ b/sys/arch/hp300/include/types.h @@ -1,10 +1,9 @@ -/* $NetBSD: types.h,v 1.5 1995/06/26 05:13:46 cgd Exp $ */ +/* $OpenBSD: types.h,v 1.2 1997/01/12 15:13:45 downsj Exp $ */ +/* $NetBSD: types.h,v 1.8 1996/12/17 08:11:50 thorpej Exp $ */ #ifndef _MACHINE_TYPES_H_ #define _MACHINE_TYPES_H_ #include -#define __BDEVSW_DUMP_OLD_TYPE - #endif diff --git a/sys/arch/hp300/include/varargs.h b/sys/arch/hp300/include/varargs.h index 1ed0916752d..c6c7fbecba6 100644 --- a/sys/arch/hp300/include/varargs.h +++ b/sys/arch/hp300/include/varargs.h @@ -1,3 +1,4 @@ +/* $OpenBSD: varargs.h,v 1.2 1997/01/12 15:13:45 downsj Exp $ */ /* $NetBSD: varargs.h,v 1.2 1994/10/26 07:26:50 cgd Exp $ */ /* Just use the common m68k definition */ diff --git a/sys/arch/hp300/include/vmparam.h b/sys/arch/hp300/include/vmparam.h index 85f9bf25311..d33af98b429 100644 --- a/sys/arch/hp300/include/vmparam.h +++ b/sys/arch/hp300/include/vmparam.h @@ -1,4 +1,5 @@ -/* $NetBSD: vmparam.h,v 1.7 1994/10/26 07:26:52 cgd Exp $ */ +/* $OpenBSD: vmparam.h,v 1.2 1997/01/12 15:13:46 downsj Exp $ */ +/* $NetBSD: vmparam.h,v 1.9 1996/10/20 23:23:28 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah.