diff options
author | 2012-06-20 18:23:51 +0000 | |
---|---|---|
committer | 2012-06-20 18:23:51 +0000 | |
commit | b863178fa44a6e31e911ff85fa98508b933f9942 (patch) | |
tree | 4256082c34669da0f992e696628bcb28f76b6df6 | |
parent | Fix some hibernate issues on machines with > 3.5GB phys mem (diff) | |
download | wireguard-openbsd-b863178fa44a6e31e911ff85fa98508b933f9942.tar.xz wireguard-openbsd-b863178fa44a6e31e911ff85fa98508b933f9942.zip |
RIP mac68k. No one loves you anymore.
119 files changed, 0 insertions, 33639 deletions
diff --git a/sys/arch/mac68k/Makefile b/sys/arch/mac68k/Makefile deleted file mode 100644 index d34742f6ca2..00000000000 --- a/sys/arch/mac68k/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# $OpenBSD: Makefile,v 1.9 2010/11/12 17:11:44 deraadt Exp $ - -S= ${.CURDIR}/../.. -KFILE= GENERIC -.if exists(conf/GENERIC.MP) -KFILE= GENERIC.MP -.endif -TDIRS= ${_arch} include pci isa eisa -TAGS= ${.CURDIR}/tags - -NOPROG= -NOMAN= -SUBDIR= - -# config the fattest kernel we can find into a temporary dir -# to create a Makefile. Then use make to pull some variables -# out and push them into the sub-shell to expand the paths, -# and finally run ctags. -tags:: - TDIR=`mktemp -d /tmp/_tagXXXXXXXXXX` || exit 1; \ - eval "S=${S}" && \ - config -s ${S} -b $${TDIR} ${.CURDIR}/conf/${KFILE} && \ - eval "_arch=\"`make -V _arch -f $${TDIR}/Makefile`\"" && \ - eval "_mach=\"`make -V _mach -f $${TDIR}/Makefile`\"" && \ - eval "_machdir=\$S/arch/$${_mach}" && \ - eval "_archdir=\$S/arch/$${_arch}" && \ - eval "HFILES=\"`find $S \( -path $S/'arch' -o -path $S/stand -o -path $S/lib/libsa -o -path $S'/lib/libkern/arch' \) -prune -o -name '*.h'; find $${_machdir} $${_archdir} $S/lib/libkern/arch/$${_mach} \( -name boot -o -name stand \) -prune -o -name '*.h'`\"" && \ - eval "SFILES=\"`make -V SFILES -f $${TDIR}/Makefile`\"" && \ - eval "CFILES=\"`make -V CFILES -f $${TDIR}/Makefile`\"" && \ - eval "AFILES=\"`make -V AFILES -f $${TDIR}/Makefile`\"" && \ - ctags -wd -f ${TAGS} $${CFILES} $${HFILES} && \ - egrep "^[_A-Z]*ENTRY[_A-Z]*\(.*\)" $${SFILES} $${AFILES} | \ - sed "s;\\([^:]*\\):\\([^(]*\\)(\\([^, )]*\\)\\(.*\\);\\3 \\1 /^\\2(\\3\\4$$/;" \ - >> ${TAGS} && \ - sort -o ${TAGS} ${TAGS} && \ - rm -rf $${TDIR} - -links: - -for i in conf ${TDIRS}; do \ - (cd $$i && rm -f tags; ln -s tags tags); done - -obj: _SUBDIRUSE - -.include <bsd.prog.mk> diff --git a/sys/arch/mac68k/compile/.cvsignore b/sys/arch/mac68k/compile/.cvsignore deleted file mode 100644 index eb0a06c8f52..00000000000 --- a/sys/arch/mac68k/compile/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -GENERIC -GENERICSBC -RAMDISK -RAMDISKSBC diff --git a/sys/arch/mac68k/conf/GENERIC b/sys/arch/mac68k/conf/GENERIC deleted file mode 100644 index 624730f3136..00000000000 --- a/sys/arch/mac68k/conf/GENERIC +++ /dev/null @@ -1,75 +0,0 @@ -# $OpenBSD: GENERIC,v 1.51 2011/06/29 20:52:09 matthew Exp $ -# -# For further information on compiling OpenBSD kernels, see the config(8) -# man page. -# -# For further information on hardware support for this architecture, see -# the intro(4) man page. For further information about kernel options -# for this architecture, see the options(4) man page. For an explanation -# of each device driver in this file see the section 4 man page for the -# device. - -machine mac68k m68k -include "../../../conf/GENERIC" -maxusers 32 # estimated number of users - -# Mac-specific options -option M68040 -option M68030 -option M68020 # Must have 68851 PMMU -option FPSP -option FPU_EMULATE -option ADBVERBOSE -option WSDISPLAY_COMPAT_RAWKBD # provide raw scancodes; needed for X11 - -config bsd swap generic - -mainbus0 at root - -# on-board I/O -obio0 at mainbus? - -adb0 at obio? -akbd* at adb? # ADB keyboard -ams* at adb? # ADB mouse - -asc0 at obio? # ASC/EASC audio -esp0 at obio? # SCSI NCR 53C9x -esp1 at obio? # SCSI NCR 53C9x -macfb* at obio? # Internal video hardware -mc* at obio? # MACE ethernet on Centris/Quadra 660av -sn* at obio? # Internal ethernet -zsc0 at obio? # Zilog serial chip -zstty* at zsc? - -# nubus boards -nubus0 at mainbus? - -ae* at nubus? # Most Apple Ethernet Cards -macfb* at nubus? # NuBus video cards -sn* at nubus? # SONIC-based ethernet cards -#sm* at nubus? # SMC 91cxx-based ethernet cards - -#nsphy* at mii? phy? -#ukphy* at mii? phy? - -# workstation console -wsdisplay* at macfb? -wskbd* at akbd? mux 1 -wsmouse* at ams? mux 0 - -# Enable only one of ncrscsi or sbc -ncrscsi0 at obio? # SCSI NCR 5380 -sbc0 at obio? disable flags 0x1 # MI NCR 5380 SCSI Bus Controller - - -scsibus* at scsi? -sd* at scsibus? # SCSI disk drives -st* at scsibus? # SCSI tape drives -cd* at scsibus? # SCSI CD-ROM drives -ch* at scsibus? # SCSI autochangers -safte* at scsibus? # SCSI accessed fault-tolerant enclosures -ses* at scsibus? # SCSI enclosure services -uk* at scsibus? # SCSI unknown - -pseudo-device wsmux 2 diff --git a/sys/arch/mac68k/conf/Makefile.mac68k b/sys/arch/mac68k/conf/Makefile.mac68k deleted file mode 100644 index 5dafae8771a..00000000000 --- a/sys/arch/mac68k/conf/Makefile.mac68k +++ /dev/null @@ -1,171 +0,0 @@ -# $OpenBSD: Makefile.mac68k,v 1.74 2011/11/08 18:41:34 matthieu Exp $ - -# For instructions on building kernels consult the config(8) and options(4) -# manual pages. -# -# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE -# IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING -# DEBUG is set to -g by config if debugging is requested (config -g). -# PROF is set to -pg by config if profiling is requested (config -p). - -.include <bsd.own.mk> - -SIZE?= size -STRIP?= strip - -# source tree is located via $S relative to the compilation directory -.ifndef S -S!= cd ../../../..; pwd -.endif - -_machdir?= $S/arch/${_mach} -_archdir?= $S/arch/${_arch} - -INCLUDES= -nostdinc -I. -I$S -I$S/arch -CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D__${_mach}__ -MD -MP -CWARNFLAGS= -Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \ - -Wno-main -Wno-uninitialized -Wno-format \ - -Wstack-larger-than-2047 - -CMACHFLAGS= -msoft-float -CMACHFLAGS+= -fno-builtin-printf -fno-builtin-snprintf \ - -fno-builtin-vsnprintf -fno-builtin-log \ - -fno-builtin-log2 -fno-builtin-malloc -.if ${IDENT:M-DNO_PROPOLICE} -CMACHFLAGS+= -fno-stack-protector -.endif - -COPTS?= -O2 -CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE} -AFLAGS= -D_LOCORE -x assembler-with-cpp -traditional-cpp ${CMACHFLAGS} -LINKFLAGS= -n -Ttext 0 -e start - -.if ${IDENT:M-DDDB_STRUCT} -DB_STRUCTINFO= db_structinfo.h -.else -DB_STRUCTINFO= -.endif - -.include "${_archdir}/fpsp/Makefile.inc" - -HOSTCC?= ${CC} -HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//} -HOSTED_CFLAGS= ${CFLAGS} -HOSTED_C= ${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $< - -NORMAL_C_NOP= ${CC} ${CFLAGS} ${CPPFLAGS} -c $< -NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< -NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< - -%OBJS - -%CFILES - -%SFILES - -# load lines for config "xxx" will be emitted as: -# xxx: ${SYSTEM_DEP} swapxxx.o -# ${SYSTEM_LD_HEAD} -# ${SYSTEM_LD} swapxxx.o -# ${SYSTEM_LD_TAIL} -SYSTEM_HEAD= locore.o param.o ioconf.o ${FPSP} -SYSTEM_OBJ= ${SYSTEM_HEAD} ${OBJS} -SYSTEM_DEP= Makefile ${SYSTEM_OBJ} -SYSTEM_LD_HEAD= @rm -f $@ -SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \ - ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} vers.o ${OBJS} -SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@ - -DEBUG?= -.if ${DEBUG} == "-g" -LINKFLAGS+= -X -STRIPFLAGS= -g -SYSTEM_LD_TAIL+=; \ - echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \ - echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ - ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb -.else -LINKFLAGS+= -S -.endif - -%LOAD - -# cc's -MD puts the source and output paths in the dependency file; -# since those are temp files here we need to fix it up. It also -# puts the file in /tmp, so we use -MF to put it in the current -# directory as assym.P and then generate assym.d from it with a -# good target name -assym.h: $S/kern/genassym.sh Makefile \ - ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf - cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ - sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp - sed '1s/.*/assym.h: \\/' assym.P > assym.d - sort -u assym.h.tmp > assym.h - -param.c: $S/conf/param.c - rm -f param.c - cp $S/conf/param.c . - -param.o: param.c Makefile - ${NORMAL_C} - -mcount.o: $S/lib/libkern/mcount.c Makefile - ${NORMAL_C_NOP} - -ioconf.o: ioconf.c - ${NORMAL_C} - -vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} - sh $S/conf/newvers.sh - ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c - -clean:: - rm -f eddep *bsd *bsd.gdb tags *.[dio] [a-z]*.s \ - [Ee]rrs linterrs assym.h ${DB_STRUCTINFO} - -lint: - @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \ - ${CFILES} ioconf.c param.c | \ - grep -v 'static function .* unused' - -depend: - @touch $@ - -tags: - @echo "see $S/kern/Makefile for tags" - -db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.awk - ${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c - objdump -g db_structinfo.o | awk -f $S/ddb/parse_structinfo.awk > $@ - rm -f db_structinfo.o - -locore.o: ${_machdir}/${_mach}/locore.s assym.h -copy.o copypage.o: assym.h - -# The install target can be redefined by putting a -# install-kernel-${MACHINE_NAME} target into /etc/mk.conf -MACHINE_NAME!= uname -n -install: install-kernel-${MACHINE_NAME} -.if !target(install-kernel-${MACHINE_NAME}}) -install-kernel-${MACHINE_NAME}: - rm -f /obsd - ln /bsd /obsd - cp bsd /nbsd - mv /nbsd /bsd -.endif - -# pull in the dependency information -.if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) - ${SYSTEM_OBJ}: ${DB_STRUCTINFO} -.endif -.ifnmake clean -. for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO} -. if exists(${o:R}.d) -. include "${o:R}.d" -. elif exists($o) - .PHONY: $o -. endif -. endfor -.endif - -%RULES diff --git a/sys/arch/mac68k/conf/RAMDISK b/sys/arch/mac68k/conf/RAMDISK deleted file mode 100644 index 441dcae0314..00000000000 --- a/sys/arch/mac68k/conf/RAMDISK +++ /dev/null @@ -1,75 +0,0 @@ -# $OpenBSD: RAMDISK,v 1.25 2011/11/08 19:22:13 deraadt Exp $ - -machine mac68k m68k - -# 1.4 meg ramdisk -option MINIROOTSIZE=2880 -option RAMDISK_HOOKS - -option SCSITERSE -option SMALL_KERNEL -option NO_PROPOLICE -option TIMEZONE=0 -option DST=0 -option FFS # UFS -option NFSCLIENT # Network File System client -option CD9660 # ISO 9660 + Rock Ridge file system -option INET # IP + ICMP + TCP + UDP - -pseudo-device loop 1 # network loopback -pseudo-device bpfilter 1 # packet filter - -# Comment out until UKC can be invoked on mac68k... -#option BOOT_CONFIG # add support for boot -c -option DDB - -# Mac-specific options -option M68040 -option M68030 -option M68020 # Must have 68851 PMMU -option FPSP -option FPU_EMULATE - -config bsd root on rd0a -maxusers 32 - -mainbus0 at root - -# on-board I/O -obio0 at mainbus? - -adb0 at obio? -akbd* at adb? # ADB keyboard -#ams* at adb? # ADB mouse - -esp0 at obio? # SCSI NCR 53C9x -esp1 at obio? # SCSI NCR 53C9x -macfb* at obio? # Internal video hardware -mc* at obio? # MACE ethernet on Centris/Quadra 660av -sn* at obio? # Internal ethernet -zsc0 at obio? # Zilog serial chip -zstty* at zsc? - -# nubus boards -nubus0 at mainbus? - -ae* at nubus? # Most Apple Ethernet Cards -macfb* at nubus? # NuBus video cards -sn* at nubus? # SONIC-based ethernet cards - -# workstation console -wsdisplay* at macfb? -wskbd* at akbd? -#wsmouse* at ams? - -# Enable only one of ncrscsi or sbc -ncrscsi0 at obio? # SCSI NCR 5380 -sbc0 at obio? disable flags 0x1 # MI NCR 5380 SCSI Bus Controller - - -scsibus* at scsi? -sd* at scsibus? # SCSI disk drives -st* at scsibus? # SCSI tape drives -cd* at scsibus? # SCSI CD-ROM drives - -pseudo-device rd 1 diff --git a/sys/arch/mac68k/conf/files.mac68k b/sys/arch/mac68k/conf/files.mac68k deleted file mode 100644 index 5a42965a28d..00000000000 --- a/sys/arch/mac68k/conf/files.mac68k +++ /dev/null @@ -1,127 +0,0 @@ -# $OpenBSD: files.mac68k,v 1.43 2007/01/22 13:17:45 martin Exp $ -# $NetBSD: files.mac68k,v 1.61 1997/03/01 20:22:16 scottr Exp $ - -# mac68k-specific configuration info - -# maxpartitions must be first item in files.${ARCH}.newconf -maxpartitions 16 - -maxusers 2 8 64 - -device mainbus {} # no locators (yet?) -attach mainbus at root - -device obio {[ addr = -1 ]} -attach obio at mainbus -file arch/mac68k/dev/obio.c obio - -device nubus {} -attach nubus at mainbus -file arch/mac68k/dev/nubus.c nubus - -device adb {} -attach adb at obio -file arch/mac68k/dev/adb.c adb -file arch/mac68k/dev/pm_direct.c adb - -# -# "workstation console" routines -# -include "dev/rasops/files.rasops" -include "dev/wscons/files.wscons" -include "dev/wsfont/files.wsfont" - -# -# adb devices -# -include "dev/adb/files.adb" -file arch/mac68k/dev/akbd_machdep.c akbd - -device asc -attach asc at obio -file arch/mac68k/dev/asc.c asc needs-flag - -device macfb: wsemuldisplaydev, rasops1, rasops2, rasops4, rasops8, rasops16, rasops32 -attach macfb at obio with macfb_obio -attach macfb at nubus with macfb_nubus -file arch/mac68k/dev/macfb.c macfb needs-flag -file arch/mac68k/dev/grf_iv.c macfb_obio -file arch/mac68k/dev/grf_mv.c macfb_nubus - -device ae: ifnet, ether, dp8390nic, ifmedia -attach ae at nubus with ae_nubus -file arch/mac68k/dev/if_ae_nubus.c ae_nubus -file arch/mac68k/dev/if_ae.c ae - -device sn: ifnet, ether -attach sn at obio with sn_obio -attach sn at nubus with sn_nubus -file arch/mac68k/dev/if_sn.c sn -file arch/mac68k/dev/if_sn_obio.c sn_obio -file arch/mac68k/dev/if_sn_nubus.c sn_nubus - -device mc: ifnet, ether -attach mc at obio with mc_obio -file arch/mac68k/dev/if_mc.c -file arch/mac68k/dev/if_mc_obio.c - -attach sm at nubus with sm_nubus -file arch/mac68k/dev/if_sm_nubus.c sm_nubus - -include "scsi/files.scsi" -include "dev/mii/files.mii" - -# Option 1 for ncr5380 support -device ncrscsi: scsi -attach ncrscsi at obio -file arch/mac68k/dev/mac68k5380.c ncrscsi needs-flag - -# Option 2 for ncr5380 support -device sbc: scsi, ncr5380sbc -attach sbc at obio with sbc_obio -file arch/mac68k/dev/sbc_obio.c sbc_obio -file arch/mac68k/dev/sbc.c sbc - -attach esp at obio -file arch/mac68k/dev/esp.c esp - -device zsc {[channel = -1]} -attach zsc at obio -file arch/mac68k/dev/zs.c zsc needs-flag -file arch/mac68k/dev/z8530sc.c zsc - -device zstty: tty -attach zstty at zsc -file arch/mac68k/dev/z8530tty.c zstty needs-flag - -file arch/m68k/m68k/db_memrw.c ddb -include "arch/m68k/fpe/files.fpe" - -file arch/mac68k/mac68k/autoconf.c -file arch/mac68k/mac68k/bus_space.c -file arch/mac68k/mac68k/clock.c -file arch/mac68k/mac68k/conf.c -file arch/mac68k/mac68k/disksubr.c disk -file arch/mac68k/mac68k/intr.c -file arch/mac68k/mac68k/iop.c -file arch/mac68k/mac68k/machdep.c -file arch/mac68k/mac68k/mainbus.c -file arch/mac68k/mac68k/mem.c -file arch/m68k/m68k/pmap_motorola.c -file arch/mac68k/mac68k/pmap_bootstrap.c -file arch/mac68k/mac68k/pram.c -file arch/mac68k/mac68k/pramasm.s -file arch/mac68k/mac68k/psc.c -file arch/mac68k/mac68k/sys_machdep.c -file arch/mac68k/mac68k/trap.c -file arch/mac68k/mac68k/via.c -file arch/mac68k/mac68k/vm_machdep.c -file arch/mac68k/mac68k/wscons_machdep.c - -file dev/cninit.c - -major {sd = 4} -major {st = 5} -major {cd = 6} -major {vnd = 8} -major {rd = 13} diff --git a/sys/arch/mac68k/dev/adb.c b/sys/arch/mac68k/dev/adb.c deleted file mode 100644 index 43e3614383e..00000000000 --- a/sys/arch/mac68k/dev/adb.c +++ /dev/null @@ -1,2817 +0,0 @@ -/* $OpenBSD: adb.c,v 1.28 2011/06/15 21:32:03 miod Exp $ */ -/* $NetBSD: adb.c,v 1.47 2005/06/16 22:43:36 jmc Exp $ */ -/* $NetBSD: adb_direct.c,v 1.51 2005/06/16 22:43:36 jmc Exp $ */ - -/* - * Copyright (C) 1996, 1997 John P. Wittkoski - * 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 John P. Wittkoski. - * 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. - */ - -/* - * Copyright (C) 1994 Bradley A. Grantham - * 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 Bradley A. Grantham. - * 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. - */ - -/* - * This code is rather messy, but I don't have time right now - * to clean it up as much as I would like. - * But it works, so I'm happy. :-) jpw - */ - -/* - * TO DO: - * - We could reduce the time spent in the adb_intr_* routines - * by having them save the incoming and outgoing data directly - * in the adbInbound and adbOutbound queues, as it would reduce - * the number of times we need to copy the data around. It - * would also make the code more readable and easier to follow. - * - (Related to above) Use the header part of adbCommand to - * reduce the number of copies we have to do of the data. - * - (Related to above) Actually implement the adbOutbound queue. - * This is fairly easy once you switch all the intr routines - * over to using adbCommand structs directly. - * - There is a bug in the state machine of adb_intr_cuda - * code that causes hangs, especially on 030 machines, probably - * because of some timing issues. Because I have been unable to - * determine the exact cause of this bug, I used the timeout function - * to check for and recover from this condition. If anyone finds - * the actual cause of this bug, the calls to timeout and the - * adb_cuda_tickle routine can be removed. - */ - -#include <sys/param.h> -#include <sys/device.h> -#include <sys/fcntl.h> -#include <sys/poll.h> -#include <sys/selinfo.h> -#include <sys/proc.h> -#include <sys/signalvar.h> -#include <sys/timeout.h> -#include <sys/systm.h> - -#include <machine/autoconf.h> -#include <machine/cpu.h> -#include <machine/viareg.h> - -#include <dev/adb/adb.h> -#include <mac68k/dev/adbvar.h> - -#define printf_intr printf - -int adb_polling; /* Are we polling? (Debugger mode) */ -#ifdef ADB_DEBUG -int adb_debug; /* Output debugging messages */ -#endif /* ADB_DEBUG */ - -struct adb_softc { - struct device sc_dev; - void *sc_softih; -}; - -/* some misc. leftovers */ -#define vPB 0x0000 -#define vPB3 0x08 -#define vPB4 0x10 -#define vPB5 0x20 -#define vSR_INT 0x04 -#define vSR_OUT 0x10 - -/* the type of ADB action that we are currently preforming */ -#define ADB_ACTION_NOTREADY 0x1 /* has not been initialized yet */ -#define ADB_ACTION_IDLE 0x2 /* the bus is currently idle */ -#define ADB_ACTION_OUT 0x3 /* sending out a command */ -#define ADB_ACTION_IN 0x4 /* receiving data */ -#define ADB_ACTION_POLLING 0x5 /* polling - II only */ - -/* - * These describe the state of the ADB bus itself, although they - * don't necessarily correspond directly to ADB states. - * Note: these are not really used in the IIsi code. - */ -#define ADB_BUS_UNKNOWN 0x1 /* we don't know yet - all models */ -#define ADB_BUS_IDLE 0x2 /* bus is idle - all models */ -#define ADB_BUS_CMD 0x3 /* starting a command - II models */ -#define ADB_BUS_ODD 0x4 /* the "odd" state - II models */ -#define ADB_BUS_EVEN 0x5 /* the "even" state - II models */ -#define ADB_BUS_ACTIVE 0x6 /* active state - IIsi models */ -#define ADB_BUS_ACK 0x7 /* currently ACKing - IIsi models */ - -/* - * Shortcuts for setting or testing the VIA bit states. - * Not all shortcuts are used for every type of ADB hardware. - */ -#define ADB_SET_STATE_IDLE_II() via_reg(VIA1, vBufB) |= (vPB4 | vPB5) -#define ADB_SET_STATE_IDLE_IISI() via_reg(VIA1, vBufB) &= ~(vPB4 | vPB5) -#define ADB_SET_STATE_IDLE_CUDA() via_reg(VIA1, vBufB) |= (vPB4 | vPB5) -#define ADB_SET_STATE_CMD() via_reg(VIA1, vBufB) &= ~(vPB4 | vPB5) -#define ADB_SET_STATE_EVEN() via_reg(VIA1, vBufB) = ((via_reg(VIA1, \ - vBufB) | vPB4) & ~vPB5) -#define ADB_SET_STATE_ODD() via_reg(VIA1, vBufB) = ((via_reg(VIA1, \ - vBufB) | vPB5) & ~vPB4) -#define ADB_SET_STATE_ACTIVE() via_reg(VIA1, vBufB) |= vPB5 -#define ADB_SET_STATE_INACTIVE() via_reg(VIA1, vBufB) &= ~vPB5 -#define ADB_SET_STATE_TIP() via_reg(VIA1, vBufB) &= ~vPB5 -#define ADB_CLR_STATE_TIP() via_reg(VIA1, vBufB) |= vPB5 -#define ADB_SET_STATE_ACKON() via_reg(VIA1, vBufB) |= vPB4 -#define ADB_SET_STATE_ACKOFF() via_reg(VIA1, vBufB) &= ~vPB4 -#define ADB_TOGGLE_STATE_ACK_CUDA() via_reg(VIA1, vBufB) ^= vPB4 -#define ADB_SET_STATE_ACKON_CUDA() via_reg(VIA1, vBufB) &= ~vPB4 -#define ADB_SET_STATE_ACKOFF_CUDA() via_reg(VIA1, vBufB) |= vPB4 -#define ADB_SET_SR_INPUT() via_reg(VIA1, vACR) &= ~vSR_OUT -#define ADB_SET_SR_OUTPUT() via_reg(VIA1, vACR) |= vSR_OUT -#define ADB_SR() via_reg(VIA1, vSR) -#define ADB_VIA_INTR_ENABLE() via_reg(VIA1, vIER) = 0x84 -#define ADB_VIA_INTR_DISABLE() via_reg(VIA1, vIER) = 0x04 -#define ADB_VIA_CLR_INTR() via_reg(VIA1, vIFR) = 0x04 -#define ADB_INTR_IS_OFF (vPB3 == (via_reg(VIA1, vBufB) & vPB3)) -#define ADB_INTR_IS_ON (0 == (via_reg(VIA1, vBufB) & vPB3)) -#define ADB_SR_INTR_IS_OFF (0 == (via_reg(VIA1, vIFR) & vSR_INT)) -#define ADB_SR_INTR_IS_ON (vSR_INT == (via_reg(VIA1, \ - vIFR) & vSR_INT)) - -/* - * This is the delay that is required (in uS) between certain - * ADB transactions. The actual timing delay for for each uS is - * calculated at boot time to account for differences in machine speed. - */ -#define ADB_DELAY 150 - -/* - * Maximum ADB message length; includes space for data, result, and - * device code - plus a little for safety. - */ -#define ADB_MAX_MSG_LENGTH 16 -#define ADB_MAX_HDR_LENGTH 8 - -#define ADB_QUEUE 32 -#define ADB_TICKLE_TICKS 4 - -/* - * A structure for storing information about each ADB device. - */ -struct ADBDevEntry { - void (*ServiceRtPtr)(void); - void *DataAreaAddr; - int devType; - int origAddr; - int currentAddr; -}; - -/* - * Used to hold ADB commands that are waiting to be sent out. - */ -struct adbCmdHoldEntry { - u_char outBuf[ADB_MAX_MSG_LENGTH]; /* our message */ - u_char *saveBuf; /* buffer to know where to save result */ - u_char *compRout; /* completion routine pointer */ - u_char *data; /* completion routine data pointer */ -}; - -/* - * Eventually used for two separate queues, the queue between - * the upper and lower halves, and the outgoing packet queue. - * TO DO: adbCommand can replace all of adbCmdHoldEntry eventually - */ -struct adbCommand { - u_char header[ADB_MAX_HDR_LENGTH]; /* not used yet */ - u_char data[ADB_MAX_MSG_LENGTH]; /* packet data only */ - u_char *saveBuf; /* where to save result */ - u_char *compRout; /* completion routine pointer */ - u_char *compData; /* completion routine data pointer */ - u_int cmd; /* the original command for this data */ - u_int unsol; /* 1 if packet was unsolicited */ - u_int ack_only; /* 1 for no special processing */ -}; - -/* - * Text representations of each hardware class - */ -const char *adbHardwareDescr[] = { - "unknown", - "II series", - "IIsi series", - "PowerBook", - "Cuda", - "IOP" -}; - -/* - * A few variables that we need and their initial values. - */ -int adbHardware = ADB_HW_UNKNOWN; -int adbActionState = ADB_ACTION_NOTREADY; -int adbBusState = ADB_BUS_UNKNOWN; -int adbWaiting; /* waiting for return data from the device */ -int adbWriteDelay; /* working on (or waiting to do) a write */ -int adbOutQueueHasData; /* something in the queue waiting to go out */ -int adbSoftPower; /* machine supports soft power */ - -int adbWaitingCmd; /* ADB command we are waiting for */ -u_char *adbBuffer; /* pointer to user data area */ -void *adbCompRout; /* pointer to the completion routine */ -void *adbCompData; /* pointer to the completion routine data */ -int adbStarting = 1; /* doing adb_reinit so do polling differently */ - -u_char adbInputBuffer[ADB_MAX_MSG_LENGTH]; /* data input buffer */ -u_char adbOutputBuffer[ADB_MAX_MSG_LENGTH]; /* data output buffer */ -struct adbCmdHoldEntry adbOutQueue; /* our 1 entry output queue */ - -int adbSentChars; /* how many characters we have sent */ -int adbLastDevice; /* last ADB dev we heard from (II ONLY) */ - -struct ADBDevEntry ADBDevTable[16]; /* our ADB device table */ -int ADBNumDevices; /* num. of ADB devices found with adb_reinit */ - -struct adbCommand adbInbound[ADB_QUEUE]; /* incoming queue */ -volatile int adbInCount; /* how many packets in in queue */ -int adbInHead; /* head of in queue */ -int adbInTail; /* tail of in queue */ -struct adbCommand adbOutbound[ADB_QUEUE]; /* outgoing queue - not used yet */ -int adbOutCount; /* how many packets in out queue */ -int adbOutHead; /* head of out queue */ -int adbOutTail; /* tail of out queue */ - -int tickle_count; /* how many tickles seen for this packet? */ -int tickle_serial; /* the last packet tickled */ -int adb_cuda_serial; /* the current packet */ - -struct timeout adb_cuda_timeout; - -void pm_setup_adb(void); -void pm_hw_setup(struct device *); -void pm_check_adb_devices(int); -int pm_adb_op(u_char *, void *, void *, int); -void pm_init_adb_device(void); - -/* - * The following are private routines. - */ -#ifdef ADB_DEBUG -void print_single(u_char *); -#endif -int adb_intr(void *); -int adb_intr_II(void *); -int adb_intr_IIsi(void *); -int adb_intr_cuda(void *); -void adb_soft_intr(void *); -int send_adb_II(u_char *, u_char *, void *, void *, int); -int send_adb_IIsi(u_char *, u_char *, void *, void *, int); -int send_adb_cuda(u_char *, u_char *, void *, void *, int); -void adb_intr_cuda_test(void); -void adb_cuda_tickle(void); -void adb_pass_up(struct adbCommand *); -void adb_op_comprout(caddr_t, caddr_t, int); -void adb_reinit(struct adb_softc *); -int count_adbs(void); -int get_ind_adb_info(ADBDataBlock *, int); -int get_adb_info(ADBDataBlock *, int); -void adb_setup_hw_type(void); -int adb_op(Ptr, Ptr, Ptr, short); -void adb_read_II(u_char *); -void adb_hw_setup(struct adb_softc *); -void adb_hw_setup_IIsi(u_char *); -int adb_cmd_result(u_char *); -int adb_guess_next_device(void); -int adb_prog_switch_enable(void); -int adb_prog_switch_disable(void); -/* we should create this and it will be the public version */ -int send_adb(u_char *, void *, void *); - -#ifdef ADB_DEBUG -/* - * print_single - * Diagnostic display routine. Displays the hex values of the - * specified elements of the u_char. The length of the "string" - * is in [0]. - */ -void -print_single(u_char *str) -{ - int x; - - if (str == NULL) { - printf_intr("no data - null pointer\n"); - return; - } - if (*str == '\0') { - printf_intr("nothing returned\n"); - return; - } - if (*str > 20) { - printf_intr("ADB: ACK > 20 no way!\n"); - *str = (u_char)20; - } - printf_intr("(length=0x%x):", (u_int)*str); - for (x = 1; x <= *str; x++) - printf_intr(" 0x%02x", (u_int)*(str + x)); - printf_intr("\n"); -} -#endif - -void -adb_cuda_tickle(void) -{ - volatile int s; - - if (adbActionState == ADB_ACTION_IN) { - if (tickle_serial == adb_cuda_serial) { - if (++tickle_count > 0) { - s = splhigh(); - adbActionState = ADB_ACTION_IDLE; - adbInputBuffer[0] = 0; - ADB_SET_STATE_IDLE_CUDA(); - splx(s); - } - } else { - tickle_serial = adb_cuda_serial; - tickle_count = 0; - } - } else { - tickle_serial = adb_cuda_serial; - tickle_count = 0; - } - - timeout_add(&adb_cuda_timeout, ADB_TICKLE_TICKS); -} - -/* - * called when when an adb interrupt happens - * - * Cuda version of adb_intr - * TO DO: do we want to add some calls to intr_dispatch() here to - * grab serial interrupts? - */ -int -adb_intr_cuda(void *arg) -{ - volatile int i, ending; - volatile unsigned int s; - struct adbCommand packet; - - s = splhigh(); /* can't be too careful - might be called */ - /* from a routine, NOT an interrupt */ - - ADB_VIA_CLR_INTR(); /* clear interrupt */ - ADB_VIA_INTR_DISABLE(); /* disable ADB interrupt on IIs. */ - -switch_start: - switch (adbActionState) { - case ADB_ACTION_IDLE: - /* - * This is an unexpected packet, so grab the first (dummy) - * byte, set up the proper vars, and tell the chip we are - * starting to receive the packet by setting the TIP bit. - */ - adbInputBuffer[1] = ADB_SR(); - adb_cuda_serial++; - if (ADB_INTR_IS_OFF) /* must have been a fake start */ - break; - - ADB_SET_SR_INPUT(); - ADB_SET_STATE_TIP(); - - adbInputBuffer[0] = 1; - adbActionState = ADB_ACTION_IN; -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("idle 0x%02x ", adbInputBuffer[1]); -#endif - break; - - case ADB_ACTION_IN: - adbInputBuffer[++adbInputBuffer[0]] = ADB_SR(); - /* intr off means this is the last byte (end of frame) */ - if (ADB_INTR_IS_OFF) - ending = 1; - else - ending = 0; - - if (1 == ending) { /* end of message? */ -#ifdef ADB_DEBUG - if (adb_debug) { - printf_intr("in end 0x%02x ", - adbInputBuffer[adbInputBuffer[0]]); - print_single(adbInputBuffer); - } -#endif - - /* - * Are we waiting AND does this packet match what we - * are waiting for AND is it coming from either the - * ADB or RTC/PRAM sub-device? This section _should_ - * recognize all ADB and RTC/PRAM type commands, but - * there may be more... NOTE: commands are always at - * [4], even for RTC/PRAM commands. - */ - /* set up data for adb_pass_up */ - memcpy(packet.data, adbInputBuffer, adbInputBuffer[0] + 1); - - if ((adbWaiting == 1) && - (adbInputBuffer[4] == adbWaitingCmd) && - ((adbInputBuffer[2] == 0x00) || - (adbInputBuffer[2] == 0x01))) { - packet.saveBuf = adbBuffer; - packet.compRout = adbCompRout; - packet.compData = adbCompData; - packet.unsol = 0; - packet.ack_only = 0; - adb_pass_up(&packet); - - adbWaitingCmd = 0; /* reset "waiting" vars */ - adbWaiting = 0; - adbBuffer = NULL; - adbCompRout = NULL; - adbCompData = NULL; - } else { - packet.unsol = 1; - packet.ack_only = 0; - adb_pass_up(&packet); - } - - - /* reset vars and signal the end of this frame */ - adbActionState = ADB_ACTION_IDLE; - adbInputBuffer[0] = 0; - ADB_SET_STATE_IDLE_CUDA(); - /*ADB_SET_SR_INPUT();*/ - - /* - * If there is something waiting to be sent out, - * the set everything up and send the first byte. - */ - if (adbWriteDelay == 1) { - delay(ADB_DELAY); /* required */ - adbSentChars = 0; - adbActionState = ADB_ACTION_OUT; - /* - * If the interrupt is on, we were too slow - * and the chip has already started to send - * something to us, so back out of the write - * and start a read cycle. - */ - if (ADB_INTR_IS_ON) { - ADB_SET_SR_INPUT(); - ADB_SET_STATE_IDLE_CUDA(); - adbSentChars = 0; - adbActionState = ADB_ACTION_IDLE; - adbInputBuffer[0] = 0; - break; - } - /* - * If we got here, it's ok to start sending - * so load the first byte and tell the chip - * we want to send. - */ - ADB_SET_STATE_TIP(); - ADB_SET_SR_OUTPUT(); - ADB_SR() = adbOutputBuffer[adbSentChars + 1]; - } - } else { - ADB_TOGGLE_STATE_ACK_CUDA(); -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("in 0x%02x ", - adbInputBuffer[adbInputBuffer[0]]); -#endif - } - break; - - case ADB_ACTION_OUT: - i = ADB_SR(); /* reset SR-intr in IFR */ -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("intr out 0x%02x ", i); -#endif - - adbSentChars++; - if (ADB_INTR_IS_ON) { /* ADB intr low during write */ -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("intr was on "); -#endif - ADB_SET_SR_INPUT(); /* make sure SR is set to IN */ - ADB_SET_STATE_IDLE_CUDA(); - adbSentChars = 0; /* must start all over */ - adbActionState = ADB_ACTION_IDLE; /* new state */ - adbInputBuffer[0] = 0; - adbWriteDelay = 1; /* must retry when done with - * read */ - delay(ADB_DELAY); - goto switch_start; /* process next state right - * now */ - break; - } - if (adbOutputBuffer[0] == adbSentChars) { /* check for done */ - if (0 == adb_cmd_result(adbOutputBuffer)) { /* do we expect data - * back? */ - adbWaiting = 1; /* signal waiting for return */ - adbWaitingCmd = adbOutputBuffer[2]; /* save waiting command */ - } else { /* no talk, so done */ - /* set up stuff for adb_pass_up */ - memcpy(packet.data, adbInputBuffer, adbInputBuffer[0] + 1); - packet.saveBuf = adbBuffer; - packet.compRout = adbCompRout; - packet.compData = adbCompData; - packet.cmd = adbWaitingCmd; - packet.unsol = 0; - packet.ack_only = 1; - adb_pass_up(&packet); - - /* reset "waiting" vars, just in case */ - adbWaitingCmd = 0; - adbBuffer = NULL; - adbCompRout = NULL; - adbCompData = NULL; - } - - adbWriteDelay = 0; /* done writing */ - adbActionState = ADB_ACTION_IDLE; /* signal bus is idle */ - ADB_SET_SR_INPUT(); - ADB_SET_STATE_IDLE_CUDA(); -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("write done "); -#endif - } else { - ADB_SR() = adbOutputBuffer[adbSentChars + 1]; /* send next byte */ - ADB_TOGGLE_STATE_ACK_CUDA(); /* signal byte ready to - * shift */ -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("toggle "); -#endif - } - break; - - case ADB_ACTION_NOTREADY: -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("adb: not yet initialized\n"); -#endif - break; - - default: -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("intr: unknown ADB state\n"); -#endif - break; - } - - ADB_VIA_INTR_ENABLE(); /* enable ADB interrupt on IIs. */ - - splx(s); /* restore */ - - return (1); -} - - -int -send_adb_cuda(u_char *in, u_char *buffer, void *compRout, void *data, int - command) -{ - int s, len; - -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("SEND\n"); -#endif - - if (adbActionState == ADB_ACTION_NOTREADY) - return 1; - - /* Don't interrupt while we are messing with the ADB */ - s = splhigh(); - - if ((adbActionState == ADB_ACTION_IDLE) && /* ADB available? */ - (ADB_INTR_IS_OFF)) { /* and no incoming interrupt? */ - } else - if (adbWriteDelay == 0) /* it's busy, but is anything waiting? */ - adbWriteDelay = 1; /* if no, then we'll "queue" - * it up */ - else { - splx(s); - return 1; /* really busy! */ - } - -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("QUEUE\n"); -#endif - if ((long)in == (long)0) { /* need to convert? */ - /* - * Don't need to use adb_cmd_extra here because this section - * will be called ONLY when it is an ADB command (no RTC or - * PRAM) - */ - if ((command & 0x0c) == 0x08) /* copy addl data ONLY if - * doing a listen! */ - len = buffer[0]; /* length of additional data */ - else - len = 0;/* no additional data */ - - adbOutputBuffer[0] = 2 + len; /* dev. type + command + addl. - * data */ - adbOutputBuffer[1] = 0x00; /* mark as an ADB command */ - adbOutputBuffer[2] = (u_char)command; /* load command */ - - /* copy additional output data, if any */ - memcpy(adbOutputBuffer + 3, buffer + 1, len); - } else - /* if data ready, just copy over */ - memcpy(adbOutputBuffer, in, in[0] + 2); - - adbSentChars = 0; /* nothing sent yet */ - adbBuffer = buffer; /* save buffer to know where to save result */ - adbCompRout = compRout; /* save completion routine pointer */ - adbCompData = data; /* save completion routine data pointer */ - adbWaitingCmd = adbOutputBuffer[2]; /* save wait command */ - - if (adbWriteDelay != 1) { /* start command now? */ -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("out start NOW"); -#endif - delay(ADB_DELAY); - adbActionState = ADB_ACTION_OUT; /* set next state */ - ADB_SET_SR_OUTPUT(); /* set shift register for OUT */ - ADB_SR() = adbOutputBuffer[adbSentChars + 1]; /* load byte for output */ - ADB_SET_STATE_ACKOFF_CUDA(); - ADB_SET_STATE_TIP(); /* tell ADB that we want to send */ - } - adbWriteDelay = 1; /* something in the write "queue" */ - - splx(s); - - /* were VIA1 interrupts blocked? */ - if (PSLTOIPL(s) >= mac68k_machine.via1_ipl) { - /* poll until byte done */ - while ((adbActionState != ADB_ACTION_IDLE) || (ADB_INTR_IS_ON) - || (adbWaiting == 1)) - if (ADB_SR_INTR_IS_ON) { /* wait for "interrupt" */ - adb_intr_cuda(NULL); /* go process it */ - if (adb_polling) - adb_soft_intr(NULL); - } - } - - return 0; -} - - -int -adb_intr_II(void *arg) -{ - struct adbCommand packet; - int i, intr_on = 0; - int send = 0; - unsigned int s; - - s = splhigh(); /* can't be too careful - might be called */ - /* from a routine, NOT an interrupt */ - - ADB_VIA_CLR_INTR(); /* clear interrupt */ - - ADB_VIA_INTR_DISABLE(); /* disable ADB interrupt on IIs. */ - - delay(ADB_DELAY); /* yuck (don't remove) */ - - (void)intr_dispatch(0x70); /* grab any serial interrupts */ - - if (ADB_INTR_IS_ON) - intr_on = 1; /* save for later */ - -switch_start: - switch (adbActionState) { - case ADB_ACTION_POLLING: - if (!intr_on) { - if (adbOutQueueHasData) { -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("POLL-doing-out-queue. "); -#endif - ADB_SET_STATE_IDLE_II(); - delay(ADB_DELAY); - - /* copy over data */ - memcpy(adbOutputBuffer, adbOutQueue.outBuf, - adbOutQueue.outBuf[0] + 2); - - adbBuffer = adbOutQueue.saveBuf; /* user data area */ - adbCompRout = adbOutQueue.compRout; /* completion routine */ - adbCompData = adbOutQueue.data; /* comp. rout. data */ - adbOutQueueHasData = 0; /* currently processing - * "queue" entry */ - adbSentChars = 0; /* nothing sent yet */ - adbActionState = ADB_ACTION_OUT; /* set next state */ - ADB_SET_SR_OUTPUT(); /* set shift register for OUT */ - ADB_SR() = adbOutputBuffer[1]; /* load byte for output */ - adbBusState = ADB_BUS_CMD; /* set bus to cmd state */ - ADB_SET_STATE_CMD(); /* tell ADB that we want to send */ - break; - } else { -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("pIDLE "); -#endif - adbActionState = ADB_ACTION_IDLE; - } - } else { -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("pIN "); -#endif - adbActionState = ADB_ACTION_IN; - } - delay(ADB_DELAY); - (void)intr_dispatch(0x70); /* grab any serial interrupts */ - goto switch_start; - break; - case ADB_ACTION_IDLE: - if (!intr_on) { - i = ADB_SR(); - adbBusState = ADB_BUS_IDLE; - adbActionState = ADB_ACTION_IDLE; - ADB_SET_STATE_IDLE_II(); - break; - } - adbInputBuffer[0] = 1; - adbInputBuffer[1] = ADB_SR(); /* get first byte */ -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("idle 0x%02x ", adbInputBuffer[1]); -#endif - ADB_SET_SR_INPUT(); /* make sure SR is set to IN */ - adbActionState = ADB_ACTION_IN; /* set next state */ - ADB_SET_STATE_EVEN(); /* set bus state to even */ - adbBusState = ADB_BUS_EVEN; - break; - - case ADB_ACTION_IN: - adbInputBuffer[++adbInputBuffer[0]] = ADB_SR(); /* get byte */ -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("in 0x%02x ", - adbInputBuffer[adbInputBuffer[0]]); -#endif - ADB_SET_SR_INPUT(); /* make sure SR is set to IN */ - - if (intr_on) { /* process last byte of packet */ - adbInputBuffer[0]--; /* minus one */ - /* - * If intr_on was true, and it's the second byte, then - * the byte we just discarded is really valid, so - * adjust the count - */ - if (adbInputBuffer[0] == 2) { - adbInputBuffer[0]++; - } - -#ifdef ADB_DEBUG - if (adb_debug & 0x80) { - printf_intr("done: "); - print_single(adbInputBuffer); - } -#endif - - adbLastDevice = ADB_CMDADDR(adbInputBuffer[1]); - - if (adbInputBuffer[0] == 1 && !adbWaiting) { /* SRQ!!!*/ -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr(" xSRQ! "); -#endif - adb_guess_next_device(); -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("try 0x%0x ", - adbLastDevice); -#endif - adbOutputBuffer[0] = 1; - adbOutputBuffer[1] = ADBTALK(adbLastDevice, 0); - - adbSentChars = 0; /* nothing sent yet */ - adbActionState = ADB_ACTION_POLLING; /* set next state */ - ADB_SET_SR_OUTPUT(); /* set shift register for OUT */ - ADB_SR() = adbOutputBuffer[1]; /* load byte for output */ - adbBusState = ADB_BUS_CMD; /* set bus to cmd state */ - ADB_SET_STATE_CMD(); /* tell ADB that we want to */ - break; - } - - /* set up data for adb_pass_up */ - memcpy(packet.data, adbInputBuffer, adbInputBuffer[0] + 1); - - if (!adbWaiting && (adbInputBuffer[0] != 0)) { - packet.unsol = 1; - packet.ack_only = 0; - adb_pass_up(&packet); - } else { - packet.saveBuf = adbBuffer; - packet.compRout = adbCompRout; - packet.compData = adbCompData; - packet.unsol = 0; - packet.ack_only = 0; - adb_pass_up(&packet); - } - - adbWaiting = 0; - adbInputBuffer[0] = 0; - adbBuffer = NULL; - adbCompRout = NULL; - adbCompData = NULL; - /* - * Since we are done, check whether there is any data - * waiting to do out. If so, start the sending the data. - */ - if (adbOutQueueHasData == 1) { -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("XXX: DOING OUT QUEUE\n"); -#endif - /* copy over data */ - memcpy(adbOutputBuffer, adbOutQueue.outBuf, - adbOutQueue.outBuf[0] + 2); - adbBuffer = adbOutQueue.saveBuf; /* user data area */ - adbCompRout = adbOutQueue.compRout; /* completion routine */ - adbCompData = adbOutQueue.data; /* comp. rout. data */ - adbOutQueueHasData = 0; /* currently processing - * "queue" entry */ - send = 1; - } else { -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("XXending "); -#endif - adb_guess_next_device(); - adbOutputBuffer[0] = 1; - adbOutputBuffer[1] = ((adbLastDevice & 0x0f) << 4) | 0x0c; - adbSentChars = 0; /* nothing sent yet */ - adbActionState = ADB_ACTION_POLLING; /* set next state */ - ADB_SET_SR_OUTPUT(); /* set shift register for OUT */ - ADB_SR() = adbOutputBuffer[1]; /* load byte for output */ - adbBusState = ADB_BUS_CMD; /* set bus to cmd state */ - ADB_SET_STATE_CMD(); /* tell ADB that we want to */ - break; - } - } - - /* - * If send is true then something above determined that - * the message has ended and we need to start sending out - * a new message immediately. This could be because there - * is data waiting to go out or because an SRQ was seen. - */ - if (send) { - adbSentChars = 0; /* nothing sent yet */ - adbActionState = ADB_ACTION_OUT; /* set next state */ - ADB_SET_SR_OUTPUT(); /* set shift register for OUT */ - ADB_SR() = adbOutputBuffer[1]; /* load byte for output */ - adbBusState = ADB_BUS_CMD; /* set bus to cmd state */ - ADB_SET_STATE_CMD(); /* tell ADB that we want to - * send */ - break; - } - /* We only get this far if the message hasn't ended yet. */ - switch (adbBusState) { /* set to next state */ - case ADB_BUS_EVEN: - ADB_SET_STATE_ODD(); /* set state to odd */ - adbBusState = ADB_BUS_ODD; - break; - - case ADB_BUS_ODD: - ADB_SET_STATE_EVEN(); /* set state to even */ - adbBusState = ADB_BUS_EVEN; - break; - default: - printf_intr("strange state!!!\n"); /* huh? */ - break; - } - break; - - case ADB_ACTION_OUT: - i = ADB_SR(); /* clear interrupt */ - adbSentChars++; - /* - * If the outgoing data was a TALK, we must - * switch to input mode to get the result. - */ - if ((adbOutputBuffer[1] & 0x0c) == 0x0c) { - adbInputBuffer[0] = 1; - adbInputBuffer[1] = i; - adbActionState = ADB_ACTION_IN; - ADB_SET_SR_INPUT(); - adbBusState = ADB_BUS_EVEN; - ADB_SET_STATE_EVEN(); -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("talk out 0x%02x ", i); -#endif - /* we want something back */ - adbWaiting = 1; - break; - } - /* - * If it's not a TALK, check whether all data has been sent. - * If so, call the completion routine and clean up. If not, - * advance to the next state. - */ -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("non-talk out 0x%0x ", i); -#endif - ADB_SET_SR_OUTPUT(); - if (adbOutputBuffer[0] == adbSentChars) { /* check for done */ -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("done \n"); -#endif - /* set up stuff for adb_pass_up */ - memcpy(packet.data, adbOutputBuffer, adbOutputBuffer[0] + 1); - packet.saveBuf = adbBuffer; - packet.compRout = adbCompRout; - packet.compData = adbCompData; - packet.cmd = adbWaitingCmd; - packet.unsol = 0; - packet.ack_only = 1; - adb_pass_up(&packet); - - /* reset "waiting" vars, just in case */ - adbBuffer = NULL; - adbCompRout = NULL; - adbCompData = NULL; - if (adbOutQueueHasData == 1) { - /* copy over data */ - memcpy(adbOutputBuffer, adbOutQueue.outBuf, - adbOutQueue.outBuf[0] + 2); - adbBuffer = adbOutQueue.saveBuf; /* user data area */ - adbCompRout = adbOutQueue.compRout; /* completion routine */ - adbCompData = adbOutQueue.data; /* comp. rout. data */ - adbOutQueueHasData = 0; /* currently processing - * "queue" entry */ - adbSentChars = 0; /* nothing sent yet */ - adbActionState = ADB_ACTION_OUT; /* set next state */ - ADB_SET_SR_OUTPUT(); /* set shift register for OUT */ - ADB_SR() = adbOutputBuffer[1]; /* load byte for output */ - adbBusState = ADB_BUS_CMD; /* set bus to cmd state */ - ADB_SET_STATE_CMD(); /* tell ADB that we want to - * send */ - break; - } else { - /* send talk to last device instead */ - adbOutputBuffer[0] = 1; - adbOutputBuffer[1] = - ADBTALK(ADB_CMDADDR(adbOutputBuffer[1]), 0); - - adbSentChars = 0; /* nothing sent yet */ - adbActionState = ADB_ACTION_IDLE; /* set next state */ - ADB_SET_SR_OUTPUT(); /* set shift register for OUT */ - ADB_SR() = adbOutputBuffer[1]; /* load byte for output */ - adbBusState = ADB_BUS_CMD; /* set bus to cmd state */ - ADB_SET_STATE_CMD(); /* tell ADB that we want to */ - break; - } - } - ADB_SR() = adbOutputBuffer[adbSentChars + 1]; - switch (adbBusState) { /* advance to next state */ - case ADB_BUS_EVEN: - ADB_SET_STATE_ODD(); /* set state to odd */ - adbBusState = ADB_BUS_ODD; - break; - - case ADB_BUS_CMD: - case ADB_BUS_ODD: - ADB_SET_STATE_EVEN(); /* set state to even */ - adbBusState = ADB_BUS_EVEN; - break; - - default: -#ifdef ADB_DEBUG - if (adb_debug) { - printf_intr("strange state!!! (0x%x)\n", - adbBusState); - } -#endif - break; - } - break; - - default: -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("adb: unknown ADB state (during intr)\n"); -#endif - break; - } - - ADB_VIA_INTR_ENABLE(); /* enable ADB interrupt on IIs. */ - - splx(s); /* restore */ - - return (1); - -} - - -/* - * send_adb version for II series machines - */ -int -send_adb_II(u_char *in, u_char *buffer, void *compRout, void *data, int command) -{ - int s, len; - - if (adbActionState == ADB_ACTION_NOTREADY) /* return if ADB not - * available */ - return 1; - - /* Don't interrupt while we are messing with the ADB */ - s = splhigh(); - - if (0 != adbOutQueueHasData) { /* right now, "has data" means "full" */ - splx(s); /* sorry, try again later */ - return 1; - } - if ((long)in == (long)0) { /* need to convert? */ - /* - * Don't need to use adb_cmd_extra here because this section - * will be called ONLY when it is an ADB command (no RTC or - * PRAM), especially on II series! - */ - if ((command & 0x0c) == 0x08) /* copy addl data ONLY if - * doing a listen! */ - len = buffer[0]; /* length of additional data */ - else - len = 0;/* no additional data */ - - adbOutQueue.outBuf[0] = 1 + len; /* command + addl. data */ - adbOutQueue.outBuf[1] = (u_char)command; /* load command */ - - /* copy additional output data, if any */ - memcpy(adbOutQueue.outBuf + 2, buffer + 1, len); - } else - /* if data ready, just copy over */ - memcpy(adbOutQueue.outBuf, in, in[0] + 2); - - adbOutQueue.saveBuf = buffer; /* save buffer to know where to save - * result */ - adbOutQueue.compRout = compRout; /* save completion routine - * pointer */ - adbOutQueue.data = data;/* save completion routine data pointer */ - - if ((adbActionState == ADB_ACTION_IDLE) && /* is ADB available? */ - (ADB_INTR_IS_OFF)) { /* and no incoming interrupts? */ - /* then start command now */ - memcpy(adbOutputBuffer, adbOutQueue.outBuf, - adbOutQueue.outBuf[0] + 2); /* copy over data */ - - adbBuffer = adbOutQueue.saveBuf; /* pointer to user data - * area */ - adbCompRout = adbOutQueue.compRout; /* pointer to the - * completion routine */ - adbCompData = adbOutQueue.data; /* pointer to the completion - * routine data */ - - adbSentChars = 0; /* nothing sent yet */ - adbActionState = ADB_ACTION_OUT; /* set next state */ - adbBusState = ADB_BUS_CMD; /* set bus to cmd state */ - - ADB_SET_SR_OUTPUT(); /* set shift register for OUT */ - - ADB_SR() = adbOutputBuffer[adbSentChars + 1]; /* load byte for output */ - ADB_SET_STATE_CMD(); /* tell ADB that we want to send */ - adbOutQueueHasData = 0; /* currently processing "queue" entry */ - } else - adbOutQueueHasData = 1; /* something in the write "queue" */ - - splx(s); - - /* were VIA1 interrupts blocked? */ - if (PSLTOIPL(s) >= mac68k_machine.via1_ipl) { - /* poll until message done */ - while ((adbActionState != ADB_ACTION_IDLE) || (ADB_INTR_IS_ON) - || (adbWaiting == 1)) - if (ADB_SR_INTR_IS_ON) { /* wait for "interrupt" */ - adb_intr_II(NULL); /* go process it */ - if (adb_polling) - adb_soft_intr(NULL); - } - } - - return 0; -} - - -/* - * This routine is called from the II series interrupt routine - * to determine what the "next" device is that should be polled. - */ -int -adb_guess_next_device(void) -{ - int last, i, dummy; - - if (adbStarting) { - /* - * Start polling EVERY device, since we can't be sure there is - * anything in the device table yet - */ - if (adbLastDevice < 1 || adbLastDevice > 15) - adbLastDevice = 1; - if (++adbLastDevice > 15) /* point to next one */ - adbLastDevice = 1; - } else { - /* find the next device using the device table */ - if (adbLastDevice < 1 || adbLastDevice > 15) /* let's be parinoid */ - adbLastDevice = 2; - last = 1; /* default index location */ - - for (i = 1; i < 16; i++) /* find index entry */ - if (ADBDevTable[i].currentAddr == adbLastDevice) { /* look for device */ - last = i; /* found it */ - break; - } - dummy = last; /* index to start at */ - for (;;) { /* find next device in index */ - if (++dummy > 15) /* wrap around if needed */ - dummy = 1; - if (dummy == last) { /* didn't find any other - * device! This can happen if - * there are no devices on the - * bus */ - dummy = 1; - break; - } - /* found the next device */ - if (ADBDevTable[dummy].devType != 0) - break; - } - adbLastDevice = ADBDevTable[dummy].currentAddr; - } - return adbLastDevice; -} - -#include "akbd.h" -#if NAKBD > 0 -/* - * Called when when an adb interrupt happens. - * This routine simply transfers control over to the appropriate - * code for the machine we are running on. - */ -int -adb_intr(void *arg) -{ - switch (adbHardware) { - case ADB_HW_II: - return adb_intr_II(arg); - case ADB_HW_IISI: - return adb_intr_IIsi(arg); - case ADB_HW_CUDA: - return adb_intr_cuda(arg); - default: - return (-1); - } -} -#endif - -/* - * called when when an adb interrupt happens - * - * IIsi version of adb_intr - * - */ -int -adb_intr_IIsi(void *arg) -{ - struct adbCommand packet; - int i, ending; - unsigned int s; - - s = splhigh(); /* can't be too careful - might be called */ - /* from a routine, NOT an interrupt */ - - ADB_VIA_CLR_INTR(); /* clear interrupt */ - - ADB_VIA_INTR_DISABLE(); /* disable ADB interrupt on IIs. */ - -switch_start: - switch (adbActionState) { - case ADB_ACTION_IDLE: - delay(ADB_DELAY); /* short delay is required before the - * first byte */ - - ADB_SET_SR_INPUT(); /* make sure SR is set to IN */ - ADB_SET_STATE_ACTIVE(); /* signal start of data frame */ - adbInputBuffer[1] = ADB_SR(); /* get byte */ - adbInputBuffer[0] = 1; - adbActionState = ADB_ACTION_IN; /* set next state */ - - ADB_SET_STATE_ACKON(); /* start ACK to ADB chip */ - delay(ADB_DELAY); /* delay */ - ADB_SET_STATE_ACKOFF(); /* end ACK to ADB chip */ - (void)intr_dispatch(0x70); /* grab any serial interrupts */ - break; - - case ADB_ACTION_IN: - ADB_SET_SR_INPUT(); /* make sure SR is set to IN */ - adbInputBuffer[++adbInputBuffer[0]] = ADB_SR(); /* get byte */ - if (ADB_INTR_IS_OFF) /* check for end of frame */ - ending = 1; - else - ending = 0; - - ADB_SET_STATE_ACKON(); /* start ACK to ADB chip */ - delay(ADB_DELAY); /* delay */ - ADB_SET_STATE_ACKOFF(); /* end ACK to ADB chip */ - (void)intr_dispatch(0x70); /* grab any serial interrupts */ - - if (1 == ending) { /* end of message? */ - ADB_SET_STATE_INACTIVE(); /* signal end of frame */ - /* - * This section _should_ handle all ADB and RTC/PRAM - * type commands, but there may be more... Note: - * commands are always at [4], even for rtc/pram - * commands - */ - /* set up data for adb_pass_up */ - memcpy(packet.data, adbInputBuffer, adbInputBuffer[0] + 1); - - if ((adbWaiting == 1) && /* are we waiting AND */ - (adbInputBuffer[4] == adbWaitingCmd) && /* the cmd we sent AND */ - ((adbInputBuffer[2] == 0x00) || /* it's from the ADB - * device OR */ - (adbInputBuffer[2] == 0x01))) { /* it's from the - * PRAM/RTC device */ - - packet.saveBuf = adbBuffer; - packet.compRout = adbCompRout; - packet.compData = adbCompData; - packet.unsol = 0; - packet.ack_only = 0; - adb_pass_up(&packet); - - adbWaitingCmd = 0; /* reset "waiting" vars */ - adbWaiting = 0; - adbBuffer = NULL; - adbCompRout = NULL; - adbCompData = NULL; - } else { - packet.unsol = 1; - packet.ack_only = 0; - adb_pass_up(&packet); - } - - adbActionState = ADB_ACTION_IDLE; - adbInputBuffer[0] = 0; /* reset length */ - - if (adbWriteDelay == 1) { /* were we waiting to - * write? */ - adbSentChars = 0; /* nothing sent yet */ - adbActionState = ADB_ACTION_OUT; /* set next state */ - - delay(ADB_DELAY); /* delay */ - (void)intr_dispatch(0x70); /* grab any serial interrupts */ - - if (ADB_INTR_IS_ON) { /* ADB intr low during - * write */ - ADB_SET_STATE_IDLE_IISI(); /* reset */ - ADB_SET_SR_INPUT(); /* make sure SR is set - * to IN */ - adbSentChars = 0; /* must start all over */ - adbActionState = ADB_ACTION_IDLE; /* new state */ - adbInputBuffer[0] = 0; - /* may be able to take this out later */ - delay(ADB_DELAY); /* delay */ - break; - } - ADB_SET_STATE_ACTIVE(); /* tell ADB that we want - * to send */ - ADB_SET_STATE_ACKOFF(); /* make sure */ - ADB_SET_SR_OUTPUT(); /* set shift register - * for OUT */ - ADB_SR() = adbOutputBuffer[adbSentChars + 1]; - ADB_SET_STATE_ACKON(); /* tell ADB byte ready - * to shift */ - } - } - break; - - case ADB_ACTION_OUT: - i = ADB_SR(); /* reset SR-intr in IFR */ - ADB_SET_SR_OUTPUT(); /* set shift register for OUT */ - - ADB_SET_STATE_ACKOFF(); /* finish ACK */ - adbSentChars++; - if (ADB_INTR_IS_ON) { /* ADB intr low during write */ - ADB_SET_STATE_IDLE_IISI(); /* reset */ - ADB_SET_SR_INPUT(); /* make sure SR is set to IN */ - adbSentChars = 0; /* must start all over */ - adbActionState = ADB_ACTION_IDLE; /* new state */ - adbInputBuffer[0] = 0; - adbWriteDelay = 1; /* must retry when done with - * read */ - delay(ADB_DELAY); /* delay */ - (void)intr_dispatch(0x70); /* grab any serial interrupts */ - goto switch_start; /* process next state right - * now */ - break; - } - delay(ADB_DELAY); /* required delay */ - (void)intr_dispatch(0x70); /* grab any serial interrupts */ - - if (adbOutputBuffer[0] == adbSentChars) { /* check for done */ - if (0 == adb_cmd_result(adbOutputBuffer)) { /* do we expect data - * back? */ - adbWaiting = 1; /* signal waiting for return */ - adbWaitingCmd = adbOutputBuffer[2]; /* save waiting command */ - } else {/* no talk, so done */ - /* set up stuff for adb_pass_up */ - memcpy(packet.data, adbInputBuffer, - adbInputBuffer[0] + 1); - packet.saveBuf = adbBuffer; - packet.compRout = adbCompRout; - packet.compData = adbCompData; - packet.cmd = adbWaitingCmd; - packet.unsol = 0; - packet.ack_only = 1; - adb_pass_up(&packet); - - /* reset "waiting" vars, just in case */ - adbWaitingCmd = 0; - adbBuffer = NULL; - adbCompRout = NULL; - adbCompData = NULL; - } - - adbWriteDelay = 0; /* done writing */ - adbActionState = ADB_ACTION_IDLE; /* signal bus is idle */ - ADB_SET_SR_INPUT(); /* make sure SR is set to IN */ - ADB_SET_STATE_INACTIVE(); /* end of frame */ - } else { - ADB_SR() = adbOutputBuffer[adbSentChars + 1]; /* send next byte */ - ADB_SET_STATE_ACKON(); /* signal byte ready to shift */ - } - break; - - case ADB_ACTION_NOTREADY: -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("adb: not yet initialized\n"); -#endif - break; - - default: -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("intr: unknown ADB state\n"); -#endif - break; - } - - ADB_VIA_INTR_ENABLE(); /* enable ADB interrupt on IIs. */ - - splx(s); /* restore */ - - return (1); -} - - -/***************************************************************************** - * if the device is currently busy, and there is no data waiting to go out, then - * the data is "queued" in the outgoing buffer. If we are already waiting, then - * we return. - * in: if (in == 0) then the command string is built from command and buffer - * if (in != 0) then in is used as the command string - * buffer: additional data to be sent (used only if in == 0) - * this is also where return data is stored - * compRout: the completion routine that is called when then return value - * is received (if a return value is expected) - * data: a data pointer that can be used by the completion routine - * command: an ADB command to be sent (used only if in == 0) - * - */ -int -send_adb_IIsi(u_char *in, u_char *buffer, void *compRout, void *data, int - command) -{ - int s, len; - - if (adbActionState == ADB_ACTION_NOTREADY) - return 1; - - /* Don't interrupt while we are messing with the ADB */ - s = splhigh(); - - if ((adbActionState == ADB_ACTION_IDLE) && /* ADB available? */ - (ADB_INTR_IS_OFF)) {/* and no incoming interrupt? */ - - } else - if (adbWriteDelay == 0) /* it's busy, but is anything waiting? */ - adbWriteDelay = 1; /* if no, then we'll "queue" - * it up */ - else { - splx(s); - return 1; /* really busy! */ - } - - if ((long)in == (long)0) { /* need to convert? */ - /* - * Don't need to use adb_cmd_extra here because this section - * will be called ONLY when it is an ADB command (no RTC or - * PRAM) - */ - if ((command & 0x0c) == 0x08) /* copy addl data ONLY if - * doing a listen! */ - len = buffer[0]; /* length of additional data */ - else - len = 0;/* no additional data */ - - adbOutputBuffer[0] = 2 + len; /* dev. type + command + addl. - * data */ - adbOutputBuffer[1] = 0x00; /* mark as an ADB command */ - adbOutputBuffer[2] = (u_char)command; /* load command */ - - /* copy additional output data, if any */ - memcpy(adbOutputBuffer + 3, buffer + 1, len); - } else - /* if data ready, just copy over */ - memcpy(adbOutputBuffer, in, in[0] + 2); - - adbSentChars = 0; /* nothing sent yet */ - adbBuffer = buffer; /* save buffer to know where to save result */ - adbCompRout = compRout; /* save completion routine pointer */ - adbCompData = data; /* save completion routine data pointer */ - adbWaitingCmd = adbOutputBuffer[2]; /* save wait command */ - - if (adbWriteDelay != 1) { /* start command now? */ - adbActionState = ADB_ACTION_OUT; /* set next state */ - - ADB_SET_STATE_ACTIVE(); /* tell ADB that we want to send */ - ADB_SET_STATE_ACKOFF(); /* make sure */ - - ADB_SET_SR_OUTPUT(); /* set shift register for OUT */ - - ADB_SR() = adbOutputBuffer[adbSentChars + 1]; /* load byte for output */ - - ADB_SET_STATE_ACKON(); /* tell ADB byte ready to shift */ - } - adbWriteDelay = 1; /* something in the write "queue" */ - - splx(s); - - /* were VIA1 interrupts blocked? */ - if (PSLTOIPL(s) >= mac68k_machine.via1_ipl) { - /* poll until byte done */ - while ((adbActionState != ADB_ACTION_IDLE) || (ADB_INTR_IS_ON) - || (adbWaiting == 1)) - if (ADB_SR_INTR_IS_ON) { /* wait for "interrupt" */ - adb_intr_IIsi(NULL); /* go process it */ - if (adb_polling) - adb_soft_intr(NULL); - } - } - - return 0; -} - -/* - * adb_pass_up is called by the interrupt-time routines. - * It takes the raw packet data that was received from the - * device and puts it into the queue that the upper half - * processes. It then signals for a soft ADB interrupt which - * will eventually call the upper half routine (adb_soft_intr). - * - * If in->unsol is 0, then this is either the notification - * that the packet was sent (on a LISTEN, for example), or the - * response from the device (on a TALK). The completion routine - * is called only if the user specified one. - * - * If in->unsol is 1, then this packet was unsolicited and - * so we look up the device in the ADB device table to determine - * what its default service routine is. - * - * If in->ack_only is 1, then we really only need to call - * the completion routine, so don't do any other stuff. - * - * Note that in->data contains the packet header AND data, - * while adbInbound[]->data contains ONLY data. - * - * Note: Called only at interrupt time. Assumes this. - */ -void -adb_pass_up(struct adbCommand *in) -{ - extern struct cfdriver adb_cd; - struct adb_softc *sc; - int start = 0, len = 0, cmd = 0; - ADBDataBlock block; - - if (adbInCount >= ADB_QUEUE) { -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("adb: ring buffer overflow\n"); -#endif - return; - } - - if (in->ack_only) { - len = in->data[0]; - cmd = in->cmd; - start = 0; - } else { - switch (adbHardware) { - case ADB_HW_IOP: - case ADB_HW_II: - cmd = in->data[1]; - if (in->data[0] < 2) - len = 0; - else - len = in->data[0]-1; - start = 1; - break; - - case ADB_HW_IISI: - case ADB_HW_CUDA: - /* If it's unsolicited, accept only ADB data for now */ - if (in->unsol) - if (0 != in->data[2]) - return; - cmd = in->data[4]; - if (in->data[0] < 5) - len = 0; - else - len = in->data[0]-4; - start = 4; - break; - - case ADB_HW_PB: - cmd = in->data[1]; - if (in->data[0] < 2) - len = 0; - else - len = in->data[0]-1; - start = 1; - break; - - case ADB_HW_UNKNOWN: - return; - } - - /* Make sure there is a valid device entry for this device */ - if (in->unsol) { - /* ignore unsolicited data during adbreinit */ - if (adbStarting) - return; - /* get device's comp. routine and data area */ - if (-1 == get_adb_info(&block, ADB_CMDADDR(cmd))) - return; - } - } - - /* - * If this is an unsolicited packet, we need to fill in - * some info so adb_soft_intr can process this packet - * properly. If it's not unsolicited, then use what - * the caller sent us. - */ - if (in->unsol) { - adbInbound[adbInTail].compRout = (void *)block.dbServiceRtPtr; - adbInbound[adbInTail].compData = (void *)block.dbDataAreaAddr; - adbInbound[adbInTail].saveBuf = (void *)adbInbound[adbInTail].data; - } else { - adbInbound[adbInTail].compRout = (void *)in->compRout; - adbInbound[adbInTail].compData = (void *)in->compData; - adbInbound[adbInTail].saveBuf = (void *)in->saveBuf; - } - -#ifdef ADB_DEBUG - if (adb_debug && in->data[1] == 2) - printf_intr("adb: caught error\n"); -#endif - - /* copy the packet data over */ - /* - * TO DO: If the *_intr routines fed their incoming data - * directly into an adbCommand struct, which is passed to - * this routine, then we could eliminate this copy. - */ - memcpy(adbInbound[adbInTail].data + 1, in->data + start + 1, len); - adbInbound[adbInTail].data[0] = len; - adbInbound[adbInTail].cmd = cmd; - - adbInCount++; - if (++adbInTail >= ADB_QUEUE) - adbInTail = 0; - - /* - * If the debugger is running, call upper half manually. - * Otherwise, trigger a soft interrupt to handle the rest later. - */ - if (adb_cd.cd_ndevs != 0) - sc = (struct adb_softc *)adb_cd.cd_devs[0]; - else - sc = NULL; - if (adb_polling || sc == NULL || sc->sc_softih == NULL) - adb_soft_intr(NULL); - else - softintr_schedule(sc->sc_softih); -} - - -/* - * Called to process the packets after they have been - * placed in the incoming queue. - * - */ -void -adb_soft_intr(void *arg) -{ - int s; - int cmd = 0; - u_char *buffer; - void *comprout; - u_char *compdata; - -/*delay(2*ADB_DELAY);*/ - - while (adbInCount) { -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("%x %x %x ", - adbInCount, adbInHead, adbInTail); -#endif - /* get the data we need from the queue */ - buffer = adbInbound[adbInHead].saveBuf; - comprout = adbInbound[adbInHead].compRout; - compdata = adbInbound[adbInHead].compData; - cmd = adbInbound[adbInHead].cmd; - - /* copy over data to data area if it's valid */ - /* - * Note that for unsol packets we don't want to copy the - * data anywhere, so buffer was already set to 0. - * For ack_only buffer was set to 0, so don't copy. - */ - if (buffer) - memcpy(buffer, adbInbound[adbInHead].data, - adbInbound[adbInHead].data[0] + 1); - -#ifdef ADB_DEBUG - if (adb_debug & 0x80) { - printf_intr("%p %p %p %x ", - buffer, comprout, compdata, (short)cmd); - printf_intr("buf: "); - print_single(adbInbound[adbInHead].data); - } -#endif - - /* - * Remove the packet from the queue before calling - * the completion routine, so that the completion - * routine can reentrantly process the queue. For - * example, this happens when polling is turned on - * by entering the debugger by keystroke. - */ - s = splhigh(); - adbInCount--; - if (++adbInHead >= ADB_QUEUE) - adbInHead = 0; - splx(s); - - /* call default completion routine if it's valid */ - if (comprout) { - (void)((int (*)(u_char *, u_char *, int))comprout) - (buffer, compdata, cmd); - } - } -} - - -/* - * This is my version of the ADBOp routine. It mainly just calls the - * hardware-specific routine. - * - * data : pointer to data area to be used by compRout - * compRout : completion routine - * buffer : for LISTEN: points to data to send - MAX 8 data bytes, - * byte 0 = # of bytes - * : for TALK: points to place to save return data - * command : the adb command to send - * result : 0 = success - * : -1 = could not complete - */ -int -adb_op(Ptr buffer, Ptr compRout, Ptr data, short command) -{ - int result; - - switch (adbHardware) { - case ADB_HW_II: - result = send_adb_II((u_char *)0, (u_char *)buffer, - (void *)compRout, (void *)data, (int)command); - if (result == 0) - return 0; - else - return -1; - break; - - case ADB_HW_IISI: - result = send_adb_IIsi((u_char *)0, (u_char *)buffer, - (void *)compRout, (void *)data, (int)command); - /* - * I wish I knew why this delay is needed. It usually needs to - * be here when several commands are sent in close succession, - * especially early in device probes when doing collision - * detection. It must be some race condition. Sigh. - jpw - */ - delay(100); - if (result == 0) - return 0; - else - return -1; - break; - - case ADB_HW_PB: - result = pm_adb_op((u_char *)buffer, (void *)compRout, - (void *)data, (int)command); - - if (result == 0) - return 0; - else - return -1; - break; - - case ADB_HW_CUDA: - result = send_adb_cuda((u_char *)0, (u_char *)buffer, - (void *)compRout, (void *)data, (int)command); - if (result == 0) - return 0; - else - return -1; - break; - - case ADB_HW_IOP: - case ADB_HW_UNKNOWN: - default: - return -1; - } -} - - -/* - * adb_hw_setup - * This routine sets up the possible machine specific hardware - * config (mainly VIA settings) for the various models. - */ -void -adb_hw_setup(struct adb_softc *sc) -{ - volatile int i; - u_char send_string[ADB_MAX_MSG_LENGTH]; - - switch (adbHardware) { - case ADB_HW_II: - via1_register_irq(2, adb_intr_II, sc, sc->sc_dev.dv_xname); - - via_reg(VIA1, vDirB) |= 0x30; /* register B bits 4 and 5: - * outputs */ - via_reg(VIA1, vDirB) &= 0xf7; /* register B bit 3: input */ - via_reg(VIA1, vACR) &= ~vSR_OUT; /* make sure SR is set - * to IN (II, IIsi) */ - adbActionState = ADB_ACTION_IDLE; /* used by all types of - * hardware (II, IIsi) */ - adbBusState = ADB_BUS_IDLE; /* this var. used in II-series - * code only */ - via_reg(VIA1, vIER) = 0x84; /* make sure VIA interrupts - * are on (II, IIsi) */ - ADB_SET_STATE_IDLE_II(); /* set ADB bus state to idle */ - - ADB_VIA_CLR_INTR(); /* clear interrupt */ - break; - - case ADB_HW_IISI: - via1_register_irq(2, adb_intr_IIsi, sc, sc->sc_dev.dv_xname); - via_reg(VIA1, vDirB) |= 0x30; /* register B bits 4 and 5: - * outputs */ - via_reg(VIA1, vDirB) &= 0xf7; /* register B bit 3: input */ - via_reg(VIA1, vACR) &= ~vSR_OUT; /* make sure SR is set - * to IN (II, IIsi) */ - adbActionState = ADB_ACTION_IDLE; /* used by all types of - * hardware (II, IIsi) */ - adbBusState = ADB_BUS_IDLE; /* this var. used in II-series - * code only */ - via_reg(VIA1, vIER) = 0x84; /* make sure VIA interrupts - * are on (II, IIsi) */ - ADB_SET_STATE_IDLE_IISI(); /* set ADB bus state to idle */ - - /* get those pesky clock ticks we missed while booting */ - for (i = 0; i < 30; i++) { - delay(ADB_DELAY); - adb_hw_setup_IIsi(send_string); -#ifdef ADB_DEBUG - if (adb_debug) { - printf_intr("adb: cleanup: "); - print_single(send_string); - } -#endif - delay(ADB_DELAY); - if (ADB_INTR_IS_OFF) - break; - } - break; - - case ADB_HW_PB: - /* - * XXX - really PM_VIA_CLR_INTR - should we put it in - * pm_direct.h? - */ - pm_hw_setup(&sc->sc_dev); - break; - - case ADB_HW_CUDA: - via1_register_irq(2, adb_intr_cuda, sc, sc->sc_dev.dv_xname); - via_reg(VIA1, vDirB) |= 0x30; /* register B bits 4 and 5: - * outputs */ - via_reg(VIA1, vDirB) &= 0xf7; /* register B bit 3: input */ - via_reg(VIA1, vACR) &= ~vSR_OUT; /* make sure SR is set - * to IN */ - via_reg(VIA1, vACR) = (via_reg(VIA1, vACR) | 0x0c) & ~0x10; - adbActionState = ADB_ACTION_IDLE; /* used by all types of - * hardware */ - adbBusState = ADB_BUS_IDLE; /* this var. used in II-series - * code only */ - via_reg(VIA1, vIER) = 0x84; /* make sure VIA interrupts - * are on */ - ADB_SET_STATE_IDLE_CUDA(); /* set ADB bus state to idle */ - - /* sort of a device reset */ - i = ADB_SR(); /* clear interrupt */ - ADB_VIA_INTR_DISABLE(); /* no interrupts while clearing */ - ADB_SET_STATE_IDLE_CUDA(); /* reset state to idle */ - delay(ADB_DELAY); - ADB_SET_STATE_TIP(); /* signal start of frame */ - delay(ADB_DELAY); - ADB_TOGGLE_STATE_ACK_CUDA(); - delay(ADB_DELAY); - ADB_CLR_STATE_TIP(); - delay(ADB_DELAY); - ADB_SET_STATE_IDLE_CUDA(); /* back to idle state */ - i = ADB_SR(); /* clear interrupt */ - ADB_VIA_INTR_ENABLE(); /* ints ok now */ - break; - - case ADB_HW_IOP: - case ADB_HW_UNKNOWN: - default: - via_reg(VIA1, vIER) = 0x04; /* turn interrupts off - TO - * DO: turn PB ints off? */ - break; - } -} - - -/* - * adb_hw_setup_IIsi - * This is sort of a "read" routine that forces the adb hardware through a read cycle - * if there is something waiting. This helps "clean up" any commands that may have gotten - * stuck or stopped during the boot process. - * - */ -void -adb_hw_setup_IIsi(u_char *buffer) -{ - int i; - int dummy; - int s; - long my_time; - int endofframe; - - delay(ADB_DELAY); - - i = 1; /* skip over [0] */ - s = splhigh(); /* block ALL interrupts while we are working */ - ADB_SET_SR_INPUT(); /* make sure SR is set to IN */ - ADB_VIA_INTR_DISABLE(); /* disable ADB interrupt on IIs. */ - /* this is required, especially on faster machines */ - delay(ADB_DELAY); - - if (ADB_INTR_IS_ON) { - ADB_SET_STATE_ACTIVE(); /* signal start of data frame */ - - endofframe = 0; - while (0 == endofframe) { - /* - * Poll for ADB interrupt and watch for timeout. - * If time out, keep going in hopes of not hanging - * the ADB chip - I think - */ - my_time = ADB_DELAY * 5; - while ((ADB_SR_INTR_IS_OFF) && (my_time-- > 0)) - dummy = via_reg(VIA1, vBufB); - - buffer[i++] = ADB_SR(); /* reset interrupt flag by - * reading vSR */ - /* - * Perhaps put in a check here that ignores all data - * after the first ADB_MAX_MSG_LENGTH bytes ??? - */ - if (ADB_INTR_IS_OFF) /* check for end of frame */ - endofframe = 1; - - ADB_SET_STATE_ACKON(); /* send ACK to ADB chip */ - delay(ADB_DELAY); /* delay */ - ADB_SET_STATE_ACKOFF(); /* send ACK to ADB chip */ - } - ADB_SET_STATE_INACTIVE(); /* signal end of frame and - * delay */ - - /* probably don't need to delay this long */ - delay(ADB_DELAY); - } - buffer[0] = --i; /* [0] is length of message */ - ADB_VIA_INTR_ENABLE(); /* enable ADB interrupt on IIs. */ - splx(s); /* restore interrupts */ -} - - - -/* - * adb_reinit sets up the adb stuff - * - */ -void -adb_reinit(struct adb_softc *sc) -{ - u_char send_string[ADB_MAX_MSG_LENGTH]; - ADBDataBlock data; /* temp. holder for getting device info */ - volatile int i, x; - int s; - int command; - int result; - int saveptr; /* point to next free relocation address */ - int device; - int nonewtimes; /* times thru loop w/o any new devices */ - - /* Make sure we are not interrupted while building the table. */ - /* ints must be on for PB & IOP (at least, for now) */ - if (adbHardware != ADB_HW_PB && adbHardware != ADB_HW_IOP) - s = splhigh(); - else - s = 0; /* XXX shut the compiler up*/ - - ADBNumDevices = 0; /* no devices yet */ - - /* Let intr routines know we are running reinit */ - adbStarting = 1; - - /* - * Initialize the ADB table. For now, we'll always use the same table - * that is defined at the beginning of this file - no mallocs. - */ - for (i = 0; i < 16; i++) { - ADBDevTable[i].devType = 0; - ADBDevTable[i].origAddr = ADBDevTable[i].currentAddr = 0; - } - - adb_hw_setup(sc); /* init the VIA bits and hard reset ADB */ - - delay(1000); - - /* send an ADB reset first */ - (void)adb_op_sync((Ptr)0, (short)0x00); - delay(3000); - - /* - * Probe for ADB devices. Probe devices 1-15 quickly to determine - * which device addresses are in use and which are free. For each - * address that is in use, move the device at that address to a higher - * free address. Continue doing this at that address until no device - * responds at that address. Then move the last device that was moved - * back to the original address. Do this for the remaining addresses - * that we determined were in use. - * - * When finished, do this entire process over again with the updated - * list of in use addresses. Do this until no new devices have been - * found in 20 passes though the in use address list. (This probably - * seems long and complicated, but it's the best way to detect multiple - * devices at the same address - sometimes it takes a couple of tries - * before the collision is detected.) - */ - - /* initial scan through the devices */ - for (i = 1; i < 16; i++) { - command = ADBTALK(i, 3); - result = adb_op_sync((Ptr)send_string, (short)command); - - if (result == 0 && send_string[0] != 0) { - /* found a device */ - ++ADBNumDevices; - KASSERT(ADBNumDevices < 16); - ADBDevTable[ADBNumDevices].devType = - (int)(send_string[2]); - ADBDevTable[ADBNumDevices].origAddr = i; - ADBDevTable[ADBNumDevices].currentAddr = i; - ADBDevTable[ADBNumDevices].DataAreaAddr = NULL; - ADBDevTable[ADBNumDevices].ServiceRtPtr = NULL; - pm_check_adb_devices(i); /* tell pm driver device - * is here */ - } - } - - /* find highest unused address */ - for (saveptr = 15; saveptr > 0; saveptr--) - if (-1 == get_adb_info(&data, saveptr)) - break; - -#ifdef ADB_DEBUG - if (adb_debug & 0x80) { - printf_intr("first free is: 0x%02x\n", saveptr); - printf_intr("devices: %i\n", ADBNumDevices); - } -#endif - - nonewtimes = 0; /* no loops w/o new devices */ - while (saveptr > 0 && nonewtimes++ < 11) { - for (i = 1;saveptr > 0 && i <= ADBNumDevices; i++) { - device = ADBDevTable[i].currentAddr; -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("moving device 0x%02x to 0x%02x " - "(index 0x%02x) ", device, saveptr, i); -#endif - - /* send TALK R3 to address */ - command = ADBTALK(device, 3); - (void)adb_op_sync((Ptr)send_string, (short)command); - - /* move device to higher address */ - command = ADBLISTEN(device, 3); - send_string[0] = 2; - send_string[1] = (u_char)(saveptr | 0x60); - send_string[2] = 0xfe; - (void)adb_op_sync((Ptr)send_string, (short)command); - delay(1000); - - /* send TALK R3 - anthing at new address? */ - command = ADBTALK(saveptr, 3); - send_string[0] = 0; - result = adb_op_sync((Ptr)send_string, (short)command); - delay(1000); - - if (result != 0 || send_string[0] == 0) { - /* - * maybe there's a communication breakdown; - * just in case, move it back from whence it - * came, and we'll try again later - */ - command = ADBLISTEN(saveptr, 3); - send_string[0] = 2; - send_string[1] = (u_char)(device | 0x60); - send_string[2] = 0x00; - (void)adb_op_sync((Ptr)send_string, - (short)command); -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("failed, continuing\n"); -#endif - delay(1000); - continue; - } - - /* send TALK R3 - anything at old address? */ - command = ADBTALK(device, 3); - send_string[0] = 0; - result = adb_op_sync((Ptr)send_string, (short)command); - if (result == 0 && send_string[0] != 0) { - /* new device found */ - /* update data for previously moved device */ - ADBDevTable[i].currentAddr = saveptr; -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("old device at index %i\n",i); -#endif - /* add new device in table */ -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("new device found\n"); -#endif - if (saveptr > ADBNumDevices) { - ++ADBNumDevices; - KASSERT(ADBNumDevices < 16); - } - ADBDevTable[ADBNumDevices].devType = - (int)(send_string[2]); - ADBDevTable[ADBNumDevices].origAddr = device; - ADBDevTable[ADBNumDevices].currentAddr = device; - /* These will be set correctly in adbsys.c */ - /* Until then, unsol. data will be ignored. */ - ADBDevTable[ADBNumDevices].DataAreaAddr = - (long)0; - ADBDevTable[ADBNumDevices].ServiceRtPtr = - (void *)0; - /* find next unused address */ - for (x = saveptr; x > 0; x--) { - if (-1 == get_adb_info(&data, x)) { - saveptr = x; - break; - } - } - if (x == 0) - saveptr = 0; -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("new free is 0x%02x\n", - saveptr); -#endif - nonewtimes = 0; - /* tell pm driver device is here */ - pm_check_adb_devices(device); - } else { -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("moving back...\n"); -#endif - /* move old device back */ - command = ADBLISTEN(saveptr, 3); - send_string[0] = 2; - send_string[1] = (u_char)(device | 0x60); - send_string[2] = 0xfe; - (void)adb_op_sync((Ptr)send_string, - (short)command); - delay(1000); - } - } - } - -#ifdef ADB_DEBUG - if (adb_debug) { - for (i = 1; i <= ADBNumDevices; i++) { - x = get_ind_adb_info(&data, i); - if (x != -1) - printf_intr("index 0x%x, addr 0x%x, type 0x%hx\n", - i, x, data.devType); - } - } -#endif - - /* enable the programmer's switch, if we have one */ - adb_prog_switch_enable(); - -#ifdef ADB_DEBUG - if (adb_debug) { - if (0 == ADBNumDevices) /* tell user if no devices found */ - printf_intr("adb: no devices found\n"); - } -#endif - - adbStarting = 0; /* not starting anymore */ -#ifdef ADB_DEBUG - if (adb_debug) - printf_intr("adb: adb_reinit complete\n"); -#endif - - if (adbHardware == ADB_HW_CUDA) { - timeout_set(&adb_cuda_timeout, (void *)adb_cuda_tickle, NULL); - timeout_add(&adb_cuda_timeout, ADB_TICKLE_TICKS); - } - - /* ints must be on for PB & IOP (at least, for now) */ - if (adbHardware != ADB_HW_PB && adbHardware != ADB_HW_IOP) - splx(s); -} - - -/* - * adb_cmd_result - * - * This routine lets the caller know whether the specified adb command string - * should expect a returned result, such as a TALK command. - * - * returns: 0 if a result should be expected - * 1 if a result should NOT be expected - */ -int -adb_cmd_result(u_char *in) -{ - switch (adbHardware) { - case ADB_HW_IOP: - case ADB_HW_II: - /* was it an ADB talk command? */ - if ((in[1] & 0x0c) == 0x0c) - return 0; - return 1; - - case ADB_HW_IISI: - case ADB_HW_CUDA: - /* was it an ADB talk command? */ - if ((in[1] == 0x00) && ((in[2] & 0x0c) == 0x0c)) - return 0; - /* was it an RTC/PRAM read date/time? */ - if ((in[1] == 0x01) && (in[2] == 0x03)) - return 0; - return 1; - - case ADB_HW_PB: - return 1; - - case ADB_HW_UNKNOWN: - default: - return 1; - } -} - -void -adb_setup_hw_type(void) -{ - /* - * Determine what type of ADB hardware we are running on. - */ - switch (mac68k_machine.machineid) { - case MACH_MACC610: /* Centris 610 */ - case MACH_MACC650: /* Centris 650 */ - case MACH_MACII: /* II */ - case MACH_MACIICI: /* IIci */ - case MACH_MACIICX: /* IIcx */ - case MACH_MACIIX: /* IIx */ - case MACH_MACQ610: /* Quadra 610 */ - case MACH_MACQ650: /* Quadra 650 */ - case MACH_MACQ700: /* Quadra 700 */ - case MACH_MACQ800: /* Quadra 800 */ - case MACH_MACSE30: /* SE/30 */ - adbHardware = ADB_HW_II; - break; - - case MACH_MACCLASSICII: /* Classic II */ - case MACH_MACLCII: /* LC II, Performa 400/405/430 */ - case MACH_MACLCIII: /* LC III, Performa 450 */ - case MACH_MACIISI: /* IIsi */ - case MACH_MACIIVI: /* IIvi */ - case MACH_MACIIVX: /* IIvx */ - case MACH_MACP460: /* Performa 460/465/467 */ - case MACH_MACP600: /* Performa 600 */ - adbHardware = ADB_HW_IISI; - break; - - case MACH_MACPB140: /* PowerBook 140 */ - case MACH_MACPB145: /* PowerBook 145 */ - case MACH_MACPB150: /* PowerBook 150 */ - case MACH_MACPB160: /* PowerBook 160 */ - case MACH_MACPB165: /* PowerBook 165 */ - case MACH_MACPB165C: /* PowerBook 165c */ - case MACH_MACPB170: /* PowerBook 170 */ - case MACH_MACPB180: /* PowerBook 180 */ - case MACH_MACPB180C: /* PowerBook 180c */ - case MACH_MACPB190: /* PowerBook 190 */ - case MACH_MACPB190CS: /* PowerBook 190cs */ - case MACH_MACPB210: /* PowerBook Duo 210 */ - case MACH_MACPB230: /* PowerBook Duo 230 */ - case MACH_MACPB250: /* PowerBook Duo 250 */ - case MACH_MACPB270: /* PowerBook Duo 270 */ - case MACH_MACPB280: /* PowerBook Duo 280 */ - case MACH_MACPB280C: /* PowerBook Duo 280c */ - case MACH_MACPB500: /* PowerBook 500 series */ - adbHardware = ADB_HW_PB; - pm_setup_adb(); - break; - - case MACH_MACC660AV: /* Centris 660AV */ - case MACH_MACCCLASSIC: /* Color Classic */ - case MACH_MACCCLASSICII: /* Color Classic II */ - case MACH_MACLC475: /* LC 475, Performa 475/476 */ - case MACH_MACLC475_33: /* Clock-chipped 47x */ - case MACH_MACLC520: /* LC 520 */ - case MACH_MACLC575: /* LC 575, Performa 575/577/578 */ - case MACH_MACP550: /* LC 550, Performa 550 */ - case MACH_MACTV: /* Macintosh TV */ - case MACH_MACP580: /* Performa 580/588 */ - case MACH_MACQ605: /* Quadra 605 */ - case MACH_MACQ605_33: /* Clock-chipped Quadra 605 */ - case MACH_MACQ630: /* LC 630, Performa 630, Quadra 630 */ - case MACH_MACQ840AV: /* Quadra 840AV */ - adbHardware = ADB_HW_CUDA; - break; - - case MACH_MACQ900: /* Quadra 900 */ - case MACH_MACQ950: /* Quadra 950 */ - case MACH_MACIIFX: /* Mac IIfx */ - adbHardware = ADB_HW_IOP; - break; - - default: - adbHardware = ADB_HW_UNKNOWN; - break; - } - - /* - * Determine whether this machine has ADB based soft power. - */ - switch (mac68k_machine.machineid) { - case MACH_MACCCLASSIC: /* Color Classic */ - case MACH_MACCCLASSICII: /* Color Classic II */ - case MACH_MACIISI: /* IIsi */ - case MACH_MACIIVI: /* IIvi */ - case MACH_MACIIVX: /* IIvx */ - case MACH_MACLC520: /* LC 520 */ - case MACH_MACLC575: /* LC 575, Performa 575/577/578 */ - case MACH_MACP550: /* LC 550, Performa 550 */ - case MACH_MACTV: /* Macintosh TV */ - case MACH_MACP580: /* Performa 580/588 */ - case MACH_MACP600: /* Performa 600 */ - case MACH_MACQ630: /* LC 630, Performa 630, Quadra 630 */ - case MACH_MACQ840AV: /* Quadra 840AV */ - adbSoftPower = 1; - break; - } -} - -/* - * adb_op_sync - * - * This routine does exactly what the adb_op routine does, except that after - * the adb_op is called, it waits until the return value is present before - * returning. - */ -int -adb_op_sync(Ptr buffer, short command) -{ - int tmout; - int result; - volatile int flag = 0; - - result = adb_op(buffer, (void *)adb_op_comprout, (Ptr)&flag, - command); /* send command */ - if (result == 0) { /* send ok? */ - /* - * Total time to wait is calculated as follows: - * - Tlt (stop to start time): 260 usec - * - start bit: 100 usec - * - up to 8 data bytes: 64 * 100 usec = 6400 usec - * - stop bit (with SRQ): 140 usec - * Total: 6900 usec - * - * This is the total time allowed by the specification. Any - * device that doesn't conform to this will fail to operate - * properly on some Apple systems. In spite of this we - * double the time to wait; some Cuda-based apparently - * queues some commands and allows the main CPU to continue - * processing (radical concept, eh?). To be safe, allow - * time for two complete ADB transactions to occur. - */ - for (tmout = 13800; !flag && tmout >= 10; tmout -= 10) - delay(10); - if (!flag && tmout > 0) - delay(tmout); - - if (!flag) - result = -2; - } - - return result; -} - -/* - * adb_op_comprout - * - * This function is used by the adb_op_sync routine so it knows when the - * function is done. - */ -void -adb_op_comprout(caddr_t buffer, caddr_t data_area, int adb_command) -{ - *(int *)data_area = 0x01; /* update flag value */ -} - -int -count_adbs(void) -{ - int i; - int found; - - found = 0; - - for (i = 1; i < 16; i++) - if (0 != ADBDevTable[i].currentAddr) - found++; - - return found; -} - -int -get_ind_adb_info(ADBDataBlock *info, int index) -{ - if ((index < 1) || (index > 15)) /* check range 1-15 */ - return (-1); - -#ifdef ADB_DEBUG - if (adb_debug & 0x80) - printf_intr("index 0x%x devType is: 0x%x\n", index, - ADBDevTable[index].devType); -#endif - if (0 == ADBDevTable[index].devType) /* make sure it's a valid entry */ - return (-1); - - info->devType = (unsigned char)(ADBDevTable[index].devType); - info->origADBAddr = (unsigned char)(ADBDevTable[index].origAddr); - info->dbServiceRtPtr = (Ptr)ADBDevTable[index].ServiceRtPtr; - info->dbDataAreaAddr = (Ptr)ADBDevTable[index].DataAreaAddr; - - return (ADBDevTable[index].currentAddr); -} - -int -get_adb_info(ADBDataBlock *info, int adbAddr) -{ - int i; - - if ((adbAddr < 1) || (adbAddr > 15)) /* check range 1-15 */ - return (-1); - - for (i = 1; i < 15; i++) - if (ADBDevTable[i].currentAddr == adbAddr) { - info->devType = (unsigned char)(ADBDevTable[i].devType); - info->origADBAddr = (unsigned char)(ADBDevTable[i].origAddr); - info->dbServiceRtPtr = (Ptr)ADBDevTable[i].ServiceRtPtr; - info->dbDataAreaAddr = ADBDevTable[i].DataAreaAddr; - return 0; /* found */ - } - - return (-1); /* not found */ -} - -int -set_adb_info(ADBSetInfoBlock *info, int adbAddr) -{ - int i; - - if ((adbAddr < 1) || (adbAddr > 15)) /* check range 1-15 */ - return (-1); - - for (i = 1; i < 15; i++) - if (ADBDevTable[i].currentAddr == adbAddr) { - ADBDevTable[i].ServiceRtPtr = - (void *)(info->siServiceRtPtr); - ADBDevTable[i].DataAreaAddr = info->siDataAreaAddr; - return 0; /* found */ - } - - return (-1); /* not found */ -} - -/* caller should really use machine-independant version: getPramTime */ -/* this version does pseudo-adb access only */ -int -adb_read_date_time(unsigned long *time) -{ - u_char output[ADB_MAX_MSG_LENGTH]; - int result; - volatile int flag = 0; - - switch (adbHardware) { - case ADB_HW_IOP: - case ADB_HW_II: - return -1; - - case ADB_HW_IISI: - output[0] = 0x02; /* 2 byte message */ - output[1] = 0x01; /* to pram/rtc device */ - output[2] = 0x03; /* read date/time */ - result = send_adb_IIsi((u_char *)output, (u_char *)output, - (void *)adb_op_comprout, (void *)&flag, (int)0); - if (result != 0) /* exit if not sent */ - return -1; - - while (0 == flag) /* wait for result */ - ; - - *time = (long)(*(long *)(output + 1)); - return 0; - - case ADB_HW_PB: - return -1; - - case ADB_HW_CUDA: - output[0] = 0x02; /* 2 byte message */ - output[1] = 0x01; /* to pram/rtc device */ - output[2] = 0x03; /* read date/time */ - result = send_adb_cuda((u_char *)output, (u_char *)output, - (void *)adb_op_comprout, (void *)&flag, (int)0); - if (result != 0) /* exit if not sent */ - return -1; - - while (0 == flag) /* wait for result */ - ; - - *time = (long)(*(long *)(output + 1)); - return 0; - - case ADB_HW_UNKNOWN: - default: - return -1; - } -} - -/* caller should really use machine-independant version: setPramTime */ -/* this version does pseudo-adb access only */ -int -adb_set_date_time(unsigned long time) -{ - u_char output[ADB_MAX_MSG_LENGTH]; - int result; - volatile int flag = 0; - - switch (adbHardware) { - case ADB_HW_IOP: - case ADB_HW_II: - return -1; - - case ADB_HW_IISI: - output[0] = 0x06; /* 6 byte message */ - output[1] = 0x01; /* to pram/rtc device */ - output[2] = 0x09; /* set date/time */ - output[3] = (u_char)(time >> 24); - output[4] = (u_char)(time >> 16); - output[5] = (u_char)(time >> 8); - output[6] = (u_char)(time); - result = send_adb_IIsi((u_char *)output, (u_char *)0, - (void *)adb_op_comprout, (void *)&flag, (int)0); - if (result != 0) /* exit if not sent */ - return -1; - - while (0 == flag) /* wait for send to finish */ - ; - - return 0; - - case ADB_HW_PB: - return -1; - - case ADB_HW_CUDA: - output[0] = 0x06; /* 6 byte message */ - output[1] = 0x01; /* to pram/rtc device */ - output[2] = 0x09; /* set date/time */ - output[3] = (u_char)(time >> 24); - output[4] = (u_char)(time >> 16); - output[5] = (u_char)(time >> 8); - output[6] = (u_char)(time); - result = send_adb_cuda((u_char *)output, (u_char *)0, - (void *)adb_op_comprout, (void *)&flag, (int)0); - if (result != 0) /* exit if not sent */ - return -1; - - while (0 == flag) /* wait for send to finish */ - ; - - return 0; - - case ADB_HW_UNKNOWN: - default: - return -1; - } -} - - -int -adb_poweroff(void) -{ - u_char output[ADB_MAX_MSG_LENGTH]; - int result; - - if (!adbSoftPower) - return -1; - - adb_polling = 1; - - switch (adbHardware) { - case ADB_HW_IISI: - output[0] = 0x02; /* 2 byte message */ - output[1] = 0x01; /* to pram/rtc/soft-power device */ - output[2] = 0x0a; /* set date/time */ - result = send_adb_IIsi((u_char *)output, (u_char *)0, - (void *)0, (void *)0, (int)0); - if (result != 0) /* exit if not sent */ - return -1; - - for (;;); /* wait for power off */ - - return 0; - - case ADB_HW_PB: - return -1; - - case ADB_HW_CUDA: - output[0] = 0x02; /* 2 byte message */ - output[1] = 0x01; /* to pram/rtc/soft-power device */ - output[2] = 0x0a; /* set date/time */ - result = send_adb_cuda((u_char *)output, (u_char *)0, - (void *)0, (void *)0, (int)0); - if (result != 0) /* exit if not sent */ - return -1; - - for (;;); /* wait for power off */ - - return 0; - - case ADB_HW_IOP: /* IOP models don't do ADB soft power */ - case ADB_HW_II: /* II models don't do ADB soft power */ - case ADB_HW_UNKNOWN: - default: - return -1; - } -} - -int -adb_prog_switch_enable(void) -{ - u_char output[ADB_MAX_MSG_LENGTH]; - int result; - volatile int flag = 0; - - switch (adbHardware) { - case ADB_HW_IISI: - output[0] = 0x03; /* 3 byte message */ - output[1] = 0x01; /* to pram/rtc/soft-power device */ - output[2] = 0x1c; /* prog. switch control */ - output[3] = 0x01; /* enable */ - result = send_adb_IIsi((u_char *)output, (u_char *)0, - (void *)adb_op_comprout, (void *)&flag, (int)0); - if (result != 0) /* exit if not sent */ - return -1; - - while (0 == flag) /* wait for send to finish */ - ; - - return 0; - - case ADB_HW_PB: - return -1; - - case ADB_HW_II: /* II models don't do prog. switch */ - case ADB_HW_IOP: /* IOP models don't do prog. switch */ - case ADB_HW_CUDA: /* cuda doesn't do prog. switch TO DO: verify this */ - case ADB_HW_UNKNOWN: - default: - return -1; - } -} - -#if 0 -int -adb_prog_switch_disable(void) -{ - u_char output[ADB_MAX_MSG_LENGTH]; - int result; - volatile int flag = 0; - - switch (adbHardware) { - case ADB_HW_IISI: - output[0] = 0x03; /* 3 byte message */ - output[1] = 0x01; /* to pram/rtc/soft-power device */ - output[2] = 0x1c; /* prog. switch control */ - output[3] = 0x01; /* disable */ - result = send_adb_IIsi((u_char *)output, (u_char *)0, - (void *)adb_op_comprout, (void *)&flag, (int)0); - if (result != 0) /* exit if not sent */ - return -1; - - while (0 == flag) /* wait for send to finish */ - ; - - return 0; - - case ADB_HW_PB: - return -1; - - case ADB_HW_II: /* II models don't do prog. switch */ - case ADB_HW_IOP: /* IOP models don't do prog. switch */ - case ADB_HW_CUDA: /* cuda doesn't do prog. switch */ - case ADB_HW_UNKNOWN: - default: - return -1; - } -} -#endif - -/* - * Function declarations. - */ -int adbmatch(struct device *, void *, void *); -void adbattach(struct device *, struct device *, void *); -void adb_attach_deferred(void *); - -/* - * Driver definition. - */ - -struct cfattach adb_ca = { - sizeof(struct adb_softc), adbmatch, adbattach -}; - -int -adbmatch(struct device *parent, void *vcf, void *aux) -{ - static int adb_matched = 0; - - /* Allow only one instance. */ - if (adb_matched) - return (0); - - adb_matched = 1; - return (1); -} - -void -adbattach(struct device *parent, struct device *self, void *aux) -{ - adb_setup_hw_type(); /* setup hardware type */ - printf(": %s\n", adbHardwareDescr[adbHardware]); - startuphook_establish(adb_attach_deferred, self); -} - -void -adb_attach_deferred(void *v) -{ - struct adb_softc *sc = v; - ADBDataBlock adbdata; - struct adb_attach_args aa_args; - int totaladbs; - int adbindex, adbaddr; - - printf("%s: ", sc->sc_dev.dv_xname); - adb_polling = 1; - adb_reinit(sc); - -#ifdef ADB_DEBUG - if (adb_debug) - printf("adb: done with adb_reinit\n"); -#endif - - totaladbs = count_adbs(); - - printf("%d target%s\n", totaladbs, (totaladbs == 1) ? "" : "s"); - - /* for each ADB device */ - for (adbindex = 1; adbindex <= totaladbs; adbindex++) { - /* Get the ADB information */ - adbaddr = get_ind_adb_info(&adbdata, adbindex); - - aa_args.name = adb_device_name; - aa_args.origaddr = (int)(adbdata.origADBAddr); - aa_args.adbaddr = adbaddr; - aa_args.handler_id = (int)(adbdata.devType); - - (void)config_found(&sc->sc_dev, &aa_args, adbprint); - } - - sc->sc_softih = softintr_establish(IPL_SOFTTTY, adb_soft_intr, NULL); - adb_polling = 0; -} diff --git a/sys/arch/mac68k/dev/adbvar.h b/sys/arch/mac68k/dev/adbvar.h deleted file mode 100644 index 5db3e163d52..00000000000 --- a/sys/arch/mac68k/dev/adbvar.h +++ /dev/null @@ -1,46 +0,0 @@ -/* $OpenBSD: adbvar.h,v 1.13 2006/01/22 15:25:30 miod Exp $ */ -/* $NetBSD: adbvar.h,v 1.22 2005/01/15 16:00:59 chs Exp $ */ - -/* - * Copyright (C) 1994 Bradley A. Grantham - * 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 Bradley A. Grantham. - * 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. - */ - -extern int adbHardware; - -/* types of adb hardware that we (will eventually) support */ -#define ADB_HW_UNKNOWN 0 /* don't know */ -#define ADB_HW_II 1 /* Mac II series */ -#define ADB_HW_IISI 2 /* Mac IIsi series */ -#define ADB_HW_PB 3 /* PowerBook series */ -#define ADB_HW_CUDA 4 /* Machines with a Cuda chip */ -#define ADB_HW_IOP 5 /* Machines with an IOP */ - -int adb_poweroff(void); -int adb_read_date_time(unsigned long *); -int adb_set_date_time(unsigned long); diff --git a/sys/arch/mac68k/dev/akbd_machdep.c b/sys/arch/mac68k/dev/akbd_machdep.c deleted file mode 100644 index 963545bc3b8..00000000000 --- a/sys/arch/mac68k/dev/akbd_machdep.c +++ /dev/null @@ -1,124 +0,0 @@ -/* $OpenBSD: akbd_machdep.c,v 1.2 2006/01/20 00:10:09 miod Exp $ */ -/* $NetBSD: akbd.c,v 1.17 2005/01/15 16:00:59 chs Exp $ */ - -/* - * Copyright (C) 1998 Colin Wood - * 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 Colin Wood. - * 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. - */ - -#include <sys/param.h> -#include <sys/timeout.h> -#include <sys/kernel.h> -#include <sys/device.h> -#include <sys/fcntl.h> -#include <sys/poll.h> -#include <sys/selinfo.h> -#include <sys/proc.h> -#include <sys/signalvar.h> -#include <sys/systm.h> - -#include <dev/wscons/wsconsio.h> -#include <dev/wscons/wskbdvar.h> - -#include <machine/cpu.h> -#include <machine/viareg.h> - -#include <dev/adb/adb.h> -#include <dev/adb/akbdvar.h> -#include <dev/adb/keyboard.h> - -void akbd_cnbell(void *, u_int, u_int, u_int); -void akbd_cngetc(void *, u_int *, int *); -void akbd_cnpollc(void *, int); - -struct wskbd_consops akbd_consops = { - akbd_cngetc, - akbd_cnpollc, - akbd_cnbell -}; - -int -akbd_is_console(void) -{ - return ((mac68k_machine.serial_console & 0x03) == 0); -} - -int -akbd_cnattach(void) -{ - wskbd_cnattach(&akbd_consops, NULL, &akbd_keymapdata); - return 0; -} - -void -akbd_cngetc(void *v, u_int *type, int *data) -{ - int intbits, key, press, val; - int s; - extern int adb_intr(void *); - extern void pm_intr(void *); - - s = splhigh(); - - adb_polledkey = -1; - adb_polling = 1; - - while (adb_polledkey == -1) { - intbits = via_reg(VIA1, vIFR); - - if (intbits & V1IF_ADBRDY) { - adb_intr(NULL); - via_reg(VIA1, vIFR) = V1IF_ADBRDY; - } - if (intbits & V1IF_ADBCLK) { - pm_intr(NULL); - via_reg(VIA1, vIFR) = 0x10; - } - } - - adb_polling = 0; - splx(s); - - key = adb_polledkey; - press = ADBK_PRESS(key); - val = ADBK_KEYVAL(key); - - *data = val; - *type = press ? WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP; -} - -void -akbd_cnpollc(void *v, int on) -{ -} - -void -akbd_cnbell(void *v, u_int pitch, u_int period, u_int volume) -{ - mac68k_ring_bell(pitch, period * hz / 1000, volume); -} diff --git a/sys/arch/mac68k/dev/asc.c b/sys/arch/mac68k/dev/asc.c deleted file mode 100644 index 01e06912d10..00000000000 --- a/sys/arch/mac68k/dev/asc.c +++ /dev/null @@ -1,370 +0,0 @@ -/* $OpenBSD: asc.c,v 1.29 2011/07/02 22:20:07 nicm Exp $ */ -/* $NetBSD: asc.c,v 1.20 1997/02/24 05:47:33 scottr Exp $ */ - -/* - * Copyright (C) 1997 Scott Reynolds - * 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. 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. - */ -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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. - */ - -/* - * ASC driver code and console bell support - */ - -#include <sys/param.h> -#include <sys/proc.h> -#include <sys/systm.h> -#include <sys/errno.h> -#include <sys/time.h> -#include <sys/device.h> -#include <sys/fcntl.h> -#include <sys/poll.h> -#include <sys/timeout.h> - -#include <uvm/uvm_extern.h> -#include <uvm/uvm_pmap.h> - -#include <machine/autoconf.h> -#include <machine/cpu.h> -#include <machine/bus.h> - -#include <mac68k/dev/ascvar.h> -#include <mac68k/dev/obiovar.h> - -#define MAC68K_ASC_BASE 0x50f14000 -#define MAC68K_IIFX_ASC_BASE 0x50f10000 -#define MAC68K_ASC_LEN 0x01000 - -static u_int8_t asc_wave_tab[0x800]; - -static int asc_ring_bell(void *, int, int, int); -static void asc_stop_bell(void *); - -static int ascmatch(struct device *, void *, void *); -static void ascattach(struct device *, struct device *, void *); - -struct cfattach asc_ca = { - sizeof(struct asc_softc), ascmatch, ascattach -}; - -struct cfdriver asc_cd = { - NULL, "asc", DV_DULL -}; - -static int -ascmatch(parent, vcf, aux) - struct device *parent; - void *vcf; - void *aux; -{ - struct obio_attach_args *oa = (struct obio_attach_args *)aux; - bus_addr_t addr; - bus_space_handle_t bsh; - int rval = 0; - - if (oa->oa_addr != (-1)) - addr = (bus_addr_t)oa->oa_addr; - else if (current_mac_model->machineid == MACH_MACTV) - return 0; - else if (current_mac_model->machineid == MACH_MACIIFX) - addr = (bus_addr_t)MAC68K_IIFX_ASC_BASE; - else - addr = (bus_addr_t)MAC68K_ASC_BASE; - - if (bus_space_map(oa->oa_tag, addr, MAC68K_ASC_LEN, 0, &bsh)) - return (0); - - if (mac68k_bus_space_probe(oa->oa_tag, bsh, 0, 1)) - rval = 1; - else - rval = 0; - - bus_space_unmap(oa->oa_tag, bsh, MAC68K_ASC_LEN); - - return rval; -} - -static void -ascattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct asc_softc *sc = (struct asc_softc *)self; - struct obio_attach_args *oa = (struct obio_attach_args *)aux; - bus_addr_t addr; - int i; - - sc->sc_tag = oa->oa_tag; - if (oa->oa_addr != (-1)) - addr = (bus_addr_t)oa->oa_addr; - else if (current_mac_model->machineid == MACH_MACIIFX) - addr = (bus_addr_t)MAC68K_IIFX_ASC_BASE; - else - addr = (bus_addr_t)MAC68K_ASC_BASE; - if (bus_space_map(sc->sc_tag, addr, MAC68K_ASC_LEN, 0, - &sc->sc_handle)) { - printf(": can't map mem space\n"); - return; - } - sc->sc_open = 0; - sc->sc_ringing = 0; - timeout_set(&sc->sc_bell_tmo, asc_stop_bell, sc); - - for (i = 0; i < 256; i++) { /* up part of wave, four voices? */ - asc_wave_tab[i] = i / 4; - asc_wave_tab[i + 512] = i / 4; - asc_wave_tab[i + 1024] = i / 4; - asc_wave_tab[i + 1536] = i / 4; - } - for (i = 0; i < 256; i++) { /* down part of wave, four voices? */ - asc_wave_tab[i + 256] = 0x3f - (i / 4); - asc_wave_tab[i + 768] = 0x3f - (i / 4); - asc_wave_tab[i + 1280] = 0x3f - (i / 4); - asc_wave_tab[i + 1792] = 0x3f - (i / 4); - } - - printf(": Apple Sound Chip"); - if (oa->oa_addr != (-1)) - printf(" at %x", oa->oa_addr); - printf("\n"); - - mac68k_set_bell_callback(asc_ring_bell, sc); -} - -int -ascopen(dev, flag, mode, p) - dev_t dev; - int flag; - int mode; - struct proc *p; -{ - struct asc_softc *sc; - int unit; - - unit = ASCUNIT(dev); - if (unit >= asc_cd.cd_ndevs) - return (ENXIO); - sc = asc_cd.cd_devs[unit]; - if (sc == NULL) - return (ENXIO); - if (sc->sc_open) - return (EBUSY); - sc->sc_open = 1; - - return (0); -} - -int -ascclose(dev, flag, mode, p) - dev_t dev; - int flag; - int mode; - struct proc *p; -{ - struct asc_softc *sc; - - sc = asc_cd.cd_devs[ASCUNIT(dev)]; - sc->sc_open = 0; - - return (0); -} - -int -ascread(dev, uio, ioflag) - dev_t dev; - struct uio *uio; - int ioflag; -{ - return (ENXIO); -} - -int -ascwrite(dev, uio, ioflag) - dev_t dev; - struct uio *uio; - int ioflag; -{ - return (ENXIO); -} - -int -ascioctl(dev, cmd, data, flag, p) - dev_t dev; - int cmd; - caddr_t data; - int flag; - struct proc *p; -{ - struct asc_softc *sc; - int error; - int unit = ASCUNIT(dev); - - sc = asc_cd.cd_devs[unit]; - error = 0; - - switch (cmd) { - default: - error = EINVAL; - break; - } - return (error); -} - -int -ascpoll(dev, events, p) - dev_t dev; - int events; - struct proc *p; -{ - /* always fails => never blocks */ - return (events & (POLLOUT | POLLWRNORM)); -} - -paddr_t -ascmmap(dev, off, prot) - dev_t dev; - off_t off; - int prot; -{ - int unit = ASCUNIT(dev); - struct asc_softc *sc; - paddr_t pa; - - sc = asc_cd.cd_devs[unit]; - if (off >= 0 && off < MAC68K_ASC_LEN) { - (void)pmap_extract(pmap_kernel(), - (vaddr_t)bus_space_vaddr(sc->sc_tag, sc->sc_handle), &pa); - return (pa + off); - } - - return (-1); -} - -static int -asc_ring_bell(arg, freq, length, volume) - void *arg; - int freq, length, volume; -{ - struct asc_softc *sc = (struct asc_softc *)arg; - unsigned long cfreq; - int i; - - if (!sc) - return (ENODEV); - - if (sc->sc_ringing == 0) { - bus_space_set_region_1(sc->sc_tag, sc->sc_handle, - 0, 0, 0x800); - bus_space_write_region_1(sc->sc_tag, sc->sc_handle, - 0, asc_wave_tab, 0x800); - - /* Fix this. Need to find exact ASC sampling freq */ - cfreq = 65536 * freq / 466; - - /* printf("beep: from %d, %02x %02x %02x %02x\n", - * cur_beep.freq, (cfreq >> 24) & 0xff, (cfreq >> 16) & 0xff, - * (cfreq >> 8) & 0xff, (cfreq) & 0xff); */ - for (i = 0; i < 8; i++) { - bus_space_write_1(sc->sc_tag, sc->sc_handle, - 0x814 + 8 * i, (cfreq >> 24) & 0xff); - bus_space_write_1(sc->sc_tag, sc->sc_handle, - 0x815 + 8 * i, (cfreq >> 16) & 0xff); - bus_space_write_1(sc->sc_tag, sc->sc_handle, - 0x816 + 8 * i, (cfreq >> 8) & 0xff); - bus_space_write_1(sc->sc_tag, sc->sc_handle, - 0x817 + 8 * i, (cfreq) & 0xff); - } /* frequency; should put cur_beep.freq in here - * somewhere. */ - - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x807, 3); /* 44 ? */ - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x806, - 255 * volume / 100); - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x805, 0); - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x80f, 0); - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x802, 2); /* sampled */ - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x801, 2); /* enable sampled */ - sc->sc_ringing = 1; - timeout_add(&sc->sc_bell_tmo, length); - } - - return (0); -} - -static void -asc_stop_bell(arg) - void *arg; -{ - struct asc_softc *sc = (struct asc_softc *)arg; - - if (!sc) - return; - - if (sc->sc_ringing > 1000 || sc->sc_ringing < 0) - panic("bell got out of sync?"); - - if (--sc->sc_ringing == 0) /* disable ASC */ - bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x801, 0); -} - -int asckqfilter(dev_t, struct knote *); - -int -asckqfilter(dev, kn) - dev_t dev; - struct knote *kn; -{ - return (ENXIO); -} diff --git a/sys/arch/mac68k/dev/ascvar.h b/sys/arch/mac68k/dev/ascvar.h deleted file mode 100644 index b735afb9db4..00000000000 --- a/sys/arch/mac68k/dev/ascvar.h +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: ascvar.h,v 1.7 2005/04/24 22:25:13 martin Exp $ */ -/* $NetBSD: ascvar.h,v 1.3 1997/02/24 05:47:34 scottr Exp $ */ - -/* - * Copyright (C) 1997 Scott Reynolds. 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. 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. - */ - -#define ASCUNIT(d) ((d) & 0x7) - -struct asc_softc { - struct device sc_dev; - bus_space_tag_t sc_tag; - bus_space_handle_t sc_handle; - int sc_open; - int sc_ringing; - struct timeout sc_bell_tmo; -}; - -int ascopen(dev_t dev, int flag, int mode, struct proc *p); -int ascclose(dev_t dev, int flag, int mode, struct proc *p); -int ascread(dev_t, struct uio *, int); -int ascwrite(dev_t, struct uio *, int); -int ascioctl(dev_t, int, caddr_t, int, struct proc *p); -int ascpoll(dev_t dev, int rw, struct proc *p); -paddr_t ascmmap(dev_t dev, off_t off, int prot); diff --git a/sys/arch/mac68k/dev/esp.c b/sys/arch/mac68k/dev/esp.c deleted file mode 100644 index dca06803f87..00000000000 --- a/sys/arch/mac68k/dev/esp.c +++ /dev/null @@ -1,694 +0,0 @@ -/* $OpenBSD: esp.c,v 1.31 2010/11/11 17:55:32 miod Exp $ */ -/* $NetBSD: esp.c,v 1.17 1998/09/05 15:15:35 pk Exp $ */ - -/* - * Copyright (c) 1997 Jason R. Thorpe. - * 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 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. - * - * 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. - */ - -/* - * Copyright (c) 1994 Peter Galbavy - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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. - */ - -/* - * Based on aic6360 by Jarle Greipsland - * - * Acknowledgements: Many of the algorithms used in this driver are - * inspired by the work of Julian Elischer (julian@tfs.com) and - * Charles Hannum (mycroft@duality.gnu.ai.mit.edu). Thanks a million! - */ - -/* - * Initial m68k mac support from Allen Briggs <briggs@macbsd.com> - * (basically consisting of the match, a bit of the attach, and the - * "DMA" glue functions). - */ - -#include <sys/types.h> -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/device.h> -#include <sys/buf.h> -#include <sys/proc.h> -#include <sys/queue.h> - -#include <scsi/scsi_all.h> -#include <scsi/scsiconf.h> -#include <scsi/scsi_message.h> - -#include <machine/cpu.h> -#include <machine/bus.h> -#include <machine/param.h> - -#include <dev/ic/ncr53c9xreg.h> -#include <dev/ic/ncr53c9xvar.h> - -#include <machine/viareg.h> - -#include <mac68k/dev/espvar.h> -#include <mac68k/dev/obiovar.h> - -void espattach(struct device *, struct device *, void *); -int espmatch(struct device *, void *, void *); - -/* Linkup to the rest of the kernel */ -struct cfattach esp_ca = { - sizeof(struct esp_softc), espmatch, espattach -}; - -struct scsi_adapter esp_switch = { - ncr53c9x_scsi_cmd, - scsi_minphys, /* no max at this level; handled by DMA code */ - NULL, - NULL, -}; - -/* - * Functions and the switch for the MI code. - */ -u_char esp_read_reg(struct ncr53c9x_softc *, int); -void esp_write_reg(struct ncr53c9x_softc *, int, u_char); -int esp_dma_isintr(struct ncr53c9x_softc *); -void esp_dma_reset(struct ncr53c9x_softc *); -int esp_dma_intr(struct ncr53c9x_softc *); -int esp_dma_setup(struct ncr53c9x_softc *, caddr_t *, - size_t *, int, size_t *); -void esp_dma_go(struct ncr53c9x_softc *); -void esp_dma_stop(struct ncr53c9x_softc *); -int esp_dma_isactive(struct ncr53c9x_softc *); -void esp_quick_write_reg(struct ncr53c9x_softc *, int, u_char); -int esp_quick_dma_intr(struct ncr53c9x_softc *); -int esp_quick_dma_setup(struct ncr53c9x_softc *, caddr_t *, - size_t *, int, size_t *); -void esp_quick_dma_go(struct ncr53c9x_softc *); -int esp_intr(void *); - -static __inline__ int esp_dafb_have_dreq(struct esp_softc *esc); -static __inline__ int esp_iosb_have_dreq(struct esp_softc *esc); -int (*esp_have_dreq) (struct esp_softc *esc); - -struct ncr53c9x_glue esp_glue = { - esp_read_reg, - esp_write_reg, - esp_dma_isintr, - esp_dma_reset, - esp_dma_intr, - esp_dma_setup, - esp_dma_go, - esp_dma_stop, - esp_dma_isactive, - NULL, /* gl_clear_latched_intr */ -}; - -int -espmatch(parent, vcf, aux) - struct device *parent; - void *vcf, *aux; -{ - struct cfdata *cf = vcf; - - if ((cf->cf_unit == 0) && mac68k_machine.scsi96) { - return 1; - } - if ((cf->cf_unit == 1) && mac68k_machine.scsi96_2) { - return 1; - } - return 0; -} - -/* - * Attach this instance, and then all the sub-devices - */ -void -espattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct obio_attach_args *oa = (struct obio_attach_args *)aux; - extern vaddr_t SCSIBase; - struct esp_softc *esc = (void *)self; - struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x; - int quick = 0; - unsigned long reg_offset; - - reg_offset = SCSIBase - IOBase; - esc->sc_tag = oa->oa_tag; - - /* - * For Wombat, Primus and Optimus motherboards, DREQ is - * visible on bit 0 of the IOSB's emulated VIA2 vIFR (and - * the SCSI registers are offset 0x1000 bytes from IOBase). - * - * For the Q700/900/950 it's at f9800024 for bus 0 and - * f9800028 for bus 1 (900/950). For these machines, that is also - * a (12-bit) configuration register for DAFB's control of the - * pseudo-DMA timing. The default value is 0x1d1. - */ - esp_have_dreq = esp_dafb_have_dreq; - if (sc->sc_dev.dv_unit == 0) { - if (reg_offset == 0x10000) { - quick = 1; - esp_have_dreq = esp_iosb_have_dreq; - } else if (reg_offset == 0x18000) { - quick = 0; - } else { - if (bus_space_map(esc->sc_tag, 0xf9800024, - 4, 0, &esc->sc_bsh)) { - printf("failed to map 4 at 0xf9800024.\n"); - } else { - quick = 1; - bus_space_write_4(esc->sc_tag, - esc->sc_bsh, 0, 0x1d1); - } - } - } else { - if (bus_space_map(esc->sc_tag, 0xf9800028, 4, 0, - &esc->sc_bsh)) { - printf("failed to map 4 at 0xf9800028.\n"); - } else { - quick = 1; - bus_space_write_4(esc->sc_tag, esc->sc_bsh, 0, 0x1d1); - } - } - if (quick) { - esp_glue.gl_write_reg = esp_quick_write_reg; - esp_glue.gl_dma_intr = esp_quick_dma_intr; - esp_glue.gl_dma_setup = esp_quick_dma_setup; - esp_glue.gl_dma_go = esp_quick_dma_go; - } - - /* - * Set up the glue for MI code early; we use some of it here. - */ - sc->sc_glue = &esp_glue; - - esc->sc_ih.vh_fn = esp_intr; - esc->sc_ih.vh_arg = esc; - esc->sc_ih.vh_ipl = VIA2_SCSIIRQ; - - /* - * Save the regs - */ - if (sc->sc_dev.dv_unit == 0) { - esc->sc_reg = (volatile u_char *) SCSIBase; - via2_register_irq(&esc->sc_ih, self->dv_xname); - esc->irq_mask = V2IF_SCSIIRQ; - if (reg_offset == 0x10000) { - /* From the Q650 developer's note */ - sc->sc_freq = 16500; - } else { - sc->sc_freq = 25000; - } - } else { - esc->sc_reg = (volatile u_char *) SCSIBase + 0x402; - via2_register_irq(&esc->sc_ih, self->dv_xname); - esc->irq_mask = 0; - sc->sc_freq = 25000; - } - - if (quick) { - printf(" (pseudo-DMA)"); - } - -#ifdef DEBUG - printf(" address %p", esc->sc_reg); -#endif - - sc->sc_id = 7; - - /* - * It is necessary to try to load the 2nd config register here, - * to find out what rev the esp chip is, else the esp_reset - * will not set up the defaults correctly. - */ - sc->sc_cfg1 = sc->sc_id; /* | NCRCFG1_PARENB; */ - sc->sc_cfg2 = NCRCFG2_SCSI2; - sc->sc_cfg3 = 0; - sc->sc_rev = NCR_VARIANT_NCR53C96; - - /* - * This is the value used to start sync negotiations - * Note that the NCR register "SYNCTP" is programmed - * in "clocks per byte", and has a minimum value of 4. - * The SCSI period used in negotiation is one-fourth - * of the time (in nanoseconds) needed to transfer one byte. - * Since the chip's clock is given in kHz, we have the following - * formula: 4 * period = (1000000 / freq) * 4 - */ - sc->sc_minsync = 1000000 / sc->sc_freq; - - /* We need this to fit into the TCR... */ - sc->sc_maxxfer = 64 * 1024; - - if (quick == 0) { - sc->sc_minsync = 0; /* No synchronous xfers w/o DMA */ - sc->sc_maxxfer = 8 * 1024; - } - - /* convert sc_freq to MHz */ - sc->sc_freq /= 1000; - - /* - * Configure interrupts. - */ - if (esc->irq_mask) { - via2_reg(vPCR) = 0x22; - via2_reg(vIFR) = esc->irq_mask; - via2_reg(vIER) = 0x80 | esc->irq_mask; - } - - /* - * Now try to attach all the sub-devices - */ - ncr53c9x_attach(sc, &esp_switch); -} - -/* - * Glue functions. - */ - -u_char -esp_read_reg(sc, reg) - struct ncr53c9x_softc *sc; - int reg; -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - return esc->sc_reg[reg * 16]; -} - -void -esp_write_reg(sc, reg, val) - struct ncr53c9x_softc *sc; - int reg; - u_char val; -{ - struct esp_softc *esc = (struct esp_softc *)sc; - u_char v = val; - - if (reg == NCR_CMD && v == (NCRCMD_TRANS|NCRCMD_DMA)) { - v = NCRCMD_TRANS; - } - esc->sc_reg[reg * 16] = v; -} - -void -esp_dma_stop(sc) - struct ncr53c9x_softc *sc; -{ -} - -int -esp_dma_isactive(sc) - struct ncr53c9x_softc *sc; -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - return esc->sc_active; -} - -int -esp_dma_isintr(sc) - struct ncr53c9x_softc *sc; -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - return esc->sc_reg[NCR_STAT * 16] & 0x80; -} - -void -esp_dma_reset(sc) - struct ncr53c9x_softc *sc; -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - esc->sc_active = 0; - esc->sc_tc = 0; -} - -int -esp_dma_intr(sc) - struct ncr53c9x_softc *sc; -{ - struct esp_softc *esc = (struct esp_softc *)sc; - volatile u_char *cmdreg, *intrreg, *statreg, *fiforeg; - u_char *p; - u_int espphase, espstat, espintr; - int cnt; - - if (esc->sc_active == 0) { - printf("dma_intr--inactive DMA\n"); - return -1; - } - - if ((sc->sc_espintr & NCRINTR_BS) == 0) { - esc->sc_active = 0; - return 0; - } - - cnt = *esc->sc_dmalen; - if (*esc->sc_dmalen == 0) { - printf("data interrupt, but no count left."); - } - - p = *esc->sc_dmaaddr; - espphase = sc->sc_phase; - espstat = (u_int) sc->sc_espstat; - espintr = (u_int) sc->sc_espintr; - cmdreg = esc->sc_reg + NCR_CMD * 16; - fiforeg = esc->sc_reg + NCR_FIFO * 16; - statreg = esc->sc_reg + NCR_STAT * 16; - intrreg = esc->sc_reg + NCR_INTR * 16; - do { - if (esc->sc_datain) { - *p++ = *fiforeg; - cnt--; - if (espphase == DATA_IN_PHASE) { - *cmdreg = NCRCMD_TRANS; - } else { - esc->sc_active = 0; - } - } else { - if ( (espphase == DATA_OUT_PHASE) - || (espphase == MESSAGE_OUT_PHASE)) { - *fiforeg = *p++; - cnt--; - *cmdreg = NCRCMD_TRANS; - } else { - esc->sc_active = 0; - } - } - - if (esc->sc_active) { - while (!(*statreg & 0x80)); - espstat = *statreg; - espintr = *intrreg; - espphase = (espintr & NCRINTR_DIS) - ? /* Disconnected */ BUSFREE_PHASE - : espstat & PHASE_MASK; - } - } while (esc->sc_active && (espintr & NCRINTR_BS)); - sc->sc_phase = espphase; - sc->sc_espstat = (u_char) espstat; - sc->sc_espintr = (u_char) espintr; - *esc->sc_dmaaddr = p; - *esc->sc_dmalen = cnt; - - if (*esc->sc_dmalen == 0) { - esc->sc_tc = NCRSTAT_TC; - } - sc->sc_espstat |= esc->sc_tc; - return 0; -} - -int -esp_dma_setup(sc, addr, len, datain, dmasize) - struct ncr53c9x_softc *sc; - caddr_t *addr; - size_t *len; - int datain; - size_t *dmasize; -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - esc->sc_dmaaddr = addr; - esc->sc_dmalen = len; - esc->sc_datain = datain; - esc->sc_dmasize = *dmasize; - esc->sc_tc = 0; - - return 0; -} - -void -esp_dma_go(sc) - struct ncr53c9x_softc *sc; -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - if (esc->sc_datain == 0) { - esc->sc_reg[NCR_FIFO * 16] = **esc->sc_dmaaddr; - (*esc->sc_dmalen)--; - (*esc->sc_dmaaddr)++; - } - esc->sc_active = 1; -} - -void -esp_quick_write_reg(sc, reg, val) - struct ncr53c9x_softc *sc; - int reg; - u_char val; -{ - struct esp_softc *esc = (struct esp_softc *)sc; - u_char v = val; - - esc->sc_reg[reg * 16] = v; -} - -int -esp_quick_dma_intr(sc) - struct ncr53c9x_softc *sc; -{ - struct esp_softc *esc = (struct esp_softc *)sc; - int trans=0, resid=0; - - if (esc->sc_active == 0) - panic("dma_intr--inactive DMA"); - - esc->sc_active = 0; - - if (esc->sc_dmasize == 0) { - int res; - - res = 65536; - res -= NCR_READ_REG(sc, NCR_TCL); - res -= NCR_READ_REG(sc, NCR_TCM) << 8; - printf("dmaintr: discarded %d b (last transfer was %d b).\n", - res, esc->sc_prevdmasize); - return 0; - } - - if (esc->sc_datain && - (resid = (NCR_READ_REG(sc, NCR_FFLAG) & NCRFIFO_FF)) != 0) { - printf("dmaintr: empty FIFO of %d\n", resid); - DELAY(1); - } - - if ((sc->sc_espstat & NCRSTAT_TC) == 0) { - resid += NCR_READ_REG(sc, NCR_TCL); - resid += NCR_READ_REG(sc, NCR_TCM) << 8; - - if (resid == 0) - resid = 65536; - } - - trans = esc->sc_dmasize - resid; - if (trans < 0) { - printf("dmaintr: trans < 0????"); - trans = esc->sc_dmasize; - } - - NCR_DMA(("dmaintr: trans %d, resid %d.\n", trans, resid)); - *esc->sc_dmaaddr += trans; - *esc->sc_dmalen -= trans; - - return 0; -} - -int -esp_quick_dma_setup(sc, addr, len, datain, dmasize) - struct ncr53c9x_softc *sc; - caddr_t *addr; - size_t *len; - int datain; - size_t *dmasize; -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - esc->sc_dmaaddr = addr; - esc->sc_dmalen = len; - - esc->sc_pdmaddr = (u_int16_t *) *addr; - esc->sc_pdmalen = *len; - - if (esc->sc_pdmalen & 1) { - esc->sc_pdmalen--; - esc->sc_pad = 1; - } else { - esc->sc_pad = 0; - } - - esc->sc_datain = datain; - esc->sc_prevdmasize = esc->sc_dmasize; - esc->sc_dmasize = *dmasize; - - return 0; -} - -static __inline__ int -esp_dafb_have_dreq(esc) - struct esp_softc *esc; -{ - return (*(volatile u_int32_t *) - bus_space_vaddr(esc->sc_tag, esc->sc_bsh) & 0x200); -} - -static __inline__ int -esp_iosb_have_dreq(esc) - struct esp_softc *esc; -{ - return (via2_reg(vIFR) & V2IF_SCSIDRQ); -} - -/* Faster spl constructs, without saving old values */ -#define __splx(s) __asm __volatile ("movew %0,sr" : : "di" (s)); -#define __splvm() __splx(mac68k_vmipl) -#define __splbio() __splx(PSL_S | PSL_IPL2) - -void -esp_quick_dma_go(sc) - struct ncr53c9x_softc *sc; -{ - struct esp_softc *esc = (struct esp_softc *)sc; - extern int *nofault; - label_t faultbuf; - u_int16_t volatile *pdma; - u_char volatile *statreg; - int espspl; - - esc->sc_active = 1; - - espspl = splbio(); - -restart_dmago: - nofault = (int *) &faultbuf; - if (setjmp((label_t *) nofault)) { - int i=0; - - nofault = (int *) 0; - statreg = esc->sc_reg + NCR_STAT * 16; - for (;;) { - if (*statreg & 0x80) { - goto gotintr; - } - - if (esp_have_dreq(esc)) { - break; - } - - DELAY(1); - if (i++ > 10000) - panic("esp_dma_go: Argh!"); - } - goto restart_dmago; - } - - statreg = esc->sc_reg + NCR_STAT * 16; - pdma = (u_int16_t *) (esc->sc_reg + 0x100); - -#define WAIT while (!esp_have_dreq(esc)) if (*statreg & 0x80) goto gotintr - - if (esc->sc_datain == 0) { - while (esc->sc_pdmalen) { - WAIT; - __splvm(); *pdma = *(esc->sc_pdmaddr)++; __splbio(); - esc->sc_pdmalen -= 2; - } - if (esc->sc_pad) { - unsigned short us; - unsigned char *c; - c = (unsigned char *) esc->sc_pdmaddr; - us = *c; - WAIT; - __splvm(); *pdma = us; __splbio(); - } - } else { - while (esc->sc_pdmalen) { - WAIT; - __splvm(); *(esc->sc_pdmaddr)++ = *pdma; __splbio(); - esc->sc_pdmalen -= 2; - } - if (esc->sc_pad) { - unsigned short us; - unsigned char *c; - WAIT; - __splvm(); us = *pdma; __splbio(); - c = (unsigned char *) esc->sc_pdmaddr; - *c = us & 0xff; - } - } -#undef WAIT - nofault = (int *) 0; - - if ((*statreg & 0x80) == 0) { - splx(espspl); - return; - } - -gotintr: - ncr53c9x_intr(sc); - splx(espspl); -} - -int -esp_intr(void *v) -{ - struct esp_softc *esc = (struct esp_softc *)v; - - if (esc->sc_reg[NCR_STAT * 16] & NCRSTAT_INT) - return (ncr53c9x_intr(v)); - - return (0); -} diff --git a/sys/arch/mac68k/dev/espvar.h b/sys/arch/mac68k/dev/espvar.h deleted file mode 100644 index 312aaddc1a8..00000000000 --- a/sys/arch/mac68k/dev/espvar.h +++ /dev/null @@ -1,54 +0,0 @@ -/* $OpenBSD: espvar.h,v 1.7 2005/07/23 16:28:19 martin Exp $ */ -/* $NetBSD: espvar.h,v 1.16 1996/10/13 02:59:50 christos Exp $ */ - -/* - * Copyright (c) 1997 Allen Briggs. - * 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 Peter Galbavy. - * 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. - */ - -struct esp_softc { - struct ncr53c9x_softc sc_ncr53c9x; /* glue to MI code */ - bus_space_tag_t sc_tag; - bus_space_handle_t sc_bsh; - struct via2hand sc_ih; - - volatile u_char *sc_reg; /* the registers */ - - u_char irq_mask; /* mask for clearing IRQ */ - - int sc_active; /* Pseudo-DMA state vars */ - int sc_datain; - size_t sc_dmasize; - char **sc_dmaaddr; - size_t *sc_dmalen; - int sc_tc; /* only used in non-quick */ - u_int16_t *sc_pdmaddr; /* only used in quick */ - int sc_pdmalen; /* only used in quick */ - size_t sc_prevdmasize; /* only used in quick */ - int sc_pad; /* only used in quick */ -}; diff --git a/sys/arch/mac68k/dev/grf_iv.c b/sys/arch/mac68k/dev/grf_iv.c deleted file mode 100644 index 08d12e94521..00000000000 --- a/sys/arch/mac68k/dev/grf_iv.c +++ /dev/null @@ -1,398 +0,0 @@ -/* $OpenBSD: grf_iv.c,v 1.42 2007/09/17 01:33:32 krw Exp $ */ -/* $NetBSD: grf_iv.c,v 1.17 1997/02/20 00:23:27 scottr Exp $ */ - -/* - * Copyright (C) 1998 Scott Reynolds - * 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. 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. - */ -/* - * Copyright (c) 1995 Allen Briggs. 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 Allen Briggs. - * 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. - */ - -/* - * Graphics display driver for the Macintosh internal video for machines - * that don't map it into a fake nubus card. - */ - -#include <sys/param.h> -#include <sys/device.h> -#include <sys/systm.h> -#include <sys/malloc.h> - -#include <machine/autoconf.h> -#include <machine/bus.h> -#include <machine/cpu.h> -#include <machine/viareg.h> - -#include <uvm/uvm_extern.h> - -#include <mac68k/dev/nubus.h> -#include <mac68k/dev/obiovar.h> - -#include <dev/wscons/wsdisplayvar.h> -#include <dev/rasops/rasops.h> -#include <mac68k/dev/macfbvar.h> - -extern u_int32_t mac68k_vidphys; -extern u_int32_t mac68k_vidlen; -extern long videoaddr; -extern long videorowbytes; -extern long videobitdepth; -extern u_long videosize; - -int macfb_obio_match(struct device *, void *, void *); -void macfb_obio_attach(struct device *, struct device *, void *); - -struct cfattach macfb_obio_ca = { - sizeof(struct macfb_softc), macfb_obio_match, macfb_obio_attach -}; - -#define DAFB_BASE 0xf9000000 -#define DAFB_CONTROL_BASE 0xf9800000 -#define DAFB_CMAP_BASE 0xf9800200 -#define CIVIC_BASE 0x50100000 -#define CIVIC_CONTROL_BASE 0x50036000 -#define VALKYRIE_BASE 0xf9000000 -#define VALKYRIE_CONTROL_BASE 0x50f2a000 - -void dafb_setcolor(void *, u_int, u_int); - -int -macfb_obio_match(struct device *parent, void *vcf, void *aux) -{ - struct obio_attach_args *oa = (struct obio_attach_args *)aux; - bus_space_handle_t bsh; - static int found; - - if (found != 0) - return (0); - - found = 1; - - switch (current_mac_model->class) { - case MACH_CLASSQ2: - if (current_mac_model->machineid != MACH_MACLC575) - break; - - /* - * Note: the only system in this class that does not have - * the Valkyrie chip -- at least, that we know of -- is - * the Performa/LC 57x series. This system has a version - * of the DAFB controller, instead. - * - * If this assumption proves false, we'll have to be more - * intelligent here. - */ - /*FALLTHROUGH*/ - case MACH_CLASSQ: - /* - * Assume DAFB for all of these, unless we can't - * access the memory. - */ - if (bus_space_map(oa->oa_tag, DAFB_CONTROL_BASE, 0x120, 0, - &bsh) != 0) - return (0); - - if (mac68k_bus_space_probe(oa->oa_tag, bsh, 0x1c, 4) == 0 || - mac68k_bus_space_probe(oa->oa_tag, bsh, 0x104, 4) == 0) - found = 0; - - bus_space_unmap(oa->oa_tag, bsh, 0x120); - break; - case MACH_CLASSAV: - break; - case MACH_CLASSIIci: - case MACH_CLASSIIsi: - if (mac68k_vidlen == 0 || - (via2_reg(rMonitor) & RBVMonitorMask) == RBVMonIDNone) - found = 0; - break; - default: - if (mac68k_vidlen == 0) - found = 0; - break; - } - - return (found); -} - -void -macfb_obio_attach(struct device *parent, struct device *self, void *aux) -{ - struct obio_attach_args *oa = (struct obio_attach_args *) aux; - struct macfb_softc *sc = (struct macfb_softc *)self; - u_long length; - u_int32_t vbase1, vbase2; - struct macfb_devconfig *dc; - - sc->card_id = 0; - sc->sc_tag = oa->oa_tag; - - dc = malloc(sizeof(*dc), M_DEVBUF, M_WAITOK | M_ZERO); - - switch (current_mac_model->class) { - case MACH_CLASSQ2: - if (current_mac_model->machineid != MACH_MACLC575) { - sc->sc_basepa = VALKYRIE_BASE; - length = 0x00100000; /* 1MB */ - - if (sc->sc_basepa <= mac68k_vidphys && - mac68k_vidphys < (sc->sc_basepa + length)) - sc->sc_fbofs = mac68k_vidphys - sc->sc_basepa; - else - sc->sc_fbofs = 0; - -#ifdef DEBUG - printf(" @ %lx", sc->sc_basepa + sc->sc_fbofs); -#endif - - if (bus_space_map(sc->sc_tag, VALKYRIE_CONTROL_BASE, - 0x40, 0, &sc->sc_regh) != 0) { - printf(": can't map Valkyrie registers\n"); - free(dc, M_DEVBUF); - return; - } - /* Disable interrupts */ - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0x18, 0x1); - bus_space_unmap(sc->sc_tag, sc->sc_regh, 0x40); - - printf(": Valkyrie\n"); - break; - } - /* - * Note: the only system in this class that does not have - * the Valkyrie chip -- at least, that we know of -- is - * the Performa/LC 57x series. This system has a version - * of the DAFB controller, instead. - * - * If this assumption proves false, we'll have to be more - * intelligent here. - */ - /*FALLTHROUGH*/ - case MACH_CLASSQ: - if (bus_space_map(sc->sc_tag, DAFB_CONTROL_BASE, 0x120, 0, - &sc->sc_regh)) { - printf(": can't map DAFB registers\n"); - free(dc, M_DEVBUF); - return; - } - - sc->sc_basepa = DAFB_BASE; - length = 0x00100000; /* 1MB */ - - /* Compute the current frame buffer offset */ - vbase1 = bus_space_read_4(sc->sc_tag, sc->sc_regh, 0x0) & 0xfff; - - /* - * XXX The following exists because the DAFB v7 in these - * systems doesn't return reasonable values to use for fbofs. - * Ken'ichi Ishizaka gets credit for this hack. (sar 19990426) - * (Does this get us the correct result for _all_ DAFB- - * equipped systems and monitor combinations? It seems - * possible, if not likely...) - */ - switch (current_mac_model->machineid) { - case MACH_MACLC475: - case MACH_MACLC475_33: - case MACH_MACLC575: - case MACH_MACQ605: - case MACH_MACQ605_33: - vbase1 &= 0x3f; - break; - } - vbase2 = bus_space_read_4(sc->sc_tag, sc->sc_regh, 0x4) & 0xf; - sc->sc_fbofs = (vbase1 << 9) | (vbase2 << 5); - -#ifdef DEBUG - printf(" @ %lx", sc->sc_basepa + sc->sc_fbofs); -#endif - - /* Disable interrupts */ - bus_space_write_4(sc->sc_tag, sc->sc_regh, 0x104, 0); - - /* Clear any pending interrupts */ - bus_space_write_4(sc->sc_tag, sc->sc_regh, 0x10C, 0); - bus_space_write_4(sc->sc_tag, sc->sc_regh, 0x110, 0); - bus_space_write_4(sc->sc_tag, sc->sc_regh, 0x114, 0); - - printf(": DAFB, monitor sense %x\n", - (bus_space_read_4(sc->sc_tag, sc->sc_regh, 0x1c) & 0x7)); - - bus_space_unmap(sc->sc_tag, sc->sc_regh, 0x120); - - if (bus_space_map(sc->sc_tag, DAFB_CMAP_BASE, 0x20, 0, - &sc->sc_regh) == 0) { - dc->dc_cmapregs = (vaddr_t)bus_space_vaddr(sc->sc_tag, - sc->sc_regh); - dc->dc_setcolor = dafb_setcolor; - } - - break; - case MACH_CLASSAV: - sc->sc_basepa = CIVIC_BASE; - length = 0x00200000; /* 2MB */ - - if (sc->sc_basepa <= mac68k_vidphys && - mac68k_vidphys < (sc->sc_basepa + length)) - sc->sc_fbofs = mac68k_vidphys - sc->sc_basepa; - else - sc->sc_fbofs = 0; - -#ifdef DEBUG - printf(" @ %lx", sc->sc_basepa + sc->sc_fbofs); -#endif - - if (bus_space_map(sc->sc_tag, CIVIC_CONTROL_BASE, PAGE_SIZE, - 0, &sc->sc_regh) != 0) { - printf(": can't map Civic registers\n"); - free(dc, M_DEVBUF); - return; - } - - /* Disable interrupts */ - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0x120, 0); - bus_space_unmap(sc->sc_tag, sc->sc_regh, PAGE_SIZE); - - printf(": Civic\n"); - break; - case MACH_CLASSIIci: - case MACH_CLASSIIsi: - sc->sc_basepa = trunc_page(mac68k_vidphys); - sc->sc_fbofs = m68k_page_offset(mac68k_vidphys); - length = mac68k_vidlen + sc->sc_fbofs; - -#ifdef DEBUG - printf(" @ %lx: RBV", sc->sc_basepa + sc->sc_fbofs); - switch (via2_reg(rMonitor) & RBVMonitorMask) { - case RBVMonIDBWP: - printf(", 15\" monochrome portrait"); - break; - case RBVMonIDRGB12: - printf(", 12\" color"); - break; - case RBVMonIDRGB15: - printf(", 15\" color"); - break; - case RBVMonIDStd: - printf(", Macintosh II"); - break; - default: - printf(", unrecognized"); - break; - } - printf(" display\n"); -#else - printf(": RBV\n"); -#endif - - break; - default: - sc->sc_basepa = trunc_page(mac68k_vidphys); - sc->sc_fbofs = m68k_page_offset(mac68k_vidphys); - length = mac68k_vidlen + sc->sc_fbofs; - -#ifdef DEBUG - printf(" @ %lx:", sc->sc_basepa + sc->sc_fbofs); -#endif - printf(": On-board video\n"); - break; - } - - if (bus_space_map(sc->sc_tag, sc->sc_basepa, length, 0, - &sc->sc_handle)) { - printf("%s: failed to map video RAM\n", sc->sc_dev.dv_xname); - free(dc, M_DEVBUF); - return; - } - - if (sc->sc_basepa <= mac68k_vidphys && - mac68k_vidphys < (sc->sc_basepa + length)) - videoaddr = - (vaddr_t)bus_space_vaddr(sc->sc_tag, sc->sc_handle) + - sc->sc_fbofs; - - dc->dc_vaddr = (vaddr_t)bus_space_vaddr(sc->sc_tag, sc->sc_handle); - dc->dc_paddr = sc->sc_basepa; - dc->dc_offset = sc->sc_fbofs; - dc->dc_wid = videosize & 0xffff; - dc->dc_ht = (videosize >> 16) & 0xffff; - dc->dc_depth = videobitdepth; - dc->dc_rowbytes = videorowbytes; - dc->dc_size = dc->dc_ht * dc->dc_rowbytes; - - /* Perform common video attachment. */ - macfb_attach_common(sc, dc); -} - -/* - * Basic indexed modes palette handling. - */ - -void -dafb_setcolor(void *v, u_int start, u_int end) -{ - struct macfb_devconfig *dc = v; - u_int i; - u_int8_t *c; - - c = dc->dc_cmap; - - /* - * DAFB can not start a colormap update at a color index different - * than zero, so we need to reprogram all slots below the requested - * range. - */ - *(volatile u_int32_t *)(dc->dc_cmapregs) = 0; - for (i = 0; i < end; i++) { - *(volatile u_int8_t *)(dc->dc_cmapregs + 0x13) = *c++; - *(volatile u_int8_t *)(dc->dc_cmapregs + 0x13) = *c++; - *(volatile u_int8_t *)(dc->dc_cmapregs + 0x13) = *c++; - } -} diff --git a/sys/arch/mac68k/dev/grf_mv.c b/sys/arch/mac68k/dev/grf_mv.c deleted file mode 100644 index 19d3231ba3f..00000000000 --- a/sys/arch/mac68k/dev/grf_mv.c +++ /dev/null @@ -1,799 +0,0 @@ -/* $OpenBSD: grf_mv.c,v 1.35 2007/09/17 01:33:33 krw Exp $ */ -/* $NetBSD: grf_nubus.c,v 1.62 2001/01/22 20:27:02 briggs Exp $ */ - -/* - * Copyright (c) 1995 Allen Briggs. 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. 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. - */ -/* - * Device-specific routines for handling Nubus-based video cards. - */ - -#include <sys/param.h> - -#include <sys/device.h> -#include <sys/ioctl.h> -#include <sys/file.h> -#include <sys/malloc.h> -#include <sys/proc.h> -#include <sys/systm.h> - -#include <machine/bus.h> -#include <machine/cpu.h> -#include <machine/viareg.h> - -#include <mac68k/dev/nubus.h> - -#include <dev/wscons/wsdisplayvar.h> -#include <dev/rasops/rasops.h> -#include <mac68k/dev/macfbvar.h> - -int macfb_nubus_match(struct device *, void *, void *); -void macfb_nubus_attach(struct device *, struct device *, void *); - -struct cfattach macfb_nubus_ca = { - sizeof(struct macfb_softc), macfb_nubus_match, macfb_nubus_attach -}; - -void load_image_data(caddr_t data, struct image_data *image); - -int grfmv_intr_generic_write1(void *vsc); -int grfmv_intr_generic_write4(void *vsc); -int grfmv_intr_generic_or4(void *vsc); - -int grfmv_intr_cb264(void *vsc); -int grfmv_intr_cb364(void *vsc); -int grfmv_intr_cmax(void *vsc); -int grfmv_intr_cti(void *vsc); -int grfmv_intr_radius(void *vsc); -int grfmv_intr_radius24(void *vsc); -int grfmv_intr_supermacgfx(void *vsc); -int grfmv_intr_lapis(void *vsc); -int grfmv_intr_formac(void *vsc); -int grfmv_intr_vimage(void *vsc); -int grfmv_intr_gvimage(void *vsc); -int grfmv_intr_radius_gsc(void *vsc); -int grfmv_intr_radius_gx(void *vsc); -int grfmv_intr_relax_200(void *); -int grfmv_intr_mvc(void *); -int grfmv_intr_viltro_340(void *); - -#define CARD_NAME_LEN 64 - -void -load_image_data(caddr_t data, struct image_data *image) -{ - bcopy(data , &image->size, 4); - bcopy(data + 4, &image->offset, 4); - bcopy(data + 8, &image->rowbytes, 2); - bcopy(data + 10, &image->top, 2); - bcopy(data + 12, &image->left, 2); - bcopy(data + 14, &image->bottom, 2); - bcopy(data + 16, &image->right, 2); - bcopy(data + 18, &image->version, 2); - bcopy(data + 20, &image->packType, 2); - bcopy(data + 22, &image->packSize, 4); - bcopy(data + 26, &image->hRes, 4); - bcopy(data + 30, &image->vRes, 4); - bcopy(data + 34, &image->pixelType, 2); - bcopy(data + 36, &image->pixelSize, 2); - bcopy(data + 38, &image->cmpCount, 2); - bcopy(data + 40, &image->cmpSize, 2); - bcopy(data + 42, &image->planeBytes, 4); -} - -int -macfb_nubus_match(struct device *parent, void *vcf, void *aux) -{ - struct nubus_attach_args *na = (struct nubus_attach_args *)aux; - - if (na->category != NUBUS_CATEGORY_DISPLAY) - return (0); - - if (na->type != NUBUS_TYPE_VIDEO) - return (0); - - if (na->drsw != NUBUS_DRSW_APPLE) - return (0); - - /* - * If we've gotten this far, then we're dealing with a real-live - * Apple QuickDraw-compatible display card resource. Now, how to - * determine that this is an active resource??? Dunno. But we'll - * proceed like it is. - */ - return (1); -} - -void -macfb_nubus_attach(struct device *parent, struct device *self, void *aux) -{ - struct nubus_attach_args *na = (struct nubus_attach_args *)aux; - struct macfb_softc *sc = (struct macfb_softc *)self; - struct image_data image_store, image; - char cardname[CARD_NAME_LEN]; - nubus_dirent dirent; - nubus_dir dir, mode_dir, board_dir; - int mode; - struct macfb_devconfig *dc; - - bcopy(na->fmt, &sc->sc_slot, sizeof(nubus_slot)); - - sc->sc_tag = na->na_tag; - sc->card_id = na->drhw; - sc->sc_basepa = (bus_addr_t)NUBUS_SLOT2PA(na->slot); - sc->sc_fbofs = 0; - - if (bus_space_map(sc->sc_tag, sc->sc_basepa, NBMEMSIZE, - 0, &sc->sc_regh)) { - printf(": failed to map slot %d\n", na->slot); - return; - } - - nubus_get_main_dir(&sc->sc_slot, &dir); - - if (nubus_find_rsrc(sc->sc_tag, sc->sc_regh, - &sc->sc_slot, &dir, na->rsrcid, &dirent) <= 0) { - printf(": failed to get board rsrc.\n"); - goto bad; - } - - nubus_get_dir_from_rsrc(&sc->sc_slot, &dirent, &board_dir); - - if (nubus_find_rsrc(sc->sc_tag, sc->sc_regh, - &sc->sc_slot, &board_dir, NUBUS_RSRC_TYPE, &dirent) <= 0) - if ((na->rsrcid != 128) || - (nubus_find_rsrc(sc->sc_tag, sc->sc_regh, - &sc->sc_slot, &dir, 129, &dirent) <= 0)) { - printf(": failed to get board rsrc.\n"); - goto bad; - } - - mode = NUBUS_RSRC_FIRSTMODE; - if (nubus_find_rsrc(sc->sc_tag, sc->sc_regh, - &sc->sc_slot, &board_dir, mode, &dirent) <= 0) { - printf(": probe failed to get board rsrc.\n"); - goto bad; - } - - nubus_get_dir_from_rsrc(&sc->sc_slot, &dirent, &mode_dir); - - if (nubus_find_rsrc(sc->sc_tag, sc->sc_regh, - &sc->sc_slot, &mode_dir, VID_PARAMS, &dirent) <= 0) { - printf(": probe failed to get mode dir.\n"); - goto bad; - } - - if (nubus_get_ind_data(sc->sc_tag, sc->sc_regh, &sc->sc_slot, - &dirent, (caddr_t)&image_store, sizeof(struct image_data)) <= 0) { - printf(": probe failed to get indirect mode data.\n"); - goto bad; - } - - /* Need to load display info (and driver?), etc... (?) */ - - load_image_data((caddr_t)&image_store, &image); - - dc = malloc(sizeof(*dc), M_DEVBUF, M_WAITOK | M_ZERO); - - dc->dc_vaddr = (vaddr_t)bus_space_vaddr(sc->sc_tag, sc->sc_handle); - dc->dc_paddr = sc->sc_basepa; - dc->dc_offset = image.offset; - dc->dc_wid = image.right - image.left; - dc->dc_ht = image.bottom - image.top; - dc->dc_depth = image.pixelSize; - dc->dc_rowbytes = image.rowbytes; - dc->dc_size = dc->dc_ht * dc->dc_rowbytes; - - /* Perform common video attachment. */ - - strlcpy(cardname, nubus_get_card_name(sc->sc_tag, sc->sc_regh, - &sc->sc_slot), sizeof cardname); - printf(": %s\n", cardname); - - if (sc->card_id == NUBUS_DRHW_TFB) { - /* - * This is the Toby card, but apparently some manufacturers - * (like Cornerstone) didn't bother to get/use their own - * value here, even though the cards are different, so we - * so we try to differentiate here. - */ - if (strncmp(cardname, "Samsung 768", 11) == 0) - sc->card_id = NUBUS_DRHW_SAM768; -#ifdef DEBUG - else if (strncmp(cardname, "Toby frame", 10) != 0) - printf("%s: This display card pretends to be a TFB!\n", - sc->sc_dev.dv_xname); -#endif - } - - switch (sc->card_id) { - case NUBUS_DRHW_TFB: - case NUBUS_DRHW_M2HRVC: - case NUBUS_DRHW_PVC: - sc->cli_offset = 0xa0000; - sc->cli_value = 0; - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_generic_write1, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_WVC: - sc->cli_offset = 0xa00000; - sc->cli_value = 0; - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_generic_write1, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_COLORMAX: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_cmax, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_SE30: - /* Do nothing--SE/30 interrupts are disabled */ - break; - case NUBUS_DRHW_MDC: - sc->cli_offset = 0x200148; - sc->cli_value = 1; - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_generic_write4, sc, - sc->sc_dev.dv_xname); - - /* Enable interrupts; to disable, write 0x7 to this location */ - bus_space_write_4(sc->sc_tag, sc->sc_regh, 0x20013C, 5); - break; - case NUBUS_DRHW_CB264: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_cb264, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_CB364: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_cb364, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_RPC8: - sc->cli_offset = 0xfdff8f; - sc->cli_value = 0xff; - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_generic_write1, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_RPC8XJ: - sc->cli_value = 0x66; - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_radius, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_RPC24X: - case NUBUS_DRHW_BOOGIE: - sc->cli_value = 0x64; - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_radius, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_RPC24XP: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_radius24, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_RADGSC: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_radius_gsc, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_RDCGX: - case NUBUS_DRHW_MPGX: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_radius_gx, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_FIILX: - case NUBUS_DRHW_FIISXDSP: - case NUBUS_DRHW_FUTURASX: - sc->cli_offset = 0xf05000; - sc->cli_value = 0x80; - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_generic_write1, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_SAM768: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_cti, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_SUPRGFX: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_supermacgfx, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_SPECTRM8: - sc->cli_offset = 0x0de178; - sc->cli_value = 0x80; - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_generic_or4, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_LAPIS: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_lapis, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_RELAX200: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_relax_200, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_BAER: - case NUBUS_DRHW_FORMAC: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_formac, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_ROPS24LXI: - case NUBUS_DRHW_ROPS24XLTV: - case NUBUS_DRHW_ROPS24MXTV: - case NUBUS_DRHW_THUNDER24: - sc->cli_offset = 0xfb0010; - sc->cli_value = 0x00; - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_generic_write4, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_ROPSPPGT: - sc->cli_offset = 0xf50010; - sc->cli_value = 0x02; - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_generic_write4, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_VIMAGE: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_vimage, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_GVIMAGE: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_gvimage, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_MC2124NB: - sc->cli_offset = 0xfd1000; - sc->cli_value = 0x00; - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_generic_write4, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_MICRON: - sc->cli_offset = 0xa00014; - sc->cli_value = 0; - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_generic_write4, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_MVC: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_mvc, sc, - sc->sc_dev.dv_xname); - break; - case NUBUS_DRHW_VILTRO340: - add_nubus_intr(na->slot, IPL_TTY, grfmv_intr_viltro_340, sc, - sc->sc_dev.dv_xname); - break; - default: - printf("%s: Unknown video card ID 0x%x\n", - sc->sc_dev.dv_xname, sc->card_id); - goto bad; - } - - /* Perform common video attachment. */ - macfb_attach_common(sc, dc); - return; - -bad: - bus_space_unmap(sc->sc_tag, sc->sc_regh, NBMEMSIZE); -} - -/* Interrupt handlers... */ -/* - * Generic routine to clear interrupts for cards where it simply takes - * a MOV.B to clear the interrupt. The offset and value of this byte - * varies between cards. - */ -/*ARGSUSED*/ -int -grfmv_intr_generic_write1(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - - bus_space_write_1(sc->sc_tag, sc->sc_regh, - sc->cli_offset, (u_int8_t)sc->cli_value); - return (1); -} - -/* - * Generic routine to clear interrupts for cards where it simply takes - * a MOV.L to clear the interrupt. The offset and value of this byte - * varies between cards. - */ -/*ARGSUSED*/ -int -grfmv_intr_generic_write4(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - - bus_space_write_4(sc->sc_tag, sc->sc_regh, - sc->cli_offset, sc->cli_value); - return (1); -} - -/* - * Generic routine to clear interrupts for cards where it simply takes - * an OR.L to clear the interrupt. The offset and value of this byte - * varies between cards. - */ -/*ARGSUSED*/ -int -grfmv_intr_generic_or4(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - unsigned long scratch; - - scratch = bus_space_read_4(sc->sc_tag, sc->sc_regh, sc->cli_offset); - scratch |= 0x80; - bus_space_write_4(sc->sc_tag, sc->sc_regh, sc->cli_offset, scratch); - return (1); -} - -/* - * Routine to clear interrupts for the Radius PrecisionColor 8xj card. - */ -/*ARGSUSED*/ -int -grfmv_intr_radius(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - u_int8_t c; - - c = sc->cli_value; - - c |= 0x80; - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0xd00403, c); - c &= 0x7f; - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0xd00403, c); - return (1); -} - -/* - * Routine to clear interrupts for the Radius PrecisionColor 24Xp card. - * Is this what the 8xj routine is doing, too? - */ -/*ARGSUSED*/ -int -grfmv_intr_radius24(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - u_int8_t c; - - c = 0x80 | bus_space_read_1(sc->sc_tag, sc->sc_regh, 0xfffd8); - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0xd00403, c); - c &= 0x7f; - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0xd00403, c); - return (1); -} - -/* - * Routine to clear interrupts on Samsung 768x1006 video controller. - * This controller was manufactured by Cornerstone Technology, Inc., - * now known as Cornerstone Imaging. - * - * To clear this interrupt, we apparently have to set, then clear, - * bit 2 at byte offset 0x80000 from the card's base. - * Information for this provided by Brad Salai <bsalai@servtech.com> - */ -/*ARGSUSED*/ -int -grfmv_intr_cti(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - u_int8_t c; - - c = bus_space_read_1(sc->sc_tag, sc->sc_regh, 0x80000); - c |= 0x02; - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0x80000, c); - c &= 0xfd; - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0x80000, c); - return (1); -} - -/*ARGSUSED*/ -int -grfmv_intr_cb264(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - volatile char *slotbase; - - slotbase = (volatile char *)bus_space_vaddr(sc->sc_tag, sc->sc_handle); - asm volatile(" movl %0,a0 - movl a0@(0xff6028),d0 - andl #0x2,d0 - beq _mv_intr0 - movql #0x3,d0 - _mv_intr0: - movl a0@(0xff600c),d1 - andl #0x3,d1 - cmpl d1,d0 - beq _mv_intr_fin - movl d0,a0@(0xff600c) - nop - tstb d0 - beq _mv_intr1 - movl #0x0002,a0@(0xff6040) - movl #0x0102,a0@(0xff6044) - movl #0x0105,a0@(0xff6048) - movl #0x000e,a0@(0xff604c) - movl #0x001c,a0@(0xff6050) - movl #0x00bc,a0@(0xff6054) - movl #0x00c3,a0@(0xff6058) - movl #0x0061,a0@(0xff605c) - movl #0x0012,a0@(0xff6060) - bra _mv_intr_fin - _mv_intr1: - movl #0x0002,a0@(0xff6040) - movl #0x0209,a0@(0xff6044) - movl #0x020c,a0@(0xff6048) - movl #0x000f,a0@(0xff604c) - movl #0x0027,a0@(0xff6050) - movl #0x00c7,a0@(0xff6054) - movl #0x00d7,a0@(0xff6058) - movl #0x006b,a0@(0xff605c) - movl #0x0029,a0@(0xff6060) - _mv_intr_fin: - movl #0x1,a0@(0xff6014)" - : : "g" (slotbase) : "a0","d0","d1"); - return (1); -} - -/* - * Support for the Colorboard 364 might be more complex than it needs to - * be. If we can find more information about this card, this might be - * significantly simplified. Contributions welcome... :-) - */ -/*ARGSUSED*/ -int -grfmv_intr_cb364(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - volatile char *slotbase; - - slotbase = (volatile char *)bus_space_vaddr(sc->sc_tag, sc->sc_handle); - asm volatile(" movl %0,a0 - movl a0@(0xfe6028),d0 - andl #0x2,d0 - beq _cb364_intr4 - movql #0x3,d0 - movl a0@(0xfe6018),d1 - movl #0x3,a0@(0xfe6018) - movw a0@(0xfe7010),d2 - movl d1,a0@(0xfe6018) - movl a0@(0xfe6020),d1 - btst #0x06,d2 - beq _cb364_intr0 - btst #0x00,d1 - beq _cb364_intr5 - bsr _cb364_intr1 - bra _cb364_intr_out - _cb364_intr0: - btst #0x00,d1 - bne _cb364_intr5 - bsr _cb364_intr1 - bra _cb364_intr_out - _cb364_intr1: - movl d0,a0@(0xfe600c) - nop - tstb d0 - beq _cb364_intr3 - movl #0x0002,a0@(0xfe6040) - movl #0x0105,a0@(0xfe6048) - movl #0x000e,a0@(0xfe604c) - movl #0x00c3,a0@(0xfe6058) - movl #0x0061,a0@(0xfe605c) - btst #0x06,d2 - beq _cb364_intr2 - movl #0x001c,a0@(0xfe6050) - movl #0x00bc,a0@(0xfe6054) - movl #0x0012,a0@(0xfe6060) - movl #0x000e,a0@(0xfe6044) - movl #0x00c3,a0@(0xfe6064) - movl #0x0061,a0@(0xfe6020) - rts - _cb364_intr2: - movl #0x0016,a0@(0xfe6050) - movl #0x00b6,a0@(0xfe6054) - movl #0x0011,a0@(0xfe6060) - movl #0x0101,a0@(0xfe6044) - movl #0x00bf,a0@(0xfe6064) - movl #0x0001,a0@(0xfe6020) - rts - _cb364_intr3: - movl #0x0002,a0@(0xfe6040) - movl #0x0209,a0@(0xfe6044) - movl #0x020c,a0@(0xfe6048) - movl #0x000f,a0@(0xfe604c) - movl #0x0027,a0@(0xfe6050) - movl #0x00c7,a0@(0xfe6054) - movl #0x00d7,a0@(0xfe6058) - movl #0x006b,a0@(0xfe605c) - movl #0x0029,a0@(0xfe6060) - oril #0x0040,a0@(0xfe6064) - movl #0x0000,a0@(0xfe6020) - rts - _cb364_intr4: - movq #0x00,d0 - _cb364_intr5: - movl a0@(0xfe600c),d1 - andl #0x3,d1 - cmpl d1,d0 - beq _cb364_intr_out - bsr _cb364_intr1 - _cb364_intr_out: - movl #0x1,a0@(0xfe6014) - _cb364_intr_quit: - " : : "g" (slotbase) : "a0","d0","d1","d2"); - return (1); -} - -/* - * Interrupt clearing routine for SuperMac GFX card. - */ -/*ARGSUSED*/ -int -grfmv_intr_supermacgfx(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - u_int8_t dummy; - - dummy = bus_space_read_1(sc->sc_tag, sc->sc_regh, 0xE70D3); - return (1); -} - -/* - * Routine to clear interrupts for the Sigma Designs ColorMax card. - */ -/*ARGSUSED*/ -int -grfmv_intr_cmax(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - u_int32_t dummy; - - dummy = bus_space_read_4(sc->sc_tag, sc->sc_regh, 0xf501c); - dummy = bus_space_read_4(sc->sc_tag, sc->sc_regh, 0xf5018); - return (1); -} - -/* - * Routine to clear interrupts for the Lapis ProColorServer 8 PDS card - * (for the SE/30). - */ -/*ARGSUSED*/ -int -grfmv_intr_lapis(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0xff7000, 0x08); - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0xff7000, 0x0C); - return (1); -} - -/* - * Routine to clear interrupts for the Formac ProNitron 80.IVb - * and Color Card II - */ -/*ARGSUSED*/ -int -grfmv_intr_formac(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - u_int8_t dummy; - - dummy = bus_space_read_1(sc->sc_tag, sc->sc_regh, 0xde80db); - dummy = bus_space_read_1(sc->sc_tag, sc->sc_regh, 0xde80d3); - return (1); -} - -/* - * Routine to clear interrupts for the Vimage by Interware Co., Ltd. - */ -/*ARGSUSED*/ -int -grfmv_intr_vimage(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0x800000, 0x67); - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0x800000, 0xE7); - return (1); -} - -/* - * Routine to clear interrupts for the Grand Vimage by Interware Co., Ltd. - */ -/*ARGSUSED*/ -int -grfmv_intr_gvimage(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - u_int8_t dummy; - - dummy = bus_space_read_1(sc->sc_tag, sc->sc_regh, 0xf00000); - return (1); -} - -/* - * Routine to clear interrupts for the Radius GS/C - */ -/*ARGSUSED*/ -int -grfmv_intr_radius_gsc(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - u_int8_t dummy; - - dummy = bus_space_read_1(sc->sc_tag, sc->sc_regh, 0xfb802); - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0xfb802, 0xff); - return (1); -} - -/* - * Routine to clear interrupts for the Radius GS/C - */ -/*ARGSUSED*/ -int -grfmv_intr_radius_gx(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0x600000, 0x00); - bus_space_write_1(sc->sc_tag, sc->sc_regh, 0x600000, 0x20); - return (1); -} - -/* - * Routine to clear interrupts for the Relax 19" model 200. - */ -/*ARGSUSED*/ -int -grfmv_intr_relax_200(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - - /* The board ROM driver code has a tst.l here. */ - bus_space_read_4(sc->sc_tag, sc->sc_handle, 0x000D0040); - return (1); -} - -/* - * Routine to clear interrupts for the Apple Mac II Monochrome Video Card. - */ -/*ARGSUSED*/ -int -grfmv_intr_mvc(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - - bus_space_write_4(sc->sc_tag, sc->sc_handle, 0x00040000, 0); - bus_space_write_4(sc->sc_tag, sc->sc_handle, 0x00020000, 0); - return (1); -} - -/* - * Routine to clear interrupts for the VillageTronic Mac Picasso 340. - */ -/*ARGSUSED*/ -int -grfmv_intr_viltro_340(void *vsc) -{ - struct macfb_softc *sc = (struct macfb_softc *)vsc; - - /* Yes, two read accesses to the same spot. */ - bus_space_read_1(sc->sc_tag, sc->sc_handle, 0x0500); - bus_space_read_1(sc->sc_tag, sc->sc_handle, 0x0500); - return (1); -} diff --git a/sys/arch/mac68k/dev/if_ae.c b/sys/arch/mac68k/dev/if_ae.c deleted file mode 100644 index b16725036f7..00000000000 --- a/sys/arch/mac68k/dev/if_ae.c +++ /dev/null @@ -1,200 +0,0 @@ -/* $OpenBSD: if_ae.c,v 1.34 2007/01/22 13:17:45 martin Exp $ */ -/* $NetBSD: if_ae.c,v 1.78 2006/09/09 06:25:08 tsutsui Exp $ */ - -/* - * Device driver for National Semiconductor DS8390/WD83C690 based ethernet - * adapters. - * - * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved. - * - * Copyright (C) 1993, David Greenman. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided that - * the above copyright and these terms are retained. Under no circumstances is - * the author responsible for the proper functioning of this software, nor does - * the author assume any responsibility for damages incurred with its use. - */ - -#include "bpfilter.h" - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/device.h> -#include <sys/mbuf.h> -#include <sys/socket.h> - -#include <net/if.h> -#include <net/if_dl.h> -#include <net/if_types.h> - -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/in_var.h> -#include <netinet/ip.h> -#include <netinet/if_ether.h> - -#include <net/if_media.h> - -#if NBPFILTER > 0 -#include <net/bpf.h> -#endif - -#include <machine/bus.h> - -#include <dev/ic/dp8390reg.h> -#include <dev/ic/dp8390var.h> -#include <mac68k/dev/if_aevar.h> - -struct cfdriver ae_cd = { - NULL, "ae", DV_IFNET -}; - -#define ETHER_PAD_LEN (ETHER_MIN_LEN - ETHER_CRC_LEN) - -int -ae_size_card_memory(bus_space_tag_t bst, bus_space_handle_t bsh, int ofs) -{ - int i1, i2, i3, i4, i8; - - /* - * banks; also assume it will generally mirror in upper banks - * if not installed. - */ - i1 = (8192 * 0); - i2 = (8192 * 1); - i3 = (8192 * 2); - i4 = (8192 * 3); - i8 = (8192 * 4); - - bus_space_write_2(bst, bsh, ofs + i8, 0x8888); - bus_space_write_2(bst, bsh, ofs + i4, 0x4444); - bus_space_write_2(bst, bsh, ofs + i3, 0x3333); - bus_space_write_2(bst, bsh, ofs + i2, 0x2222); - bus_space_write_2(bst, bsh, ofs + i1, 0x1111); - - /* - * 1) If the memory range is decoded completely, it does not - * matter what we write first: High tags written into - * the void are lost. - * 2) If the memory range is not decoded completely (banks are - * mirrored), high tags are overwritten by lower ones. - * 3) Lazy implementation of pathological cases - none found yet. - */ - - if (bus_space_read_2(bst, bsh, ofs + i1) == 0x1111 && - bus_space_read_2(bst, bsh, ofs + i2) == 0x2222 && - bus_space_read_2(bst, bsh, ofs + i3) == 0x3333 && - bus_space_read_2(bst, bsh, ofs + i4) == 0x4444 && - bus_space_read_2(bst, bsh, ofs + i8) == 0x8888) - return 8192 * 8; - - if (bus_space_read_2(bst, bsh, ofs + i1) == 0x1111 && - bus_space_read_2(bst, bsh, ofs + i2) == 0x2222 && - bus_space_read_2(bst, bsh, ofs + i3) == 0x3333 && - bus_space_read_2(bst, bsh, ofs + i4) == 0x4444) - return 8192 * 4; - - if ((bus_space_read_2(bst, bsh, ofs + i1) == 0x1111 && - bus_space_read_2(bst, bsh, ofs + i2) == 0x2222) || - (bus_space_read_2(bst, bsh, ofs + i1) == 0x3333 && - bus_space_read_2(bst, bsh, ofs + i2) == 0x4444)) - return 8192 * 2; - - if (bus_space_read_2(bst, bsh, ofs + i1) == 0x1111 || - bus_space_read_2(bst, bsh, ofs + i1) == 0x4444) - return 8192; - - return 0; -} - -/* - * Zero memory and verify that it is clear. The only difference between - * this and the default test_mem function is that the DP8390-based NuBus - * cards * apparently require word-wide writes and byte-wide reads, an - * `interesting' combination. - */ -int -ae_test_mem(struct dp8390_softc *sc) -{ - bus_space_tag_t buft = sc->sc_buft; - bus_space_handle_t bufh = sc->sc_bufh; - int i; - - bus_space_set_region_2(buft, bufh, sc->mem_start, 0, - sc->mem_size / 2); - - for (i = 0; i < sc->mem_size; ++i) { - if (bus_space_read_1(sc->sc_buft, sc->sc_bufh, i)) { - printf(": failed to clear NIC buffer at offset %x - " - "check configuration\n", (sc->mem_start + i)); - return 1; - } - } - - return 0; -} - -/* - * Copy packet from mbuf to the board memory Currently uses an extra - * buffer/extra memory copy, unless the whole packet fits in one mbuf. - * - * As in the test_mem function, we use word-wide writes. - */ -int -ae_write_mbuf(struct dp8390_softc *sc, struct mbuf *m, int buf) -{ - u_char *data, savebyte[2]; - int len, wantbyte; - u_short totlen = 0; - - wantbyte = 0; - - for (; m ; m = m->m_next) { - data = mtod(m, u_char *); - len = m->m_len; - totlen += len; - if (len > 0) { - /* Finish the last word. */ - if (wantbyte) { - savebyte[1] = *data; - bus_space_write_region_2(sc->sc_buft, - sc->sc_bufh, buf, (u_int16_t *)savebyte, 1); - buf += 2; - data++; - len--; - wantbyte = 0; - } - /* Output contiguous words. */ - if (len > 1) { - bus_space_write_region_2( - sc->sc_buft, sc->sc_bufh, - buf, (u_int16_t *)data, len >> 1); - buf += len & ~1; - data += len & ~1; - len &= 1; - } - /* Save last byte, if necessary. */ - if (len == 1) { - savebyte[0] = *data; - wantbyte = 1; - } - } - } - - len = ETHER_PAD_LEN - totlen; - if (wantbyte) { - savebyte[1] = 0; - bus_space_write_region_2(sc->sc_buft, sc->sc_bufh, - buf, (u_int16_t *)savebyte, 1); - buf += 2; - if (len > 0) - totlen++; - len--; - } - /* if sent data is shorter than EHTER_PAD_LEN, put 0 to padding */ - if (len > 0) { - bus_space_set_region_2(sc->sc_buft, sc->sc_bufh, buf, 0, - len >> 1); - totlen = ETHER_PAD_LEN; - } - return (totlen); -} diff --git a/sys/arch/mac68k/dev/if_ae_nubus.c b/sys/arch/mac68k/dev/if_ae_nubus.c deleted file mode 100644 index 46353b65501..00000000000 --- a/sys/arch/mac68k/dev/if_ae_nubus.c +++ /dev/null @@ -1,514 +0,0 @@ -/* $OpenBSD: if_ae_nubus.c,v 1.19 2009/03/29 21:53:52 sthen Exp $ */ -/* $NetBSD: if_ae_nubus.c,v 1.17 1997/05/01 18:17:16 briggs Exp $ */ - -/* - * Copyright (C) 1997 Scott Reynolds - * 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. 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. - */ -/* - * Some parts are derived from code adapted for MacBSD by Brad Parker - * <brad@fcr.com>. - * - * Currently supports: - * Apple NB Ethernet Card - * Apple NB Ethernet Card II - * Interlan A310 NuBus Ethernet card - * Cayman Systems GatorCard - * Asante MacCon II/E - * Kinetics EtherPort SE/30 - */ - -#define AE_OLD_GET_ENADDR - -#include <sys/param.h> -#include <sys/device.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/socket.h> -#include <sys/syslog.h> -#include <sys/systm.h> - -#include <net/if.h> - -#ifdef INET -#include <netinet/in.h> -#include <netinet/if_ether.h> -#endif - -#include <machine/bus.h> -#include <machine/viareg.h> - -#include <net/if_media.h> - -#include <dev/ic/dp8390reg.h> -#include <dev/ic/dp8390var.h> -#include <mac68k/dev/nubus.h> -#include <mac68k/dev/if_aevar.h> -#include <mac68k/dev/if_aereg.h> - -static int ae_nubus_match(struct device *, void *, void *); -static void ae_nubus_attach(struct device *, struct device *, void *); -static int ae_nb_card_vendor(bus_space_tag_t, bus_space_handle_t, - struct nubus_attach_args *); -static int ae_nb_get_enaddr(bus_space_tag_t, bus_space_handle_t, - struct nubus_attach_args *, u_int8_t *); -#ifdef DEBUG -static void ae_nb_watchdog(struct ifnet *); -#endif - -struct cfattach ae_nubus_ca = { - sizeof(struct dp8390_softc), ae_nubus_match, ae_nubus_attach -}; - -static int -ae_nubus_match(parent, vcf, aux) - struct device *parent; - void *vcf; - void *aux; -{ - struct nubus_attach_args *na = (struct nubus_attach_args *) aux; - bus_space_handle_t bsh; - int rv = 0; - - if (bus_space_map(na->na_tag, NUBUS_SLOT2PA(na->slot), NBMEMSIZE, - 0, &bsh)) - return (0); - - if (na->category == NUBUS_CATEGORY_NETWORK && - na->type == NUBUS_TYPE_ETHERNET) { - switch (ae_nb_card_vendor(na->na_tag, bsh, na)) { - case DP8390_VENDOR_APPLE: - case DP8390_VENDOR_ASANTE: - case DP8390_VENDOR_FARALLON: - case DP8390_VENDOR_INTERLAN: - case DP8390_VENDOR_KINETICS: - case DP8390_VENDOR_CABLETRON: - rv = 1; - break; - case DP8390_VENDOR_DAYNA: - case DP8390_VENDOR_FOCUS: - /* not supported yet */ - /* FALLTHROUGH */ - default: - rv = 0; - break; - } - } - - bus_space_unmap(na->na_tag, bsh, NBMEMSIZE); - - return (rv); -} - -/* - * Install interface into kernel networking data structures - */ -static void -ae_nubus_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct dp8390_softc *sc = (struct dp8390_softc *)self; - struct nubus_attach_args *na = (struct nubus_attach_args *) aux; -#ifdef DEBUG - struct ifnet *ifp = &sc->sc_arpcom.ac_if; -#endif - bus_space_tag_t bst; - bus_space_handle_t bsh; - int i, success; - const char *cardtype; - - bst = na->na_tag; - if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE, - 0, &bsh)) { - printf(": can't map mem space\n"); - return; - } - - sc->sc_regt = sc->sc_buft = bst; - sc->sc_flags = self->dv_cfdata->cf_flags; - - cardtype = nubus_get_card_name(bst, bsh, na->fmt); - - sc->is790 = 0; - - sc->mem_start = 0; - sc->mem_size = 0; - - success = 0; - - switch (ae_nb_card_vendor(bst, bsh, na)) { - case DP8390_VENDOR_APPLE: /* Apple-compatible cards */ - case DP8390_VENDOR_ASANTE: - /* Map register offsets */ - for (i = 0; i < 16; i++) /* reverse order, longword aligned */ - sc->sc_reg_map[i] = (15 - i) << 2; - - sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS); - if (bus_space_subregion(bst, bsh, - AE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) { - printf(": failed to map register space\n"); - break; - } - if ((sc->mem_size = ae_size_card_memory(bst, bsh, - AE_DATA_OFFSET)) == 0) { - printf(": failed to determine size of RAM.\n"); - break; - } - if (bus_space_subregion(bst, bsh, - AE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) { - printf(": failed to map register space\n"); - break; - } -#ifdef AE_OLD_GET_ENADDR - /* Get station address from on-board ROM */ - for (i = 0; i < ETHER_ADDR_LEN; ++i) - sc->sc_arpcom.ac_enaddr[i] = - bus_space_read_1(bst, bsh, (AE_ROM_OFFSET + i * 2)); -#else - if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_arpcom.ac_enaddr)) { - printf(": can't find MAC address\n"); - break; - } -#endif - - success = 1; - break; - - case DP8390_VENDOR_DAYNA: - /* Map register offsets */ - for (i = 0; i < 16; i++) /* normal order, longword aligned */ - sc->sc_reg_map[i] = i << 2; - - sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS); - if (bus_space_subregion(bst, bsh, - DP_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) { - printf(": failed to map register space\n"); - break; - } - sc->mem_size = 8192; - if (bus_space_subregion(bst, bsh, - DP_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) { - printf(": failed to map register space\n"); - break; - } -#ifdef AE_OLD_GET_ENADDR - /* Get station address from on-board ROM */ - for (i = 0; i < ETHER_ADDR_LEN; ++i) - sc->sc_arpcom.ac_enaddr[i] = - bus_space_read_1(bst, bsh, (DP_ROM_OFFSET + i * 2)); -#else - if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_arpcom.ac_enaddr)) { - printf(": can't find MAC address\n"); - break; - } -#endif - - case DP8390_VENDOR_FARALLON: - /* Map register offsets */ - for (i = 0; i < 16; i++) /* reverse order, longword aligned */ - sc->sc_reg_map[i] = (15 - i) << 2; - - sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS); - if (bus_space_subregion(bst, bsh, - AE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) { - printf(": failed to map register space\n"); - break; - } - if ((sc->mem_size = ae_size_card_memory(bst, bsh, - AE_DATA_OFFSET)) == 0) { - printf(": failed to determine size of RAM.\n"); - break; - } - if (bus_space_subregion(bst, bsh, - AE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) { - printf(": failed to map register space\n"); - break; - } -#ifdef AE_OLD_GET_ENADDR - /* Get station address from on-board ROM */ - for (i = 0; i < ETHER_ADDR_LEN; ++i) - sc->sc_arpcom.ac_enaddr[i] = - bus_space_read_1(bst, bsh, (FE_ROM_OFFSET + i)); -#endif - - success = 1; - break; - - case DP8390_VENDOR_INTERLAN: - /* Map register offsets */ - for (i = 0; i < 16; i++) /* normal order, longword aligned */ - sc->sc_reg_map[i] = i << 2; - - sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS); - if (bus_space_subregion(bst, bsh, - GC_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) { - printf(": failed to map register space\n"); - break; - } - if ((sc->mem_size = ae_size_card_memory(bst, bsh, - GC_DATA_OFFSET)) == 0) { - printf(": failed to determine size of RAM.\n"); - break; - } - if (bus_space_subregion(bst, bsh, - GC_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) { - printf(": failed to map register space\n"); - break; - } - - /* reset the NIC chip */ - bus_space_write_1(bst, bsh, GC_RESET_OFFSET, 0); - - if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_arpcom.ac_enaddr)) { - /* Fall back to snarf directly from ROM. Ick. */ - for (i = 0; i < ETHER_ADDR_LEN; ++i) - sc->sc_arpcom.ac_enaddr[i] = - bus_space_read_1(bst, bsh, - (GC_ROM_OFFSET + i * 4)); - } - - success = 1; - break; - - case DP8390_VENDOR_KINETICS: - /* Map register offsets */ - for (i = 0; i < 16; i++) /* normal order, longword aligned */ - sc->sc_reg_map[i] = i << 2; - - /* sc->use16bit = 0; */ - if (bus_space_subregion(bst, bsh, - KE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) { - printf(": failed to map register space\n"); - break; - } - if ((sc->mem_size = ae_size_card_memory(bst, bsh, - KE_DATA_OFFSET)) == 0) { - printf(": failed to determine size of RAM.\n"); - break; - } - if (bus_space_subregion(bst, bsh, - KE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) { - printf(": failed to map register space\n"); - break; - } - if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_arpcom.ac_enaddr)) { - printf(": can't find MAC address\n"); - break; - } - - success = 1; - break; - case DP8390_VENDOR_CABLETRON: - /* Map register offsets */ - for (i = 0; i < 16; i++) - sc->sc_reg_map[i] = i << 1; /* normal order, word aligned */ - - sc->dcr_reg = (ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS); - if (bus_space_subregion(bst, bsh, - CT_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) { - printf(": failed to map register space\n"); - break; - } - if ((sc->mem_size = ae_size_card_memory(bst, bsh, - CT_DATA_OFFSET)) == 0) { - printf(": failed to determine size of RAM.\n"); - break; - } - if (bus_space_subregion(bst, bsh, - CT_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) { - printf(": failed to map register space\n"); - break; - } - if (ae_nb_get_enaddr(bst, bsh, na, sc->sc_arpcom.ac_enaddr)) { - printf(": can't find MAC address\n"); - break; - } - success = 1; - default: - break; - } - - if (!success) { - bus_space_unmap(bst, bsh, NBMEMSIZE); - return; - } - - /* - * Override test_mem and write_mbuf functions; other defaults - * already work properly. - */ - sc->test_mem = ae_test_mem; - sc->write_mbuf = ae_write_mbuf; -#ifdef DEBUG - ifp->if_watchdog = ae_nb_watchdog; /* Override watchdog */ -#endif - sc->sc_media_init = dp8390_media_init; - - /* Interface is always enabled. */ - sc->sc_enabled = 1; - - printf(": %s, %dKB memory", cardtype, sc->mem_size / 1024); - - if (dp8390_config(sc)) { - bus_space_unmap(bst, bsh, NBMEMSIZE); - return; - } - - /* make sure interrupts are vectored to us */ - add_nubus_intr(na->slot, IPL_NET, dp8390_intr, sc, sc->sc_dev.dv_xname); -} - -static int -ae_nb_card_vendor(bst, bsh, na) - bus_space_tag_t bst; - bus_space_handle_t bsh; - struct nubus_attach_args *na; -{ - int vendor; - - switch (na->drsw) { - case NUBUS_DRSW_3COM: - switch (na->drhw) { - case NUBUS_DRHW_APPLE_SN: - case NUBUS_DRHW_APPLE_SNT: - vendor = DP8390_VENDOR_UNKNOWN; - break; - default: - vendor = DP8390_VENDOR_APPLE; - break; - } - break; - case NUBUS_DRSW_APPLE: - if (na->drhw == NUBUS_DRHW_ASANTE_LC) { - vendor = DP8390_VENDOR_UNKNOWN; - break; - } - /* FALLTHROUGH */ - case NUBUS_DRSW_DAYNA2: - case NUBUS_DRSW_TECHWORKS: - case NUBUS_DRSW_TFLLAN: - if (na->drhw == NUBUS_DRHW_CABLETRON) { - vendor = DP8390_VENDOR_CABLETRON; - } else { - vendor = DP8390_VENDOR_APPLE; - } - break; - case NUBUS_DRSW_ASANTE: - vendor = DP8390_VENDOR_ASANTE; - break; - case NUBUS_DRSW_FARALLON: - vendor = DP8390_VENDOR_FARALLON; - break; - case NUBUS_DRSW_FOCUS: - vendor = DP8390_VENDOR_FOCUS; - break; - case NUBUS_DRSW_GATOR: - switch (na->drhw) { - default: - case NUBUS_DRHW_INTERLAN: - vendor = DP8390_VENDOR_INTERLAN; - break; - case NUBUS_DRHW_KINETICS: - if (strncmp(nubus_get_card_name(bst, bsh, na->fmt), - "EtherPort", 9) == 0) - vendor = DP8390_VENDOR_KINETICS; - else - vendor = DP8390_VENDOR_DAYNA; - break; - } - break; - default: - vendor = DP8390_VENDOR_UNKNOWN; - } - return vendor; -} - -static int -ae_nb_get_enaddr(bst, bsh, na, ep) - bus_space_tag_t bst; - bus_space_handle_t bsh; - struct nubus_attach_args *na; - u_int8_t *ep; -{ - nubus_dir dir; - nubus_dirent dirent; - int rv; - - /* - * XXX - note hardwired resource IDs here (0x80); these are - * assumed to be used by all cards, but should be fixed when - * we find out more about Ethernet card resources. - */ - nubus_get_main_dir(na->fmt, &dir); - switch (ae_nb_card_vendor(bst, bsh, na)) { - case DP8390_VENDOR_APPLE: - if (na->drsw == NUBUS_DRSW_TFLLAN) { /* TFL LAN E410/E420 */ - rv = nubus_find_rsrc(bst, bsh, na->fmt, - &dir, 0x80, &dirent); - break; - } - /* FALLTHROUGH */ - default: - rv = nubus_find_rsrc(bst, bsh, na->fmt, &dir, 0x80, &dirent); - break; - } - if (rv <= 0) - return 1; - nubus_get_dir_from_rsrc(na->fmt, &dirent, &dir); - if (nubus_find_rsrc(bst, bsh, na->fmt, &dir, 0x80, &dirent) <= 0) - return 1; - if (nubus_get_ind_data(bst, bsh, - na->fmt, &dirent, ep, ETHER_ADDR_LEN) <= 0) - return 1; - - return 0; -} - -#ifdef DEBUG -static void -ae_nb_watchdog(ifp) - struct ifnet *ifp; -{ - struct dp8390_softc *sc = ifp->if_softc; - extern via2hand_t via2intrs[7]; - -/* - * This is a kludge! The via code seems to miss slot interrupts - * sometimes. This kludges around that by calling the handler - * by hand if the watchdog is activated. -- XXX (akb) - * XXX note that this assumes the nubus handler is first in the chain. - */ - if (!SLIST_EMPTY(&via2intrs[1])) { - struct via2hand *vh = SLIST_FIRST(&via2intrs[1]); - (void)(*vh->vh_fn)(vh->vh_arg); - } - - log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname); - ++sc->sc_arpcom.ac_if.if_oerrors; - - dp8390_reset(sc); -} -#endif diff --git a/sys/arch/mac68k/dev/if_aereg.h b/sys/arch/mac68k/dev/if_aereg.h deleted file mode 100644 index 37aab45f81e..00000000000 --- a/sys/arch/mac68k/dev/if_aereg.h +++ /dev/null @@ -1,40 +0,0 @@ -/* $OpenBSD: if_aereg.h,v 1.8 2007/01/22 13:17:45 martin Exp $ */ -/* $NetBSD: if_aereg.h,v 1.17 1998/08/12 07:19:09 scottr Exp $ */ - -/* - * National Semiconductor DS8390 NIC register definitions. - * - * Copyright (C) 1993, David Greenman. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided that - * the above copyright and these terms are retained. Under no circumstances is - * the author responsible for the proper functioning of this software, nor does - * the author assume any responsibility for damages incurred with its use. - */ - -/* - * Memory offsets from slot base PA - */ -#define GC_RESET_OFFSET 0x000c0000 /* writes here reset NIC */ -#define GC_ROM_OFFSET 0x000c0000 /* address prom */ -#define GC_DATA_OFFSET 0x000d0000 /* Offset to NIC memory */ -#define GC_REG_OFFSET 0x000e0000 /* Offset to NIC registers */ - -#define DP_ROM_OFFSET 0x000f0000 -#define DP_DATA_OFFSET 0x000d0000 /* Offset to SONIC memory */ -#define DP_REG_OFFSET 0x000e0000 /* Offset to SONIC registers */ - -#define AE_ROM_OFFSET 0x000f0000 -#define AE_DATA_OFFSET 0x000d0000 /* Offset to NIC memory */ -#define AE_REG_OFFSET 0x000e0000 /* Offset to NIC registers */ - -#define FE_ROM_OFFSET 0x000d0006 /* Determined empirically */ - -#define KE_ROM_OFFSET 0x000f0007 -#define KE_DATA_OFFSET 0x00000000 /* Offset to NIC memory */ -#define KE_REG_OFFSET 0x00080003 /* Offset to NIC registers */ - -#define CT_ROM_OFFSET 0x00030000 /* ROM offset */ -#define CT_DATA_OFFSET 0x00000000 /* RAM offset */ -#define CT_REG_OFFSET 0x00010000 /* REG offset */ - -#define AE_REG_SIZE 0x40 /* Size of register space */ diff --git a/sys/arch/mac68k/dev/if_aevar.h b/sys/arch/mac68k/dev/if_aevar.h deleted file mode 100644 index 562e7d25098..00000000000 --- a/sys/arch/mac68k/dev/if_aevar.h +++ /dev/null @@ -1,19 +0,0 @@ -/* $OpenBSD: if_aevar.h,v 1.5 2007/01/22 13:17:45 martin Exp $ */ -/* $NetBSD: if_aevar.h,v 1.10 2005/12/11 12:18:02 christos Exp $ */ - -/* - * Device driver for National Semiconductor DS8390/WD83C690 based ethernet - * adapters. - * - * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved. - * - * Copyright (C) 1993, David Greenman. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided that - * the above copyright and these terms are retained. Under no circumstances is - * the author responsible for the proper functioning of this software, nor does - * the author assume any responsibility for damages incurred with its use. - */ - -int ae_size_card_memory(bus_space_tag_t, bus_space_handle_t, int); -int ae_test_mem(struct dp8390_softc *); -int ae_write_mbuf(struct dp8390_softc *, struct mbuf *, int); diff --git a/sys/arch/mac68k/dev/if_mc.c b/sys/arch/mac68k/dev/if_mc.c deleted file mode 100644 index c3c0ee17ef1..00000000000 --- a/sys/arch/mac68k/dev/if_mc.c +++ /dev/null @@ -1,744 +0,0 @@ -/* $OpenBSD: if_mc.c,v 1.19 2008/11/28 02:44:17 brad Exp $ */ -/* $NetBSD: if_mc.c,v 1.24 2004/10/30 18:08:34 thorpej Exp $ */ - -/*- - * Copyright (c) 1997 David Huang <khym@azeotrope.org> - * All rights reserved. - * - * Portions of this code are based on code by Denton Gentry <denny1@home.com>, - * Charles M. Hannum, Yanagisawa Takeshi <yanagisw@aa.ap.titech.ac.jp>, 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. 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. - * - */ - -/* - * Driver for the AMD Am79C940 (MACE) ethernet chip, used for onboard - * ethernet on the Centris/Quadra 660av and Quadra 840av. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/mbuf.h> -#include <sys/buf.h> -#include <sys/protosw.h> -#include <sys/socket.h> -#include <sys/syslog.h> -#include <sys/ioctl.h> -#include <sys/errno.h> -#include <sys/device.h> - -#include <net/if.h> -#include <net/if_dl.h> - -#ifdef INET -#include <netinet/in.h> -#include <netinet/if_ether.h> -#include <netinet/in_systm.h> -#include <netinet/in_var.h> -#include <netinet/ip.h> -#endif - -#include <uvm/uvm_extern.h> - -#include "bpfilter.h" -#if NBPFILTER > 0 -#include <net/bpf.h> -#include <net/bpfdesc.h> -#endif - -#include <machine/bus.h> -#include <mac68k/dev/if_mcreg.h> -#include <mac68k/dev/if_mcvar.h> - -struct cfdriver mc_cd = { - NULL, "mc", DV_IFNET -}; - -void mcwatchdog(struct ifnet *); -int mcinit(struct mc_softc *sc); -int mcstop(struct mc_softc *sc); -int mcioctl(struct ifnet *ifp, u_long cmd, caddr_t data); -void mcstart(struct ifnet *ifp); -void mcreset(struct mc_softc *sc); - -u_int maceput(struct mc_softc *sc, struct mbuf *m0); -void mc_tint(struct mc_softc *sc); -void mace_read(struct mc_softc *, caddr_t, int); -struct mbuf *mace_get(struct mc_softc *, caddr_t, int); -static void mace_calcladrf(struct arpcom *ac, u_int8_t *af); -static inline u_int16_t ether_cmp(void *, void *); - - -/* - * Compare two Ether/802 addresses for equality, inlined and - * unrolled for speed. Use this like bcmp(). - * - * XXX: Add <machine/inlines.h> for stuff like this? - * XXX: or maybe add it to libkern.h instead? - * - * "I'd love to have an inline assembler version of this." - * XXX: Who wanted that? mycroft? I wrote one, but this - * version in C is as good as hand-coded assembly. -gwr - * - * Please do NOT tweak this without looking at the actual - * assembly code generated before and after your tweaks! - */ -static inline u_int16_t -ether_cmp(one, two) - void *one, *two; -{ - register u_int16_t *a = (u_short *) one; - register u_int16_t *b = (u_short *) two; - register u_int16_t diff; - -#ifdef m68k - /* - * The post-increment-pointer form produces the best - * machine code for m68k. This was carefully tuned - * so it compiles to just 8 short (2-byte) op-codes! - */ - diff = *a++ - *b++; - diff |= *a++ - *b++; - diff |= *a++ - *b++; -#else - /* - * Most modern CPUs do better with a single expression. - * Note that short-cut evaluation is NOT helpful here, - * because it just makes the code longer, not faster! - */ - diff = (a[0] - b[0]) | (a[1] - b[1]) | (a[2] - b[2]); -#endif - - return (diff); -} - -#define ETHER_CMP ether_cmp - -/* - * Interface exists: make available by filling in network interface - * record. System will initialize the interface when it is ready - * to accept packets. - */ -int -mcsetup(sc, lladdr) - struct mc_softc *sc; - u_int8_t *lladdr; -{ - struct ifnet *ifp = &sc->sc_if; - - /* reset the chip and disable all interrupts */ - NIC_PUT(sc, MACE_BIUCC, SWRST); - DELAY(100); - NIC_PUT(sc, MACE_IMR, ~0); - - bcopy(lladdr, sc->sc_enaddr, ETHER_ADDR_LEN); - bcopy(sc->sc_enaddr, sc->sc_ethercom.ac_enaddr, ETHER_ADDR_LEN); - printf(": address %s\n", ether_sprintf(lladdr)); - - bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); - ifp->if_softc = sc; - ifp->if_ioctl = mcioctl; - ifp->if_start = mcstart; - ifp->if_flags = - IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; - ifp->if_watchdog = mcwatchdog; - IFQ_SET_READY(&ifp->if_snd); - - if_attach(ifp); - ether_ifattach(ifp); - - return (0); -} - -int -mcioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - caddr_t data; -{ - struct mc_softc *sc = ifp->if_softc; - struct ifaddr *ifa = (struct ifaddr *) data; - int s, err = 0; - - s = splnet(); - - switch (cmd) { - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - mcinit(sc); - arp_ifinit(&sc->sc_ethercom, ifa); - break; -#endif - default: - mcinit(sc); - break; - } - break; - - case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { - /* - * If interface is marked down and it is running, - * then stop it. - */ - mcstop(sc); - ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { - /* - * If interface is marked up and it is stopped, - * then start it. - */ - (void)mcinit(sc); - } else { - /* - * reset the interface to pick up any other changes - * in flags - */ - mcreset(sc); - mcstart(ifp); - } - break; - - default: - err = ether_ioctl(ifp, &sc->sc_ethercom, cmd, data); - } - - if (err == ENETRESET) { - if (ifp->if_flags & IFF_RUNNING) - mcreset(sc); - err = 0; - } - - splx(s); - return (err); -} - -/* - * Encapsulate a packet of type family for the local net. - */ -void -mcstart(ifp) - struct ifnet *ifp; -{ - struct mc_softc *sc = ifp->if_softc; - struct mbuf *m; - - if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) - return; - - while (1) { - if (ifp->if_flags & IFF_OACTIVE) - return; - - IFQ_DEQUEUE(&ifp->if_snd, m); - if (m == NULL) - return; - -#if NBPFILTER > 0 - /* - * If bpf is listening on this interface, let it - * see the packet before we commit it to the wire. - */ - if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT); -#endif - - /* - * Copy the mbuf chain into the transmit buffer. - */ - ifp->if_flags |= IFF_OACTIVE; - maceput(sc, m); - - ifp->if_opackets++; /* # of pkts */ - } -} - -/* - * reset and restart the MACE. Called in case of fatal - * hardware/software errors. - */ -void -mcreset(sc) - struct mc_softc *sc; -{ - mcstop(sc); - mcinit(sc); -} - -int -mcinit(sc) - struct mc_softc *sc; -{ - int s; - u_int8_t maccc, ladrf[8]; - - if (sc->sc_if.if_flags & IFF_RUNNING) - /* already running */ - return (0); - - s = splnet(); - - NIC_PUT(sc, MACE_BIUCC, sc->sc_biucc); - NIC_PUT(sc, MACE_FIFOCC, sc->sc_fifocc); - NIC_PUT(sc, MACE_IMR, ~0); /* disable all interrupts */ - NIC_PUT(sc, MACE_PLSCC, sc->sc_plscc); - - NIC_PUT(sc, MACE_UTR, RTRD); /* disable reserved test registers */ - - /* set MAC address */ - NIC_PUT(sc, MACE_IAC, ADDRCHG); - while (NIC_GET(sc, MACE_IAC) & ADDRCHG) - ; - NIC_PUT(sc, MACE_IAC, PHYADDR); - bus_space_write_multi_1(sc->sc_regt, sc->sc_regh, MACE_REG(MACE_PADR), - sc->sc_enaddr, ETHER_ADDR_LEN); - - /* set logical address filter */ - mace_calcladrf(&sc->sc_ethercom, ladrf); - - NIC_PUT(sc, MACE_IAC, ADDRCHG); - while (NIC_GET(sc, MACE_IAC) & ADDRCHG) - ; - NIC_PUT(sc, MACE_IAC, LOGADDR); - bus_space_write_multi_1(sc->sc_regt, sc->sc_regh, MACE_REG(MACE_LADRF), - ladrf, 8); - - NIC_PUT(sc, MACE_XMTFC, APADXMT); - /* - * No need to autostrip padding on receive... Ethernet frames - * don't have a length field, unlike 802.3 frames, so the MACE - * can't figure out the length of the packet anyways. - */ - NIC_PUT(sc, MACE_RCVFC, 0); - - maccc = ENXMT | ENRCV; - if (sc->sc_if.if_flags & IFF_PROMISC) - maccc |= PROM; - - NIC_PUT(sc, MACE_MACCC, maccc); - - if (sc->sc_bus_init) - (*sc->sc_bus_init)(sc); - - /* - * Enable all interrupts except receive, since we use the DMA - * completion interrupt for that. - */ - NIC_PUT(sc, MACE_IMR, RCVINTM); - - /* flag interface as "running" */ - sc->sc_if.if_flags |= IFF_RUNNING; - sc->sc_if.if_flags &= ~IFF_OACTIVE; - - splx(s); - return (0); -} - -/* - * close down an interface and free its buffers - * Called on final close of device, or if mcinit() fails - * part way through. - */ -int -mcstop(sc) - struct mc_softc *sc; -{ - int s = splnet(); - - NIC_PUT(sc, MACE_BIUCC, SWRST); - DELAY(100); - - sc->sc_if.if_timer = 0; - sc->sc_if.if_flags &= ~IFF_RUNNING; - - splx(s); - return (0); -} - -/* - * Called if any Tx packets remain unsent after 5 seconds, - * In all cases we just reset the chip, and any retransmission - * will be handled by higher level protocol timeouts. - */ -void -mcwatchdog(ifp) - struct ifnet *ifp; -{ - struct mc_softc *sc = ifp->if_softc; - - printf("mcwatchdog: resetting chip\n"); - mcreset(sc); -} - -/* - * stuff packet into MACE (at splnet) - */ -u_int -maceput(sc, m) - struct mc_softc *sc; - struct mbuf *m; -{ - struct mbuf *n; - u_int len, totlen = 0; - u_char *buff; - - buff = sc->sc_txbuf; - - for (; m; m = n) { - u_char *data = mtod(m, u_char *); - len = m->m_len; - totlen += len; - bcopy(data, buff, len); - buff += len; - MFREE(m, n); - } - - if (totlen > PAGE_SIZE) - panic("%s: maceput: packet overflow", sc->sc_dev.dv_xname); - -#if 0 - if (totlen < ETHERMIN + sizeof(struct ether_header)) { - int pad = ETHERMIN + sizeof(struct ether_header) - totlen; - bzero(sc->sc_txbuf + totlen, pad); - totlen = ETHERMIN + sizeof(struct ether_header); - } -#endif - - (*sc->sc_putpacket)(sc, totlen); - - sc->sc_if.if_timer = 5; /* 5 seconds to watch for failing to transmit */ - return (totlen); -} - -void -mcintr(arg) - void *arg; -{ -struct mc_softc *sc = arg; - u_int8_t ir; - - ir = NIC_GET(sc, MACE_IR) & ~NIC_GET(sc, MACE_IMR); - if (ir & JAB) { -#ifdef MCDEBUG - printf("%s: jabber error\n", sc->sc_dev.dv_xname); -#endif - sc->sc_if.if_oerrors++; - } - - if (ir & BABL) { -#ifdef MCDEBUG - printf("%s: babble\n", sc->sc_dev.dv_xname); -#endif - sc->sc_if.if_oerrors++; - } - - if (ir & CERR) { -#ifdef MCDEBUG - printf("%s: collision error\n", sc->sc_dev.dv_xname); -#endif - sc->sc_if.if_collisions++; - } - - /* - * Pretend we have carrier; if we don't this will be cleared - * shortly. - */ - sc->sc_havecarrier = 1; - - if (ir & XMTINT) - mc_tint(sc); - - if (ir & RCVINT) - mc_rint(sc); -} - -void -mc_tint(sc) - struct mc_softc *sc; -{ - u_int8_t xmtrc, xmtfs; - - xmtrc = NIC_GET(sc, MACE_XMTRC); - xmtfs = NIC_GET(sc, MACE_XMTFS); - - if ((xmtfs & XMTSV) == 0) - return; - - if (xmtfs & UFLO) { - printf("%s: underflow\n", sc->sc_dev.dv_xname); - mcreset(sc); - return; - } - - if (xmtfs & LCOL) { - printf("%s: late collision\n", sc->sc_dev.dv_xname); - sc->sc_if.if_oerrors++; - sc->sc_if.if_collisions++; - } - - if (xmtfs & MORE) - /* Real number is unknown. */ - sc->sc_if.if_collisions += 2; - else if (xmtfs & ONE) - sc->sc_if.if_collisions++; - else if (xmtfs & RTRY) { - printf("%s: excessive collisions\n", sc->sc_dev.dv_xname); - sc->sc_if.if_collisions += 16; - sc->sc_if.if_oerrors++; - } - - if (xmtfs & LCAR) { - sc->sc_havecarrier = 0; - printf("%s: lost carrier\n", sc->sc_dev.dv_xname); - sc->sc_if.if_oerrors++; - } - - sc->sc_if.if_flags &= ~IFF_OACTIVE; - sc->sc_if.if_timer = 0; - mcstart(&sc->sc_if); -} - -void -mc_rint(sc) - struct mc_softc *sc; -{ -#define rxf sc->sc_rxframe - u_int len; - - len = (rxf.rx_rcvcnt | ((rxf.rx_rcvsts & 0xf) << 8)) - 4; - -#ifdef MCDEBUG - if (rxf.rx_rcvsts & 0xf0) - printf("%s: rcvcnt %02x rcvsts %02x rntpc 0x%02x rcvcc 0x%02x\n", - sc->sc_dev.dv_xname, rxf.rx_rcvcnt, rxf.rx_rcvsts, - rxf.rx_rntpc, rxf.rx_rcvcc); -#endif - - if (rxf.rx_rcvsts & OFLO) { -#ifdef MCDEBUG - printf("%s: receive FIFO overflow\n", sc->sc_dev.dv_xname); -#endif - sc->sc_if.if_ierrors++; - return; - } - - if (rxf.rx_rcvsts & CLSN) - sc->sc_if.if_collisions++; - - if (rxf.rx_rcvsts & FRAM) { -#ifdef MCDEBUG - printf("%s: framing error\n", sc->sc_dev.dv_xname); -#endif - sc->sc_if.if_ierrors++; - return; - } - - if (rxf.rx_rcvsts & FCS) { -#ifdef MCDEBUG - printf("%s: frame control checksum error\n", sc->sc_dev.dv_xname); -#endif - sc->sc_if.if_ierrors++; - return; - } - - mace_read(sc, rxf.rx_frame, len); -#undef rxf -} - -void -mace_read(sc, pkt, len) - struct mc_softc *sc; - caddr_t pkt; - int len; -{ - struct ifnet *ifp = &sc->sc_if; - struct mbuf *m; - - if (len <= sizeof(struct ether_header) || - len > ETHERMTU + sizeof(struct ether_header)) { -#ifdef MCDEBUG - printf("%s: invalid packet size %d; dropping\n", - sc->sc_dev.dv_xname, len); -#endif - ifp->if_ierrors++; - return; - } - - m = mace_get(sc, pkt, len); - if (m == NULL) { - ifp->if_ierrors++; - return; - } - - ifp->if_ipackets++; - -#if NBPFILTER > 0 - /* Pass the packet to any BPF listeners. */ - if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); -#endif - - /* Pass the packet up. */ - ether_input_mbuf(ifp, m); -} - -/* - * Pull data off an interface. - * Len is length of data, with local net header stripped. - * We copy the data into mbufs. When full cluster sized units are present - * we copy into clusters. - */ -struct mbuf * -mace_get(sc, pkt, totlen) - struct mc_softc *sc; - caddr_t pkt; - int totlen; -{ - register struct mbuf *m; - struct mbuf *top, **mp; - int len; - - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) - return (NULL); - - m->m_pkthdr.rcvif = &sc->sc_if; - m->m_pkthdr.len = totlen; - len = MHLEN; - top = 0; - mp = ⊤ - - while (totlen > 0) { - if (top) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == NULL) { - m_freem(top); - return (NULL); - } - len = MLEN; - } - if (totlen >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if ((m->m_flags & M_EXT) == 0) { - m_free(m); - m_freem(top); - return (NULL); - } - len = MCLBYTES; - } - m->m_len = len = min(totlen, len); - bcopy(pkt, mtod(m, caddr_t), len); - pkt += len; - totlen -= len; - *mp = m; - mp = &m->m_next; - } - - return (top); -} - -/* - * Go through the list of multicast addresses and calculate the logical - * address filter. - */ -void -mace_calcladrf(ac, af) - struct arpcom *ac; - u_int8_t *af; -{ - struct ifnet *ifp = &ac->ac_if; - struct ether_multi *enm; - register u_int32_t crc; - struct ether_multistep step; - - /* - * Set up multicast address filter by passing all multicast addresses - * through a crc generator, and then using the high order 6 bits as an - * index into the 64 bit logical address filter. The high order bit - * selects the word, while the rest of the bits select the bit within - * the word. - */ - - *((u_int32_t *)af) = *((u_int32_t *)af + 1) = 0; - ETHER_FIRST_MULTI(step, ac, enm); - while (enm != NULL) { - if (ETHER_CMP(enm->enm_addrlo, enm->enm_addrhi)) { - /* - * We must listen to a range of multicast addresses. - * For now, just accept all multicasts, rather than - * trying to set only those filter bits needed to match - * the range. (At this time, the only use of address - * ranges is for IP multicast routing, for which the - * range is big enough to require all bits set.) - */ - goto allmulti; - } - - crc = ether_crc32_le(enm->enm_addrlo, sizeof(enm->enm_addrlo)); - - /* Just want the 6 most significant bits. */ - crc >>= 26; - - /* Set the corresponding bit in the filter. */ - af[crc >> 3] |= 1 << (crc & 7); - - ETHER_NEXT_MULTI(step, enm); - } - ifp->if_flags &= ~IFF_ALLMULTI; - return; - -allmulti: - ifp->if_flags |= IFF_ALLMULTI; - *((u_int32_t *)af) = *((u_int32_t *)af + 1) = 0xffffffff; -} - -static u_char bbr4[] = {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15}; -#define bbr(v) ((bbr4[(v)&0xf] << 4) | bbr4[((v)>>4) & 0xf]) - -u_char -mc_get_enaddr(t, h, o, dst) - bus_space_tag_t t; - bus_space_handle_t h; - bus_size_t o; - u_char *dst; -{ - int i; - u_char b, csum; - - /* - * The XOR of the 8 bytes of the ROM must be 0xff for it to be - * valid - */ - for (i = 0, csum = 0; i < 8; i++) { - b = bus_space_read_1(t, h, o+16*i); - if (i < ETHER_ADDR_LEN) - dst[i] = bbr(b); - csum ^= b; - } - - return csum; -} diff --git a/sys/arch/mac68k/dev/if_mc_obio.c b/sys/arch/mac68k/dev/if_mc_obio.c deleted file mode 100644 index 89f701e9a7d..00000000000 --- a/sys/arch/mac68k/dev/if_mc_obio.c +++ /dev/null @@ -1,434 +0,0 @@ -/* $OpenBSD: if_mc_obio.c,v 1.9 2010/03/31 19:46:27 miod Exp $ */ -/* $NetBSD: if_mc_obio.c,v 1.13 2004/03/26 12:15:46 wiz Exp $ */ - -/*- - * Copyright (c) 1997 David Huang <khym@azeotrope.org> - * All rights reserved. - * - * Portions of this code are based on code by Denton Gentry <denny1@home.com> - * and Yanagisawa Takeshi <yanagisw@aa.ap.titech.ac.jp>. - * - * 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. 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. - * - */ - -/* - * Bus attachment and DMA routines for the mc driver (Centris/Quadra - * 660av and Quadra 840av onboard ethernet, based on the AMD Am79C940 - * MACE ethernet chip). Also uses the PSC (Peripheral Subsystem - * Controller) for DMA to and from the MACE. - */ - -#include <sys/param.h> -#include <sys/device.h> -#include <sys/socket.h> -#include <sys/systm.h> - -#include <net/if.h> - -#include <netinet/in.h> -#include <netinet/if_ether.h> - -#include <uvm/uvm_extern.h> - -#include <machine/bus.h> -#include <machine/cpu.h> -#include <machine/psc.h> - -#include <mac68k/dev/obiovar.h> -#include <mac68k/dev/if_mcreg.h> -#include <mac68k/dev/if_mcvar.h> - -#define MACE_REG_BASE 0x50F1C000 -#define MACE_PROM_BASE 0x50F08000 - -int mc_obio_match(struct device *, void *, void *); -void mc_obio_attach(struct device *, struct device *, void *); -void mc_obio_init(struct mc_softc *sc); -void mc_obio_put(struct mc_softc *sc, u_int len); -int mc_dmaintr(void *arg); -void mc_reset_rxdma(struct mc_softc *sc); -void mc_reset_rxdma_set(struct mc_softc *, int set); -void mc_reset_txdma(struct mc_softc *sc); -int mc_obio_getaddr(struct mc_softc *, u_int8_t *); - -struct cfattach mc_obio_ca = { - sizeof(struct mc_softc), mc_obio_match, mc_obio_attach -}; - -int -mc_obio_match(parent, cf, aux) - struct device *parent; - void *cf; - void *aux; -{ - struct obio_attach_args *oa = aux; - bus_space_handle_t bsh; - int found = 0; - - if (current_mac_model->class != MACH_CLASSAV) - return 0; - - if (bus_space_map(oa->oa_tag, MACE_REG_BASE, MC_REGSIZE, 0, &bsh)) - return 0; - - /* - * Make sure the MACE's I/O space is readable, and if it is, - * try to read the CHIPID register. A MACE will always have - * 0x?940, where the ? depends on the chip version. - */ - if (mac68k_bus_space_probe(oa->oa_tag, bsh, 0, 1)) { - if ((bus_space_read_1( - oa->oa_tag, bsh, MACE_REG(MACE_CHIPIDL)) == 0x40) && - ((bus_space_read_1( - oa->oa_tag, bsh, MACE_REG(MACE_CHIPIDH)) & 0xf) == 9)) - found = 1; - } - - bus_space_unmap(oa->oa_tag, bsh, MC_REGSIZE); - - return found; -} - -void -mc_obio_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct obio_attach_args *oa = (struct obio_attach_args *)aux; - struct mc_softc *sc = (void *)self; - struct pglist rxlist, txlist; - vm_page_t pg; - vaddr_t va; - u_int8_t myaddr[ETHER_ADDR_LEN]; - - sc->sc_regt = oa->oa_tag; - sc->sc_biucc = XMTSP_64; - sc->sc_fifocc = XMTFW_16 | RCVFW_64 | XMTFWU | RCVFWU | - XMTBRST | RCVBRST; - sc->sc_plscc = PORTSEL_AUI; - - if (bus_space_map(sc->sc_regt, MACE_REG_BASE, MC_REGSIZE, 0, - &sc->sc_regh)) { - printf(": failed to map space for MACE regs.\n"); - return; - } - - if (mc_obio_getaddr(sc, myaddr)) { - printf(": failed to get MAC address.\n"); - goto out1; - } - - /* allocate memory for transmit buffer and mark it non-cacheable */ - TAILQ_INIT(&txlist); - if (uvm_pglistalloc(PAGE_SIZE, 0, -1, PAGE_SIZE, 0, - &txlist, 1, UVM_PLA_NOWAIT) != 0) { - printf(": could not allocate transmit buffer memory\n"); - goto out1; - } - sc->sc_txbuf = (u_char *)uvm_km_valloc(kernel_map, PAGE_SIZE); - if (sc->sc_txbuf == NULL) { - printf(": can't map transmit buffer memory\n"); - goto out2; - } - pg = TAILQ_FIRST(&txlist); - sc->sc_txbuf_phys = VM_PAGE_TO_PHYS(pg); - pmap_enter_cache(pmap_kernel(), (vaddr_t)sc->sc_txbuf, - sc->sc_txbuf_phys, UVM_PROT_RW, UVM_PROT_RW | PMAP_WIRED, PG_CI); - pmap_update(pmap_kernel()); - - /* - * allocate memory for receive buffer and mark it non-cacheable - */ - TAILQ_INIT(&rxlist); - if (uvm_pglistalloc(MC_NPAGES * PAGE_SIZE, 0, -1, PAGE_SIZE, 0, - &rxlist, 1, UVM_PLA_NOWAIT) != 0) { - printf(": could not allocate receive buffer memory\n"); - goto out3; - } - sc->sc_rxbuf = (u_char *)(va = uvm_km_valloc(kernel_map, - MC_NPAGES * PAGE_SIZE)); - if (sc->sc_rxbuf == NULL) { - printf(": can't map receive buffer memory\n"); - goto out4; - } - pg = TAILQ_FIRST(&rxlist); - sc->sc_rxbuf_phys = VM_PAGE_TO_PHYS(pg); - TAILQ_FOREACH(pg, &rxlist, pageq) { - pmap_enter_cache(pmap_kernel(), va, VM_PAGE_TO_PHYS(pg), - UVM_PROT_RW, UVM_PROT_RW | PMAP_WIRED, PG_CI); - va += PAGE_SIZE; - } - pmap_update(pmap_kernel()); - - sc->sc_bus_init = mc_obio_init; - sc->sc_putpacket = mc_obio_put; - - /* disable receive DMA */ - psc_reg2(PSC_ENETRD_CTL) = 0x8800; - psc_reg2(PSC_ENETRD_CTL) = 0x1000; - psc_reg2(PSC_ENETRD_CMD + PSC_SET0) = 0x1100; - psc_reg2(PSC_ENETRD_CMD + PSC_SET1) = 0x1100; - - /* disable transmit DMA */ - psc_reg2(PSC_ENETWR_CTL) = 0x8800; - psc_reg2(PSC_ENETWR_CTL) = 0x1000; - psc_reg2(PSC_ENETWR_CMD + PSC_SET0) = 0x1100; - psc_reg2(PSC_ENETWR_CMD + PSC_SET1) = 0x1100; - - /* install interrupt handlers */ - add_psc_lev4_intr(PSCINTR_ENET_DMA, mc_dmaintr, sc); - add_psc_lev3_intr(mcintr, sc); - - /* enable MACE DMA interrupts */ - psc_reg1(PSC_LEV4_IER) = 0x80 | (1 << PSCINTR_ENET_DMA); - - /* don't know what this does */ - psc_reg2(PSC_ENETWR_CTL) = 0x9000; - psc_reg2(PSC_ENETRD_CTL) = 0x9000; - psc_reg2(PSC_ENETWR_CTL) = 0x0400; - psc_reg2(PSC_ENETRD_CTL) = 0x0400; - - /* enable MACE interrupts */ - psc_reg1(PSC_LEV3_IER) = 0x80 | (1 << PSCINTR_ENET); - - /* mcsetup returns 1 if something fails */ - if (mcsetup(sc, myaddr) != 0) - goto out5; - - return; - -out5: - /* disable interrupts */ - psc_reg1(PSC_LEV4_IER) = (1 << PSCINTR_ENET_DMA); - psc_reg1(PSC_LEV3_IER) = (1 << PSCINTR_ENET); - /* remove interrupt handlers */ - remove_psc_lev4_intr(PSCINTR_ENET_DMA); - remove_psc_lev3_intr(); - pmap_remove(pmap_kernel(), (vaddr_t)sc->sc_rxbuf, - (vaddr_t)sc->sc_rxbuf + MC_NPAGES * PAGE_SIZE); - pmap_update(pmap_kernel()); -out4: - uvm_pglistfree(&rxlist); -out3: - pmap_remove(pmap_kernel(), (vaddr_t)sc->sc_txbuf, - (vaddr_t)sc->sc_txbuf + PAGE_SIZE); - pmap_update(pmap_kernel()); -out2: - uvm_pglistfree(&txlist); -out1: - bus_space_unmap(sc->sc_regt, sc->sc_regh, MC_REGSIZE); -} - -/* Bus-specific initialization */ -void -mc_obio_init(sc) - struct mc_softc *sc; -{ - mc_reset_rxdma(sc); - mc_reset_txdma(sc); -} - -void -mc_obio_put(sc, len) - struct mc_softc *sc; - u_int len; -{ - psc_reg4(PSC_ENETWR_ADDR + sc->sc_txset) = sc->sc_txbuf_phys; - psc_reg4(PSC_ENETWR_LEN + sc->sc_txset) = len; - psc_reg2(PSC_ENETWR_CMD + sc->sc_txset) = 0x9800; - - sc->sc_txset ^= 0x10; -} - -/* - * Interrupt handler for the MACE DMA completion interrupts - */ -int -mc_dmaintr(arg) - void *arg; -{ - struct mc_softc *sc = arg; - u_int16_t status; - u_int32_t bufsleft, which; - int head; - - /* - * Not sure what this does... figure out if this interrupt is - * really ours? - */ - while ((which = psc_reg4(0x804)) != psc_reg4(0x804)) - ; - if ((which & 0x60000000) == 0) - return 0; - - /* Get the read channel status */ - status = psc_reg2(PSC_ENETRD_CTL); - if (status & 0x2000) { - /* I think this is an exceptional condition. Reset the DMA */ - mc_reset_rxdma(sc); -#ifdef MCDEBUG - printf("%s: resetting receive DMA channel (status 0x%04x)\n", - sc->sc_dev.dv_xname, status); -#endif - } else if (status & 0x100) { - /* We've received some packets from the MACE */ - int offset; - - /* Clear the interrupt */ - psc_reg2(PSC_ENETRD_CMD + sc->sc_rxset) = 0x1100; - - /* See how may receive buffers are left */ - bufsleft = psc_reg4(PSC_ENETRD_LEN + sc->sc_rxset); - head = MC_RXDMABUFS - bufsleft; - -#if 0 /* I don't think this should ever happen */ - if (head == sc->sc_tail) { -#ifdef MCDEBUG - printf("%s: head == tail: suspending DMA?\n", - sc->sc_dev.dv_xname); -#endif - psc_reg2(PSC_ENETRD_CMD + sc->sc_rxset) = 0x9000; - } -#endif - - /* Loop through, processing each of the packets */ - for (; sc->sc_tail < head; sc->sc_tail++) { - offset = sc->sc_tail * 0x800; - sc->sc_rxframe.rx_rcvcnt = sc->sc_rxbuf[offset]; - sc->sc_rxframe.rx_rcvsts = sc->sc_rxbuf[offset+2]; - sc->sc_rxframe.rx_rntpc = sc->sc_rxbuf[offset+4]; - sc->sc_rxframe.rx_rcvcc = sc->sc_rxbuf[offset+6]; - sc->sc_rxframe.rx_frame = sc->sc_rxbuf + offset + 16; - - mc_rint(sc); - } - - /* - * If we're out of buffers, reset this register set - * and switch to the other one. Otherwise, reactivate - * this set. - */ - if (bufsleft == 0) { - mc_reset_rxdma_set(sc, sc->sc_rxset); - sc->sc_rxset ^= 0x10; - } else - psc_reg2(PSC_ENETRD_CMD + sc->sc_rxset) = 0x9800; - } - - /* Get the write channel status */ - status = psc_reg2(PSC_ENETWR_CTL); - if (status & 0x2000) { - /* I think this is an exceptional condition. Reset the DMA */ - mc_reset_txdma(sc); -#ifdef MCDEBUG - printf("%s: resetting transmit DMA channel (status 0x%04x)\n", - sc->sc_dev.dv_xname, status); -#endif - } else if (status & 0x100) { - /* Clear the interrupt and switch register sets */ - psc_reg2(PSC_ENETWR_CMD + sc->sc_txseti) = 0x100; - sc->sc_txseti ^= 0x10; - } - - return 1; -} - - -void -mc_reset_rxdma(sc) - struct mc_softc *sc; -{ - u_int8_t maccc; - - /* Disable receiver, reset the DMA channels */ - maccc = NIC_GET(sc, MACE_MACCC); - NIC_PUT(sc, MACE_MACCC, maccc & ~ENRCV); - psc_reg2(PSC_ENETRD_CTL) = 0x8800; - mc_reset_rxdma_set(sc, 0); - psc_reg2(PSC_ENETRD_CTL) = 0x400; - - psc_reg2(PSC_ENETRD_CTL) = 0x8800; - mc_reset_rxdma_set(sc, 0x10); - psc_reg2(PSC_ENETRD_CTL) = 0x400; - - /* Reenable receiver, reenable DMA */ - NIC_PUT(sc, MACE_MACCC, maccc); - sc->sc_rxset = 0; - - psc_reg2(PSC_ENETRD_CMD + PSC_SET0) = 0x9800; - psc_reg2(PSC_ENETRD_CMD + PSC_SET1) = 0x9800; -} - -void -mc_reset_rxdma_set(sc, set) - struct mc_softc *sc; - int set; -{ - /* disable DMA while modifying the registers, then reenable DMA */ - psc_reg2(PSC_ENETRD_CMD + set) = 0x0100; - psc_reg4(PSC_ENETRD_ADDR + set) = sc->sc_rxbuf_phys; - psc_reg4(PSC_ENETRD_LEN + set) = MC_RXDMABUFS; - psc_reg2(PSC_ENETRD_CMD + set) = 0x9800; - sc->sc_tail = 0; -} - -void -mc_reset_txdma(sc) - struct mc_softc *sc; -{ - u_int8_t maccc; - - psc_reg2(PSC_ENETWR_CTL) = 0x8800; - maccc = NIC_GET(sc, MACE_MACCC); - NIC_PUT(sc, MACE_MACCC, maccc & ~ENXMT); - sc->sc_txset = sc->sc_txseti = 0; - psc_reg2(PSC_ENETWR_CTL) = 0x400; - NIC_PUT(sc, MACE_MACCC, maccc); -} - -int -mc_obio_getaddr(sc, lladdr) - struct mc_softc *sc; - u_int8_t *lladdr; -{ - bus_space_handle_t bsh; - u_char csum; - - if (bus_space_map(sc->sc_regt, MACE_PROM_BASE, 8*16, 0, &bsh)) { - printf(": failed to map space to read MACE address.\n%s", - sc->sc_dev.dv_xname); - return (-1); - } - - if (!mac68k_bus_space_probe(sc->sc_regt, bsh, 0, 1)) { - bus_space_unmap(sc->sc_regt, bsh, 8*16); - return (-1); - } - - csum = mc_get_enaddr(sc->sc_regt, bsh, 1, lladdr); - if (csum != 0xff) - printf(": ethernet PROM checksum failed (0x%x != 0xff)\n%s", - (int)csum, sc->sc_dev.dv_xname); - - bus_space_unmap(sc->sc_regt, bsh, 8*16); - - return (csum == 0xff ? 0 : -1); -} diff --git a/sys/arch/mac68k/dev/if_mcreg.h b/sys/arch/mac68k/dev/if_mcreg.h deleted file mode 100644 index 45d53bab652..00000000000 --- a/sys/arch/mac68k/dev/if_mcreg.h +++ /dev/null @@ -1,201 +0,0 @@ -/* $OpenBSD: if_mcreg.h,v 1.2 2004/12/15 06:48:24 martin Exp $ */ -/* NetBSD: if_mcreg.h,v 1.3 2004/03/26 12:15:46 wiz Exp $ */ - -/*- - * Copyright (c) 1997 David Huang <khym@azeotrope.org> - * 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. 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. - * - */ - -/* - * AMD MACE (Am79C940) register definitions - */ -#define MACE_RCVFIFO 0 /* Receive FIFO [15-00] (read only) */ -#define MACE_XMTFIFO 1 /* Transmit FIFO [15-00] (write only) */ -#define MACE_XMTFC 2 /* Transmit Frame Control (read/write) */ -#define MACE_XMTFS 3 /* Transmit Frame Status (read only) */ -#define MACE_XMTRC 4 /* Transmit Retry Count (read only) */ -#define MACE_RCVFC 5 /* Receive Frame Control (read/write) */ -#define MACE_RCVFS 6 /* Receive Frame Status (4 bytes) (read only) */ -#define MACE_FIFOFC 7 /* FIFO Frame Count (read only) */ -#define MACE_IR 8 /* Interrupt Register (read only) */ -#define MACE_IMR 9 /* Interrupt Mask Register (read/write) */ -#define MACE_PR 10 /* Poll Register (read only) */ -#define MACE_BIUCC 11 /* BIU Configuration Control (read/write) */ -#define MACE_FIFOCC 12 /* FIFO Configuration Control (read/write) */ -#define MACE_MACCC 13 /* MAC Configuration Control (read/write) */ -#define MACE_PLSCC 14 /* PLS Configuration Control (read/write) */ -#define MACE_PHYCC 15 /* PHY Confiuration Control (read/write) */ -#define MACE_CHIPIDL 16 /* Chip ID Register [07-00] (read only) */ -#define MACE_CHIPIDH 17 /* Chip ID Register [15-08] (read only) */ -#define MACE_IAC 18 /* Internal Address Configuration (read/write) */ -/* RESERVED 19 Reserved (read/write as 0) */ -#define MACE_LADRF 20 /* Logical Address Filter (8 bytes) (read/write) */ -#define MACE_PADR 21 /* Physical Address (6 bytes) (read/write) */ -/* RESERVED 22 Reserved (read/write as 0) */ -/* RESERVED 23 Reserved (read/write as 0) */ -#define MACE_MPC 24 /* Missed Packet Count (read only) */ -/* RESERVED 25 Reserved (read/write as 0) */ -#define MACE_RNTPC 26 /* Runt Packet Count (read only) */ -#define MACE_RCVCC 27 /* Receive Collision Count (read only) */ -/* RESERVED 28 Reserved (read/write as 0) */ -#define MACE_UTR 29 /* User Test Register (read/write) */ -#define MACE_RTR1 30 /* Reserved Test Register 1 (read/write as 0) */ -#define MACE_RTR2 31 /* Reserved Test Register 2 (read/write as 0) */ - -#define MACE_NREGS 32 - -/* 2: Transmit Frame Control (XMTFC) */ -#define DRTRY 0x80 /* Disable Retry */ -#define DXMTFCS 0x08 /* Disable Transmit FCS */ -#define APADXMT 0x01 /* Auto Pad Transmit */ - -/* 3: Transmit Frame Status (XMTFS) */ -#define XMTSV 0x80 /* Transmit Status Valid */ -#define UFLO 0x40 /* Underflow */ -#define LCOL 0x20 /* Late Collision */ -#define MORE 0x10 /* More than one retry needed */ -#define ONE 0x08 /* Exactly one retry needed */ -#define DEFER 0x04 /* Transmission deferred */ -#define LCAR 0x02 /* Loss of Carrier */ -#define RTRY 0x01 /* Retry Error */ - -/* 4: Transmit Retry Count (XMTRC) */ -#define EXDEF 0x80 /* Excessive Defer */ -#define XMTRC 0x0f /* Transmit Retry Count */ - -/* 5: Receive Frame Control (RCVFC) */ -#define LLRCV 0x08 /* Low Latency Receive */ -#define MR 0x04 /* Match/Reject */ -#define ASTRPRCV 0x01 /* Auto Strip Receive */ - -/* 6: Receive Frame Status (RCVFS) */ -/* 4 byte register; read 4 times to get all of the bytes */ -/* Read 1: RFS0 - Receive Message Byte Count [7-0] (RCVCNT) */ - -/* Read 2: RFS1 - Receive Status (RCVSTS) */ -#define OFLO 0x80 /* Overflow flag */ -#define CLSN 0x40 /* Collision flag */ -#define FRAM 0x20 /* Framing Error flag */ -#define FCS 0x10 /* FCS Error flag */ -#define RCVCNT 0x0f /* Receive Message Byte Count [11-8] */ - -/* Read 3: RFS2 - Runt Packet Count (RNTPC) [7-0] */ - -/* Read 4: RFS3 - Receive Collision Count (RCVCC) [7-0] */ - -/* 7: FIFO Frame Count (FIFOFC) */ -#define RCVFC 0xf0 /* Receive Frame Count */ -#define XMTFC 0x0f /* Transmit Frame Count */ - -/* 8: Interrupt Register (IR) */ -#define JAB 0x80 /* Jabber Error */ -#define BABL 0x40 /* Babble Error */ -#define CERR 0x20 /* Collision Error */ -#define RCVCCO 0x10 /* Receive Collision Count Overflow */ -#define RNTPCO 0x08 /* Runt Packet Count Overflow */ -#define MPCO 0x04 /* Missed Packet Count Overflow */ -#define RCVINT 0x02 /* Receive Interrupt */ -#define XMTINT 0x01 /* Transmit Interrupt */ - -/* 9: Interrut Mask Register (IMR) */ -#define JABM 0x80 /* Jabber Error Mask */ -#define BABLM 0x40 /* Babble Error Mask */ -#define CERRM 0x20 /* Collision Error Mask */ -#define RCVCCOM 0x10 /* Receive Collision Count Overflow Mask */ -#define RNTPCOM 0x08 /* Runt Packet Count Overflow Mask */ -#define MPCOM 0x04 /* Missed Packet Count Overflow Mask */ -#define RCVINTM 0x02 /* Receive Interrupt Mask */ -#define XMTINTM 0x01 /* Transmit Interrupt Mask */ - -/* 10: Poll Register (PR) */ -#define XMTSV 0x80 /* Transmit Status Valid */ -#define TDTREQ 0x40 /* Transmit Data Transfer Request */ -#define RDTREQ 0x20 /* Receive Data Transfer Request */ - -/* 11: BIU Configuration Control (BIUCC) */ -#define BSWP 0x40 /* Byte Swap */ -#define XMTSP 0x30 /* Transmit Start Point */ -#define XMTSP_4 0x00 /* 4 bytes */ -#define XMTSP_16 0x10 /* 16 bytes */ -#define XMTSP_64 0x20 /* 64 bytes */ -#define XMTSP_112 0x30 /* 112 bytes */ -#define SWRST 0x01 /* Software Reset */ - -/* 12: FIFO Configuration Control (FIFOCC) */ -#define XMTFW 0xc0 /* Transmit FIFO Watermark */ -#define XMTFW_8 0x00 /* 8 write cycles */ -#define XMTFW_16 0x40 /* 16 write cycles */ -#define XMTFW_32 0x80 /* 32 write cycles */ -#define RCVFW 0x30 /* Receive FIFO Watermark */ -#define RCVFW_16 0x00 /* 16 bytes */ -#define RCVFW_32 0x10 /* 32 bytes */ -#define RCVFW_64 0x20 /* 64 bytes */ -#define XMTFWU 0x08 /* Transmit FIFO Watermark Update */ -#define RCVFWU 0x04 /* Receive FIFO Watermark Update */ -#define XMTBRST 0x02 /* Transmit Burst */ -#define RCVBRST 0x01 /* Receive Burst */ - -/* 13: MAC Configuration (MACCC) */ -#define PROM 0x80 /* Promiscuous */ -#define DXMT2PD 0x40 /* Disable Transmit Two Part Deferral */ -#define EMBA 0x20 /* Enable Modified Back-off Algorithm */ -#define DRCVPA 0x08 /* Disable Receive Physical Address */ -#define DRCVBC 0x04 /* Disable Receive Broadcast */ -#define ENXMT 0x02 /* Enable Transmit */ -#define ENRCV 0x01 /* Enable Receive */ - -/* 14: PLS Configuration Control (PLSCC) */ -#define XMTSEL 0x08 /* Transmit Mode Select */ -#define PORTSEL 0x06 /* Port Select */ -#define PORTSEL_AUI 0x00 /* Select AUI */ -#define PORTSEL_10BT 0x02 /* Select 10BASE-T */ -#define PORTSEL_DAI 0x04 /* Select DAI port */ -#define PORTSEL_GPSI 0x06 /* Select GPSI */ -#define ENPLSIO 0x01 /* Enable PLS I/O */ - -/* 15: PHY Configuration (PHYCC) */ -#define LNKFL 0x80 /* Link Fail */ -#define DLNKTST 0x40 /* Disable Link Test */ -#define REVPOL 0x20 /* Reversed Polarity */ -#define DAPC 0x10 /* Disable Auto Polarity Correction */ -#define LRT 0x08 /* Low Receive Threshold */ -#define ASEL 0x04 /* Auto Select */ -#define RWAKE 0x02 /* Remote Wake */ -#define AWAKE 0x01 /* Auto Wake */ - -/* 18: Internal Address Configuration (IAC) */ -#define ADDRCHG 0x80 /* Address Change */ -#define PHYADDR 0x04 /* Physical Address Reset */ -#define LOGADDR 0x02 /* Logical Address Reset */ - -/* 28: User Test Register (UTR) */ -#define RTRE 0x80 /* Reserved Test Register Enable */ -#define RTRD 0x40 /* Reserved Test Register Disable */ -#define RPA 0x20 /* Run Packet Accept */ -#define FCOLL 0x10 /* Force Collision */ -#define RCVFCSE 0x08 /* Receive FCS Enable */ -#define LOOP 0x06 /* Loopback Control */ -#define LOOP_NONE 0x00 /* No Loopback */ -#define LOOP_EXT 0x02 /* External Loopback */ -#define LOOP_INT 0x04 /* Internal Loopback, excludes MENDEC */ -#define LOOP_INT_MENDEC 0x06 /* Internal Loopback, includes MENDEC */ diff --git a/sys/arch/mac68k/dev/if_mcvar.h b/sys/arch/mac68k/dev/if_mcvar.h deleted file mode 100644 index 062c8600cee..00000000000 --- a/sys/arch/mac68k/dev/if_mcvar.h +++ /dev/null @@ -1,85 +0,0 @@ -/* $OpenBSD: if_mcvar.h,v 1.5 2006/06/24 13:23:27 miod Exp $ */ -/* $NetBSD: if_mcvar.h,v 1.8 2004/03/26 12:15:46 wiz Exp $ */ - -/*- - * Copyright (c) 1997 David Huang <khym@azeotrope.org> - * 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. 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. - * - */ - -#define MC_REGSPACING 16 -#define MC_REGSIZE MACE_NREGS * MC_REGSPACING -#define MACE_REG(x) ((x)*MC_REGSPACING) - -#define NIC_GET(sc, reg) (bus_space_read_1((sc)->sc_regt, \ - (sc)->sc_regh, MACE_REG(reg))) - -#define NIC_PUT(sc, reg, val) (bus_space_write_1((sc)->sc_regt, \ - (sc)->sc_regh, MACE_REG(reg), (val))) - -#ifndef MC_RXDMABUFS -#define MC_RXDMABUFS 4 -#endif -#if (MC_RXDMABUFS < 2) -#error Must have at least two buffers for DMA! -#endif - -#define MC_NPAGES ((MC_RXDMABUFS * 0x800 + PAGE_SIZE - 1) / PAGE_SIZE) - -struct mc_rxframe { - u_int8_t rx_rcvcnt; - u_int8_t rx_rcvsts; - u_int8_t rx_rntpc; - u_int8_t rx_rcvcc; - u_char *rx_frame; -}; - -struct mc_softc { - struct device sc_dev; /* base device glue */ - struct arpcom sc_ethercom; /* Ethernet common part */ -#define sc_if sc_ethercom.ac_if - - struct mc_rxframe sc_rxframe; - u_int8_t sc_biucc; - u_int8_t sc_fifocc; - u_int8_t sc_plscc; - u_int8_t sc_enaddr[6]; - u_int8_t sc_pad[2]; - int sc_havecarrier; /* carrier status */ - void (*sc_bus_init)(struct mc_softc *); - void (*sc_putpacket)(struct mc_softc *, u_int); - - bus_space_tag_t sc_regt; - bus_space_handle_t sc_regh; - - u_char *sc_txbuf, *sc_rxbuf; - paddr_t sc_txbuf_phys, sc_rxbuf_phys; - int sc_tail; - int sc_rxset; - int sc_txset, sc_txseti; -}; - -int mcsetup(struct mc_softc *, u_int8_t *); -void mcintr(void *arg); -void mc_rint(struct mc_softc *sc); -u_char mc_get_enaddr(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, u_char *dst); diff --git a/sys/arch/mac68k/dev/if_sm_nubus.c b/sys/arch/mac68k/dev/if_sm_nubus.c deleted file mode 100644 index 447c814ce9a..00000000000 --- a/sys/arch/mac68k/dev/if_sm_nubus.c +++ /dev/null @@ -1,166 +0,0 @@ -/* $OpenBSD: if_sm_nubus.c,v 1.3 2009/03/29 21:53:52 sthen Exp $ */ -/* $NetBSD: if_sm_nubus.c,v 1.2 2000/08/01 13:08:39 briggs Exp $ */ - -/* - * Copyright (c) 2000 Allen Briggs. - * 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. 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. - */ - -#include <sys/param.h> -#include <sys/device.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/socket.h> -#include <sys/syslog.h> -#include <sys/systm.h> - -#include <net/if.h> - -#ifdef INET -#include <netinet/in.h> -#include <netinet/if_ether.h> -#endif - -#include <machine/bus.h> -#include <machine/viareg.h> - -#include <net/if_media.h> - -#include <dev/mii/mii.h> -#include <dev/mii/miivar.h> - -#include <dev/ic/smc91cxxreg.h> -#include <dev/ic/smc91cxxvar.h> - -#include <mac68k/dev/nubus.h> - -static int sm_nubus_match(struct device *, void *, void *); -static void sm_nubus_attach(struct device *, struct device *, void *); - -struct cfattach sm_nubus_ca = { - sizeof(struct smc91cxx_softc), sm_nubus_match, sm_nubus_attach -}; - -static int -sm_nubus_match(parent, cf, aux) - struct device *parent; - void *cf; - void *aux; -{ - struct nubus_attach_args *na = (struct nubus_attach_args *) aux; - bus_space_handle_t bsh; - int rv; - - if (bus_space_map(na->na_tag, - NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &bsh)) - return (0); - - rv = 0; - - if (na->category == NUBUS_CATEGORY_NETWORK && - na->type == NUBUS_TYPE_ETHERNET) { - switch (na->drsw) { - case NUBUS_DRSW_FOCUS: - case NUBUS_DRSW_ASANTEF: - rv = 1; - break; - default: - rv = 0; - break; - } - } - - bus_space_unmap(na->na_tag, bsh, NBMEMSIZE); - - return rv; -} - -/* - * Install interface into kernel networking data structures - */ -static void -sm_nubus_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct smc91cxx_softc *smc = (struct smc91cxx_softc *) self; - struct nubus_attach_args *na = (struct nubus_attach_args *)aux; - bus_space_tag_t bst = na->na_tag; - bus_space_handle_t bsh, prom_bsh; - u_int8_t myaddr[ETHER_ADDR_LEN]; - int i, success; - char *cardtype; - - bst = na->na_tag; - if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &bsh)) { - printf(": can't map mem space.\n"); - return; - } - - mac68k_bus_space_handle_swapped(bst, &bsh); - - smc->sc_bst = bst; - smc->sc_bsh = bsh; - - cardtype = nubus_get_card_name(bst, bsh, na->fmt); - - success = 0; - - switch (na->drsw) { - case NUBUS_DRSW_FOCUS: - if (bus_space_subregion(bst, bsh, 0xFF8000, 0x20, &prom_bsh)) { - printf(": can't map EEPROM space\n"); - break; - } - - success = 1; - break; - case NUBUS_DRSW_ASANTEF: - if (bus_space_subregion(bst, bsh, 0xFE0000, 0x20, &prom_bsh)) { - printf(": can't map EEPROM space\n"); - break; - } - - success = 1; - break; - } - - if (!success) { - bus_space_unmap(bst, bsh, NBMEMSIZE); - return; - } - for (i=0 ; i<6 ; i++) { - myaddr[i] = bus_space_read_1(bst, prom_bsh, i*4); - } - - smc->sc_flags |= SMC_FLAGS_ENABLED; - - printf(": %s", cardtype); - - smc91cxx_attach(smc, myaddr); - - add_nubus_intr(na->slot, IPL_NET, smc91cxx_intr, smc, - smc->sc_dev.dv_xname); -} diff --git a/sys/arch/mac68k/dev/if_sn.c b/sys/arch/mac68k/dev/if_sn.c deleted file mode 100644 index 4a3bf5a08e5..00000000000 --- a/sys/arch/mac68k/dev/if_sn.c +++ /dev/null @@ -1,1173 +0,0 @@ -/* $OpenBSD: if_sn.c,v 1.55 2011/04/07 15:30:15 miod Exp $ */ -/* $NetBSD: if_sn.c,v 1.13 1997/04/25 03:40:10 briggs Exp $ */ - -/* - * National Semiconductor DP8393X SONIC Driver - * Copyright (c) 1991 Algorithmics Ltd (http://www.algor.co.uk) - * You may use, copy, and modify this program so long as you retain the - * copyright line. - * - * This driver has been substantially modified since Algorithmics donated - * it. - * - * Denton Gentry <denny1@home.com> - * and also - * Yanagisawa Takeshi <yanagisw@aa.ap.titech.ac.jp> - * did the work to get this running on the Macintosh. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/mbuf.h> -#include <sys/buf.h> -#include <sys/protosw.h> -#include <sys/socket.h> -#include <sys/syslog.h> -#include <sys/ioctl.h> -#include <sys/errno.h> -#include <sys/device.h> - -#include <net/if.h> -#include <net/if_dl.h> - -#ifdef INET -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/in_var.h> -#include <netinet/ip.h> -#include <netinet/if_ether.h> -#endif - -#include <uvm/uvm_extern.h> - -#include "bpfilter.h" -#if NBPFILTER > 0 -#include <net/bpf.h> -#include <net/bpfdesc.h> -#endif - -#include <machine/bus.h> -#include <machine/cpu.h> -/* #include <machine/viareg.h> */ -#include <mac68k/dev/if_snreg.h> -#include <mac68k/dev/if_snvar.h> - -static void snwatchdog(struct ifnet *); -static int sninit(struct sn_softc *); -static int snstop(struct sn_softc *); -static int snioctl(struct ifnet *, u_long, caddr_t); -static void snstart(struct ifnet *); -static void snreset(struct sn_softc *); - -static void caminitialise(struct sn_softc *); -static void camentry(struct sn_softc *, int, u_char *); -static void camprogram(struct sn_softc *); -static void initialise_tda(struct sn_softc *); -static void initialise_rda(struct sn_softc *); -static void initialise_rra(struct sn_softc *); -#ifdef SNDEBUG -static void camdump(struct sn_softc *); -#endif - -static void sonictxint(struct sn_softc *); -static void sonicrxint(struct sn_softc *); - -static __inline__ int sonicput(struct sn_softc *, struct mbuf *, - int); -static __inline__ int sonic_read(struct sn_softc *, caddr_t, int); -static __inline__ struct mbuf *sonic_get(struct sn_softc *, caddr_t, int); - -struct cfdriver sn_cd = { - NULL, "sn", DV_IFNET -}; - -/* - * SONIC buffers need to be aligned 16 or 32 bit aligned. - * These macros calculate and verify alignment. - */ -#define ROUNDUP(p, N) (((int) p + N - 1) & ~(N - 1)) - -#define SOALIGN(m, array) (m ? (ROUNDUP(array, 4)) : (ROUNDUP(array, 2))) - -#define LOWER(x) ((unsigned)(x) & 0xffff) -#define UPPER(x) ((unsigned)(x) >> 16) - -/* - * Interface exists: make available by filling in network interface - * record. System will initialize the interface when it is ready - * to accept packets. - */ -int -snsetup(struct sn_softc *sc, u_int8_t *lladdr) -{ - struct ifnet *ifp = &sc->sc_if; - struct pglist pglist; - vm_page_t pg; - paddr_t phys; - vaddr_t p, pp; - int i, offset, error; - - /* - * XXX if_sn.c is intended to be MI. Should it allocate memory - * for its descriptor areas, or expect the MD attach code - * to do that? - */ - TAILQ_INIT(&pglist); - error = uvm_pglistalloc(SN_NPAGES * PAGE_SIZE, 0, -1, - PAGE_SIZE, 0, &pglist, 1, UVM_PLA_NOWAIT); - if (error != 0) { - printf(": could not allocate descriptor memory\n"); - return (error); - } - - /* - * Map the pages uncached. - */ - sc->space = uvm_km_valloc(kernel_map, SN_NPAGES * PAGE_SIZE); - if (sc->space == 0) { - printf(": can't map descriptor memory\n"); - uvm_pglistfree(&pglist); - return (ENOMEM); - } - - phys = VM_PAGE_TO_PHYS(TAILQ_FIRST(&pglist)); - p = pp = sc->space; - TAILQ_FOREACH(pg, &pglist, pageq) { - pmap_enter_cache(pmap_kernel(), p, VM_PAGE_TO_PHYS(pg), - UVM_PROT_RW, UVM_PROT_RW | PMAP_WIRED, PG_CI); - p += PAGE_SIZE; - } - pmap_update(pmap_kernel()); - p = pp; - - /* - * Put the pup in reset mode (sninit() will fix it later), - * stop the timer, disable all interrupts and clear any interrupts. - */ - NIC_PUT(sc, SNR_CR, CR_STP); - wbflush(); - NIC_PUT(sc, SNR_CR, CR_RST); - wbflush(); - NIC_PUT(sc, SNR_IMR, 0); - wbflush(); - NIC_PUT(sc, SNR_ISR, ISR_ALL); - wbflush(); - - for (i = 0; i < NRRA; i++) { - sc->p_rra[i] = (void *)p; - sc->v_rra[i] = (p - sc->space) + phys; - p += RXRSRC_SIZE(sc); - } - sc->v_rea = (p - sc->space) + phys; - - p = SOALIGN(sc, p); - - sc->p_cda = (void *)(p); - sc->v_cda = (p - sc->space) + phys; - p += CDA_SIZE(sc); - - p = SOALIGN(sc, p); - - for (i = 0; i < NTDA; i++) { - struct mtd *mtdp = &sc->mtda[i]; - mtdp->mtd_txp = (void *)p; - mtdp->mtd_vtxp = (p - sc->space) + phys; - p += TXP_SIZE(sc); - } - - p = SOALIGN(sc, p); - -#ifdef DIAGNOSTIC - if ((p - pp) > PAGE_SIZE) { - printf (": sizeof RRA (%ld) + CDA (%ld) +" - "TDA (%ld) > PAGE_SIZE (%d). Punt!\n", - (ulong)sc->p_cda - (ulong)sc->p_rra[0], - (ulong)sc->mtda[0].mtd_txp - (ulong)sc->p_cda, - (ulong)p - (ulong)sc->mtda[0].mtd_txp, - PAGE_SIZE); - return (EINVAL); - } -#endif - - p = pp + PAGE_SIZE; - pp = p; - - sc->sc_nrda = PAGE_SIZE / RXPKT_SIZE(sc); - sc->p_rda = (caddr_t)p; - sc->v_rda = (p - sc->space) + phys; - - p = pp + PAGE_SIZE; - - for (i = 0; i < NRBA; i++) { - sc->rbuf[i] = (caddr_t)p; - sc->rbuf_phys[i] = (p - sc->space) + phys; - p += PAGE_SIZE; - } - - pp = p; - offset = 0; - for (i = 0; i < NTDA; i++) { - struct mtd *mtdp = &sc->mtda[i]; - - mtdp->mtd_buf = (caddr_t)p; - mtdp->mtd_vbuf = (p - sc->space) + phys; - offset += TXBSIZE; - if (offset < PAGE_SIZE - TXBSIZE) { - p += TXBSIZE; - } else { - p = pp + PAGE_SIZE; - pp = p; - offset = 0; - } - } - -#ifdef SNDEBUG - camdump(sc); -#endif - printf("address %s\n", ether_sprintf(lladdr)); - -#ifdef SNDEBUG - printf("%s: buffers: rra=%p cda=%p rda=%p tda=%p\n", - sc->sc_dev.dv_xname, sc->p_rra[0], sc->p_cda, - sc->p_rda, sc->mtda[0].mtd_txp); -#endif - - bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); - bcopy(lladdr, sc->sc_enaddr, ETHER_ADDR_LEN); - - ifp->if_softc = sc; - ifp->if_ioctl = snioctl; - ifp->if_start = snstart; - ifp->if_flags = - IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; - ifp->if_watchdog = snwatchdog; - if_attach(ifp); - ether_ifattach(ifp); - - return (0); -} - -static int -snioctl(struct ifnet *ifp, u_long cmd, caddr_t data) -{ - struct sn_softc *sc = ifp->if_softc; - struct ifaddr *ifa = (struct ifaddr *) data; - int s, err = 0; - - s = splnet(); - - switch (cmd) { - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - (void)sninit(sc); - arp_ifinit(&sc->sc_arpcom, ifa); - break; -#endif - default: - (void)sninit(sc); - break; - } - break; - - case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { - /* - * If interface is marked down and it is running, - * then stop it. - */ - snstop(sc); - ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { - /* - * If interface is marked up and it is stopped, - * then start it. - */ - (void)sninit(sc); - } else { - /* - * reset the interface to pick up any other changes - * in flags - */ - snreset(sc); - snstart(ifp); - } - break; - - default: - err = ether_ioctl(ifp, &sc->sc_arpcom, cmd, data); - } - - if (err == ENETRESET) { - if (ifp->if_flags & IFF_RUNNING) - snreset(sc); - err = 0; - } - - splx(s); - return (err); -} - -/* - * Encapsulate a packet of type family for the local net. - */ -static void -snstart(struct ifnet *ifp) -{ - struct sn_softc *sc = ifp->if_softc; - struct mbuf *m; - int mtd_next; - - if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) - return; - -outloop: - /* Check for room in the xmit buffer. */ - if ((mtd_next = (sc->mtd_free + 1)) == NTDA) - mtd_next = 0; - - if (mtd_next == sc->mtd_hw) { - ifp->if_flags |= IFF_OACTIVE; - return; - } - - IF_DEQUEUE(&ifp->if_snd, m); - if (m == NULL) - return; - - /* We need the header for m_pkthdr.len. */ - if ((m->m_flags & M_PKTHDR) == 0) - panic("%s: snstart: no header mbuf", sc->sc_dev.dv_xname); - -#if NBPFILTER > 0 - /* - * If bpf is listening on this interface, let it - * see the packet before we commit it to the wire. - */ - if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT); -#endif - - /* - * If there is nothing in the o/p queue, and there is room in - * the Tx ring, then send the packet directly. Otherwise append - * it to the o/p queue. - */ - if ((sonicput(sc, m, mtd_next)) > 0) { - } else { - IF_PREPEND(&ifp->if_snd, m); - return; - } - - sc->mtd_prev = sc->mtd_free; - sc->mtd_free = mtd_next; - - ifp->if_opackets++; /* # of pkts */ - - /* Jump back for possibly more punishment. */ - goto outloop; -} - -/* - * reset and restart the SONIC. Called in case of fatal - * hardware/software errors. - */ -static void -snreset(struct sn_softc *sc) -{ - snstop(sc); - sninit(sc); -} - -static int -sninit(struct sn_softc *sc) -{ - u_long s_rcr; - int s; - - if (sc->sc_if.if_flags & IFF_RUNNING) - /* already running */ - return (0); - - s = splnet(); - - NIC_PUT(sc, SNR_CR, CR_RST); /* DCR only accessible in reset mode! */ - - /* config it */ - NIC_PUT(sc, SNR_DCR, (sc->snr_dcr | - (sc->bitmode ? DCR_DW32 : DCR_DW16))); - NIC_PUT(sc, SNR_DCR2, sc->snr_dcr2); - - s_rcr = RCR_BRD | RCR_LBNONE; - if (sc->sc_if.if_flags & IFF_PROMISC) - s_rcr |= RCR_PRO; - if (sc->sc_if.if_flags & IFF_ALLMULTI) - s_rcr |= RCR_AMC; - NIC_PUT(sc, SNR_RCR, s_rcr); - - NIC_PUT(sc, SNR_IMR, (IMR_PRXEN | IMR_PTXEN | IMR_TXEREN | IMR_LCDEN)); - - /* clear pending interrupts */ - NIC_PUT(sc, SNR_ISR, ISR_ALL); - - /* clear tally counters */ - NIC_PUT(sc, SNR_CRCT, -1); - NIC_PUT(sc, SNR_FAET, -1); - NIC_PUT(sc, SNR_MPT, -1); - - initialise_tda(sc); - initialise_rda(sc); - initialise_rra(sc); - - /* enable the chip */ - NIC_PUT(sc, SNR_CR, 0); - wbflush(); - - /* program the CAM */ - camprogram(sc); - - /* get it to read resource descriptors */ - NIC_PUT(sc, SNR_CR, CR_RRRA); - wbflush(); - while ((NIC_GET(sc, SNR_CR)) & CR_RRRA) - continue; - - /* enable rx */ - NIC_PUT(sc, SNR_CR, CR_RXEN); - wbflush(); - - /* flag interface as "running" */ - sc->sc_if.if_flags |= IFF_RUNNING; - sc->sc_if.if_flags &= ~IFF_OACTIVE; - - splx(s); - return (0); -} - -/* - * close down an interface and free its buffers - * Called on final close of device, or if sninit() fails - * part way through. - */ -static int -snstop(struct sn_softc *sc) -{ - struct mtd *mtd; - int s = splnet(); - - /* stick chip in reset */ - NIC_PUT(sc, SNR_CR, CR_RST); - wbflush(); - - /* free all receive buffers (currently static so nothing to do) */ - - /* free all pending transmit mbufs */ - while (sc->mtd_hw != sc->mtd_free) { - mtd = &sc->mtda[sc->mtd_hw]; - if (mtd->mtd_mbuf) - m_freem(mtd->mtd_mbuf); - if (++sc->mtd_hw == NTDA) sc->mtd_hw = 0; - } - - sc->sc_if.if_timer = 0; - sc->sc_if.if_flags &= ~IFF_RUNNING; - - splx(s); - return (0); -} - -/* - * Called if any Tx packets remain unsent after 5 seconds, - * In all cases we just reset the chip, and any retransmission - * will be handled by higher level protocol timeouts. - */ -static void -snwatchdog(struct ifnet *ifp) -{ - struct sn_softc *sc = ifp->if_softc; - struct mtd *mtd; - - if (sc->mtd_hw != sc->mtd_free) { - /* something still pending for transmit */ - mtd = &sc->mtda[sc->mtd_hw]; - if (SRO(sc->bitmode, mtd->mtd_txp, TXP_STATUS) == 0) - log(LOG_ERR, "%s: Tx - timeout\n", - sc->sc_dev.dv_xname); - else - log(LOG_ERR, "%s: Tx - lost interrupt\n", - sc->sc_dev.dv_xname); - snreset(sc); - } -} - -/* - * stuff packet into sonic (at splnet) - */ -static __inline__ int -sonicput(struct sn_softc *sc, struct mbuf *m0, int mtd_next) -{ - struct mtd *mtdp; - struct mbuf *m; - u_char *buff; - void *txp; - u_int len = 0; - u_int totlen = 0; - - /* grab the replacement mtd */ - mtdp = &sc->mtda[sc->mtd_free]; - - buff = mtdp->mtd_buf; - - /* this packet goes to mtdnext fill in the TDA */ - mtdp->mtd_mbuf = m0; - txp = mtdp->mtd_txp; - - /* Write to the config word. Every (NTDA/2)+1 packets we set an intr */ - if (sc->mtd_pint == 0) { - sc->mtd_pint = NTDA/2; - SWO(sc->bitmode, txp, TXP_CONFIG, TCR_PINT); - } else { - sc->mtd_pint--; - SWO(sc->bitmode, txp, TXP_CONFIG, 0); - } - - for (m = m0; m; m = m->m_next) { - u_char *data = mtod(m, u_char *); - len = m->m_len; - totlen += len; - bcopy(data, buff, len); - buff += len; - } - if (totlen >= TXBSIZE) { - panic("%s: sonicput: packet overflow", sc->sc_dev.dv_xname); - } - - SWO(sc->bitmode, txp, TXP_FRAGOFF + (0 * TXP_FRAGSIZE) + TXP_FPTRLO, - LOWER(mtdp->mtd_vbuf)); - SWO(sc->bitmode, txp, TXP_FRAGOFF + (0 * TXP_FRAGSIZE) + TXP_FPTRHI, - UPPER(mtdp->mtd_vbuf)); - - if (totlen < ETHERMIN + ETHER_HDR_LEN) { - int pad = ETHERMIN + ETHER_HDR_LEN - totlen; - bzero(mtdp->mtd_buf + totlen, pad); - totlen = ETHERMIN + ETHER_HDR_LEN; - } - - SWO(sc->bitmode, txp, TXP_FRAGOFF + (0 * TXP_FRAGSIZE) + TXP_FSIZE, - totlen); - SWO(sc->bitmode, txp, TXP_FRAGCNT, 1); - SWO(sc->bitmode, txp, TXP_PKTSIZE, totlen); - - /* link onto the next mtd that will be used */ - SWO(sc->bitmode, txp, TXP_FRAGOFF + (1 * TXP_FRAGSIZE) + TXP_FPTRLO, - LOWER(sc->mtda[mtd_next].mtd_vtxp) | EOL); - - /* - * The previous txp.tlink currently contains a pointer to - * our txp | EOL. Want to clear the EOL, so write our - * pointer to the previous txp. - */ - SWO(sc->bitmode, sc->mtda[sc->mtd_prev].mtd_txp, sc->mtd_tlinko, - LOWER(mtdp->mtd_vtxp)); - - /* make sure chip is running */ - wbflush(); - NIC_PUT(sc, SNR_CR, CR_TXP); - wbflush(); - sc->sc_if.if_timer = 5; /* 5 seconds to watch for failing to transmit */ - - return (totlen); -} - -/* - * These are called from sonicioctl() when /etc/ifconfig is run to set - * the address or switch the i/f on. - */ -/* - * CAM support - */ -static void -caminitialise(struct sn_softc *sc) -{ - void *p_cda = sc->p_cda; - int i; - int bitmode = sc->bitmode; - int camoffset; - - for (i = 0; i < MAXCAM; i++) { - camoffset = i * CDA_CAMDESC; - SWO(bitmode, p_cda, (camoffset + CDA_CAMEP), i); - SWO(bitmode, p_cda, (camoffset + CDA_CAMAP2), 0); - SWO(bitmode, p_cda, (camoffset + CDA_CAMAP1), 0); - SWO(bitmode, p_cda, (camoffset + CDA_CAMAP0), 0); - } - SWO(bitmode, p_cda, CDA_ENABLE, 0); -} - -static void -camentry(struct sn_softc *sc, int entry, u_char *ea) -{ - void *p_cda = sc->p_cda; - int bitmode = sc->bitmode; - int camoffset = entry * CDA_CAMDESC; - - SWO(bitmode, p_cda, camoffset + CDA_CAMEP, entry); - SWO(bitmode, p_cda, camoffset + CDA_CAMAP2, (ea[5] << 8) | ea[4]); - SWO(bitmode, p_cda, camoffset + CDA_CAMAP1, (ea[3] << 8) | ea[2]); - SWO(bitmode, p_cda, camoffset + CDA_CAMAP0, (ea[1] << 8) | ea[0]); - SWO(bitmode, p_cda, CDA_ENABLE, - (SRO(bitmode, p_cda, CDA_ENABLE) | (1 << entry))); -} - -static void -camprogram(struct sn_softc *sc) -{ - struct ether_multistep step; - struct ether_multi *enm; - struct ifnet *ifp; - int timeout; - int mcount = 0; - - caminitialise(sc); - - ifp = &sc->sc_if; - - /* Always load our own address first. */ - camentry (sc, mcount, sc->sc_enaddr); - mcount++; - - /* Assume we won't need allmulti bit. */ - ifp->if_flags &= ~IFF_ALLMULTI; - - /* Loop through multicast addresses */ - ETHER_FIRST_MULTI(step, &sc->sc_arpcom, enm); - while (enm != NULL) { - if (mcount == MAXCAM) { - ifp->if_flags |= IFF_ALLMULTI; - break; - } - - if (bcmp(enm->enm_addrlo, enm->enm_addrhi, - sizeof(enm->enm_addrlo)) != 0) { - /* - * SONIC's CAM is programmed with specific - * addresses. It has no way to specify a range. - * (Well, thats not exactly true. If the - * range is small one could program each addr - * within the range as a separate CAM entry) - */ - ifp->if_flags |= IFF_ALLMULTI; - break; - } - - /* program the CAM with the specified entry */ - camentry(sc, mcount, enm->enm_addrlo); - mcount++; - - ETHER_NEXT_MULTI(step, enm); - } - - NIC_PUT(sc, SNR_CDP, LOWER(sc->v_cda)); - NIC_PUT(sc, SNR_CDC, MAXCAM); - NIC_PUT(sc, SNR_CR, CR_LCAM); - wbflush(); - - timeout = 10000; - while ((NIC_GET(sc, SNR_CR) & CR_LCAM) && timeout--) - continue; - if (timeout == 0) { - /* XXX */ - panic("%s: CAM initialisation failed", sc->sc_dev.dv_xname); - } - timeout = 10000; - while (((NIC_GET(sc, SNR_ISR) & ISR_LCD) == 0) && timeout--) - continue; - - if (NIC_GET(sc, SNR_ISR) & ISR_LCD) - NIC_PUT(sc, SNR_ISR, ISR_LCD); - else - printf("%s: CAM initialisation without interrupt\n", - sc->sc_dev.dv_xname); -} - -#ifdef SNDEBUG -static void -camdump(struct sn_softc *sc) -{ - int i; - - printf("CAM entries:\n"); - NIC_PUT(sc, SNR_CR, CR_RST); - wbflush(); - - for (i = 0; i < 16; i++) { - ushort ap2, ap1, ap0; - NIC_PUT(sc, SNR_CEP, i); - wbflush(); - ap2 = NIC_GET(sc, SNR_CAP2); - ap1 = NIC_GET(sc, SNR_CAP1); - ap0 = NIC_GET(sc, SNR_CAP0); - printf("%d: ap2=0x%x ap1=0x%x ap0=0x%x\n", i, ap2, ap1, ap0); - } - printf("CAM enable 0x%x\n", NIC_GET(sc, SNR_CEP)); - - NIC_PUT(sc, SNR_CR, 0); - wbflush(); -} -#endif - -static void -initialise_tda(struct sn_softc *sc) -{ - struct mtd *mtd; - int i; - - for (i = 0; i < NTDA; i++) { - mtd = &sc->mtda[i]; - mtd->mtd_mbuf = 0; - } - - sc->mtd_hw = 0; - sc->mtd_prev = NTDA - 1; - sc->mtd_free = 0; - sc->mtd_tlinko = TXP_FRAGOFF + 1*TXP_FRAGSIZE + TXP_FPTRLO; - sc->mtd_pint = NTDA/2; - - NIC_PUT(sc, SNR_UTDA, UPPER(sc->mtda[0].mtd_vtxp)); - NIC_PUT(sc, SNR_CTDA, LOWER(sc->mtda[0].mtd_vtxp)); -} - -static void -initialise_rda(struct sn_softc *sc) -{ - int bitmode = sc->bitmode; - int i; - caddr_t p_rda = 0; - u_int32_t v_rda = 0; - - /* link the RDA's together into a circular list */ - for (i = 0; i < (sc->sc_nrda - 1); i++) { - p_rda = sc->p_rda + (i * RXPKT_SIZE(sc)); - v_rda = sc->v_rda + ((i+1) * RXPKT_SIZE(sc)); - SWO(bitmode, p_rda, RXPKT_RLINK, LOWER(v_rda)); - SWO(bitmode, p_rda, RXPKT_INUSE, 1); - } - p_rda = sc->p_rda + ((sc->sc_nrda - 1) * RXPKT_SIZE(sc)); - SWO(bitmode, p_rda, RXPKT_RLINK, LOWER(sc->v_rda) | EOL); - SWO(bitmode, p_rda, RXPKT_INUSE, 1); - - /* mark end of receive descriptor list */ - sc->sc_rdamark = sc->sc_nrda - 1; - - sc->sc_rxmark = 0; - - NIC_PUT(sc, SNR_URDA, UPPER(sc->v_rda)); - NIC_PUT(sc, SNR_CRDA, LOWER(sc->v_rda)); - wbflush(); -} - -static void -initialise_rra(struct sn_softc *sc) -{ - int i; - u_int v; - int bitmode = sc->bitmode; - - if (bitmode) - NIC_PUT(sc, SNR_EOBC, RBASIZE(sc) / 2 - 2); - else - NIC_PUT(sc, SNR_EOBC, RBASIZE(sc) / 2 - 1); - - NIC_PUT(sc, SNR_URRA, UPPER(sc->v_rra[0])); - NIC_PUT(sc, SNR_RSA, LOWER(sc->v_rra[0])); - /* rea must point just past the end of the rra space */ - NIC_PUT(sc, SNR_REA, LOWER(sc->v_rea)); - NIC_PUT(sc, SNR_RRP, LOWER(sc->v_rra[0])); - NIC_PUT(sc, SNR_RSC, 0); - - /* fill up SOME of the rra with buffers */ - for (i = 0; i < NRBA; i++) { - v = sc->rbuf_phys[i]; - SWO(bitmode, sc->p_rra[i], RXRSRC_PTRHI, UPPER(v)); - SWO(bitmode, sc->p_rra[i], RXRSRC_PTRLO, LOWER(v)); - SWO(bitmode, sc->p_rra[i], RXRSRC_WCHI, UPPER(PAGE_SIZE/2)); - SWO(bitmode, sc->p_rra[i], RXRSRC_WCLO, LOWER(PAGE_SIZE/2)); - } - sc->sc_rramark = NRBA; - NIC_PUT(sc, SNR_RWP, LOWER(sc->v_rra[sc->sc_rramark])); - wbflush(); -} - -int -snintr(void *arg) -{ - struct sn_softc *sc = (struct sn_softc *)arg; - int isr; - int rv = 0; - - while ((isr = (NIC_GET(sc, SNR_ISR) & ISR_ALL)) != 0) { - rv = 1; - /* scrub the interrupts that we are going to service */ - NIC_PUT(sc, SNR_ISR, isr); - wbflush(); - - if (isr & (ISR_BR | ISR_LCD | ISR_TC)) - printf("%s: unexpected interrupt status 0x%x\n", - sc->sc_dev.dv_xname, isr); - - if (isr & (ISR_TXDN | ISR_TXER | ISR_PINT)) - sonictxint(sc); - - if (isr & ISR_PKTRX) - sonicrxint(sc); - - if (isr & (ISR_HBL | ISR_RDE | ISR_RBE | ISR_RBAE | ISR_RFO)) { - if (isr & ISR_HBL) - /* - * The repeater is not providing a heartbeat. - * In itself this isn't harmful, lots of the - * cheap repeater hubs don't supply a heartbeat. - * So ignore the lack of heartbeat. Its only - * if we can't detect a carrier that we have a - * problem. - */ - ; - if (isr & ISR_RDE) - printf("%s: receive descriptors exhausted\n", - sc->sc_dev.dv_xname); - if (isr & ISR_RBE) - printf("%s: receive buffers exhausted\n", - sc->sc_dev.dv_xname); - if (isr & ISR_RBAE) - printf("%s: receive buffer area exhausted\n", - sc->sc_dev.dv_xname); - if (isr & ISR_RFO) - printf("%s: receive FIFO overrun\n", - sc->sc_dev.dv_xname); - if (isr & (ISR_RDE | ISR_RBE | ISR_RBAE /* | ISR_RFO */)) - snreset(sc); - } - if (isr & (ISR_CRC | ISR_FAE | ISR_MP)) { -#ifdef notdef - if (isr & ISR_CRC) - sc->sc_crctally++; - if (isr & ISR_FAE) - sc->sc_faetally++; - if (isr & ISR_MP) - sc->sc_mptally++; -#endif - } - snstart(&sc->sc_if); - } - - return (rv); -} - -/* - * Transmit interrupt routine - */ -static void -sonictxint(struct sn_softc *sc) -{ - struct mtd *mtd; - void *txp; - unsigned short txp_status; - int mtd_hw; - struct ifnet *ifp = &sc->sc_if; - - mtd_hw = sc->mtd_hw; - - if (mtd_hw == sc->mtd_free) - return; - - while (mtd_hw != sc->mtd_free) { - mtd = &sc->mtda[mtd_hw]; - - txp = mtd->mtd_txp; - - if (SRO(sc->bitmode, txp, TXP_STATUS) == 0) { - break; /* it hasn't really gone yet */ - } - -#ifdef SNDEBUG - { - struct ether_header *eh; - - eh = (struct ether_header *) mtd->mtd_buf; - printf("%s: xmit status=0x%x len=%d type=0x%x from %s", - sc->sc_dev.dv_xname, - SRO(sc->bitmode, txp, TXP_STATUS), - SRO(sc->bitmode, txp, TXP_PKTSIZE), - htons(eh->ether_type), - ether_sprintf(eh->ether_shost)); - printf(" (to %s)\n", ether_sprintf(eh->ether_dhost)); - } -#endif /* SNDEBUG */ - - ifp->if_flags &= ~IFF_OACTIVE; - - if (mtd->mtd_mbuf != 0) { - m_freem(mtd->mtd_mbuf); - mtd->mtd_mbuf = 0; - } - if (++mtd_hw == NTDA) mtd_hw = 0; - - txp_status = SRO(sc->bitmode, txp, TXP_STATUS); - - ifp->if_collisions += (txp_status & TCR_EXC) ? 16 : - ((txp_status & TCR_NC) >> 12); - - if ((txp_status & TCR_PTX) == 0) { - ifp->if_oerrors++; - - /* XXX - DG This looks bogus */ - if (mtd_hw != sc->mtd_free) { - mtd = &sc->mtda[mtd_hw]; - NIC_PUT(sc, SNR_CTDA, LOWER(mtd->mtd_vtxp)); - NIC_PUT(sc, SNR_CR, CR_TXP); - wbflush(); - break; - } - } - } - - sc->mtd_hw = mtd_hw; - return; -} - -/* - * Receive interrupt routine - */ -static void -sonicrxint(struct sn_softc *sc) -{ - caddr_t rda; - int orra; - int len; - int rramark; - int rdamark; - int bitmode = sc->bitmode; - u_int16_t rxpkt_ptr; - - rda = sc->p_rda + (sc->sc_rxmark * RXPKT_SIZE(sc)); - - while (SRO(bitmode, rda, RXPKT_INUSE) == 0) { - u_int status = SRO(bitmode, rda, RXPKT_STATUS); - - orra = RBASEQ(SRO(bitmode, rda, RXPKT_SEQNO)) & RRAMASK; - rxpkt_ptr = SRO(bitmode, rda, RXPKT_PTRLO); - len = SRO(bitmode, rda, RXPKT_BYTEC) - FCSSIZE; - if (status & RCR_PRX) { - caddr_t pkt = sc->rbuf[orra & RBAMASK] + - m68k_page_offset(rxpkt_ptr); - if (sonic_read(sc, pkt, len)) - sc->sc_if.if_ipackets++; - else - sc->sc_if.if_ierrors++; - } else - sc->sc_if.if_ierrors++; - - /* - * give receive buffer area back to chip. - * - * If this was the last packet in the RRA, give the RRA to - * the chip again. - * If sonic read didnt copy it out then we would have to - * wait !! - * (dont bother add it back in again straight away) - * - * Really, we're doing p_rra[rramark] = p_rra[orra] but - * we have to use the macros because SONIC might be in - * 16 or 32 bit mode. - */ - if (status & RCR_LPKT) { - void *tmp1, *tmp2; - - rramark = sc->sc_rramark; - tmp1 = sc->p_rra[rramark]; - tmp2 = sc->p_rra[orra]; - SWO(bitmode, tmp1, RXRSRC_PTRLO, - SRO(bitmode, tmp2, RXRSRC_PTRLO)); - SWO(bitmode, tmp1, RXRSRC_PTRHI, - SRO(bitmode, tmp2, RXRSRC_PTRHI)); - SWO(bitmode, tmp1, RXRSRC_WCLO, - SRO(bitmode, tmp2, RXRSRC_WCLO)); - SWO(bitmode, tmp1, RXRSRC_WCHI, - SRO(bitmode, tmp2, RXRSRC_WCHI)); - - /* zap old rra for fun */ - SWO(bitmode, tmp2, RXRSRC_WCHI, 0); - SWO(bitmode, tmp2, RXRSRC_WCLO, 0); - - sc->sc_rramark = (++rramark) & RRAMASK; - NIC_PUT(sc, SNR_RWP, LOWER(sc->v_rra[rramark])); - wbflush(); - } - - /* - * give receive descriptor back to chip simple - * list is circular - */ - rdamark = sc->sc_rdamark; - SWO(bitmode, rda, RXPKT_INUSE, 1); - SWO(bitmode, rda, RXPKT_RLINK, - SRO(bitmode, rda, RXPKT_RLINK) | EOL); - SWO(bitmode, (sc->p_rda + (rdamark * RXPKT_SIZE(sc))), RXPKT_RLINK, - SRO(bitmode, (sc->p_rda + (rdamark * RXPKT_SIZE(sc))), - RXPKT_RLINK) & ~EOL); - sc->sc_rdamark = sc->sc_rxmark; - - if (++sc->sc_rxmark >= sc->sc_nrda) - sc->sc_rxmark = 0; - rda = sc->p_rda + (sc->sc_rxmark * RXPKT_SIZE(sc)); - } -} - -/* - * sonic_read -- pull packet off interface and forward to - * appropriate protocol handler - */ -static __inline__ int -sonic_read(struct sn_softc *sc, caddr_t pkt, int len) -{ - struct ifnet *ifp = &sc->sc_if; -#ifdef SNDEBUG - struct ether_header *et; -#endif - struct mbuf *m; - -#ifdef SNDEBUG - /* - * Get pointer to ethernet header (in input buffer). - */ - et = (struct ether_header *)pkt; - - printf("%s: rcvd %p len=%d type=0x%x from %s", - sc->sc_dev.dv_xname, et, len, htons(et->ether_type), - ether_sprintf(et->ether_shost)); - printf(" (to %s)\n", ether_sprintf(et->ether_dhost)); -#endif /* SNDEBUG */ - - if (len < (ETHER_MIN_LEN - ETHER_CRC_LEN) || - len > (ETHER_MAX_LEN - ETHER_CRC_LEN)) { - printf("%s: invalid packet length %d bytes\n", - sc->sc_dev.dv_xname, len); - return (0); - } - - m = sonic_get(sc, pkt, len); - if (m == NULL) - return (0); -#if NBPFILTER > 0 - /* Pass this up to any BPF listeners. */ - if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); -#endif - ether_input_mbuf(ifp, m); - return (1); -} - -/* - * munge the received packet into an mbuf chain - */ -static __inline__ struct mbuf * -sonic_get(struct sn_softc *sc, caddr_t pkt, int datalen) -{ - struct mbuf *m, *top, **mp; - int len; - - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) - return (NULL); - - m->m_pkthdr.rcvif = &sc->sc_if; - m->m_pkthdr.len = datalen; - len = MHLEN; - top = 0; - mp = ⊤ - - while (datalen > 0) { - if (top) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == NULL) { - m_freem(top); - return (NULL); - } - len = MLEN; - } - if (datalen >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if ((m->m_flags & M_EXT) == 0) { - if (top) - m_freem(top); - return (NULL); - } - len = MCLBYTES; - } - m->m_len = len = min(datalen, len); - - bcopy(pkt, mtod(m, caddr_t), (unsigned) len); - pkt += len; - datalen -= len; - *mp = m; - mp = &m->m_next; - } - - return (top); -} - -static u_char bbr4[] = {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15}; -#define bbr(v) ((bbr4[(v)&0xf] << 4) | bbr4[((v)>>4) & 0xf]) - -void -sn_get_enaddr(bus_space_tag_t t, bus_space_handle_t h, bus_addr_t o, - u_char *dst) -{ - int i, do_bbr; - u_char b; - - /* - * For reasons known only to Apple, MAC addresses in the ethernet - * PROM are stored in Token Ring (IEEE 802.5) format, that is - * with all of the bits in each byte reversed (canonical bit format). - * When the address is read out it must be reversed to ethernet format - * before use. - * - * Apple has been assigned OUI's 08:00:07 and 00:a0:40. All onboard - * ethernet addresses on 68K machines should be in one of these - * two ranges. - * - * Here is where it gets complicated. - * - * The PMac 7200, 7500, 8500, and 9500 accidentally had the PROM - * written in standard ethernet format. The MacOS accounted for this - * in these systems, and did not reverse the bytes. Some other - * networking utilities were not so forgiving, and got confused. - * "Some" of Apple's Nubus ethernet cards also had their bits - * burned in ethernet format. - * - * Apple petitioned the IEEE and was granted the 00:05:02 (bit reversal - * of 00:a0:40) as well. As of OpenTransport 1.1.1, Apple removed - * their workaround and now reverses the bits regardless of - * what kind of machine it is. So PMac systems and the affected - * Nubus cards now use 00:05:02, instead of the 00:a0:40 for which they - * were intended. - * - * See Apple Techinfo article TECHINFO-0020552, "OpenTransport 1.1.1 - * and MacOS System 7.5.3 FAQ (10/96)" for more details. - */ - do_bbr = 0; - b = bus_space_read_1(t, h, o); - if (b == 0x10) - do_bbr = 1; - dst[0] = (do_bbr) ? bbr(b) : b; - - for (i = 1 ; i < ETHER_ADDR_LEN ; i++) { - b = bus_space_read_1(t, h, o+i); - dst[i] = (do_bbr) ? bbr(b) : b; - } -} diff --git a/sys/arch/mac68k/dev/if_sn_nubus.c b/sys/arch/mac68k/dev/if_sn_nubus.c deleted file mode 100644 index 5da3bcd0714..00000000000 --- a/sys/arch/mac68k/dev/if_sn_nubus.c +++ /dev/null @@ -1,297 +0,0 @@ -/* $OpenBSD: if_sn_nubus.c,v 1.20 2009/03/29 21:53:52 sthen Exp $ */ -/* $NetBSD: if_sn_nubus.c,v 1.13 1997/05/11 19:11:34 scottr Exp $ */ -/* - * Copyright (C) 1997 Allen Briggs - * 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 Allen Briggs - * 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. - */ - -#include <sys/param.h> -#include <sys/device.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/socket.h> -#include <sys/syslog.h> -#include <sys/systm.h> - -#include <net/if.h> - -#ifdef INET -#include <netinet/in.h> -#include <netinet/if_ether.h> -#endif - -#include <machine/bus.h> -#include <machine/viareg.h> - -#include <mac68k/dev/nubus.h> -#include <mac68k/dev/if_snreg.h> -#include <mac68k/dev/if_snvar.h> - -#define INTERFACE_NAME_LEN 32 - -static int sn_nubus_match(struct device *, void *, void *); -static void sn_nubus_attach(struct device *, struct device *, void *); -static int sn_nb_card_vendor(bus_space_tag_t, bus_space_handle_t, - struct nubus_attach_args *); - -struct cfattach sn_nubus_ca = { - sizeof(struct sn_softc), sn_nubus_match, sn_nubus_attach -}; - - -static int -sn_nubus_match(struct device *parent, void *cf, void *aux) -{ - struct nubus_attach_args *na = (struct nubus_attach_args *) aux; - bus_space_handle_t bsh; - int rv; - - if (bus_space_map(na->na_tag, - NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &bsh)) - return (0); - - rv = 0; - - if (na->category == NUBUS_CATEGORY_NETWORK && - na->type == NUBUS_TYPE_ETHERNET) { - switch (sn_nb_card_vendor(na->na_tag, bsh, na)) { - default: - break; - - case SN_VENDOR_APPLE: - case SN_VENDOR_APPLE16: - case SN_VENDOR_ASANTELC: - case SN_VENDOR_DAYNA: - rv = 1; - break; - } - } - - bus_space_unmap(na->na_tag, bsh, NBMEMSIZE); - - return (rv); -} - -/* - * Install interface into kernel networking data structures - */ -static void -sn_nubus_attach(struct device *parent, struct device *self, void *aux) -{ - struct sn_softc *sc = (void *)self; - struct nubus_attach_args *na = (struct nubus_attach_args *)aux; - int i, success, offset; - bus_space_tag_t bst; - bus_space_handle_t bsh, tmp_bsh; - u_int8_t myaddr[ETHER_ADDR_LEN]; - char cardtype[INTERFACE_NAME_LEN]; /* type string */ - - (void)(&offset); /* Work around lame gcc initialization bug */ - - bst = na->na_tag; - if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &bsh)) { - printf(": can't map mem space\n"); - return; - } - - sc->sc_regt = bst; - - strncpy(cardtype, nubus_get_card_name(bst, bsh, na->fmt), - INTERFACE_NAME_LEN); - - success = 0; - - sc->slotno = na->slot; - - switch (sn_nb_card_vendor(bst, bsh, na)) { - case SN_VENDOR_DAYNA: - sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 | - DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16; - sc->snr_dcr2 = 0; - sc->bitmode = 1; /* 32 bit card */ - - if (bus_space_subregion(bst, bsh, - 0x00180000, SN_REGSIZE, &sc->sc_regh)) { - printf(": can't map register space\n"); - break; - } - - if (bus_space_subregion(bst, bsh, - 0x00ffe004, ETHER_ADDR_LEN, &tmp_bsh)) { - printf(": can't map ROM space\n"); - break; - } - - sn_get_enaddr(bst, tmp_bsh, 0, myaddr); - - offset = 2; - success = 1; - break; - - case SN_VENDOR_APPLE: - sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 | - DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16; - sc->snr_dcr2 = 0; - sc->bitmode = 1; /* 32 bit card */ - - if (bus_space_subregion(bst, bsh, - 0x0, SN_REGSIZE, &sc->sc_regh)) { - printf(": failed to map register space.\n"); - break; - } - - if (bus_space_subregion(bst, bsh, - 0x40000, ETHER_ADDR_LEN, &tmp_bsh)) { - printf(": failed to map ROM space.\n"); - break; - } - - sn_get_enaddr(bst, tmp_bsh, 0, myaddr); - - offset = 0; - success = 1; - break; - - case SN_VENDOR_APPLE16: - sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 | DCR_EXBUS | - DCR_DMABLOCK | DCR_PO1 | DCR_RFT16 | DCR_TFT16; - sc->snr_dcr2 = 0; - sc->bitmode = 0; /* 16 bit card */ - - if (bus_space_subregion(bst, bsh, - 0x0, SN_REGSIZE, &sc->sc_regh)) { - printf(": failed to map register space.\n"); - break; - } - - if (bus_space_subregion(bst, bsh, - 0x40000, ETHER_ADDR_LEN, &tmp_bsh)) { - printf(": failed to map ROM space.\n"); - break; - } - - sn_get_enaddr(bst, tmp_bsh, 0, myaddr); - - offset = 0; - success = 1; - break; - - case SN_VENDOR_ASANTELC: /* Macintosh LC Ethernet Adapter */ - sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 | - DCR_DMABLOCK | DCR_PO1 | DCR_RFT16 | DCR_TFT16; - sc->snr_dcr2 = 0; - sc->bitmode = 0; /* 16 bit card */ - - if (bus_space_subregion(bst, bsh, - 0x0, SN_REGSIZE, &sc->sc_regh)) { - printf(": failed to map register space.\n"); - break; - } - - if (bus_space_subregion(bst, bsh, - 0x400000, ETHER_ADDR_LEN, &tmp_bsh)) { - printf(": failed to map ROM space.\n"); - break; - } - - sn_get_enaddr(bst, tmp_bsh, 0, myaddr); - - offset = 0; - success = 1; - break; - - default: - /* - * You can't actually get this default, the snmatch - * will fail for unknown hardware. If you're adding support - * for a new card, the following defaults are a - * good starting point. - */ - sc->snr_dcr = DCR_SYNC | DCR_WAIT0 | DCR_DW32 | - DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16; - sc->snr_dcr2 = 0; - success = 0; - printf(": unknown card: attachment incomplete.\n"); - } - - if (!success) { - bus_space_unmap(bst, bsh, NBMEMSIZE); - return; - } - - /* Regs are addressed as words, big endian. */ - for (i = 0; i < SN_NREGS; i++) { - sc->sc_reg_map[i] = (bus_size_t)((i * 4) + offset); - } - - printf(": %s, ", cardtype); - - /* snsetup returns 1 if something fails */ - if (snsetup(sc, myaddr)) { - bus_space_unmap(bst, bsh, NBMEMSIZE); - return; - } - - add_nubus_intr(sc->slotno, IPL_NET, snintr, sc, sc->sc_dev.dv_xname); -} - -static int -sn_nb_card_vendor(bus_space_tag_t bst, bus_space_handle_t bsh, - struct nubus_attach_args *na) -{ - int vendor = SN_VENDOR_UNKNOWN; - - switch (na->drsw) { - case NUBUS_DRSW_3COM: - if (na->drhw == NUBUS_DRHW_APPLE_SNT) - vendor = SN_VENDOR_APPLE; - else if (na->drhw == NUBUS_DRHW_APPLE_SN) - vendor = SN_VENDOR_APPLE16; - break; - case NUBUS_DRSW_APPLE: - if (na->drhw == NUBUS_DRHW_ASANTE_LC) - vendor = SN_VENDOR_ASANTELC; - else - vendor = SN_VENDOR_APPLE; - break; - case NUBUS_DRSW_TECHWORKS: - vendor = SN_VENDOR_APPLE; - break; - case NUBUS_DRSW_GATOR: - if (na->drhw == NUBUS_DRHW_KINETICS && - strncmp(nubus_get_card_name(bst, bsh, na->fmt), - "EtherPort", 9) != 0) - vendor = SN_VENDOR_DAYNA; - break; - case NUBUS_DRSW_DAYNA: - vendor = SN_VENDOR_DAYNA; - break; - } - - return (vendor); -} diff --git a/sys/arch/mac68k/dev/if_sn_obio.c b/sys/arch/mac68k/dev/if_sn_obio.c deleted file mode 100644 index 84794e924d1..00000000000 --- a/sys/arch/mac68k/dev/if_sn_obio.c +++ /dev/null @@ -1,254 +0,0 @@ -/* $OpenBSD: if_sn_obio.c,v 1.24 2007/09/10 20:29:46 miod Exp $ */ -/* $NetBSD: if_sn_obio.c,v 1.9 1997/04/22 20:56:15 scottr Exp $ */ - -/* - * Copyright (C) 1997 Allen Briggs - * 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 Allen Briggs - * 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. - */ - -#include <sys/param.h> -#include <sys/device.h> -#include <sys/errno.h> -#include <sys/ioctl.h> -#include <sys/socket.h> -#include <sys/syslog.h> -#include <sys/systm.h> - -#include <uvm/uvm_extern.h> - -#include <net/if.h> -#include <netinet/in.h> -#include <netinet/if_ether.h> - -#include <machine/bus.h> -#include <machine/cpu.h> -#include <machine/viareg.h> - -#include <mac68k/dev/obiovar.h> -#include <mac68k/dev/if_snreg.h> -#include <mac68k/dev/if_snvar.h> - -#define SONIC_REG_BASE 0x50F0A000 -#define SONIC_PROM_BASE 0x50F08000 - -static int sn_obio_match(struct device *, void *, void *); -static void sn_obio_attach(struct device *, struct device *, void *); -static int sn_obio_getaddr(struct sn_softc *, u_int8_t *); -static int sn_obio_getaddr_kludge(struct sn_softc *, u_int8_t *); - -struct cfattach sn_obio_ca = { - sizeof(struct sn_softc), sn_obio_match, sn_obio_attach -}; - -static int -sn_obio_match(struct device *parent, void *cf, void *aux) -{ - struct obio_attach_args *oa = (struct obio_attach_args *)aux; - bus_space_handle_t bsh; - int found = 0; - - if (!mac68k_machine.sonic) - return 0; - - if (bus_space_map(oa->oa_tag, - SONIC_REG_BASE, SN_REGSIZE, 0, &bsh)) - return 0; - - if (mac68k_bus_space_probe(oa->oa_tag, bsh, 0, 4)) - found = 1; - - bus_space_unmap(oa->oa_tag, bsh, SN_REGSIZE); - - return found; -} - -/* - * Install interface into kernel networking data structures - */ -static void -sn_obio_attach(struct device *parent, struct device *self, void *aux) -{ - struct obio_attach_args *oa = (struct obio_attach_args *)aux; - struct sn_softc *sc = (void *)self; - u_int8_t myaddr[ETHER_ADDR_LEN]; - int i; - - sc->snr_dcr = DCR_WAIT0 | DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16; - sc->snr_dcr2 = 0; - - sc->slotno = 9; - - switch (current_mac_model->machineid) { - case MACH_MACC610: - case MACH_MACC650: - case MACH_MACQ610: - case MACH_MACQ650: - case MACH_MACQ700: - case MACH_MACQ800: - case MACH_MACQ900: - case MACH_MACQ950: - sc->snr_dcr |= DCR_EXBUS; - sc->bitmode = 1; - break; - - case MACH_MACLC575: - case MACH_MACP580: - case MACH_MACQ630: - break; - - case MACH_MACPB500: - sc->snr_dcr |= DCR_SYNC | DCR_LBR; - sc->bitmode = 0; /* 16 bit interface */ - break; - - default: - printf(": unsupported machine type\n"); - return; - } - - sc->sc_regt = oa->oa_tag; - - if (bus_space_map(sc->sc_regt, - SONIC_REG_BASE, SN_REGSIZE, 0, &sc->sc_regh)) { - printf(": failed to map space for SONIC regs.\n"); - return; - } - - /* regs are addressed as words, big-endian. */ - for (i = 0; i < SN_NREGS; i++) { - sc->sc_reg_map[i] = (bus_size_t)((i * 4) + 2); - } - - /* - * Kind of kludge this. Comm-slot cards do not really - * have a visible type, as far as I can tell at this time, - * so assume that MacOS had it properly configured and use - * that configuration. - */ - switch (current_mac_model->machineid) { - case MACH_MACLC575: - case MACH_MACP580: - case MACH_MACQ630: - NIC_PUT(sc, SNR_CR, CR_RST); wbflush(); - i = NIC_GET(sc, SNR_DCR); - sc->snr_dcr |= (i & 0xfff0); - sc->bitmode = (i & DCR_DW) ? 1 : 0; - break; - default: - break; - } - - if (sn_obio_getaddr(sc, myaddr) && - sn_obio_getaddr_kludge(sc, myaddr)) { /* XXX kludge for PB */ - printf(": failed to get MAC address.\n"); - bus_space_unmap(sc->sc_regt, sc->sc_regh, SN_REGSIZE); - return; - } - - printf(": integrated ethernet adapter, "); - - /* snsetup returns 1 if something fails */ - if (snsetup(sc, myaddr)) { - bus_space_unmap(sc->sc_regt, sc->sc_regh, SN_REGSIZE); - return; - } - - if (mac68k_machine.aux_interrupts) - intr_establish(snintr, sc, 3, sc->sc_dev.dv_xname); - else - add_nubus_intr(sc->slotno, IPL_NET, snintr, sc, - sc->sc_dev.dv_xname); -} - -static int -sn_obio_getaddr(struct sn_softc *sc, u_int8_t *lladdr) -{ - bus_space_handle_t bsh; - - if (bus_space_map(sc->sc_regt, SONIC_PROM_BASE, PAGE_SIZE, 0, &bsh)) { - printf(": failed to map space to read SONIC address.\n%s", - sc->sc_dev.dv_xname); - return (-1); - } - - if (!mac68k_bus_space_probe(sc->sc_regt, bsh, 0, 1)) { - bus_space_unmap(sc->sc_regt, bsh, PAGE_SIZE); - return (-1); - } - - sn_get_enaddr(sc->sc_regt, bsh, 0, lladdr); - - bus_space_unmap(sc->sc_regt, bsh, PAGE_SIZE); - - return (0); -} - -/* - * Assume that the SONIC was initialized in MacOS. This should go away - * when we can properly get the MAC address on the PBs. - */ -static int -sn_obio_getaddr_kludge(struct sn_softc *sc, u_int8_t *lladdr) -{ - int i, ors = 0; - - /* Shut down NIC */ - NIC_PUT(sc, SNR_CR, CR_RST); - wbflush(); - - NIC_PUT(sc, SNR_CEP, 15); /* For some reason, Apple fills top first. */ - wbflush(); - i = NIC_GET(sc, SNR_CAP2); - wbflush(); - - ors |= i; - lladdr[5] = i >> 8; - lladdr[4] = i; - - i = NIC_GET(sc, SNR_CAP1); - wbflush(); - - ors |= i; - lladdr[3] = i >> 8; - lladdr[2] = i; - - i = NIC_GET(sc, SNR_CAP0); - wbflush(); - - ors |= i; - lladdr[1] = i >> 8; - lladdr[0] = i; - - NIC_PUT(sc, SNR_CR, 0); - wbflush(); - - if (ors == 0) - return (-1); - - return (0); -} diff --git a/sys/arch/mac68k/dev/if_snreg.h b/sys/arch/mac68k/dev/if_snreg.h deleted file mode 100644 index eda817c4f20..00000000000 --- a/sys/arch/mac68k/dev/if_snreg.h +++ /dev/null @@ -1,265 +0,0 @@ -/* $OpenBSD: if_snreg.h,v 1.4 2001/07/04 08:52:46 niklas Exp $ */ -/* $NetBSD: if_snreg.h,v 1.3 1997/04/30 19:47:12 scottr Exp $ */ - -/* - * Copyright (c) 1991 Algorithmics Ltd (http://www.algor.co.uk) - * You may use, copy, and modify this program so long as you retain the - * copyright line. - */ - -/* - * if_snreg.h -- National Semiconductor DP8393X (SONIC) register defs - */ - -/* - * SONIC registers as seen by the processor - */ -#define SNR_CR 0x00 /* Command */ -#define SNR_DCR 0x01 /* Data Configuration */ -#define SNR_RCR 0x02 /* Receive Control */ -#define SNR_TCR 0x03 /* Transmit Control */ -#define SNR_IMR 0x04 /* Interrupt Mask */ -#define SNR_ISR 0x05 /* Interrupt Status */ -#define SNR_UTDA 0x06 /* Upper Transmit Descriptor Address */ -#define SNR_CTDA 0x07 /* Current Transmit Descriptor Address */ -#define SNR_TPS 0x08 /* Transmit Packet Size */ -#define SNR_TFC 0x09 /* Transmit Fragment Count */ -#define SNR_TSA0 0x0a /* Transmit Start Address 0 */ -#define SNR_TSA1 0x0b /* Transmit Start Address 1 */ -#define SNR_TFS 0x0c /* Transmit Fragment Size */ -#define SNR_URDA 0x0d /* Upper Receive Descriptor Address */ -#define SNR_CRDA 0x0e /* Current Receive Descriptor Address */ -#define SNR_CRBA0 0x0f /* Current Receive Buffer Address 0 */ -#define SNR_CRBA1 0x10 /* Current Receive Buffer Address 1 */ -#define SNR_RBWC0 0x11 /* Remaining Buffer Word Count 0 */ -#define SNR_RBWC1 0x12 /* Remaining Buffer Word Count 1 */ -#define SNR_EOBC 0x13 /* End Of Buffer Word Count */ -#define SNR_URRA 0x14 /* Upper Receive Resource Address */ -#define SNR_RSA 0x15 /* Resource Start Address */ -#define SNR_REA 0x16 /* Resource End Address */ -#define SNR_RRP 0x17 /* Resource Read Pointer */ -#define SNR_RWP 0x18 /* Resource Write Pointer */ -#define SNR_TRBA0 0x19 /* Temporary Receive Buffer Address 0 */ -#define SNR_TRBA1 0x1a /* Temporary Receive Buffer Address 1 */ -#define SNR_TBWC0 0x1b /* Temporary Buffer Word Count 0 */ -#define SNR_TBWC1 0x1c /* Temporary Buffer Word Count 1 */ -#define SNR_ADDR0 0x1d /* Address Generator 0 */ -#define SNR_ADDR1 0x1e /* Address Generator 1 */ -#define SNR_LLFA 0x1f /* Last Link Field Address */ -#define SNR_TTDA 0x20 /* Temp Transmit Descriptor Address */ -#define SNR_CEP 0x21 /* CAM Entry Pointer */ -#define SNR_CAP2 0x22 /* CAM Address Port 2 */ -#define SNR_CAP1 0x23 /* CAM Address Port 1 */ -#define SNR_CAP0 0x24 /* CAM Address Port 0 */ -#define SNR_CE 0x25 /* CAM Enable */ -#define SNR_CDP 0x26 /* CAM Descriptor Pointer */ -#define SNR_CDC 0x27 /* CAM Descriptor Count */ -#define SNR_SR 0x28 /* Silicon Revision */ -#define SNR_WT0 0x29 /* Watchdog Timer 0 */ -#define SNR_WT1 0x2a /* Watchdog Timer 1 */ -#define SNR_RSC 0x2b /* Receive Sequence Counter */ -#define SNR_CRCT 0x2c /* CRC Error Tally */ -#define SNR_FAET 0x2d /* FAE Tally */ -#define SNR_MPT 0x2e /* Missed Packet Tally */ -#define SNR_MDT 0x2f /* Maximum Deferral Timer */ -#define SNR_RTC 0x30 /* Receive Test Control */ -#define SNR_TTC 0x31 /* Transmit Test Control */ -#define SNR_DTC 0x32 /* DMA Test Control */ -#define SNR_CC0 0x33 /* CAM Comparison 0 */ -#define SNR_CC1 0x34 /* CAM Comparison 1 */ -#define SNR_CC2 0x35 /* CAM Comparison 2 */ -#define SNR_CM 0x36 /* CAM Match */ -#define SNR_RES1 0x37 /* reserved */ -#define SNR_RES2 0x38 /* reserved */ -#define SNR_RBC 0x39 /* Receiver Byte Count */ -#define SNR_RES3 0x3a /* reserved */ -#define SNR_TBO 0x3b /* Transmitter Backoff Counter */ -#define SNR_TRC 0x3c /* Transmitter Random Counter */ -#define SNR_TBM 0x3d /* Transmitter Backoff Mask */ -#define SNR_RES4 0x3e /* Reserved */ -#define SNR_DCR2 0x3f /* Data Configuration 2 (AVF) */ - -#define SN_NREGS 0x40 - -/* - * Register Interpretations - */ - -/* - * The command register is used for issuing commands to the SONIC. - * With the exception of CR_RST, the bit is reset when the operation - * completes. - */ -#define CR_LCAM 0x0200 /* load CAM with descriptor at s_cdp */ -#define CR_RRRA 0x0100 /* read next RRA descriptor at s_rrp */ -#define CR_RST 0x0080 /* software reset */ -#define CR_ST 0x0020 /* start timer */ -#define CR_STP 0x0010 /* stop timer */ -#define CR_RXEN 0x0008 /* receiver enable */ -#define CR_RXDIS 0x0004 /* receiver disable */ -#define CR_TXP 0x0002 /* transmit packets */ -#define CR_HTX 0x0001 /* halt transmission */ - -/* - * The data configuration register establishes the SONIC's bus cycle - * operation. This register can only be accessed when the SONIC is in - * reset mode (s_cr.CR_RST is set.) - */ -#define DCR_EXBUS 0x8000 /* extended bus mode (AVF) */ -#define DCR_LBR 0x2000 /* latched bus retry */ -#define DCR_PO1 0x1000 /* programmable output 1 */ -#define DCR_PO0 0x0800 /* programmable output 0 */ -#define DCR_STERM 0x0400 /* synchronous termination */ -#define DCR_USR1 0x0200 /* reflects USR1 input pin */ -#define DCR_USR0 0x0100 /* reflects USR0 input pin */ -#define DCR_WC1 0x0080 /* wait state control 1 */ -#define DCR_WC0 0x0040 /* wait state control 0 */ -#define DCR_DW 0x0020 /* data width select */ -#define DCR_BMS 0x0010 /* DMA block mode select */ -#define DCR_RFT1 0x0008 /* receive FIFO threshold control 1 */ -#define DCR_RFT0 0x0004 /* receive FIFO threshold control 0 */ -#define DCR_TFT1 0x0002 /* transmit FIFO threshold control 1 */ -#define DCR_TFT0 0x0001 /* transmit FIFO threshold control 0 */ - -/* data configuration register aliases */ -#define DCR_SYNC DCR_STERM /* synchronous (memory cycle 2 clocks) */ -#define DCR_ASYNC 0 /* asynchronous (memory cycle 3 clocks) */ - -#define DCR_WAIT0 0 /* 0 wait states added */ -#define DCR_WAIT1 DCR_WC0 /* 1 wait state added */ -#define DCR_WAIT2 DCR_WC1 /* 2 wait states added */ -#define DCR_WAIT3 (DCR_WC1|DCR_WC0) /* 3 wait states added */ - -#define DCR_DW16 0 /* use 16-bit DMA accesses */ -#define DCR_DW32 DCR_DW /* use 32-bit DMA accesses */ - -#define DCR_DMAEF 0 /* DMA until TX/RX FIFO has emptied/filled */ -#define DCR_DMABLOCK DCR_BMS /* DMA until RX/TX threshold crossed */ - -#define DCR_RFT4 0 /* receive threshold 4 bytes */ -#define DCR_RFT8 DCR_RFT0 /* receive threshold 8 bytes */ -#define DCR_RFT16 DCR_RFT1 /* receive threshold 16 bytes */ -#define DCR_RFT24 (DCR_RFT1|DCR_RFT0) /* receive threshold 24 bytes */ - -#define DCR_TFT8 0 /* transmit threshold 8 bytes */ -#define DCR_TFT16 DCR_TFT0 /* transmit threshold 16 bytes */ -#define DCR_TFT24 DCR_TFT1 /* transmit threshold 24 bytes */ -#define DCR_TFT28 (DCR_TFT1|DCR_TFT0) /* transmit threshold 28 bytes */ - -/* - * The receive control register is used to filter incoming packets and - * provides status information on packets received. - * The contents of the register are copied into the RXpkt.status field - * when a packet is received. RCR_MC - RCR_PRX are then reset. - */ -#define RCR_ERR 0x8000 /* accept packets with CRC errors */ -#define RCR_RNT 0x4000 /* accept runt (length < 64) packets */ -#define RCR_BRD 0x2000 /* accept broadcast packets */ -#define RCR_PRO 0x1000 /* accept all physical address packets */ -#define RCR_AMC 0x0800 /* accept all multicast packets */ -#define RCR_LB1 0x0400 /* loopback control 1 */ -#define RCR_LB0 0x0200 /* loopback control 0 */ -#define RCR_MC 0x0100 /* multicast packet received */ -#define RCR_BC 0x0080 /* broadcast packet received */ -#define RCR_LPKT 0x0040 /* last packet in RBA (RBWC < EOBC) */ -#define RCR_CRS 0x0020 /* carrier sense activity */ -#define RCR_COL 0x0010 /* collision activity */ -#define RCR_CRC 0x0008 /* CRC error */ -#define RCR_FAE 0x0004 /* frame alignment error */ -#define RCR_LBK 0x0002 /* loopback packet received */ -#define RCR_PRX 0x0001 /* packet received without errors */ - -/* receiver control register aliases */ -/* the loopback control bits provide the following options */ -#define RCR_LBNONE 0 /* no loopback - normal operation */ -#define RCR_LBMAC RCR_LB0 /* MAC loopback */ -#define RCR_LBENDEC RCR_LB1 /* ENDEC loopback */ -#define RCR_LBTRANS (RCR_LB1|RCR_LB0) /* transceiver loopback */ - -/* - * The transmit control register controls the SONIC's transmit operations. - * TCR_PINT - TCR_EXDIS are loaded from the TXpkt.config field at the - * start of transmission. TCR_EXD-TCR_PTX are cleared at the beginning - * of transmission and updated when the transmission is completed. - */ -#define TCR_PINT 0x8000 /* interrupt when transmission starts */ -#define TCR_POWC 0x4000 /* program out of window collision timer */ -#define TCR_CRCI 0x2000 /* transmit packet without 4 byte FCS */ -#define TCR_EXDIS 0x1000 /* disable excessive deferral timer */ -#define TCR_EXD 0x0400 /* excessive deferrals occurred (>3.2ms) */ -#define TCR_DEF 0x0200 /* deferred transmissions occurred */ -#define TCR_NCRS 0x0100 /* carrier not present during transmission */ -#define TCR_CRSL 0x0080 /* carrier lost during transmission */ -#define TCR_EXC 0x0040 /* excessive collisions (>16) detected */ -#define TCR_OWC 0x0020 /* out of window (bad) collision occurred */ -#define TCR_PMB 0x0008 /* packet monitored bad - the tansmitted - * packet had a bad source address or CRC */ -#define TCR_FU 0x0004 /* FIFO underrun (memory access failed) */ -#define TCR_BCM 0x0002 /* byte count mismatch (TXpkt.pkt_size - * != sum(TXpkt.frag_size) */ -#define TCR_PTX 0x0001 /* packet transmitted without errors */ -#define TCR_NC 0xf000 /* after transmission, # of colls */ - -/* transmit control register aliases */ -#define TCR_OWCSFD 0 /* start after start of frame delimiter */ -#define TCR_OWCPRE TCR_POWC /* start after first bit of preamble */ - - -/* - * The interrupt mask register masks the interrupts that - * are generated from the interrupt status register. - * All reserved bits should be written with 0. - */ -#define IMR_BREN 0x4000 /* bus retry occurred enable */ -#define IMR_HBLEN 0x2000 /* heartbeat lost enable */ -#define IMR_LCDEN 0x1000 /* load CAM done interrupt enable */ -#define IMR_PINTEN 0x0800 /* programmable interrupt enable */ -#define IMR_PRXEN 0x0400 /* packet received enable */ -#define IMR_PTXEN 0x0200 /* packet transmitted enable */ -#define IMR_TXEREN 0x0100 /* transmit error enable */ -#define IMR_TCEN 0x0080 /* timer complete enable */ -#define IMR_RDEEN 0x0040 /* receive descriptors exhausted enable */ -#define IMR_RBEEN 0x0020 /* receive buffers exhausted enable */ -#define IMR_RBAEEN 0x0010 /* receive buffer area exceeded enable */ -#define IMR_CRCEN 0x0008 /* CRC tally counter rollover enable */ -#define IMR_FAEEN 0x0004 /* FAE tally counter rollover enable */ -#define IMR_MPEN 0x0002 /* MP tally counter rollover enable */ -#define IMR_RFOEN 0x0001 /* receive FIFO overrun enable */ - - -/* - * The interrupt status register indicates the source of an interrupt when - * the INT pin goes active. The interrupt is acknowledged by writing - * the appropriate bit(s) in this register. - */ -#define ISR_ALL 0x7fff /* all interrupts */ -#define ISR_BR 0x4000 /* bus retry occurred */ -#define ISR_HBL 0x2000 /* CD heartbeat lost */ -#define ISR_LCD 0x1000 /* load CAM command has completed */ -#define ISR_PINT 0x0800 /* programmed interrupt from TXpkt.config */ -#define ISR_PKTRX 0x0400 /* packet received */ -#define ISR_TXDN 0x0200 /* no remaining packets to be transmitted */ -#define ISR_TXER 0x0100 /* packet transmission caused error */ -#define ISR_TC 0x0080 /* timer complete */ -#define ISR_RDE 0x0040 /* receive descriptors exhausted */ -#define ISR_RBE 0x0020 /* receive buffers exhausted */ -#define ISR_RBAE 0x0010 /* receive buffer area exceeded */ -#define ISR_CRC 0x0008 /* CRC tally counter rollover */ -#define ISR_FAE 0x0004 /* FAE tally counter rollover */ -#define ISR_MP 0x0002 /* MP tally counter rollover */ -#define ISR_RFO 0x0001 /* receive FIFO overrun */ - -/* - * The second data configuration register allows additional user defined - * pins to be controlled. These bits are only available if s_dcr.DCR_EXBUS - * is set. - */ -#define DCR2_EXPO3 0x8000 /* EXUSR3 output */ -#define DCR2_EXPO2 0x4000 /* EXUSR2 output */ -#define DCR2_EXPO1 0x2000 /* EXUSR1 output */ -#define DCR2_EXPO0 0x1000 /* EXUSR0 output */ -#define DCR2_PHL 0x0010 /* extend HOLD signal by 1/2 clock */ -#define DCR2_LRDY 0x0008 /* set latched ready mode */ -#define DCR2_PCM 0x0004 /* packet compress on match */ -#define DCR2_PCNM 0x0002 /* packet compress on mismatch */ -#define DCR2_RJM 0x0001 /* reject on match */ diff --git a/sys/arch/mac68k/dev/if_snvar.h b/sys/arch/mac68k/dev/if_snvar.h deleted file mode 100644 index b9104b60d7f..00000000000 --- a/sys/arch/mac68k/dev/if_snvar.h +++ /dev/null @@ -1,219 +0,0 @@ -/* $OpenBSD: if_snvar.h,v 1.14 2006/06/24 13:23:27 miod Exp $ */ -/* $NetBSD: if_snvar.h,v 1.8 1997/04/25 03:40:09 briggs Exp $ */ - -/* - * Copyright (c) 1991 Algorithmics Ltd (http://www.algor.co.uk) - * You may use, copy, and modify this program so long as you retain the - * copyright line. - */ - -/* - * if_snvar.h -- National Semiconductor DP8393X (SONIC) NetBSD/mac68k vars - */ - -/* - * Vendor types - */ -#define SN_VENDOR_UNKNOWN 0xff /* Unknown */ -#define SN_VENDOR_APPLE 0x00 /* Apple Computer/compatible */ -#define SN_VENDOR_DAYNA 0x01 /* Dayna/Kinetics EtherPort */ -#define SN_VENDOR_APPLE16 0x02 /* Apple Twisted Pair Ether NB */ -#define SN_VENDOR_ASANTELC 0x09 /* Asante Macintosh LC Ethernet */ - -/* - * Memory access macros. Since we handle SONIC in 16 bit mode (PB5X0) - * and 32 bit mode (everything else) using a single GENERIC kernel - * binary, all structures have to be accessed using macros which can - * adjust the offsets appropriately. - */ -#define SWO(m, a, o, x) (m ? (*(u_int32_t *)((u_int32_t *)(a) + (o)) = (x)) : \ - (*(u_int16_t *)((u_int16_t *)(a) + (o)) = (x))) -#define SRO(m, a, o) (m ? (*(u_int32_t *)((u_int32_t *)(a) + (o)) & 0xffff) : \ - (*(u_int16_t *)((u_int16_t *)(a) + (o)) & 0xffff)) - -/* - * Register access macros. We use bus_space_* to talk to the Sonic - * registers. A mapping table is used in case a particular configuration - * hooked the regs up at non-word offsets. - */ -#define NIC_GET(sc, reg) (bus_space_read_2((sc)->sc_regt, \ - (sc)->sc_regh, \ - ((sc)->sc_reg_map[(reg)]))) -#define NIC_PUT(sc, reg, val) (bus_space_write_2((sc)->sc_regt, \ - (sc)->sc_regh, \ - ((sc)->sc_reg_map[reg]), \ - (val))) - -#define SN_REGSIZE SN_NREGS*4 - -/* mac68k does not have any write buffers to flush... */ -#define wbflush() - -/* - * buffer sizes in 32 bit mode - * 1 TXpkt is 4 hdr words + (3 * FRAGMAX) + 1 link word == 23 words == 92 bytes - * - * 1 RxPkt is 7 words == 28 bytes - * 1 Rda is 4 words == 16 bytes - * - * The CDA is 17 words == 68 bytes - * - * total space in page 0 = NTDA * 92 + NRRA * 16 + NRDA * 28 + 68 - */ - -#define NRBA 32 /* # receive buffers < NRRA */ -#define RBAMASK (NRBA-1) -#define NTDA 16 /* # transmit descriptors */ -#define NRRA 64 /* # receive resource descriptors */ -#define RRAMASK (NRRA-1) /* the reason why NRRA must be power of two */ - -#define FCSSIZE 4 /* size of FCS appended to packets */ - -/* - * maximum receive packet size plus 2 byte pad to make each - * one aligned. 4 byte slop (required for eobc) - */ -#define RBASIZE(sc) (sizeof(struct ether_header) + ETHERMTU + FCSSIZE + \ - ((sc)->bitmode ? 6 : 2)) - -/* - * transmit buffer area - */ -#define TXBSIZE 1536 /* 6*2^8 -- the same size as the 8390 TXBUF */ - -#define SN_NPAGES (2 + NRBA + (NTDA/2)) - -typedef struct mtd { - void *mtd_txp; - paddr_t mtd_vtxp; - caddr_t mtd_buf; - paddr_t mtd_vbuf; - struct mbuf *mtd_mbuf; -} mtd_t; - -/* - * The sn_softc for Mac68k if_sn. - */ -typedef struct sn_softc { - struct device sc_dev; - struct arpcom sc_arpcom; -#define sc_if sc_arpcom.ac_if -#define sc_enaddr sc_arpcom.ac_enaddr /* hardware ethernet address */ - - bus_space_tag_t sc_regt; - bus_space_handle_t sc_regh; - - int bitmode; /* 32 bit mode == 1, 16 == 0 */ - bus_size_t sc_reg_map[SN_NREGS]; /* register offsets */ - - u_int16_t snr_dcr; /* DCR for this instance */ - u_int16_t snr_dcr2; /* DCR2 for this instance */ - int slotno; /* Slot number */ - - int sc_rramark; /* index into p_rra of wp */ - void *p_rra[NRRA]; /* RX resource descs */ - paddr_t v_rra[NRRA]; /* DMA addresses of p_rra */ - u_int32_t v_rea; /* ptr to the end of the rra space */ - - int sc_rxmark; /* current hw pos in rda ring */ - int sc_rdamark; /* current sw pos in rda ring */ - int sc_nrda; /* total number of RDAs */ - caddr_t p_rda; - paddr_t v_rda; - - caddr_t rbuf[NRBA]; - paddr_t rbuf_phys[NRBA]; - - struct mtd mtda[NTDA]; - int mtd_hw; /* idx of first mtd given to hw */ - int mtd_prev; /* idx of last mtd given to hardware */ - int mtd_free; /* next free mtd to use */ - int mtd_tlinko; /* - * offset of tlink of last txp given - * to SONIC. Need to clear EOL on - * this word to add a desc. - */ - int mtd_pint; /* Counter to set TXP_PINT */ - - void *p_cda; - u_int32_t v_cda; - - vaddr_t space; -} sn_softc_t; - -/* - * Accessing SONIC data structures and registers as 32 bit values - * makes code endianess independent. The SONIC is however always in - * bigendian mode so it is necessary to ensure that data structures shared - * between the CPU and the SONIC are always in bigendian order. - */ - -/* - * Receive Resource Descriptor - * This structure describes the buffers into which packets - * will be received. Note that more than one packet may be - * packed into a single buffer if constraints permit. - */ -#define RXRSRC_PTRLO 0 /* buffer address LO */ -#define RXRSRC_PTRHI 1 /* buffer address HI */ -#define RXRSRC_WCLO 2 /* buffer size (16bit words) LO */ -#define RXRSRC_WCHI 3 /* buffer size (16bit words) HI */ - -#define RXRSRC_SIZE(sc) (sc->bitmode ? (4 * 4) : (4 * 2)) - -/* - * Receive Descriptor - * This structure holds information about packets received. - */ -#define RXPKT_STATUS 0 -#define RXPKT_BYTEC 1 -#define RXPKT_PTRLO 2 -#define RXPKT_PTRHI 3 -#define RXPKT_SEQNO 4 -#define RXPKT_RLINK 5 -#define RXPKT_INUSE 6 -#define RXPKT_SIZE(sc) (sc->bitmode ? (7 * 4) : (7 * 2)) - -#define RBASEQ(x) (((x)>>8)&0xff) -#define PSNSEQ(x) ((x) & 0xff) - -/* - * Transmit Descriptor - * This structure holds information about packets to be transmitted. - */ -#define FRAGMAX 8 /* maximum number of fragments in a packet */ - -#define TXP_STATUS 0 /* + transmitted packet status */ -#define TXP_CONFIG 1 /* transmission configuration */ -#define TXP_PKTSIZE 2 /* entire packet size in bytes */ -#define TXP_FRAGCNT 3 /* # fragments in packet */ - -#define TXP_FRAGOFF 4 /* offset to first fragment */ -#define TXP_FRAGSIZE 3 /* size of each fragment desc */ -#define TXP_FPTRLO 0 /* ptr to packet fragment LO */ -#define TXP_FPTRHI 1 /* ptr to packet fragment HI */ -#define TXP_FSIZE 2 /* fragment size */ - -#define TXP_WORDS TXP_FRAGOFF + (FRAGMAX*TXP_FRAGSIZE) + 1 /* 1 for tlink */ -#define TXP_SIZE(sc) ((sc->bitmode) ? (TXP_WORDS*4) : (TXP_WORDS*2)) - -#define EOL 0x0001 /* end of list marker for link fields */ - -/* - * CDA, the CAM descriptor area. The SONIC has a 16 entry CAM to - * match incoming addresses against. It is programmed via DMA - * from a memory region. - */ -#define MAXCAM 16 /* number of user entries in CAM */ -#define CDA_CAMDESC 4 /* # words i na descriptor */ -#define CDA_CAMEP 0 /* CAM Address Port 0 xx-xx-xx-xx-YY-YY */ -#define CDA_CAMAP0 1 /* CAM Address Port 1 xx-xx-YY-YY-xx-xx */ -#define CDA_CAMAP1 2 /* CAM Address Port 2 YY-YY-xx-xx-xx-xx */ -#define CDA_CAMAP2 3 -#define CDA_ENABLE 64 /* mask enabling CAM entries */ -#define CDA_SIZE(sc) ((4*16 + 1) * ((sc->bitmode) ? 4 : 2)) - -int snsetup(struct sn_softc *sc, u_int8_t *); -int snintr(void *); -void sn_get_enaddr(bus_space_tag_t t, bus_space_handle_t h, - bus_addr_t o, u_char *dst); diff --git a/sys/arch/mac68k/dev/mac68k5380.c b/sys/arch/mac68k/dev/mac68k5380.c deleted file mode 100644 index f518b06866a..00000000000 --- a/sys/arch/mac68k/dev/mac68k5380.c +++ /dev/null @@ -1,655 +0,0 @@ -/* $OpenBSD: mac68k5380.c,v 1.22 2006/01/16 21:45:57 miod Exp $ */ -/* $NetBSD: mac68k5380.c,v 1.29 1997/02/28 15:50:50 scottr Exp $ */ - -/* - * Copyright (c) 1995 Allen Briggs - * 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 Allen Briggs - * 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. - * - * Derived from atari5380.c for the mac68k port of NetBSD. - * - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/device.h> -#include <sys/syslog.h> -#include <sys/buf.h> -#include <scsi/scsi_all.h> -#include <scsi/scsi_message.h> -#include <scsi/scsiconf.h> - -/* - * Include the driver definitions - */ - -#include <machine/viareg.h> - -#include "ncr5380reg.h" -#include "ncr5380var.h" - -/* - * Set the various driver options - */ -#define NREQ 18 /* Size of issue queue */ -#define AUTO_SENSE 1 /* Automatically issue a request-sense */ - -#define DRNAME ncrscsi /* used in various prints */ -#undef DBG_SEL /* Show the selection process */ -#undef DBG_REQ /* Show enqueued/ready requests */ -#undef DBG_NOWRITE /* Do not allow writes to the targets */ -#undef DBG_PIO /* Show the polled-I/O process */ -#undef DBG_INF /* Show information transfer process */ -#define DBG_NOSTATIC /* No static functions, all in DDB trace*/ -#define DBG_PID 25 /* Keep track of driver */ -#ifdef DBG_NOSTATIC -# define static -#endif -#ifdef DBG_SEL -# define DBG_SELPRINT(a,b) printf(a,b) -#else -# define DBG_SELPRINT(a,b) -#endif -#ifdef DBG_PIO -# define DBG_PIOPRINT(a,b,c) printf(a,b,c) -#else -# define DBG_PIOPRINT(a,b,c) -#endif -#ifdef DBG_INF -# define DBG_INFPRINT(a,b,c) a(b,c) -#else -# define DBG_INFPRINT(a,b,c) -#endif -#ifdef DBG_PID - /* static char *last_hit = NULL, *olast_hit = NULL; */ - static char *last_hit[DBG_PID]; -# define PID(a) \ - { int i; \ - for (i=0; i < DBG_PID-1; i++) \ - last_hit[i] = last_hit[i + 1]; \ - last_hit[DBG_PID - 1] = a; } -#else -# define PID(a) -#endif - -#undef REAL_DMA /* Use DMA if sensible */ -#define scsi_ipending() (GET_5380_REG(NCR5380_DMSTAT) & SC_IRQ_SET) -#define fair_to_keep_dma() 1 -#define claimed_dma() 1 -#define reconsider_dma() -#define USE_PDMA 1 /* Use special pdma-transfer function */ -#define MIN_PHYS 0x2000 /* pdma space w/ /DSACK is only 0x2000 */ - -#define ENABLE_NCR5380(sc) cur_softc = sc; - -/* - * softc of currently active controller (well, we only have one for now). - */ - -static struct ncr_softc *cur_softc; - -struct scsi_5380 { - volatile u_char scsi_5380[8*16]; /* 8 regs, 1 every 16th byte. */ -}; - -extern vaddr_t SCSIBase; -static volatile u_char *ncr = (volatile u_char *) 0x10000; -static volatile u_char *ncr_5380_with_drq = (volatile u_char *) 0x6000; -static volatile u_char *ncr_5380_without_drq = (volatile u_char *) 0x12000; - -#define SCSI_5380 ((struct scsi_5380 *) ncr) -#define GET_5380_REG(rnum) SCSI_5380->scsi_5380[((rnum)<<4)] -#define SET_5380_REG(rnum,val) (SCSI_5380->scsi_5380[((rnum)<<4)] = (val)) - -static int ncr5380_irq_intr(void *); -static int ncr5380_drq_intr(void *); -static void do_ncr5380_drq_intr(void *); - -static __inline__ void scsi_clr_ipend(void); -static void scsi_mach_init(struct ncr_softc *sc); -static int machine_match(struct device *parent, - struct cfdata *cf, void *aux, - struct cfdriver *cd); -static __inline__ int pdma_ready(void); -static int transfer_pdma(u_char *phasep, u_char *data, - u_long *count); - -static __inline__ void -scsi_clr_ipend(void) -{ - int tmp; - - tmp = GET_5380_REG(NCR5380_IRCV); - scsi_clear_irq(); -} - -static void -scsi_mach_init(sc) - struct ncr_softc *sc; -{ - static int initted = 0; - - if (initted++) - panic("scsi_mach_init called again."); - - ncr = (volatile u_char *) - (SCSIBase + (u_long) ncr); - ncr_5380_with_drq = (volatile u_char *) - (SCSIBase + (u_int) ncr_5380_with_drq); - ncr_5380_without_drq = (volatile u_char *) - (SCSIBase + (u_int) ncr_5380_without_drq); - - if (VIA2 == VIA2OFF) { - scsi_enable = Via1Base + VIA2 * 0x2000 + vIER; - scsi_flag = Via1Base + VIA2 * 0x2000 + vIFR; - } else { - scsi_enable = Via1Base + VIA2 * 0x2000 + rIER; - scsi_flag = Via1Base + VIA2 * 0x2000 + rIFR; - } - - sc->sc_ih_irq.vh_fn = ncr5380_irq_intr; - sc->sc_ih_irq.vh_arg = sc; - sc->sc_ih_irq.vh_ipl = VIA2_SCSIIRQ; - via2_register_irq(&sc->sc_ih_irq, sc->sc_dev.dv_xname); - sc->sc_ih_drq.vh_fn = ncr5380_drq_intr; - sc->sc_ih_drq.vh_arg = sc; - sc->sc_ih_drq.vh_ipl = VIA2_SCSIDRQ; - via2_register_irq(&sc->sc_ih_drq, sc->sc_dev.dv_xname); -} - -static int -machine_match(parent, cf, aux, cd) - struct device *parent; - struct cfdata *cf; - void *aux; - struct cfdriver *cd; -{ - if (!mac68k_machine.scsi80) - return 0; - return 1; -} - -#if USE_PDMA -int pdma_5380_dir = 0; - -u_char *pending_5380_data; -u_long pending_5380_count; - -#define NCR5380_PDMA_DEBUG 1 /* Maybe we try with this off eventually. */ - -#if NCR5380_PDMA_DEBUG -int pdma_5380_sends = 0; -int pdma_5380_bytes = 0; - -void -pdma_stat(void) -{ - printf("PDMA SCSI: %d xfers completed for %d bytes.\n", - pdma_5380_sends, pdma_5380_bytes); - printf("pdma_5380_dir = %d\t", - pdma_5380_dir); - printf("datap = %p, remainder = %ld.\n", - pending_5380_data, pending_5380_count); - scsi_show(); -} -#endif - -void -pdma_cleanup(void) -{ - SC_REQ *reqp = connected; - int s; - - s = splbio(); - PID("pdma_cleanup0"); - - pdma_5380_dir = 0; - -#if NCR5380_PDMA_DEBUG - pdma_5380_sends++; - pdma_5380_bytes+=(reqp->xdata_len - pending_5380_count); -#endif - - /* - * Update pointers. - */ - reqp->xdata_ptr += reqp->xdata_len - pending_5380_count; - reqp->xdata_len = pending_5380_count; - - /* - * Reset DMA mode. - */ - SET_5380_REG(NCR5380_MODE, GET_5380_REG(NCR5380_MODE) & ~SC_M_DMA); - - /* - * Clear any pending interrupts. - */ - scsi_clr_ipend(); - - /* - * Tell interrupt functions that DMA has ended. - */ - reqp->dr_flag &= ~DRIVER_IN_DMA; - - SET_5380_REG(NCR5380_MODE, IMODE_BASE); - SET_5380_REG(NCR5380_ICOM, 0); - - splx(s); - - /* - * Back for more punishment. - */ - PID("pdma_cleanup1"); - run_main(cur_softc); - PID("pdma_cleanup2"); -} -#endif - -static __inline__ int -pdma_ready(void) -{ -#if USE_PDMA - SC_REQ *reqp = connected; - int dmstat, idstat; -extern u_char ncr5380_no_parchk; - - PID("pdma_ready0"); - if (pdma_5380_dir) { - PID("pdma_ready1."); - /* - * For a phase mis-match, ATN is a "don't care," IRQ is 1 and - * all other bits in the Bus & Status Register are 0. Also, - * the current SCSI Bus Status Register has a 1 for BSY and - * REQ. Since we're just checking that this interrupt isn't a - * reselection or a reset, we just check for either. - */ - dmstat = GET_5380_REG(NCR5380_DMSTAT); - idstat = GET_5380_REG(NCR5380_IDSTAT); - if ( ((dmstat & (0xff & ~SC_ATN_STAT)) == SC_IRQ_SET) - && ((idstat & (SC_S_BSY|SC_S_REQ)) - == (SC_S_BSY | SC_S_REQ)) ) { - PID("pdma_ready2"); - pdma_cleanup(); - return 1; - } else if (PH_IN(reqp->phase) && (dmstat & SC_PAR_ERR)) { - if (!(ncr5380_no_parchk & (1 << reqp->targ_id))) - /* XXX: Should be parity error ???? */ - reqp->xs->error = XS_DRIVER_STUFFUP; - PID("pdma_ready3"); - /* XXX: is this the right reaction? */ - pdma_cleanup(); - return 1; - } else if ( !(idstat & SC_S_REQ) - || (((idstat>>2) & 7) != reqp->phase)) { -#ifdef DIAGNOSTIC - /* XXX: is this the right reaction? Can this happen? */ - scsi_show(); - printf("Unexpected phase change.\n"); -#endif - reqp->xs->error = XS_DRIVER_STUFFUP; - pdma_cleanup(); - return 1; - } else { - scsi_show(); - panic("Spurious interrupt during PDMA xfer."); - } - } else - PID("pdma_ready4"); -#endif - return 0; -} - -static int -ncr5380_irq_intr(p) - void *p; -{ - PID("irq"); - -#if USE_PDMA - if (pdma_ready()) { - return (1); - } -#endif - scsi_idisable(); - ncr_ctrl_intr(cur_softc); - return (1); -} - -/* - * This is the meat of the PDMA transfer. - * When we get here, we shove data as fast as the mac can take it. - * We depend on several things: - * * All macs after the Mac Plus that have a 5380 chip should have a general - * logic IC that handshakes data for blind transfers. - * * If the SCSI controller finishes sending/receiving data before we do, - * the same general logic IC will generate a /BERR for us in short order. - * * The fault address for said /BERR minus the base address for the - * transfer will be the amount of data that was actually written. - * - * We use the nofault flag and the setjmp/longjmp in locore.s so we can - * detect and handle the bus error for early termination of a command. - * This is usually caused by a disconnecting target. - */ -static void -do_ncr5380_drq_intr(p) - void *p; -{ -#if USE_PDMA -extern int *nofault, m68k_fault_addr; - label_t faultbuf; - register int count; - volatile u_int32_t *long_drq; - u_int32_t *long_data; - volatile u_int8_t *drq, tmp_data; - u_int8_t *data; - -#if DBG_PID - if (pdma_5380_dir == 2) { - PID("drq (in)"); - } else { - PID("drq (out)"); - } -#endif - - /* - * Setup for a possible bus error caused by SCSI controller - * switching out of DATA-IN/OUT before we're done with the - * current transfer. - */ - nofault = (int *) &faultbuf; - - if (setjmp((label_t *) nofault)) { - PID("drq berr"); - nofault = (int *) 0; - count = ( (u_long) m68k_fault_addr - - (u_long) ncr_5380_with_drq); - if ((count < 0) || (count > pending_5380_count)) { - printf("pdma %s: cnt = %d (0x%x) (pending cnt %ld)\n", - (pdma_5380_dir == 2) ? "in" : "out", - count, count, pending_5380_count); - panic("something is wrong"); - } - - pending_5380_data += count; - pending_5380_count -= count; - - m68k_fault_addr = 0; - - PID("end drq early"); - - return; - } - - if (pdma_5380_dir == 2) { /* Data In */ - int resid; - - /* - * Get the dest address aligned. - */ - resid = count = min(pending_5380_count, - 4 - (((int) pending_5380_data) & 0x3)); - if (count && (count < 4)) { - data = (u_int8_t *) pending_5380_data; - drq = (u_int8_t *) ncr_5380_with_drq; - while (count) { -#define R1 *data++ = *drq++ - R1; count--; -#undef R1 - } - pending_5380_data += resid; - pending_5380_count -= resid; - } - - /* - * Get ready to start the transfer. - */ - while (pending_5380_count) { - int dcount; - - dcount = count = min(pending_5380_count, MIN_PHYS); - long_drq = (volatile u_int32_t *) ncr_5380_with_drq; - long_data = (u_int32_t *) pending_5380_data; - -#define R4 *long_data++ = *long_drq++ - while ( count > 64 ) { - R4; R4; R4; R4; R4; R4; R4; R4; - R4; R4; R4; R4; R4; R4; R4; R4; /* 64 */ - count -= 64; - } - while (count > 8) { - R4; R4; count -= 8; - } -#undef R4 - data = (u_int8_t *) long_data; - drq = (u_int8_t *) long_drq; - while (count) { -#define R1 *data++ = *drq++ - R1; count--; -#undef R1 - } - pending_5380_count -= dcount; - pending_5380_data += dcount; - } - } else { - int resid; - - /* - * Get the source address aligned. - */ - resid = count = min(pending_5380_count, - 4 - (((int) pending_5380_data) & 0x3)); - if (count && (count < 4)) { - data = (u_int8_t *) pending_5380_data; - drq = (u_int8_t *) ncr_5380_with_drq; - while (count) { -#define W1 *drq++ = *data++ - W1; count--; -#undef W1 - } - pending_5380_data += resid; - pending_5380_count -= resid; - } - - /* - * Get ready to start the transfer. - */ - while (pending_5380_count) { - int dcount; - - dcount = count = min(pending_5380_count, MIN_PHYS); - long_drq = (volatile u_int32_t *) ncr_5380_with_drq; - long_data = (u_int32_t *) pending_5380_data; - -#define W4 *long_drq++ = *long_data++ - while ( count > 64 ) { - W4; W4; W4; W4; W4; W4; W4; W4; - W4; W4; W4; W4; W4; W4; W4; W4; /* 64 */ - count -= 64; - } - while ( count > 8 ) { - W4; W4; - count -= 8; - } -#undef W4 - data = (u_int8_t *) long_data; - drq = (u_int8_t *) long_drq; - while (count) { -#define W1 *drq++ = *data++ - W1; count--; -#undef W1 - } - pending_5380_count -= dcount; - pending_5380_data += dcount; - } - - PID("write complete"); - - drq = (volatile u_int8_t *) ncr_5380_with_drq; - tmp_data = *drq; - - PID("read a byte to force a phase change"); - } - - /* - * OK. No bus error occurred above. Clear the nofault flag - * so we no longer short-circuit bus errors. - */ - nofault = (int *) 0; - - PID("end drq"); -#endif /* if USE_PDMA */ -} - -static int -ncr5380_drq_intr(p) - void *p; -{ - int rv = 0; - - while (GET_5380_REG(NCR5380_DMSTAT) & SC_DMA_REQ) { - do_ncr5380_drq_intr(p); - scsi_clear_drq(); - rv = 1; - } - - return (rv); -} - -#if USE_PDMA - -#define SCSI_TIMEOUT_VAL 10000000 - -static int -transfer_pdma(phasep, data, count) - u_char *phasep; - u_char *data; - u_long *count; -{ - SC_REQ *reqp = connected; - int len = *count, s, scsi_timeout = SCSI_TIMEOUT_VAL; - - if (pdma_5380_dir) { - panic("ncrscsi: transfer_pdma called when operation already " - "pending."); - } - PID("transfer_pdma0") - - /* - * Don't bother with PDMA if we can't sleep or for small transfers. - */ - if (reqp->dr_flag & DRIVER_NOINT) { - PID("pdma, falling back to transfer_pio.") - transfer_pio(phasep, data, count, 0); - return -1; - } - - /* - * We are probably already at spl2(), so this is likely a no-op. - * Paranoia. - */ - s = splbio(); - - scsi_idisable(); - - /* - * Match phases with target. - */ - SET_5380_REG(NCR5380_TCOM, *phasep); - - /* - * Clear pending interrupts. - */ - scsi_clr_ipend(); - - /* - * Wait until target asserts BSY. - */ - while ( ((GET_5380_REG(NCR5380_IDSTAT) & SC_S_BSY) == 0) - && (--scsi_timeout) ); - if (!scsi_timeout) { -#ifdef DIAGNOSTIC - printf("scsi timeout: waiting for BSY in %s.\n", - (*phasep == PH_DATAOUT) ? "pdma_out" : "pdma_in"); -#endif - goto scsi_timeout_error; - } - - /* - * Tell the driver that we're in DMA mode. - */ - reqp->dr_flag |= DRIVER_IN_DMA; - - /* - * Load transfer values for DRQ interrupt handlers. - */ - pending_5380_data = data; - pending_5380_count = len; - - /* - * Set the transfer function to be called on DRQ interrupts. - * And note that we're waiting. - */ - switch (*phasep) { - default: - panic("Unexpected phase in transfer_pdma."); - case PH_DATAOUT: - pdma_5380_dir = 1; - SET_5380_REG(NCR5380_ICOM, GET_5380_REG(NCR5380_ICOM)|SC_ADTB); - SET_5380_REG(NCR5380_MODE, GET_5380_REG(NCR5380_MODE)|SC_M_DMA); - SET_5380_REG(NCR5380_DMSTAT, 0); - break; - case PH_DATAIN: - pdma_5380_dir = 2; - SET_5380_REG(NCR5380_ICOM, 0); - SET_5380_REG(NCR5380_MODE, GET_5380_REG(NCR5380_MODE)|SC_M_DMA); - SET_5380_REG(NCR5380_IRCV, 0); - break; - } - - PID("waiting for interrupt.") - - /* - * Now that we're set up, enable interrupts and drop processor - * priority back down. - */ - scsi_ienable(); - splx(s); - return 0; - -scsi_timeout_error: - /* - * Clear the DMA mode. - */ - SET_5380_REG(NCR5380_MODE, GET_5380_REG(NCR5380_MODE) & ~SC_M_DMA); - splx(s); - return -1; -} -#endif /* if USE_PDMA */ - -/* Include general routines. */ -#include <mac68k/dev/ncr5380.c> diff --git a/sys/arch/mac68k/dev/macfb.c b/sys/arch/mac68k/dev/macfb.c deleted file mode 100644 index e31e849da39..00000000000 --- a/sys/arch/mac68k/dev/macfb.c +++ /dev/null @@ -1,574 +0,0 @@ -/* $OpenBSD: macfb.c,v 1.19 2010/12/26 15:40:59 miod Exp $ */ -/* $NetBSD: macfb.c,v 1.11 2005/01/15 16:00:59 chs Exp $ */ -/* - * Copyright (c) 1998 Matt DeBergalis - * 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 Matt DeBergalis - * 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. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/device.h> -#include <sys/malloc.h> - -#include <machine/cpu.h> -#include <machine/bus.h> - -#include <mac68k/dev/nubus.h> - -#include <uvm/uvm_extern.h> - -#include <dev/wscons/wsconsio.h> -#include <dev/wscons/wsdisplayvar.h> -#include <dev/rasops/rasops.h> - -#include <mac68k/dev/macfbvar.h> - -struct cfdriver macfb_cd = { - NULL, "macfb", DV_DULL -}; - -int macfb_ioctl(void *, u_long, caddr_t, int, struct proc *); -paddr_t macfb_mmap(void *, off_t, int); -int macfb_alloc_screen(void *, const struct wsscreen_descr *, - void **, int *, int *, long *); -void macfb_free_screen(void *, void *); -int macfb_show_screen(void *, void *, int, - void (*)(void *, int, int), void *); - -const struct wsdisplay_accessops macfb_accessops = { - macfb_ioctl, - macfb_mmap, - macfb_alloc_screen, - macfb_free_screen, - macfb_show_screen, - NULL, /* load_font */ - NULL, /* scrollback */ - NULL, /* getchar */ - NULL /* burner */ -}; - -int macfb_alloc_cattr(void *, int, int, int, long *); -int macfb_alloc_hattr(void *, int, int, int, long *); -int macfb_alloc_mattr(void *, int, int, int, long *); -int macfb_color_setup(struct macfb_devconfig *); -int macfb_getcmap(struct macfb_devconfig *, struct wsdisplay_cmap *); -int macfb_init(struct macfb_devconfig *); -int macfb_is_console(paddr_t); -void macfb_palette_setup(struct macfb_devconfig *); -int macfb_putcmap(struct macfb_devconfig *, struct wsdisplay_cmap *); - -paddr_t macfb_consaddr; - -static struct macfb_devconfig macfb_console_dc; - -/* From Booter via locore */ -extern long videoaddr; -extern long videorowbytes; -extern long videobitdepth; -extern u_long videosize; -extern u_int32_t mac68k_vidphys; -extern u_int32_t mac68k_vidlen; - -extern int rasops_alloc_cattr(void *, int, int, int, long *); - -int -macfb_is_console(paddr_t addr) -{ - if (addr != macfb_consaddr && (addr >= NBBASE && addr < NBTOP)) { - /* - * This is in the NuBus standard slot space range, so we - * may well have to look at 0xFssxxxxx, too. Mask off the - * slot number and duplicate it in bits 20-23, per IM:V - * pp 459, 463, and IM:VI ch 30 p 17. - * Note: this is an ugly hack and I wish I knew what - * to do about it. -- sr - */ - addr = (paddr_t)(((u_long)addr & 0xff0fffff) | - (((u_long)addr & 0x0f000000) >> 4)); - } - return ((mac68k_machine.serial_console & 0x03) == 0 - && (addr == macfb_consaddr)); -} - -int -macfb_init(struct macfb_devconfig *dc) -{ - struct rasops_info *ri = &dc->dc_ri; - int bgcolor; - - bzero(ri, sizeof(*ri)); - ri->ri_depth = dc->dc_depth; - ri->ri_stride = dc->dc_rowbytes; - ri->ri_flg = RI_CENTER; - ri->ri_bits = (void *)(dc->dc_vaddr + dc->dc_offset); - ri->ri_width = dc->dc_wid; - ri->ri_height = dc->dc_ht; - ri->ri_hw = dc; - - /* swap B and R if necessary */ - switch (ri->ri_depth) { - case 16: - ri->ri_rnum = 5; - ri->ri_rpos = 11; - ri->ri_gnum = 6; - ri->ri_gpos = 5; - ri->ri_bnum = 5; - ri->ri_bpos = 0; - break; - case 24: - case 32: - ri->ri_rnum = 8; - ri->ri_rpos = 16; - ri->ri_gnum = 8; - ri->ri_gpos = 8; - ri->ri_bnum = 8; - ri->ri_bpos = 0; - break; - } - - /* - * Ask for an unholy big display, rasops will trim this to more - * reasonable values. - */ - if (rasops_init(ri, 160, 160) != 0) - return (-1); - - bgcolor = macfb_color_setup(dc); - - /* - * Clear display. We can't pass RI_CLEAR in ri_flg and have rasops - * do it for us until we know how to setup the colormap first. - */ - memset((char *)dc->dc_vaddr + dc->dc_offset, bgcolor, - dc->dc_rowbytes * dc->dc_ht); - - strlcpy(dc->dc_wsd.name, "std", sizeof(dc->dc_wsd.name)); - dc->dc_wsd.ncols = ri->ri_cols; - dc->dc_wsd.nrows = ri->ri_rows; - dc->dc_wsd.textops = &ri->ri_ops; - dc->dc_wsd.fontwidth = ri->ri_font->fontwidth; - dc->dc_wsd.fontheight = ri->ri_font->fontheight; - dc->dc_wsd.capabilities = ri->ri_caps; - - return (0); -} - -int -macfb_color_setup(struct macfb_devconfig *dc) -{ - extern int rasops_alloc_cattr(void *, int, int, int, long *); - struct rasops_info *ri = &dc->dc_ri; - - /* nothing to do for non-indexed modes... */ - if (ri->ri_depth > 8) - return (0); /* fill in black */ - - if (dc->dc_setcolor == NULL || ISSET(dc->dc_flags, FB_MACOS_PALETTE) || - ri->ri_depth < 2) { - /* - * Until we know how to setup the colormap, or if we are - * already initialized (i.e. glass console), constrain ourselves - * to mono mode. Note that we need to use our own alloc_attr - * routine to compensate for inverted black and white colors. - */ - ri->ri_ops.alloc_attr = macfb_alloc_mattr; - ri->ri_caps &= ~(WSSCREEN_WSCOLORS | WSSCREEN_HILIT); - if (ri->ri_depth == 8) - ri->ri_devcmap[15] = 0xffffffff; - - macfb_palette_setup(dc); - - return (0xff); /* fill in black inherited from MacOS */ - } - - /* start from the rasops colormap */ - bcopy(rasops_cmap, dc->dc_cmap, 256 * 3); - - switch (ri->ri_depth) { - case 2: - /* - * 2bpp mode does not really have colors, only two gray - * shades in addition to black and white, to allow - * hilighting. - * - * Our palette needs to be: - * 00 black - * 01 dark gray (highlighted black, sort of) - * 02 light gray (normal white) - * 03 white (highlighted white) - */ - bcopy(dc->dc_cmap + (255 - WSCOL_WHITE) * 3, - dc->dc_cmap + 1 * 3, 3); - bcopy(dc->dc_cmap + WSCOL_WHITE * 3, dc->dc_cmap + 2 * 3, 3); - bcopy(dc->dc_cmap + (8 + WSCOL_WHITE) * 3, - dc->dc_cmap + 3 * 3, 3); - ri->ri_caps |= WSSCREEN_HILIT; - ri->ri_ops.alloc_attr = macfb_alloc_hattr; - break; - case 4: - /* - * Tweak colormap - * - * Due to the way rasops cursor work, we need to provide - * inverted copies of the 8 basic colors as the other 8 - * in 4bpp mode. - */ - bcopy(dc->dc_cmap + (256 - 8) * 3, dc->dc_cmap + 8 * 3, 8 * 3); - ri->ri_caps |= WSSCREEN_WSCOLORS; - ri->ri_ops.alloc_attr = macfb_alloc_cattr; - break; - default: - case 8: - break; - } - - (*dc->dc_setcolor)(dc, 0, 1 << ri->ri_depth); - - return (WSCOL_BLACK); /* fill in our own black */ -} - -/* - * Initialize a black and white, MacOS compatible, shadow colormap. - * This is necessary if we still want to be able to run X11 with colors. - */ -void -macfb_palette_setup(struct macfb_devconfig *dc) -{ - memset(dc->dc_cmap, 0xff, 3); /* white */ - bzero(dc->dc_cmap + 3, 255 * 3); /* black */ -} - -/* - * Attribute allocator for monochrome displays (either 1bpp or no colormap - * control). Note that the colors we return are indexes into ri_devcmap which - * will select the actual bits. - */ -int -macfb_alloc_mattr(void *cookie, int fg, int bg, int flg, long *attr) -{ - if ((flg & (WSATTR_BLINK | WSATTR_HILIT | WSATTR_WSCOLORS)) != 0) - return (EINVAL); - - /* - * Default values are white on black. However, on indexed displays, - * 0 is white and all bits set is black. - */ - if ((flg & WSATTR_REVERSE) != 0) { - fg = 15; - bg = 0; - } else { - fg = 0; - bg = 15; - } - - *attr = (bg << 16) | (fg << 24) | ((flg & WSATTR_UNDERLINE) ? 7 : 6); - return (0); -} - -/* - * Attribute allocator for 2bpp displays. - * Note that the colors we return are indexes into ri_devcmap which will - * select the actual bits. - */ -int -macfb_alloc_hattr(void *cookie, int fg, int bg, int flg, long *attr) -{ - if ((flg & (WSATTR_BLINK | WSATTR_WSCOLORS)) != 0) - return (EINVAL); - - if ((flg & WSATTR_REVERSE) != 0) { - fg = WSCOL_BLACK; - bg = WSCOL_WHITE; - } else { - fg = WSCOL_WHITE; - bg = WSCOL_BLACK; - } - - if ((flg & WSATTR_HILIT) != 0) - fg += 8; - - *attr = (bg << 16) | (fg << 24) | ((flg & WSATTR_UNDERLINE) ? 7 : 6); - return (0); -} - -/* - * Attribute allocator for 4bpp displays. - */ -int -macfb_alloc_cattr(void *cookie, int fg, int bg, int flg, long *attr) -{ - if ((flg & (WSATTR_BLINK | WSATTR_HILIT)) != 0) - return (EINVAL); - - return (rasops_alloc_cattr(cookie, fg, bg, flg, attr)); -} - -void -macfb_attach_common(struct macfb_softc *sc, struct macfb_devconfig *dc) -{ - struct wsemuldisplaydev_attach_args waa; - int isconsole; - - /* Print hardware characteristics. */ - printf("%s: %dx%d, ", sc->sc_dev.dv_xname, dc->dc_wid, dc->dc_ht); - if (dc->dc_depth == 1) - printf("monochrome"); - else - printf("%dbit color", dc->dc_depth); - printf(" display\n"); - - isconsole = macfb_is_console(sc->sc_basepa + dc->dc_offset); - - if (isconsole) { - macfb_console_dc.dc_setcolor = dc->dc_setcolor; - macfb_console_dc.dc_cmapregs = dc->dc_cmapregs; - free(dc, M_DEVBUF); - dc = sc->sc_dc = &macfb_console_dc; - dc->dc_nscreens = 1; - macfb_color_setup(dc); - /* XXX at this point we should reset the emulation to have - * it pick better attributes for kernel messages. Oh well. */ - } else { - sc->sc_dc = dc; - if (macfb_init(dc) != 0) - return; - } - - dc->dc_scrlist[0] = &dc->dc_wsd; - dc->dc_screenlist.nscreens = 1; - dc->dc_screenlist.screens = - (const struct wsscreen_descr **)dc->dc_scrlist; - - waa.console = isconsole; - waa.scrdata = &dc->dc_screenlist; - waa.accessops = &macfb_accessops; - waa.accesscookie = sc; - waa.defaultscreens = 0; - - config_found((struct device *)sc, &waa, wsemuldisplaydevprint); -} - -int -macfb_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) -{ - struct macfb_softc *sc = v; - struct macfb_devconfig *dc = sc->sc_dc; - struct wsdisplay_fbinfo *wdf; - - switch (cmd) { - case WSDISPLAYIO_GTYPE: - *(int *)data = WSDISPLAY_TYPE_MAC68K; - break; - case WSDISPLAYIO_GINFO: - wdf = (struct wsdisplay_fbinfo *)data; - wdf->height = dc->dc_ri.ri_height; - wdf->width = dc->dc_ri.ri_width; - wdf->depth = dc->dc_ri.ri_depth; - if (dc->dc_ri.ri_depth > 8 || dc->dc_setcolor == NULL) - wdf->cmsize = 0; - else - wdf->cmsize = 1 << dc->dc_ri.ri_depth; - break; - case WSDISPLAYIO_LINEBYTES: - *(u_int *)data = dc->dc_ri.ri_stride; - break; - case WSDISPLAYIO_GETCMAP: - if (dc->dc_ri.ri_depth > 8 || dc->dc_setcolor == NULL) - return (0); - return (macfb_getcmap(dc, (struct wsdisplay_cmap *)data)); - case WSDISPLAYIO_PUTCMAP: - if (dc->dc_ri.ri_depth > 8 || dc->dc_setcolor == NULL) - return (0); - return (macfb_putcmap(dc, (struct wsdisplay_cmap *)data)); - case WSDISPLAYIO_SMODE: - if (dc->dc_ri.ri_depth > 8 || dc->dc_setcolor == NULL) - return (0); - if (*(u_int *)data == WSDISPLAYIO_MODE_EMUL && - ISSET(dc->dc_flags, FB_MACOS_PALETTE)) { - macfb_palette_setup(dc); - (*dc->dc_setcolor)(dc, 0, 1 << dc->dc_ri.ri_depth); - /* clear display */ - memset((char *)dc->dc_vaddr + dc->dc_offset, 0xff, - dc->dc_rowbytes * dc->dc_ht); - } - break; - case WSDISPLAYIO_GVIDEO: - case WSDISPLAYIO_SVIDEO: - break; - default: - return (-1); - } - - return (0); -} - -paddr_t -macfb_mmap(void *v, off_t offset, int prot) -{ - struct macfb_softc *sc = v; - struct macfb_devconfig *dc = sc->sc_dc; - paddr_t addr; - - if (offset >= 0 && - offset < round_page(dc->dc_size)) - addr = (dc->dc_paddr + dc->dc_offset + offset); - else - addr = (-1); - - return addr; -} - -int -macfb_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep, - int *curxp, int *curyp, long *defattrp) -{ - struct macfb_softc *sc = v; - struct rasops_info *ri = &sc->sc_dc->dc_ri; - - if (sc->sc_dc->dc_nscreens > 0) - return (ENOMEM); - - *cookiep = ri; - *curxp = *curyp = 0; - ri->ri_ops.alloc_attr(ri, 0, 0, 0, defattrp); - sc->sc_dc->dc_nscreens++; - - return (0); -} - -void -macfb_free_screen(void *v, void *cookie) -{ - struct macfb_softc *sc = v; - - sc->sc_dc->dc_nscreens--; -} - -int -macfb_show_screen(void *v, void *cookie, int waitok, - void (*cb)(void *, int, int), void *cbarg) -{ - return (0); -} - -int -macfb_getcmap(struct macfb_devconfig *dc, struct wsdisplay_cmap *cm) -{ - u_int index = cm->index, count = cm->count; - u_int colcount = 1 << dc->dc_ri.ri_depth; - int i, error; - u_int8_t ramp[256], *c, *r; - - if (index >= colcount || count > colcount - index) - return (EINVAL); - - /* extract reds */ - c = dc->dc_cmap + 0 + index * 3; - for (i = count, r = ramp; i != 0; i--) - *r++ = *c, c += 3; - if ((error = copyout(ramp, cm->red, count)) != 0) - return (error); - - /* extract greens */ - c = dc->dc_cmap + 1 + index * 3; - for (i = count, r = ramp; i != 0; i--) - *r++ = *c, c += 3; - if ((error = copyout(ramp, cm->green, count)) != 0) - return (error); - - /* extract blues */ - c = dc->dc_cmap + 2 + index * 3; - for (i = count, r = ramp; i != 0; i--) - *r++ = *c, c += 3; - if ((error = copyout(ramp, cm->blue, count)) != 0) - return (error); - - return (0); -} - -int -macfb_putcmap(struct macfb_devconfig *dc, struct wsdisplay_cmap *cm) -{ - u_int index = cm->index, count = cm->count; - u_int colcount = 1 << dc->dc_ri.ri_depth; - int i, error; - u_int8_t r[256], g[256], b[256], *nr, *ng, *nb, *c; - - if (index >= colcount || count > colcount - index) - return (EINVAL); - - if ((error = copyin(cm->red, r, count)) != 0) - return (error); - if ((error = copyin(cm->green, g, count)) != 0) - return (error); - if ((error = copyin(cm->blue, b, count)) != 0) - return (error); - - nr = r, ng = g, nb = b; - c = dc->dc_cmap + index * 3; - for (i = count; i != 0; i--) { - *c++ = *nr++; - *c++ = *ng++; - *c++ = *nb++; - } - - (*dc->dc_setcolor)(dc, index, index + count); - - return (0); -} - -int -macfb_cnattach() -{ - struct macfb_devconfig *dc = &macfb_console_dc; - long defattr; - struct rasops_info *ri; - - dc->dc_vaddr = trunc_page(videoaddr); - dc->dc_paddr = trunc_page(mac68k_vidphys); - dc->dc_offset = m68k_page_offset(mac68k_vidphys); - dc->dc_wid = videosize & 0xffff; - dc->dc_ht = (videosize >> 16) & 0xffff; - dc->dc_depth = videobitdepth; - dc->dc_rowbytes = videorowbytes; - dc->dc_size = (mac68k_vidlen > 0) ? - mac68k_vidlen : dc->dc_ht * dc->dc_rowbytes; - - /* set up the display */ - dc->dc_flags |= FB_MACOS_PALETTE; - if (macfb_init(dc) != 0) - return (-1); - - ri = &dc->dc_ri; - ri->ri_ops.alloc_attr(ri, 0, 0, 0, &defattr); - wsdisplay_cnattach(&dc->dc_wsd, ri, 0, 0, defattr); - - macfb_consaddr = mac68k_vidphys; - return (0); -} diff --git a/sys/arch/mac68k/dev/macfbvar.h b/sys/arch/mac68k/dev/macfbvar.h deleted file mode 100644 index 01ec96f6c5d..00000000000 --- a/sys/arch/mac68k/dev/macfbvar.h +++ /dev/null @@ -1,153 +0,0 @@ -/* $OpenBSD: macfbvar.h,v 1.7 2006/03/13 22:35:17 miod Exp $ */ -/* $NetBSD: macfbvar.h,v 1.3 2005/01/15 16:00:59 chs Exp $ */ -/* $NetBSD: grfvar.h,v 1.11 1996/08/04 06:03:58 scottr Exp $ */ -/* $NetBSD: grfioctl.h,v 1.5 1995/07/02 05:26:45 briggs Exp $ */ -/* - * Copyright (c) 1998 Matt DeBergalis - * 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 Matt DeBergalis - * 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. - */ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah $Hdr: grfvar.h 1.9 91/01/21$ - * - * @(#)grfvar.h 7.3 (Berkeley) 5/7/91 - */ - -/* - * Nubus image data structure. This is the equivalent of a PixMap in - * MacOS programming parlance. One of these structures exists for each - * video mode that a quickdraw compatible card can fit in. - */ -struct image_data { - u_int32_t size; - u_int32_t offset; - u_int16_t rowbytes; - u_int16_t top; - u_int16_t left; - u_int16_t bottom; - u_int16_t right; - u_int16_t version; - u_int16_t packType; - u_int32_t packSize; - u_int32_t hRes; - u_int32_t vRes; - u_int16_t pixelType; - u_int16_t pixelSize; - u_int16_t cmpCount; - u_int16_t cmpSize; - u_int32_t planeBytes; -}; - -#define VID_PARAMS 1 -#define VID_TABLE_OFFSET 2 -#define VID_PAGE_CNT 3 -#define VID_DEV_TYPE 4 - -struct macfb_devconfig { - vaddr_t dc_vaddr; /* memory space virtual base address */ - paddr_t dc_paddr; /* memory space physical base address */ - psize_t dc_size; /* size of slot memory */ - vaddr_t dc_cmapregs; /* va of cmap registers if known */ - - int dc_offset; /* offset to base of flat fb */ - - int dc_wid; /* width of frame buffer */ - int dc_ht; /* height of frame buffer */ - int dc_depth; /* depth of frame buffer */ - int dc_rowbytes; /* bytes in fb scan line */ - - int dc_flags; /* various flags */ -#define FB_MACOS_PALETTE 0x01 /* text mode uses MacOS palette */ - - /* rasops information */ - struct rasops_info dc_ri; - - /* shadow colormap */ - u_int8_t dc_cmap[256 * 3]; - void (*dc_setcolor)(void *, u_int, u_int); - - /* wsdisplay information */ - struct wsscreen_descr dc_wsd; - struct wsscreen_descr *dc_scrlist[1]; - struct wsscreen_list dc_screenlist; - int dc_nscreens; -}; - -struct macfb_softc { - struct device sc_dev; - - nubus_slot sc_slot; - - bus_addr_t sc_basepa; /* base of video space */ - bus_addr_t sc_fbofs; /* offset to framebuffer */ - - bus_space_tag_t sc_tag; - bus_space_handle_t sc_handle; - bus_space_handle_t sc_regh; - - u_int32_t card_id; /* DrHW value for nubus cards */ - bus_size_t cli_offset; /* Offset of byte to clear intr */ - /* for cards where that's suff. */ - u_int32_t cli_value; /* Value to write at cli_offset */ - - struct macfb_devconfig *sc_dc; -}; - -void macfb_attach_common(struct macfb_softc *, struct macfb_devconfig *); -int macfb_cnattach(void); diff --git a/sys/arch/mac68k/dev/ncr5380.c b/sys/arch/mac68k/dev/ncr5380.c deleted file mode 100644 index a7dc3f974c9..00000000000 --- a/sys/arch/mac68k/dev/ncr5380.c +++ /dev/null @@ -1,1994 +0,0 @@ -/* $OpenBSD: ncr5380.c,v 1.43 2011/07/17 22:46:47 matthew Exp $ */ -/* $NetBSD: ncr5380.c,v 1.38 1996/12/19 21:48:18 scottr Exp $ */ - -/* - * Copyright (c) 1995 Leo Weppelman. - * 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 Leo Weppelman. - * 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. - */ - -/* - * Bit mask of targets you want debugging to be shown - */ -u_char dbg_target_mask = 0x7f; - -/* - * Set bit for target when parity checking must be disabled. - * My (LWP) Maxtor 7245S seems to generate parity errors on about 50% - * of all transfers while the data is correct!? - */ -u_char ncr5380_no_parchk = 0xff; - -/* - * Flags to allow binpatching of which devices to allow or disallow - * issuance of linked commands. disallowance is favored over allowance, - * so if the same bit is set in either, the driver will not issue linked - * commands to the corresponding target. - * SCSI-2 devices can report whether or not they will accept linked - * commands. If that reports that a device supports linked commands, - * then it is treated as if the corresponding bit in ncr5380_allow_linked - * is set. - */ -u_char ncr5380_allow_linked = 0x80; -u_char ncr5380_disallow_linked = 0x80; - -/* - * This is the default sense-command we send. - */ -static u_char sense_cmd[] = { - REQUEST_SENSE, 0, 0, 0, sizeof(struct scsi_sense_data), 0 -}; - -/* - * True if the main co-routine is running - */ -static volatile int main_running = 0; - -/* - * Mask of targets selected - */ -static u_char busy; - -static void ncr5380_minphys(struct buf *bp, struct scsi_link *sl); -static void mac68k_ncr5380_scsi_cmd(struct scsi_xfer *xs); -static void ncr5380_show_scsi_cmd(struct scsi_xfer *xs); - -void ncr_sc_req_free(void *, void *); -void *ncr_sc_req_alloc(void *); - -struct scsi_adapter ncr5380_switch = { - mac68k_ncr5380_scsi_cmd, /* scsi_cmd() */ - ncr5380_minphys, /* scsi_minphys() */ - NULL, /* probe_dev() */ - NULL /* free_dev() */ -}; - - -static SC_REQ req_queue[NREQ]; -static SC_REQ *free_head = NULL; /* Free request structures */ - -/* - * Inline functions: - */ - -/* - * Determine the size of a SCSI command. - */ -extern __inline__ int command_size(opcode) -u_char opcode; -{ - switch ((opcode >> 4) & 0xf) { - case 0: - case 1: - return (6); - case 2: - case 3: - return (10); - } - return (12); -} - - -/* - * Wait for request-line to become active. When it doesn't return 0. - * Otherwise return != 0. - * The timeouts in the 'wait_req_*' functions are arbitrary and rather - * large. In 99% of the invocations nearly no timeout is needed but in - * some cases (especially when using my tapedrive, a Tandberg 3600) the - * device is busy internally and the first SCSI-phase will be delayed. - * - * -- A sleeping Fujitsu M2512 is even worse; try 2.5 sec -hf 20 Jun - */ -extern __inline__ int wait_req_true(void) -{ - int timeout = 2500000; - - while (!(GET_5380_REG(NCR5380_IDSTAT) & SC_S_REQ) && --timeout) - delay(1); - return (GET_5380_REG(NCR5380_IDSTAT) & SC_S_REQ); -} - -/* - * Wait for request-line to become inactive. When it doesn't return 0. - * Otherwise return != 0. - */ -extern __inline__ int wait_req_false(void) -{ - int timeout = 2500000; - - while ((GET_5380_REG(NCR5380_IDSTAT) & SC_S_REQ) && --timeout) - delay(1); - return (!(GET_5380_REG(NCR5380_IDSTAT) & SC_S_REQ)); -} - -extern __inline__ void ack_message() -{ - SET_5380_REG(NCR5380_ICOM, 0); -} - -extern __inline__ void nack_message(SC_REQ *reqp, u_char msg) -{ - SET_5380_REG(NCR5380_ICOM, SC_A_ATN); - reqp->msgout = msg; -} - -extern __inline__ void finish_req(SC_REQ *reqp) -{ - struct scsi_xfer *xs = reqp->xs; - -#ifdef REAL_DMA - /* - * If we bounced, free the bounce buffer - */ - if (reqp->dr_flag & DRIVER_BOUNCING) - free_bounceb(reqp->bounceb); -#endif /* REAL_DMA */ -#ifdef DBG_REQ - if (dbg_target_mask & (1 << reqp->targ_id)) - show_request(reqp, "DONE"); -#endif -#ifdef DBG_ERR_RET - if (reqp->xs->error != 0) - show_request(reqp, "ERR_RET"); -#endif - scsi_done(xs); -} - -/* - * Auto config stuff.... - */ -void ncr_attach(struct device *, struct device *, void *); -int ncr_match(struct device *, void *, void *); - -/* - * Tricks to make driver-name configurable - */ -#define CFNAME(n) __CONCAT(n,_cd) -#define CANAME(n) __CONCAT(n,_ca) -#define CFSTRING(n) __STRING(n) - -struct cfattach CANAME(DRNAME) = { - sizeof(struct ncr_softc), ncr_match, ncr_attach -}; - -struct cfdriver CFNAME(DRNAME) = { - NULL, CFSTRING(DRNAME), DV_DULL -}; - -void -ncr_sc_req_free(void *xsc, void *xsc_req) -{ - struct ncr_softc *sc = (struct ncr_softc *)xsc; - SC_REQ *sc_req = (SC_REQ *)xsc_req; - - mtx_enter(&sc->sc_sc_req_mtx); - sc_req->next = free_head; - free_head = sc_req; - mtx_leave(&sc->sc_sc_req_mtx); -} - -void * -ncr_sc_req_alloc(void *xsc) -{ - struct ncr_softc *sc = (struct ncr_softc *)xsc; - SC_REQ *sc_req = NULL; - - mtx_enter(&sc->sc_sc_req_mtx); - if (free_head) { - sc_req = free_head; - free_head = free_head->next; - sc_req->next = NULL; - } - mtx_leave(&sc->sc_sc_req_mtx); - - return (sc_req); -} - -int -ncr_match(parent, cf, aux) - struct device *parent; - void *cf; - void *aux; -{ - return (machine_match(parent, - (struct cfdata *) cf, aux, &CFNAME(DRNAME))); -} - -void -ncr_attach(pdp, dp, auxp) -struct device *pdp, *dp; -void *auxp; -{ - struct ncr_softc *sc; - struct scsibus_attach_args saa; - int i; - - sc = (struct ncr_softc *)dp; - - sc->sc_link.adapter_softc = sc; - sc->sc_link.adapter_target = 7; - sc->sc_link.adapter = &ncr5380_switch; - sc->sc_link.openings = NREQ - 1; - sc->sc_link.pool = &sc->sc_iopool; - - /* - * bitmasks - */ - sc->sc_noselatn = 0; - sc->sc_selected = 0; - - /* - * Initialize machine-type specific things... - */ - scsi_mach_init(sc); - printf("\n"); - - /* - * Initialize request queue freelist. - */ - for (i = 0; i < NREQ; i++) { - req_queue[i].next = free_head; - free_head = &req_queue[i]; - } - - /* - * Initialize the iopool. - */ - mtx_init(&sc->sc_sc_req_mtx, IPL_BIO); - scsi_iopool_init(&sc->sc_iopool, sc, ncr_sc_req_alloc, ncr_sc_req_free); - - /* - * Initialize the host adapter - */ - scsi_idisable(); - ENABLE_NCR5380(sc); - SET_5380_REG(NCR5380_ICOM, 0); - SET_5380_REG(NCR5380_MODE, IMODE_BASE); - SET_5380_REG(NCR5380_TCOM, 0); - SET_5380_REG(NCR5380_IDSTAT, 0); - scsi_ienable(); - - bzero(&saa, sizeof(saa)); - saa.saa_sc_link = &sc->sc_link; - - /* - * attach all scsi units on us - */ - config_found(dp, &saa, scsiprint); -} - -/* - * End of auto config stuff.... - */ - -/* - * Carry out a request from the high level driver. - */ -static void -mac68k_ncr5380_scsi_cmd(struct scsi_xfer *xs) -{ - int sps; - SC_REQ *reqp, *link, *tmp; - int flags = xs->flags; - - /* - * We do not queue RESET commands - */ - if (flags & SCSI_RESET) { - scsi_reset_verbose(xs->sc_link->adapter_softc, - "Got reset-command"); - return; - } - - reqp = xs->io; - - /* - * Initialize our private fields - */ - reqp->dr_flag = (flags & SCSI_POLL) ? DRIVER_NOINT : 0; - reqp->phase = NR_PHASE; - reqp->msgout = MSG_NOOP; - reqp->status = SCSGOOD; - reqp->message = 0xff; - reqp->link = NULL; - reqp->xs = xs; - reqp->targ_id = xs->sc_link->target; - reqp->targ_lun = xs->sc_link->lun; - reqp->xdata_ptr = (u_char *)xs->data; - reqp->xdata_len = xs->datalen; - memcpy(&reqp->xcmd, xs->cmd, sizeof(struct scsi_generic)); - reqp->xcmd.bytes[0] |= reqp->targ_lun << 5; - -#ifdef REAL_DMA - /* - * Check if DMA can be used on this request - */ - if (scsi_dmaok(reqp)) - reqp->dr_flag |= DRIVER_DMAOK; -#endif /* REAL_DMA */ - - /* - * Insert the command into the issue queue. Note that 'REQUEST SENSE' - * commands are inserted at the head of the queue since any command - * will clear the existing contingent allegience condition and the sense - * data is only valid while the condition exists. - * When possible, link the command to a previous command to the same - * target. This is not very sensible when AUTO_SENSE is not defined! - * Interrupts are disabled while we are fiddling with the issue-queue. - */ - sps = splbio(); - link = NULL; - if ((issue_q == NULL) || (reqp->xcmd.opcode == REQUEST_SENSE)) { - reqp->next = issue_q; - issue_q = reqp; - } - else { - tmp = issue_q; - do { - if (!link && (tmp->targ_id == reqp->targ_id) && !tmp->link) - link = tmp; - } while (tmp->next && (tmp = tmp->next)); - tmp->next = reqp; -#ifdef AUTO_SENSE - if (link && ((xs->sc_link->inqdata.flags & SID_Linked) - || ((1<<reqp->targ_id) & ncr5380_allow_linked)) - && !((1<<reqp->targ_id) & ncr5380_disallow_linked)) { - link->link = reqp; - link->xcmd.bytes[link->xs->cmdlen-2] |= 1; - } -#endif - } - splx(sps); - -#ifdef DBG_REQ - if (dbg_target_mask & (1 << reqp->targ_id)) - show_request(reqp, (reqp->xcmd.opcode == REQUEST_SENSE) ? - "HEAD":"TAIL"); -#endif - - run_main(xs->sc_link->adapter_softc); -} - -static void -ncr5380_minphys(struct buf *bp, struct scsi_link *sl) -{ - if (bp->b_bcount > MIN_PHYS) - bp->b_bcount = MIN_PHYS; - minphys(bp); -} -#undef MIN_PHYS - -static void -ncr5380_show_scsi_cmd(struct scsi_xfer *xs) -{ - u_char *b = (u_char *) xs->cmd; - int i = 0; - - if (!(xs->flags & SCSI_RESET)) { - printf("(%d:%d:%d,0x%x)-", xs->sc_link->scsibus, - xs->sc_link->target, xs->sc_link->lun, xs->sc_link->flags); - while (i < xs->cmdlen) { - if (i) - printf(","); - printf("%x",b[i++]); - } - printf("-\n"); - } - else { - printf("(%d:%d:%d)-RESET-\n", - xs->sc_link->scsibus,xs->sc_link->target, xs->sc_link->lun); - } -} - -/* - * The body of the driver. - */ -static void -scsi_main(sc) -struct ncr_softc *sc; -{ - SC_REQ *req, *prev; - int itype; - int sps; - - /* - * While running in the driver SCSI-interrupts are disabled. - */ - scsi_idisable(); - ENABLE_NCR5380(sc); - - PID("scsi_main1"); - for (;;) { - sps = splbio(); - if (!connected) { - /* - * Check if it is fair keep any exclusive access to DMA - * claimed. If not, stop queueing new jobs so the discon_q - * will be eventually drained and DMA can be given up. - */ - if (!fair_to_keep_dma()) - goto main_exit; - - /* - * Search through the issue-queue for a command - * destined for a target that isn't busy. - */ - prev = NULL; - for (req=issue_q; req != NULL; prev = req, req = req->next) { - if (!(busy & (1 << req->targ_id))) { - /* - * Found one, remove it from the issue queue - */ - if (prev == NULL) - issue_q = req->next; - else prev->next = req->next; - req->next = NULL; - break; - } - } - - /* - * When a request has just ended, we get here before an other - * device detects that the bus is free and that it can - * reconnect. The problem is that when this happens, we always - * baffle the device because our (initiator) id is higher. This - * can cause a sort of starvation on slow devices. So we check - * for a pending reselection here. - * Note that 'connected' will be non-null if the reselection - * succeeds. - */ - if ((GET_5380_REG(NCR5380_IDSTAT) & (SC_S_SEL|SC_S_IO)) - == (SC_S_SEL|SC_S_IO)){ - if (req != NULL) { - req->next = issue_q; - issue_q = req; - } - splx(sps); - - reselect(sc); - scsi_clr_ipend(); - goto connected; - } - - /* - * The host is not connected and there is no request - * pending, exit. - */ - if (req == NULL) { - PID("scsi_main2"); - goto main_exit; - } - - /* - * Re-enable interrupts before handling the request. - */ - splx(sps); - -#ifdef DBG_REQ - if (dbg_target_mask & (1 << req->targ_id)) - show_request(req, "TARGET"); -#endif - /* - * We found a request. Try to connect to the target. If the - * initiator fails arbitration, the command is put back in the - * issue queue. - */ - if (scsi_select(req, 0)) { - sps = splbio(); - req->next = issue_q; - issue_q = req; - splx(sps); -#ifdef DBG_REQ - if (dbg_target_mask & (1 << req->targ_id)) - ncr_tprint(req, "Select failed\n"); -#endif - } - } - else splx(sps); -connected: - if (connected) { - /* - * If the host is currently connected but a 'real-dma' transfer - * is in progress, the 'end-of-dma' interrupt restarts main. - * So quit. - */ - sps = splbio(); - if (connected && (connected->dr_flag & DRIVER_IN_DMA)) { - PID("scsi_main3"); - goto main_exit; - } - splx(sps); - - /* - * Let the target guide us through the bus-phases - */ - while (information_transfer(sc) == -1) - ; - } - } - /* NEVER TO REACH HERE */ - panic("ncr5380-SCSI: not designed to come here"); - -main_exit: - /* - * We enter here with interrupts disabled. We are about to exit main - * so interrupts should be re-enabled. Because interrupts are edge - * triggered, we could already have missed the interrupt. Therefore - * we check the IRQ-line here and re-enter when we really missed a - * valid interrupt. - */ - PID("scsi_main4"); - scsi_ienable(); - - /* - * If we're not currently connected, enable reselection - * interrupts. - */ - if (!connected) - SET_5380_REG(NCR5380_IDSTAT, SC_HOST_ID); - - if (scsi_ipending()) { - if ((itype = check_intr(sc)) != INTR_SPURIOUS) { - scsi_idisable(); - splx(sps); - - if (itype == INTR_RESEL) - reselect(sc); -#ifdef REAL_DMA - else dma_ready(); -#else - else { - if (pdma_ready()) - goto connected; - panic("Got DMA interrupt without DMA"); - } -#endif - scsi_clr_ipend(); - goto connected; - } - } - reconsider_dma(); - - main_running = 0; - splx(sps); - PID("scsi_main5"); -} - -#ifdef REAL_DMA -/* - * The SCSI-DMA interrupt. - * This interrupt can only be triggered when running in non-polled DMA - * mode. When DMA is not active, it will be silently ignored, it is usually - * too late because the EOP interrupt of the controller happens just a tiny - * bit earlier. It might become useful when scatter/gather is implemented, - * because in that case only part of the DATAIN/DATAOUT transfer is taken - * out of a single buffer. - */ -static void -ncr_dma_intr(sc) -struct ncr_softc *sc; -{ - SC_REQ *reqp; - int dma_done; - - PID("ncr_dma_intr"); - if ((reqp = connected) && (reqp->dr_flag & DRIVER_IN_DMA)) { - scsi_idisable(); - if (!(dma_done = dma_ready())) { - transfer_dma(reqp, reqp->phase, 0); - return; - } - run_main(sc); - } -} -#endif /* REAL_DMA */ - -/* - * The SCSI-controller interrupt. This interrupt occurs on reselections and - * at the end of non-polled DMA-interrupts. It is assumed to be called from - * the machine-dependent hardware interrupt. - */ -static void -ncr_ctrl_intr(sc) -struct ncr_softc *sc; -{ - int itype; - - while (scsi_ipending()) { - scsi_idisable(); - if ((itype = check_intr(sc)) != INTR_SPURIOUS) { - if (itype == INTR_RESEL) - reselect(sc); - else { -#ifdef REAL_DMA - int dma_done; - if (!(dma_done = dma_ready())) { - transfer_dma(connected, connected->phase, 0); - return; - } -#else - if (pdma_ready()) - return; - panic("Got DMA interrupt without DMA"); -#endif - } - scsi_clr_ipend(); - } - run_main(sc); - return; - } - PID("ncr_ctrl_intr1"); -} - -/* - * Initiate a connection path between the host and the target. The function - * first goes into arbitration for the SCSI-bus. When this succeeds, the target - * is selected and an 'IDENTIFY' message is send. - * Returns -1 when the arbitration failed. Otherwise 0 is returned. When - * the target does not respond (to either selection or 'MESSAGE OUT') the - * 'done' function is executed. - * The result code given by the driver can be influenced by setting 'code' - * to a non-zero value. This is the case when 'select' is called by abort. - */ -static int -scsi_select(reqp, code) -SC_REQ *reqp; -int code; -{ - u_char tmp[1]; - u_char phase; - u_long cnt; - int sps; - u_int8_t atn_flag; - u_int8_t targ_bit; - struct ncr_softc *sc; - - sc = reqp->xs->sc_link->adapter_softc; - DBG_SELPRINT ("Starting arbitration\n", 0); - PID("scsi_select1"); - - sps = splbio(); - - /* - * Prevent a race condition here. If a reslection interrupt occurred - * between the decision to pick a new request and the call to select, - * we abort the selection. - * Interrupts are lowered when the 5380 is setup to arbitrate for the - * bus. - */ - if (connected) { - splx(sps); - PID("scsi_select2"); - return (-1); - } - - /* - * Set phase bits to 0, otherwise the 5380 won't drive the bus during - * selection. - */ - SET_5380_REG(NCR5380_TCOM, 0); - SET_5380_REG(NCR5380_ICOM, 0); - - /* - * Arbitrate for the bus. - */ - SET_5380_REG(NCR5380_DATA, SC_HOST_ID); - SET_5380_REG(NCR5380_MODE, SC_ARBIT); - - splx(sps); - - cnt = 10; - while (!(GET_5380_REG(NCR5380_ICOM) & SC_AIP) && --cnt) - delay(1); - - if (!(GET_5380_REG(NCR5380_ICOM) & SC_AIP)) { - SET_5380_REG(NCR5380_MODE, IMODE_BASE); - SET_5380_REG(NCR5380_ICOM, 0); - DBG_SELPRINT ("Arbitration lost, bus not free\n",0); - PID("scsi_select3"); - return (-1); - } - - /* The arbitration delay is 2.2 usecs */ - delay(3); - - /* - * Check the result of the arbitration. If we failed, return -1. - */ - if (GET_5380_REG(NCR5380_ICOM) & SC_LA) { - SET_5380_REG(NCR5380_MODE, IMODE_BASE); - SET_5380_REG(NCR5380_ICOM, 0); - PID("scsi_select4"); - return (-1); - } - - /* - * The spec requires that we should read the data register to - * check for higher id's and check the SC_LA again. - */ - tmp[0] = GET_5380_REG(NCR5380_DATA); - if (tmp[0] & ~((SC_HOST_ID << 1) - 1)) { - SET_5380_REG(NCR5380_MODE, IMODE_BASE); - SET_5380_REG(NCR5380_ICOM, 0); - DBG_SELPRINT ("Arbitration lost, higher id present\n",0); - PID("scsi_select5"); - return (-1); - } - if (GET_5380_REG(NCR5380_ICOM) & SC_LA) { - SET_5380_REG(NCR5380_MODE, IMODE_BASE); - SET_5380_REG(NCR5380_ICOM, 0); - DBG_SELPRINT ("Arbitration lost,deassert SC_ARBIT\n",0); - PID("scsi_select6"); - return (-1); - } - SET_5380_REG(NCR5380_ICOM, SC_A_SEL | SC_A_BSY); - if (GET_5380_REG(NCR5380_ICOM) & SC_LA) { - SET_5380_REG(NCR5380_MODE, IMODE_BASE); - SET_5380_REG(NCR5380_ICOM, 0); - DBG_SELPRINT ("Arbitration lost, deassert SC_A_SEL\n", 0); - PID("scsi_select7"); - return (-1); - } - /* Bus settle delay + Bus clear delay = 1.2 usecs */ - delay(2); - DBG_SELPRINT ("Arbitration complete\n", 0); - - /* - * Now that we won the arbitration, start the selection. - */ - targ_bit = 1 << reqp->targ_id; - SET_5380_REG(NCR5380_DATA, SC_HOST_ID | targ_bit); - - if (sc->sc_noselatn & targ_bit) - atn_flag = 0; - else - atn_flag = SC_A_ATN; - - /* - * Raise ATN while SEL is true before BSY goes false from arbitration, - * since this is the only way to guarantee that we'll get a MESSAGE OUT - * phase immediately after the selection. - */ - SET_5380_REG(NCR5380_ICOM, SC_A_BSY | SC_A_SEL | atn_flag | SC_ADTB); - SET_5380_REG(NCR5380_MODE, IMODE_BASE); - - /* - * Turn off reselection interrupts - */ - SET_5380_REG(NCR5380_IDSTAT, 0); - - /* - * Reset BSY. The delay following it, surpresses a glitch in the - * 5380 which causes us to see our own BSY signal instead of that of - * the target. - */ - SET_5380_REG(NCR5380_ICOM, SC_A_SEL | atn_flag | SC_ADTB); - delay(1); - - /* - * Wait for the target to react, the specs call for a timeout of - * 250 ms. - */ - cnt = 25000; - while (!(GET_5380_REG(NCR5380_IDSTAT) & SC_S_BSY) && --cnt) - delay(10); - - if (!(GET_5380_REG(NCR5380_IDSTAT) & SC_S_BSY)) { - /* - * There is no reaction from the target, start the selection - * timeout procedure. We release the databus but keep SEL - * asserted. After that we wait a 'selection abort time' (200 - * usecs) and 2 deskew delays (90 ns) and check BSY again. - * When BSY is asserted, we assume the selection succeeded, - * otherwise we release the bus. - */ - SET_5380_REG(NCR5380_ICOM, SC_A_SEL | atn_flag); - delay(201); - if (!(GET_5380_REG(NCR5380_IDSTAT) & SC_S_BSY)) { - SET_5380_REG(NCR5380_ICOM, 0); - reqp->xs->error = code ? code : XS_SELTIMEOUT; - DBG_SELPRINT ("Target %d not responding to sel\n", - reqp->targ_id); - finish_req(reqp); - PID("scsi_select8"); - return (0); - } - } - SET_5380_REG(NCR5380_ICOM, atn_flag); - - DBG_SELPRINT ("Target %d responding to select.\n", reqp->targ_id); - - /* - * The SCSI-interrupts are disabled while a request is being handled. - */ - scsi_idisable(); - - /* - * If we did not request ATN, then don't try to send IDENTIFY. - */ - if (atn_flag == 0) { - reqp->phase = PH_CMD; - goto identify_failed; - } - - /* - * Here we prepare to send an 'IDENTIFY' message. - * Allow disconnect only when interrupts are allowed. - */ - tmp[0] = MSG_IDENTIFY(reqp->targ_lun, - (reqp->dr_flag & DRIVER_NOINT) ? 0 : 1); - cnt = 1; - phase = PH_MSGOUT; - - /* - * Since we followed the SCSI-spec and raised ATN while SEL was true - * but before BSY was false during the selection, a 'MESSAGE OUT' - * phase should follow. Unfortunately, this does not happen on - * all targets (Asante ethernet devices, for example), so we must - * check the actual mode if the message transfer fails--if the - * new phase is PH_CMD and has never been successfully selected - * w/ATN in the past, then we assume that it is an old device - * that doesn't support select w/ATN. - */ - if (transfer_pio(&phase, tmp, &cnt, 0) || cnt) { - - if ((phase == PH_CMD) && !(sc->sc_selected & targ_bit)) { - DBG_SELPRINT ("Target %d: not responding to ATN.\n", - reqp->targ_id); - sc->sc_noselatn |= targ_bit; - reqp->phase = PH_CMD; - goto identify_failed; - } - - DBG_SELPRINT ("Target %d: failed to send identify\n", - reqp->targ_id); - /* - * Try to disconnect from the target. We cannot leave - * it just hanging here. - */ - if (!reach_msg_out(sc, sizeof(struct scsi_generic))) { - u_long len = 1; - u_char phase = PH_MSGOUT; - u_char msg = MSG_ABORT; - - transfer_pio(&phase, &msg, &len, 0); - } - else scsi_reset_verbose(sc, "Connected to unidentified target"); - - SET_5380_REG(NCR5380_ICOM, 0); - reqp->xs->error = code ? code : XS_DRIVER_STUFFUP; - finish_req(reqp); - PID("scsi_select9"); - return (0); - } - reqp->phase = PH_MSGOUT; - -identify_failed: - sc->sc_selected |= targ_bit; - -#ifdef notyet /* LWP: Do we need timeouts in the driver? */ - /* - * Command is connected, start timer ticking. - */ - ccb_p->xtimeout = ccb_p->timeout + Lbolt; -#endif - - connected = reqp; - busy |= targ_bit; - PID("scsi_select10"); - return (0); -} - -/* - * Return codes: - * 0: Job has finished or disconnected, find something else - * -1: keep on calling information_transfer() from scsi_main() - */ -static int -information_transfer(sc) -struct ncr_softc *sc; -{ - SC_REQ *reqp = connected; - u_char tmp, phase; - u_long len; - - PID("info_transf1"); - /* - * Clear pending interrupts from 5380-chip. - */ - scsi_clr_ipend(); - - /* - * The SCSI-spec requires BSY to be true while connected to a target, - * loosing it means we lost the target... - * Also REQ needs to be asserted here to indicate that the bus-phase - * is valid. When the target does not supply REQ within a 'reasonable' - * amount of time, it's probably lost in its own maze of twisting - * passages, we have to reset the bus to free it. - */ - if (GET_5380_REG(NCR5380_IDSTAT) & SC_S_BSY) - wait_req_true(); - tmp = GET_5380_REG(NCR5380_IDSTAT); - - - if ((tmp & (SC_S_BSY|SC_S_REQ)) != (SC_S_BSY|SC_S_REQ)) { - busy &= ~(1 << reqp->targ_id); - connected = NULL; - reqp->xs->error = XS_TIMEOUT; - finish_req(reqp); - if (!(tmp & SC_S_REQ)) - scsi_reset_verbose(sc, - "Timeout waiting for phase-change"); - PID("info_transf2"); - return (0); - } - - phase = (tmp >> 2) & 7; - if (phase != reqp->phase) { - reqp->phase = phase; - DBG_INFPRINT(show_phase, reqp, phase); - } - else { - /* - * Same data-phase. If same error give up - */ - if ((reqp->msgout == MSG_ABORT) - && ((phase == PH_DATAOUT) || (phase == PH_DATAIN))) { - busy &= ~(1 << reqp->targ_id); - connected = NULL; - finish_req(reqp); - scsi_reset_verbose(sc, "Failure to abort command"); - return (0); - } - } - - switch (phase) { - case PH_DATAOUT: -#ifdef DBG_NOWRITE - ncr_tprint(reqp, "NOWRITE set -- write attempt aborted."); - reqp->msgout = MSG_ABORT; - SET_5380_REG(NCR5380_ICOM, SC_A_ATN); - return (-1); -#endif /* DBG_NOWRITE */ - /* - * If this is the first write using DMA, fill - * the bounce buffer. - */ - if (reqp->xdata_ptr == reqp->xs->data) { /* XXX */ - if (reqp->dr_flag & DRIVER_BOUNCING) - bcopy(reqp->xdata_ptr, reqp->bounceb, reqp->xdata_len); - } - - case PH_DATAIN: - if (reqp->xdata_len <= 0) { - /* - * Target keeps requesting data. Try to get into - * message-out phase by feeding/taking 100 byte. - */ - ncr_tprint(reqp, "Target requests too much data\n"); - reqp->msgout = MSG_ABORT; - SET_5380_REG(NCR5380_ICOM, SC_A_ATN); - reach_msg_out(sc, 100); - return (-1); - } -#ifdef REAL_DMA - if (reqp->dr_flag & DRIVER_DMAOK) { - int poll = REAL_DMA_POLL|(reqp->dr_flag & DRIVER_NOINT); - transfer_dma(reqp, phase, poll); - if (!poll) - return (0); - } - else -#endif - { - PID("info_transf3"); - len = reqp->xdata_len; -#ifdef USE_PDMA - if (transfer_pdma(&phase, reqp->xdata_ptr, &len) == 0) - return (0); -#else - transfer_pio(&phase, reqp->xdata_ptr, &len, 0); -#endif - reqp->xdata_ptr += reqp->xdata_len - len; - reqp->xdata_len = len; - } - return (-1); - case PH_MSGIN: - /* - * We only expect single byte messages here. - */ - len = 1; - transfer_pio(&phase, &tmp, &len, 1); - reqp->message = tmp; - return (handle_message(reqp, tmp)); - case PH_MSGOUT: - len = 1; - transfer_pio(&phase, &reqp->msgout, &len, 0); - if (reqp->msgout == MSG_ABORT) { - busy &= ~(1 << reqp->targ_id); - connected = NULL; - if (!reqp->xs->error) - reqp->xs->error = XS_DRIVER_STUFFUP; - finish_req(reqp); - PID("info_transf4"); - return (0); - } - reqp->msgout = MSG_NOOP; - return (-1); - case PH_CMD : - len = command_size(reqp->xcmd.opcode); - transfer_pio(&phase, (u_char *)&reqp->xcmd, &len, 0); - PID("info_transf5"); - return (-1); - case PH_STATUS: - len = 1; - transfer_pio(&phase, &tmp, &len, 0); - reqp->status = tmp; - PID("info_transf6"); - return (-1); - default : - ncr_tprint(reqp, "Unknown phase\n"); - } - PID("info_transf7"); - return (-1); -} - -/* - * Handle the message 'msg' send to us by the target. - * Return values: - * 0 : The current command has completed. - * -1 : Get on to the next phase. - */ -static int -handle_message(reqp, msg) -SC_REQ *reqp; -u_int msg; -{ - int sps; - SC_REQ *prev, *req; - - PID("hmessage1"); - switch (msg) { - /* - * Linking lets us reduce the time required to get - * the next command to the device, skipping the arbitration - * and selection time. In the current implementation, - * we merely have to start the next command pointed - * to by 'next_link'. - */ - case MSG_LINK_CMD_COMPLETE: - case MSG_LINK_CMD_COMPLETEF: - if (reqp->link == NULL) { - ncr_tprint(reqp, "No link for linked command"); - nack_message(reqp, MSG_ABORT); - PID("hmessage2"); - return (-1); - } - ack_message(); - if (!(reqp->dr_flag & DRIVER_AUTOSEN)) { - reqp->xs->resid = reqp->xdata_len; - reqp->xs->error = 0; - } - -#ifdef AUTO_SENSE - if (check_autosense(reqp, 1) == -1) - return (-1); -#endif /* AUTO_SENSE */ - -#ifdef DBG_REQ - if (dbg_target_mask & (1 << reqp->targ_id)) - show_request(reqp->link, "LINK"); -#endif - connected = reqp->link; - - /* - * Unlink the 'linked' request from the issue_q - */ - sps = splbio(); - prev = NULL; - req = issue_q; - for (; req != NULL; prev = req, req = req->next) { - if (req == connected) - break; - } - if (req == NULL) - panic("Inconsistent issue_q"); - if (prev == NULL) - issue_q = req->next; - else prev->next = req->next; - req->next = NULL; - splx(sps); - - finish_req(reqp); - PID("hmessage3"); - return (-1); - case MSG_ABORT: - case MSG_CMDCOMPLETE: - ack_message(); - connected = NULL; - busy &= ~(1 << reqp->targ_id); - if (!(reqp->dr_flag & DRIVER_AUTOSEN)) { - reqp->xs->resid = reqp->xdata_len; - reqp->xs->error = 0; - } - -#ifdef AUTO_SENSE - if (check_autosense(reqp, 0) == -1) { - PID("hmessage4"); - return (0); - } -#endif /* AUTO_SENSE */ - - finish_req(reqp); - PID("hmessage5"); - return (0); - case MSG_MESSAGE_REJECT: - ack_message(); - PID("hmessage6"); - return (-1); - case MSG_DISCONNECT: - ack_message(); -#ifdef DBG_REQ - if (dbg_target_mask & (1 << reqp->targ_id)) - show_request(reqp, "DISCON"); -#endif - sps = splbio(); - connected = NULL; - reqp->next = discon_q; - discon_q = reqp; - splx(sps); - PID("hmessage7"); - return (0); - case MSG_SAVEDATAPOINTER: - case MSG_RESTOREPOINTERS: - /* - * We save pointers implicitely at disconnect. - * So we can ignore these messages. - */ - ack_message(); - PID("hmessage8"); - return (-1); - case MSG_EXTENDED: - nack_message(reqp, MSG_MESSAGE_REJECT); - PID("hmessage9"); - return (-1); - default: - if ((msg & 0x80) && !(msg & 0x18)) { /* IDENTIFY */ - PID("hmessage10"); - ack_message(); - return (0); - } else { - ncr_tprint(reqp, - "Unknown message %x. Rejecting.\n", - msg); - nack_message(reqp, MSG_MESSAGE_REJECT); - } - return (-1); - } - PID("hmessage11"); - return (-1); -} - -/* - * Handle reselection. If a valid reconnection occurs, connected - * points at the reconnected command. The command is removed from the - * disconnected queue. - */ -static void -reselect(sc) -struct ncr_softc *sc; -{ - u_char phase; - u_long len; - u_char msg; - u_char target_mask; - int abort = 0; - SC_REQ *tmp, *prev; - - PID("reselect1"); - target_mask = GET_5380_REG(NCR5380_DATA) & ~SC_HOST_ID; - - /* - * At this point, we have detected that our SCSI-id is on the bus, - * SEL is true and BSY was false for at least one bus settle - * delay (400 ns.). - * We must assert BSY ourselves, until the target drops the SEL signal. - * The SCSI-spec specifies no maximum time for this, so we have to - * choose something long enough to suit all targets. - */ - SET_5380_REG(NCR5380_ICOM, SC_A_BSY); - len = 250000; - while ((GET_5380_REG(NCR5380_IDSTAT) & SC_S_SEL) && (len > 0)) { - delay(1); - len--; - } - if (GET_5380_REG(NCR5380_IDSTAT) & SC_S_SEL) { - /* Damn SEL isn't dropping */ - scsi_reset_verbose(sc, "Target won't drop SEL during Reselect"); - return; - } - - SET_5380_REG(NCR5380_ICOM, 0); - - /* - * Check if the reselection is still valid. Check twice because - * of possible line glitches - cheaper than delay(1) and we need - * only a few nanoseconds. - */ - if (!(GET_5380_REG(NCR5380_IDSTAT) & SC_S_BSY)) { - if (!(GET_5380_REG(NCR5380_IDSTAT) & SC_S_BSY)) { - ncr_aprint(sc, "Stepped into the reselection timeout\n"); - return; - } - } - - /* - * Get the expected identify message. - */ - phase = PH_MSGIN; - len = 1; - transfer_pio(&phase, &msg, &len, 0); - if (len || !MSG_ISIDENTIFY(msg)) { - ncr_aprint(sc, "Expecting IDENTIFY, got 0x%x\n", msg); - abort = 1; - tmp = NULL; - } - else { - /* - * Find the command reconnecting - */ - for (tmp = discon_q, prev = NULL; tmp; prev = tmp, tmp = tmp->next){ - if (target_mask == (1 << tmp->targ_id)) { - if (prev) - prev->next = tmp->next; - else discon_q = tmp->next; - tmp->next = NULL; - break; - } - } - if (tmp == NULL) { - ncr_aprint(sc, "No disconnected job for targetmask %x\n", - target_mask); - abort = 1; - } - } - if (abort) { - msg = MSG_ABORT; - len = 1; - phase = PH_MSGOUT; - - SET_5380_REG(NCR5380_ICOM, SC_A_ATN); - if (transfer_pio(&phase, &msg, &len, 0) || len) - scsi_reset_verbose(sc, "Failure to abort reselection"); - } - else { - connected = tmp; -#ifdef DBG_REQ - if (dbg_target_mask & (1 << tmp->targ_id)) - show_request(tmp, "RECON"); -#endif - } - PID("reselect2"); -} - -/* - * Transfer data in a given phase using programmed I/O. - * Returns -1 when a different phase is entered without transferring the - * maximum number of bytes, 0 if all bytes transferred or exit is in the same - * phase. - */ -static int -transfer_pio(phase, data, len, dont_drop_ack) -u_char *phase; -u_char *data; -u_long *len; -int dont_drop_ack; -{ - u_int cnt = *len; - u_char ph = *phase; - u_char tmp, new_icom; - - DBG_PIOPRINT ("SCSI: transfer_pio start: phase: %d, len: %d\n", ph,cnt); - PID("tpio1"); - SET_5380_REG(NCR5380_TCOM, ph); - do { - if (!wait_req_true()) { - DBG_PIOPRINT ("SCSI: transfer_pio: missing REQ\n", 0, 0); - break; - } - if (((GET_5380_REG(NCR5380_IDSTAT) >> 2) & 7) != ph) { - DBG_PIOPRINT ("SCSI: transfer_pio: phase mismatch\n", 0, 0); - break; - } - if (PH_IN(ph)) { - *data++ = GET_5380_REG(NCR5380_DATA); - SET_5380_REG(NCR5380_ICOM, SC_A_ACK); - if ((cnt == 1) && dont_drop_ack) - new_icom = SC_A_ACK; - else new_icom = 0; - } - else { - SET_5380_REG(NCR5380_DATA, *data++); - - /* - * The SCSI-standard suggests that in the 'MESSAGE OUT' phase, - * the initiator should drop ATN on the last byte of the - * message phase after REQ has been asserted for the handshake - * but before the initiator raises ACK. - */ - if (!( (ph == PH_MSGOUT) && (cnt > 1) )) { - SET_5380_REG(NCR5380_ICOM, SC_ADTB); - SET_5380_REG(NCR5380_ICOM, SC_ADTB | SC_A_ACK); - new_icom = 0; - } - else { - SET_5380_REG(NCR5380_ICOM, SC_ADTB | SC_A_ATN); - SET_5380_REG(NCR5380_ICOM, SC_ADTB|SC_A_ATN|SC_A_ACK); - new_icom = SC_A_ATN; - } - } - if (!wait_req_false()) { - DBG_PIOPRINT ("SCSI: transfer_pio - REQ not dropping\n", 0, 0); - break; - } - SET_5380_REG(NCR5380_ICOM, new_icom); - - } while (--cnt); - - if ((tmp = GET_5380_REG(NCR5380_IDSTAT)) & SC_S_REQ) - *phase = (tmp >> 2) & 7; - else *phase = NR_PHASE; - *len = cnt; - DBG_PIOPRINT ("SCSI: transfer_pio done: phase: %d, len: %d\n", - *phase, cnt); - PID("tpio2"); - if (!cnt || (*phase == ph)) - return (0); - return (-1); -} - -#ifdef REAL_DMA -/* - * Start a DMA-transfer on the device using the current pointers. - * If 'poll' is true, the function busy-waits until DMA has completed. - */ -static void -transfer_dma(reqp, phase, poll) -SC_REQ *reqp; -u_int phase; -int poll; -{ - int dma_done; - u_char mbase = 0; - int sps; - -again: - PID("tdma1"); - - /* - * We should be in phase, otherwise we are not allowed to - * drive the bus. - */ - SET_5380_REG(NCR5380_TCOM, phase); - - /* - * Defer interrupts until DMA is fully running. - */ - sps = splbio(); - - /* - * Clear pending interrupts and parity errors. - */ - scsi_clr_ipend(); - - if (!poll) { - /* - * Enable SCSI interrupts and set IN_DMA flag, set 'mbase' - * to the interrupts we want enabled. - */ - scsi_ienable(); - reqp->dr_flag |= DRIVER_IN_DMA; - mbase = SC_E_EOPI | SC_MON_BSY; - } - else scsi_idisable(); - mbase |= IMODE_BASE | SC_M_DMA; - scsi_dma_setup(reqp, phase, mbase); - - splx(sps); - - if (poll) { - /* - * On polled-dma transfers, we wait here until the - * 'end-of-dma' condition occurs. - */ - poll_edma(reqp); - if (!(dma_done = dma_ready())) - goto again; - } - PID("tdma2"); -} - -/* - * Check results of a DMA data-transfer. - */ -static int -dma_ready() -{ - SC_REQ *reqp = connected; - int dmstat, is_edma; - long bytes_left, bytes_done; - - is_edma = get_dma_result(reqp, &bytes_left); - dmstat = GET_5380_REG(NCR5380_DMSTAT); - - /* - * Check if the call is sensible and not caused by any spurious - * interrupt. - */ - if (!is_edma && !(dmstat & (SC_END_DMA|SC_BSY_ERR)) - && (dmstat & SC_PHS_MTCH) ) { - ncr_tprint(reqp, "dma_ready: spurious call " - "(dm:%x,last_hit: %s)\n", -#ifdef DBG_PID - dmstat, last_hit[DBG_PID-1]); -#else - dmstat, "unknown"); -#endif - return (0); - } - - /* - * Clear all (pending) interrupts. - */ - scsi_clr_ipend(); - - /* - * Update various transfer-pointers/lengths - */ - bytes_done = reqp->dm_cur->dm_count - bytes_left; - - if ((reqp->dr_flag & DRIVER_BOUNCING) && (PH_IN(reqp->phase))) { - /* - * Copy the bytes read until now from the bounce buffer - * to the 'real' destination. Flush the data-cache - * before copying. - */ - PCIA(); - bcopy(reqp->bouncerp, reqp->xdata_ptr, bytes_done); - reqp->bouncerp += bytes_done; - } - - reqp->xdata_ptr = &reqp->xdata_ptr[bytes_done]; /* XXX */ - reqp->xdata_len -= bytes_done; /* XXX */ - if ((reqp->dm_cur->dm_count -= bytes_done) == 0) - reqp->dm_cur++; - else reqp->dm_cur->dm_addr += bytes_done; - - if (PH_IN(reqp->phase) && (dmstat & SC_PAR_ERR)) { - if (!(ncr5380_no_parchk & (1 << reqp->targ_id))) { - ncr_tprint(reqp, "parity error in data-phase\n"); - reqp->xs->error = XS_TIMEOUT; - } - } - - /* - * DMA mode should always be reset even when we will continue with the - * next chain. It is also essential to clear the MON_BUSY because - * when LOST_BUSY is unexpectedly set, we will not be able to drive - * the bus.... - */ - SET_5380_REG(NCR5380_MODE, IMODE_BASE); - - - if ((dmstat & SC_BSY_ERR) || !(dmstat & SC_PHS_MTCH) - || (reqp->dm_cur > reqp->dm_last) || (reqp->xs->error)) { - - /* - * Tell interrupt functions DMA mode has ended. - */ - reqp->dr_flag &= ~DRIVER_IN_DMA; - - /* - * Clear mode and icom - */ - SET_5380_REG(NCR5380_MODE, IMODE_BASE); - SET_5380_REG(NCR5380_ICOM, 0); - - if (dmstat & SC_BSY_ERR) { - if (!reqp->xs->error) - reqp->xs->error = XS_TIMEOUT; - finish_req(reqp); - PID("dma_ready1"); - return (1); - } - - if (reqp->xs->error != 0) { -ncr_tprint(reqp, "dma-ready: code = %d\n", reqp->xs->error); /* LWP */ - reqp->msgout = MSG_ABORT; - SET_5380_REG(NCR5380_ICOM, SC_A_ATN); - } - PID("dma_ready2"); - return (1); - } - return (0); -} -#endif /* REAL_DMA */ - -static int -check_autosense(reqp, linked) -SC_REQ *reqp; -int linked; -{ - int sps; - - /* - * If we not executing an auto-sense and the status code - * is request-sense, we automatically issue a request - * sense command. - */ - PID("cautos1"); - if (!(reqp->dr_flag & DRIVER_AUTOSEN)) { - switch (reqp->status & SCSMASK) { - case SCSCHKC: - bcopy(sense_cmd, &reqp->xcmd, sizeof(sense_cmd)); - reqp->xdata_ptr = (u_char *)&reqp->xs->sense; - reqp->xdata_len = sizeof(reqp->xs->sense); - reqp->dr_flag |= DRIVER_AUTOSEN; - reqp->dr_flag &= ~DRIVER_DMAOK; - if (!linked) { - sps = splbio(); - reqp->next = issue_q; - issue_q = reqp; - splx(sps); - } - else reqp->xcmd.bytes[sizeof(sense_cmd)-2] |= 1; - -#ifdef DBG_REQ - bzero(reqp->xdata_ptr, reqp->xdata_len); - if (dbg_target_mask & (1 << reqp->targ_id)) - show_request(reqp, "AUTO-SENSE"); -#endif - PID("cautos2"); - return (-1); - case SCSBUSY: - reqp->xs->error = XS_BUSY; - return (0); - } - } - else { - /* - * An auto-sense has finished - */ - if ((reqp->status & SCSMASK) != SCSGOOD) - reqp->xs->error = XS_DRIVER_STUFFUP; /* SC_E_AUTOSEN; */ - else reqp->xs->error = XS_SENSE; - reqp->status = SCSCHKC; - } - PID("cautos3"); - return (0); -} - -static int -reach_msg_out(sc, len) -struct ncr_softc *sc; -u_long len; -{ - u_char phase; - u_char data; - u_long n = len; - - ncr_aprint(sc, "Trying to reach Message-out phase\n"); - if ((phase = GET_5380_REG(NCR5380_IDSTAT)) & SC_S_REQ) - phase = (phase >> 2) & 7; - else return (-1); - ncr_aprint(sc, "Trying to reach Message-out phase, now: %d\n", phase); - if (phase == PH_MSGOUT) - return (0); - - SET_5380_REG(NCR5380_TCOM, phase); - - do { - if (!wait_req_true()) - break; - if (((GET_5380_REG(NCR5380_IDSTAT) >> 2) & 7) != phase) - break; - if (PH_IN(phase)) { - data = GET_5380_REG(NCR5380_DATA); - SET_5380_REG(NCR5380_ICOM, SC_A_ACK | SC_A_ATN); - } - else { - SET_5380_REG(NCR5380_DATA, 0); - SET_5380_REG(NCR5380_ICOM, SC_ADTB|SC_A_ACK|SC_A_ATN); - } - if (!wait_req_false()) - break; - SET_5380_REG(NCR5380_ICOM, SC_A_ATN); - } while (--n); - - if ((phase = GET_5380_REG(NCR5380_IDSTAT)) & SC_S_REQ) { - phase = (phase >> 2) & 7; - if (phase == PH_MSGOUT) { - ncr_aprint(sc, "Message-out phase reached after " - "%ld bytes.\n", len - n); - return (0); - } - } - return (-1); -} - -void -scsi_reset() -{ - SC_REQ *tmp, *next; - int sps; - - PID("scsi_reset1"); - sps = splbio(); - SET_5380_REG(NCR5380_ICOM, SC_A_RST); - delay(100); - SET_5380_REG(NCR5380_ICOM, 0); - scsi_clr_ipend(); - - /* - * None of the jobs in the discon_q will ever be reconnected, - * notify this to the higher level code. - */ - for (tmp = discon_q; tmp ;) { - next = tmp->next; - tmp->next = NULL; - tmp->xs->error = XS_TIMEOUT; - busy &= ~(1 << tmp->targ_id); - finish_req(tmp); - tmp = next; - } - discon_q = NULL; - - /* - * The current job will never finish either. - * The problem is that we can't finish the job because an instance - * of main is running on it. Our best guess is that the job is currently - * doing REAL-DMA. In that case 'dma_ready()' should correctly finish - * the job because it detects BSY-loss. - */ - if ((tmp = connected) != NULL) { - if (tmp->dr_flag & DRIVER_IN_DMA) { - tmp->xs->error = XS_DRIVER_STUFFUP; -#ifdef REAL_DMA - dma_ready(); -#endif - } - } - splx(sps); - PID("scsi_reset2"); - - /* - * Give the attached devices some time to handle the reset. This - * value is arbitrary but should be relatively long. - */ - delay(100000); -} - -static void -scsi_reset_verbose(sc, why) -struct ncr_softc *sc; -const char *why; -{ - ncr_aprint(sc, "Resetting SCSI-bus (%s)\n", why); - - scsi_reset(); -} - -/* - * Check validity of the IRQ set by the 5380. If the interrupt is valid, - * the appropriate action is carried out (reselection or DMA ready) and - * INTR_RESEL or INTR_DMA is returned. Otherwise a console notice is written - * and INTR_SPURIOUS is returned. - */ -static int -check_intr(sc) -struct ncr_softc *sc; -{ - SC_REQ *reqp; - - if ((GET_5380_REG(NCR5380_IDSTAT) & (SC_S_SEL|SC_S_IO)) - ==(SC_S_SEL|SC_S_IO)) - return (INTR_RESEL); - else { - if ((reqp = connected) && (reqp->dr_flag & DRIVER_IN_DMA)){ - reqp->dr_flag &= ~DRIVER_IN_DMA; - return (INTR_DMA); - } - } - scsi_clr_ipend(); - printf("-->"); - scsi_show(); - ncr_aprint(sc, "Spurious interrupt.\n"); - return (INTR_SPURIOUS); -} - -#ifdef REAL_DMA -/* - * Check if DMA can be used for this request. This function also builds - * the dma-chain. - */ -static int -scsi_dmaok(reqp) -SC_REQ *reqp; -{ - u_long phy_buf; - u_long phy_len; - void *req_addr; - u_long req_len; - struct dma_chain *dm; - - /* - * Initialize locals and requests' DMA-chain. - */ - req_len = reqp->xdata_len; - req_addr = (void *)reqp->xdata_ptr; - dm = reqp->dm_cur = reqp->dm_last = reqp->dm_chain; - dm->dm_count = dm->dm_addr = 0; - reqp->dr_flag &= ~DRIVER_BOUNCING; - - /* - * Do not accept zero length DMA. - */ - if (req_len == 0) - return (0); - - /* - * LWP: I think that this restriction is not strictly necessary. - */ - if ((req_len & 0x1) || ((u_int)req_addr & 0x3)) - return (0); - - /* - * Build the DMA-chain. - */ - dm->dm_addr = phy_buf = kvtop(req_addr); - while (req_len) { - if (req_len < (phy_len = NBPG - m68k_page_offset(req_addr))) - phy_len = req_len; - - req_addr += phy_len; - req_len -= phy_len; - dm->dm_count += phy_len; - - if (req_len) { - u_long tmp = kvtop(req_addr); - - if ((phy_buf + phy_len) != tmp) { - if (wrong_dma_range(reqp, dm)) { - if (reqp->dr_flag & DRIVER_BOUNCING) - goto bounceit; - return (0); - } - - if (++dm >= &reqp->dm_chain[MAXDMAIO]) { - ncr_tprint(reqp,"dmaok: DMA chain too long!\n"); - return (0); - } - dm->dm_count = 0; - dm->dm_addr = tmp; - } - phy_buf = tmp; - } - } - if (wrong_dma_range(reqp, dm)) { - if (reqp->dr_flag & DRIVER_BOUNCING) - goto bounceit; - return (0); - } - reqp->dm_last = dm; - return (1); - -bounceit: - if ((reqp->bounceb = alloc_bounceb(reqp->xdata_len)) == NULL) { - /* - * If we can't get a bounce buffer, forget DMA - */ - reqp->dr_flag &= ~DRIVER_BOUNCING; - return(0); - } - /* - * Initialize a single DMA-range containing the bounced request - */ - dm = reqp->dm_cur = reqp->dm_last = reqp->dm_chain; - dm->dm_addr = kvtop(reqp->bounceb); - dm->dm_count = reqp->xdata_len; - reqp->bouncerp = reqp->bounceb; - - return (1); -} -#endif /* REAL_DMA */ - -static void -run_main(sc) -struct ncr_softc *sc; -{ - int sps = splbio(); - - if (!main_running) { - /* - * If shared resources are required, claim them - * before entering 'scsi_main'. If we can't get them - * now, assume 'run_main' will be called when the resource - * becomes available. - */ - if (!claimed_dma()) { - splx(sps); - return; - } - main_running = 1; - splx(sps); - scsi_main(sc); - } - else splx(sps); -} - -/* - * Prefix message with full target info. - */ -static void -ncr_tprint(SC_REQ *reqp, char *fmt, ...) -{ - va_list ap; - - sc_print_addr(reqp->xs->sc_link); - va_start(ap, fmt); - vprintf(fmt, ap); - va_end(ap); -} - -/* - * Prefix message with adapter info. - */ -static void -ncr_aprint(struct ncr_softc *sc, char *fmt, ...) -{ - va_list ap; - - printf("%s: ", sc->sc_dev.dv_xname); - va_start(ap, fmt); - vprintf(fmt, ap); - va_end(ap); -} -/**************************************************************************** - * Start Debugging Functions * - ****************************************************************************/ -static void -show_data_sense(xs) -struct scsi_xfer *xs; -{ - u_char *p1, *p2; - int i; - int sz; - - p1 = (u_char *) xs->cmd; - p2 = (u_char *)&xs->sense; - if(*p2 == 0) - return; /* No(n)sense */ - printf("cmd[%d,%d]: ", xs->cmdlen, sz = command_size(*p1)); - for (i = 0; i < sz; i++) - printf("%x ", p1[i]); - printf("\nsense: "); - for (i = 0; i < sizeof(xs->sense); i++) - printf("%x ", p2[i]); - printf("\n"); -} - -static void -show_request(reqp, qtxt) -SC_REQ *reqp; -char *qtxt; -{ - printf("REQ-%s: %d %p[%ld] cmd[0]=%x S=%x M=%x R=%x resid=%d dr_flag=%x %s\n", - qtxt, reqp->targ_id, reqp->xdata_ptr, reqp->xdata_len, - reqp->xcmd.opcode, reqp->status, reqp->message, - reqp->xs->error, reqp->xs->resid, reqp->dr_flag, - reqp->link ? "L":""); - if (reqp->status == SCSCHKC) - show_data_sense(reqp->xs); -} - -static char *sig_names[] = { - "PAR", "SEL", "I/O", "C/D", "MSG", "REQ", "BSY", "RST", - "ACK", "ATN", "LBSY", "PMATCH", "IRQ", "EPAR", "DREQ", "EDMA" -}; - -static void -show_signals(dmstat, idstat) -u_char dmstat, idstat; -{ - u_short tmp, mask; - int j, need_pipe; - - tmp = idstat | ((dmstat & 3) << 8); - printf("Bus signals (%02x/%02x): ", idstat, dmstat & 3); - for (mask = 1, j = need_pipe = 0; mask <= tmp; mask <<= 1, j++) { - if (tmp & mask) - printf("%s%s", need_pipe++ ? "|" : "", sig_names[j]); - } - printf("\nDma status (%02x): ", dmstat); - for (mask = 4, j = 10, need_pipe = 0; mask <= dmstat; mask <<= 1, j++) { - if (dmstat & mask) - printf("%s%s", need_pipe++ ? "|" : "", sig_names[j]); - } - printf("\n"); -} - -void -scsi_show() -{ - SC_REQ *tmp; - int sps = splhigh(); - u_char idstat, dmstat; -#ifdef DBG_PID - int i; -#endif - - printf("scsi_show: scsi_main is%s running\n", - main_running ? "" : " not"); - for (tmp = issue_q; tmp; tmp = tmp->next) - show_request(tmp, "ISSUED"); - for (tmp = discon_q; tmp; tmp = tmp->next) - show_request(tmp, "DISCONNECTED"); - if (connected) - show_request(connected, "CONNECTED"); - idstat = GET_5380_REG(NCR5380_IDSTAT); - dmstat = GET_5380_REG(NCR5380_DMSTAT); - show_signals(dmstat, idstat); - if (connected) - printf("phase = %d, ", connected->phase); - printf("busy:%x, spl:%04x\n", busy, sps); -#ifdef DBG_PID - for (i=0; i<DBG_PID; i++) - printf("\t%d\t%s\n", i, last_hit[i]); -#endif - - splx(sps); -} diff --git a/sys/arch/mac68k/dev/ncr5380reg.h b/sys/arch/mac68k/dev/ncr5380reg.h deleted file mode 100644 index 9314967b1aa..00000000000 --- a/sys/arch/mac68k/dev/ncr5380reg.h +++ /dev/null @@ -1,265 +0,0 @@ -/* $OpenBSD: ncr5380reg.h,v 1.7 2011/04/03 16:37:25 krw Exp $ */ -/* $NetBSD: ncr5380reg.h,v 1.9 1996/05/05 06:16:58 briggs Exp $ */ - -/* - * Copyright (c) 1995 Leo Weppelman. - * 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 Leo Weppelman. - * 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. - */ - -#ifndef _NCR5380REG_H -#define _NCR5380REG_H -/* - * NCR5380 common interface definitions. - */ - -/* - * Register numbers: (first argument to GET/SET_5380_REG ) - */ -#define NCR5380_DATA 0 /* Data register */ -#define NCR5380_ICOM 1 /* Initiator command register */ -#define NCR5380_MODE 2 /* Mode register */ -#define NCR5380_TCOM 3 /* Target command register */ -#define NCR5380_IDSTAT 4 /* Bus status register */ -#define NCR5380_DMSTAT 5 /* DMA status register */ -#define NCR5380_TRCV 6 /* Target receive register */ -#define NCR5380_IRCV 7 /* Initiator receive register */ - -/* - * Definitions for Initiator command register. - */ -#define SC_A_RST 0x80 /* RW - Assert RST */ -#define SC_TEST 0x40 /* W - Test mode */ -#define SC_AIP 0x40 /* R - Arbitration in progress */ -#define SC_LA 0x20 /* R - Lost arbitration */ -#define SC_A_ACK 0x10 /* RW - Assert ACK */ -#define SC_A_BSY 0x08 /* RW - Assert BSY */ -#define SC_A_SEL 0x04 /* RW - Assert SEL */ -#define SC_A_ATN 0x02 /* RW - Assert ATN */ -#define SC_ADTB 0x01 /* RW - Assert Data To Bus */ - -/* - * Definitions for mode register - */ -#define SC_B_DMA 0x80 /* RW - Block mode DMA (not on TT!) */ -#define SC_T_MODE 0x40 /* RW - Target mode */ -#define SC_E_PAR 0x20 /* RW - Enable parity check */ -#define SC_E_PARI 0x10 /* RW - Enable parity interrupt */ -#define SC_E_EOPI 0x08 /* RW - Enable End Of Process Interrupt */ -#define SC_MON_BSY 0x04 /* RW - Monitor BSY */ -#define SC_M_DMA 0x02 /* RW - Set DMA mode */ -#define SC_ARBIT 0x01 /* RW - Arbitrate */ - -/* - * Definitions for tcom register - */ -#define SC_LBS 0x80 /* RW - Last Byte Send (not on TT!) */ -#define SC_A_REQ 0x08 /* RW - Assert REQ */ -#define SC_A_MSG 0x04 /* RW - Assert MSG */ -#define SC_A_CD 0x02 /* RW - Assert C/D */ -#define SC_A_IO 0x01 /* RW - Assert I/O */ - -/* - * Definitions for idstat register - */ -#define SC_S_RST 0x80 /* R - RST is set */ -#define SC_S_BSY 0x40 /* R - BSY is set */ -#define SC_S_REQ 0x20 /* R - REQ is set */ -#define SC_S_MSG 0x10 /* R - MSG is set */ -#define SC_S_CD 0x08 /* R - C/D is set */ -#define SC_S_IO 0x04 /* R - I/O is set */ -#define SC_S_SEL 0x02 /* R - SEL is set */ -#define SC_S_PAR 0x01 /* R - Parity bit */ - -/* - * Definitions for dmastat register - */ -#define SC_END_DMA 0x80 /* R - End of DMA */ -#define SC_DMA_REQ 0x40 /* R - DMA request */ -#define SC_PAR_ERR 0x20 /* R - Parity error */ -#define SC_IRQ_SET 0x10 /* R - IRQ is active */ -#define SC_PHS_MTCH 0x08 /* R - Phase Match */ -#define SC_BSY_ERR 0x04 /* R - Busy error */ -#define SC_ATN_STAT 0x02 /* R - State of ATN line */ -#define SC_ACK_STAT 0x01 /* R - State of ACK line */ -#define SC_S_SEND 0x00 /* W - Start DMA output */ - -#define SC_CLINT { /* Clear interrupts */ \ - int i = GET_5380_REG(NCR5380_IRCV); \ - } - - -/* - * Definition of SCSI-bus phases. The values are determined by signals - * on the SCSI-bus. DO NOT CHANGE! - * The values must be used to index the pointers in SCSI-PARMS. - */ -#define NR_PHASE 8 -#define PH_DATAOUT 0 -#define PH_DATAIN 1 -#define PH_CMD 2 -#define PH_STATUS 3 -#define PH_RES1 4 -#define PH_RES2 5 -#define PH_MSGOUT 6 -#define PH_MSGIN 7 - -#define PH_OUT(phase) (!(phase & 1)) /* TRUE if output phase */ -#define PH_IN(phase) (phase & 1) /* TRUE if input phase */ - -/* - * Id of Host-adapter - */ -#define SC_HOST_ID 0x80 - -/* - * Base setting for 5380 mode register - */ -#define IMODE_BASE SC_E_PAR - -/* - * SCSI completion status codes, should move to sys/scsi/???? - */ -#define SCSMASK 0x1e /* status code mask */ -#define SCSGOOD 0x00 /* good status */ -#define SCSCHKC 0x02 /* check condition */ -#define SCSBUSY 0x08 /* busy status */ -#define SCSCMET 0x04 /* condition met / good */ - -/* - * Return values of check_intr() - */ -#define INTR_SPURIOUS 0 -#define INTR_RESEL 2 -#define INTR_DMA 3 - -struct ncr_softc { - struct device sc_dev; - struct scsi_link sc_link; - - struct via2hand sc_ih_irq, sc_ih_drq; - - struct mutex sc_sc_req_mtx; - struct scsi_iopool sc_iopool; - - /* - * Some (pre-SCSI2) devices don't support select with ATN. - * If the device responds to select with ATN by going into - * command phase (ignoring ATN), then we flag it in the - * following bitmask. - * We also keep track of which devices have been selected - * before. This allows us to not even try raising ATN if - * the target doesn't respond to it the first time. - */ - u_int8_t sc_noselatn; - u_int8_t sc_selected; -}; - -/* - * Max. number of dma-chains per request - */ -#define MAXDMAIO (MAXPHYS/NBPG + 1) - -/* - * Some requests are not contiguous in physical memory. We need to break them - * up into contiguous parts for DMA. - */ -struct dma_chain { - u_int dm_count; - u_long dm_addr; -}; - -/* - * Define our issue, free and disconnect queue's. - */ -typedef struct req_q { - struct req_q *next; /* next in free, issue or discon queue */ - struct req_q *link; /* next linked command to execute */ - struct scsi_xfer *xs; /* request from high-level driver */ - u_short dr_flag; /* driver state */ - u_char phase; /* current SCSI phase */ - u_char msgout; /* message to send when requested */ - u_char targ_id; /* target for command */ - u_char targ_lun; /* lun for command */ - u_char status; /* returned status byte */ - u_char message; /* returned message byte */ - u_char *bounceb; /* allocated bounce buffer */ - u_char *bouncerp; /* bounce read-pointer */ - struct dma_chain dm_chain[MAXDMAIO]; - struct dma_chain *dm_cur; /* current dma-request */ - struct dma_chain *dm_last; /* last dma-request */ - long xdata_len; /* length of transfer */ - u_char *xdata_ptr; /* virtual address of transfer */ - struct scsi_generic xcmd; /* command to execute */ -} SC_REQ; - -/* - * Values for dr_flag: - */ -#define DRIVER_IN_DMA 0x01 /* Non-polled DMA activated */ -#define DRIVER_AUTOSEN 0x02 /* Doing automatic sense */ -#define DRIVER_NOINT 0x04 /* We are booting: no interrupts */ -#define DRIVER_DMAOK 0x08 /* DMA can be used on this request */ -#define DRIVER_BOUNCING 0x10 /* Using the bounce buffer */ -#define DRIVER_LINKCHK 0x20 /* Doing the linked command check */ - -/* XXX: Should go to ncr5380var.h */ -static SC_REQ *issue_q = NULL; /* Commands waiting to be issued*/ -static SC_REQ *discon_q = NULL; /* Commands disconnected */ -static SC_REQ *connected = NULL; /* Command currently connected */ - -/* - * Function decls: - */ -static int transfer_pio(u_char *, u_char *, u_long *, int); -static int wait_req_true(void); -static int wait_req_false(void); -static int scsi_select(SC_REQ *, int); -static int handle_message(SC_REQ *, u_int); -static void ack_message(void); -static void nack_message(SC_REQ *, u_char); -static void finish_req(SC_REQ *reqp); -static int command_size(u_char opcode); -static int information_transfer(struct ncr_softc *); -static void reselect(struct ncr_softc *); -static int check_autosense(SC_REQ *, int); -static int reach_msg_out(struct ncr_softc *, u_long); -static int check_intr(struct ncr_softc *); -static void scsi_reset(void); -static void scsi_reset_verbose(struct ncr_softc *, const char *); -static void run_main(struct ncr_softc *); -static void scsi_main(struct ncr_softc *); -static void ncr_ctrl_intr(struct ncr_softc *); -static void ncr_tprint(SC_REQ *, char *, ...); -static void ncr_aprint(struct ncr_softc *, char *, ...); - -static void show_data_sense(struct scsi_xfer *xs); -static void show_request(SC_REQ *, char *); -/* static void show_phase(SC_REQ *, int); */ -static void show_signals(u_char, u_char); - -#endif /* _NCR5380REG_H */ diff --git a/sys/arch/mac68k/dev/ncr5380var.h b/sys/arch/mac68k/dev/ncr5380var.h deleted file mode 100644 index fe1a1cec391..00000000000 --- a/sys/arch/mac68k/dev/ncr5380var.h +++ /dev/null @@ -1,79 +0,0 @@ -/* $OpenBSD: ncr5380var.h,v 1.2 2002/03/14 01:26:35 millert Exp $ */ -/* $NetBSD: ncr5380var.h,v 1.2 1996/05/25 16:42:31 briggs Exp $ */ - -/* - * Copyright (c) 1995 Allen Briggs. 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 Allen Briggs. - * 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. - */ - -static volatile u_char *scsi_enable = NULL; -static volatile u_char *scsi_flag = NULL; - -static __inline__ void -scsi_clear_drq(void) -{ - int s; - - s = splhigh(); - *scsi_flag = 0x80 | V2IF_SCSIDRQ; - splx(s); -} - -static __inline__ void -scsi_clear_irq(void) -{ - int s; - - s = splhigh(); - *scsi_flag = 0x80 | V2IF_SCSIIRQ; - splx(s); -} - -static __inline__ void -scsi_ienable(void) -{ - int s; - - s = splhigh(); - *scsi_enable = 0x80 | (V2IF_SCSIIRQ | V2IF_SCSIDRQ); - splx(s); -} - -static __inline__ void -scsi_idisable(void) -{ - int s; - - s = splhigh(); - *scsi_enable = V2IF_SCSIIRQ | V2IF_SCSIDRQ; - splx(s); -} - -void pdma_stat(void); -void pdma_cleanup(void); -void scsi_show(void); - diff --git a/sys/arch/mac68k/dev/nubus.c b/sys/arch/mac68k/dev/nubus.c deleted file mode 100644 index fb05fcc839c..00000000000 --- a/sys/arch/mac68k/dev/nubus.c +++ /dev/null @@ -1,899 +0,0 @@ -/* $OpenBSD: nubus.c,v 1.34 2008/05/19 18:42:12 miod Exp $ */ -/* $NetBSD: nubus.c,v 1.53 2002/04/13 17:49:41 briggs Exp $ */ - -/* - * Copyright (c) 1995, 1996 Allen Briggs. 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 Allen Briggs. - * 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. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/malloc.h> -#include <sys/device.h> -#include <sys/buf.h> -#include <sys/conf.h> - -#include <uvm/uvm_extern.h> - -#include <machine/autoconf.h> -#include <machine/bus.h> -#include <machine/vmparam.h> -#include <machine/param.h> -#include <machine/cpu.h> -#include <machine/pte.h> -#include <machine/viareg.h> - -#include <mac68k/dev/nubus.h> - -#ifdef DEBUG -#define NDB_PROBE 0x1 -#define NDB_FOLLOW 0x2 -#define NDB_ARITH 0x4 -static int nubus_debug = 0 /* | NDB_PROBE | NDB_FOLLOW | NDB_ARITH */ ; -#endif - -static int nubus_print(void *, const char *); -static int nubus_match(struct device *, void *, void *); -static void nubus_attach(struct device *, struct device *, void *); -static int nubus_video_resource(int); - -static int nubus_probe_slot(bus_space_tag_t, bus_space_handle_t, - int, nubus_slot *); -static u_int32_t nubus_calc_CRC(bus_space_tag_t, bus_space_handle_t, - nubus_slot *); - -static u_long nubus_adjust_ptr(u_int8_t, u_long, long); -static u_int8_t nubus_read_1(bus_space_tag_t, bus_space_handle_t, - u_int8_t, u_long); -#ifdef notyet -static u_int16_t nubus_read_2(bus_space_tag_t, bus_space_handle_t, - u_int8_t, u_long); -#endif -static u_int32_t nubus_read_4(bus_space_tag_t, bus_space_handle_t, - u_int8_t, u_long); - -struct cfattach nubus_ca = { - sizeof(struct nubus_softc), nubus_match, nubus_attach -}; - -struct cfdriver nubus_cd = { - NULL, "nubus", DV_DULL, -}; - -static int -nubus_match(parent, cf, aux) - struct device *parent; - void *cf; - void *aux; -{ - static int nubus_matched = 0; - - /* Allow only one instance. */ - if (nubus_matched) - return (0); - - nubus_matched = 1; - return (1); -} - -static void -nubus_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct nubus_attach_args na_args; - bus_space_tag_t bst; - bus_space_handle_t bsh; - nubus_slot fmtblock; - nubus_dir dir; - nubus_dirent dirent; - nubus_type slottype; - u_long entry; - int i, rsrcid; - u_int8_t lanes; - - printf("\n"); - - for (i = NUBUS_MIN_SLOT; i <= NUBUS_MAX_SLOT; i++) { - na_args.slot = i; - na_args.na_tag = bst = MAC68K_BUS_SPACE_MEM; - - if (bus_space_map(bst, - NUBUS_SLOT2PA(na_args.slot), NBMEMSIZE, 0, &bsh)) { -#ifdef DEBUG - if (nubus_debug & NDB_PROBE) - printf("%s: failed to map slot %x, " - "address %p (in use?)\n", - self->dv_xname, i, - (void *)NUBUS_SLOT2PA(i)); -#endif - continue; - } - - if (nubus_probe_slot(bst, bsh, i, &fmtblock) <= 0) { -notfound: - bus_space_unmap(bst, bsh, NBMEMSIZE); - continue; - } - - rsrcid = 0x80; - lanes = fmtblock.bytelanes; - - nubus_get_main_dir(&fmtblock, &dir); - - /* - * Get the resource for the first function on the card. - * This is assumed to be at resource ID 0x80. If we can - * not find this entry (as we can not on some video cards), - * check to see if we can get a different ID from the list - * of video resources given to us by the booter. If that - * doesn't work either, take the first resource following - * the board resource. - * If we only find a board resource, report that. - * There are cards that do not have anything else; their - * driver then has to match on the board resource and - * the card name. - */ - if (nubus_find_rsrc(bst, bsh, - &fmtblock, &dir, rsrcid, &dirent) <= 0) { - if ((rsrcid = nubus_video_resource(i)) == -1) { - int has_board_rsrc = 0; - - /* - * Since nubus_find_rsrc failed, the directory - * is back at its base. - */ - entry = dir.curr_ent; - - /* - * All nubus cards should have a board - * resource, but be sure that's what it - * is before we skip it, and note the fact. - */ - rsrcid = nubus_read_1(bst, bsh, - lanes, entry); - if (rsrcid == 0x1) { - has_board_rsrc = 1; - entry = nubus_adjust_ptr(lanes, - dir.curr_ent, 4); - } - rsrcid = nubus_read_1(bst, bsh, lanes, entry); - /* end of chain? */ - if (rsrcid == 0xff) { - if (!has_board_rsrc) - goto notfound; - else - rsrcid = 0x01; - } -#ifdef DEBUG - if (nubus_debug & NDB_FOLLOW) - printf("\tUsing rsrc 0x%x.\n", rsrcid); -#endif - } - /* - * Try to find the resource passed by the booter - * or the one we just tracked down. - */ - if (nubus_find_rsrc(bst, bsh, - &fmtblock, &dir, rsrcid, &dirent) <= 0) - goto notfound; - } - - nubus_get_dir_from_rsrc(&fmtblock, &dirent, &dir); - - if (nubus_find_rsrc(bst, bsh, - &fmtblock, &dir, NUBUS_RSRC_TYPE, &dirent) <= 0) - goto notfound; - - if (nubus_get_ind_data(bst, bsh, &fmtblock, &dirent, - (caddr_t)&slottype, sizeof(nubus_type)) <= 0) - goto notfound; - - /* - * If this is a display card, try to pull out the correct - * display mode as passed by the booter. - */ - if (slottype.category == NUBUS_CATEGORY_DISPLAY) { - int r; - - if ((r = nubus_video_resource(i)) != -1) { - - nubus_get_main_dir(&fmtblock, &dir); - - if (nubus_find_rsrc(bst, bsh, - &fmtblock, &dir, r, &dirent) <= 0) - goto notfound; - - nubus_get_dir_from_rsrc(&fmtblock, - &dirent, &dir); - - if (nubus_find_rsrc(bst, bsh, &fmtblock, &dir, - NUBUS_RSRC_TYPE, &dirent) <= 0) - goto notfound; - - if (nubus_get_ind_data(bst, bsh, - &fmtblock, &dirent, (caddr_t)&slottype, - sizeof(nubus_type)) <= 0) - goto notfound; - - rsrcid = r; - } - } - - na_args.slot = i; - na_args.rsrcid = rsrcid; - na_args.category = slottype.category; - na_args.type = slottype.type; - na_args.drsw = slottype.drsw; - na_args.drhw = slottype.drhw; - na_args.fmt = &fmtblock; - - bus_space_unmap(bst, bsh, NBMEMSIZE); - - config_found(self, &na_args, nubus_print); - } - - enable_nubus_intr(); -} - -static int -nubus_print(aux, pnp) - void *aux; - const char *pnp; -{ - struct nubus_attach_args *na = (struct nubus_attach_args *)aux; - bus_space_tag_t bst = na->na_tag; - bus_space_handle_t bsh; - - if (pnp) { - printf("%s slot %x", pnp, na->slot); - if (bus_space_map(bst, - NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &bsh) == 0) { - printf(": %s", nubus_get_card_name(bst, bsh, na->fmt)); - printf(" (Vendor: %s,", nubus_get_vendor(bst, bsh, - na->fmt, NUBUS_RSRC_VEND_ID)); - printf(" Part: %s)", nubus_get_vendor(bst, bsh, - na->fmt, NUBUS_RSRC_VEND_PART)); - - bus_space_unmap(bst, bsh, NBMEMSIZE); - } -#ifdef DIAGNOSTIC - else - printf(":"); - printf(" Type: %04x %04x %04x %04x", - na->category, na->type, na->drsw, na->drhw); -#endif - } else { - printf(" slot %x", na->slot); - } - return (UNCONF); -} - -static int -nubus_video_resource(slot) - int slot; -{ - extern u_int16_t mac68k_vrsrc_vec[]; - int i; - - for (i = 0 ; i < 6 ; i++) - if ((mac68k_vrsrc_vec[i] & 0xff) == slot) - return ((mac68k_vrsrc_vec[i] >> 8) & 0xff); - return (-1); -} - -/* - * Probe a given nubus slot. If a card is there and we can get the - * format block from its clutching decl. ROMs, fill the format block - * and return non-zero. If we can't find a card there with a valid - * decl. ROM, return 0. - * - * First, we check to see if we can access the memory at the tail - * end of the slot. If so, then we check for a bytelanes byte. We - * could probably just return a failure status if we bus error on - * the first try, but there really is little reason not to go ahead - * and check the other three locations in case there's a weird card - * out there. - * - * Checking for a card involves locating the "bytelanes" byte which - * tells us how to interpret the declaration ROM's data. The format - * block is at the top of the card's standard memory space and the - * bytelanes byte is at the end of that block. - * - * After some inspection of the bytelanes byte, it appears that it - * takes the form 0xXY where Y is a bitmask of the bytelanes in use - * and X is a bitmask of the lanes to ignore. Hence, (X ^ Y) == 0 - * and (less obviously), Y will have the upper N bits clear if it is - * found N bytes from the last possible location. Both that and - * the exclusive-or check are made. - * - * If a valid - */ -static u_int8_t nbits[] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4}; -static int -nubus_probe_slot(bst, bsh, slot, fmt) - bus_space_tag_t bst; - bus_space_handle_t bsh; - int slot; - nubus_slot *fmt; -{ - u_long ofs, hdr; - int i, j, found, hdr_size; - u_int8_t lanes; - -#ifdef DEBUG - if (nubus_debug & NDB_PROBE) - printf("probing slot %x\n", slot); -#endif - - /* - * The idea behind this glorious work of art is to probe for only - * valid bytelanes values at appropriate locations (see DC&D p. 159 - * for a list). Note the pattern: the first 8 values are at offset - * 0xffffff in the slot's space; the next 4 values at 0xfffffe; the - * next 2 values at 0xfffffd; and the last one at 0xfffffc. - * - * The nested loops implement an efficient search of this space, - * probing first for a valid address, then checking for each of the - * valid bytelanes values at that address. - */ - ofs = NBMEMSIZE; - lanes = 0xf; - - for (j = 8, found = 0; j > 0 && !found; j >>= 1) { - ofs--; - for (i = j; i > 0; i--, lanes--) { - if (!mac68k_bus_space_probe(bst, bsh, ofs, 1)) { - lanes -= i; - break; - } - if (bus_space_read_1(bst, bsh, ofs) == - (((~lanes & 0xf) << 4) | lanes)) { - found = 1; - break; - } - } - } - - if (!found) { -#ifdef DEBUG - if (nubus_debug & NDB_PROBE) - printf("bytelanes not found for slot %x\n", slot); -#endif - return 0; - } - - fmt->bytelanes = lanes; - fmt->step = nbits[(lanes & 0x0f)]; - fmt->slot = slot; /* XXX redundant; get rid of this someday */ - -#ifdef DEBUG - if (nubus_debug & NDB_PROBE) - printf("bytelanes of 0x%x found for slot 0x%x.\n", - fmt->bytelanes, slot); -#endif - - /* - * Go ahead and attempt to load format header. - * First, we need to find the first byte beyond memory that - * would be valid. This is necessary for NUBUS_ROM_offset() - * to work. - */ - hdr = NBMEMSIZE; - hdr_size = 20; - - i = 0x10 | (lanes & 0x0f); - while ((i & 1) == 0) { - hdr++; - i >>= 1; - } - fmt->top = hdr; - hdr = nubus_adjust_ptr(lanes, hdr, -hdr_size); -#ifdef DEBUG - if (nubus_debug & NDB_PROBE) - printf("fmt->top is 0x%lx, that minus 0x%x puts us at 0x%lx.\n", - fmt->top, hdr_size, hdr); - if (nubus_debug & NDB_ARITH) - for (i = 1 ; i < 8 ; i++) - printf("0x%lx - 0x%x = 0x%lx, + 0x%x = 0x%lx.\n", - hdr, i, nubus_adjust_ptr(lanes, hdr, -i), - i, nubus_adjust_ptr(lanes, hdr, i)); -#endif - - fmt->directory_offset = - 0xff000000 | nubus_read_4(bst, bsh, lanes, hdr); - hdr = nubus_adjust_ptr(lanes, hdr, 4); - fmt->length = nubus_read_4(bst, bsh, lanes, hdr); - hdr = nubus_adjust_ptr(lanes, hdr, 4); - fmt->crc = nubus_read_4(bst, bsh, lanes, hdr); - hdr = nubus_adjust_ptr(lanes, hdr, 4); - fmt->revision_level = nubus_read_1(bst, bsh, lanes, hdr); - hdr = nubus_adjust_ptr(lanes, hdr, 1); - fmt->format = nubus_read_1(bst, bsh, lanes, hdr); - hdr = nubus_adjust_ptr(lanes, hdr, 1); - fmt->test_pattern = nubus_read_4(bst, bsh, lanes, hdr); - -#ifdef DEBUG - if (nubus_debug & NDB_PROBE) { - printf("Directory offset 0x%x\t", fmt->directory_offset); - printf("Length 0x%x\t", fmt->length); - printf("CRC 0x%x\n", fmt->crc); - printf("Revision level 0x%x\t", fmt->revision_level); - printf("Format 0x%x\t", fmt->format); - printf("Test Pattern 0x%x\n", fmt->test_pattern); - } -#endif - - if ((fmt->directory_offset & 0x00ff0000) == 0) { - printf("Invalid looking directory offset (0x%x)!\n", - fmt->directory_offset); - return 0; - } - if (fmt->test_pattern != NUBUS_ROM_TEST_PATTERN) { - printf("Nubus--test pattern invalid:\n"); - printf(" slot 0x%x, bytelanes 0x%x?\n", fmt->slot, lanes); - printf(" read test 0x%x, compare with 0x%x.\n", - fmt->test_pattern, NUBUS_ROM_TEST_PATTERN); - return 0; - } - - /* Perform CRC */ - if (fmt->crc != nubus_calc_CRC(bst, bsh, fmt)) { - printf("Nubus--crc check failed, slot 0x%x.\n", fmt->slot); - return 0; - } - - return 1; -} - -static u_int32_t -nubus_calc_CRC(bst, bsh, fmt) - bus_space_tag_t bst; - bus_space_handle_t bsh; - nubus_slot *fmt; -{ -#if 0 - u_long base, ptr, crc_loc; - u_int32_t sum; - u_int8_t lanes = fmt->bytelanes; - - base = fmt->top; - crc_loc = NUBUS_ROM_offset(fmt, base, -12); - ptr = NUBUS_ROM_offset(fmt, base, -fmt->length); - - sum = 0; - while (ptr < base) - roll #1, sum - if (ptr == crc_loc) { - roll #3, sum - ptr = nubus_adjust_ptr(lanes, ptr, 3); - } else { - sum += nubus_read_1(bst, bsh, lanes, ptr); - } - ptr = nubus_adjust_ptr(lanes, ptr, 1); - } - - return sum; -#endif - return fmt->crc; -} - -/* - * Compute byte offset on card, taking into account bytelanes. - * Base must be on a valid bytelane for this function to work. - * Return the new address. - * - * XXX -- There has GOT to be a better way to do this. - */ -static u_long -nubus_adjust_ptr(lanes, base, amt) - u_int8_t lanes; - u_long base; - long amt; -{ - u_int8_t b, t; - - if (!amt) - return base; - - if (amt < 0) { - amt = -amt; - b = lanes; - t = (b << 4); - b <<= (3 - (base & 0x3)); - while (amt) { - b <<= 1; - if (b == t) - b = lanes; - if (b & 0x08) - amt--; - base--; - } - return base; - } - - t = (lanes & 0xf) | 0x10; - b = t >> (base & 0x3); - while (amt) { - b >>= 1; - if (b == 1) - b = t; - if (b & 1) - amt--; - base++; - } - - return base; -} - -static u_int8_t -nubus_read_1(bst, bsh, lanes, ofs) - bus_space_tag_t bst; - bus_space_handle_t bsh; - u_int8_t lanes; - u_long ofs; -{ - return bus_space_read_1(bst, bsh, ofs); -} - -#ifdef notyet -/* Nothing uses this, yet */ -static u_int16_t -nubus_read_2(bst, bsh, lanes, ofs) - bus_space_tag_t bst; - bus_space_handle_t bsh; - u_int8_t lanes; - u_long ofs; -{ - u_int16_t s; - - s = (nubus_read_1(bst, bsh, lanes, ofs) << 8); - ofs = nubus_adjust_ptr(lanes, ofs, 1); - s |= nubus_read_1(bst, bsh, lanes, ofs); - return s; -} -#endif - -static u_int32_t -nubus_read_4(bst, bsh, lanes, ofs) - bus_space_tag_t bst; - bus_space_handle_t bsh; - u_int8_t lanes; - u_long ofs; -{ - u_int32_t l; - int i; - - l = 0; - for (i = 0; i < 4; i++) { - l = (l << 8) | nubus_read_1(bst, bsh, lanes, ofs); - ofs = nubus_adjust_ptr(lanes, ofs, 1); - } - return l; -} - -void -nubus_get_main_dir(fmt, dir_return) - nubus_slot *fmt; - nubus_dir *dir_return; -{ -#ifdef DEBUG - if (nubus_debug & NDB_FOLLOW) - printf("nubus_get_main_dir(%p, %p)\n", - fmt, dir_return); -#endif - dir_return->dirbase = nubus_adjust_ptr(fmt->bytelanes, fmt->top, - fmt->directory_offset - 20); - dir_return->curr_ent = dir_return->dirbase; -} - -void -nubus_get_dir_from_rsrc(fmt, dirent, dir_return) - nubus_slot *fmt; - nubus_dirent *dirent; - nubus_dir *dir_return; -{ - u_long loc; - -#ifdef DEBUG - if (nubus_debug & NDB_FOLLOW) - printf("nubus_get_dir_from_rsrc(%p, %p, %p).\n", - fmt, dirent, dir_return); -#endif - if ((loc = dirent->offset) & 0x800000) { - loc |= 0xff000000; - } - dir_return->dirbase = - nubus_adjust_ptr(fmt->bytelanes, dirent->myloc, loc); - dir_return->curr_ent = dir_return->dirbase; -} - -int -nubus_find_rsrc(bst, bsh, fmt, dir, rsrcid, dirent_return) - bus_space_tag_t bst; - bus_space_handle_t bsh; - nubus_slot *fmt; - nubus_dir *dir; - u_int8_t rsrcid; - nubus_dirent *dirent_return; -{ - u_long entry; - u_int8_t byte, lanes = fmt->bytelanes; - -#ifdef DEBUG - if (nubus_debug & NDB_FOLLOW) - printf("nubus_find_rsrc(%p, %p, 0x%x, %p)\n", - fmt, dir, rsrcid, dirent_return); -#endif - if (fmt->test_pattern != NUBUS_ROM_TEST_PATTERN) - return -1; - - entry = dir->curr_ent; - do { - byte = nubus_read_1(bst, bsh, lanes, entry); -#ifdef DEBUG - if (nubus_debug & NDB_FOLLOW) - printf("\tFound rsrc 0x%x.\n", byte); -#endif - if (byte == rsrcid) { - dirent_return->myloc = entry; - dirent_return->rsrc_id = rsrcid; - entry = nubus_read_4(bst, bsh, lanes, entry); - dirent_return->offset = (entry & 0x00ffffff); - return 1; - } - if (byte == 0xff) { - entry = dir->dirbase; - } else { - entry = nubus_adjust_ptr(lanes, entry, 4); - } - } while (entry != (u_long)dir->curr_ent); - return 0; -} - -int -nubus_get_ind_data(bst, bsh, fmt, dirent, data_return, nbytes) - bus_space_tag_t bst; - bus_space_handle_t bsh; - nubus_slot *fmt; - nubus_dirent *dirent; - caddr_t data_return; - int nbytes; -{ - u_long loc; - u_int8_t lanes = fmt->bytelanes; - -#ifdef DEBUG - if (nubus_debug & NDB_FOLLOW) - printf("nubus_get_ind_data(%p, %p, %p, %d).\n", - fmt, dirent, data_return, nbytes); -#endif - if ((loc = dirent->offset) & 0x800000) { - loc |= 0xff000000; - } - loc = nubus_adjust_ptr(lanes, dirent->myloc, loc); - - while (nbytes--) { - *data_return++ = nubus_read_1(bst, bsh, lanes, loc); - loc = nubus_adjust_ptr(lanes, loc, 1); - } - return 1; -} - -int -nubus_get_c_string(bst, bsh, fmt, dirent, data_return, max_bytes) - bus_space_tag_t bst; - bus_space_handle_t bsh; - nubus_slot *fmt; - nubus_dirent *dirent; - caddr_t data_return; - int max_bytes; -{ - u_long loc; - u_int8_t lanes = fmt->bytelanes; - -#ifdef DEBUG - if (nubus_debug & NDB_FOLLOW) - printf("nubus_get_c_string(%p, %p, %p, %d).\n", - fmt, dirent, data_return, max_bytes); -#endif - if ((loc = dirent->offset) & 0x800000) - loc |= 0xff000000; - - loc = nubus_adjust_ptr(lanes, dirent->myloc, loc); - - *data_return = '\0'; - while (max_bytes--) { - if ((*data_return++ = - nubus_read_1(bst, bsh, lanes, loc)) == 0) - return 1; - loc = nubus_adjust_ptr(lanes, loc, 1); - } - *(data_return-1) = '\0'; - return 0; -} - -/* - * Get list of address ranges for an sMemory resource - * -> DC&D, p.171 - */ -int -nubus_get_smem_addr_rangelist(bst, bsh, fmt, dirent, data_return) - bus_space_tag_t bst; - bus_space_handle_t bsh; - nubus_slot *fmt; - nubus_dirent *dirent; - caddr_t data_return; -{ - u_long loc; - u_int8_t lanes = fmt->bytelanes; - long blocklen; - caddr_t blocklist; - -#ifdef DEBUG - if (nubus_debug & NDB_FOLLOW) - printf("nubus_get_smem_addr_rangelist(%p, %p, %p).\n", - fmt, dirent, data_return); -#endif - if ((loc = dirent->offset) & 0x800000) { - loc |= 0xff000000; - } - loc = nubus_adjust_ptr(lanes, dirent->myloc, loc); - - /* Obtain the block length from the head of the list */ - blocklen = nubus_read_4(bst, bsh, lanes, loc); - - /* - * malloc a block of (blocklen) bytes - * caller must recycle block after use - */ - blocklist = (caddr_t)malloc(blocklen, M_TEMP, M_WAITOK); - - /* read ((blocklen - 4) / 8) (length,offset) pairs into block */ - nubus_get_ind_data(bst, bsh, fmt, dirent, blocklist, blocklen); -#ifdef DEBUG - if (nubus_debug & NDB_FOLLOW) { - int ii; - nubus_smem_rangelist *rlist; - - rlist = (nubus_smem_rangelist *)blocklist; - printf("\tblock@%p, len 0x0%X\n", rlist, rlist->length); - - for (ii=0; ii < ((blocklen - 4) / 8); ii++) { - printf("\tRange %d: base addr 0x%X [0x%X]\n", ii, - rlist->range[ii].offset, rlist->range[ii].length); - } - } -#endif - *(caddr_t *)data_return = blocklist; - - return 1; -} - -static char *huh = "???"; - -char * -nubus_get_vendor(bst, bsh, fmt, rsrc) - bus_space_tag_t bst; - bus_space_handle_t bsh; - nubus_slot *fmt; - int rsrc; -{ - static char str_ret[64]; - nubus_dir dir; - nubus_dirent ent; - -#ifdef DEBUG - if (nubus_debug & NDB_FOLLOW) - printf("nubus_get_vendor(%p, 0x%x).\n", fmt, rsrc); -#endif - nubus_get_main_dir(fmt, &dir); - if (nubus_find_rsrc(bst, bsh, fmt, &dir, 1, &ent) <= 0) - return huh; - nubus_get_dir_from_rsrc(fmt, &ent, &dir); - - if (nubus_find_rsrc(bst, bsh, fmt, &dir, NUBUS_RSRC_VENDORINFO, &ent) - <= 0) - return huh; - nubus_get_dir_from_rsrc(fmt, &ent, &dir); - - if (nubus_find_rsrc(bst, bsh, fmt, &dir, rsrc, &ent) <= 0) - return huh; - - nubus_get_c_string(bst, bsh, fmt, &ent, str_ret, 64); - - return str_ret; -} - -char * -nubus_get_card_name(bst, bsh, fmt) - bus_space_tag_t bst; - bus_space_handle_t bsh; - nubus_slot *fmt; -{ - static char name_ret[64]; - nubus_dir dir; - nubus_dirent ent; - -#ifdef DEBUG - if (nubus_debug & NDB_FOLLOW) - printf("nubus_get_card_name(%p).\n", fmt); -#endif - nubus_get_main_dir(fmt, &dir); - - if (nubus_find_rsrc(bst, bsh, fmt, &dir, 1, &ent) <= 0) - return huh; - - nubus_get_dir_from_rsrc(fmt, &ent, &dir); - - if (nubus_find_rsrc(bst, bsh, fmt, &dir, NUBUS_RSRC_NAME, &ent) <= 0) - return huh; - - nubus_get_c_string(bst, bsh, fmt, &ent, name_ret, 64); - - return name_ret; -} - -#ifdef DEBUG -void -nubus_scan_slot(bst, slotno) - bus_space_tag_t bst; - int slotno; -{ - int i=0, state=0; - char twirl[] = "-\\|/"; - bus_space_handle_t sc_bsh; - - if (bus_space_map(bst, NUBUS_SLOT2PA(slotno), NBMEMSIZE, 0, &sc_bsh)) { - printf("nubus_scan_slot: failed to map slot %x\n", slotno); - return; - } - - printf("Scanning slot %c for accessible regions:\n", - slotno == 9 ? '9' : slotno - 10 + 'A'); - for (i=0 ; i<NBMEMSIZE; i++) { - if (mac68k_bus_space_probe(bst, sc_bsh, i, 1)) { - if (state == 0) { - printf("\t0x%x-", i); - state = 1; - } - } else { - if (state) { - printf("0x%x\n", i); - state = 0; - } - } - if (i%100 == 0) { - printf("%c\b", twirl[(i/100)%4]); - } - } - if (state) { - printf("0x%x\n", i); - } - return; -} -#endif diff --git a/sys/arch/mac68k/dev/nubus.h b/sys/arch/mac68k/dev/nubus.h deleted file mode 100644 index a0629105d71..00000000000 --- a/sys/arch/mac68k/dev/nubus.h +++ /dev/null @@ -1,386 +0,0 @@ -/* $NetBSD: nubus.h,v 1.59 2005/01/15 16:00:59 chs Exp $ */ - -/* - * Copyright (c) 1995 Allen Briggs. 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 Allen Briggs. - * 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. - */ - -/* - * Nubus cards in Macintoshes are identified by 4 16-bit numbers: - * Category: What is the main purpose of this card? - * Type: Within this overall category, what kind of card? - * DrSW: What software interface does it use? - * DrHW: What specific hardware is it? - * - * For example, the "Toby Frame Buffer" display card is - * Category 3 (display) - * Type 1 (video) - * DrSW 1 (Apple) - * and DrHW 1 (TFB). - */ - -#include <machine/cpu.h> - -#define NUBUS_CATEGORY_BOARD 0x0001 -#define NUBUS_TYPE_BOARD 0x0000 /* We want these for minimal board */ -#define NUBUS_DRSW_BOARD 0x0000 /* ROMs that come with nothing but */ -#define NUBUS_DRHW_BOARD 0x0000 /* a board resource (old NI_GPIB) */ - -#define NUBUS_CATEGORY_DISPLAY 0x0003 -#define NUBUS_TYPE_VIDEO 0x0001 -#define NUBUS_TYPE_LCD 0x0002 -#define NUBUS_DRSW_APPLE 0x0001 -#define NUBUS_DRHW_TFB 0x0001 /* Apple Toby Frame Buffer */ -#define NUBUS_DRHW_BAER 0x0002 /* Formac Baers/ProNitron 80.IVb */ -#define NUBUS_DRHW_WVC 0x0006 /* Apple Workstation Video Card */ -#define NUBUS_DRHW_COLORMAX 0x0007 /* Sigma Designs ColorMax */ -#define NUBUS_DRHW_SE30 0x0009 /* Apple SE/30 pseudo-slot video */ -#define NUBUS_DRHW_M2HRVC 0x0013 /* Apple Mac II High-Res Video Card */ -#define NUBUS_DRHW_MVC 0x0014 /* Apple Mac II Monochrome Video Card */ -#define NUBUS_DRHW_PVC 0x0017 /* Apple Mac II Portrait Video Card */ -#define NUBUS_DRHW_MDC 0x0019 /* Apple Macintosh Display Card */ -#define NUBUS_DRHW_VSC 0x0020 /* Apple Macintosh Duo MiniDock */ -#define NUBUS_DRHW_JET 0x0029 /* Apple Macintosh DuoDock II */ -#define NUBUS_DRHW_BOOGIE 0x002b /* Apple Macintosh 24AC Video Card */ -#define NUBUS_DRHW_VILTRO340 0x0102 /* VillageTronic Mac Picasso 340 */ -#define NUBUS_DRHW_SUPRGFX 0x0105 /* SuperMac GFX */ -#define NUBUS_DRHW_RELAX200 0x0131 /* Relax 19" Model 200 */ -#define NUBUS_DRHW_FORMAC 0x013A /* Formac color card II */ -#define NUBUS_DRHW_CB264 0x013B /* RasterOps ColorBoard 264 */ -#define NUBUS_DRHW_MICRON 0x0146 /* Micron Exceed color */ -#define NUBUS_DRHW_RADGSC 0x0153 /* Radius GS/C */ -#define NUBUS_DRHW_SPECTRM8 0x017b /* SuperMac Spectrum/8 Series III */ -#define NUBUS_DRHW_SPECTRUM 0x017c /* SuperMac Spectrum/24 Series III */ -#define NUBUS_DRHW_VIMAGE 0x026E /* Interware Co., Ltd. Vimage */ -#define NUBUS_DRHW_CB364 0x026F /* RasterOps ColorBoard 364 */ -#define NUBUS_DRHW_LVIEW 0x0278 /* Sigma Designs L-View */ -#define NUBUS_DRHW_RDCGX 0x027C /* Radius DirectColor/GX */ -#define NUBUS_DRHW_RPC8 0x0291 /* Radius PrecisionColor 8 */ -#define NUBUS_DRHW_LAPIS 0x0292 /* SE/30 Lapis ProColorServer 8 PDS */ -#define NUBUS_DRHW_ROPS24LXI 0x02A0 /* RasterOps 8/24 XLi */ -#define NUBUS_DRHW_ROPSPPGT 0x02A5 /* RasterOps PaintBoard Prism GT 1.0 */ -#define NUBUS_DRHW_FUTURASX 0x02AE /* E-Machines Futura-SX */ -#define NUBUS_DRHW_ROPS24XLTV 0x02B7 /* RasterOps 24XlTV */ -#define NUBUS_DRHW_THUNDER24 0x02CB /* SuperMac Thunder/24 */ -#define NUBUS_DRHW_MPGX 0x03D6 /* MiroPRISMA GX */ -#define NUBUS_DRHW_ROPS24MXTV 0x03DF /* RasterOps 24MxTV */ -#define NUBUS_DRHW_GVIMAGE 0x03FB /* Interware Co., Ltd. Grand Vimage */ -#define NUBUS_DRHW_RPC24XP 0x0406 /* Radius PrecisionColor 24Xp */ -#define NUBUS_DRHW_RPC24X 0x040A /* Radius PrecisionColor 24X */ -#define NUBUS_DRHW_RPC8XJ 0x040B /* Radius PrecisionColor 8xj */ -#define NUBUS_DRHW_FIILX 0x0417 /* Futura II LX */ -#define NUBUS_DRHW_FIISXDSP 0x042F /* Futura II SX/DSP */ -#define NUBUS_DRHW_MC2124NB 0x0462 /* MicroConversions 2124NB II */ - -/* False DrHW values for video cards masquerading as other cards */ -#define NUBUS_DRHW_SAM768 0x10000 /* Cornerstone/Samsung 768x1006 */ - -#define NUBUS_CATEGORY_NETWORK 0x0004 -#define NUBUS_TYPE_ETHERNET 0x0001 -#define NUBUS_DRSW_3COM 0x0000 -#define NUBUS_DRSW_CABLETRON 0x0001 -#define NUBUS_DRSW_GATOR 0x0103 -#define NUBUS_DRSW_ASANTE 0x0104 -#define NUBUS_DRSW_TECHWORKS 0x0109 -#define NUBUS_DRSW_DAYNA 0x010B -#define NUBUS_DRSW_FARALLON 0x010C -#define NUBUS_DRSW_DAYNA2 0x0115 -#define NUBUS_DRSW_FOCUS 0x011A -#define NUBUS_DRSW_ASANTEF 0x011D -#define NUBUS_DRSW_TFLLAN 0x011E -#define NUBUS_DRHW_INTERLAN 0x0100 -#define NUBUS_DRHW_ASANTEF 0x0101 -#define NUBUS_DRHW_KINETICS 0x0106 -#define NUBUS_DRHW_CABLETRON 0x0109 -#define NUBUS_DRHW_NUVOLINK 0x010B -#define NUBUS_DRHW_ASANTE_LC 0x010F -#define NUBUS_DRHW_SONIC 0x0110 -#define NUBUS_DRHW_TECHWORKS 0x0112 -#define NUBUS_DRHW_APPLE_SNT 0x0118 -#define NUBUS_DRHW_APPLE_SN 0x0119 - -#define NUBUS_CATEGORY_COMMUNICATIONS 0x0006 -#define NUBUS_TYPE_RS232 0x0002 -#define NUBUS_TYPE_IEEE488 0x0004 -#define NUBUS_DRSW_HDS 0x0102 -#define NUBUS_DRSW_NI488 0x0104 -#define NUBUS_DRSW_HQS 0x0105 -#define NUBUS_DRHW_HDS 0x0102 /* CS Hustler serial */ -#define NUBUS_DRHW_HQS 0x0105 /* CS Hurdler quad serial */ -#define NUBUS_DRHW_NB_GPIB_TNT 0x0102 /* NatInst NB-GPIB/TNT */ - -#define NUBUS_CATEGORY_MEMORY 0x0009 /* Also KanjiTalk Font Card? */ -#define NUBUS_TYPE_RAMCACHE 0x010C /* From Apple PDS card */ -#define NUBUS_DRSW_AWGSPDS 0x0100 -#define NUBUS_DRHW_AWGSPDS 0x0100 - -#define NUBUS_CATEGORY_CPU 0x000A -#define NUBUS_TYPE_68000 0x0002 -#define NUBUS_TYPE_68020 0x0003 -#define NUBUS_TYPE_68030 0x0004 -#define NUBUS_TYPE_68040 0x0005 -#define NUBUS_TYPE_MX 0x0009 /* TI microExplorer */ - -#define NUBUS_CATEGORY_INTBUS 0x000C -#define NUBUS_TYPE_SCSI 0x0008 -#define NUBUS_DRSW_AWGSPDS_SCSI 0x0006 -#define NUBUS_DRHW_AWGSPDS_SCSI 0x0100 -#define NUBUS_DRSW_PLI 0x0108 -#define NUBUS_DRHW_PLI 0x0100 -#define NUBUS_TYPE_SCSIW 0x000B /* FWB JackHammer Fast/Wide */ -#define NUBUS_DRSW_FWB 0x0001 /* XXX Allen says 0x010C */ -#define NUBUS_DRHW_FWB 0x0100 - -#define NUBUS_CATEGORY_DOCK 0x0020 -#define NUBUS_TYPE_STATION 0x0001 -#define NUBUS_TYPE_DESK 0x0002 -#define NUBUS_TYPE_TRAVEL 0x0003 -/* #define NUBUS_DRSW_APPLE 0x0001 */ -#define NUBUS_DRSW_NEWERTECH 0x0101 - -/* Station */ -#define NUBUS_DRHW_DUODOCK 0x0001 /* Apple DuoDock */ -#define NUBUS_DRHW_DUODOCKII 0x0002 /* Apple DuoDock II */ - -/* Desk */ -#define NUBUS_DRHW_DUOMINIDOCK 0x0001 /* Apple Duo MiniDock */ - -/* Travel */ -#define NUBUS_DRHW_MICROSCSI 0x0100 /* Newer Technology SCSI MicroDock */ - - -/* - * This is the same as Apple's Format Block for a card, with the - * addition of a pointer to the base of the NuBUS slot. - * - * This basically describes a nubus card--this structure is held in the last - * N bytes of each valid card's declaration ROM. - */ -typedef struct _nubus_slot { - u_long top; - u_int8_t slot; - u_int8_t bytelanes; - u_int8_t step; - u_int32_t test_pattern; - u_int8_t format; - u_int8_t revision_level; - u_int32_t crc; - u_int32_t length; - u_int32_t directory_offset; -} nubus_slot; - -/* - * Just a structure to ease comparison of type for drivers, etc. - */ -typedef struct _nubus_type { - u_int16_t category; - u_int16_t type; - u_int16_t drsw; - u_int16_t drhw; -} nubus_type; - -/* - * nubus_dir is a structure that describes a nubus directory. - * The nubus*dir() functions should be used to traverse this. - */ -typedef struct _nubus_dir { - u_int32_t dirbase; - u_int32_t curr_ent; -} nubus_dir; - -/* - * This is the equivalent of an Apple sResource directory entry - * with the addition of a pointer to itself (essentially) for easy - * calculation of jump to indirect data. - */ -typedef struct _nubus_dirent { - u_int32_t myloc; - u_int8_t rsrc_id; - u_int32_t offset; -} nubus_dirent; - -/* - * This is the equivalent of an Apple sResource with the addition of - * a pointer back to the sResource directory from whence we came. - * - * According to the Apple documentation, each sResource is of one of the - * following forms: - * all: bits 31-24 Identification number - * - * offset: bits 23-0 Offset to long data, cString, sBlock, etc. - * word: bits 23-16 0x00 - * bits 15-0 word data - * byte: bits 23-8 0x0000 - * bits 7-0 byte data - * - * The last resource has id = 0xff and data = 0x000000. - */ -typedef struct _nubus_rsrc { - u_int32_t myloc; - u_int8_t id; - u_int32_t data; -} nubus_rsrc; - -/* - * On a NuBus master, an sMemory resource (this is a second-level - * resource list) holds a list of address ranges for onboard - * RAM, ROM and IO resources. - */ -typedef struct _nubus_smem_range { - u_int32_t length; - u_int32_t offset; -} nubus_smem_range; - -/* - * XXX This is mapped on the range list we get back out of the sMemory - * resources. I would have liked the range[] array to be of undefined - * size but the compiler does not let me. - * Maybe it's just too much grief, and we should work with an array - * of u_int32_t. - */ -typedef struct _nubus_smem_rangelist { - u_int32_t length; - nubus_smem_range range[1]; -} nubus_smem_rangelist; - - -/* Resource IDs for NUBUS_CATEGORY_* (All) */ -#define NUBUS_RSRC_TYPE 0x01 /* Type (required) */ -#define NUBUS_RSRC_NAME 0x02 /* Name (required) */ -#define NUBUS_RSRC_ICON 0x03 /* Icon */ -#define NUBUS_RSRC_DRVRDIR 0x04 /* Driver directory */ -#define NUBUS_RSRC_LOADREC 0x05 /* Load record for resource */ -#define NUBUS_RSRC_BOOTREC 0x06 /* Boot record */ -#define NUBUS_RSRC_FLAGS 0x07 /* sResource Flags */ -#define NUBUS_RSRC_HWDEVID 0x08 /* Hardware device ID */ -#define NUBUS_RSRC_MINOR_BASEOS 0x0A /* Offset to hw in std space */ -#define NUBUS_RSRC_MINOR_LENGTH 0x0B /* Length of std space */ -#define NUBUS_RSRC_MAJOR_BASEOS 0x0C /* Offset to hw in super space */ -#define NUBUS_RSRC_MAJOR_LENGTH 0x0D /* Length of super space */ -#define NUBUS_RSRC_CICN 0x0F /* Color icon */ -#define NUBUS_RSRC_ICL8 0x10 /* 8-bit icon data */ -#define NUBUS_RSRC_ICL4 0x11 /* 4-bit icon data */ -#define NUBUS_RSRC_SMEMORY 0x6C /* Resource list for master */ - -/* Resource IDs for NUBUS_CATEGORY_DISPLAY */ -#define NUBUS_RSRC_GAMMADIR 0x40 /* ID for gamma directory */ -#define NUBUS_RSRC_VIDNAMES 0x41 /* ID for video name directory */ -#define NUBUS_RSRC_FIRSTMODE 0x80 /* ID for first mode (1-bit) */ -#define NUBUS_RSRC_SECONDMODE 0x81 /* ID for 2nd mode (2-bit) */ -#define NUBUS_RSRC_THIRDMODE 0x82 /* ID for 3rd mode (4-bit) */ -#define NUBUS_RSRC_FOURTHMODE 0x83 /* ID for 4th mode (8-bit) */ -#define NUBUS_RSRC_FIFTHMODE 0x84 /* ID for 5th mode (16-bit) */ -#define NUBUS_RSRC_SIXTHMODE 0x85 /* ID for 6th mode (32-bit) */ - -/* Resource IDs for NUBUS_CATEGORY_BOARD */ -#define NUBUS_RSRC_BOARDID 0x20 /* Board ID */ -#define NUBUS_RSRC_PRAMINITDATA 0x21 /* Private board data for PRAM */ -#define NUBUS_RSRC_PRIMARYINIT 0x22 /* Primary init record */ -#define NUBUS_RSRC_TIMEOUTCONST 0x23 /* Timeout constant */ -#define NUBUS_RSRC_VENDORINFO 0x24 /* Vendor info list */ -#define NUBUS_RSRC_BOARDFLAGS 0x25 /* Board flags */ -#define NUBUS_RSRC_SECONDINIT 0x26 /* Secondary init record */ - -#define NUBUS_RSRC_VEND_ID 0x01 /* Card vendor's design ID */ -#define NUBUS_RSRC_VEND_SERIAL 0x02 /* Card's serial number */ -#define NUBUS_RSRC_VEND_REV 0x03 /* Card design's revision level */ -#define NUBUS_RSRC_VEND_PART 0x04 /* Card part number */ -#define NUBUS_RSRC_VEND_DATE 0x05 /* Card revision date */ - -/* Resource IDs for NUBUS_RSRC_SMEMORY master sMemory resource list */ -#define NUBUS_RSRC_SMEM_MINOR_RAMADDR 0x80 /* Minor RAM address ranges */ -#define NUBUS_RSRC_SMEM_MAJOR_RAMADDR 0x81 /* Major RAM address ranges */ -#define NUBUS_RSRC_SMEM_MINOR_ROMADDR 0x82 /* Minor ROM address ranges */ -#define NUBUS_RSRC_SMEM_MAJOR_ROMADDR 0x83 /* Major ROM address ranges */ -#define NUBUS_RSRC_SMEM_MINOR_DEVADDR 0x84 /* Minor device address ranges */ -#define NUBUS_RSRC_SMEM_MAJOR_DEVADDR 0x85 /* Major device address ranges */ - - -typedef struct _NUBUS_DRIVER { - u_int8_t drvr_id; - u_int32_t offset; -} NUBUS_DRIVER; - -typedef struct _NUBUS_BLOCK { - u_int32_t size; /* Size of block of data */ - caddr_t data; /* Pointer to data */ -} NUBUS_BLOCK; - -typedef struct _NUBUS_EXEC_BLOCK { - u_int32_t size; /* Size of total block - 4 */ - u_int8_t revision; /* Always 0x2 */ - u_int8_t cpu; /* Which processor? */ - u_int32_t code_offset; /* Offset base to start of code */ - caddr_t code; /* pointer to base of code. */ -} NUBUS_EXEC_BLOCK; - -#define NUBUS_EXEC_CPU_68000 1 -#define NUBUS_EXEC_CPU_68020 2 -#define NUBUS_EXEC_CPU_68030 3 -#define NUBUS_EXEC_CPU_68040 4 - -#define NUBUS_MIN_SLOT 0x9 -#define NUBUS_MAX_SLOT 0xE -#define NUBUS_ROM_TEST_PATTERN 0x5A932BC7 - -#define NUBUS_SLOT2PA(x) (0xf9000000 + \ - ((((x) - NUBUS_MIN_SLOT) & 0xf) << 24)) - -struct nubus_attach_args { - bus_space_tag_t na_tag; - int slot; - int rsrcid; - u_int16_t category; - u_int16_t type; - u_int16_t drsw; - u_int16_t drhw; - nubus_slot *fmt; -}; - -struct nubus_softc { - struct device sc_dev; -}; - - -void nubus_get_main_dir(nubus_slot *, nubus_dir *); -void nubus_get_dir_from_rsrc(nubus_slot *, nubus_dirent *, nubus_dir *); - -int nubus_find_rsrc(bus_space_tag_t, bus_space_handle_t, nubus_slot *, - nubus_dir *, u_int8_t, nubus_dirent *); -int nubus_get_ind_data(bus_space_tag_t, bus_space_handle_t, nubus_slot *, - nubus_dirent *, caddr_t, int); -int nubus_get_c_string(bus_space_tag_t, bus_space_handle_t, nubus_slot *, - nubus_dirent *, caddr_t, int); -int nubus_get_smem_addr_rangelist(bus_space_tag_t, bus_space_handle_t, - nubus_slot *, nubus_dirent *, caddr_t); - -char *nubus_get_vendor(bus_space_tag_t, bus_space_handle_t, nubus_slot *, - int); -char *nubus_get_card_name(bus_space_tag_t, bus_space_handle_t, nubus_slot *); -#ifdef DEBUG -void nubus_scan_slot(bus_space_tag_t, int); -#endif diff --git a/sys/arch/mac68k/dev/obio.c b/sys/arch/mac68k/dev/obio.c deleted file mode 100644 index b297ae62a06..00000000000 --- a/sys/arch/mac68k/dev/obio.c +++ /dev/null @@ -1,111 +0,0 @@ -/* $OpenBSD: obio.c,v 1.7 2008/06/26 05:42:12 ray Exp $ */ -/* $NetBSD: obio.c,v 1.7 1997/02/13 19:01:07 scottr 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. - * - * 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. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/device.h> - -#include <machine/bus.h> - -#include <mac68k/dev/obiovar.h> - -static int obio_match(struct device *, void *, void *); -static void obio_attach(struct device *, struct device *, void *); -static int obio_print(void *, const char *); -static int obio_search(struct device *, void *, void *); - -struct cfattach obio_ca = { - sizeof(struct device), obio_match, obio_attach -}; - -struct cfdriver obio_cd = { - NULL, "obio", DV_DULL -}; - -static int -obio_match(parent, vcf, aux) - struct device *parent; - void *vcf; - void *aux; -{ - static int obio_matched = 0; - - /* Allow only one instance. */ - if (obio_matched) - return (0); - - obio_matched = 1; - return (1); -} - -static void -obio_attach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -{ - printf("\n"); - - /* Search for and attach children. */ - (void)config_search(obio_search, self, aux); -} - -int -obio_print(args, name) - void *args; - const char *name; -{ - struct obio_attach_args *oa = (struct obio_attach_args *)args; - - if (oa->oa_addr != (-1)) - printf(" addr %x", oa->oa_addr); - - return (UNCONF); -} - -int -obio_search(parent, vcf, aux) - struct device *parent; - void *vcf; - void *aux; -{ - struct obio_attach_args oa; - struct cfdata *cf = (struct cfdata *) vcf; - - oa.oa_addr = cf->cf_loc[0]; - oa.oa_tag = MAC68K_BUS_SPACE_MEM; - - if ((*cf->cf_attach->ca_match)(parent, cf, &oa) > 0) - config_attach(parent, cf, &oa, obio_print); - - return (0); -} diff --git a/sys/arch/mac68k/dev/obiovar.h b/sys/arch/mac68k/dev/obiovar.h deleted file mode 100644 index 21bcfb0cc4d..00000000000 --- a/sys/arch/mac68k/dev/obiovar.h +++ /dev/null @@ -1,44 +0,0 @@ -/* $OpenBSD: obiovar.h,v 1.5 2008/06/26 05:42:12 ray Exp $ */ -/* $NetBSD: obiovar.h,v 1.3 1997/02/13 19:01:08 scottr 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. - * - * 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 mac68k - * on-board i/o space. - */ - -/* - * Arguments used to attach a device to the internal i/o space. - */ -struct obio_attach_args { - int oa_addr; /* physical address */ - bus_space_tag_t oa_tag; /* bus space tag */ -}; diff --git a/sys/arch/mac68k/dev/pm_direct.c b/sys/arch/mac68k/dev/pm_direct.c deleted file mode 100644 index fb1cb412d39..00000000000 --- a/sys/arch/mac68k/dev/pm_direct.c +++ /dev/null @@ -1,1128 +0,0 @@ -/* $OpenBSD: pm_direct.c,v 1.13 2007/03/17 20:01:44 miod Exp $ */ -/* $NetBSD: pm_direct.c,v 1.25 2005/10/28 21:54:52 christos Exp $ */ - -/* - * Copyright (C) 1997 Takashi Hamada - * 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 Takashi Hamada - * 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. - */ -/* From: pm_direct.c 1.3 03/18/98 Takashi Hamada */ - -#ifdef DEBUG -#ifndef ADB_DEBUG -#define ADB_DEBUG -#endif -#endif - -/* #define PM_GRAB_SI 1 */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/device.h> - -#include <machine/cpu.h> -#include <machine/viareg.h> - -#include <dev/adb/adb.h> -#include <mac68k/dev/adbvar.h> -#include <mac68k/dev/pm_direct.h> - -/* hardware dependent values */ -u_int32_t HwCfgFlags3; -u_short ADBDelay = 0xcea; - -/* define the types of the Power Manager */ -#define PM_HW_UNKNOWN 0x00 /* don't know */ -#define PM_HW_PB1XX 0x01 /* PowerBook 1XX series */ -#define PM_HW_PB5XX 0x02 /* PowerBook Duo and 5XX series */ - -/* useful macros */ -#define PM_SR() via_reg(VIA1, vSR) -#define PM_VIA_INTR_ENABLE() via_reg(VIA1, vIER) = 0x90 -#define PM_VIA_INTR_DISABLE() via_reg(VIA1, vIER) = 0x10 -#define PM_VIA_CLR_INTR() via_reg(VIA1, vIFR) = 0x90 -#define PM_SET_STATE_ACKON() via_reg(VIA2, vBufB) |= 0x04 -#define PM_SET_STATE_ACKOFF() via_reg(VIA2, vBufB) &= ~0x04 -#define PM_IS_ON (0x02 == (via_reg(VIA2, vBufB) & 0x02)) -#define PM_IS_OFF (0x00 == (via_reg(VIA2, vBufB) & 0x02)) - -/* - * Variables for internal use - */ -int pmHardware = PM_HW_UNKNOWN; -u_short pm_existent_ADB_devices = 0x0; /* each bit expresses the existent ADB device */ -u_int pm_LCD_brightness = 0x0; -u_int pm_LCD_contrast = 0x0; -u_int pm_counter = 0; /* clock count */ - -/* these values shows that number of data returned after 'send' cmd is sent */ -char pm_send_cmd_type[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, - 0xff, 0x00, 0x02, 0x01, 0x01, 0xff, 0xff, 0xff, - 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x04, 0x14, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x01, 0x00, 0x02, 0x02, 0xff, 0x01, 0x03, 0x01, - 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, - 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x01, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x04, 0x04, - 0x04, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x01, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x02, 0x02, 0x02, 0x04, 0xff, 0x00, 0xff, 0xff, - 0x01, 0x01, 0x03, 0x02, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x01, 0x01, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, - 0xff, 0x04, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x03, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff -}; - -/* these values shows that number of data returned after 'receive' cmd is sent */ -char pm_receive_cmd_type[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x15, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x03, 0x03, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x04, 0x03, 0x09, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x02, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0xff, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -}; - - -/* - * Define the private functions - */ - -/* for debugging */ -#ifdef ADB_DEBUG -void pm_printerr(const char *, int, int, char *); -#endif - -int pm_wait_busy(int); -int pm_wait_free(int); - -/* these functions are for the PB1XX series */ -int pm_receive_pm1(u_char *); -int pm_send_pm1(u_char, int); -int pm_pmgrop_pm1(PMData *); -int pm_intr_pm1(void *); - -/* these functions are for the PB Duo series and the PB 5XX series */ -int pm_receive_pm2(u_char *); -int pm_send_pm2(u_char); -int pm_pmgrop_pm2(PMData *); -int pm_intr_pm2(void *); - -/* these functions are called from adb_direct.c */ -void pm_setup_adb(void); -void pm_check_adb_devices(int); -int pm_intr(void *); -int pm_adb_op(u_char *, void *, void *, int); -void pm_hw_setup(struct device *); - -/* these functions also use the variables of adb_direct.c */ -void pm_adb_get_TALK_result(PMData *); -void pm_adb_get_ADB_data(PMData *); -void pm_adb_poll_next_device_pm1(PMData *); - - -/* - * These variables are in adb_direct.c. - */ -extern u_char *adbBuffer; /* pointer to user data area */ -extern void *adbCompRout; /* pointer to the completion routine */ -extern void *adbCompData; /* pointer to the completion routine data */ -extern int adbWaiting; /* waiting for return data from the device */ -extern int adbWaitingCmd; /* ADB command we are waiting for */ -extern int adbStarting; /* doing ADB reinit, so do "polling" differently */ - -#define ADB_MAX_MSG_LENGTH 16 -#define ADB_MAX_HDR_LENGTH 8 -struct adbCommand { - u_char header[ADB_MAX_HDR_LENGTH]; /* not used yet */ - u_char data[ADB_MAX_MSG_LENGTH]; /* packet data only */ - u_char *saveBuf; /* where to save result */ - u_char *compRout; /* completion routine pointer */ - u_char *compData; /* completion routine data pointer */ - u_int cmd; /* the original command for this data */ - u_int unsol; /* 1 if packet was unsolicited */ - u_int ack_only; /* 1 for no special processing */ -}; -extern void adb_pass_up(struct adbCommand *); - -#ifdef ADB_DEBUG -/* - * This function dumps contents of the PMData - */ -void -pm_printerr(const char *ttl, int rval, int num, char *data) -{ - int i; - - printf("pm: %s:%04x %02x ", ttl, rval, num); - for (i = 0; i < num; i++) - printf("%02x ", data[i]); - printf("\n"); -} -#endif - - - -/* - * Check the hardware type of the Power Manager - */ -void -pm_setup_adb(void) -{ - switch (mac68k_machine.machineid) { - case MACH_MACPB140: - case MACH_MACPB145: - case MACH_MACPB160: - case MACH_MACPB165: - case MACH_MACPB165C: - case MACH_MACPB170: - case MACH_MACPB180: - case MACH_MACPB180C: - pmHardware = PM_HW_PB1XX; - break; - case MACH_MACPB150: - case MACH_MACPB210: - case MACH_MACPB230: - case MACH_MACPB250: - case MACH_MACPB270: - case MACH_MACPB280: - case MACH_MACPB280C: - case MACH_MACPB500: - case MACH_MACPB190: - case MACH_MACPB190CS: - pmHardware = PM_HW_PB5XX; - break; - default: - break; - } -} - - -/* - * Check the existent ADB devices - */ -void -pm_check_adb_devices(int id) -{ - u_short ed = 0x1; - - ed <<= id; - pm_existent_ADB_devices |= ed; -} - - -/* - * Wait until PM IC is busy - */ -int -pm_wait_busy(int xdelay) -{ - while (PM_IS_ON) { -#ifdef PM_GRAB_SI - (void)intr_dispatch(0x70); /* grab any serial interrupts */ -#endif - if ((--xdelay) < 0) - return 1; /* timeout */ - } - return 0; -} - - -/* - * Wait until PM IC is free - */ -int -pm_wait_free(int xdelay) -{ - while (PM_IS_OFF) { -#ifdef PM_GRAB_SI - (void)intr_dispatch(0x70); /* grab any serial interrupts */ -#endif - if ((--xdelay) < 0) - return 0; /* timeout */ - } - return 1; -} - - - -/* - * Functions for the PB1XX series - */ - -/* - * Receive data from PM for the PB1XX series - */ -int -pm_receive_pm1(u_char *data) -{ - int rval = 0xffffcd34; - - via_reg(VIA2, vDirA) = 0x00; - - switch (1) { - default: - if (pm_wait_busy(0x40) != 0) - break; /* timeout */ - - PM_SET_STATE_ACKOFF(); - *data = via_reg(VIA2, 0x200); - - rval = 0xffffcd33; - if (pm_wait_free(0x40) == 0) - break; /* timeout */ - - rval = 0x00; - break; - } - - PM_SET_STATE_ACKON(); - via_reg(VIA2, vDirA) = 0x00; - - return rval; -} - - - -/* - * Send data to PM for the PB1XX series - */ -int -pm_send_pm1(u_char data, int timo) -{ - int rval; - - via_reg(VIA2, vDirA) = 0xff; - via_reg(VIA2, 0x200) = data; - - PM_SET_STATE_ACKOFF(); -#if 0 - if (pm_wait_busy(0x400) == 0) { -#else - if (pm_wait_busy(timo) == 0) { -#endif - PM_SET_STATE_ACKON(); - if (pm_wait_free(0x40) != 0) - rval = 0x0; - else - rval = 0xffffcd35; - } else { - rval = 0xffffcd36; - } - - PM_SET_STATE_ACKON(); - via_reg(VIA2, vDirA) = 0x00; - - return rval; -} - - -/* - * My PMgrOp routine for the PB1XX series - */ -int -pm_pmgrop_pm1(PMData *pmdata) -{ - int i; - int s = 0x81815963; - u_char via1_vIER, via1_vDirA; - int rval = 0; - int num_pm_data = 0; - u_char pm_cmd; - u_char pm_data; - u_char *pm_buf; - - /* disable all inetrrupts but PM */ - via1_vIER = via_reg(VIA1, vIER); - PM_VIA_INTR_DISABLE(); - - via1_vDirA = via_reg(VIA1, vDirA); - - switch (pmdata->command) { - default: - for (i = 0; i < 7; i++) { - via_reg(VIA2, vDirA) = 0x00; - - /* wait until PM is free */ - if (pm_wait_free(ADBDelay) == 0) { /* timeout */ - via_reg(VIA2, vDirA) = 0x00; - /* restore former value */ - via_reg(VIA1, vDirA) = via1_vDirA; - via_reg(VIA1, vIER) = via1_vIER; - return 0xffffcd38; - } - - switch (mac68k_machine.machineid) { - /* XXX what about 140 and 145? -- miod */ - case MACH_MACPB160: - case MACH_MACPB165: - case MACH_MACPB165C: - case MACH_MACPB170: - case MACH_MACPB180: - case MACH_MACPB180C: - { - int xdelay = ADBDelay * 16; - - via_reg(VIA2, vDirA) = 0x00; - while ((via_reg(VIA2, 0x200) == 0x7f) && (xdelay >= 0)) - xdelay--; - - if (xdelay < 0) { /* timeout */ - via_reg(VIA2, vDirA) = 0x00; - /* restore former value */ - via_reg(VIA1, vIER) = via1_vIER; - return 0xffffcd38; - } - } - break; - } /* end switch */ - - s = splhigh(); - - via1_vDirA = via_reg(VIA1, vDirA); - via_reg(VIA1, vDirA) &= 0x7f; - - pm_cmd = (u_char)(pmdata->command & 0xff); - if ((rval = pm_send_pm1(pm_cmd, ADBDelay * 8)) == 0) - break; /* send command succeeded */ - - via_reg(VIA1, vDirA) = via1_vDirA; - splx(s); - } /* end for */ - - /* failed to send a command */ - if (i == 7) { - via_reg(VIA2, vDirA) = 0x00; - /* restore former value */ - via_reg(VIA1, vDirA) = via1_vDirA; - via_reg(VIA1, vIER) = via1_vIER; - if (s != 0x81815963) - splx(s); - return 0xffffcd38; - } - - /* send # of PM data */ - num_pm_data = pmdata->num_data; - if ((rval = pm_send_pm1((u_char)(num_pm_data & 0xff), ADBDelay * 8)) != 0) - break; /* timeout */ - - /* send PM data */ - pm_buf = (u_char *)pmdata->s_buf; - for (i = 0; i < num_pm_data; i++) - if ((rval = pm_send_pm1(pm_buf[i], ADBDelay * 8)) != 0) - break; /* timeout */ - if ((i != num_pm_data) && (num_pm_data != 0)) - break; /* timeout */ - - /* Will PM IC return data? */ - if ((pm_cmd & 0x08) == 0) { - rval = 0; - break; /* no returned data */ - } - - rval = 0xffffcd37; - if (pm_wait_busy(ADBDelay) != 0) - break; /* timeout */ - - /* receive PM command */ - if ((rval = pm_receive_pm1(&pm_data)) != 0) - break; - - pmdata->command = pm_data; - - /* receive number of PM data */ - if ((rval = pm_receive_pm1(&pm_data)) != 0) - break; /* timeout */ - num_pm_data = pm_data; - pmdata->num_data = num_pm_data; - - /* receive PM data */ - pm_buf = (u_char *)pmdata->r_buf; - for (i = 0; i < num_pm_data; i++) { - if ((rval = pm_receive_pm1(&pm_data)) != 0) - break; /* timeout */ - pm_buf[i] = pm_data; - } - - rval = 0; - } - - via_reg(VIA2, vDirA) = 0x00; - - /* restore former value */ - via_reg(VIA1, vDirA) = via1_vDirA; - via_reg(VIA1, vIER) = via1_vIER; - if (s != 0x81815963) - splx(s); - - return rval; -} - - -/* - * My PM interrupt routine for PB1XX series - */ -int -pm_intr_pm1(void *arg) -{ - int s; - int rval; - PMData pmdata; - - s = splhigh(); - - PM_VIA_CLR_INTR(); /* clear VIA1 interrupt */ - - /* ask PM what happend */ - pmdata.command = 0x78; - pmdata.num_data = 0; - pmdata.data[0] = pmdata.data[1] = 0; - pmdata.s_buf = &pmdata.data[2]; - pmdata.r_buf = &pmdata.data[2]; - rval = pm_pmgrop_pm1(&pmdata); - if (rval != 0) { -#ifdef ADB_DEBUG - if (adb_debug) - printf("pm: PM is not ready. error code=%08x\n", rval); -#endif - splx(s); - } - - if ((pmdata.data[2] & 0x10) == 0x10) { - if ((pmdata.data[2] & 0x0f) == 0) { - /* ADB data that were requested by TALK command */ - pm_adb_get_TALK_result(&pmdata); - } else if ((pmdata.data[2] & 0x08) == 0x8) { - /* PM is requesting to poll */ - pm_adb_poll_next_device_pm1(&pmdata); - } else if ((pmdata.data[2] & 0x04) == 0x4) { - /* ADB device event */ - pm_adb_get_ADB_data(&pmdata); - } - } else { -#ifdef ADB_DEBUG - if (adb_debug) - pm_printerr("driver does not supported this event.", - rval, pmdata.num_data, pmdata.data); -#endif - } - - splx(s); - - return (1); -} - - - -/* - * Functions for the PB Duo series and the PB 5XX series - */ - -/* - * Receive data from PM for the PB Duo series and the PB 5XX series - */ -int -pm_receive_pm2(u_char *data) -{ - int i; - int rval; - - rval = 0xffffcd34; - - switch (1) { - default: - /* set VIA SR to input mode */ - via_reg(VIA1, vACR) |= 0x0c; - via_reg(VIA1, vACR) &= ~0x10; - i = PM_SR(); - - PM_SET_STATE_ACKOFF(); - if (pm_wait_busy((int)ADBDelay*32) != 0) - break; /* timeout */ - - PM_SET_STATE_ACKON(); - rval = 0xffffcd33; - if (pm_wait_free((int)ADBDelay*32) == 0) - break; /* timeout */ - - *data = PM_SR(); - rval = 0; - - break; - } - - PM_SET_STATE_ACKON(); - via_reg(VIA1, vACR) |= 0x1c; - - return rval; -} - - - -/* - * Send data to PM for the PB Duo series and the PB 5XX series - */ -int -pm_send_pm2(u_char data) -{ - int rval; - - via_reg(VIA1, vACR) |= 0x1c; - PM_SR() = data; - - PM_SET_STATE_ACKOFF(); - if (pm_wait_busy((int)ADBDelay*32) == 0) { - PM_SET_STATE_ACKON(); - if (pm_wait_free((int)ADBDelay*32) != 0) - rval = 0; - else - rval = 0xffffcd35; - } else { - rval = 0xffffcd36; - } - - PM_SET_STATE_ACKON(); - via_reg(VIA1, vACR) |= 0x1c; - - return rval; -} - - - -/* - * My PMgrOp routine for the PB Duo series and the PB 5XX series - */ -int -pm_pmgrop_pm2(PMData *pmdata) -{ - int i; - int s; - u_char via1_vIER; - int rval = 0; - int num_pm_data = 0; - u_char pm_cmd; - short pm_num_rx_data; - u_char pm_data; - u_char *pm_buf; - - s = splhigh(); - - /* disable all inetrrupts but PM */ - via1_vIER = 0x10; - via1_vIER &= via_reg(VIA1, vIER); - via_reg(VIA1, vIER) = via1_vIER; - if (via1_vIER != 0x0) - via1_vIER |= 0x80; - - switch (pmdata->command) { - default: - /* wait until PM is free */ - pm_cmd = (u_char)(pmdata->command & 0xff); - rval = 0xcd38; - if (pm_wait_free(ADBDelay * 4) == 0) - break; /* timeout */ - - if (HwCfgFlags3 & 0x00200000) { - /* PB 160, PB 165(c), PB 180(c)? */ - int xdelay = ADBDelay * 16; - - via_reg(VIA2, vDirA) = 0x00; - while ((via_reg(VIA2, 0x200) == 0x07) && - (xdelay >= 0)) - xdelay--; - - if (xdelay < 0) { - rval = 0xffffcd38; - break; /* timeout */ - } - } - - /* send PM command */ - if ((rval = pm_send_pm2((u_char)(pm_cmd & 0xff)))) - break; /* timeout */ - - /* send number of PM data */ - num_pm_data = pmdata->num_data; - if (HwCfgFlags3 & 0x00020000) { /* PB Duo, PB 5XX */ - if (pm_send_cmd_type[pm_cmd] < 0) { - if ((rval = pm_send_pm2((u_char)(num_pm_data & 0xff))) != 0) - break; /* timeout */ - pmdata->command = 0; - } - } else { /* PB 1XX series ? */ - if ((rval = pm_send_pm2((u_char)(num_pm_data & 0xff))) != 0) - break; /* timeout */ - } - /* send PM data */ - pm_buf = (u_char *)pmdata->s_buf; - for (i = 0 ; i < num_pm_data; i++) - if ((rval = pm_send_pm2(pm_buf[i])) != 0) - break; /* timeout */ - if (i != num_pm_data) - break; /* timeout */ - - - /* check if PM will send me data */ - pm_num_rx_data = pm_receive_cmd_type[pm_cmd]; - pmdata->num_data = pm_num_rx_data; - if (pm_num_rx_data == 0) { - rval = 0; - break; /* no return data */ - } - - /* receive PM command */ - pm_data = pmdata->command; - if (HwCfgFlags3 & 0x00020000) { /* PB Duo, PB 5XX */ - pm_num_rx_data--; - if (pm_num_rx_data == 0) - if ((rval = pm_receive_pm2(&pm_data)) != 0) { - rval = 0xffffcd37; - break; - } - pmdata->command = pm_data; - } else { /* PB 1XX series ? */ - if ((rval = pm_receive_pm2(&pm_data)) != 0) { - rval = 0xffffcd37; - break; - } - pmdata->command = pm_data; - } - - /* receive number of PM data */ - if (HwCfgFlags3 & 0x00020000) { /* PB Duo, PB 5XX */ - if (pm_num_rx_data < 0) { - if ((rval = pm_receive_pm2(&pm_data)) != 0) - break; /* timeout */ - num_pm_data = pm_data; - } else - num_pm_data = pm_num_rx_data; - pmdata->num_data = num_pm_data; - } else { /* PB 1XX serias ? */ - if ((rval = pm_receive_pm2(&pm_data)) != 0) - break; /* timeout */ - num_pm_data = pm_data; - pmdata->num_data = num_pm_data; - } - - /* receive PM data */ - pm_buf = (u_char *)pmdata->r_buf; - for (i = 0; i < num_pm_data; i++) { - if ((rval = pm_receive_pm2(&pm_data)) != 0) - break; /* timeout */ - pm_buf[i] = pm_data; - } - - rval = 0; - } - - /* restore former value */ - via_reg(VIA1, vIER) = via1_vIER; - splx(s); - - return rval; -} - - -/* - * My PM interrupt routine for the PB Duo series and the PB 5XX series - */ -int -pm_intr_pm2(void *arg) -{ - int s; - int rval; - PMData pmdata; - - s = splhigh(); - - PM_VIA_CLR_INTR(); /* clear VIA1 interrupt */ - /* ask PM what happend */ - pmdata.command = 0x78; - pmdata.num_data = 0; - pmdata.s_buf = &pmdata.data[2]; - pmdata.r_buf = &pmdata.data[2]; - rval = pm_pmgrop_pm2(&pmdata); - if (rval != 0) { -#ifdef ADB_DEBUG - if (adb_debug) - printf("pm: PM is not ready. error code: %08x\n", rval); -#endif - splx(s); - } - - switch ((u_int)(pmdata.data[2] & 0xff)) { - case 0x00: /* 1 sec interrupt? */ - break; - case 0x80: /* 1 sec interrupt? */ - pm_counter++; - break; - case 0x08: /* Brightness/Contrast button on LCD panel */ - /* get brightness and contrast of the LCD */ - pm_LCD_brightness = (u_int)pmdata.data[3] & 0xff; - pm_LCD_contrast = (u_int)pmdata.data[4] & 0xff; -/* - pm_printerr("#08", rval, pmdata.num_data, pmdata.data); - pmdata.command = 0x33; - pmdata.num_data = 1; - pmdata.s_buf = pmdata.data; - pmdata.r_buf = pmdata.data; - pmdata.data[0] = pm_LCD_contrast; - rval = pm_pmgrop_pm2(&pmdata); - pm_printerr("#33", rval, pmdata.num_data, pmdata.data); -*/ - /* this is an experimental code */ - pmdata.command = 0x41; - pmdata.num_data = 1; - pmdata.s_buf = pmdata.data; - pmdata.r_buf = pmdata.data; - pm_LCD_brightness = 0x7f - pm_LCD_brightness / 2; - if (pm_LCD_brightness < 0x25) - pm_LCD_brightness = 0x25; - if (pm_LCD_brightness > 0x5a) - pm_LCD_brightness = 0x7f; - pmdata.data[0] = pm_LCD_brightness; - rval = pm_pmgrop_pm2(&pmdata); - break; - case 0x10: /* ADB data that were requested by TALK command */ - case 0x14: - pm_adb_get_TALK_result(&pmdata); - break; - case 0x16: /* ADB device event */ - case 0x18: - case 0x1e: - pm_adb_get_ADB_data(&pmdata); - break; - default: -#ifdef ADB_DEBUG - if (adb_debug) - pm_printerr("driver does not supported this event.", - pmdata.data[2], pmdata.num_data, - pmdata.data); -#endif - break; - } - - splx(s); - - return (1); -} - - -/* - * My PMgrOp routine - */ -int -pmgrop(PMData *pmdata) -{ - switch (pmHardware) { - case PM_HW_PB1XX: - return (pm_pmgrop_pm1(pmdata)); - break; - case PM_HW_PB5XX: - return (pm_pmgrop_pm2(pmdata)); - break; - default: - return 1; - } -} - -int -pm_intr(void *arg) -{ - switch (pmHardware) { - case PM_HW_PB1XX: - return (pm_intr_pm1(arg)); - case PM_HW_PB5XX: - return (pm_intr_pm2(arg)); - default: - return (-1); - } -} - -void -pm_hw_setup(struct device *self) -{ - switch (pmHardware) { - case PM_HW_PB1XX: - via1_register_irq(4, pm_intr_pm1, self, self->dv_xname); - PM_VIA_CLR_INTR(); - break; - case PM_HW_PB5XX: - via1_register_irq(4, pm_intr_pm2, self, self->dv_xname); - PM_VIA_CLR_INTR(); - break; - default: - break; - } -} - - -/* - * Synchronous ADBOp routine for the Power Manager - */ -int -pm_adb_op(u_char *buffer, void *compRout, void *data, int command) -{ - int i; - int s; - int rval; - int xdelay; - PMData pmdata; - struct adbCommand packet; - - if (adbWaiting == 1) - return 1; - - s = splhigh(); - via_reg(VIA1, vIER) = 0x10; - - adbBuffer = buffer; - adbCompRout = compRout; - adbCompData = data; - - pmdata.command = 0x20; - pmdata.s_buf = pmdata.data; - pmdata.r_buf = pmdata.data; - - if ((command & 0xc) == 0x8) { /* if the command is LISTEN, add number of ADB data to number of PM data */ - if (buffer != (u_char *)0) - pmdata.num_data = buffer[0] + 3; - } else { - pmdata.num_data = 3; - } - - pmdata.data[0] = (u_char)(command & 0xff); - pmdata.data[1] = 0; - if ((command & 0xc) == 0x8) { /* if the command is LISTEN, copy ADB data to PM buffer */ - if ((buffer != (u_char *)0) && (buffer[0] <= 24)) { - pmdata.data[2] = buffer[0]; /* number of data */ - for (i = 0; i < buffer[0]; i++) - pmdata.data[3 + i] = buffer[1 + i]; - } else - pmdata.data[2] = 0; - } else - pmdata.data[2] = 0; - - if ((command & 0xc) != 0xc) { /* if the command is not TALK */ - /* set up stuff fNULLor adb_pass_up */ - packet.data[0] = 1 + pmdata.data[2]; - packet.data[1] = command; - for (i = 0; i < pmdata.data[2]; i++) - packet.data[i+2] = pmdata.data[i+3]; - packet.saveBuf = adbBuffer; - packet.compRout = adbCompRout; - packet.compData = adbCompData; - packet.cmd = command; - packet.unsol = 0; - packet.ack_only = 1; - adb_polling = 1; - adb_pass_up(&packet); - adb_polling = 0; - } - - rval = pmgrop(&pmdata); - if (rval != 0) { - splx(s); - return 1; - } - - adbWaiting = 1; - adbWaitingCmd = command; - - PM_VIA_INTR_ENABLE(); - - /* wait until the PM interrupt has occurred */ - xdelay = 0x80000; - while (adbWaiting == 1) { - switch (mac68k_machine.machineid) { - case MACH_MACPB150: - case MACH_MACPB210: - case MACH_MACPB230: /* daishi tested with Duo230 */ - case MACH_MACPB250: - case MACH_MACPB270: - case MACH_MACPB280: - case MACH_MACPB280C: - case MACH_MACPB190: - case MACH_MACPB190CS: - pm_intr((void *)0); - break; - default: - if ((via_reg(VIA1, vIFR) & 0x10) == 0x10) - pm_intr((void *)0); - break; - } -#ifdef PM_GRAB_SI - (void)intr_dispatch(0x70); /* grab any serial interrupts */ -#endif - if ((--xdelay) < 0) { - splx(s); - return 1; - } - } - - /* this command enables the interrupt by operating ADB devices */ - if (HwCfgFlags3 & 0x00020000) { /* PB Duo series, PB 5XX series */ - pmdata.command = 0x20; - pmdata.num_data = 4; - pmdata.s_buf = pmdata.data; - pmdata.r_buf = pmdata.data; - pmdata.data[0] = 0x00; - pmdata.data[1] = 0x86; /* magic spell for awaking the PM */ - pmdata.data[2] = 0x00; - pmdata.data[3] = 0x0c; /* each bit may express the existent ADB device */ - } else { /* PB 1XX series */ - pmdata.command = 0x20; - pmdata.num_data = 3; - pmdata.s_buf = pmdata.data; - pmdata.r_buf = pmdata.data; - pmdata.data[0] = (u_char)(command & 0xf0) | 0xc; - pmdata.data[1] = 0x04; - pmdata.data[2] = 0x00; - } - rval = pmgrop(&pmdata); - - splx(s); - return rval; -} - - -void -pm_adb_get_TALK_result(PMData *pmdata) -{ - int i; - struct adbCommand packet; - - /* set up data for adb_pass_up */ - packet.data[0] = pmdata->num_data-1; - packet.data[1] = pmdata->data[3]; - for (i = 0; i <packet.data[0]-1; i++) - packet.data[i+2] = pmdata->data[i+4]; - - packet.saveBuf = adbBuffer; - packet.compRout = adbCompRout; - packet.compData = adbCompData; - packet.unsol = 0; - packet.ack_only = 0; - adb_polling = 1; - adb_pass_up(&packet); - adb_polling = 0; - - adbWaiting = 0; - adbBuffer = (long)0; - adbCompRout = (long)0; - adbCompData = (long)0; -} - - -void -pm_adb_get_ADB_data(PMData *pmdata) -{ - int i; - struct adbCommand packet; - - /* set up data for adb_pass_up */ - packet.data[0] = pmdata->num_data-1; /* number of raw data */ - packet.data[1] = pmdata->data[3]; /* ADB command */ - for (i = 0; i <packet.data[0]-1; i++) - packet.data[i+2] = pmdata->data[i+4]; - packet.unsol = 1; - packet.ack_only = 0; - adb_pass_up(&packet); -} - - -void -pm_adb_poll_next_device_pm1(PMData *pmdata) -{ - int i; - int ndid; - u_short bendid = 0x1; - int rval; - PMData tmp_pmdata; - - /* find another existent ADB device to poll */ - for (i = 1; i < 16; i++) { - ndid = (ADB_CMDADDR(pmdata->data[3]) + i) & 0xf; - bendid <<= ndid; - if ((pm_existent_ADB_devices & bendid) != 0) - break; - } - - /* poll the other device */ - tmp_pmdata.command = 0x20; - tmp_pmdata.num_data = 3; - tmp_pmdata.s_buf = tmp_pmdata.data; - tmp_pmdata.r_buf = tmp_pmdata.data; - tmp_pmdata.data[0] = (u_char)(ndid << 4) | 0xc; - tmp_pmdata.data[1] = 0x04; /* magic spell for awaking the PM */ - tmp_pmdata.data[2] = 0x00; - rval = pmgrop(&tmp_pmdata); -} diff --git a/sys/arch/mac68k/dev/pm_direct.h b/sys/arch/mac68k/dev/pm_direct.h deleted file mode 100644 index e19cc085182..00000000000 --- a/sys/arch/mac68k/dev/pm_direct.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: pm_direct.h,v 1.5 2006/01/04 20:39:05 miod Exp $ */ -/* $NetBSD: pm_direct.h,v 1.1 1997/04/08 03:11:38 scottr Exp $ */ - -/* - * Copyright (C) 1997 Takashi Hamada - * 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 Takashi Hamada. - * 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. - */ -/* From: pm_direct.h 1.0 01/02/97 Takashi Hamada */ - -/* - * Public declarations that other routines may need. - */ - -/* data structure of the command of the Power Manager */ -typedef struct { - short command; /* command of the Power Manager */ - short num_data; /* number of data */ - char *s_buf; /* pointer to buffer for sending */ - char *r_buf; /* pointer to buffer for receiving */ - char data[32]; /* data buffer (is it too much?) */ -} PMData; - -int pmgrop(PMData *); diff --git a/sys/arch/mac68k/dev/sbc.c b/sys/arch/mac68k/dev/sbc.c deleted file mode 100644 index f627bd26335..00000000000 --- a/sys/arch/mac68k/dev/sbc.c +++ /dev/null @@ -1,762 +0,0 @@ -/* $OpenBSD: sbc.c,v 1.20 2010/06/28 18:31:01 krw Exp $ */ -/* $NetBSD: sbc.c,v 1.24 1997/04/18 17:38:08 scottr Exp $ */ - -/* - * Copyright (C) 1996 Scott Reynolds. 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 Scott Reynolds for - * the NetBSD Project. - * 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. - */ - -/* - * This file contains only the machine-dependent parts of the mac68k - * NCR 5380 SCSI driver. (Autoconfig stuff and PDMA functions.) - * The machine-independent parts are in ncr5380sbc.c - * - * Supported hardware includes: - * Macintosh II family 5380-based controller - * - * Credits, history: - * - * Scott Reynolds wrote this module, based on work by Allen Briggs - * (mac68k), Gordon W. Ross and David Jones (sun3), and Leo Weppelman - * (atari). Thanks to Allen for supplying crucial interpretation of the - * NetBSD/mac68k 1.1 'ncrscsi' driver. Also, Allen, Gordon, and Jason - * Thorpe all helped to refine this code, and were considerable sources - * of moral support. - */ - -#include <sys/types.h> -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/errno.h> -#include <sys/device.h> -#include <sys/buf.h> -#include <sys/proc.h> - -#include <scsi/scsi_all.h> -#include <scsi/scsi_debug.h> -#include <scsi/scsiconf.h> - -#include <dev/ic/ncr5380reg.h> -#include <dev/ic/ncr5380var.h> - -#include <machine/cpu.h> -#include <machine/viareg.h> - -#include "sbcreg.h" -#include "sbcvar.h" - -int sbc_debug = 0 /* | SBC_DB_INTR | SBC_DB_DMA */; -int sbc_link_flags = 0 /* | SDEV_DB2 */; -int sbc_options = 0 /* | SBC_PDMA */; - -static void sbc_minphys(struct buf *bp, struct scsi_link *sl); - -struct scsi_adapter sbc_ops = { - ncr5380_scsi_cmd, /* scsi_cmd() */ - sbc_minphys, /* scsi_minphys() */ - NULL, /* probe_dev() */ - NULL, /* free_dev() */ -}; - -struct cfdriver sbc_cd = { - NULL, "sbc", DV_DULL -}; - -static int sbc_ready(struct ncr5380_softc *); -static void sbc_wait_not_req(struct ncr5380_softc *); - -static void -sbc_minphys(struct buf *bp, struct scsi_link *sl) -{ - if (bp->b_bcount > MAX_DMA_LEN) - bp->b_bcount = MAX_DMA_LEN; - minphys(bp); -} - - -/*** - * General support for Mac-specific SCSI logic. - ***/ - -int -sbc_irq_intr(p) - void *p; -{ - struct ncr5380_softc *ncr_sc = p; - int claimed = 0; - - /* How we ever arrive here without IRQ set is a mystery... */ - if (*ncr_sc->sci_csr & SCI_CSR_INT) { -#ifdef SBC_DEBUG - if (sbc_debug & SBC_DB_INTR) - decode_5380_intr(ncr_sc); -#endif - claimed = ncr5380_intr(ncr_sc); - if (!claimed) { - if (((*ncr_sc->sci_csr & ~SCI_CSR_PHASE_MATCH) == SCI_CSR_INT) - && ((*ncr_sc->sci_bus_csr & ~SCI_BUS_RST) == 0)) - SCI_CLR_INTR(ncr_sc); /* RST interrupt */ -#ifdef SBC_DEBUG - else { - printf("%s: spurious intr\n", - ncr_sc->sc_dev.dv_xname); - SBC_BREAK; - } -#endif - } - } - - return (claimed); -} - -#ifdef SBC_DEBUG -void -decode_5380_intr(ncr_sc) - struct ncr5380_softc *ncr_sc; -{ - u_char csr = *ncr_sc->sci_csr; - u_char bus_csr = *ncr_sc->sci_bus_csr; - - if (((csr & ~(SCI_CSR_PHASE_MATCH | SCI_CSR_ATN)) == SCI_CSR_INT) && - ((bus_csr & ~(SCI_BUS_MSG | SCI_BUS_CD | SCI_BUS_IO | SCI_BUS_DBP)) == SCI_BUS_SEL)) { - if (csr & SCI_BUS_IO) - printf("%s: reselect\n", ncr_sc->sc_dev.dv_xname); - else - printf("%s: select\n", ncr_sc->sc_dev.dv_xname); - } else if (((csr & ~SCI_CSR_ACK) == (SCI_CSR_DONE | SCI_CSR_INT)) && - ((bus_csr & (SCI_BUS_RST | SCI_BUS_BSY | SCI_BUS_SEL)) == SCI_BUS_BSY)) - printf("%s: dma eop\n", ncr_sc->sc_dev.dv_xname); - else if (((csr & ~SCI_CSR_PHASE_MATCH) == SCI_CSR_INT) && - ((bus_csr & ~SCI_BUS_RST) == 0)) - printf("%s: bus reset\n", ncr_sc->sc_dev.dv_xname); - else if (((csr & ~(SCI_CSR_DREQ | SCI_CSR_ATN | SCI_CSR_ACK)) == (SCI_CSR_PERR | SCI_CSR_INT | SCI_CSR_PHASE_MATCH)) && - ((bus_csr & (SCI_BUS_RST | SCI_BUS_BSY | SCI_BUS_SEL)) == SCI_BUS_BSY)) - printf("%s: parity error\n", ncr_sc->sc_dev.dv_xname); - else if (((csr & ~SCI_CSR_ATN) == SCI_CSR_INT) && - ((bus_csr & (SCI_BUS_RST | SCI_BUS_BSY | SCI_BUS_REQ | SCI_BUS_SEL)) == (SCI_BUS_BSY | SCI_BUS_REQ))) - printf("%s: phase mismatch\n", ncr_sc->sc_dev.dv_xname); - else if (((csr & ~SCI_CSR_PHASE_MATCH) == (SCI_CSR_INT | SCI_CSR_DISC)) && - (bus_csr == 0)) - printf("%s: disconnect\n", ncr_sc->sc_dev.dv_xname); - else - printf("%s: unknown intr: csr=%x, bus_csr=%x\n", - ncr_sc->sc_dev.dv_xname, csr, bus_csr); -} -#endif - - -/*** - * The following code implements polled PDMA. - ***/ - -#define TIMEOUT 5000000 /* x 2 usec = 10 sec */ - -static __inline__ int -sbc_ready(sc) - struct ncr5380_softc *sc; -{ - int i = TIMEOUT; - - for (;;) { - if ((*sc->sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) == - (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) - return 1; - if (((*sc->sci_csr & SCI_CSR_PHASE_MATCH) == 0) || - (SCI_BUSY(sc) == 0)) - return 0; - if (--i < 0) - break; - delay(2); - } - - printf("%s: ready timeout\n", sc->sc_dev.dv_xname); - return 0; -} - -static __inline__ void -sbc_wait_not_req(sc) - struct ncr5380_softc *sc; -{ - int i = TIMEOUT; - - for (;;) { - if ((*sc->sci_bus_csr & SCI_BUS_REQ) == 0 || - (*sc->sci_csr & SCI_CSR_PHASE_MATCH) == 0 || - SCI_BUSY(sc) == 0) { - return; - } - if (--i < 0) - break; - delay(2); - } - printf("%s: pdma not_req timeout\n", sc->sc_dev.dv_xname); -} - -int -sbc_pdma_in(ncr_sc, phase, datalen, data) - struct ncr5380_softc *ncr_sc; - int phase, datalen; - u_char *data; -{ - struct sbc_softc *sc = (struct sbc_softc *)ncr_sc; - volatile u_int32_t *long_data = (u_int32_t *)sc->sc_drq_addr; - volatile u_int8_t *byte_data = (u_int8_t *)sc->sc_nodrq_addr; - int resid, s; - - s = splbio(); - *ncr_sc->sci_mode |= SCI_MODE_DMA; - *ncr_sc->sci_irecv = 0; - -#define R4 *((u_int32_t *)data)++ = *long_data++ -#define R1 *data++ = *byte_data++ - for (resid = datalen; resid >= 128; resid -= 128) { - if (sbc_ready(ncr_sc) == 0) - goto interrupt; - R4; R4; R4; R4; R4; R4; R4; R4; - R4; R4; R4; R4; R4; R4; R4; R4; - R4; R4; R4; R4; R4; R4; R4; R4; - R4; R4; R4; R4; R4; R4; R4; R4; - - long_data = (u_int32_t *)sc->sc_drq_addr; - byte_data = (u_int8_t *)sc->sc_nodrq_addr; - } - while (resid) { - if (sbc_ready(ncr_sc) == 0) - goto interrupt; - R1; - resid--; - } -#undef R4 -#undef R1 - - sbc_wait_not_req(ncr_sc); -interrupt: - SCI_CLR_INTR(ncr_sc); - *ncr_sc->sci_mode &= ~SCI_MODE_DMA; - splx(s); - return datalen - resid; -} - -int -sbc_pdma_out(ncr_sc, phase, datalen, data) - struct ncr5380_softc *ncr_sc; - int phase, datalen; - u_char *data; -{ - struct sbc_softc *sc = (struct sbc_softc *)ncr_sc; - volatile u_int32_t *long_data = (u_int32_t *)sc->sc_drq_addr; - volatile u_int8_t *byte_data = (u_int8_t *)sc->sc_nodrq_addr; - int i, s, resid; - u_char icmd; - - if (datalen < 64) - return ncr5380_pio_out(ncr_sc, phase, datalen, data); - - s = splbio(); - icmd = *(ncr_sc->sci_icmd) & SCI_ICMD_RMASK; - *ncr_sc->sci_icmd = icmd | SCI_ICMD_DATA; - *ncr_sc->sci_mode |= SCI_MODE_DMA; - *ncr_sc->sci_dma_send = 0; - - resid = datalen; - if (sbc_ready(ncr_sc) == 0) - goto interrupt; - -#define W1 *byte_data++ = *data++ -#define W4 *long_data++ = *((u_int32_t *)data)++ - while (resid >= 64) { - if (sbc_ready(ncr_sc) == 0) - goto interrupt; - W1; - resid--; - if (sbc_ready(ncr_sc) == 0) - goto interrupt; - W1; - resid--; - if (sbc_ready(ncr_sc) == 0) - goto interrupt; - W1; - resid--; - if (sbc_ready(ncr_sc) == 0) - goto interrupt; - W1; - resid--; - if (sbc_ready(ncr_sc) == 0) - goto interrupt; - W4; W4; W4; W4; - W4; W4; W4; W4; - W4; W4; W4; W4; - W4; W4; W4; - resid -= 60; - - long_data = (u_int32_t *)sc->sc_drq_addr; - byte_data = (u_int8_t *)sc->sc_nodrq_addr; - } - for (; resid; resid--) { - if (sbc_ready(ncr_sc) == 0) - goto interrupt; - W1; - } -#undef W1 -#undef W4 - - for (i = TIMEOUT; i > 0; i--) { - if ((*ncr_sc->sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) - != SCI_CSR_DREQ) - break; - } - if (i != 0) - *byte_data = 0; - else - printf("%s: timeout waiting for final SCI_DSR_DREQ.\n", - ncr_sc->sc_dev.dv_xname); - - sbc_wait_not_req(ncr_sc); -interrupt: - SCI_CLR_INTR(ncr_sc); - *ncr_sc->sci_mode &= ~SCI_MODE_DMA; - *ncr_sc->sci_icmd = icmd; - splx(s); - return (datalen - resid); -} - - -/*** - * The following code implements interrupt-driven PDMA. - ***/ - -/* - * This is the meat of the PDMA transfer. - * When we get here, we shove data as fast as the mac can take it. - * We depend on several things: - * * All macs after the Mac Plus that have a 5380 chip should have a general - * logic IC that handshakes data for blind transfers. - * * If the SCSI controller finishes sending/receiving data before we do, - * the same general logic IC will generate a /BERR for us in short order. - * * The fault address for said /BERR minus the base address for the - * transfer will be the amount of data that was actually written. - * - * We use the nofault flag and the setjmp/longjmp in locore.s so we can - * detect and handle the bus error for early termination of a command. - * This is usually caused by a disconnecting target. - */ -int -sbc_drq_intr(p) - void *p; -{ - extern int *nofault, m68k_fault_addr; - struct sbc_softc *sc = (struct sbc_softc *)p; - struct ncr5380_softc *ncr_sc = (struct ncr5380_softc *)p; - struct sci_req *sr = ncr_sc->sc_current; - struct sbc_pdma_handle *dh = sr->sr_dma_hand; - label_t faultbuf; - volatile u_int32_t *long_drq; - u_int32_t *long_data; - volatile u_int8_t *drq; - u_int8_t *data; - int count, dcount, resid; -#ifdef SBC_WRITE_HACK - u_int8_t tmp; -#endif - - /* - * If we're not ready to xfer data, or have no more, just return. - */ - if ((*ncr_sc->sci_csr & SCI_CSR_DREQ) == 0 || dh->dh_len == 0) - return (0); - -#ifdef SBC_DEBUG - if (sbc_debug & SBC_DB_INTR) - printf("%s: drq intr, dh_len=0x%x, dh_flags=0x%x\n", - ncr_sc->sc_dev.dv_xname, dh->dh_len, dh->dh_flags); -#endif - - /* - * Setup for a possible bus error caused by SCSI controller - * switching out of DATA-IN/OUT before we're done with the - * current transfer. - */ - nofault = (int *) &faultbuf; - - if (setjmp((label_t *)nofault)) { - nofault = (int *) 0; - if ((dh->dh_flags & SBC_DH_DONE) == 0) { - count = (( (u_long)m68k_fault_addr - - (u_long)sc->sc_drq_addr)); - - if ((count < 0) || (count > dh->dh_len)) { - printf("%s: complete=0x%x (pending 0x%x)\n", - ncr_sc->sc_dev.dv_xname, count, dh->dh_len); - panic("something is wrong"); - } - - dh->dh_addr += count; - dh->dh_len -= count; - } else - count = 0; - -#ifdef SBC_DEBUG - if (sbc_debug & SBC_DB_INTR) - printf("%s: drq /berr, complete=0x%x (pending 0x%x)\n", - ncr_sc->sc_dev.dv_xname, count, dh->dh_len); -#endif - m68k_fault_addr = 0; - - return (1); - } - - if (dh->dh_flags & SBC_DH_OUT) { /* Data Out */ -#if notyet /* XXX */ - /* - * Get the source address aligned. - */ - resid = - count = min(dh->dh_len, 4 - (((int)dh->dh_addr) & 0x3)); - if (count && count < 4) { - drq = (volatile u_int8_t *)sc->sc_drq_addr; - data = (u_int8_t *)dh->dh_addr; - -#define W1 *drq++ = *data++ - while (count) { - W1; count--; - } -#undef W1 - dh->dh_addr += resid; - dh->dh_len -= resid; - } - - /* - * Start the transfer. - */ - while (dh->dh_len) { - dcount = count = min(dh->dh_len, MAX_DMA_LEN); - long_drq = (volatile u_int32_t *)sc->sc_drq_addr; - long_data = (u_int32_t *)dh->dh_addr; - -#define W4 *long_drq++ = *long_data++ - while (count >= 64) { - W4; W4; W4; W4; W4; W4; W4; W4; - W4; W4; W4; W4; W4; W4; W4; W4; /* 64 */ - count -= 64; - } - while (count >= 4) { - W4; count -= 4; - } -#undef W4 - data = (u_int8_t *)long_data; - drq = (u_int8_t *)long_drq; -#else /* notyet */ - /* - * Start the transfer. - */ - while (dh->dh_len) { - dcount = count = min(dh->dh_len, MAX_DMA_LEN); - drq = (volatile u_int8_t *)sc->sc_drq_addr; - data = (u_int8_t *)dh->dh_addr; -#endif /* notyet */ - -#define W1 *drq++ = *data++ - while (count) { - W1; count--; - } -#undef W1 - dh->dh_len -= dcount; - dh->dh_addr += dcount; - } - dh->dh_flags |= SBC_DH_DONE; - -#ifdef SBC_WRITE_HACK - /* - * XXX -- Read a byte from the SBC to trigger a /BERR. - * This seems to be necessary for us to notice that - * the target has disconnected. Ick. 06 jun 1996 (sr) - */ - if (dcount >= MAX_DMA_LEN) { -#if 0 - while ((*ncr_sc->sci_csr & SCI_CSR_ACK) == 0) - ; -#endif - drq = (volatile u_int8_t *)sc->sc_drq_addr; - } - tmp = *drq; -#endif - } else { /* Data In */ - /* - * Get the dest address aligned. - */ - resid = - count = min(dh->dh_len, 4 - (((int)dh->dh_addr) & 0x3)); - if (count && count < 4) { - data = (u_int8_t *)dh->dh_addr; - drq = (volatile u_int8_t *)sc->sc_drq_addr; - -#define R1 *data++ = *drq++ - while (count) { - R1; count--; - } -#undef R1 - dh->dh_addr += resid; - dh->dh_len -= resid; - } - - /* - * Start the transfer. - */ - while (dh->dh_len) { - dcount = count = min(dh->dh_len, MAX_DMA_LEN); - long_data = (u_int32_t *)dh->dh_addr; - long_drq = (volatile u_int32_t *)sc->sc_drq_addr; - -#define R4 *long_data++ = *long_drq++ - while (count >= 64) { - R4; R4; R4; R4; R4; R4; R4; R4; - R4; R4; R4; R4; R4; R4; R4; R4; /* 64 */ - count -= 64; - } - while (count >= 4) { - R4; count -= 4; - } -#undef R4 - data = (u_int8_t *)long_data; - drq = (volatile u_int8_t *)long_drq; - -#define R1 *data++ = *drq++ - while (count) { - R1; count--; - } -#undef R1 - dh->dh_len -= dcount; - dh->dh_addr += dcount; - } - dh->dh_flags |= SBC_DH_DONE; - } - - /* - * OK. No bus error occurred above. Clear the nofault flag - * so we no longer short-circuit bus errors. - */ - nofault = (int *) 0; - -#ifdef SBC_DEBUG - if (sbc_debug & (SBC_DB_REG | SBC_DB_INTR)) - printf("%s: drq intr complete: csr=0x%x, bus_csr=0x%x\n", - ncr_sc->sc_dev.dv_xname, *ncr_sc->sci_csr, - *ncr_sc->sci_bus_csr); -#endif - - return (1); -} - -void -sbc_dma_alloc(ncr_sc) - struct ncr5380_softc *ncr_sc; -{ - struct sbc_softc *sc = (struct sbc_softc *)ncr_sc; - struct sci_req *sr = ncr_sc->sc_current; - struct scsi_xfer *xs = sr->sr_xs; - struct sbc_pdma_handle *dh; - int i, xlen; - -#ifdef DIAGNOSTIC - if (sr->sr_dma_hand != NULL) - panic("sbc_dma_alloc: already have PDMA handle"); -#endif - - /* Polled transfers shouldn't allocate a PDMA handle. */ - if (sr->sr_flags & SR_IMMED) - return; - - xlen = ncr_sc->sc_datalen; - - /* Make sure our caller checked sc_min_dma_len. */ - if (xlen < MIN_DMA_LEN) - panic("sbc_dma_alloc: len=0x%x", xlen); - - /* - * Find free PDMA handle. Guaranteed to find one since we - * have as many PDMA handles as the driver has processes. - * (instances?) - */ - for (i = 0; i < SCI_OPENINGS; i++) { - if ((sc->sc_pdma[i].dh_flags & SBC_DH_BUSY) == 0) - goto found; - } - panic("sbc: no free PDMA handles"); -found: - dh = &sc->sc_pdma[i]; - dh->dh_flags = SBC_DH_BUSY; - dh->dh_addr = ncr_sc->sc_dataptr; - dh->dh_len = xlen; - - /* Copy the 'write' flag for convenience. */ - if (xs->flags & SCSI_DATA_OUT) - dh->dh_flags |= SBC_DH_OUT; - - sr->sr_dma_hand = dh; -} - -void -sbc_dma_free(ncr_sc) - struct ncr5380_softc *ncr_sc; -{ - struct sci_req *sr = ncr_sc->sc_current; - struct sbc_pdma_handle *dh = sr->sr_dma_hand; - -#ifdef DIAGNOSTIC - if (sr->sr_dma_hand == NULL) - panic("sbc_dma_free: no DMA handle"); -#endif - - if (ncr_sc->sc_state & NCR_DOINGDMA) - panic("sbc_dma_free: free while in progress"); - - if (dh->dh_flags & SBC_DH_BUSY) { - dh->dh_flags = 0; - dh->dh_addr = NULL; - dh->dh_len = 0; - } - sr->sr_dma_hand = NULL; -} - -void -sbc_dma_poll(ncr_sc) - struct ncr5380_softc *ncr_sc; -{ - struct sci_req *sr = ncr_sc->sc_current; - - /* - * We shouldn't arrive here; if SR_IMMED is set, then - * dma_alloc() should have refused to allocate a handle - * for the transfer. This forces the polled PDMA code - * to handle the request... - */ -#ifdef SBC_DEBUG - if (sbc_debug & SBC_DB_DMA) - printf("%s: lost DRQ interrupt?\n", ncr_sc->sc_dev.dv_xname); -#endif - sr->sr_flags |= SR_OVERDUE; -} - -void -sbc_dma_setup(ncr_sc) - struct ncr5380_softc *ncr_sc; -{ - /* Not needed; we don't have real DMA */ -} - -void -sbc_dma_start(ncr_sc) - struct ncr5380_softc *ncr_sc; -{ - struct sbc_softc *sc = (struct sbc_softc *)ncr_sc; - struct sci_req *sr = ncr_sc->sc_current; - struct sbc_pdma_handle *dh = sr->sr_dma_hand; - - /* - * Match bus phase, clear pending interrupts, set DMA mode, and - * assert data bus (for writing only), then start the transfer. - */ - if (dh->dh_flags & SBC_DH_OUT) { - *ncr_sc->sci_tcmd = PHASE_DATA_OUT; - SCI_CLR_INTR(ncr_sc); - if (sc->sc_clrintr) - (*sc->sc_clrintr)(ncr_sc); - *ncr_sc->sci_mode |= SCI_MODE_DMA; - *ncr_sc->sci_icmd = SCI_ICMD_DATA; - *ncr_sc->sci_dma_send = 0; - } else { - *ncr_sc->sci_tcmd = PHASE_DATA_IN; - SCI_CLR_INTR(ncr_sc); - if (sc->sc_clrintr) - (*sc->sc_clrintr)(ncr_sc); - *ncr_sc->sci_mode |= SCI_MODE_DMA; - *ncr_sc->sci_icmd = 0; - *ncr_sc->sci_irecv = 0; - } - ncr_sc->sc_state |= NCR_DOINGDMA; - -#ifdef SBC_DEBUG - if (sbc_debug & SBC_DB_DMA) - printf("%s: PDMA started, va=%p, len=0x%x\n", - ncr_sc->sc_dev.dv_xname, dh->dh_addr, dh->dh_len); -#endif -} - -void -sbc_dma_stop(ncr_sc) - struct ncr5380_softc *ncr_sc; -{ - struct sbc_softc *sc = (struct sbc_softc *)ncr_sc; - struct sci_req *sr = ncr_sc->sc_current; - struct sbc_pdma_handle *dh = sr->sr_dma_hand; - int ntrans; - - if ((ncr_sc->sc_state & NCR_DOINGDMA) == 0) { -#ifdef SBC_DEBUG - if (sbc_debug & SBC_DB_DMA) - printf("%s: dma_stop: DMA not running\n", - ncr_sc->sc_dev.dv_xname); -#endif - return; - } - ncr_sc->sc_state &= ~NCR_DOINGDMA; - - if ((ncr_sc->sc_state & NCR_ABORTING) == 0) { - ntrans = ncr_sc->sc_datalen - dh->dh_len; - -#ifdef SBC_DEBUG - if (sbc_debug & SBC_DB_DMA) - printf("%s: dma_stop: ntrans=0x%x\n", - ncr_sc->sc_dev.dv_xname, ntrans); -#endif - - if (ntrans > ncr_sc->sc_datalen) - panic("sbc_dma_stop: excess transfer"); - - /* Adjust data pointer */ - ncr_sc->sc_dataptr += ntrans; - ncr_sc->sc_datalen -= ntrans; - - /* Clear any pending interrupts. */ - SCI_CLR_INTR(ncr_sc); - if (sc->sc_clrintr) - (*sc->sc_clrintr)(ncr_sc); - } - - /* Put SBIC back into PIO mode. */ - *ncr_sc->sci_mode &= ~SCI_MODE_DMA; - *ncr_sc->sci_icmd = 0; - -#ifdef SBC_DEBUG - if (sbc_debug & SBC_DB_REG) - printf("%s: dma_stop: csr=0x%x, bus_csr=0x%x\n", - ncr_sc->sc_dev.dv_xname, *ncr_sc->sci_csr, - *ncr_sc->sci_bus_csr); -#endif -} diff --git a/sys/arch/mac68k/dev/sbc_obio.c b/sys/arch/mac68k/dev/sbc_obio.c deleted file mode 100644 index 2917acde15e..00000000000 --- a/sys/arch/mac68k/dev/sbc_obio.c +++ /dev/null @@ -1,305 +0,0 @@ -/* $OpenBSD: sbc_obio.c,v 1.17 2010/06/28 18:31:01 krw Exp $ */ -/* $NetBSD: sbc_obio.c,v 1.1 1997/03/01 20:18:59 scottr Exp $ */ - -/* - * Copyright (C) 1996,1997 Scott Reynolds. 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 Scott Reynolds for - * the NetBSD Project. - * 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. - */ - -#include <sys/types.h> -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/errno.h> -#include <sys/device.h> -#include <sys/buf.h> -#include <sys/proc.h> - -#include <scsi/scsi_all.h> -#include <scsi/scsi_debug.h> -#include <scsi/scsiconf.h> - -#include <dev/ic/ncr5380reg.h> -#include <dev/ic/ncr5380var.h> - -#include <machine/cpu.h> -#include <machine/viareg.h> - -#include "sbcreg.h" -#include "sbcvar.h" - -/* - * From Guide to the Macintosh Family Hardware, pp. 137-143 - * These are offsets from SCSIBase (see pmap_bootstrap.c) - */ -#define SBC_REG_OFS 0x10000 -#define SBC_DMA_OFS 0x12000 -#define SBC_HSK_OFS 0x06000 - -#define SBC_DMA_OFS_PB500 0x06000 - -#define SBC_REG_OFS_IIFX 0x08000 /* Just guessing... */ -#define SBC_DMA_OFS_IIFX 0x0c000 -#define SBC_HSK_OFS_IIFX 0x0e000 - -#define SBC_REG_OFS_DUO2 0x00000 -#define SBC_DMA_OFS_DUO2 0x02000 -#define SBC_HSK_OFS_DUO2 0x04000 - -static int sbc_obio_match(struct device *, void *, void *); -static void sbc_obio_attach(struct device *, struct device *, void *); - -void sbc_intr_enable(struct ncr5380_softc *); -void sbc_intr_disable(struct ncr5380_softc *); -void sbc_obio_clrintr(struct ncr5380_softc *); - -struct cfattach sbc_obio_ca = { - sizeof(struct sbc_softc), sbc_obio_match, sbc_obio_attach -}; - -static int -sbc_obio_match(parent, vcf, args) - struct device *parent; - void *vcf; - void *args; -{ - struct cfdata *cf = (struct cfdata *) vcf; - - switch (current_mac_model->machineid) { - case MACH_MACIIFX: /* Note: the IIfx isn't (yet) supported. */ - break; - case MACH_MACPB210: - case MACH_MACPB230: - case MACH_MACPB250: - case MACH_MACPB270: - case MACH_MACPB280: - case MACH_MACPB280C: - if (cf->cf_unit == 1) - return 1; - /*FALLTHROUGH*/ - default: - if (cf->cf_unit == 0 && mac68k_machine.scsi80) - return 1; - } - return 0; -} - -static void -sbc_obio_attach(parent, self, args) - struct device *parent, *self; - void *args; -{ - struct sbc_softc *sc = (struct sbc_softc *) self; - struct ncr5380_softc *ncr_sc = (struct ncr5380_softc *) sc; - struct scsibus_attach_args saa; - extern vaddr_t SCSIBase; - - /* Pull in the options flags. */ - sc->sc_options = ((ncr_sc->sc_dev.dv_cfdata->cf_flags | sbc_options) - & SBC_OPTIONS_MASK); - - /* - * Set up offsets to 5380 registers and GLUE I/O space, and turn - * off options we know we can't support on certain models. - */ - switch (current_mac_model->machineid) { - case MACH_MACIIFX: /* Note: the IIfx isn't (yet) supported. */ - sc->sc_regs = (struct sbc_regs *)(SCSIBase + SBC_REG_OFS_IIFX); - sc->sc_drq_addr = (vaddr_t)(SCSIBase + SBC_HSK_OFS_IIFX); - sc->sc_nodrq_addr = (vaddr_t)(SCSIBase + SBC_DMA_OFS_IIFX); - sc->sc_options &= ~(SBC_INTR | SBC_RESELECT); - break; - case MACH_MACPB500: - sc->sc_regs = (struct sbc_regs *)(SCSIBase + SBC_REG_OFS); - sc->sc_drq_addr = (vaddr_t)(SCSIBase + SBC_HSK_OFS); /*??*/ - sc->sc_nodrq_addr = (vaddr_t)(SCSIBase + SBC_DMA_OFS_PB500); - sc->sc_options &= ~(SBC_INTR | SBC_RESELECT); - break; - case MACH_MACPB210: - case MACH_MACPB230: - case MACH_MACPB250: - case MACH_MACPB270: - case MACH_MACPB280: - case MACH_MACPB280C: - if (ncr_sc->sc_dev.dv_unit == 1) { - sc->sc_regs = (struct sbc_regs *)(0xfee00000 + SBC_REG_OFS_DUO2); - sc->sc_drq_addr = (vaddr_t)(0xfee00000 + SBC_HSK_OFS_DUO2); - sc->sc_nodrq_addr = (vaddr_t)(0xfee00000 + SBC_DMA_OFS_DUO2); - break; - } - /*FALLTHROUGH*/ - default: - sc->sc_regs = (struct sbc_regs *)(SCSIBase + SBC_REG_OFS); - sc->sc_drq_addr = (vaddr_t)(SCSIBase + SBC_HSK_OFS); - sc->sc_nodrq_addr = (vaddr_t)(SCSIBase + SBC_DMA_OFS); - break; - } - - /* - * Fill in the prototype scsi_link. - */ - ncr_sc->sc_link.adapter_softc = sc; - ncr_sc->sc_link.adapter_target = 7; - ncr_sc->sc_link.adapter = &sbc_ops; - ncr_sc->sc_link.openings = 4; - - /* - * Initialize fields used by the MI code - */ - ncr_sc->sci_r0 = &sc->sc_regs->sci_pr0.sci_reg; - ncr_sc->sci_r1 = &sc->sc_regs->sci_pr1.sci_reg; - ncr_sc->sci_r2 = &sc->sc_regs->sci_pr2.sci_reg; - ncr_sc->sci_r3 = &sc->sc_regs->sci_pr3.sci_reg; - ncr_sc->sci_r4 = &sc->sc_regs->sci_pr4.sci_reg; - ncr_sc->sci_r5 = &sc->sc_regs->sci_pr5.sci_reg; - ncr_sc->sci_r6 = &sc->sc_regs->sci_pr6.sci_reg; - ncr_sc->sci_r7 = &sc->sc_regs->sci_pr7.sci_reg; - - /* - * MD function pointers used by the MI code. - */ - if (sc->sc_options & SBC_PDMA) { - ncr_sc->sc_pio_out = sbc_pdma_out; - ncr_sc->sc_pio_in = sbc_pdma_in; - } else { - ncr_sc->sc_pio_out = ncr5380_pio_out; - ncr_sc->sc_pio_in = ncr5380_pio_in; - } - ncr_sc->sc_dma_alloc = NULL; - ncr_sc->sc_dma_free = NULL; - ncr_sc->sc_dma_poll = NULL; - ncr_sc->sc_intr_on = NULL; - ncr_sc->sc_intr_off = NULL; - ncr_sc->sc_dma_setup = NULL; - ncr_sc->sc_dma_start = NULL; - ncr_sc->sc_dma_stop = NULL; - ncr_sc->sc_flags = 0; - ncr_sc->sc_min_dma_len = MIN_DMA_LEN; - - if (sc->sc_options & SBC_INTR) { - ncr_sc->sc_dma_alloc = sbc_dma_alloc; - ncr_sc->sc_dma_free = sbc_dma_free; - ncr_sc->sc_dma_poll = sbc_dma_poll; - ncr_sc->sc_dma_setup = sbc_dma_setup; - ncr_sc->sc_dma_start = sbc_dma_start; - ncr_sc->sc_dma_stop = sbc_dma_stop; - - sc->sc_ih_drq.vh_fn = sbc_drq_intr; - sc->sc_ih_drq.vh_arg = ncr_sc; - sc->sc_ih_drq.vh_ipl = VIA2_SCSIDRQ; - via2_register_irq(&sc->sc_ih_drq, ncr_sc->sc_dev.dv_xname); - } - - sc->sc_ih_irq.vh_fn = sbc_irq_intr; - sc->sc_ih_irq.vh_arg = ncr_sc; - sc->sc_ih_irq.vh_ipl = VIA2_SCSIIRQ; - via2_register_irq(&sc->sc_ih_irq, ncr_sc->sc_dev.dv_xname); - sc->sc_clrintr = sbc_obio_clrintr; - - if (sc->sc_options) - printf(": options=0x%x", sc->sc_options); - printf("\n"); - - /* Enable SCSI interrupts through VIA2 */ - sbc_intr_enable(ncr_sc); - -#ifdef SBC_DEBUG - if (sbc_debug) - printf("%s: softc=%p regs=%p\n", ncr_sc->sc_dev.dv_xname, - sc, sc->sc_regs); - ncr_sc->sc_link.flags |= sbc_link_flags; -#endif - - bzero(&saa, sizeof(saa)); - saa.saa_sc_link = &(ncr_sc->sc_link); - - /* - * Initialize the SCSI controller itself. - */ - ncr5380_init(ncr_sc); - ncr5380_reset_scsibus(ncr_sc); - config_found(self, &saa, scsiprint); -} - -/* - * Interrupt support routines. - */ -void -sbc_intr_enable(ncr_sc) - struct ncr5380_softc *ncr_sc; -{ - struct sbc_softc *sc = (struct sbc_softc *)ncr_sc; - int s, flags; - - flags = V2IF_SCSIIRQ; - if (sc->sc_options & SBC_INTR) - flags |= V2IF_SCSIDRQ; - - s = splhigh(); - if (VIA2 == VIA2OFF) - via2_reg(vIER) = 0x80 | flags; - else - via2_reg(rIER) = 0x80 | flags; - splx(s); -} - -void -sbc_intr_disable(ncr_sc) - struct ncr5380_softc *ncr_sc; -{ - struct sbc_softc *sc = (struct sbc_softc *)ncr_sc; - int s, flags; - - flags = V2IF_SCSIIRQ; - if (sc->sc_options & SBC_INTR) - flags |= V2IF_SCSIDRQ; - - s = splhigh(); - if (VIA2 == VIA2OFF) - via2_reg(vIER) = flags; - else - via2_reg(rIER) = flags; - splx(s); -} - -void -sbc_obio_clrintr(ncr_sc) - struct ncr5380_softc *ncr_sc; -{ - struct sbc_softc *sc = (struct sbc_softc *)ncr_sc; - int flags; - - flags = V2IF_SCSIIRQ; - if (sc->sc_options & SBC_INTR) - flags |= V2IF_SCSIDRQ; - - if (VIA2 == VIA2OFF) - via2_reg(vIFR) = 0x80 | flags; - else - via2_reg(rIFR) = 0x80 | flags; -} diff --git a/sys/arch/mac68k/dev/sbcreg.h b/sys/arch/mac68k/dev/sbcreg.h deleted file mode 100644 index df384b7f836..00000000000 --- a/sys/arch/mac68k/dev/sbcreg.h +++ /dev/null @@ -1,28 +0,0 @@ -/* $OpenBSD: sbcreg.h,v 1.2 1997/03/08 16:16:59 briggs Exp $ */ -/* $NetBSD: sbcreg.h,v 1.2 1997/03/01 20:18:59 scottr Exp $ */ - -/* - * Register map for the Mac II SCSI Interface (sbc) - * This register map is for the SYM/NCR5380 SCSI Bus Interface - * Controller (SBIC), with the wonderful 16 bytes/register layout - * that Macs have. - */ - -/* - * Am5380 Register map (with padding) - */ -typedef union { - volatile u_char sci_reg; - volatile u_char pad[16]; -} ncr5380_padded_reg_t; - -struct sbc_regs { - ncr5380_padded_reg_t sci_pr0; - ncr5380_padded_reg_t sci_pr1; - ncr5380_padded_reg_t sci_pr2; - ncr5380_padded_reg_t sci_pr3; - ncr5380_padded_reg_t sci_pr4; - ncr5380_padded_reg_t sci_pr5; - ncr5380_padded_reg_t sci_pr6; - ncr5380_padded_reg_t sci_pr7; -}; diff --git a/sys/arch/mac68k/dev/sbcvar.h b/sys/arch/mac68k/dev/sbcvar.h deleted file mode 100644 index 059413013e7..00000000000 --- a/sys/arch/mac68k/dev/sbcvar.h +++ /dev/null @@ -1,122 +0,0 @@ -/* $OpenBSD: sbcvar.h,v 1.9 2010/06/28 18:31:01 krw Exp $ */ -/* $NetBSD: sbcvar.h,v 1.1 1997/03/01 20:19:00 scottr Exp $ */ - -/* - * Copyright (C) 1996 Scott Reynolds. 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 Scott Reynolds for - * the NetBSD Project. - * 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. - */ - -/* - * Transfers smaller than this are done using PIO - * (on assumption they're not worth PDMA overhead) - */ -#define MIN_DMA_LEN 128 - -/* - * Transfers larger than 8192 bytes need to be split up - * due to the size of the PDMA space. - */ -#define MAX_DMA_LEN 0x2000 - -#ifdef SBC_DEBUG -# define SBC_DB_INTR 0x01 -# define SBC_DB_DMA 0x02 -# define SBC_DB_REG 0x04 -# define SBC_DB_BREAK 0x08 -# ifndef DDB -# define Debugger() printf("Debug: sbc.c:%d\n", __LINE__) -# endif -# define SBC_BREAK \ - do { if (sbc_debug & SBC_DB_BREAK) Debugger(); } while (0) -#else -# define SBC_BREAK -#endif - -/* - * This structure is used to keep track of PDMA requests. - */ -struct sbc_pdma_handle { - int dh_flags; /* flags */ -#define SBC_DH_BUSY 0x01 /* This handle is in use */ -#define SBC_DH_OUT 0x02 /* PDMA data out (write) */ -#define SBC_DH_DONE 0x04 /* PDMA transfer is complete */ - u_char *dh_addr; /* data buffer */ - int dh_len; /* length of data buffer */ -}; - -/* - * The first structure member has to be the ncr5380_softc - * so we can just cast to go back and forth between them. - */ -struct sbc_softc { - struct ncr5380_softc ncr_sc; - struct via2hand sc_ih_drq, sc_ih_irq; - volatile struct sbc_regs *sc_regs; - volatile vaddr_t sc_drq_addr; - volatile vaddr_t sc_nodrq_addr; - void (*sc_clrintr)(struct ncr5380_softc *); - int sc_options; /* options for this instance. */ - struct sbc_pdma_handle sc_pdma[SCI_OPENINGS]; -}; - -/* - * Options. By default, SCSI interrupts and reselect are disabled. - * You may enable either of these features with the `flags' directive - * in your kernel's configuration file. - * - * Alternatively, you can patch your kernel with DDB or some other - * mechanism. The sc_options member of the softc is OR'd with - * the value in sbc_options. - * - * The options code is based on the sparc 'si' driver's version of - * the same. - */ -#define SBC_PDMA 0x01 /* Use PDMA for polled transfers */ -#define SBC_INTR 0x02 /* Allow SCSI IRQ/DRQ interrupts */ -#define SBC_RESELECT 0x04 /* Allow disconnect/reselect */ -#define SBC_OPTIONS_MASK (SBC_RESELECT|SBC_INTR|SBC_PDMA) -#define SBC_OPTIONS_BITS "\10\3RESELECT\2INTR\1PDMA" - -extern int sbc_debug; -extern int sbc_link_flags; -extern int sbc_options; -extern struct scsi_adapter sbc_ops; - -int sbc_pdma_in(struct ncr5380_softc *, int, int, u_char *); -int sbc_pdma_out(struct ncr5380_softc *, int, int, u_char *); -int sbc_irq_intr(void *); -int sbc_drq_intr(void *); -void sbc_dma_alloc(struct ncr5380_softc *); -void sbc_dma_free(struct ncr5380_softc *); -void sbc_dma_poll(struct ncr5380_softc *); -void sbc_dma_setup(struct ncr5380_softc *); -void sbc_dma_start(struct ncr5380_softc *); -void sbc_dma_stop(struct ncr5380_softc *); -#ifdef SBC_DEBUG -void decode_5380_intr(struct ncr5380_softc *); -#endif diff --git a/sys/arch/mac68k/dev/z8530reg.h b/sys/arch/mac68k/dev/z8530reg.h deleted file mode 100644 index 57a1cc636cf..00000000000 --- a/sys/arch/mac68k/dev/z8530reg.h +++ /dev/null @@ -1,446 +0,0 @@ -/* $OpenBSD: z8530reg.h,v 1.5 2004/11/25 18:32:10 miod Exp $ */ -/* $NetBSD: z8530reg.h,v 1.7 1996/10/23 00:32:31 gwr Exp $ */ - -/* - * 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: - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)zsreg.h 8.1 (Berkeley) 6/11/93 - */ - -/* - * Zilog SCC registers, as implemented on the Sun-4c. - * - * Each Z8530 implements two channels (called `a' and `b'). - * - * The damnable chip was designed to fit on Z80 I/O ports, and thus - * has everything multiplexed out the wazoo. We have to select - * a register, then read or write the register, and so on. Worse, - * the parameter bits are scattered all over the register space. - * This thing is full of `miscellaneous' control registers. - * - * Worse yet, the registers have incompatible functions on read - * and write operations. We describe the registers below according - * to whether they are `read registers' (RR) or `write registers' (WR). - * As if this were not enough, some of the channel B status bits show - * up in channel A, and vice versa. The blasted thing shares write - * registers 2 and 9 across both channels, and reads registers 2 and 3 - * differently for the two channels. We can, however, ignore this much - * of the time. - * - * This file also includes flags for the Z85C30 and Z85230 enhanced scc. - * The CMOS 8530 includes extra SDLC functionality, and is used in a - * number of Macs (often in the Z85C80, an 85C30 combined w/ a SCSI - * controller). -wrs - * - * Some of the names in this files were chosen to make the hsis driver - * work unchanged (which means that they will match some in SunOS). - * - * `S.C.' stands for Special Condition, which is any of these: - * receiver overrun (aka silo overflow) - * framing error (missing stop bit, etc) - * end of frame (in synchronous modes) - * parity error (when `parity error is S.C.' is set) - * - * Registers with only a single `numeric value' get a name. - * Other registers hold bits and are only numbered; the bit - * definitions imply the register number (see below). - * - * We never use the receive and transmit data registers as - * indirects (choosing instead the zc_data register), so they - * are not defined here. - */ -#define ZSRR_IVEC 2 /* interrupt vector (channel 0) */ -#define ZSRR_IPEND 3 /* interrupt pending (ch. 0 only) */ -#define ZSRR_TXSYNC 6 /* sync transmit char (monosync mode) */ -#define ZSRR_RXSYNC 7 /* sync receive char (monosync mode) */ -#define ZSRR_SYNCLO 6 /* sync low byte (bisync mode) */ -#define ZSRR_SYNCHI 7 /* sync high byte (bisync mode) */ -#define ZSRR_SDLC_ADDR 6 /* SDLC address (SDLC mode) */ -#define ZSRR_SDLC_FLAG 7 /* SDLC flag 0x7E (SDLC mode) */ -#define ZSRR_BAUDLO 12 /* baud rate generator (low half) */ -#define ZSRR_BAUDHI 13 /* baud rate generator (high half) */ -#define ZSRR_ENHANCED 14 /* read address of WR7' - yes, it's not 7!*/ - -#define ZSWR_IVEC 2 /* interrupt vector (shared) */ -#define ZSWR_TXSYNC 6 /* sync transmit char (monosync mode) */ -#define ZSWR_RXSYNC 7 /* sync receive char (monosync mode) */ -#define ZSWR_SYNCLO 6 /* sync low byte (bisync mode) */ -#define ZSWR_SYNCHI 7 /* sync high byte (bisync mode) */ -#define ZSWR_SDLC_ADDR 6 /* SDLC address (SDLC mode) */ -#define ZSWR_SDLC_FLAG 7 /* SDLC flag 0x7E (SDLC mode) */ -#define ZSWR_BAUDLO 12 /* baud rate generator (low half) */ -#define ZSWR_BAUDHI 13 /* baud rate generator (high half) */ -#define ZSWR_ENHANCED 7 /* write address of WR7' */ - -/* - * Registers 0 through 7 may be written with any one of the 8 command - * modifiers, and/or any one of the 4 reset modifiers, defined below. - * To write registers 8 through 15, however, the command modifier must - * always be `point high'. Rather than track this bizzareness all over - * the driver, we try to avoid using any modifiers, ever (but they are - * defined here if you want them). - */ -#define ZSM_RESET_TXUEOM 0xc0 /* reset xmit underrun / eom latch */ -#define ZSM_RESET_TXCRC 0x80 /* reset xmit crc generator */ -#define ZSM_RESET_RXCRC 0x40 /* reset recv crc checker */ -#define ZSM_NULL 0x00 /* nothing special */ - -#define ZSM_RESET_IUS 0x38 /* reset interrupt under service */ -#define ZSM_RESET_ERR 0x30 /* reset error cond */ -#define ZSM_RESET_TXINT 0x28 /* reset xmit interrupt pending */ -#define ZSM_EI_NEXTRXC 0x20 /* enable int. on next rcvd char */ -#define ZSM_SEND_ABORT 0x18 /* send abort (SDLC) */ -#define ZSM_RESET_STINT 0x10 /* reset external/status interrupt */ -#define ZSM_POINTHIGH 0x08 /* `point high' (use r8-r15) */ -#define ZSM_NULL 0x00 /* nothing special */ - -/* - * Commands for Write Register 0 (`Command Register'). - * These are just the command modifiers or'ed with register number 0 - * (which of course equals the command modifier). - */ -#define ZSWR0_RESET_EOM ZSM_RESET_TXUEOM -#define ZSWR0_RESET_TXCRC ZSM_RESET_TXCRC -#define ZSWR0_RESET_RXCRC ZSM_RESET_RXCRC -#define ZSWR0_CLR_INTR ZSM_RESET_IUS -#define ZSWR0_RESET_ERRORS ZSM_RESET_ERR -#define ZSWR0_EI_NEXTRXC ZSM_EI_NEXTRXC -#define ZSWR0_SEND_ABORT ZSM_SEND_ABORT -#define ZSWR0_RESET_STATUS ZSM_RESET_STINT -#define ZSWR0_RESET_TXINT ZSM_RESET_TXINT - -/* - * Bits in Write Register 1 (`Transmit/Receive Interrupt and Data - * Transfer Mode Definition'). Note that bits 3 and 4 are taken together - * as a single unit, and bits 5 and 6 are useful only if bit 7 is set. - */ -#define ZSWR1_REQ_WAIT 0x80 /* WAIT*-REQ* pin gives WAIT* */ -#define ZSWR1_REQ_REQ 0xc0 /* WAIT*-REQ* pin gives REQ* */ -#define ZSWR1_REQ_TX 0x00 /* WAIT*-REQ* pin follows xmit buf */ -#define ZSWR1_REQ_RX 0x20 /* WAIT*-REQ* pin follows recv buf */ - -#define ZSWR1_RIE_NONE 0x00 /* disable rxint entirely */ -#define ZSWR1_RIE_FIRST 0x08 /* rxint on first char & on S.C. */ -#define ZSWR1_RIE 0x10 /* rxint per char & on S.C. */ -#define ZSWR1_RIE_SPECIAL_ONLY 0x18 /* rxint on S.C. only */ - -#define ZSWR1_PE_SC 0x04 /* parity error is special condition */ -#define ZSWR1_TIE 0x02 /* transmit interrupt enable */ -#define ZSWR1_SIE 0x01 /* external/status interrupt enable */ - -#define ZSWR1_IMASK 0x1F /* mask of all itr. enable bits. */ - -/* HSIS compat */ -#define ZSWR1_REQ_ENABLE (ZSWR1_REQ_WAIT | ZSWR1_REQ_TX) - -/* - * Bits in Write Register 3 (`Receive Parameters and Control'). - * Bits 7 and 6 are taken as a unit. Note that the receive bits - * per character ordering is insane. - * - * Here `hardware flow control' means CTS enables the transmitter - * and DCD enables the receiver. The latter is neither interesting - * nor useful, and gets in our way, making it almost unusable. - */ -#define ZSWR3_RX_5 0x00 /* receive 5 bits per char */ -#define ZSWR3_RX_7 0x40 /* receive 7 bits per char */ -#define ZSWR3_RX_6 0x80 /* receive 6 bits per char */ -#define ZSWR3_RX_8 0xc0 /* receive 8 bits per char */ -#define ZSWR3_RXSIZE 0xc0 /* receive char size mask */ - -#define ZSWR3_HFC 0x20 /* hardware flow control */ -#define ZSWR3_HUNT 0x10 /* enter hunt mode */ -#define ZSWR3_RXCRC_ENABLE 0x08 /* enable recv crc calculation */ -#define ZSWR3_ADDR_SEARCH_MODE 0x04 /* address search mode (SDLC only) */ -#define ZSWR3_SYNC_LOAD_INH 0x02 /* sync character load inhibit */ -#define ZSWR3_RX_ENABLE 0x01 /* receiver enable */ - -/* - * Bits in Write Register 4 (`Transmit/Receive Miscellaneous Parameters - * and Modes'). Bits 7&6, 5&4, and 3&2 are taken as units. - */ -#define ZSWR4_CLK_X1 0x00 /* clock divisor = 1 */ -#define ZSWR4_CLK_X16 0x40 /* clock divisor = 16 */ -#define ZSWR4_CLK_X32 0x80 /* clock divisor = 32 */ -#define ZSWR4_CLK_X64 0xc0 /* clock divisor = 64 */ -#define ZSWR4_CLK_MASK 0xc0 /* clock divisor mask */ - -#define ZSWR4_MONOSYNC 0x00 /* 8 bit sync char (sync only) */ -#define ZSWR4_BISYNC 0x10 /* 16 bit sync char (sync only) */ -#define ZSWR4_SDLC 0x20 /* SDLC mode */ -#define ZSWR4_EXTSYNC 0x30 /* external sync mode */ -#define ZSWR4_SYNC_MASK 0x30 /* sync mode bit mask */ - -#define ZSWR4_SYNCMODE 0x00 /* no stop bit (sync mode only) */ -#define ZSWR4_ONESB 0x04 /* 1 stop bit */ -#define ZSWR4_1P5SB 0x08 /* 1.5 stop bits (clk cannot be 1x) */ -#define ZSWR4_TWOSB 0x0c /* 2 stop bits */ -#define ZSWR4_SBMASK 0x0c /* mask of all stop bits */ - -#define ZSWR4_EVENP 0x02 /* check for even parity */ -#define ZSWR4_PARENB 0x01 /* enable parity checking */ -#define ZSWR4_PARMASK 0x03 /* mask of all parity bits */ - -/* - * Bits in Write Register 5 (`Transmit Parameter and Controls'). - * Bits 6 and 5 are taken as a unit; the ordering is, as with RX - * bits per char, not sensible. - */ -#define ZSWR5_DTR 0x80 /* assert (set to -12V) DTR */ - -#define ZSWR5_TX_5 0x00 /* transmit 5 or fewer bits */ -#define ZSWR5_TX_7 0x20 /* transmit 7 bits */ -#define ZSWR5_TX_6 0x40 /* transmit 6 bits */ -#define ZSWR5_TX_8 0x60 /* transmit 8 bits */ -#define ZSWR5_TXSIZE 0x60 /* transmit char size mask */ - -#define ZSWR5_BREAK 0x10 /* send break (continuous 0s) */ -#define ZSWR5_TX_ENABLE 0x08 /* enable transmitter */ -#define ZSWR5_CRC16 0x04 /* use CRC16 (off => use SDLC) */ -#define ZSWR5_RTS 0x02 /* assert RTS */ -#define ZSWR5_TXCRC_ENABLE 0x01 /* enable xmit crc calculation */ - -#ifdef not_done_here -/* - * Bits in Write Register 7 when the chip is in SDLC mode. - */ -#define ZSWR7_SDLCFLAG 0x7e /* this value makes SDLC mode work */ -#endif - -/* - * Bits in Write Register 7' (ZSWR_ENHANCED above). This register is - * only available on the 85230. Dispite the fact it contains flags - * and not a single value, the register was named as it is read - * via RR14. Weird. - */ - /* 0x80 unused */ -#define ZSWR7P_EXTEND_READ 0x40 /* modify read map; make most regs readable */ -#define ZSWR7P_TX_FIFO 0x20 /* change level for Tx FIFO empty int */ -#define ZSWR7P_DTR_TIME 0x10 /* modifies deact. speed of /DTR//REQ */ -#define ZSWR7P_RX_FIFO 0x08 /* Rx FIFO int on 1/2 full? */ -#define ZSWR7P_RTS_DEACT 0x04 /* automatically deassert RTS */ -#define ZSWR7P_AUTO_EOM_RESET 0x02 /* automatically reset EMO/Tx Underrun */ -#define ZSWR7P_AUTO_TX_FLAG 0x01 /* Auto send SDLC flag at transmit start */ - -/* - * Bits in Write Register 9 (`Master Interrupt Control'). Bits 7 & 6 - * are taken as a unit and indicate the type of reset; 00 means no reset - * (and is not defined here). - */ -#define ZSWR9_HARD_RESET 0xc0 /* force hardware reset */ -#define ZSWR9_A_RESET 0x80 /* reset channel A (0) */ -#define ZSWR9_B_RESET 0x40 /* reset channel B (1) */ -#define ZSWR9_SOFT_INTAC 0x20 /* Not in NMOS version */ - -#define ZSWR9_STATUS_HIGH 0x10 /* status in high bits of intr vec */ -#define ZSWR9_MASTER_IE 0x08 /* master interrupt enable */ -#define ZSWR9_DLC 0x04 /* disable lower chain */ -#define ZSWR9_NO_VECTOR 0x02 /* no vector */ -#define ZSWR9_VECTOR_INCL_STAT 0x01 /* vector includes status */ - -/* - * Bits in Write Register 10 (`Miscellaneous Transmitter/Receiver Control - * Bits'). Bits 6 & 5 are taken as a unit, and some of the bits are - * meaningful only in certain modes. Bleah. - */ -#define ZSWR10_PRESET_ONES 0x80 /* preset CRC to all 1 (else all 0) */ - -#define ZSWR10_NRZ 0x00 /* NRZ encoding */ -#define ZSWR10_NRZI 0x20 /* NRZI encoding */ -#define ZSWR10_FM1 0x40 /* FM1 encoding */ -#define ZSWR10_FM0 0x60 /* FM0 encoding */ - -#define ZSWR10_GA_ON_POLL 0x10 /* go active on poll (loop mode) */ -#define ZSWR10_MARK_IDLE 0x08 /* all 1s (vs flag) when idle (SDLC) */ -#define ZSWR10_ABORT_ON_UNDERRUN 0x4 /* abort on xmit underrun (SDLC) */ -#define ZSWR10_LOOP_MODE 0x02 /* loop mode (SDLC) */ -#define ZSWR10_6_BIT_SYNC 0x01 /* 6 bits per sync char (sync modes) */ - -/* - * Bits in Write Register 11 (`Clock Mode Control'). Bits 6&5, 4&3, and - * 1&0 are taken as units. Various bits depend on other bits in complex - * ways; see the Zilog manual. - */ -#define ZSWR11_XTAL 0x80 /* have xtal between RTxC* and SYNC* */ - /* (else have TTL oscil. on RTxC*) */ -#define ZSWR11_RXCLK_RTXC 0x00 /* recv clock taken from RTxC* pin */ -#define ZSWR11_RXCLK_TRXC 0x20 /* recv clock taken from TRxC* pin */ -#define ZSWR11_RXCLK_BAUD 0x40 /* recv clock taken from BRG */ -#define ZSWR11_RXCLK_DPLL 0x60 /* recv clock taken from DPLL */ - -#define ZSWR11_TXCLK_RTXC 0x00 /* xmit clock taken from RTxC* pin */ -#define ZSWR11_TXCLK_TRXC 0x08 /* xmit clock taken from TRxC* pin */ -#define ZSWR11_TXCLK_BAUD 0x10 /* xmit clock taken from BRG */ -#define ZSWR11_TXCLK_DPLL 0x18 /* xmit clock taken from DPLL */ - -#define ZSWR11_TRXC_OUT_ENA 0x04 /* TRxC* pin will be an output */ - /* (unless it is being used above) */ -#define ZSWR11_TRXC_XTAL 0x00 /* TRxC output from xtal oscillator */ -#define ZSWR11_TRXC_XMIT 0x01 /* TRxC output from xmit clock */ -#define ZSWR11_TRXC_BAUD 0x02 /* TRxC output from BRG */ -#define ZSWR11_TRXC_DPLL 0x03 /* TRxC output from DPLL */ - -/* - * Formula for Write Registers 12 and 13 (`Lower Byte of Baud Rate - * Generator Time Constant' and `Upper Byte of ...'). Inputs: - * - * f BRG input clock frequency (in Hz) AFTER division - * by 1, 16, 32, or 64 (per clock divisor in WR4) - * bps desired rate in bits per second (9600, etc) - * - * We want - * - * f - * ----- + 0.5 - 2 - * 2 bps - * - * rounded down to an integer. This can be computed entirely - * in integer arithmetic as: - * - * f + bps - * ------- - 2 - * 2 bps - */ -#define BPS_TO_TCONST(f, bps) ((((f) + (bps)) / (2 * (bps))) - 2) - -/* inverse of above: given a BRG Time Constant, return Bits Per Second */ -#define TCONST_TO_BPS(f, tc) ((f) / 2 / ((tc) + 2)) - -/* - * Bits in Write Register 14 (`Miscellaneous Control Bits'). - * Bits 7 through 5 are taken as a unit and make up a `DPLL command'. - */ -#define ZSWR14_DPLL_NOOP 0x00 /* leave DPLL alone */ -#define ZSWR14_DPLL_SEARCH 0x20 /* enter search mode */ -#define ZSWR14_DPLL_RESET_CM 0x40 /* reset `clock missing' in RR10 */ -#define ZSWR14_DPLL_DISABLE 0x60 /* disable DPLL (continuous search) */ -#define ZSWR14_DPLL_SRC_BAUD 0x80 /* set DPLL src = BRG */ -#define ZSWR14_DPLL_SRC_RTXC 0xa0 /* set DPLL src = RTxC* or xtal osc */ -#define ZSWR14_DPLL_FM 0xc0 /* operate in FM mode */ -#define ZSWR14_DPLL_NRZI 0xe0 /* operate in NRZI mode */ - -#define ZSWR14_LOCAL_LOOPBACK 0x10 /* set local loopback mode */ -#define ZSWR14_AUTO_ECHO 0x08 /* set auto echo mode */ -#define ZSWR14_DTR_REQ 0x04 /* DTR* / REQ* pin gives REQ* */ -#define ZSWR14_BAUD_FROM_PCLK 0x02 /* BRG clock taken from PCLK */ - /* (else from RTxC* pin or xtal osc) */ -#define ZSWR14_BAUD_ENA 0x01 /* enable BRG countdown */ - -/* - * Bits in Write Register 15 (`External/Status Interrupt Control'). - * Most of these cause status interrupts whenever the corresponding - * bit or pin changes state (i.e., any rising or falling edge). - * - * NOTE: ZSWR15_SDLC_FIFO & ZSWR15_ENABLE_ENHANCED should not be - * set on an NMOS 8530. Also, ZSWR15_ENABLE_ENHANCED is only - * available on the 85230. - */ -#define ZSWR15_BREAK_IE 0x80 /* enable break/abort status int */ -#define ZSWR15_TXUEOM_IE 0x40 /* enable TX underrun/EOM status int */ -#define ZSWR15_CTS_IE 0x20 /* enable CTS* pin status int */ -#define ZSWR15_SYNCHUNT_IE 0x10 /* enable SYNC* pin/hunt status int */ -#define ZSWR15_DCD_IE 0x08 /* enable DCD* pin status int */ -#define ZSWR15_SDLC_FIFO 0x04 /* enable SDLC FIFO enhancements */ -#define ZSWR15_ZERO_COUNT_IE 0x02 /* enable BRG-counter = 0 status int */ -#define ZSWR15_ENABLE_ENHANCED 0x01 /* enable writing WR7' at reg 7 */ - -/* - * Bits in Read Register 0 (`Transmit/Receive Buffer Status and External - * Status'). - */ -#define ZSRR0_BREAK 0x80 /* break/abort detected */ -#define ZSRR0_TXUNDER 0x40 /* transmit underrun/EOM (sync) */ -#define ZSRR0_CTS 0x20 /* clear to send */ -#define ZSRR0_SYNC_HUNT 0x10 /* sync/hunt (sync mode) */ -#define ZSRR0_DCD 0x08 /* data carrier detect */ -#define ZSRR0_TX_READY 0x04 /* transmit buffer empty */ -#define ZSRR0_ZERO_COUNT 0x02 /* zero count in baud clock */ -#define ZSRR0_RX_READY 0x01 /* received character ready */ - -/* - * Bits in Read Register 1 (the Zilog book does not name this one). - */ -#define ZSRR1_EOF 0x80 /* end of frame (SDLC mode) */ -#define ZSRR1_FE 0x40 /* CRC/framing error */ -#define ZSRR1_DO 0x20 /* data (receiver) overrun */ -#define ZSRR1_PE 0x10 /* parity error */ -#define ZSRR1_RC0 0x08 /* residue code 0 (SDLC mode) */ -#define ZSRR1_RC1 0x04 /* residue code 1 (SDLC mode) */ -#define ZSRR1_RC2 0x02 /* residue code 2 (SDLC mode) */ -#define ZSRR1_ALL_SENT 0x01 /* all chars out of xmitter (async) */ - -/* - * Read Register 2 in B channel contains status bits if VECTOR_INCL_STAT - * is set. - */ - -/* - * Bits in Read Register 3 (`Interrupt Pending'). Only channel A - * has an RR3. - */ - /* 0x80 unused, returned as 0 */ - /* 0x40 unused, returned as 0 */ -#define ZSRR3_IP_A_RX 0x20 /* channel A recv int pending */ -#define ZSRR3_IP_A_TX 0x10 /* channel A xmit int pending */ -#define ZSRR3_IP_A_STAT 0x08 /* channel A status int pending */ -#define ZSRR3_IP_B_RX 0x04 /* channel B recv int pending */ -#define ZSRR3_IP_B_TX 0x02 /* channel B xmit int pending */ -#define ZSRR3_IP_B_STAT 0x01 /* channel B status int pending */ - -/* - * Bits in Read Register 10 (`contains some miscellaneous status bits'). - */ -#define ZSRR10_1_CLOCK_MISSING 0x80 /* 1 clock edge missing (FM mode) */ -#define ZSRR10_2_CLOCKS_MISSING 0x40 /* 2 clock edges missing (FM mode) */ - /* 0x20 unused */ -#define ZSRR10_LOOP_SENDING 0x10 /* xmitter controls loop (SDLC loop) */ - /* 0x08 unused */ - /* 0x04 unused */ -#define ZSRR10_ON_LOOP 0x02 /* SCC is on loop (SDLC/X.21 modes) */ - -/* - * Bits in Read Register 15. This register is one of the few that - * simply reads back the corresponding Write Register. - */ -#define ZSRR15_BREAK_IE 0x80 /* break/abort status int enable */ -#define ZSRR15_TXUEOM_IE 0x40 /* TX underrun/EOM status int enable */ -#define ZSRR15_CTS_IE 0x20 /* CTS* pin status int enable */ -#define ZSRR15_SYNCHUNT_IE 0x10 /* SYNC* pin/hunt status int enable */ -#define ZSRR15_DCD_IE 0x08 /* DCD* pin status int enable */ - /* 0x04 unused, returned as zero */ -#define ZSRR15_ZERO_COUNT_IE 0x02 /* BRG-counter = 0 status int enable */ - /* 0x01 unused, returned as zero */ diff --git a/sys/arch/mac68k/dev/z8530sc.c b/sys/arch/mac68k/dev/z8530sc.c deleted file mode 100644 index 28976cb10dc..00000000000 --- a/sys/arch/mac68k/dev/z8530sc.c +++ /dev/null @@ -1,329 +0,0 @@ -/* $OpenBSD: z8530sc.c,v 1.8 2009/03/15 20:40:25 miod Exp $ */ -/* $NetBSD: z8530sc.c,v 1.5 1996/12/17 20:42:40 gwr Exp $ */ - -/* - * Copyright (c) 1994 Gordon W. Ross - * 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: - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)zs.c 8.1 (Berkeley) 7/19/93 - */ - -/* - * Zilog Z8530 Dual UART driver (common part) - * - * This file contains the machine-independent parts of the - * driver common to tty and keyboard/mouse sub-drivers. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/proc.h> -#include <sys/device.h> -#include <sys/conf.h> -#include <sys/file.h> -#include <sys/ioctl.h> -#include <sys/tty.h> -#include <sys/time.h> -#include <sys/kernel.h> -#include <sys/syslog.h> - -#include <mac68k/dev/z8530reg.h> -#include <machine/z8530var.h> - -static void zsnull_intr(struct zs_chanstate *); -static void zsnull_softint(struct zs_chanstate *); - -void -zs_break(cs, set) - struct zs_chanstate *cs; - int set; -{ - int s; - - s = splzs(); - if (set) { - cs->cs_preg[5] |= ZSWR5_BREAK; - cs->cs_creg[5] |= ZSWR5_BREAK; - } else { - cs->cs_preg[5] &= ~ZSWR5_BREAK; - cs->cs_creg[5] &= ~ZSWR5_BREAK; - } - zs_write_reg(cs, 5, cs->cs_creg[5]); - splx(s); -} - - -/* - * drain on-chip fifo - */ -void -zs_iflush(cs) - struct zs_chanstate *cs; -{ - u_char c, rr0, rr1; - - for (;;) { - /* Is there input available? */ - rr0 = zs_read_csr(cs); - if ((rr0 & ZSRR0_RX_READY) == 0) - break; - - /* - * First read the status, because reading the data - * destroys the status of this char. - */ - rr1 = zs_read_reg(cs, 1); - c = zs_read_data(cs); - - if (rr1 & (ZSRR1_FE | ZSRR1_DO | ZSRR1_PE)) { - /* Clear the receive error. */ - zs_write_csr(cs, ZSWR0_RESET_ERRORS); - } - } -} - - -/* - * Write the given register set to the given zs channel in the proper order. - * The channel must not be transmitting at the time. The receiver will - * be disabled for the time it takes to write all the registers. - * Call this with interrupts disabled. - */ -void -zs_loadchannelregs(cs) - struct zs_chanstate *cs; -{ - u_char *reg; - - /* Copy "pending" regs to "current" */ - bcopy((caddr_t)cs->cs_preg, (caddr_t)cs->cs_creg, 16); - reg = cs->cs_creg; /* current regs */ - - zs_write_csr(cs, ZSM_RESET_ERR); /* XXX: reset error condition */ - -#if 1 - /* - * XXX: Is this really a good idea? - * XXX: Should go elsewhere! -gwr - */ - zs_iflush(cs); /* XXX */ -#endif - - /* disable interrupts */ - zs_write_reg(cs, 1, reg[1] & ~ZSWR1_IMASK); - - /* baud clock divisor, stop bits, parity */ - zs_write_reg(cs, 4, reg[4]); - - /* misc. TX/RX control bits */ - zs_write_reg(cs, 10, reg[10]); - - /* char size, enable (RX/TX) */ - zs_write_reg(cs, 3, reg[3] & ~ZSWR3_RX_ENABLE); - zs_write_reg(cs, 5, reg[5] & ~ZSWR5_TX_ENABLE); - - /* synchronous mode stuff */ - zs_write_reg(cs, 6, reg[6]); - zs_write_reg(cs, 7, reg[7]); - -#if 0 - /* - * Registers 2 and 9 are special because they are - * actually common to both channels, but must be - * programmed through channel A. The "zsc" attach - * function takes care of setting these registers - * and they should not be touched thereafter. - */ - /* interrupt vector */ - zs_write_reg(cs, 2, reg[2]); - /* master interrupt control */ - zs_write_reg(cs, 9, reg[9]); -#endif - - /* Shut down the BRG */ - zs_write_reg(cs, 14, reg[14] & ~ZSWR14_BAUD_ENA); - -#ifdef ZS_MD_SETCLK - /* Let the MD code setup any external clock. */ - ZS_MD_SETCLK(cs); -#endif /* ZS_MD_SETCLK */ - - /* clock mode control */ - zs_write_reg(cs, 11, reg[11]); - - /* baud rate (lo/hi) */ - zs_write_reg(cs, 12, reg[12]); - zs_write_reg(cs, 13, reg[13]); - - /* Misc. control bits */ - zs_write_reg(cs, 14, reg[14]); - - /* which lines cause status interrupts */ - zs_write_reg(cs, 15, reg[15]); - - /* - * Zilog docs recommend resetting external status twice at this - * point. Mainly as the status bits are latched, and the first - * interrupt clear might unlatch them to new values, generating - * a second interrupt request. - */ - zs_write_csr(cs, ZSM_RESET_STINT); - zs_write_csr(cs, ZSM_RESET_STINT); - - /* char size, enable (RX/TX)*/ - zs_write_reg(cs, 3, reg[3]); - zs_write_reg(cs, 5, reg[5]); - - /* interrupt enables: RX, TX, STATUS */ - zs_write_reg(cs, 1, reg[1]); -} - - -/* - * ZS hardware interrupt. Scan all ZS channels. NB: we know here that - * channels are kept in (A,B) pairs. - * - * Do just a little, then get out; set a software interrupt if more - * work is needed. - * - * We deliberately ignore the vectoring Zilog gives us, and match up - * only the number of `reset interrupt under service' operations, not - * the order. - */ -int -zsc_intr_hard(arg) - void *arg; -{ - register struct zsc_softc *zsc = arg; - register struct zs_chanstate *cs; - register u_char rr3; - - /* First look at channel A. */ - cs = zsc->zsc_cs[0]; - /* Note: only channel A has an RR3 */ - rr3 = zs_read_reg(cs, 3); - - /* - * Clear interrupt first to avoid a race condition. - * If a new interrupt condition happens while we are - * servicing this one, we will get another interrupt - * shortly. We can NOT just sit here in a loop, or - * we will cause horrible latency for other devices - * on this interrupt level (i.e. sun3x floppy disk). - */ - if (rr3 & (ZSRR3_IP_A_RX | ZSRR3_IP_A_TX | ZSRR3_IP_A_STAT)) { - zs_write_csr(cs, ZSWR0_CLR_INTR); - if (rr3 & ZSRR3_IP_A_RX) - (*cs->cs_ops->zsop_rxint)(cs); - if (rr3 & ZSRR3_IP_A_STAT) - (*cs->cs_ops->zsop_stint)(cs); - if (rr3 & ZSRR3_IP_A_TX) - (*cs->cs_ops->zsop_txint)(cs); - } - - /* Now look at channel B. */ - cs = zsc->zsc_cs[1]; - if (rr3 & (ZSRR3_IP_B_RX | ZSRR3_IP_B_TX | ZSRR3_IP_B_STAT)) { - zs_write_csr(cs, ZSWR0_CLR_INTR); - if (rr3 & ZSRR3_IP_B_RX) - (*cs->cs_ops->zsop_stint)(cs); - if (rr3 & ZSRR3_IP_B_STAT) - (*cs->cs_ops->zsop_stint)(cs); - if (rr3 & ZSRR3_IP_B_TX) - (*cs->cs_ops->zsop_txint)(cs); - } - - /* Note: caller will check cs_x->cs_softreq and DTRT. */ - return (rr3); -} - - -/* - * ZS software interrupt. Scan all channels for deferred interrupts. - */ -void -zsc_intr_soft(arg) - void *arg; -{ - register struct zsc_softc *zsc = arg; - register struct zs_chanstate *cs; - register int chan; - - for (chan = 0; chan < 2; chan++) { - cs = zsc->zsc_cs[chan]; - - /* - * The softint flag can be safely cleared once - * we have decided to call the softint routine. - * (No need to do splzs() first.) - */ - if (cs->cs_softreq) { - cs->cs_softreq = 0; - (*cs->cs_ops->zsop_softint)(cs); - } - } -} - -/* - * Provide a null zs "ops" vector. - */ - -static void zsnull_intr(struct zs_chanstate *); -static void zsnull_softint(struct zs_chanstate *); - -static void -zsnull_intr(cs) - struct zs_chanstate *cs; -{ - /* Ask for softint() call. */ - cs->cs_softreq = 1; -} - -static void -zsnull_softint(cs) - struct zs_chanstate *cs; -{ - zs_write_reg(cs, 1, 0); - zs_write_reg(cs, 15, 0); -} - -struct zsops zsops_null = { - zsnull_intr, /* receive char available */ - zsnull_intr, /* external/status */ - zsnull_intr, /* xmit buffer empty */ - zsnull_softint, /* process software interrupt */ -}; diff --git a/sys/arch/mac68k/dev/z8530sc.h b/sys/arch/mac68k/dev/z8530sc.h deleted file mode 100644 index 80a41ed7539..00000000000 --- a/sys/arch/mac68k/dev/z8530sc.h +++ /dev/null @@ -1,130 +0,0 @@ -/* $OpenBSD: z8530sc.h,v 1.7 2009/03/15 20:40:25 miod Exp $ */ -/* $NetBSD: z8530sc.h,v 1.5 1996/12/17 20:42:42 gwr Exp $ */ - -/* - * Copyright (c) 1994 Gordon W. Ross - * 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: - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)zsvar.h 8.1 (Berkeley) 6/11/93 - */ - - -/* - * Software state, per zs channel. - */ -struct zs_chanstate { - - /* Pointers to the device registers. */ - volatile u_char *cs_reg_csr; /* ctrl, status, and reg. number. */ - volatile u_char *cs_reg_data; /* data or numbered register */ - - int cs_channel; /* sub-unit number */ - void *cs_private; /* sub-driver data pointer */ - struct zsops *cs_ops; - - int cs_brg_clk; /* BAUD Rate Generator clock - * (usually PCLK / 16) */ - int cs_defspeed; /* default baud rate */ - int cs_defcflag; /* default cflag */ - - /* - * We must keep a copy of the write registers as they are - * mostly write-only and we sometimes need to set and clear - * individual bits (e.g., in WR3). Not all of these are - * needed but 16 bytes is cheap and this makes the addressing - * simpler. Unfortunately, we can only write to some registers - * when the chip is not actually transmitting, so whenever - * we are expecting a `transmit done' interrupt the preg array - * is allowed to `get ahead' of the current values. In a - * few places we must change the current value of a register, - * rather than (or in addition to) the pending value; for these - * cs_creg[] contains the current value. - */ - u_char cs_creg[16]; /* current values */ - u_char cs_preg[16]; /* pending values */ - int cs_heldchange; /* change pending (creg != preg) */ - - u_char cs_rr0; /* last rr0 processed */ - u_char cs_rr0_delta; /* rr0 changes at status intr. */ - u_char cs_rr0_dcd; /* which bit to read as DCD */ - u_char cs_rr0_cts; /* which bit to read as CTS */ - /* the above is set only while CRTSCTS is enabled. */ - - u_char cs_wr5_dtr; /* which bit to write as DTR */ - u_char cs_wr5_rts; /* which bit to write as RTS */ - /* the above is set only while CRTSCTS is enabled. */ - - char cs_softreq; /* need soft interrupt call */ - char cs_pad[1]; - /* MD code might define a larger variant of this. */ -}; - -/* - * Function vector - per channel - */ -struct zs_chanstate; -typedef void (*zsop_t) (struct zs_chanstate *); -struct zsops { - zsop_t zsop_rxint; /* receive char available */ - zsop_t zsop_stint; /* external/status */ - zsop_t zsop_txint; /* xmit buffer empty */ - zsop_t zsop_softint; /* process software interrupt */ -}; - -extern struct zsops zsops_null; - -struct zsc_attach_args { - int channel; /* two serial channels per zsc */ - int hwflags; -}; -#define ZS_HWFLAG_CONSOLE 1 -#define ZS_HWFLAG_NO_DCD 2 /* Ignore the DCD bit */ -#define ZS_HWFLAG_NO_CTS 4 /* Ignore the CTS bit */ -#define ZS_HWFLAG_RAW 8 /* advise raw mode */ - -int zsc_intr_hard(void *); -void zsc_intr_soft(void *); - -void zs_abort(struct zs_chanstate *); -void zs_break(struct zs_chanstate *, int); -void zs_iflush (struct zs_chanstate *); -void zs_loadchannelregs(struct zs_chanstate *); -int zs_set_speed (struct zs_chanstate *, int); -int zs_set_modes (struct zs_chanstate *, int); -int zs_getspeed(struct zs_chanstate *); - -extern int zs_major; diff --git a/sys/arch/mac68k/dev/z8530tty.c b/sys/arch/mac68k/dev/z8530tty.c deleted file mode 100644 index 6f856bbbb5b..00000000000 --- a/sys/arch/mac68k/dev/z8530tty.c +++ /dev/null @@ -1,1316 +0,0 @@ -/* $OpenBSD: z8530tty.c,v 1.24 2010/07/02 17:27:01 nicm Exp $ */ -/* $NetBSD: z8530tty.c,v 1.14 1996/12/17 20:42:43 gwr Exp $ */ - -/* - * Copyright (c) 1994 Gordon W. Ross - * 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: - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)zs.c 8.1 (Berkeley) 7/19/93 - */ - -/* - * Zilog Z8530 Dual UART driver (tty interface) - * - * This is the "slave" driver that will be attached to - * the "zsc" driver for plain "tty" async. serial lines. - * - * Credits, history: - * - * The original version of this code was the sparc/dev/zs.c driver - * as distributed with the Berkeley 4.4 Lite release. Since then, - * Gordon Ross reorganized the code into the current parent/child - * driver scheme, separating the Sun keyboard and mouse support - * into independent child drivers. - * - * RTS/CTS flow-control support was a collaboration of: - * Gordon Ross <gwr@netbsd.org>, - * Bill Studenmund <wrstuden@loki.stanford.edu> - * Ian Dall <Ian.Dall@dsto.defence.gov.au> - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/proc.h> -#include <sys/device.h> -#include <sys/conf.h> -#include <sys/file.h> -#include <sys/ioctl.h> -#include <sys/malloc.h> -#include <sys/tty.h> -#include <sys/time.h> -#include <sys/kernel.h> -#include <sys/syslog.h> - -#include <mac68k/dev/z8530reg.h> -#include <machine/z8530var.h> - -#ifdef KGDB -extern int zs_check_kgdb(); -#endif - -/* - * How many input characters we can buffer. - * The port-specific var.h may override this. - * Note: must be a power of two! - */ -#ifndef ZSTTY_RING_SIZE -#define ZSTTY_RING_SIZE 2048 -#endif - -/* - * Make this an option variable one can patch. - * But be warned: this must be a power of 2! - */ -int zstty_rbuf_size = ZSTTY_RING_SIZE; - -/* This should usually be 3/4 of ZSTTY_RING_SIZE */ -int zstty_rbuf_hiwat = (ZSTTY_RING_SIZE - (ZSTTY_RING_SIZE >> 2)); - -struct zstty_softc { - struct device zst_dev; /* required first: base device */ - struct tty *zst_tty; - struct zs_chanstate *zst_cs; - - int zst_hwflags; /* see z8530var.h */ - int zst_swflags; /* TIOCFLAG_SOFTCAR, ... <ttycom.h> */ - - /* - * Printing an overrun error message often takes long enough to - * cause another overrun, so we only print one per second. - */ - long zst_rotime; /* time of last ring overrun */ - long zst_fotime; /* time of last fifo overrun */ - - /* - * The receive ring buffer. - */ - int zst_rbget; /* ring buffer `get' index */ - volatile int zst_rbput; /* ring buffer `put' index */ - int zst_ringmask; - int zst_rbhiwat; - - u_short *zst_rbuf; /* rr1, data pairs */ - - /* - * The transmit byte count and address are used for pseudo-DMA - * output in the hardware interrupt code. PDMA can be suspended - * to get pending changes done; heldtbc is used for this. It can - * also be stopped for ^S; this sets TS_TTSTOP in tp->t_state. - */ - int zst_tbc; /* transmit byte count */ - caddr_t zst_tba; /* transmit buffer address */ - int zst_heldtbc; /* held tbc while xmission stopped */ - - /* Flags to communicate with zstty_softint() */ - volatile char zst_rx_blocked; /* input block at ring */ - volatile char zst_rx_overrun; /* ring overrun */ - volatile char zst_tx_busy; /* working on an output chunk */ - volatile char zst_tx_done; /* done with one output chunk */ - volatile char zst_tx_stopped; /* H/W level stop (lost CTS) */ - volatile char zst_st_check; /* got a status interrupt */ - char pad[2]; -}; - - -/* Definition of the driver for autoconfig. */ -static int zstty_match(struct device *, void *, void *); -static void zstty_attach(struct device *, struct device *, void *); - -struct cfattach zstty_ca = { - sizeof(struct zstty_softc), zstty_match, zstty_attach -}; - -struct cfdriver zstty_cd = { - NULL, "zstty", DV_TTY -}; - -struct zsops zsops_tty; - -/* Routines called from other code. */ -cdev_decl(zs); /* open, close, read, write, ioctl, stop, ... */ - -void zsstart(struct tty *); -int zsparam(struct tty *, struct termios *); -void zs_modem(struct zstty_softc *zst, int onoff); -int zshwiflow(struct tty *, int); -void zs_hwiflow(struct zstty_softc *, int); -void zstty_rxint(register struct zs_chanstate *); -void zstty_txint(register struct zs_chanstate *); -void zstty_stint(register struct zs_chanstate *); -void zstty_softint(struct zs_chanstate *); -void zsoverrun(struct zstty_softc *, long *, char *); -/* - * zstty_match: how is this zs channel configured? - */ -static int -zstty_match(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct cfdata *cf = match; - struct zsc_attach_args *args = aux; - - /* Exact match is better than wildcard. */ - if (cf->cf_loc[0] == args->channel) - return 2; - - /* This driver accepts wildcard. */ - if (cf->cf_loc[0] == -1) - return 1; - - return 0; -} - -static void -zstty_attach(parent, self, aux) - struct device *parent, *self; - void *aux; - -{ - struct zsc_softc *zsc = (void *) parent; - struct zstty_softc *zst = (void *) self; - struct zsc_attach_args *args = aux; - struct zs_chanstate *cs; - struct cfdata *cf; - struct tty *tp; - int channel, tty_unit; - dev_t dev; - - tty_unit = zst->zst_dev.dv_unit; - channel = args->channel; - cs = zsc->zsc_cs[channel]; - cs->cs_private = zst; - cs->cs_ops = &zsops_tty; - - zst->zst_cs = cs; - zst->zst_swflags = cf->cf_flags; /* softcar, etc. */ - zst->zst_hwflags = args->hwflags; - dev = makedev(zs_major, tty_unit); - - if (zst->zst_swflags) - printf(" flags 0x%x", zst->zst_swflags); - - if (zst->zst_hwflags & ZS_HWFLAG_CONSOLE) - printf(": console"); - else { -#ifdef KGDB - /* - * Allow kgdb to "take over" this port. If this port is - * NOT the kgdb port, zs_check_kgdb() will return zero. - * If it IS the kgdb port, it will print "kgdb,...\n" - * and then return non-zero. - */ - if (zs_check_kgdb(cs, dev)) { - /* - * This is the kgdb port (exclusive use) - * so skip the normal attach code. - */ - return; - } -#endif - } - printf("\n"); - - tp = ttymalloc(0); - tp->t_dev = dev; - tp->t_oproc = zsstart; - tp->t_param = zsparam; - tp->t_hwiflow = zshwiflow; - - zst->zst_tty = tp; - zst->zst_rbhiwat = zstty_rbuf_size; /* impossible value */ - zst->zst_ringmask = zstty_rbuf_size - 1; - zst->zst_rbuf = malloc(zstty_rbuf_size * sizeof(zst->zst_rbuf[0]), - M_DEVBUF, M_WAITOK); - /* XXX - Do we need an MD hook here? */ - - /* - * Hardware init - */ - if (zst->zst_hwflags & ZS_HWFLAG_CONSOLE) { - /* Call zsparam similar to open. */ - struct termios t; - - /* Make console output work while closed. */ - zst->zst_swflags |= TIOCFLAG_SOFTCAR; - /* Setup the "new" parameters in t. */ - bzero((void*)&t, sizeof(t)); - t.c_cflag = cs->cs_defcflag; - t.c_ospeed = cs->cs_defspeed; - /* Enable interrupts. */ - cs->cs_preg[1] = ZSWR1_RIE | ZSWR1_SIE; - /* Make sure zsparam will see changes. */ - tp->t_ospeed = 0; - (void) zsparam(tp, &t); - } else { - /* Not the console; may need reset. */ - int reset, s; - reset = (channel == 0) ? - ZSWR9_A_RESET : ZSWR9_B_RESET; - s = splzs(); - zs_write_reg(cs, 9, reset); - splx(s); - } - - /* - * Initialize state of modem control lines (DTR). - * If softcar is set, turn on DTR now and leave it. - * otherwise, turn off DTR now, and raise in open. - * (Keeps modem from answering too early.) - */ - zs_modem(zst, (zst->zst_swflags & TIOCFLAG_SOFTCAR) ? 1 : 0); -} - - -/* - * Return pointer to our tty. - */ -struct tty * -zstty(dev) - dev_t dev; -{ - struct zstty_softc *zst; - int unit = minor(dev); - -#ifdef DIAGNOSTIC - if (unit >= zstty_cd.cd_ndevs) - panic("zstty"); -#endif - zst = zstty_cd.cd_devs[unit]; - return (zst->zst_tty); -} - - -/* - * Open a zs serial (tty) port. - */ -int -zsopen(dev, flags, mode, p) - dev_t dev; - int flags; - int mode; - struct proc *p; -{ - register struct tty *tp; - register struct zs_chanstate *cs; - struct zstty_softc *zst; - int error, s, unit; - - unit = minor(dev); - if (unit >= zstty_cd.cd_ndevs) - return (ENXIO); - zst = zstty_cd.cd_devs[unit]; - if (zst == NULL) - return (ENXIO); - tp = zst->zst_tty; - cs = zst->zst_cs; - - /* If KGDB took the line, then tp==NULL */ - if (tp == NULL) - return (EBUSY); - - /* It's simpler to do this up here. */ - if (((tp->t_state & (TS_ISOPEN | TS_XCLUDE)) - == (TS_ISOPEN | TS_XCLUDE)) - && (suser(p, 0) != 0) ) - { - return (EBUSY); - } - - s = spltty(); - - if ((tp->t_state & TS_ISOPEN) == 0) { - /* First open. */ - struct termios t; - - /* - * Setup the "new" parameters in t. - * Can not use tp->t because zsparam - * deals only with what has changed. - */ - bzero((void*)&t, sizeof(t)); - t.c_cflag = cs->cs_defcflag; - if (zst->zst_swflags & TIOCFLAG_CLOCAL) - t.c_cflag |= CLOCAL; - if (zst->zst_swflags & TIOCFLAG_CRTSCTS) - t.c_cflag |= CRTSCTS; - if (zst->zst_swflags & TIOCFLAG_MDMBUF) - t.c_cflag |= MDMBUF; - t.c_ospeed = cs->cs_defspeed; - /* Enable interrupts. */ - cs->cs_preg[1] = ZSWR1_RIE | ZSWR1_SIE; - /* Make sure zsparam will see changes. */ - tp->t_ospeed = 0; - (void) zsparam(tp, &t); - /* - * Note: zsparam has done: cflag, ispeed, ospeed - * so we just need to do: iflag, oflag, lflag, cc - * For "raw" mode, just leave all zeros. - */ - if ((zst->zst_hwflags & ZS_HWFLAG_RAW) == 0) { - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_lflag = TTYDEF_LFLAG; - ttychars(tp); - } - ttsetwater(tp); - /* Flush any pending input. */ - zst->zst_rbget = zst->zst_rbput; - zs_iflush(cs); /* XXX */ - /* DTR was turned on by zsparam. */ - if (zst->zst_swflags & TIOCFLAG_SOFTCAR) { - tp->t_state |= TS_CARR_ON; - } - /* XXX - The MD code could just force CLOCAL instead. */ - if (zst->zst_hwflags & ZS_HWFLAG_NO_DCD) { - tp->t_state |= TS_CARR_ON; - } - } - error = 0; - - /* In this section, we may touch the chip. */ - (void)splzs(); - - /* - * Get initial value of RR0. This is done after we - * raise DTR in case the cable loops DTR back to CTS. - */ - cs->cs_rr0 = zs_read_csr(cs); - - /* - * Wait for DCD (if necessary). Note that we might - * never get status interrupt if DCD is already on. - */ - for (;;) { - /* Check the DCD bit (if we have one). */ - if (cs->cs_rr0 & cs->cs_rr0_dcd) - tp->t_state |= TS_CARR_ON; - - if ((tp->t_state & TS_CARR_ON) || - (tp->t_cflag & CLOCAL) || - (flags & O_NONBLOCK) ) - break; - - /* Sleep waiting for a status interrupt. */ - tp->t_state |= TS_WOPEN; - error = ttysleep(tp, (caddr_t)&tp->t_rawq, - TTIPRI | PCATCH, ttopen, 0); - if (error) { - if ((tp->t_state & TS_ISOPEN) == 0) { - /* Never get here with softcar */ - zs_modem(zst, 0); - tp->t_state &= ~TS_WOPEN; - ttwakeup(tp); - } - break; - } - /* The status interrupt changed cs->cs_rr0 */ - } - - splx(s); - if (error == 0) - error = linesw[tp->t_line].l_open(dev, tp, p); - return (error); -} - -/* - * Close a zs serial port. - */ -int -zsclose(dev, flags, mode, p) - dev_t dev; - int flags; - int mode; - struct proc *p; -{ - struct zstty_softc *zst; - register struct zs_chanstate *cs; - register struct tty *tp; - int hup, s; - - zst = zstty_cd.cd_devs[minor(dev)]; - cs = zst->zst_cs; - tp = zst->zst_tty; - - /* XXX This is for cons.c. */ - if ((tp->t_state & TS_ISOPEN) == 0) - return 0; - - (*linesw[tp->t_line].l_close)(tp, flags, p); - - /* Disable interrupts. */ - s = splzs(); - cs->cs_creg[1] = cs->cs_preg[1] = 0; - zs_write_reg(cs, 1, cs->cs_creg[1]); - splx(s); - - /* Maybe do "hangup" (drop DTR). */ - hup = tp->t_cflag & HUPCL; - if (zst->zst_swflags & TIOCFLAG_SOFTCAR) - hup = 0; - if (hup) { - zs_modem(zst, 0); - /* hold low for 1 second */ - (void) tsleep((caddr_t)cs, TTIPRI, ttclos, hz); - } - if (cs->cs_creg[5] & ZSWR5_BREAK) { - zs_break(cs, 0); - } - - ttyclose(tp); - return (0); -} - -/* - * Read/write zs serial port. - */ -int -zsread(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; -{ - register struct zstty_softc *zst; - register struct tty *tp; - - zst = zstty_cd.cd_devs[minor(dev)]; - tp = zst->zst_tty; - return (linesw[tp->t_line].l_read(tp, uio, flags)); -} - -int -zswrite(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; -{ - register struct zstty_softc *zst; - register struct tty *tp; - - zst = zstty_cd.cd_devs[minor(dev)]; - tp = zst->zst_tty; - return (linesw[tp->t_line].l_write(tp, uio, flags)); -} - -#define TIOCFLAG_ALL (TIOCFLAG_SOFTCAR | TIOCFLAG_CLOCAL | \ - TIOCFLAG_CRTSCTS | TIOCFLAG_MDMBUF ) - -int -zsioctl(dev, cmd, data, flag, p) - dev_t dev; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; -{ - register struct zstty_softc *zst; - register struct zs_chanstate *cs; - register struct tty *tp; - register int error, tmp; - - zst = zstty_cd.cd_devs[minor(dev)]; - cs = zst->zst_cs; - tp = zst->zst_tty; - - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); - if (error >= 0) - return (error); - error = ttioctl(tp, cmd, data, flag, p); - if (error >= 0) - return (error); - - #ifdef ZS_MD_IOCTL - error = ZS_MD_IOCTL; - if (error >= 0) - return (error); - #endif /* ZS_MD_IOCTL */ - - switch (cmd) { - - case TIOCSBRK: - zs_break(cs, 1); - break; - - case TIOCCBRK: - zs_break(cs, 0); - break; - - case TIOCGFLAGS: - *(int *)data = zst->zst_swflags; - break; - - case TIOCSFLAGS: - error = suser(p, 0); - if (error != 0) - return (EPERM); - tmp = *(int *)data; - /* Check for random bits... */ - if (tmp & ~TIOCFLAG_ALL) - return(EINVAL); - /* Silently enforce softcar on the console. */ - if (zst->zst_hwflags & ZS_HWFLAG_CONSOLE) - tmp |= TIOCFLAG_SOFTCAR; - /* These flags take effect during open. */ - zst->zst_swflags = tmp; - break; - - case TIOCSDTR: - zs_modem(zst, 1); - break; - - case TIOCCDTR: - zs_modem(zst, 0); - break; - - case TIOCMSET: - case TIOCMBIS: - case TIOCMBIC: - case TIOCMGET: - default: - return (ENOTTY); - } - return (0); -} - -/* - * Start or restart transmission. - */ -void -zsstart(tp) - register struct tty *tp; -{ - register struct zstty_softc *zst; - register struct zs_chanstate *cs; - register int s, nch; - - zst = zstty_cd.cd_devs[minor(tp->t_dev)]; - cs = zst->zst_cs; - - s = spltty(); - - /* - * If currently active or delaying, no need to do anything. - */ - if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) - goto out; - - /* - * If under CRTSCTS hfc and halted, do nothing - * This flag can only be set with CRTSCTS. - */ - if (zst->zst_tx_stopped) - goto out; - - /* - * If there are sleepers, and output has drained below low - * water mark, awaken. - */ - ttwakeupwr(tp); - - nch = ndqb(&tp->t_outq, 0); /* XXX */ - (void) splzs(); - - if (nch) { - register char *p = tp->t_outq.c_cf; - - /* mark busy, enable tx done interrupts, & send first byte */ - tp->t_state |= TS_BUSY; - zst->zst_tx_busy = 1; - cs->cs_preg[1] |= ZSWR1_TIE; - cs->cs_creg[1] = cs->cs_preg[1]; - zs_write_reg(cs, 1, cs->cs_creg[1]); - zs_write_data(cs, *p); - zst->zst_tba = p + 1; - zst->zst_tbc = nch - 1; - } else { - /* - * Nothing to send, turn off transmit done interrupts. - * This is useful if something is doing polled output. - */ - cs->cs_preg[1] &= ~ZSWR1_TIE; - cs->cs_creg[1] = cs->cs_preg[1]; - zs_write_reg(cs, 1, cs->cs_creg[1]); - } -out: - splx(s); -} - -/* - * Stop output, e.g., for ^S or output flush. - */ -int -zsstop(tp, flag) - struct tty *tp; - int flag; -{ - register struct zstty_softc *zst; - register struct zs_chanstate *cs; - register int s; - - zst = zstty_cd.cd_devs[minor(tp->t_dev)]; - cs = zst->zst_cs; - - s = splzs(); - if (tp->t_state & TS_BUSY) { - /* - * Device is transmitting; must stop it. - * Also clear _heldtbc to prevent any - * flow-control event from resuming. - */ - zst->zst_tbc = 0; - zst->zst_heldtbc = 0; - if ((tp->t_state & TS_TTSTOP) == 0) - tp->t_state |= TS_FLUSH; - } - splx(s); - return (0); -} - -/* - * Set ZS tty parameters from termios. - * XXX - Should just copy the whole termios after - * making sure all the changes could be done. - */ -int -zsparam(tp, t) - register struct tty *tp; - register struct termios *t; -{ - struct zstty_softc *zst; - struct zs_chanstate *cs; - int s, bps, cflag, error; - u_char tmp3, tmp4, tmp5; - - zst = zstty_cd.cd_devs[minor(tp->t_dev)]; - cs = zst->zst_cs; - bps = t->c_ospeed; - cflag = t->c_cflag; - - if (bps < 0 || (t->c_ispeed && t->c_ispeed != bps)) - return (EINVAL); - - /* - * Only whack the UART when params change. - * Some callers need to clear tp->t_ospee - * to make sure initialization gets done. - */ - if ((tp->t_ospeed == bps) && - (tp->t_cflag == cflag) ) - return (0); - - /* - * Call MD functions to deal with changed - * clock modes or H/W flow control modes. - * The BRG divisor is set now. (reg 12,13 - */ - - error = zs_set_speed(cs, bps); - if (error) - return (error); - error = zs_set_modes(cs, cflag); - if (error) - return (error); - - /* OK, we are now committed to do it. */ - tp->t_cflag = cflag; - tp->t_ospeed = bps; - tp->t_ispeed = bps; - - /* - * Block interrupts so that state will not - * be altered until we are done setting it up. - * - * Initial values in cs_preg are set before - * our attach routine is called. The master - * interrupt enable is handled by zsc.c - */ - s = splzs(); - - /* Recompute character size bits. */ - tmp3 = cs->cs_preg[3] & ~ZSWR3_RXSIZE; - tmp5 = cs->cs_preg[5] & ~ZSWR5_TXSIZE; - switch (cflag & CSIZE) { - case CS5: - /* These are |= 0 but let the optimizer deal with it. */ - tmp3 |= ZSWR3_RX_5; - tmp5 |= ZSWR5_TX_5; - break; - case CS6: - tmp3 |= ZSWR3_RX_6; - tmp5 |= ZSWR5_TX_6; - break; - case CS7: - tmp3 |= ZSWR3_RX_7; - tmp5 |= ZSWR5_TX_7; - break; - case CS8: - default: - tmp3 |= ZSWR3_RX_8; - tmp5 |= ZSWR5_TX_8; - break; - } - /* Raise or lower DTR and RTS as appropriate. */ - if (bps) { - /* Raise DTR and RTS */ - tmp5 |= cs->cs_wr5_dtr; - } else { - /* Drop DTR and RTS */ - /* XXX: Should SOFTCAR prevent this? */ - tmp5 &= ~(cs->cs_wr5_dtr); - } - cs->cs_preg[3] = tmp3; - cs->cs_preg[5] = tmp5; - - /* - * Recompute the stop bits and parity bits. Note that - * zs_set_speed() may have set clock selection bits etc. - * in wr4, so those must preserved. - */ - tmp4 = cs->cs_preg[4]; - /* Recompute stop bits. */ - tmp4 &= ~ZSWR4_SBMASK; - tmp4 |= (cflag & CSTOPB) ? - ZSWR4_TWOSB : ZSWR4_ONESB; - /* Recompute parity bits. */ - tmp4 &= ~ZSWR4_PARMASK; - if ((cflag & PARODD) == 0) - tmp4 |= ZSWR4_EVENP; - if (cflag & PARENB) - tmp4 |= ZSWR4_PARENB; - cs->cs_preg[4] = tmp4; - - /* The MD function zs_set_modes handled CRTSCTS, etc. */ - - /* - * If nothing is being transmitted, set up new current values, - * else mark them as pending. - */ - if (cs->cs_heldchange == 0) { - if (zst->zst_tx_busy) { - zst->zst_heldtbc = zst->zst_tbc; - zst->zst_tbc = 0; - cs->cs_heldchange = 0xFFFF; - } else { - zs_loadchannelregs(cs); - } - } - splx(s); - - /* If we can throttle input, enable "high water" detection. */ - if (cflag & CHWFLOW) { - zst->zst_rbhiwat = zstty_rbuf_hiwat; - } else { - /* This impossible value prevents a "high water" trigger. */ - zst->zst_rbhiwat = zstty_rbuf_size; - /* XXX: Lost hwi ability, so unblock and restart. */ - zst->zst_rx_blocked = 0; - if (zst->zst_tx_stopped) { - zst->zst_tx_stopped = 0; - zsstart(tp); - } - } - - return (0); -} - -/* - * Raise or lower modem control (DTR/RTS) signals. If a character is - * in transmission, the change is deferred. - */ -void -zs_modem(zst, onoff) - struct zstty_softc *zst; - int onoff; -{ - struct zs_chanstate *cs; - int s, clr, set; - - cs = zst->zst_cs; - if (cs->cs_wr5_dtr == 0) - return; - - if (onoff) { - clr = 0; - set = cs->cs_wr5_dtr; - } else { - clr = cs->cs_wr5_dtr; - set = 0; - } - - s = splzs(); - cs->cs_preg[5] &= ~clr; - cs->cs_preg[5] |= set; - if (cs->cs_heldchange == 0) { - if (zst->zst_tx_busy) { - zst->zst_heldtbc = zst->zst_tbc; - zst->zst_tbc = 0; - cs->cs_heldchange = (1<<5); - } else { - cs->cs_creg[5] = cs->cs_preg[5]; - zs_write_reg(cs, 5, cs->cs_creg[5]); - } - } - splx(s); -} - -/* - * Try to block or unblock input using hardware flow-control. - * This is called by kern/tty.c if MDMBUF|CRTSCTS is set, and - * if this function returns non-zero, the TS_TBLOCK flag will - * be set or cleared according to the "stop" arg passed. - */ -int -zshwiflow(tp, stop) - struct tty *tp; - int stop; -{ - register struct zstty_softc *zst; - register struct zs_chanstate *cs; - int s; - - zst = zstty_cd.cd_devs[minor(tp->t_dev)]; - cs = zst->zst_cs; - - /* Can not do this without some bit assigned as RTS. */ - if (cs->cs_wr5_rts == 0) - return (0); - - s = splzs(); - if (stop) { - /* - * The tty layer is asking us to block input. - * If we already did it, just return TRUE. - */ - if (zst->zst_rx_blocked) - goto out; - zst->zst_rx_blocked = 1; - } else { - /* - * The tty layer is asking us to resume input. - * The input ring is always empty by now. - */ - zst->zst_rx_blocked = 0; - } - zs_hwiflow(zst, stop); - out: - splx(s); - return 1; -} - -/* - * Internal version of zshwiflow - * called at splzs - */ -void -zs_hwiflow(zst, stop) - register struct zstty_softc *zst; - int stop; -{ - register struct zs_chanstate *cs; - register int clr, set; - - cs = zst->zst_cs; - - if (cs->cs_wr5_rts == 0) - return; - - if (stop) { - /* Block input (Lower RTS) */ - clr = cs->cs_wr5_rts; - set = 0; - } else { - /* Unblock input (Raise RTS) */ - clr = 0; - set = cs->cs_wr5_rts; - } - - cs->cs_preg[5] &= ~clr; - cs->cs_preg[5] |= set; - if (cs->cs_heldchange == 0) { - if (zst->zst_tx_busy) { - zst->zst_heldtbc = zst->zst_tbc; - zst->zst_tbc = 0; - cs->cs_heldchange = (1<<5); - } else { - cs->cs_creg[5] = cs->cs_preg[5]; - zs_write_reg(cs, 5, cs->cs_creg[5]); - } - } -} - - -/**************************************************************** - * Interface to the lower layer (zscc) - ****************************************************************/ - -void zstty_rxint(struct zs_chanstate *); -void zstty_txint(struct zs_chanstate *); -void zstty_stint(struct zs_chanstate *); - -/* - * receiver ready interrupt. - * called at splzs - */ -void -zstty_rxint(cs) - register struct zs_chanstate *cs; -{ - register struct zstty_softc *zst; - register int cc, put, put_next, ringmask; - register u_char c, rr0, rr1; - register u_short ch_rr1; - - zst = cs->cs_private; - put = zst->zst_rbput; - ringmask = zst->zst_ringmask; - -nextchar: - - /* - * First read the status, because reading the received char - * destroys the status of this char. - */ - rr1 = zs_read_reg(cs, 1); - c = zs_read_data(cs); - ch_rr1 = (c << 8) | rr1; - - if (ch_rr1 & (ZSRR1_FE | ZSRR1_DO | ZSRR1_PE)) { - /* Clear the receive error. */ - zs_write_csr(cs, ZSWR0_RESET_ERRORS); - } - - /* XXX: Check for the stop character? */ - - zst->zst_rbuf[put] = ch_rr1; - put_next = (put + 1) & ringmask; - - /* Would overrun if increment makes (put==get). */ - if (put_next == zst->zst_rbget) { - zst->zst_rx_overrun = 1; - } else { - /* OK, really increment. */ - put = put_next; - } - - /* Keep reading until the FIFO is empty. */ - rr0 = zs_read_csr(cs); - if (rr0 & ZSRR0_RX_READY) - goto nextchar; - - /* Done reading. */ - zst->zst_rbput = put; - - /* - * If ring is getting too full, try to block input. - */ - cc = put - zst->zst_rbget; - if (cc < 0) - cc += zstty_rbuf_size; - if ((cc > zst->zst_rbhiwat) && (zst->zst_rx_blocked == 0)) { - zst->zst_rx_blocked = 1; - zs_hwiflow(zst, 1); - } - - /* Ask for softint() call. */ - cs->cs_softreq = 1; -} - -/* - * transmitter ready interrupt. (splzs) - */ -void -zstty_txint(cs) - register struct zs_chanstate *cs; -{ - register struct zstty_softc *zst; - register int count; - - zst = cs->cs_private; - - /* - * If we suspended output for a "held" change, - * then handle that now and resume. - * Do flow-control changes ASAP. - * When the only change is for flow control, - * avoid hitting other registers, because that - * often makes the stupid zs drop input... - */ - if (cs->cs_heldchange) { - if (cs->cs_heldchange == (1<<5)) { - /* Avoid whacking the chip... */ - cs->cs_creg[5] = cs->cs_preg[5]; - zs_write_reg(cs, 5, cs->cs_creg[5]); - } else - zs_loadchannelregs(cs); - cs->cs_heldchange = 0; - count = zst->zst_heldtbc; - } else - count = zst->zst_tbc; - - /* - * If our transmit buffer still has data, - * just send the next character. - */ - if (count > 0) { - /* Send the next char. */ - zst->zst_tbc = --count; - zs_write_data(cs, *zst->zst_tba); - zst->zst_tba++; - return; - } - - zs_write_csr(cs, ZSWR0_RESET_TXINT); - - /* Ask the softint routine for more output. */ - zst->zst_tx_busy = 0; - zst->zst_tx_done = 1; - cs->cs_softreq = 1; -} - -/* - * status change interrupt. (splzs) - */ -void -zstty_stint(cs) - register struct zs_chanstate *cs; -{ - register struct zstty_softc *zst; - register u_char rr0, delta; - - zst = cs->cs_private; - - rr0 = zs_read_csr(cs); - zs_write_csr(cs, ZSWR0_RESET_STATUS); - - /* - * Check here for console break, so that we can abort - * even when interrupts are locking up the machine. - */ - if ((rr0 & ZSRR0_BREAK) && - (zst->zst_hwflags & ZS_HWFLAG_CONSOLE)) - { - zs_abort(cs); - return; - } - - /* - * We have to accumulate status line changes here. - * Otherwise, if we get multiple status interrupts - * before the softint runs, we could fail to notice - * some status line changes in the softint routine. - * Fix from Bill Studenmund, October 1996. - */ - delta = (cs->cs_rr0 ^ rr0); - cs->cs_rr0_delta |= delta; - cs->cs_rr0 = rr0; - - /* - * Need to handle CTS output flow control here. - * Output remains stopped as long as either the - * zst_tx_stopped or TS_TTSTOP flag is set. - * Never restart here; the softint routine will - * do that after things are ready to move. - */ - if ((delta & cs->cs_rr0_cts) && - ((rr0 & cs->cs_rr0_cts) == 0)) - { - zst->zst_tbc = 0; - zst->zst_heldtbc = 0; - zst->zst_tx_stopped = 1; - } - zst->zst_st_check = 1; - - /* Ask for softint() call. */ - cs->cs_softreq = 1; -} - -/* - * Print out a ring or fifo overrun error message. - */ -void -zsoverrun(zst, ptime, what) - struct zstty_softc *zst; - long *ptime; - char *what; -{ - - if (*ptime != time_second) { - *ptime = time_second; - log(LOG_WARNING, "%s: %s overrun\n", - zst->zst_dev.dv_xname, what); - } -} - -/* - * Software interrupt. Called at zssoft - * - * The main job to be done here is to empty the input ring - * by passing its contents up to the tty layer. The ring is - * always emptied during this operation, therefore the ring - * must not be larger than the space after "high water" in - * the tty layer, or the tty layer might drop our input. - * - * Note: an "input blockage" condition is assumed to exist if - * EITHER the TS_TBLOCK flag or zst_rx_blocked flag is set. - */ -void -zstty_softint(cs) - struct zs_chanstate *cs; -{ - register struct zstty_softc *zst; - register struct linesw *line; - register struct tty *tp; - register int get, c, s; - int ringmask, overrun; - register u_short ring_data; - register u_char rr0, delta; - - zst = cs->cs_private; - tp = zst->zst_tty; - line = &linesw[tp->t_line]; - ringmask = zst->zst_ringmask; - overrun = 0; - - /* - * Raise to tty priority while servicing the ring. - */ - s = spltty(); - - if (zst->zst_rx_overrun) { - zst->zst_rx_overrun = 0; - zsoverrun(zst, &zst->zst_rotime, "ring"); - } - - /* - * Copy data from the receive ring into the tty layer. - */ - get = zst->zst_rbget; - while (get != zst->zst_rbput) { - ring_data = zst->zst_rbuf[get]; - get = (get + 1) & ringmask; - - if (ring_data & ZSRR1_DO) - overrun++; - /* low byte of ring_data is rr1 */ - c = (ring_data >> 8) & 0xff; - if (ring_data & ZSRR1_FE) - c |= TTY_FE; - if (ring_data & ZSRR1_PE) - c |= TTY_PE; - - line->l_rint(c, tp); - } - zst->zst_rbget = get; - - /* - * If the overrun flag is set now, it was set while - * copying char/status pairs from the ring, which - * means this was a hardware (fifo) overrun. - */ - if (overrun) { - zsoverrun(zst, &zst->zst_fotime, "fifo"); - } - - /* - * We have emptied the input ring. Maybe unblock input. - * Note: an "input blockage" condition is assumed to exist - * when EITHER zst_rx_blocked or the TS_TBLOCK flag is set, - * so unblock here ONLY if TS_TBLOCK has not been set. - */ - if (zst->zst_rx_blocked && ((tp->t_state & TS_TBLOCK) == 0)) { - (void) splzs(); - zst->zst_rx_blocked = 0; - zs_hwiflow(zst, 0); /* unblock input */ - (void) spltty(); - } - - /* - * Do any deferred work for status interrupts. - * The rr0 was saved in the h/w interrupt to - * avoid another splzs in here. - */ - if (zst->zst_st_check) { - zst->zst_st_check = 0; - - (void) splzs(); - rr0 = cs->cs_rr0; - delta = cs->cs_rr0_delta; - cs->cs_rr0_delta = 0; - (void) spltty(); - - /* Note, the MD code may use DCD for something else. */ - if (delta & cs->cs_rr0_dcd) { - c = ((rr0 & cs->cs_rr0_dcd) != 0); - if (line->l_modem(tp, c) == 0) - zs_modem(zst, c); - } - - /* Note, cs_rr0_cts is set only with H/W flow control. */ - if (delta & cs->cs_rr0_cts) { - /* - * Only do restart here. Stop is handled - * at the h/w interrupt level. - */ - if (rr0 & cs->cs_rr0_cts) { - zst->zst_tx_stopped = 0; - /* tp->t_state &= ~TS_TTSTOP; */ - (*line->l_start)(tp); - } - } - } - - if (zst->zst_tx_done) { - zst->zst_tx_done = 0; - tp->t_state &= ~TS_BUSY; - if (tp->t_state & TS_FLUSH) - tp->t_state &= ~TS_FLUSH; - else - ndflush(&tp->t_outq, zst->zst_tba - - (caddr_t) tp->t_outq.c_cf); - line->l_start(tp); - } - - splx(s); -} - -struct zsops zsops_tty = { - zstty_rxint, /* receive char available */ - zstty_stint, /* external/status */ - zstty_txint, /* xmit buffer empty */ - zstty_softint, /* process software interrupt */ -}; - diff --git a/sys/arch/mac68k/dev/zs.c b/sys/arch/mac68k/dev/zs.c deleted file mode 100644 index 794471d5002..00000000000 --- a/sys/arch/mac68k/dev/zs.c +++ /dev/null @@ -1,1128 +0,0 @@ -/* $OpenBSD: zs.c,v 1.27 2009/03/15 20:40:25 miod Exp $ */ -/* $NetBSD: zs.c,v 1.19 1998/01/12 19:22:18 thorpej Exp $ */ - -/* - * Copyright (c) 1996-1998 Bill Studenmund - * Copyright (c) 1995 Gordon W. Ross - * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * 4. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Gordon Ross - * - * 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. - */ - -/* - * Zilog Z8530 Dual UART driver (machine-dependent part) - * - * Runs two serial lines per chip using slave drivers. - * Plain tty/async lines use the zs_async slave. - * Sun keyboard/mouse uses the zs_kbd/zs_ms slaves. - * Other ports use their own mice & keyboard slaves. - * - * Credits & history: - * - * With NetBSD 1.1, port-mac68k started using a port of the port-sparc - * (port-sun3?) zs.c driver (which was in turn based on code in the - * Berkeley 4.4 Lite release). Bill Studenmund did the port, with - * help from Allen Briggs and Gordon Ross <gwr@netbsd.org>. Noud de - * Brouwer field-tested the driver at a local ISP. - * - * Bill Studenmund and Gordon Ross then ported the machine-independant - * z8530 driver to work with port-mac68k. NetBSD 1.2 contained an - * intermediate version (mac68k using a local, patched version of - * the m.i. drivers), with NetBSD 1.3 containing a full version. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/proc.h> -#include <sys/device.h> -#include <sys/conf.h> -#include <sys/file.h> -#include <sys/ioctl.h> -#include <sys/tty.h> -#include <sys/time.h> -#include <sys/kernel.h> -#include <sys/syslog.h> - -#include <dev/cons.h> - -#include <mac68k/dev/z8530reg.h> -#include <machine/z8530var.h> - -#include <machine/autoconf.h> -#include <machine/cpu.h> -#include <machine/psc.h> -#include <machine/viareg.h> - -#ifdef DDB -#include <ddb/db_var.h> -#endif - -/* Are these in a header file anywhere? */ -/* Booter flags interface */ -#define ZSMAC_RAW 0x01 -#define ZSMAC_LOCALTALK 0x02 -#define ZS_STD_BRG (57600*4) - -#include "zsc.h" /* get the # of zs chips defined */ - -/* - * Some warts needed by z8530tty.c - - */ -int zs_def_cflag = (CREAD | CS8 | HUPCL); -int zs_major = 12; - -/* - * abort detection on console will now timeout after iterating on a loop - * the following # of times. Cheep hack. Also, abort detection is turned - * off after a timeout (i.e. maybe there's not a terminal hooked up). - */ -#define ZSABORT_DELAY 3000000 - -/* - * Define interrupt levels. - */ -#define ZSHARD_PRI 4 /* Wired on the CPU board... */ -/* - * Serial port cards with zs chips on them are actually at the - * NuBus interrupt level, which is lower than 4. But blocking - * level 4 interrupts will block those interrupts too, so level - * 4 is fine. - */ - -/* The layout of this is hardware-dependent (padding, order). */ -struct zschan { - volatile u_char zc_csr; /* ctrl,status, and indirect access */ - u_char zc_xxx0; - u_char zc_xxx1; /* part of the other channel lives here!*/ - u_char zc_xxx2; /* Yea Apple! */ - volatile u_char zc_data; /* data */ - u_char zc_xxx3; - u_char zc_xxx4; - u_char zc_xxx5; -}; - -/* Saved PROM mappings */ -static char *zsaddr[NZSC]; /* See zs_init() */ -/* Flags from cninit() */ -static int zs_hwflags[NZSC][2]; -/* Default speed for each channel */ -static int zs_defspeed[NZSC][2] = { - { 9600, /* tty00 */ - 9600 }, /* tty01 */ -}; -void *zs_conschan = 0; -int zs_consunit; -/* Mac stuff */ -volatile unsigned char *sccA = 0; -int nzsc_attached = 0; /* needed as long as we have spurious - * interrupt problems. - */ - -static struct zschan *zs_get_chan_addr(int zsc_unit, int channel); -void zs_init(void); -int zs_cn_check_speed(int bps); - -static struct zschan * -zs_get_chan_addr(zsc_unit, channel) - int zsc_unit, channel; -{ - char *addr; - struct zschan *zc; - - if (zsc_unit >= NZSC) - return NULL; - addr = zsaddr[zsc_unit]; - if (addr == NULL) - return NULL; - if (channel == 0) { - zc = (struct zschan *)(addr +2); - /* handle the fact the ports are intertwined. */ - } else { - zc = (struct zschan *)(addr); - } - return (zc); -} - - -/* Find PROM mappings (for console support). */ -int zsinited = 0; /* 0 = not, 1 = inited, not attached, 2= attached */ - -void -zs_init() -{ - if ((zsinited == 2)&&(zsaddr[0] != (char *) sccA)) - panic("Moved zs0 address after attached!"); - zsaddr[0] = (char *) sccA; - zsinited = 1; - if (zs_conschan != 0){ /* we might have moved io under the console */ - zs_conschan = zs_get_chan_addr(0, zs_consunit); - /* so recalc the console port */ - } -} - - -/* - * Even though zsparam will set up the clock multiples, etc., we - * still set them here as: 1) mice & keyboards don't use zsparam, - * and 2) the console stuff uses these defaults before device - * attach. - */ - -static u_char zs_init_reg[16] = { - 0, /* 0: CMD (reset, etc.) */ - ZSWR1_RIE | ZSWR1_TIE | ZSWR1_SIE, - 0x18 + ZSHARD_PRI, /* IVECT */ - ZSWR3_RX_8 | ZSWR3_RX_ENABLE, - ZSWR4_CLK_X16 | ZSWR4_ONESB | ZSWR4_EVENP, - ZSWR5_TX_8 | ZSWR5_TX_ENABLE, - 0, /* 6: TXSYNC/SYNCLO */ - 0, /* 7: RXSYNC/SYNCHI */ - 0, /* 8: alias for data port */ - ZSWR9_MASTER_IE, - 0, /*10: Misc. TX/RX control bits */ - ZSWR11_TXCLK_BAUD | ZSWR11_RXCLK_BAUD, - 14, /*12: BAUDLO (default=9600) */ - 0, /*13: BAUDHI (default=9600) */ - ZSWR14_BAUD_ENA, - ZSWR15_BREAK_IE | ZSWR15_DCD_IE | ZSWR15_CTS_IE, -}; - - -/**************************************************************** - * Autoconfig - ****************************************************************/ - -/* Definition of the driver for autoconfig. */ -static int zsc_match(struct device *, void *, void *); -static void zsc_attach(struct device *, struct device *, void *); -static int zsc_print(void *, const char *name); - -struct cfattach zsc_ca = { - sizeof(struct zsc_softc), zsc_match, zsc_attach -}; - -struct cfdriver zsc_cd = { - NULL, "zsc", DV_DULL -}; - -int zshard(void *); -void zssoft(void *); - - -/* - * Is the zs chip present? - */ -static int -zsc_match(parent, vcf, aux) - struct device *parent; - void *vcf; - void *aux; -{ - return 1; -} - -/* - * Attach a found zs. - * - * Match slave number to zs unit number, so that misconfiguration will - * not set up the keyboard as ttya, etc. - */ -static void -zsc_attach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -{ - struct zsc_softc *zsc = (void *)self; - struct zsc_attach_args zsc_args; - volatile struct zschan *zc; - struct xzs_chanstate *xcs; - struct zs_chanstate *cs; - int zsc_unit, channel; - int s, chip, theflags; - - if (!zsinited) - zs_init(); - zsinited = 2; - - zsc_unit = zsc->zsc_dev.dv_unit; - - /* Make sure everything's inited ok. */ - if (zsaddr[zsc_unit] == NULL) - panic("zs_attach: zs%d not mapped", zsc_unit); - - chip = 0; -#ifdef DEBUG - printf(" chip type %d",chip); -#endif - printf("\n"); - - /* - * Initialize software state for each channel. - */ - for (channel = 0; channel < 2; channel++) { - zsc_args.channel = channel; - zsc_args.hwflags = zs_hwflags[zsc_unit][channel]; - xcs = &zsc->xzsc_xcs_store[channel]; - cs = &xcs->xzs_cs; - zsc->zsc_cs[channel] = cs; - - cs->cs_channel = channel; - cs->cs_private = NULL; - cs->cs_ops = &zsops_null; - - zc = zs_get_chan_addr(zsc_unit, channel); - cs->cs_reg_csr = &zc->zc_csr; - cs->cs_reg_data = &zc->zc_data; - - if (channel == 0) /* Double check interrupts are off */ - zs_write_reg(cs, 9, 0); - - bcopy(zs_init_reg, cs->cs_creg, 16); - bcopy(zs_init_reg, cs->cs_preg, 16); - - /* Current BAUD rate generator clock. */ - cs->cs_brg_clk = ZS_STD_BRG; /* RTxC is 230400*16, so use 230400 */ - cs->cs_defspeed = zs_defspeed[zsc_unit][channel]; - cs->cs_defcflag = zs_def_cflag; - - /* Make these correspond to cs_defcflag (-crtscts) */ - cs->cs_rr0_dcd = ZSRR0_DCD; - cs->cs_rr0_cts = 0; - cs->cs_wr5_dtr = ZSWR5_DTR; - cs->cs_wr5_rts = 0; - -#ifdef __notyet__ - cs->cs_slave_type = ZS_SLAVE_NONE; -#endif - - /* Define BAUD rate stuff. */ - xcs->cs_clocks[0].clk = ZS_STD_BRG * 16; - xcs->cs_clocks[0].flags = ZSC_RTXBRG; - xcs->cs_clocks[1].flags = - ZSC_RTXBRG | ZSC_RTXDIV | ZSC_VARIABLE | ZSC_EXTERN; - xcs->cs_clocks[2].flags = ZSC_TRXDIV | ZSC_VARIABLE; - xcs->cs_clock_count = 3; - - if (channel == 0) { - theflags = mac68k_machine.modem_flags; - xcs->cs_clocks[1].clk = mac68k_machine.modem_dcd_clk; - xcs->cs_clocks[2].clk = mac68k_machine.modem_cts_clk; - } else { - theflags = mac68k_machine.print_flags; - xcs->cs_clocks[1].flags = ZSC_VARIABLE; - /* - * Yes, we aren't defining ANY clock source enables for - * the printer's DCD clock in. The hardware won't let - * us use it. But a clock will freak out the chip, so - * we let you set it, telling us to bar interrupts on - * the line. - */ - xcs->cs_clocks[1].clk = mac68k_machine.print_dcd_clk; - xcs->cs_clocks[2].clk = mac68k_machine.print_cts_clk; - } - if (xcs->cs_clocks[1].clk) - zsc_args.hwflags |= ZS_HWFLAG_NO_DCD; - if (xcs->cs_clocks[2].clk) - zsc_args.hwflags |= ZS_HWFLAG_NO_CTS; - -#ifdef DEBUG - printf("zsc%d channel %d: d_speed %6d DCD clk %ld CTS clk %ld", - zsc_unit, channel, cs->cs_defspeed, - xcs->cs_clocks[1].clk, xcs->cs_clocks[2].clk); -#endif - - /* Set defaults in our "extended" chanstate. */ - xcs->cs_csource = 0; - xcs->cs_psource = 0; - xcs->cs_cclk_flag = 0; /* Nothing fancy by default */ - xcs->cs_pclk_flag = 0; - - if (theflags & ZSMAC_RAW) { - zsc_args.hwflags |= ZS_HWFLAG_RAW; -#ifdef DEBUG - printf(" (raw defaults)"); -#endif - } - - /* - * XXX - This might be better done with a "stub" driver - * (to replace zstty) that ignores LocalTalk for now. - */ - if (theflags & ZSMAC_LOCALTALK) { - printf(" shielding from LocalTalk"); - cs->cs_defspeed = 1; - cs->cs_creg[ZSRR_BAUDLO] = cs->cs_preg[ZSRR_BAUDLO] = 0xff; - cs->cs_creg[ZSRR_BAUDHI] = cs->cs_preg[ZSRR_BAUDHI] = 0xff; - zs_write_reg(cs, ZSRR_BAUDLO, 0xff); - zs_write_reg(cs, ZSRR_BAUDHI, 0xff); - /* - * If we might have LocalTalk, then make sure we have - * the Baud rate low-enough to not do any damage. - */ - } - - /* - * We used to disable chip interrupts here, but we now - * do that in zscnprobe, just in case MacOS left the chip on. - */ - - xcs->cs_chip = chip; - - /* Stash away a copy of the final H/W flags. */ - xcs->cs_hwflags = zsc_args.hwflags; - -#ifdef DEBUG - printf("\n"); -#endif - - /* - * Look for a child driver for this channel. - * The child attach will setup the hardware. - */ - if (!config_found(self, (void *)&zsc_args, zsc_print)) { - /* No sub-driver. Just reset it. */ - u_char reset = (channel == 0) ? - ZSWR9_A_RESET : ZSWR9_B_RESET; - s = splzs(); - zs_write_reg(cs, 9, reset); - splx(s); - } - } - - /* XXX - Now safe to install interrupt handlers. */ - - if (current_mac_model->class == MACH_CLASSAV) { - add_psc_lev4_intr(PSCINTR_SCCA, zshard, zsc); - add_psc_lev4_intr(PSCINTR_SCCB, zshard, zsc); - } else { - intr_establish(zshard, zsc, ZSHARD_PRI, self->dv_xname); - } - - zsc->zsc_softih = softintr_establish(IPL_SOFTTTY, zssoft, zsc); - - /* - * Set the master interrupt enable and interrupt vector. - * (common to both channels, do it on A) - */ - cs = zsc->zsc_cs[0]; - s = splzs(); - /* interrupt vector */ - zs_write_reg(cs, 2, zs_init_reg[2]); - /* master interrupt control (enable) */ - zs_write_reg(cs, 9, zs_init_reg[9]); - nzsc_attached++; - splx(s); -} - -static int -zsc_print(aux, name) - void *aux; - const char *name; -{ - struct zsc_attach_args *args = aux; - - if (name != NULL) - printf("%s: ", name); - - if (args->channel != -1) - printf(" channel %d", args->channel); - return UNCONF; -} - -int -zsmdioctl(cs, cmd, data) - struct zs_chanstate *cs; - u_long cmd; - caddr_t data; -{ - switch (cmd) { - default: - return (-1); - } - return (0); -} - -void -zsmd_setclock(cs) - struct zs_chanstate *cs; -{ - struct xzs_chanstate *xcs = (void *)cs; - - if (cs->cs_channel != 0) - return; - - /* - * If the new clock has the external bit set, then select the - * external source. - */ - via_set_modem((xcs->cs_pclk_flag & ZSC_EXTERN) ? 1 : 0); -} - -/* - * Do the minimum work to pull data off of the chip and queue it up - * for later processing. - */ -int -zshard(arg) - void *arg; -{ - struct zsc_softc *zsc = (struct zsc_softc *)arg; - int rr3, rval; - - /* - * The horror: the adb subsystem will invoke us directly. - * However if we were already servicing an interrupt, - * we'll lose bigtime. Don't allow such reentrancy. - */ - static int zshard_busy = 0; - - if (zshard_busy != 0) - return 0; - - if (zsc == NULL) - return 0; - - zshard_busy++; - - rval = 0; - while ((rr3 = zsc_intr_hard(zsc))) - rval |= rr3; - - if ((zsc->zsc_cs[0]->cs_softreq) || (zsc->zsc_cs[1]->cs_softreq)) { - /* zsc_req_softint(zsc); */ - softintr_schedule(zsc->zsc_softih); - } - - zshard_busy--; - - return (rval); -} - -void -zssoft(arg) - void *arg; -{ - struct zsc_softc *zsc = (struct zsc_softc *)arg; - int s; - - s = spltty(); - zsc_intr_soft(zsc); - splx(s); -} - -#ifndef ZS_TOLERANCE -#define ZS_TOLERANCE 51 -/* 5% in tenths of a %, plus 1 so that exactly 5% will be ok. */ -#endif - -/* - * check out a rate for acceptability from the internal clock - * source. Used in console config to validate a requested - * default speed. Placed here so that all the speed checking code is - * in one place. - * - * != 0 means ok. - */ -int -zs_cn_check_speed(bps) - int bps; /* target rate */ -{ - int tc, rate; - - tc = BPS_TO_TCONST(ZS_STD_BRG, bps); - if (tc < 0) - return 0; - rate = TCONST_TO_BPS(ZS_STD_BRG, tc); - if (ZS_TOLERANCE > abs(((rate - bps)*1000)/bps)) - return 1; - else - return 0; -} - -/* - * Search through the signal sources in the channel, and - * pick the best one for the baud rate requested. Return - * a -1 if not achievable in tolerance. Otherwise return 0 - * and fill in the values. - * - * This routine draws inspiration from the Atari port's zs.c - * driver in NetBSD 1.1 which did the same type of source switching. - * Tolerance code inspired by comspeed routine in isa/com.c. - * - * By Bill Studenmund, 1996-05-12 - */ -int -zs_set_speed(cs, bps) - struct zs_chanstate *cs; - int bps; /* bits per second */ -{ - struct xzs_chanstate *xcs = (void *) cs; - int i, tc, tc0 = 0, tc1, s, sf = 0; - int src, rate0, rate1, err, tol; - - if (bps == 0) - return (0); - - src = -1; /* no valid source yet */ - tol = ZS_TOLERANCE; - - /* - * Step through all the sources and see which one matches - * the best. A source has to match BETTER than tol to be chosen. - * Thus if two sources give the same error, the first one will be - * chosen. Also, allow for the possability that one source might run - * both the BRG and the direct divider (i.e. RTxC). - */ - for (i=0; i < xcs->cs_clock_count; i++) { - if (xcs->cs_clocks[i].clk <= 0) - continue; /* skip non-existent or bad clocks */ - if (xcs->cs_clocks[i].flags & ZSC_BRG) { - /* check out BRG at /16 */ - tc1 = BPS_TO_TCONST(xcs->cs_clocks[i].clk >> 4, bps); - if (tc1 >= 0) { - rate1 = TCONST_TO_BPS(xcs->cs_clocks[i].clk >> 4, tc1); - err = abs(((rate1 - bps)*1000)/bps); - if (err < tol) { - tol = err; - src = i; - sf = xcs->cs_clocks[i].flags & ~ZSC_DIV; tc0 = tc1; - rate0 = rate1; - } - } - } - if (xcs->cs_clocks[i].flags & ZSC_DIV) { - /* - * Check out either /1, /16, /32, or /64 - * Note: for /1, you'd better be using a synchronized - * clock! - */ - int b0 = xcs->cs_clocks[i].clk, e0 = abs(b0-bps); - int b1 = b0 >> 4, e1 = abs(b1-bps); - int b2 = b1 >> 1, e2 = abs(b2-bps); - int b3 = b2 >> 1, e3 = abs(b3-bps); - - if (e0 < e1 && e0 < e2 && e0 < e3) { - err = e0; - rate1 = b0; - tc1 = ZSWR4_CLK_X1; - } else if (e0 > e1 && e1 < e2 && e1 < e3) { - err = e1; - rate1 = b1; - tc1 = ZSWR4_CLK_X16; - } else if (e0 > e2 && e1 > e2 && e2 < e3) { - err = e2; - rate1 = b2; - tc1 = ZSWR4_CLK_X32; - } else { - err = e3; - rate1 = b3; - tc1 = ZSWR4_CLK_X64; - } - - err = (err * 1000)/bps; - if (err < tol) { - tol = err; - src = i; - sf = xcs->cs_clocks[i].flags & ~ZSC_BRG; - tc0 = tc1; - rate0 = rate1; - } - } - } -#ifdef ZSMACDEBUG - printf("Checking for rate %d. Found source #%d.\n",bps, src); -#endif - if (src == -1) - return (EINVAL); /* no can do */ - - /* - * The M.I. layer likes to keep cs_brg_clk current, even though - * we are the only ones who should be touching the BRG's rate. - * - * Note: we are assuming that any ZSC_EXTERN signal source comes in - * on the RTxC pin. Correct for the mac68k obio zsc. - */ - if (sf & ZSC_EXTERN) - cs->cs_brg_clk = xcs->cs_clocks[i].clk >> 4; - else - cs->cs_brg_clk = ZS_STD_BRG; - - /* - * Now we have a source, so set it up. - */ - s = splzs(); - xcs->cs_psource = src; - xcs->cs_pclk_flag = sf; - bps = rate0; - if (sf & ZSC_BRG) { - cs->cs_preg[4] = ZSWR4_CLK_X16; - cs->cs_preg[11]= ZSWR11_RXCLK_BAUD | ZSWR11_TXCLK_BAUD; - if (sf & ZSC_PCLK) { - cs->cs_preg[14] = ZSWR14_BAUD_ENA | ZSWR14_BAUD_FROM_PCLK; - } else { - cs->cs_preg[14] = ZSWR14_BAUD_ENA; - } - tc = tc0; - } else { - cs->cs_preg[4] = tc0; - if (sf & ZSC_RTXDIV) { - cs->cs_preg[11] = ZSWR11_RXCLK_RTXC | ZSWR11_TXCLK_RTXC; } else { - cs->cs_preg[11] = ZSWR11_RXCLK_TRXC | ZSWR11_TXCLK_TRXC; } - cs->cs_preg[14]= 0; - tc = 0xffff; - } - /* Set the BAUD rate divisor. */ - cs->cs_preg[12] = tc; - cs->cs_preg[13] = tc >> 8; - splx(s); - -#ifdef ZSMACDEBUG - printf("Rate is %7d, tc is %7d, source no. %2d, flags %4x\n", \ - bps, tc, src, sf); - printf("Registers are: 4 %x, 11 %x, 14 %x\n\n", - cs->cs_preg[4], cs->cs_preg[11], cs->cs_preg[14]); -#endif - - cs->cs_preg[5] |= ZSWR5_RTS; /* Make sure the drivers are on! */ - - /* Caller will stuff the pending registers. */ - return (0); -} - -int -zs_set_modes(cs, cflag) - struct zs_chanstate *cs; - int cflag; /* bits per second */ -{ - struct xzs_chanstate *xcs = (void*)cs; - int s; - - /* - * Make sure we don't enable hfc on a signal line we're ignoring. - * As we enable CTS interrupts only if we have CRTSCTS or CDTRCTS, - * this code also effectivly turns off ZSWR15_CTS_IE. - * - * Also, disable DCD interrupts if we've been told to ignore - * the DCD pin. Happens on mac68k because the input line for - * DCD can also be used as a clock input. (Just set CLOCAL.) - * - * If someone tries to turn an invalid flow mode on, Just Say No - * (Suggested by gwr) - */ -#if 0 - if ((cflag & CDTRCTS) && (cflag & (CRTSCTS | MDMBUF))) - return (EINVAL); -#endif - if (xcs->cs_hwflags & ZS_HWFLAG_NO_DCD) { - if (cflag & MDMBUF) - return (EINVAL); - cflag |= CLOCAL; - } -#if 0 - if ((xcs->cs_hwflags & ZS_HWFLAG_NO_CTS) && (cflag & (CRTSCTS | CDTRCTS))) - return (EINVAL); -#endif - - /* - * Output hardware flow control on the chip is horrendous: - * if carrier detect drops, the receiver is disabled, and if - * CTS drops, the transmitter is stopped IN MID CHARACTER! - * Therefore, NEVER set the HFC bit, and instead use the - * status interrupt to detect CTS changes. - */ - s = splzs(); - if ((cflag & (CLOCAL | MDMBUF)) != 0) - cs->cs_rr0_dcd = 0; - else - cs->cs_rr0_dcd = ZSRR0_DCD; - /* - * The mac hardware only has one output, DTR (HSKo in Mac - * parlance). In HFC mode, we use it for the functions - * typically served by RTS and DTR on other ports, so we - * have to fake the upper layer out some. - * - * CRTSCTS we use CTS as an input which tells us when to shut up. - * We make no effort to shut up the other side of the connection. - * DTR is used to hang up the modem. - * - * In CDTRCTS, we use CTS to tell us to stop, but we use DTR to - * shut up the other side. - */ - if ((cflag & CRTSCTS) != 0){ - cs->cs_wr5_dtr = ZSWR5_DTR; - cs->cs_wr5_rts = 0; - cs->cs_rr0_cts = ZSRR0_CTS; -#if 0 - } else if ((cflag & CDTRCTS) != 0) { - cs->cs_wr5_dtr = 0; - cs->cs_wr5_rts = ZSWR5_DTR; - cs->cs_rr0_cts = ZSRR0_CTS; -#endif - } else if ((cflag & MDMBUF) != 0) { - cs->cs_wr5_dtr = 0; - cs->cs_wr5_rts = ZSWR5_DTR; - cs->cs_rr0_cts = ZSRR0_DCD; - } else { - cs->cs_wr5_dtr = ZSWR5_DTR; - cs->cs_wr5_rts = 0; - cs->cs_rr0_cts = 0; - } - splx(s); - - /* Caller will stuff the pending registers. */ - return(0); -} - -/* - * Read or write the chip with suitable delays. - * MacII hardware has the delay built in. - * No need for extra delay. :-) However, some clock-chiped - * macs, or zsc's on serial add-on boards might need it. - */ -#define ZS_DELAY() - -u_char -zs_read_reg(cs, reg) - struct zs_chanstate *cs; - u_char reg; -{ - u_char val; - - *cs->cs_reg_csr = reg; - ZS_DELAY(); - val = *cs->cs_reg_csr; - ZS_DELAY(); - return val; -} - -void -zs_write_reg(cs, reg, val) - struct zs_chanstate *cs; - u_char reg, val; -{ - *cs->cs_reg_csr = reg; - ZS_DELAY(); - *cs->cs_reg_csr = val; - ZS_DELAY(); -} - -u_char -zs_read_csr(cs) - struct zs_chanstate *cs; -{ - u_char val; - - val = *cs->cs_reg_csr; - ZS_DELAY(); - /* make up for the fact CTS is wired backwards */ - val ^= ZSRR0_CTS; - return val; -} - -void -zs_write_csr(cs, val) - struct zs_chanstate *cs; - register u_char val; -{ - /* Note, the csr does not write CTS... */ - *cs->cs_reg_csr = val; - ZS_DELAY(); -} - -u_char -zs_read_data(cs) - struct zs_chanstate *cs; -{ - register u_char val; - - val = *cs->cs_reg_data; - ZS_DELAY(); - return val; -} - -void -zs_write_data(cs, val) - struct zs_chanstate *cs; - u_char val; -{ - *cs->cs_reg_data = val; - ZS_DELAY(); -} - -/**************************************************************** - * Console support functions (mac68k specific!) - * Note: this code is allowed to know about the layout of - * the chip registers, and uses that to keep things simple. - * XXX - I think I like the mvme167 code better. -gwr - * XXX - Well :-P :-) -wrs - ****************************************************************/ - -#define zscnpollc nullcnpollc -cons_decl(zs); - -static void zs_putc(register volatile struct zschan *, int); -static int zs_getc(register volatile struct zschan *); -static void zscnsetup(void); -extern int zsopen( dev_t dev, int flags, int mode, struct proc *p); - -/* - * Console functions. - */ - -/* - * This code modled after the zs_setparam routine in zskgdb - * It sets the console unit to a known state so we can output - * correctly. - */ -static void -zscnsetup() -{ - struct xzs_chanstate xcs; - struct zs_chanstate *cs; - struct zschan *zc; - int tconst, s; - - /* Setup temporary chanstate. */ - bzero((caddr_t)&xcs, sizeof(xcs)); - cs = &xcs.xzs_cs; - zc = zs_conschan; - cs->cs_reg_csr = &zc->zc_csr; - cs->cs_reg_data = &zc->zc_data; - cs->cs_channel = zs_consunit; - cs->cs_brg_clk = ZS_STD_BRG; - - bcopy(zs_init_reg, cs->cs_preg, 16); - cs->cs_preg[5] |= ZSWR5_DTR | ZSWR5_RTS; - cs->cs_preg[15] = ZSWR15_BREAK_IE; - tconst = BPS_TO_TCONST(cs->cs_brg_clk, - zs_defspeed[0][zs_consunit]); - cs->cs_preg[12] = tconst; - cs->cs_preg[13] = tconst >> 8; - /* can't use zs_set_speed as we haven't set up the - * signal sources, and it's not worth it for now - */ - - /* - * As zs_loadchannelregs doesn't touch reg 9 (interrupt control), - * we won't accidentally turn on interrupts below - */ - s = splhigh(); - zs_loadchannelregs(cs); - splx(s); -} - -/* - * zscnprobe is the routine which gets called as the kernel is trying to - * figure out where the console should be. Each io driver which might - * be the console (as defined in mac68k/conf.c) gets probed. The probe - * fills in the consdev structure. Important parts are the device #, - * and the console priority. Values are CN_DEAD (don't touch me), - * CN_LOWPRI (I'm here, but elsewhere might be better), CN_MIDPRI - * (the video, better than CN_LOWPRI), and CN_HIGHPRI (pick me!) - * - * As the mac's a bit different, we do extra work here. We mainly check - * to see if we have serial echo going on. Also chould check for default - * speeds. - */ -void -zscnprobe(struct consdev * cp) -{ - extern u_long IOBase; - int maj, unit, i; - - for (maj = 0; maj < nchrdev; maj++) { - if (cdevsw[maj].d_open == zsopen) { - break; - } - } - if (maj != nchrdev) { - cp->cn_pri = CN_LOWPRI; - if (mac68k_machine.serial_console != 0) { - cp->cn_pri = CN_HIGHPRI; - mac68k_machine.serial_boot_echo =0; - } - - unit = (mac68k_machine.serial_console == 1) ? 0 : 1; - zs_consunit = unit; - zs_conschan = (struct zschan *) -1; /* dummy flag for zs_init() */ - - cp->cn_dev = makedev(maj, unit); - } - if (mac68k_machine.serial_boot_echo) { - /* - * at this point, we know that we don't have a serial - * console, but are doing echo - */ - zs_conschan = (struct zschan *) -1; /* dummy flag for zs_init() */ - zs_consunit = 1; /* printer port */ - } - - if ((i = mac68k_machine.modem_d_speed) > 0) { - if (zs_cn_check_speed(i)) - zs_defspeed[0][0] = i; - } - if ((i = mac68k_machine.print_d_speed) > 0) { - if (zs_cn_check_speed(i)) - zs_defspeed[0][1] = i; - } - mac68k_set_io_offsets(IOBase); - zs_init(); - /* - * zsinit will set up the addresses of the scc. It will also, if - * zs_conschan != 0, calculate the new address of the conschan for - * unit zs_consunit. So if we are (or think we are) going to use the - * chip for console I/O, we just set up the internal addresses for it. - * - * Now turn off interrupts for the chip. Note: this code piece is the - * only vestage of the NetBSD 1.0 ser driver. :-) - */ - unit = sccA[2]; /* reset reg. access */ - unit = sccA[0]; - sccA[2] = 9; sccA[2] = 0; /* write 0 to reg. 9, clearing MIE */ - sccA[2] = ZSWR0_CLR_INTR; unit = sccA[2]; /* reset any pending ints. */ - sccA[0] = ZSWR0_CLR_INTR; unit = sccA[0]; - - if (mac68k_machine.serial_boot_echo) - zscnsetup(); -} - -void -zscninit(struct consdev * cp) -{ - zs_hwflags[0][zs_consunit] = ZS_HWFLAG_CONSOLE; - /* - * zsinit will set up the addresses of the scc. It will also, if - * zs_conschan != 0, calculate the new address of the conschan for - * unit zs_consunit. So zs_init implicitly sets zs_conschan to the right - * number. :-) - */ - zscnsetup(); -} - - -/* - * Polled input char. - */ -static int -zs_getc(zc) - register volatile struct zschan *zc; -{ - register int s, c, rr0; - - s = splhigh(); - /* Wait for a character to arrive. */ - do { - rr0 = zc->zc_csr; - ZS_DELAY(); - } while ((rr0 & ZSRR0_RX_READY) == 0); - - c = zc->zc_data; - ZS_DELAY(); - splx(s); - - return (c); -} - -/* - * Polled output char. - */ -static void -zs_putc(zc, c) - register volatile struct zschan *zc; - int c; -{ - register int s, rr0; - register long wait = 0; - - s = splhigh(); - /* Wait for transmitter to become ready. */ - do { - rr0 = zc->zc_csr; - ZS_DELAY(); - } while (((rr0 & ZSRR0_TX_READY) == 0) && (wait++ < 1000000)); - - if ((rr0 & ZSRR0_TX_READY) != 0) { - zc->zc_data = c; - ZS_DELAY(); - } - splx(s); -} - - -/* - * Polled console input putchar. - */ -int -zscngetc(dev) - dev_t dev; -{ - register volatile struct zschan *zc = zs_conschan; - register int c; - - c = zs_getc(zc); - return (c); -} - -/* - * Polled console output putchar. - */ -void -zscnputc(dev, c) - dev_t dev; - int c; -{ - register volatile struct zschan *zc = zs_conschan; - - zs_putc(zc, c); -} - - - -/* - * Handle user request to enter kernel debugger. - */ -void -zs_abort(cs) - struct zs_chanstate *cs; -{ - volatile struct zschan *zc = zs_conschan; - int rr0; - register long wait = 0; - - /* Wait for end of break to avoid PROM abort. */ - do { - rr0 = zc->zc_csr; - ZS_DELAY(); - } while ((rr0 & ZSRR0_BREAK) && (wait++ < ZSABORT_DELAY)); - - if (wait > ZSABORT_DELAY) - return; /* XXX */ -#ifdef DDB - if (db_console) - Debugger(); -#endif -} diff --git a/sys/arch/mac68k/dev/zsvar.h b/sys/arch/mac68k/dev/zsvar.h deleted file mode 100644 index a016be646c4..00000000000 --- a/sys/arch/mac68k/dev/zsvar.h +++ /dev/null @@ -1,153 +0,0 @@ -/* $OpenBSD: zsvar.h,v 1.4 2003/06/02 23:27:49 millert Exp $ */ -/* $NetBSD: zsvar.h,v 1.2 1995/12/13 03:08:12 briggs Exp $ */ - -/* - * Copyright (c) 1994 Gordon W. Ross - * 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: - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)zsvar.h 8.1 (Berkeley) 6/11/93 - */ - -/* - * Software state, per zs channel. - * - * The zs chip has insufficient buffering, so we provide a software - * buffer using a two-level interrupt scheme. The hardware (high priority) - * interrupt simply grabs the `cause' of the interrupt and stuffs it into - * a ring buffer. It then schedules a software interrupt; the latter - * empties the ring as fast as it can, hoping to avoid overflow. - * - * Interrupts can happen because of: - * - received data; - * - transmit pseudo-DMA done; and - * - status change. - * These are all stored together in the (single) ring. The size of the - * ring is a power of two, to make % operations fast. Since we need two - * bits to distinguish the interrupt type, and up to 16 for the received - * data plus RR1 status, we use 32 bits per ring entry. - * - * When the value is a character + RR1 status, the character is in the - * upper 8 bits of the RR1 status. - */ -#define ZLRB_RING_SIZE 512 /* ZS line ring buffer size */ -#define ZLRB_RING_MASK 511 /* mask for same */ - -/* 0 is reserved (means "no interrupt") */ -#define ZRING_RINT 1 /* receive data interrupt */ -#define ZRING_XINT 2 /* transmit done interrupt */ -#define ZRING_SINT 3 /* status change interrupt */ - -#define ZRING_TYPE(x) ((x) & 3) -#define ZRING_VALUE(x) ((x) >> 8) -#define ZRING_MAKE(t, v) ((t) | (v) << 8) - -struct zs_chanstate { - struct zs_chanstate *cs_next; /* linked list for zshard() */ - volatile struct zschan *cs_zc; /* points to hardware regs */ - int cs_unit; /* unit number */ - struct tty *cs_ttyp; /* ### */ - - /* - * We must keep a copy of the write registers as they are - * mostly write-only and we sometimes need to set and clear - * individual bits (e.g., in WR3). Not all of these are - * needed but 16 bytes is cheap and this makes the addressing - * simpler. Unfortunately, we can only write to some registers - * when the chip is not actually transmitting, so whenever - * we are expecting a `transmit done' interrupt the preg array - * is allowed to `get ahead' of the current values. In a - * few places we must change the current value of a register, - * rather than (or in addition to) the pending value; for these - * cs_creg[] contains the current value. - */ - u_char cs_creg[16]; /* current values */ - u_char cs_preg[16]; /* pending values */ - u_char cs_heldchange; /* change pending (creg != preg) */ - u_char cs_rr0; /* last rr0 processed */ - u_char cs_rr0_mask; /* xor mask for inverted status bits */ - u_char cs_SFC; /* do Software-based CTS Flow Control? */ - u_char cs_holdSFC; /* Are we holding transmission for CTS to assert? */ - u_char cs_tiu; /* transmitter in use (char. being sent) */ - - /* pure software data, per channel */ - char cs_softcar; /* software carrier */ - char cs_conk; /* is console keyboard, decode L1-A */ - char cs_brkabort; /* abort (as if via L1-A) on BREAK */ - char cs_kgdb; /* enter debugger on frame char */ - char cs_consio; /* port does /dev/console I/O */ - char cs_xxx; /* (spare) */ - int cs_speed; /* default baud rate (from ROM) */ - - /* - * The transmit byte count and address are used for pseudo-DMA - * output in the hardware interrupt code. PDMA can be suspended - * to get pending changes done; heldtbc is used for this. It can - * also be stopped for ^S; this sets TS_TTSTOP in tp->t_state. - */ - int cs_tbc; /* transmit byte count */ - caddr_t cs_tba; /* transmit buffer address */ - int cs_heldtbc; /* held tbc while xmission stopped */ - - /* - * Printing an overrun error message often takes long enough to - * cause another overrun, so we only print one per second. - */ - long cs_rotime; /* time of last ring overrun */ - long cs_fotime; /* time of last fifo overrun */ - - /* - * The ring buffer. - */ - u_int cs_rbget; /* ring buffer `get' index */ - volatile u_int cs_rbput; /* ring buffer `put' index */ - long cs_rbuf[ZLRB_RING_SIZE];/* type, value pairs */ -}; - -/* - * N.B.: the keyboard is channel 1, the mouse channel 0; ttyb is 1, ttya - * is 0. In other words, the things are BACKWARDS. - */ -#define ZS_CHAN_A 1 -#define ZS_CHAN_B 0 - -/* - * Macros to read and write individual registers (except 0) in a channel. - * The ZS chip requires a 1.6 uSec. recovery time between accesses. - */ -#define ZS_READ(c, r) zs_read(c, r) -#define ZS_WRITE(c, r, v) zs_write(c, r, v) -#define ZS_DELAY() delay2us() diff --git a/sys/arch/mac68k/include/_types.h b/sys/arch/mac68k/include/_types.h deleted file mode 100644 index 35b1108bd5b..00000000000 --- a/sys/arch/mac68k/include/_types.h +++ /dev/null @@ -1,10 +0,0 @@ -/* $OpenBSD: _types.h,v 1.2 2011/03/23 16:54:35 pirofti Exp $ */ - -/* public domain */ - -#ifndef _MACHINE__TYPES_H_ -#define _MACHINE__TYPES_H_ - -#include <m68k/_types.h> - -#endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/mac68k/include/asm.h b/sys/arch/mac68k/include/asm.h deleted file mode 100644 index 95c23293bbe..00000000000 --- a/sys/arch/mac68k/include/asm.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $OpenBSD: asm.h,v 1.4 2011/03/23 16:54:35 pirofti Exp $ */ -/* $NetBSD: asm.h,v 1.2 1994/10/26 08:46:25 cgd Exp $ */ - -#ifndef _MACHINE_ASM_H_ -#define _MACHINE_ASM_H_ - -#include <m68k/asm.h> - -#endif diff --git a/sys/arch/mac68k/include/atomic.h b/sys/arch/mac68k/include/atomic.h deleted file mode 100644 index c62462c7c3a..00000000000 --- a/sys/arch/mac68k/include/atomic.h +++ /dev/null @@ -1,10 +0,0 @@ -/* $OpenBSD: atomic.h,v 1.3 2011/03/23 16:54:35 pirofti Exp $ */ - -/* Public Domain */ - -#ifndef _MACHINE_ATOMIC_H_ -#define _MACHINE_ATOMIC_H_ - -#include <m68k/atomic.h> - -#endif /* _MACHINE_ATOMIC_H_ */ diff --git a/sys/arch/mac68k/include/autoconf.h b/sys/arch/mac68k/include/autoconf.h deleted file mode 100644 index 863e6ebf4fd..00000000000 --- a/sys/arch/mac68k/include/autoconf.h +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: autoconf.h,v 1.15 2011/03/23 16:54:35 pirofti Exp $ */ -/* $NetBSD: autoconf.h,v 1.5 1996/12/17 06:47:40 scottr Exp $ */ - -/* - * Copyright (c) 1994 Gordon W. Ross - * Copyright (c) 1993 Adam Glass - * 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 Adam Glass. - * 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 Adam Glass ``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. - */ - -#ifndef _MACHINE_AUTOCONF_H_ -#define _MACHINE_AUTOCONF_H_ - -/* - * Autoconfiguration information. - * From sun3 port--adapted for mac68k platform by Allen Briggs. - */ - -#ifdef _KERNEL -/* machdep.c */ -void mac68k_set_io_offsets(vaddr_t); -void dumpconf(void); - -/* clock.h */ - -u_long clkread(void); -void mac68k_calibrate_delay(void); -void startrtclock(void); - -#endif /* _KERNEL */ - -#endif /* _MACHINE_AUTOCONF_H_ */ diff --git a/sys/arch/mac68k/include/bus.h b/sys/arch/mac68k/include/bus.h deleted file mode 100644 index af7d89dc0dc..00000000000 --- a/sys/arch/mac68k/include/bus.h +++ /dev/null @@ -1,434 +0,0 @@ -/* $OpenBSD: bus.h,v 1.15 2011/03/23 16:54:35 pirofti Exp $ */ -/* $NetBSD: bus.h,v 1.9 1998/01/13 18:32:15 scottr Exp $ */ - -/*- - * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (C) 1997 Scott Reynolds. 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. 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. - */ - -#ifndef _MACHINE_BUS_H_ -#define _MACHINE_BUS_H_ - -/* - * Value for the mac68k bus space tag, not to be used directly by MI code. - */ -#define MAC68K_BUS_SPACE_MEM 0 /* space is mem space */ - -/* - * Bus address and size types - */ -typedef u_long bus_addr_t; -typedef u_long bus_size_t; - -/* - * Access methods for bus resources and address space. - */ -#define BSH_T struct bus_space_handle_s -typedef int bus_space_tag_t; -typedef struct bus_space_handle_s { - u_long base; - int swapped; - - u_int8_t (*bsr1)(bus_space_tag_t, BSH_T *, bus_size_t); - u_int16_t (*bsr2)(bus_space_tag_t, BSH_T *, bus_size_t); - u_int32_t (*bsr4)(bus_space_tag_t, BSH_T *, bus_size_t); - void (*bsrm1)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int8_t *, size_t); - void (*bsrm2)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int16_t *, size_t); - void (*bsrm4)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int32_t *, size_t); - void (*bsrms2)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int16_t *, size_t); - void (*bsrms4)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int32_t *, size_t); - void (*bsrr1)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int8_t *, size_t); - void (*bsrr2)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int16_t *, size_t); - void (*bsrr4)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int32_t *, size_t); - void (*bsrrs1)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int8_t *, size_t); - void (*bsrrs2)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int16_t *, size_t); - void (*bsrrs4)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int32_t *, size_t); - void (*bsw1)(bus_space_tag_t, BSH_T *, bus_size_t, u_int8_t); - void (*bsw2)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int16_t); - void (*bsw4)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int32_t); - void (*bswm1)(bus_space_tag_t, BSH_T *, bus_size_t, - const u_int8_t *, size_t); - void (*bswm2)(bus_space_tag_t, BSH_T *, bus_size_t, - const u_int16_t *, size_t); - void (*bswm4)(bus_space_tag_t, BSH_T *, bus_size_t, - const u_int32_t *, size_t); - void (*bswms1)(bus_space_tag_t, BSH_T *, bus_size_t, - const u_int8_t *, size_t); - void (*bswms2)(bus_space_tag_t, BSH_T *, bus_size_t, - const u_int16_t *, size_t); - void (*bswms4)(bus_space_tag_t, BSH_T *, bus_size_t, - const u_int32_t *, size_t); - void (*bswr1)(bus_space_tag_t, BSH_T *, bus_size_t, - const u_int8_t *, size_t); - void (*bswr2)(bus_space_tag_t, BSH_T *, bus_size_t, - const u_int16_t *, size_t); - void (*bswr4)(bus_space_tag_t, BSH_T *, bus_size_t, - const u_int32_t *, size_t); - void (*bswrs1)(bus_space_tag_t, BSH_T *, bus_size_t, - const u_int8_t *, size_t); - void (*bswrs2)(bus_space_tag_t, BSH_T *, bus_size_t, - const u_int16_t *, size_t); - void (*bswrs4)(bus_space_tag_t, BSH_T *, bus_size_t, - const u_int32_t *, size_t); - void (*bssm1)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int8_t v, size_t); - void (*bssm2)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int16_t v, size_t); - void (*bssm4)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int32_t v, size_t); - void (*bssr1)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int8_t v, size_t); - void (*bssr2)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int16_t v, size_t); - void (*bssr4)(bus_space_tag_t, BSH_T *, bus_size_t, - u_int32_t v, size_t); -} bus_space_handle_t; -#undef BSH_T - -void mac68k_bus_space_handle_swapped(bus_space_tag_t, - bus_space_handle_t *h); - -/* - * int bus_space_map(bus_space_tag_t t, bus_addr_t addr, - * bus_size_t size, int flags, bus_space_handle_t *bshp); - * - * Map a region of bus space. - */ - -#define BUS_SPACE_MAP_CACHEABLE 0x01 -#define BUS_SPACE_MAP_LINEAR 0x02 -#define BUS_SPACE_MAP_PREFETCHABLE 0x04 - -int bus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t, - int, bus_space_handle_t *); - -/* - * void bus_space_unmap(bus_space_tag_t t, - * bus_space_handle_t bsh, bus_size_t size); - * - * Unmap a region of bus space. - */ - -void bus_space_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t); - -/* - * int bus_space_subregion(bus_space_tag_t t, - * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size, - * bus_space_handle_t *nbshp); - * - * Get a new handle for a subregion of an already-mapped area of bus space. - */ - -int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh, - bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp); - -/* - * int bus_space_alloc(bus_space_tag_t t, bus_addr_t, rstart, - * bus_addr_t rend, bus_size_t size, bus_size_t align, - * bus_size_t boundary, int flags, bus_addr_t *addrp, - * bus_space_handle_t *bshp); - * - * Allocate a region of bus space. - */ - -int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, - bus_addr_t rend, bus_size_t size, bus_size_t align, - bus_size_t boundary, int flags, bus_addr_t *addrp, - bus_space_handle_t *bshp); - -/* - * int bus_space_free(bus_space_tag_t t, - * bus_space_handle_t bsh, bus_size_t size); - * - * Free a region of bus space. - */ - -void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh, - bus_size_t size); - -/* - * int mac68k_bus_space_probe(bus_space_tag_t t, - * bus_space_handle_t bsh, bus_size_t offset, int sz); - * - * Probe the bus at t/bsh/offset, using sz as the size of the load. - * - * This is a machine-dependent extension, and is not to be used by - * machine-independent code. - */ - -int mac68k_bus_space_probe(bus_space_tag_t t, - bus_space_handle_t bsh, bus_size_t offset, int sz); - -/* - * u_intN_t bus_space_read_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset); - * - * Read a 1, 2, 4, or 8 byte quantity from bus space - * described by tag/handle/offset. - */ - -u_int8_t mac68k_bsr1(bus_space_tag_t tag, bus_space_handle_t *bsh, - bus_size_t offset); -u_int16_t mac68k_bsr2(bus_space_tag_t tag, bus_space_handle_t *bsh, - bus_size_t offset); -u_int16_t mac68k_bsr2_swap(bus_space_tag_t tag, bus_space_handle_t *bsh, - bus_size_t offset); -u_int32_t mac68k_bsr4(bus_space_tag_t tag, bus_space_handle_t *bsh, - bus_size_t offset); -u_int32_t mac68k_bsr4_swap(bus_space_tag_t tag, bus_space_handle_t *bsh, - bus_size_t offset); - -#define bus_space_read_1(t,h,o) (h).bsr1((t), &(h), (o)) -#define bus_space_read_2(t,h,o) (h).bsr2((t), &(h), (o)) -#define bus_space_read_4(t,h,o) (h).bsr4((t), &(h), (o)) - -/* - * void bus_space_read_multi_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * u_intN_t *addr, size_t count); - * - * Read `count' 1, 2, 4, or 8 byte quantities from bus space - * described by tag/handle/offset and copy into buffer provided. - */ - -void mac68k_bsrm1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - u_int8_t *, size_t); -void mac68k_bsrm2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - u_int16_t *, size_t); -void mac68k_bsrm2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - u_int16_t *, size_t); -void mac68k_bsrm4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - u_int32_t *, size_t); -void mac68k_bsrms4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - u_int32_t *, size_t); -void mac68k_bsrm4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - u_int32_t *, size_t); - -#define bus_space_read_multi_1(t, h, o, a, c) (h).bsrm1(t, &(h), o, a, c) -#define bus_space_read_multi_2(t, h, o, a, c) (h).bsrm2(t, &(h), o, a, c) -#define bus_space_read_multi_4(t, h, o, a, c) (h).bsrm4(t, &(h), o, a, c) - -/* - * void bus_space_read_region_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * u_intN_t *addr, size_t count); - * - * Read `count' 1, 2, 4, or 8 byte quantities from bus space - * described by tag/handle and starting at `offset' and copy into - * buffer provided. - */ - -void mac68k_bsrr1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - u_int8_t *, size_t); -void mac68k_bsrr2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - u_int16_t *, size_t); -void mac68k_bsrr2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - u_int16_t *, size_t); -void mac68k_bsrr4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - u_int32_t *, size_t); -void mac68k_bsrr4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - u_int32_t *, size_t); - -#define bus_space_read_region_1(t, h, o, a, c) (h).bsrr1(t,&(h),o,a,c) -#define bus_space_read_region_2(t, h, o, a, c) (h).bsrr2(t,&(h),o,a,c) -#define bus_space_read_region_4(t, h, o, a, c) (h).bsrr4(t,&(h),o,a,c) - -/* - * void bus_space_write_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * u_intN_t value); - * - * Write the 1, 2, 4, or 8 byte value `value' to bus space - * described by tag/handle/offset. - */ - -void mac68k_bsw1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, u_int8_t); -void mac68k_bsw2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, u_int16_t); -void mac68k_bsw2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - u_int16_t); -void mac68k_bsw4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, u_int32_t); -void mac68k_bsw4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - u_int32_t); - -#define bus_space_write_1(t, h, o, v) (h).bsw1(t, &(h), o, v) -#define bus_space_write_2(t, h, o, v) (h).bsw2(t, &(h), o, v) -#define bus_space_write_4(t, h, o, v) (h).bsw4(t, &(h), o, v) - -/* - * void bus_space_write_multi_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * const u_intN_t *addr, size_t count); - * - * Write `count' 1, 2, 4, or 8 byte quantities from the buffer - * provided to bus space described by tag/handle/offset. - */ - -void mac68k_bswm1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - const u_int8_t *, size_t); -void mac68k_bswm2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - const u_int16_t *, size_t); -void mac68k_bswm2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - const u_int16_t *, size_t); -void mac68k_bswm4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - const u_int32_t *, size_t); -void mac68k_bswm4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - const u_int32_t *, size_t); - -#define bus_space_write_multi_1(t, h, o, a, c) (h).bswm1(t, &(h), o, a, c) -#define bus_space_write_multi_2(t, h, o, a, c) (h).bswm2(t, &(h), o, a, c) -#define bus_space_write_multi_4(t, h, o, a, c) (h).bswm4(t, &(h), o, a, c) - -/* - * void bus_space_write_region_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * const u_intN_t *addr, size_t count); - * - * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided - * to bus space described by tag/handle starting at `offset'. - */ - -void mac68k_bswr1(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - const u_int8_t *, size_t); -void mac68k_bswr2(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - const u_int16_t *, size_t); -void mac68k_bswr2_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - const u_int16_t *, size_t); -void mac68k_bswr4(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - const u_int32_t *, size_t); -void mac68k_bswr4_swap(bus_space_tag_t, bus_space_handle_t *, bus_size_t, - const u_int32_t *, size_t); - -#define bus_space_write_region_1(t, h, o, a, c) (h).bswr1(t, &(h), o, a, c) -#define bus_space_write_region_2(t, h, o, a, c) (h).bswr2(t, &(h), o, a, c) -#define bus_space_write_region_4(t, h, o, a, c) (h).bswr4(t, &(h), o, a, c) - -/* - * void bus_space_set_multi_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val, - * size_t count); - * - * Write the 1, 2, 4, or 8 byte value `val' to bus space described - * by tag/handle/offset `count' times. - */ - -void mac68k_bssm1(bus_space_tag_t t, bus_space_handle_t *h, - bus_size_t o, u_int8_t v, size_t c); -void mac68k_bssm2(bus_space_tag_t t, bus_space_handle_t *h, - bus_size_t o, u_int16_t v, size_t c); -void mac68k_bssm2_swap(bus_space_tag_t t, bus_space_handle_t *h, - bus_size_t o, u_int16_t v, size_t c); -void mac68k_bssm4(bus_space_tag_t t, bus_space_handle_t *h, - bus_size_t o, u_int32_t v, size_t c); -void mac68k_bssm4_swap(bus_space_tag_t t, bus_space_handle_t *h, - bus_size_t o, u_int32_t v, size_t c); - -#define bus_space_set_multi_1(t, h, o, val, c) (h).bssm1(t, &(h), o, val, c) -#define bus_space_set_multi_2(t, h, o, val, c) (h).bssm2(t, &(h), o, val, c) -#define bus_space_set_multi_4(t, h, o, val, c) (h).bssm4(t, &(h), o, val, c) - -/* - * void bus_space_set_region_N(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val, - * size_t count); - * - * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described - * by tag/handle starting at `offset'. - */ - -void mac68k_bssr1(bus_space_tag_t t, bus_space_handle_t *h, - bus_size_t o, u_int8_t v, size_t c); -void mac68k_bssr2(bus_space_tag_t t, bus_space_handle_t *h, - bus_size_t o, u_int16_t v, size_t c); -void mac68k_bssr2_swap(bus_space_tag_t t, bus_space_handle_t *h, - bus_size_t o, u_int16_t v, size_t c); -void mac68k_bssr4(bus_space_tag_t t, bus_space_handle_t *h, - bus_size_t o, u_int32_t v, size_t c); -void mac68k_bssr4_swap(bus_space_tag_t t, bus_space_handle_t *h, - bus_size_t o, u_int32_t v, size_t c); - -#define bus_space_set_region_1(t, h, o, val, c) (h).bssr1(t, &(h), o, val, c) -#define bus_space_set_region_2(t, h, o, val, c) (h).bssr2(t, &(h), o, val, c) -#define bus_space_set_region_4(t, h, o, val, c) (h).bssr4(t, &(h), o, val, c) - -/* - * Bus read/write barrier methods. - * - * void bus_space_barrier(bus_space_tag_t tag, - * bus_space_handle_t bsh, bus_size_t offset, - * bus_size_t len, int flags); - * - * Note: the 680x0 does not currently require barriers, but we must - * provide the flags to MI code. - */ -#define bus_space_barrier(t, h, o, l, f) \ - ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f))) -#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ -#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ - -#define bus_space_vaddr(t, h) (void *)((h).base) - -#endif /* _MACHINE_BUS_H_ */ diff --git a/sys/arch/mac68k/include/cdefs.h b/sys/arch/mac68k/include/cdefs.h deleted file mode 100644 index 5c9b2fcc416..00000000000 --- a/sys/arch/mac68k/include/cdefs.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $OpenBSD: cdefs.h,v 1.6 2011/03/23 16:54:36 pirofti Exp $ */ -/* public domain */ -#include <m68k/cdefs.h> diff --git a/sys/arch/mac68k/include/cpu.h b/sys/arch/mac68k/include/cpu.h deleted file mode 100644 index ccb64ea8219..00000000000 --- a/sys/arch/mac68k/include/cpu.h +++ /dev/null @@ -1,280 +0,0 @@ -/* $OpenBSD: cpu.h,v 1.50 2011/11/01 21:20:55 miod Exp $ */ -/* $NetBSD: cpu.h,v 1.45 1997/02/10 22:13:40 scottr Exp $ */ - -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Copyright (c) 1992, 1993 BCDL Labs. All rights reserved. - * Allen Briggs, Chris Caputo, Michael Finch, Brad Grantham, Lawrence Kesteloot - - * Redistribution of this source code or any part thereof is permitted, - * provided that the following conditions are met: - * 1) Utilized source contains the copyright message above, this list - * of conditions, and the following disclaimer. - * 2) Binary objects containing compiled source reproduce the - * copyright notice above on startup. - * - * CAVEAT: This source code is provided "as-is" by BCDL Labs, and any - * warranties of ANY kind are disclaimed. We don't even claim that it - * won't crash your hard disk. Basically, we want a little credit if - * it works, but we don't want to get mail-bombed if it doesn't. - */ - -/* - * from: Utah $Hdr: cpu.h 1.16 91/03/25$ - * - * @(#)cpu.h 7.7 (Berkeley) 6/27/91 - */ - -#ifndef _CPU_MACHINE_ -#define _CPU_MACHINE_ - -/* - * Exported definitions unique to mac68k/68k cpu support. - */ - -/* - * Get common m68k definitions. - */ -#include <m68k/cpu.h> - -#ifdef _KERNEL - -/* - * Get interrupt glue. - */ -#include <machine/intr.h> - -/* - * Arguments to hardclock and gatherstats encapsulate the previous - * machine state in an opaque clockframe. On the m68k, we use - * what the hardware pushes on an interrupt (frame format 0). - */ -struct clockframe { - u_short sr; /* sr at time of interrupt */ - u_long pc; /* pc at time of interrupt */ - u_short vo; /* vector offset (4-word frame) */ -}; - -#define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0) -#define CLKF_PC(framep) ((framep)->pc) -#define CLKF_INTR(framep) (0) /* XXX should use PSL_M (see hp300) */ - -/* - * Preempt the current process if in interrupt from user mode, - * or after the current trap/syscall if in system mode. - */ -extern int want_resched; /* resched() was called */ -#define need_resched(ci) { want_resched = 1; aston(); } -#define clear_resched(ci) want_resched = 0 - -/* - * Give a profiling tick to the current process from the softclock - * interrupt. Request an ast to send us through trap(), - * marking the proc as needing a profiling tick. - */ -#define need_proftick(p) aston() - -/* - * Notify the current process (p) that it has a signal pending, - * process as soon as possible. - */ -#define signotify(p) aston() - -extern int astpending; /* need to trap before returning to user mode */ -#define aston() (astpending = 1) - -#endif /* _KERNEL */ - -#define CPU_CONSDEV 1 -#define CPU_MAXID 2 - -#define CTL_MACHDEP_NAMES { \ - { 0, 0 }, \ - { "console_device", CTLTYPE_STRUCT }, \ -} - -#ifdef _KERNEL - -/* values for machineid -- - * These are equivalent to the MacOS Gestalt values. */ -#define MACH_MACII 6 -#define MACH_MACIIX 7 -#define MACH_MACIICX 8 -#define MACH_MACSE30 9 -#define MACH_MACIICI 11 -#define MACH_MACIIFX 13 -#define MACH_MACIISI 18 -#define MACH_MACQ900 20 -#define MACH_MACPB170 21 -#define MACH_MACQ700 22 -#define MACH_MACCLASSICII 23 -#define MACH_MACPB100 24 -#define MACH_MACPB140 25 -#define MACH_MACQ950 26 -#define MACH_MACLCIII 27 -#define MACH_MACPB210 29 -#define MACH_MACC650 30 -#define MACH_MACPB230 32 -#define MACH_MACPB180 33 -#define MACH_MACPB160 34 -#define MACH_MACQ800 35 -#define MACH_MACQ650 36 -#define MACH_MACLCII 37 -#define MACH_MACPB250 38 -#define MACH_MACIIVI 44 -#define MACH_MACP600 45 -#define MACH_MACIIVX 48 -#define MACH_MACCCLASSIC 49 -#define MACH_MACPB165C 50 -#define MACH_MACC610 52 -#define MACH_MACQ610 53 -#define MACH_MACPB145 54 -#define MACH_MACLC520 56 -#define MACH_MACC660AV 60 -#define MACH_MACP460 62 -#define MACH_MACPB180C 71 -#define MACH_MACPB500 72 -#define MACH_MACPB270 77 -#define MACH_MACQ840AV 78 -#define MACH_MACP550 80 -#define MACH_MACCCLASSICII 83 -#define MACH_MACPB165 84 -#define MACH_MACPB190CS 85 -#define MACH_MACTV 88 -#define MACH_MACLC475 89 -#define MACH_MACLC475_33 90 -#define MACH_MACLC575 92 -#define MACH_MACQ605 94 -#define MACH_MACQ605_33 95 -#define MACH_MACQ630 98 -#define MACH_MACP580 99 -#define MACH_MACPB280 102 -#define MACH_MACPB280C 103 -#define MACH_MACPB150 115 -#define MACH_MACPB190 122 - -/* - * Machine classes. These define subsets of the above machines. - */ -#define MACH_CLASSH 0 /* Hopeless cases... */ -#define MACH_CLASSII 1 /* MacII class */ -#define MACH_CLASSIIci 2 /* Have RBV, but no Egret */ -#define MACH_CLASSIIsi 3 /* Similar to IIci -- Have Egret. */ -#define MACH_CLASSIIvx 4 /* Similar to IIsi -- different via2 emul? */ -#define MACH_CLASSLC 5 /* Low-Cost/Performa/Wal-Mart Macs. */ -#define MACH_CLASSPB 6 /* Powerbooks. Power management. */ -#define MACH_CLASSDUO 7 /* Powerbooks Duos. More integration/Docks. */ -#define MACH_CLASSIIfx 8 /* The IIfx is in a class by itself. */ -#define MACH_CLASSQ 9 /* non-A/V Centris/Quadras. */ -#define MACH_CLASSAV 10 /* A/V Centris/Quadras. */ -#define MACH_CLASSQ2 11 /* More Centris/Quadras, different sccA. */ - -struct mac68k_machine_S { - int cpu_model_index; - /* - * Misc. info from booter. - */ - int machineid; - int mach_memsize; - int booter_version; - /* - * Debugging flags. - */ - int do_graybars; - int serial_boot_echo; - int serial_console; - - int modem_flags; - int modem_cts_clk; - int modem_dcd_clk; - int modem_d_speed; - int print_flags; - int print_cts_clk; - int print_dcd_clk; - int print_d_speed; - /* - * Misc. hardware info. - */ - int scsi80; /* Has NCR 5380 */ - int scsi96; /* Has NCR 53C96 */ - int scsi96_2; /* Has 2nd 53C96 */ - int sonic; /* Has SONIC e-net */ - - int via1_ipl; - int aux_interrupts; -}; - - /* What kind of model is this */ -struct cpu_model_info { - int machineid; /* MacOS Gestalt value. */ - const char *model; /* Model description */ - int class; /* Rough class of machine. */ -}; -extern const struct cpu_model_info *current_mac_model; - -extern unsigned long IOBase; /* Base address of I/O */ -extern unsigned long NuBusBase; /* Base address of NuBus */ - -extern struct mac68k_machine_S mac68k_machine; -extern unsigned long load_addr; - -#define IIOMAPSIZE (0x040000 / PAGE_SIZE) - -/* XXX -- Need to do something about superspace. - * Technically, NuBus superspace starts at 0x60000000, but no - * known Macintosh has used any slot lower numbered than 9, and - * the super space is defined as 0xS000 0000 through 0xSFFF FFFF - * where S is the slot number--ranging from 0x9 - 0xE. - */ -#define NBSBASE 0x90000000 -#define NBSTOP 0xF0000000 -#define NBBASE 0xF9000000 /* NUBUS space */ -#define NBTOP 0xFF000000 /* NUBUS space */ -#define NBMAPSIZE atop(NBTOP-NBBASE) /* ~ 96 megs */ -#define NBMEMSIZE 0x01000000 /* 16 megs per card */ -#define NBROMOFFSET 0x00FF0000 /* Last 64K == ROM */ - -/* locore.s */ -void PCIA(void); - -/* machdep.c */ -void mac68k_set_bell_callback(int (*)(void *, int, int, int), void *); -int mac68k_ring_bell(int, int, int); -u_int get_mapping(void); - -#endif - -#endif /* _CPU_MACHINE_ */ diff --git a/sys/arch/mac68k/include/db_machdep.h b/sys/arch/mac68k/include/db_machdep.h deleted file mode 100644 index f8188f7e258..00000000000 --- a/sys/arch/mac68k/include/db_machdep.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $OpenBSD: db_machdep.h,v 1.4 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: db_machdep.h,v 1.3 1994/10/26 08:46:27 cgd Exp $ */ - -#ifndef _MACHINE_DB_MACHDEP_H_ -#define _MACHINE_DB_MACHDEP_H_ - -#include <m68k/db_machdep.h> - -#endif /* _MACHINE_DB_MACHDEP_H_ */ diff --git a/sys/arch/mac68k/include/disklabel.h b/sys/arch/mac68k/include/disklabel.h deleted file mode 100644 index 98612bee869..00000000000 --- a/sys/arch/mac68k/include/disklabel.h +++ /dev/null @@ -1,40 +0,0 @@ -/* $OpenBSD: disklabel.h,v 1.9 2011/03/23 16:54:36 pirofti Exp $ */ - -/* - * Copyright (c) 1994 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. - */ - -#ifndef _MACHINE_DISKLABEL_H_ -#define _MACHINE_DISKLABEL_H_ - -#define LABELSECTOR 0 /* sector containing label */ -#define LABELOFFSET 64 /* offset of label in sector */ -#define MAXPARTITIONS 16 /* number of partitions */ - -#endif /* _MACHINE_DISKLABEL_H_ */ diff --git a/sys/arch/mac68k/include/endian.h b/sys/arch/mac68k/include/endian.h deleted file mode 100644 index 40e1fdac923..00000000000 --- a/sys/arch/mac68k/include/endian.h +++ /dev/null @@ -1,4 +0,0 @@ -/* $OpenBSD: endian.h,v 1.5 2011/03/15 18:23:38 deraadt Exp $ */ -/* $NetBSD: endian.h,v 1.5 1994/10/26 08:46:28 cgd Exp $ */ - -#include <m68k/endian.h> diff --git a/sys/arch/mac68k/include/exec.h b/sys/arch/mac68k/include/exec.h deleted file mode 100644 index 7e02e75ecf4..00000000000 --- a/sys/arch/mac68k/include/exec.h +++ /dev/null @@ -1,38 +0,0 @@ -/* $OpenBSD: exec.h,v 1.8 2003/10/09 21:48:48 miod Exp $ */ -/* $NetBSD: exec.h,v 1.8 1996/05/05 06:17:40 briggs Exp $ */ - -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include <m68k/exec.h> diff --git a/sys/arch/mac68k/include/fenv.h b/sys/arch/mac68k/include/fenv.h deleted file mode 100644 index f7924ba05fa..00000000000 --- a/sys/arch/mac68k/include/fenv.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $OpenBSD: fenv.h,v 1.1 2011/04/28 18:05:39 martynas Exp $ */ - -#include <m68k/fenv.h> diff --git a/sys/arch/mac68k/include/float.h b/sys/arch/mac68k/include/float.h deleted file mode 100644 index 142d8258609..00000000000 --- a/sys/arch/mac68k/include/float.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $OpenBSD: float.h,v 1.5 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: float.h,v 1.6 1996/05/05 06:17:44 briggs Exp $ */ - -#ifndef _MACHINE_FLOAT_H_ -#define _MACHINE_FLOAT_H_ - -#include <m68k/float.h> - -#endif /* _MACHINE_FLOAT_H_ */ diff --git a/sys/arch/mac68k/include/frame.h b/sys/arch/mac68k/include/frame.h deleted file mode 100644 index 79c680e1459..00000000000 --- a/sys/arch/mac68k/include/frame.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $OpenBSD: frame.h,v 1.5 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: frame.h,v 1.5 1996/05/05 06:17:46 briggs Exp $ */ - -#ifndef _MACHINE_FRAME_H_ -#define _MACHINE_FRAME_H_ - -#include <m68k/frame.h> - -#endif /* _MACHINE_FRAME_H_ */ diff --git a/sys/arch/mac68k/include/ieee.h b/sys/arch/mac68k/include/ieee.h deleted file mode 100644 index a71abb6e62c..00000000000 --- a/sys/arch/mac68k/include/ieee.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $OpenBSD: ieee.h,v 1.1 2001/09/06 00:07:10 millert Exp $ */ - -#include <m68k/ieee.h> diff --git a/sys/arch/mac68k/include/ieeefp.h b/sys/arch/mac68k/include/ieeefp.h deleted file mode 100644 index b9f71534588..00000000000 --- a/sys/arch/mac68k/include/ieeefp.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $OpenBSD: ieeefp.h,v 1.4 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: ieeefp.h,v 1.2 1995/04/16 16:47:07 jtc Exp $ */ - -#ifndef _MACHINE_IEEEFP_H_ -#define _MACHINE_IEEEFP_H_ - -#include <m68k/ieeefp.h> - -#endif /* _MACHINE_IEEEFP_H_ */ diff --git a/sys/arch/mac68k/include/internal_types.h b/sys/arch/mac68k/include/internal_types.h deleted file mode 100644 index 61dd1740f08..00000000000 --- a/sys/arch/mac68k/include/internal_types.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $OpenBSD: internal_types.h,v 1.1 2002/04/24 21:53:11 espie Exp $ */ -/* Public domain */ -#include <m68k/internal_types.h> diff --git a/sys/arch/mac68k/include/intr.h b/sys/arch/mac68k/include/intr.h deleted file mode 100644 index 64364f25a09..00000000000 --- a/sys/arch/mac68k/include/intr.h +++ /dev/null @@ -1,124 +0,0 @@ -/* $OpenBSD: intr.h,v 1.22 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: intr.h,v 1.9 1998/08/12 06:58:42 scottr Exp $ */ - -/* - * Copyright (C) 1997 Scott Reynolds - * 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. 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. - */ - -#ifndef _MACHINE_INTR_H_ -#define _MACHINE_INTR_H_ - -#include <machine/psl.h> - -#ifdef _KERNEL - -/* - * splnet must block hardware network interrupts - * splvm must be > spltty - */ -extern u_short mac68k_ttyipl; -extern u_short mac68k_netipl; -extern u_short mac68k_vmipl; -extern u_short mac68k_audioipl; -extern u_short mac68k_clockipl; -extern u_short mac68k_statclockipl; - -/* - * Interrupt "levels". These are a more abstract representation - * of interrupt levels, and do not have the same meaning as m68k - * CPU interrupt levels. They serve two purposes: - * - * - properly order ISRs in the list for that CPU ipl - * - compute CPU PSL values for the spl*() calls. - */ -#define IPL_NONE 0 -#define IPL_SOFTINT 1 -#define IPL_BIO 2 -#define IPL_AUDIO PSLTOIPL(mac68k_audioipl) -#define IPL_NET PSLTOIPL(mac68k_netipl) -#define IPL_TTY PSLTOIPL(mac68k_ttyipl) -#define IPL_VM PSLTOIPL(mac68k_vmipl) -#define IPL_CLOCK PSLTOIPL(mac68k_clockipl) -#define IPL_STATCLOCK PSLTOIPL(mac68k_statclockipl) -#define IPL_SCHED 7 -#define IPL_HIGH 7 - -#define MD_IPLTOPSL(ipl) IPLTOPSL(ipl) - -/* - * These should be used for: - * 1) ensuring mutual exclusion (why use processor level?) - * 2) allowing faster devices to take priority - * - * Note that on the Mac, most things are masked at spl1, almost - * everything at spl2, and everything but the panic switch and - * power at spl4. - */ -#define splsoft() _splraise(PSL_S | PSL_IPL1) -#define splsoftclock() splsoft() -#define splsoftnet() splsoft() -#define spltty() _splraise(mac68k_ttyipl) -#define splbio() _splraise(PSL_S | PSL_IPL2) -#define splnet() _splraise(mac68k_netipl) -#define splvm() _splraise(mac68k_vmipl) -#define splaudio() _splraise(mac68k_audioipl) -#define splclock() _splraise(mac68k_clockipl) -#define splstatclock() _splraise(mac68k_statclockipl) -#define splserial() _splraise(PSL_S | PSL_IPL4) -#define splhigh() _spl(PSL_S | PSL_IPL7) -#define splsched() splhigh() - -/* These spl calls are _not_ to be used by machine-independent code. */ -#define splzs() splserial() - -/* watch out for side effects */ -#define splx(s) ((s) & PSL_IPL ? _spl(s) : spl0()) - -#include <m68k/intr.h> /* soft interrupt support */ - -/* intr.c */ -void intr_init(void); -void intr_establish(int (*)(void *), void *, int, const char *); -void intr_disestablish(int); -void intr_dispatch(int); - -/* locore.s */ -int spl0(void); - -/* - * Interrupt handler. - * There is no support for shared interrupts at the moment. - */ -#include <sys/evcount.h> -struct intrhand { - int (*ih_fn)(void *); - void *ih_arg; - int ih_ipl; - struct evcount ih_count; -}; -#endif /* _KERNEL */ - -#endif /* _MACHINE_INTR_H_ */ diff --git a/sys/arch/mac68k/include/iop.h b/sys/arch/mac68k/include/iop.h deleted file mode 100644 index 01fa00738c9..00000000000 --- a/sys/arch/mac68k/include/iop.h +++ /dev/null @@ -1,76 +0,0 @@ -/* $OpenBSD: iop.h,v 1.1 2006/01/22 13:53:16 miod Exp $ */ -/* $NetBSD: iopreg.h,v 1.7 2005/12/11 12:18:03 christos Exp $ */ - -/* - * Copyright (c) 2000 Allen Briggs. - * 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. 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. - */ - -#define SCC_IOP 0 -#define ISM_IOP 1 - -#define IOP_CS_BYPASS 0x01 -#define IOP_CS_AUTOINC 0x02 -#define IOP_CS_RUN 0x04 -#define IOP_CS_IRQ 0x08 -#define IOP_CS_INT0 0x10 -#define IOP_CS_INT1 0x20 -#define IOP_CS_HWINT 0x40 -#define IOP_CS_DMAINACT 0x80 - -#define IOP_RESET (IOP_CS_DMAINACT | IOP_CS_AUTOINC) -#define IOP_BYPASS \ - (IOP_CS_BYPASS | IOP_CS_AUTOINC | IOP_CS_RUN | IOP_CS_DMAINACT) -#define IOP_INTERRUPT (IOP_CS_INT0 | IOP_CS_INT1) - -typedef struct { - volatile u_char ram_hi; - u_char pad0; - volatile u_char ram_lo; - u_char pad1; - volatile u_char control_status; - u_char pad2[3]; - volatile u_char data; - u_char pad3[23]; - union { - struct { - volatile u_char sccb_cmd; - u_char pad0; - volatile u_char scca_cmd; - u_char pad1; - volatile u_char sccb_data; - u_char pad2; - volatile u_char scca_data; - u_char pad3; - } scc; - struct { - volatile u_char wdata; - u_char pad0; - /* etc... */ - } iwm; - } bypass; -} IOPHW; - -void iop_serial_compatible(void); diff --git a/sys/arch/mac68k/include/kcore.h b/sys/arch/mac68k/include/kcore.h deleted file mode 100644 index d41bc4a19d3..00000000000 --- a/sys/arch/mac68k/include/kcore.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $OpenBSD: kcore.h,v 1.1 1999/04/23 05:12:35 downsj Exp $ */ -/* $NetBSD: kcore.h,v 1.1 1997/04/23 19:15:16 scottr Exp $ */ - -#ifndef _MACHINE_KCORE_H_ -#define _MACHINE_KCORE_H_ - -#include <m68k/kcore.h> - -#endif diff --git a/sys/arch/mac68k/include/limits.h b/sys/arch/mac68k/include/limits.h deleted file mode 100644 index 0dd4fb31483..00000000000 --- a/sys/arch/mac68k/include/limits.h +++ /dev/null @@ -1,4 +0,0 @@ -/* $OpenBSD: limits.h,v 1.5 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: limits.h,v 1.6 1994/10/26 08:46:34 cgd Exp $ */ -/* public domain */ -#include <m68k/limits.h> diff --git a/sys/arch/mac68k/include/lock.h b/sys/arch/mac68k/include/lock.h deleted file mode 100644 index a83fd0016e1..00000000000 --- a/sys/arch/mac68k/include/lock.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $OpenBSD: lock.h,v 1.1 2007/05/01 18:56:30 miod Exp $ */ -/* public domain */ -#include <m68k/lock.h> diff --git a/sys/arch/mac68k/include/mutex.h b/sys/arch/mac68k/include/mutex.h deleted file mode 100644 index f899120c22e..00000000000 --- a/sys/arch/mac68k/include/mutex.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $OpenBSD: mutex.h,v 1.1 2007/02/03 20:08:50 miod Exp $ */ -/* public domain */ -#include <m68k/mutex.h> diff --git a/sys/arch/mac68k/include/param.h b/sys/arch/mac68k/include/param.h deleted file mode 100644 index 1747f5fc8ee..00000000000 --- a/sys/arch/mac68k/include/param.h +++ /dev/null @@ -1,100 +0,0 @@ -/* $OpenBSD: param.h,v 1.22 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: param.h,v 1.28 1997/03/01 06:57:45 scottr Exp $ */ - -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -/* - * from: Utah $Hdr: machparam.h 1.11 89/08/14$ - * - * @(#)param.h 7.8 (Berkeley) 6/28/91 - */ - -#ifndef _MACHINE_PARAM_H_ -#define _MACHINE_PARAM_H_ - -/* - * Machine dependent constants for Macintosh II-and-similar series. - */ -#define _MACHINE mac68k -#define MACHINE "mac68k" - -#define PAGE_SHIFT 12 - -#define KERNBASE 0x00000000 /* start of kernel virtual */ - -#define UPAGES 3 /* pages of u-area */ - -#include <m68k/param.h> - -#define MSGBUFSIZE 4096 - -#if defined(_KERNEL) && !defined(_LOCORE) -void delay(unsigned); -#define DELAY(ms) delay(ms) -#endif /* _KERNEL && !_LOCORE */ - -#endif /* _MACHINE_PARAM_H_ */ diff --git a/sys/arch/mac68k/include/pcb.h b/sys/arch/mac68k/include/pcb.h deleted file mode 100644 index 4c1192d3cbe..00000000000 --- a/sys/arch/mac68k/include/pcb.h +++ /dev/null @@ -1,76 +0,0 @@ -/* $OpenBSD: pcb.h,v 1.7 2003/10/09 21:48:48 miod Exp $ */ -/* $NetBSD: pcb.h,v 1.7 1996/05/05 06:17:51 briggs Exp $ */ - -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -/* - * from: Utah $Hdr: pcb.h 1.13 89/04/23$ - * - * @(#)pcb.h 7.4 (Berkeley) 5/4/91 - */ - -#include <m68k/pcb.h> diff --git a/sys/arch/mac68k/include/pmap.h b/sys/arch/mac68k/include/pmap.h deleted file mode 100644 index ad7cd3d90ea..00000000000 --- a/sys/arch/mac68k/include/pmap.h +++ /dev/null @@ -1,13 +0,0 @@ -/* $OpenBSD: pmap.h,v 1.20 2011/03/23 16:54:36 pirofti Exp $ */ - -#ifndef _MACHINE_PMAP_H_ -#define _MACHINE_PMAP_H_ - -#include <m68k/pmap_motorola.h> - -#ifdef _KERNEL -void pmap_init_md(void); -#define PMAP_INIT_MD() pmap_init_md() -#endif /* _KERNEL */ - -#endif /* _MACHINE_PMAP_H_ */ diff --git a/sys/arch/mac68k/include/proc.h b/sys/arch/mac68k/include/proc.h deleted file mode 100644 index 19d35bfe80e..00000000000 --- a/sys/arch/mac68k/include/proc.h +++ /dev/null @@ -1,35 +0,0 @@ -/* $OpenBSD: proc.h,v 1.7 2003/10/09 21:48:48 miod Exp $ */ -/* $NetBSD: proc.h,v 1.5 1994/10/26 08:46:40 cgd Exp $ */ - -/* - * Copyright (c) 1991 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)proc.h 7.1 (Berkeley) 5/15/91 - */ - -#include <m68k/proc.h> diff --git a/sys/arch/mac68k/include/profile.h b/sys/arch/mac68k/include/profile.h deleted file mode 100644 index d8f8974df40..00000000000 --- a/sys/arch/mac68k/include/profile.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $OpenBSD: profile.h,v 1.5 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: profile.h,v 1.3 1996/05/05 06:17:55 briggs Exp $ */ - -#ifndef _MACHINE_PROFILE_H_ -#define _MACHINE_PROFILE_H_ - -#include <m68k/profile.h> - -#endif diff --git a/sys/arch/mac68k/include/psc.h b/sys/arch/mac68k/include/psc.h deleted file mode 100644 index 999e30b6c41..00000000000 --- a/sys/arch/mac68k/include/psc.h +++ /dev/null @@ -1,126 +0,0 @@ -/* $OpenBSD: psc.h,v 1.5 2004/12/14 14:50:55 martin Exp $ */ -/* $NetBSD: psc.h,v 1.5 2004/03/26 12:15:46 wiz Exp $ */ - -/*- - * Copyright (c) 1997 David Huang <khym@azeotrope.org> - * 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. 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. - * - */ - -/* - * Some register definitions for the PSC, present only on the - * Centris/Quadra 660av and the Quadra 840av. - */ - -extern volatile u_int8_t *PSCBase; - -#define psc_reg1(r) (*((volatile u_int8_t *)(PSCBase+r))) -#define psc_reg2(r) (*((volatile u_int16_t *)(PSCBase+r))) -#define psc_reg4(r) (*((volatile u_int32_t *)(PSCBase+r))) - -void psc_init(void); - -int add_psc_lev3_intr(void (*)(void *), void *); -int add_psc_lev4_intr(int, int (*)(void *), void *); -int add_psc_lev5_intr(int, void (*)(void *), void *); -int add_psc_lev6_intr(int, void (*)(void *), void *); - -int remove_psc_lev3_intr(void); -int remove_psc_lev4_intr(int); -int remove_psc_lev5_intr(int); -int remove_psc_lev6_intr(int); - -/* - * Reading an interrupt status register returns a mask of the - * currently interrupting devices (one bit per device). Reading an - * interrupt enable register returns a mask of the currently enabled - * devices. Writing an interrupt enable register with the MSB set - * enables the interrupts in the lower 4 bits, while writing with the - * MSB clear disables the corresponding interrupts. - * e.g. write 0x81 to enable device 0, write 0x86 to enable devices 1 - * and 2, write 0x02 to disable device 1. - * - * Level 3 device 0 is MACE - * Level 4 device 0 is 3210 DSP? - * Level 4 device 1 is SCC channel A (modem port) - * Level 4 device 2 is SCC channel B (printer port) - * Level 4 device 3 is MACE DMA completion - * Level 5 device 0 is 3210 DSP? - * Level 5 device 1 is 3210 DSP? - * Level 6 device 0 is ? - * Level 6 device 1 is ? - * Level 6 device 2 is ? - */ - -/* PSC interrupt registers */ -#define PSC_ISR_BASE 0x100 /* ISR is BASE + 0x10 * level */ -#define PSC_IER_BASE 0x104 /* IER is BASE + 0x10 * level */ - -#define PSC_LEV3_ISR 0x130 /* level 3 interrupt status register */ -#define PSC_LEV3_IER 0x134 /* level 3 interrupt enable register */ -#define PSCINTR_ENET 0 /* Ethernet interrupt */ - -#define PSC_LEV4_ISR 0x140 /* level 4 interrupt status register */ -#define PSC_LEV4_IER 0x144 /* level 4 interrupt enable register */ -#define PSCINTR_SCCA 1 /* SCC channel A interrupt */ -#define PSCINTR_SCCB 2 /* SCC channel B interrupt */ -#define PSCINTR_ENET_DMA 3 /* Ethernet DMA completion interrupt */ - -#define PSC_LEV5_ISR 0x150 /* level 5 interrupt status register */ -#define PSC_LEV5_IER 0x154 /* level 5 interrupt enable register */ - -#define PSC_LEV6_ISR 0x160 /* level 6 interrupt status register */ -#define PSC_LEV6_IER 0x164 /* level 6 interrupt enable register */ - -/* PSC DMA channel control registers */ -#define PSC_CTLBASE 0xc00 - -#define PSC_SCSI_CTL 0xc00 /* SCSI control/status */ -#define PSC_ENETRD_CTL 0xc10 /* MACE receive DMA channel control/status */ -#define PSC_ENETWR_CTL 0xc20 /* MACE transmit DMA channel control/status */ -#define PSC_FDC_CTL 0xc30 /* Floppy disk */ -#define PSC_SCCA_CTL 0xc40 /* SCC channel A */ -#define PSC_SCCB_CTL 0xc50 /* SCC channel B */ -#define PSC_SCCATX_CTL 0xc60 /* SCC channel A transmit */ - -/* PSC DMA channels */ -#define PSC_ADDRBASE 0x1000 -#define PSC_LENBASE 0x1004 -#define PSC_CMDBASE 0x1008 - -#define PSC_SCSI_ADDR 0x1000 /* SCSI DMA address register */ -#define PSC_SCSI_LEN 0x1004 /* SCSI DMA buffer count */ -#define PSC_SCSI_CMD 0x1008 /* SCSI DMA command register */ -#define PSC_ENETRD_ADDR 0x1020 /* MACE receive DMA address register */ -#define PSC_ENETRD_LEN 0x1024 /* MACE receive DMA buffer count */ -#define PSC_ENETRD_CMD 0x1028 /* MACE receive DMA command register */ -#define PSC_ENETWR_ADDR 0x1040 /* MACE transmit DMA address register */ -#define PSC_ENETWR_LEN 0x1044 /* MACE transmit DMA length */ -#define PSC_ENETWR_CMD 0x1048 /* MACE transmit DMA command register */ - -/* - * PSC DMA channels are controlled by two sets of registers (see p.29 - * of the Quadra 840av and Centris 660av Developer Note). Add the - * following offsets to get the desired register set. - */ -#define PSC_SET0 0x00 -#define PSC_SET1 0x10 diff --git a/sys/arch/mac68k/include/psl.h b/sys/arch/mac68k/include/psl.h deleted file mode 100644 index e272a8e0e2f..00000000000 --- a/sys/arch/mac68k/include/psl.h +++ /dev/null @@ -1,4 +0,0 @@ -/* $OpenBSD: psl.h,v 1.6 1998/05/03 07:10:48 gene Exp $ */ -/* $NetBSD: psl.h,v 1.11 1996/06/21 21:51:15 briggs Exp $ */ - -#include <m68k/psl.h> diff --git a/sys/arch/mac68k/include/pte.h b/sys/arch/mac68k/include/pte.h deleted file mode 100644 index 1689e29b9f1..00000000000 --- a/sys/arch/mac68k/include/pte.h +++ /dev/null @@ -1,14 +0,0 @@ -/* $OpenBSD: pte.h,v 1.7 2002/01/10 22:25:40 miod Exp $ */ - -#ifndef _MACHINE_PTE_H_ -#define _MACHINE_PTE_H_ - -#include <m68k/pte_motorola.h> - -#define MACHINE_STSIZE M68K_STSIZE -#define MACHINE_MAX_PTSIZE M68K_MAX_PTSIZE -#define MACHINE_MAX_KPTSIZE M68K_MAX_KPTSIZE -#define MACHINE_PTBASE M68K_PTBASE -#define MACHINE_PTMAXSIZE M68K_PTMAXSIZE - -#endif /* _MACHINE_PTE_H_ */ diff --git a/sys/arch/mac68k/include/ptrace.h b/sys/arch/mac68k/include/ptrace.h deleted file mode 100644 index 17a3905e7f5..00000000000 --- a/sys/arch/mac68k/include/ptrace.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $OpenBSD: ptrace.h,v 1.4 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: ptrace.h,v 1.2 1994/10/26 08:46:43 cgd Exp $ */ - -#ifndef _MACHINE_PTRACE_H_ -#define _MACHINE_PTRACE_H_ - -#include <m68k/ptrace.h> - -#endif diff --git a/sys/arch/mac68k/include/reg.h b/sys/arch/mac68k/include/reg.h deleted file mode 100644 index 68d9dbd8fa1..00000000000 --- a/sys/arch/mac68k/include/reg.h +++ /dev/null @@ -1,10 +0,0 @@ -/* $OpenBSD: reg.h,v 1.6 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: reg.h,v 1.10 1996/05/05 06:18:00 briggs Exp $ */ - -#ifndef _MACHINE_REG_H_ -#define _MACHINE_REG_H_ - -#include <machine/frame.h> -#include <m68k/reg.h> - -#endif /* _MACHINE_REG_H_ */ diff --git a/sys/arch/mac68k/include/scsi_5380.h b/sys/arch/mac68k/include/scsi_5380.h deleted file mode 100644 index dd52f93069f..00000000000 --- a/sys/arch/mac68k/include/scsi_5380.h +++ /dev/null @@ -1,147 +0,0 @@ -/* $OpenBSD: scsi_5380.h,v 1.4 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: scsi_5380.h,v 1.3 1994/10/26 08:46:46 cgd Exp $ */ - -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ -/* - * File: scsi_5380.h - * Author: Alessandro Forin, Carnegie Mellon University - * Date: 5/91 - * - * Defines for the NCR 5380 (SCSI chip), aka Am5380 - */ - -#ifndef _MACHINE_SCSI_5380_H_ -#define _MACHINE_SCSI_5380_H_ - -/* - * Register map - */ - -typedef struct { - volatile unsigned char sci_data; /* r: Current data */ -#define sci_odata sci_data /* w: Out data */ - PAD(pad0); - - volatile unsigned char sci_icmd; /* rw: Initiator command */ - PAD(pad1); - - volatile unsigned char sci_mode; /* rw: Mode */ - PAD(pad2); - - volatile unsigned char sci_tcmd; /* rw: Target command */ - PAD(pad3); - - volatile unsigned char sci_bus_csr; /* r: Bus Status */ -#define sci_sel_enb sci_bus_csr /* w: Select enable */ - PAD(pad4); - - volatile unsigned char sci_csr; /* r: Status */ -#define sci_dma_send sci_csr /* w: Start dma send data */ - PAD(pad5); - - volatile unsigned char sci_idata; /* r: Input data */ -#define sci_trecv sci_idata /* w: Start dma receive, target */ - PAD(pad6); - - volatile unsigned char sci_iack; /* r: Interrupt Acknowledge */ -#define sci_irecv sci_iack /* w: Start dma receive, initiator */ -} sci_regmap_t; - - -/* - * Initiator command register - */ - -#define SCI_ICMD_DATA 0x01 /* rw: Assert data bus */ -#define SCI_ICMD_ATN 0x02 /* rw: Assert ATN signal */ -#define SCI_ICMD_SEL 0x04 /* rw: Assert SEL signal */ -#define SCI_ICMD_BSY 0x08 /* rw: Assert BSY signal */ -#define SCI_ICMD_ACK 0x10 /* rw: Assert ACK signal */ -#define SCI_ICMD_LST 0x20 /* r: Lost arbitration */ -#define SCI_ICMD_DIFF SCI_ICMD_LST /* w: Differential cable */ -#define SCI_ICMD_AIP 0x40 /* r: Arbitration in progress */ -#define SCI_ICMD_TEST SCI_ICMD_AIP /* w: Test mode */ -#define SCI_ICMD_RST 0x80 /* rw: Assert RST signal */ - - -/* - * Mode register - */ - -#define SCI_MODE_ARB 0x01 /* rw: Start arbitration */ -#define SCI_MODE_DMA 0x02 /* rw: Enable DMA xfers */ -#define SCI_MODE_MONBSY 0x04 /* rw: Monitor BSY signal */ -#define SCI_MODE_DMA_IE 0x08 /* rw: Enable DMA complete interrupt */ -#define SCI_MODE_PERR_IE 0x10 /* rw: Interrupt on parity errors */ -#define SCI_MODE_PAR_CHK 0x20 /* rw: Check parity */ -#define SCI_MODE_TARGET 0x40 /* rw: Target mode (Initiator if 0) */ -#define SCI_MODE_BLOCKDMA 0x80 /* rw: Block-mode DMA handshake (MBZ) */ - - -/* - * Target command register - */ - -#define SCI_TCMD_IO 0x01 /* rw: Assert I/O signal */ -#define SCI_TCMD_CD 0x02 /* rw: Assert C/D signal */ -#define SCI_TCMD_MSG 0x04 /* rw: Assert MSG signal */ -#define SCI_TCMD_PHASE_MASK 0x07 /* r: Mask for current bus phase */ -#define SCI_TCMD_REQ 0x08 /* rw: Assert REQ signal */ -#define SCI_TCMD_LAST_SENT 0x80 /* ro: Last byte was xferred - * (not on 5380/1) */ - -#define SCI_PHASE(x) SCSI_PHASE(x) - -/* - * Current (SCSI) Bus status - */ - -#define SCI_BUS_DBP 0x01 /* r: Data Bus parity */ -#define SCI_BUS_SEL 0x02 /* r: SEL signal */ -#define SCI_BUS_IO 0x04 /* r: I/O signal */ -#define SCI_BUS_CD 0x08 /* r: C/D signal */ -#define SCI_BUS_MSG 0x10 /* r: MSG signal */ -#define SCI_BUS_REQ 0x20 /* r: REQ signal */ -#define SCI_BUS_BSY 0x40 /* r: BSY signal */ -#define SCI_BUS_RST 0x80 /* r: RST signal */ - -#define SCI_CUR_PHASE(x) SCSI_PHASE((x)>>2) - -/* - * Bus and Status register - */ - -#define SCI_CSR_ACK 0x01 /* r: ACK signal */ -#define SCI_CSR_ATN 0x02 /* r: ATN signal */ -#define SCI_CSR_DISC 0x04 /* r: Disconnected (BSY==0) */ -#define SCI_CSR_PHASE_MATCH 0x08 /* r: Bus and SCI_TCMD match */ -#define SCI_CSR_INT 0x10 /* r: Interrupt request */ -#define SCI_CSR_PERR 0x20 /* r: Parity error */ -#define SCI_CSR_DREQ 0x40 /* r: DMA request */ -#define SCI_CSR_DONE 0x80 /* r: DMA count is zero */ - -#endif /* _MACHINE_SCSI_5380_H_ */ diff --git a/sys/arch/mac68k/include/setjmp.h b/sys/arch/mac68k/include/setjmp.h deleted file mode 100644 index d3ee5255fdf..00000000000 --- a/sys/arch/mac68k/include/setjmp.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $OpenBSD: setjmp.h,v 1.4 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: setjmp.h,v 1.1 1994/12/20 10:36:57 cgd Exp $ */ - -#ifndef _MACHINE_SETJMP_H_ -#define _MACHINE_SETJMP_H_ - -#include <m68k/setjmp.h> - -#endif diff --git a/sys/arch/mac68k/include/signal.h b/sys/arch/mac68k/include/signal.h deleted file mode 100644 index 8236a88bbde..00000000000 --- a/sys/arch/mac68k/include/signal.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $OpenBSD: signal.h,v 1.4 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: signal.h,v 1.3 1994/10/26 08:46:47 cgd Exp $ */ - -#ifndef _MACHINE_SIGNAL_H_ -#define _MACHINE_SIGNAL_H_ - -#include <m68k/signal.h> - -#endif diff --git a/sys/arch/mac68k/include/spinlock.h b/sys/arch/mac68k/include/spinlock.h deleted file mode 100644 index 46634aefed3..00000000000 --- a/sys/arch/mac68k/include/spinlock.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $OpenBSD: spinlock.h,v 1.1 1999/01/21 02:59:34 millert Exp $ */ - -#include <m68k/spinlock.h> diff --git a/sys/arch/mac68k/include/stdarg.h b/sys/arch/mac68k/include/stdarg.h deleted file mode 100644 index d6ca78ac8dc..00000000000 --- a/sys/arch/mac68k/include/stdarg.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $OpenBSD: stdarg.h,v 1.4 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: stdarg.h,v 1.5 1994/10/26 08:46:48 cgd Exp $ */ - -#ifndef _MACHINE_STDARG_H_ -#define _MACHINE_STDARG_H_ - -#include <m68k/stdarg.h> - -#endif diff --git a/sys/arch/mac68k/include/tcb.h b/sys/arch/mac68k/include/tcb.h deleted file mode 100644 index 34ed3c65c1d..00000000000 --- a/sys/arch/mac68k/include/tcb.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $OpenBSD: tcb.h,v 1.1 2011/10/27 04:01:17 guenther Exp $ */ - -#include <m68k/tcb.h> diff --git a/sys/arch/mac68k/include/trap.h b/sys/arch/mac68k/include/trap.h deleted file mode 100644 index 74e07d224b7..00000000000 --- a/sys/arch/mac68k/include/trap.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $OpenBSD: trap.h,v 1.4 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: trap.h,v 1.5 1994/10/26 08:46:49 cgd Exp $ */ - -#ifndef _MACHINE_TRAP_H_ -#define _MACHINE_TRAP_H_ - -#include <m68k/trap.h> - -#endif diff --git a/sys/arch/mac68k/include/varargs.h b/sys/arch/mac68k/include/varargs.h deleted file mode 100644 index 1e90c548efc..00000000000 --- a/sys/arch/mac68k/include/varargs.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $OpenBSD: varargs.h,v 1.4 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: varargs.h,v 1.2 1994/10/26 08:46:51 cgd Exp $ */ - -#ifndef _MACHINE_VARARGS_H_ -#define _MACHINE_VARARGS_H_ - -#include <m68k/varargs.h> - -#endif diff --git a/sys/arch/mac68k/include/viareg.h b/sys/arch/mac68k/include/viareg.h deleted file mode 100644 index 52ad5f10686..00000000000 --- a/sys/arch/mac68k/include/viareg.h +++ /dev/null @@ -1,222 +0,0 @@ -/* $OpenBSD: viareg.h,v 1.20 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: viareg.h,v 1.6 1997/02/28 07:41:41 scottr Exp $ */ - -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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. - * - */ - -/* - * Prototype VIA control definitions - */ -#ifndef _MACHINE_VIAREG_H_ -#define _MACHINE_VIAREG_H_ - -/* VIA1 data register A */ -#define DA1I_vSCCWrReq 0x80 -#define DA1O_vPage2 0x40 -#define DA1I_CPU_ID1 0x40 -#define DA1O_vHeadSel 0x20 -#define DA1O_vOverlay 0x10 -#define DA1O_vSync 0x08 -#define DA1O_RESERVED2 0x04 -#define DA1O_RESERVED1 0x02 -#define DA1O_RESERVED0 0x01 - -/* VIA1 data register B */ -#define DB1I_Par_Err 0x80 -#define DB1O_vSndEnb 0x80 -#define DB1O_Par_Enb 0x40 -#define DB1O_AuxIntEnb 0x40 /* 0 = enabled, 1 = disabled */ -#define DB1O_vFDesk2 0x20 -#define DB1O_vFDesk1 0x10 -#define DB1I_vFDBInt 0x08 -#define DB1O_rTCEnb 0x04 -#define DB1O_rTCCLK 0x02 -#define DB1O_rTCData 0x01 -#define DB1I_rTCData 0x01 - -/* VIA2 data register A */ -#define DA2O_v2Ram1 0x80 -#define DA2O_v2Ram0 0x40 -#define DA2I_v2IRQ0 0x40 -#define DA2I_v2IRQE 0x20 -#define DA2I_v2IRQD 0x10 -#define DA2I_v2IRQC 0x08 -#define DA2I_v2IRQB 0x04 -#define DA2I_v2IRQA 0x02 -#define DA2I_v2IRQ9 0x01 - -/* VIA2 data register B */ -#define DB2O_v2VBL 0x80 -#define DB2O_Par_Test 0x80 -#define DB2I_v2SNDEXT 0x40 -#define DB2I_v2TM0A 0x20 -#define DB2I_v2TM1A 0x10 -#define DB2I_vFC3 0x08 -#define DB2O_vFC3 0x08 -#define DB2O_v2PowerOff 0x04 -#define DB2O_v2BusLk 0x02 -#define DB2O_vCDis 0x01 -#define DB2O_CEnable 0x01 - -/* - * VIA1 interrupts - */ -#define VIA1_T1 6 -#define VIA1_T2 5 -#define VIA1_ADBCLK 4 -#define VIA1_ADBDATA 3 -#define VIA1_ADBRDY 2 -#define VIA1_VBLNK 1 -#define VIA1_ONESEC 0 - -/* VIA1 interrupt bits */ -#define V1IF_IRQ 0x80 -#define V1IF_T1 (1 << VIA1_T1) -#define V1IF_T2 (1 << VIA1_T2) -#define V1IF_ADBCLK (1 << VIA1_ADBCLK) -#define V1IF_ADBDATA (1 << VIA1_ADBDATA) -#define V1IF_ADBRDY (1 << VIA1_ADBRDY) -#define V1IF_VBLNK (1 << VIA1_VBLNK) -#define V1IF_ONESEC (1 << VIA1_ONESEC) - -/* - * VIA2 interrupts - */ -#define VIA2_T1 6 -#define VIA2_T2 5 -#define VIA2_ASC 4 -#define VIA2_SCSIIRQ 3 -#define VIA2_EXPIRQ 2 -#define VIA2_SLOTINT 1 -#define VIA2_SCSIDRQ 0 - -/* VIA2 interrupt bits */ -#define V2IF_IRQ 0x80 -#define V2IF_T1 (1 << VIA2_T1) -#define V2IF_T2 (1 << VIA2_T2) -#define V2IF_ASC (1 << VIA2_ASC) -#define V2IF_SCSIIRQ (1 << VIA2_SCSIIRQ) -#define V2IF_EXPIRQ (1 << VIA2_EXPIRQ) -#define V2IF_SLOTINT (1 << VIA2_SLOTINT) -#define V2IF_SCSIDRQ (1 << VIA2_SCSIDRQ) - -#define VIA1_INTS (V1IF_T1 | V1IF_ADBRDY) -#define VIA2_INTS (V2IF_T1 | V2IF_ASC | V2IF_SCSIIRQ | V2IF_SLOTINT | \ - V2IF_SCSIDRQ) - -#define RBV_INTS (V2IF_T1 | V2IF_ASC | V2IF_SCSIIRQ | V2IF_SLOTINT | \ - V2IF_SCSIDRQ | V1IF_ADBRDY) - -#define ACR_T1LATCH 0x40 - -extern volatile unsigned char *Via1Base; -extern volatile unsigned char *Via2Base; /* init in VIA_Initialize */ -#define VIA1_addr Via1Base /* at PA 0x50f00000 */ - -#define VIA2OFF 1 /* VIA2 addr = VIA1_addr + 0x2000 */ -#define RBVOFF 0x13 /* RBV addr = VIA1_addr + 0x26000 */ -#define OSSOFF 0xd /* OSS addr = VIA1_addr + 0x1A000 */ - -#define VIA1 0 -extern int VIA2; - - /* VIA interface registers */ -#define vBufA 0x1e00 /* register A */ -#define vBufB 0 /* register B */ -#define vDirA 0x0600 /* data direction register */ -#define vDirB 0x0400 /* data direction register */ -#define vT1C 0x0800 -#define vT1CH 0x0a00 -#define vT1L 0x0c00 -#define vT1LH 0x0e00 -#define vT2C 0x1000 -#define vT2CH 0x1200 -#define vSR 0x1400 /* shift register */ -#define vACR 0x1600 /* aux control register */ -#define vPCR 0x1800 /* peripheral control register */ -#define vIFR 0x1a00 /* interrupt flag register */ -#define vIER 0x1c00 /* interrupt enable register */ - -/* RBV interface registers */ -#define rBufB 0 /* register B */ -#define rBufA 2 /* register A */ -#define rIFR 0x3 /* interrupt flag register (writes?) */ -#define rIER 0x13 /* interrupt enable register */ -#define rMonitor 0x10 /* Monitor type */ -#define rSlotInt 0x12 /* Slot interrupt */ - -/* RBV monitor type flags and masks */ -#define RBVDepthMask 0x07 /* Depth in bits */ -#define RBVMonitorMask 0x38 /* Type numbers */ -#define RBVOff 0x40 /* Monitor turned off */ -#define RBVMonIDBWP 0x08 /* 15 inch BW portrait */ -#define RBVMonIDRGB12 0x10 /* 12 inch color */ -#define RBVMonIDRGB15 0x28 /* 15 inch RGB */ -#define RBVMonIDStd 0x30 /* 12 inch BW or 13 inch color */ -#define RBVMonIDNone 0x38 /* No monitor connected */ - -/* OSS registers */ -#define OSS_IFR 0x202 -#define OSS_PENDING_IRQ (*(volatile u_short *)(Via2Base + (OSS_IFR))) - -#define OSS_oRCR 0x204 -#define OSS_POWEROFF 0x80 - -#define via_reg(v, r) (*(Via1Base+(v)*0x2000+(r))) -#define via2_reg(r) (*(Via2Base+(r))) - -#define vDirA_ADBState 0x30 - -#ifdef _KERNEL -/* VIA2 interrupts may be shared */ -struct via2hand { - SLIST_ENTRY(via2hand) v2h_link; - struct intrhand v2h_ih; -#define vh_fn v2h_ih.ih_fn -#define vh_arg v2h_ih.ih_arg -#define vh_ipl v2h_ih.ih_ipl -#define vh_count v2h_ih.ih_count -}; -typedef SLIST_HEAD(, via2hand) via2hand_t; - -void via_init(void); -void via_powerdown(void); -void via_set_modem(int); -void add_nubus_intr(int, int, int (*)(void *), void *, const char *); -void enable_nubus_intr(void); -void via1_register_irq(int, int (*)(void *), void *, const char *); -int via2_register_irq(struct via2hand *, const char *); -#endif /* _KERNEL */ - -#endif /* _MACHINE_VIAREG_H_ */ diff --git a/sys/arch/mac68k/include/vmparam.h b/sys/arch/mac68k/include/vmparam.h deleted file mode 100644 index ec07dcede74..00000000000 --- a/sys/arch/mac68k/include/vmparam.h +++ /dev/null @@ -1,100 +0,0 @@ -/* $OpenBSD: vmparam.h,v 1.17 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: vmparam.h,v 1.8 1996/11/15 14:21:00 briggs Exp $ */ - -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -/* - * from: Utah $Hdr: vmparam.h 1.16 91/01/18$ - * - * @(#)vmparam.h 7.3 (Berkeley) 5/7/91 - */ - -#ifndef _MACHINE_VMPARAM_H_ -#define _MACHINE_VMPARAM_H_ - -/* - * Machine dependent constants for mac68k -- mostly derived from hp300. - */ - -#include <m68k/vmparam.h> - -/* - * Constants which control the way the VM system deals with memory segments. - * Most mac68k systems have only 1 physical memory segment, but some have 2. - * - * On the systems that have multiple segments, specifically the IIsi and - * IIci, the optimal configuration is to put the higher-density SIMMs in - * bank B. This is because the on-board video uses main memory in bank A - * for the framebuffer, and a memory controller prevents access during - * video refresh cycles. Even if both banks contain the same amount of - * RAM, a minimum of ~320KB will be subtracted from the amount in bank A - * for the framebuffer (if on-board video is in use). - */ -#define VM_PHYSSEG_MAX 8 -#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST - -#endif /* _MACHINE_VMPARAM_H_ */ diff --git a/sys/arch/mac68k/include/z8530var.h b/sys/arch/mac68k/include/z8530var.h deleted file mode 100644 index 7e5e45e0641..00000000000 --- a/sys/arch/mac68k/include/z8530var.h +++ /dev/null @@ -1,129 +0,0 @@ -/* $OpenBSD: z8530var.h,v 1.9 2011/03/23 16:54:36 pirofti Exp $ */ -/* $NetBSD: z8530var.h,v 1.2 1996/06/07 10:27:19 briggs Exp $ */ - -/* - * Copyright (c) 1994 Gordon W. Ross - * 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: - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)zsvar.h 8.1 (Berkeley) 6/11/93 - */ - -#ifndef _MACHINE_Z8530VAR_H_ -#define _MACHINE_Z8530VAR_H_ - -#ifdef _KERNEL -#include <mac68k/dev/z8530sc.h> - -/* - * Clock source info structure, added here so xzs_chanstate works - */ -struct zsclksrc { - long clk; /* clock rate, in MHz, present on signal line */ - int flags; /* Specifies how this source can be used - (RTxC divided, RTxC BRG, PCLK BRG, TRxC divided) and also if the source is "external" and if it - is changeable (by an ioctl ex.). The - source usage flags are used by the tty - child. The other bits tell zsloadchannelregs - if it should call an md signal source - changing routine. ZSC_VARIABLE says if - an ioctl should be able to change the - clock rate.*/ -}; -#define ZSC_PCLK 0x01 -#define ZSC_RTXBRG 0x02 -#define ZSC_RTXDIV 0x04 -#define ZSC_TRXDIV 0x08 -#define ZSC_VARIABLE 0x40 -#define ZSC_EXTERN 0x80 - -#define ZSC_BRG 0x03 -#define ZSC_DIV 0x0c - -/* - * These are the machine-dependent (extended) variants of - * struct zs_chanstate and struct zsc_softc - */ -struct xzs_chanstate { - /* machine-independent part (First!)*/ - struct zs_chanstate xzs_cs; - /* machine-dependent extensions */ - int cs_hwflags; - int cs_chip; /* type of chip */ - /* Clock source info... */ - int cs_clock_count; /* how many signal sources available */ - struct zsclksrc cs_clocks[4]; /* info on available signal sources */ - long cs_cclk_flag; /* flag for current clock source */ - long cs_pclk_flag; /* flag for pending clock source */ - int cs_csource; /* current source # */ - int cs_psource; /* pending source # */ -}; - -struct zsc_softc { - struct device zsc_dev; /* required first: base device */ - struct zs_chanstate *zsc_cs[2]; /* channel A and B soft state */ - /* Machine-dependent part follows... */ - struct xzs_chanstate xzsc_xcs_store[2]; - void *zsc_softih; -}; - -/* - * Functions to read and write individual registers in a channel. - * The ZS chip requires a 1.6 uSec. recovery time between accesses, - * and the Sun3 hardware does NOT take care of this for you. - * MacII hardware DOES dake care of the delay for us. - */ - -u_char zs_read_reg(struct zs_chanstate *cs, u_char reg); -u_char zs_read_csr(struct zs_chanstate *cs); -u_char zs_read_data(struct zs_chanstate *cs); - -void zs_write_reg(struct zs_chanstate *cs, u_char reg, u_char val); -void zs_write_csr(struct zs_chanstate *cs, u_char val); -void zs_write_data(struct zs_chanstate *cs, u_char val); -#endif /* _KERNEL */ - -/* XXX - Could define splzs() here instead of in psl.h */ - -/* Hook for MD ioctl support */ -int zsmdioctl (struct zs_chanstate *cs, u_long cmd, caddr_t data); -/* XXX - This is a bit gross... */ -#define ZS_MD_IOCTL zsmdioctl(cs, cmd, data) - -/* Callback for "external" clock sources */ -void zsmd_setclock(struct zs_chanstate *cs); -#define ZS_MD_SETCLK(cs) zsmd_setclock(cs) -#endif /* _KERNEL */ diff --git a/sys/arch/mac68k/mac68k/autoconf.c b/sys/arch/mac68k/mac68k/autoconf.c deleted file mode 100644 index f441a840df0..00000000000 --- a/sys/arch/mac68k/mac68k/autoconf.c +++ /dev/null @@ -1,194 +0,0 @@ -/* $OpenBSD: autoconf.c,v 1.33 2010/07/01 03:20:37 matthew Exp $ */ -/* $NetBSD: autoconf.c,v 1.38 1996/12/18 05:46:09 scottr Exp $ */ - -/* - * 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: - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)autoconf.c 8.4 (Berkeley) 10/1/93 - */ - -/* - * Setup the system to run on the current machine. - * - * cpu_configure() is called at boot time. Available - * devices are determined (from possibilities mentioned in ioconf.c), - * and the drivers are initialized. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/buf.h> -#include <sys/disklabel.h> -#include <sys/conf.h> -#include <sys/reboot.h> -#include <sys/device.h> -#include <sys/disk.h> - -#include <dev/cons.h> - -#include <machine/autoconf.h> -#include <machine/viareg.h> - -#include <scsi/scsi_all.h> -#include <scsi/scsiconf.h> - -int target_to_unit(u_long, u_long, u_long); -void findbootdev(void); - -struct device *booted_device; -int booted_partition; -dev_t bootdev; - -/* - * Yanked from i386/i386/autoconf.c (and tweaked a bit) - */ -void -findbootdev() -{ - struct device *dv; - int major, unit; - - booted_device = NULL; - booted_partition = 0; /* Assume root is on partition a */ - - major = B_TYPE(bootdev); - if (major < 0 || major >= nblkdev) - return; - - unit = B_UNIT(bootdev); - - bootdev &= ~(B_UNITMASK << B_UNITSHIFT); - unit = target_to_unit(-1, unit, 0); - bootdev |= (unit << B_UNITSHIFT); - - if (disk_count <= 0) - return; - - TAILQ_FOREACH(dv, &alldevs, dv_list) { - if (dv->dv_class == DV_DISK && major == findblkmajor(dv) && - unit == dv->dv_unit) { - booted_device = dv; - return; - } - } -} - -void -cpu_configure() -{ - /* this couldn't be done in intr_init() because this uses malloc() */ - softintr_init(); - - startrtclock(); - - if (config_rootfound("mainbus", "mainbus") == NULL) - panic("No mainbus found!"); - spl0(); - - findbootdev(); - cold = 0; -} - -void -device_register(struct device *dev, void *aux) -{ -} - -void -diskconf(void) -{ - setroot(booted_device, booted_partition, RB_USERREQ); - dumpconf(); -} - -/* - * Map a SCSI bus, target, lun to a device number. - * This could be tape, disk, CD. The calling routine, though, - * assumes DISK. It would be nice to allow CD, too... - */ -int -target_to_unit(bus, target, lun) - u_long bus, target, lun; -{ - struct scsibus_softc *scsi; - struct scsi_link *sc_link; - struct device *sc_dev; - extern struct cfdriver scsibus_cd; - - if (target < 0 || target > 7 || lun < 0 || lun > 7) { - printf("scsi target to unit, target (%ld) or lun (%ld)" - " out of range.\n", target, lun); - return -1; - } - - if (bus == -1) { - for (bus = 0 ; bus < scsibus_cd.cd_ndevs ; bus++) { - if (scsibus_cd.cd_devs[bus]) { - scsi = (struct scsibus_softc *) - scsibus_cd.cd_devs[bus]; - sc_link = scsi_get_link(scsi, target, lun); - if (sc_link != NULL) { - sc_dev = (struct device *) - sc_link->device_softc; - return sc_dev->dv_unit; - } - } - } - return -1; - } - if (bus < 0 || bus >= scsibus_cd.cd_ndevs) { - printf("scsi target to unit, bus (%ld) out of range.\n", bus); - return -1; - } - if (scsibus_cd.cd_devs[bus]) { - scsi = (struct scsibus_softc *) scsibus_cd.cd_devs[bus]; - sc_link = scsi_get_link(scsi, target, lun); - if (sc_link != NULL) { - sc_dev = (struct device *) sc_link->device_softc; - return sc_dev->dv_unit; - } - } - return -1; -} - -struct nam2blk nam2blk[] = { - { "sd", 4 }, - { "cd", 6 }, - { "rd", 13 }, - { "vnd", 8 }, - { NULL, -1 } -}; diff --git a/sys/arch/mac68k/mac68k/bus_space.c b/sys/arch/mac68k/mac68k/bus_space.c deleted file mode 100644 index 12064e6d2d8..00000000000 --- a/sys/arch/mac68k/mac68k/bus_space.c +++ /dev/null @@ -1,905 +0,0 @@ -/* $OpenBSD: bus_space.c,v 1.23 2008/06/26 05:42:12 ray Exp $ */ -/* $NetBSD: bus_space.c,v 1.5 1999/03/26 23:41:30 mycroft Exp $ */ - -/*- - * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Implementation of bus_space mapping for mac68k. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/extent.h> - -#include <machine/bus.h> - -#include <uvm/uvm_extern.h> - -int bus_mem_add_mapping(bus_addr_t, bus_size_t, - int, bus_space_handle_t *); - -extern struct extent *iomem_ex; -extern int iomem_malloc_safe; -label_t *nofault; - -int -bus_space_map(t, bpa, size, flags, bshp) - bus_space_tag_t t; - bus_addr_t bpa; - bus_size_t size; - int flags; - bus_space_handle_t *bshp; -{ - paddr_t pa, endpa; - int error; - - /* - * Before we go any further, let's make sure that this - * region is available. - */ - error = extent_alloc_region(iomem_ex, bpa, size, - EX_NOWAIT | (iomem_malloc_safe ? EX_MALLOCOK : 0)); - if (error) - return (error); - - pa = trunc_page(bpa + t); - endpa = round_page((bpa + t + size) - 1); - -#ifdef DIAGNOSTIC - if (endpa <= pa) - panic("bus_space_map: overflow"); -#endif - - error = bus_mem_add_mapping(bpa, size, flags, bshp); - if (error) { - if (extent_free(iomem_ex, bpa, size, EX_NOWAIT | - (iomem_malloc_safe ? EX_MALLOCOK : 0))) { - printf("bus_space_map: pa 0x%lx, size 0x%lx\n", - bpa, size); - printf("bus_space_map: can't free region\n"); - } - } - - return (error); -} - -int -bus_space_alloc(t, rstart, rend, size, alignment, boundary, flags, bpap, bshp) - bus_space_tag_t t; - bus_addr_t rstart, rend; - bus_size_t size, alignment, boundary; - int flags; - bus_addr_t *bpap; - bus_space_handle_t *bshp; -{ - u_long bpa; - int error; - - /* - * Sanity check the allocation against the extent's boundaries. - */ - if (rstart < iomem_ex->ex_start || rend > iomem_ex->ex_end) - panic("bus_space_alloc: bad region start/end"); - - /* - * Do the requested allocation. - */ - error = extent_alloc_subregion(iomem_ex, rstart, rend, size, alignment, - 0, boundary, - EX_FAST | EX_NOWAIT | (iomem_malloc_safe ? EX_MALLOCOK : 0), - &bpa); - - if (error) - return (error); - - /* - * For memory space, map the bus physical address to - * a kernel virtual address. - */ - error = bus_mem_add_mapping(bpa, size, flags, bshp); - if (error) { - if (extent_free(iomem_ex, bpa, size, EX_NOWAIT | - (iomem_malloc_safe ? EX_MALLOCOK : 0))) { - printf("bus_space_alloc: pa 0x%lx, size 0x%lx\n", - bpa, size); - printf("bus_space_alloc: can't free region\n"); - } - } - - *bpap = bpa; - - return (error); -} - -int -bus_mem_add_mapping(bpa, size, flags, bshp) - bus_addr_t bpa; - bus_size_t size; - int flags; - bus_space_handle_t *bshp; -{ - u_long pa, endpa; - vaddr_t va; - pt_entry_t pte; - - pa = trunc_page(bpa); - endpa = round_page((bpa + size) - 1); - -#ifdef DIAGNOSTIC - if (endpa <= pa) - panic("bus_mem_add_mapping: overflow"); -#endif - - va = uvm_km_valloc(kernel_map, endpa - pa); - if (va == 0) - return (ENOMEM); - - bshp->base = (u_long)(va + m68k_page_offset(bpa)); - bshp->swapped = 0; - bshp->bsr1 = mac68k_bsr1; - bshp->bsr2 = mac68k_bsr2; - bshp->bsr4 = mac68k_bsr4; - bshp->bsrm1 = mac68k_bsrm1; - bshp->bsrm2 = mac68k_bsrm2; - bshp->bsrm4 = mac68k_bsrm4; - bshp->bsrr1 = mac68k_bsrr1; - bshp->bsrr2 = mac68k_bsrr2; - bshp->bsrr4 = mac68k_bsrr4; - bshp->bsw1 = mac68k_bsw1; - bshp->bsw2 = mac68k_bsw2; - bshp->bsw4 = mac68k_bsw4; - bshp->bswm1 = mac68k_bswm1; - bshp->bswm2 = mac68k_bswm2; - bshp->bswm4 = mac68k_bswm4; - bshp->bswr1 = mac68k_bswr1; - bshp->bswr2 = mac68k_bswr2; - bshp->bswr4 = mac68k_bswr4; - bshp->bssm1 = mac68k_bssm1; - bshp->bssm2 = mac68k_bssm2; - bshp->bssm4 = mac68k_bssm4; - bshp->bssr1 = mac68k_bssr1; - bshp->bssr2 = mac68k_bssr2; - bshp->bssr4 = mac68k_bssr4; - - if (flags & BUS_SPACE_MAP_CACHEABLE) - pte = PG_CWT; - else - pte = PG_CI; - - for (; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) - pmap_enter_cache(pmap_kernel(), va, pa, - UVM_PROT_RW, UVM_PROT_RW | PMAP_WIRED, pte); - pmap_update(pmap_kernel()); - - return 0; -} - -void -bus_space_unmap(t, bsh, size) - bus_space_tag_t t; - bus_space_handle_t bsh; - bus_size_t size; -{ - vaddr_t va, endva; - bus_addr_t bpa; - - va = trunc_page(bsh.base); - endva = round_page((bsh.base + size) - 1); - -#ifdef DIAGNOSTIC - if (endva <= va) - panic("bus_space_unmap: overflow"); -#endif - - pmap_extract(pmap_kernel(), va, &bpa); - bpa += m68k_page_offset(bsh.base); - - /* - * Free the kernel virtual mapping. - */ - pmap_remove(pmap_kernel(), va, endva); - pmap_update(pmap_kernel()); - uvm_km_free(kernel_map, va, endva - va); - - if (extent_free(iomem_ex, bpa, size, - EX_NOWAIT | (iomem_malloc_safe ? EX_MALLOCOK : 0))) { - printf("bus_space_unmap: pa 0x%lx, size 0x%lx\n", - bpa, size); - printf("bus_space_unmap: can't free region\n"); - } -} - -void -bus_space_free(t, bsh, size) - bus_space_tag_t t; - bus_space_handle_t bsh; - bus_size_t size; -{ - /* bus_space_unmap() does all that we need to do. */ - bus_space_unmap(t, bsh, size); -} - -int -bus_space_subregion(t, bsh, offset, size, nbshp) - bus_space_tag_t t; - bus_space_handle_t bsh; - bus_size_t offset, size; - bus_space_handle_t *nbshp; -{ - *nbshp = bsh; - nbshp->base += offset; - return (0); -} - -int -mac68k_bus_space_probe(t, bsh, offset, sz) - bus_space_tag_t t; - bus_space_handle_t bsh; - bus_size_t offset; - int sz; -{ - int i; - label_t faultbuf; - - nofault = &faultbuf; - if (setjmp(nofault)) { - nofault = (label_t *)0; - return (0); - } - - switch (sz) { - case 1: - i = bus_space_read_1(t, bsh, offset); - break; - case 2: - i = bus_space_read_2(t, bsh, offset); - break; - case 4: - i = bus_space_read_4(t, bsh, offset); - break; - case 8: - default: - panic("bus_space_probe: unsupported data size %d", sz); - /* NOTREACHED */ - } - - nofault = (label_t *)0; - return (1); -} - -void -mac68k_bus_space_handle_swapped(t, h) - bus_space_tag_t t; - bus_space_handle_t *h; -{ - h->swapped = 1; - h->bsr2 = mac68k_bsr2_swap; - h->bsr4 = mac68k_bsr4_swap; - h->bsrm2 = mac68k_bsrm2_swap; - h->bsrm4 = mac68k_bsrm4_swap; - h->bsrr2 = mac68k_bsrr2_swap; - h->bsrr4 = mac68k_bsrr4_swap; - h->bsw2 = mac68k_bsw2_swap; - h->bsw4 = mac68k_bsw4_swap; - h->bswm2 = mac68k_bswm2_swap; - h->bswm4 = mac68k_bswm4_swap; - h->bswr2 = mac68k_bswr2_swap; - h->bswr4 = mac68k_bswr4_swap; - h->bssm2 = mac68k_bssm2_swap; - h->bssm4 = mac68k_bssm4_swap; - h->bssr2 = mac68k_bssr2_swap; - h->bssr4 = mac68k_bssr4_swap; -} - -u_int8_t -mac68k_bsr1(bus_space_tag_t t, bus_space_handle_t *bsh, bus_size_t offset) -{ - return (*(volatile u_int8_t *) (bsh->base + offset)); -} - -u_int16_t -mac68k_bsr2(bus_space_tag_t t, bus_space_handle_t *bsh, bus_size_t offset) -{ - return (*(volatile u_int16_t *) (bsh->base + offset)); -} - -u_int16_t -mac68k_bsr2_swap(bus_space_tag_t t, bus_space_handle_t *bsh, bus_size_t offset) -{ - u_int16_t v; - - v = (*(volatile u_int16_t *) (bsh->base + offset)); - return swap16(v); -} - -u_int32_t -mac68k_bsr4(bus_space_tag_t tag, bus_space_handle_t *bsh, bus_size_t offset) -{ - return (*(volatile u_int32_t *) (bsh->base + offset)); -} - -u_int32_t -mac68k_bsr4_swap(bus_space_tag_t t, bus_space_handle_t *bsh, bus_size_t offset) -{ - u_int32_t v; - - v = (*(volatile u_int32_t *) (bsh->base + offset)); - return swap32(v); -} - -void -mac68k_bsrm1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int8_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movb a0@,a1@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0"); -} - -void -mac68k_bsrm2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int16_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movw a0@,a1@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0"); -} - -void -mac68k_bsrm2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int16_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movw a0@,d1 ;" - " rolw #8,d1 ;" - " movw d1,a1@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0","d1"); -} - -void -mac68k_bsrm4(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int32_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,%d0 ;" - "1: movl a0@,a1@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0"); -} - -void -mac68k_bsrm4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int32_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movl a0@,d1 ;" - " rolw #8,d1 ;" - " swap d1 ;" - " rolw #8,d1 ;" - " movl d1,a1@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0","d1"); -} - -void -mac68k_bsrr1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int8_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movb a0@+,a1@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0"); -} - -void -mac68k_bsrr2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int16_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movw a0@+,a1@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0"); -} - -void -mac68k_bsrr2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int16_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movw a0@+,d1 ;" - " rolw #8,d1 ;" - " movw d1,a1@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0","d1"); -} - -void -mac68k_bsrr4(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int32_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movl a0@+,a1@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0"); -} - -void -mac68k_bsrr4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int32_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movl a0@+,d1 ;" - " rolw #8,d1 ;" - " swap d1 ;" - " rolw #8,d1 ;" - " movl d1,a1@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0"); -} - -void -mac68k_bsw1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int8_t v) -{ - (*(volatile u_int8_t *)(h->base + offset)) = v; -} - -void -mac68k_bsw2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int16_t v) -{ - (*(volatile u_int16_t *)(h->base + offset)) = v; -} - -void -mac68k_bsw2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int16_t v) -{ - v = swap16(v); - (*(volatile u_int16_t *)(h->base + offset)) = v; -} - -void -mac68k_bsw4(bus_space_tag_t tag, bus_space_handle_t *h, bus_size_t offset, - u_int32_t v) -{ - (*(volatile u_int32_t *)(h->base + offset)) = v; -} - -void -mac68k_bsw4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int32_t v) -{ - v = swap32(v); - (*(volatile u_int32_t *)(h->base + offset)) = v; -} - -void -mac68k_bswm1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - const u_int8_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movb a1@+,a0@ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0"); -} - -void -mac68k_bswm2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - const u_int16_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movw a1@+,a0@ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0"); -} - -void -mac68k_bswm2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - const u_int16_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movw a1@+,d1 ;" - " rolw #8,d1 ;" - " movw d1,a0@ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0","d1"); -} - -void -mac68k_bswm4(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - const u_int32_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movl a1@+,a0@ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0"); -} - -void -mac68k_bswm4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - const u_int32_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movl a1@+,d1 ;" - " rolw #8,d1 ;" - " swap d1 ;" - " rolw #8,d1 ;" - " movl d1,a0@ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0","d1"); -} - -void -mac68k_bswr1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - const u_int8_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movb a1@+,a0@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0"); -} - -void -mac68k_bswr2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - const u_int16_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movw a1@+,a0@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0"); -} - -void -mac68k_bswr2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - const u_int16_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movw a1@+,d1 ;" - " rolw #8,d1 ;" - " movw d1,a0@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0","d1"); -} - -void -mac68k_bswr4(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - const u_int32_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movl a1@+,a0@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0"); -} - -void -mac68k_bswr4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - const u_int32_t *a, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,a1 ;" - " movl %2,d0 ;" - "1: movl a1@+,d1 ;" - " rolw #8,d1 ;" - " swap d1 ;" - " rolw #8,d1 ;" - " movl d1,a0@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" (a), "g" (c) : - "a0","a1","d0","d1"); -} - -void -mac68k_bssm1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int8_t v, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,d1 ;" - " movl %2,d0 ;" - "1: movb d1,a0@ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" ((u_long)v), "g" (c) : - "a0","d0","d1"); -} - -void -mac68k_bssm2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int16_t v, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,d1 ;" - " movl %2,d0 ;" - "1: movw d1,a0@ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" ((u_long)v), "g" (c) : - "a0","d0","d1"); -} - -void -mac68k_bssm2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int16_t v, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,d1 ;" - " rolw #8,d1 ;" - " movl %2,d0 ;" - "1: movw d1,a0@ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" ((u_long)v), "g" (c) : - "a0","d0","d1"); -} - -void -mac68k_bssm4(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int32_t v, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,d1 ;" - " movl %2,d0 ;" - "1: movl d1,a0@ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" ((u_long)v), "g" (c) : - "a0","d0","d1"); -} - -void -mac68k_bssm4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int32_t v, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,d1 ;" - " rolw #8,d1 ;" - " swap d1 ;" - " rolw #8,d1 ;" - " movl %2,d0 ;" - "1: movl d1,a0@ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" ((u_long)v), "g" (c) : - "a0","d0","d1"); -} - -void -mac68k_bssr1(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int8_t v, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,d1 ;" - " movl %2,d0 ;" - "1: movb d1,a0@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" ((u_long)v), "g" (c) : - "a0","d0","d1"); -} - -void -mac68k_bssr2(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int16_t v, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,d1 ;" - " movl %2,d0 ;" - "1: movw d1,a0@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" ((u_long)v), "g" (c) : - "a0","d0","d1"); -} - -void -mac68k_bssr2_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int16_t v, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,d1 ;" - " rolw #8,d1 ;" - " movl %2,d0 ;" - "1: movw d1,a0@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" ((u_long)v), "g" (c) : - "a0","d0","d1"); -} - -void -mac68k_bssr4(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int32_t v, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,d1 ;" - " movl %2,d0 ;" - "1: movl d1,a0@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" ((u_long)v), "g" (c) : - "a0","d0","d1"); -} - -void -mac68k_bssr4_swap(bus_space_tag_t t, bus_space_handle_t *h, bus_size_t offset, - u_int32_t v, size_t c) -{ - __asm __volatile ( - " movl %0,a0 ;" - " movl %1,d1 ;" - " rolw #8,d1 ;" - " swap d1 ;" - " rolw #8,d1 ;" - " movl %2,d0 ;" - "1: movl d1,a0@+ ;" - " subql #1,d0 ;" - " jne 1b" : - : - "r" (h->base + offset), "g" ((u_long)v), "g" (c) : - "a0","d0","d1"); -} diff --git a/sys/arch/mac68k/mac68k/clock.c b/sys/arch/mac68k/mac68k/clock.c deleted file mode 100644 index af50ea6faf2..00000000000 --- a/sys/arch/mac68k/mac68k/clock.c +++ /dev/null @@ -1,409 +0,0 @@ -/* $OpenBSD: clock.c,v 1.24 2007/07/14 19:06:48 miod Exp $ */ -/* $NetBSD: clock.c,v 1.39 1999/11/05 19:14:56 scottr Exp $ */ - -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -/* - * - * from: Utah $Hdr: clock.c 1.18 91/01/21$ - * - * @(#)clock.c 7.6 (Berkeley) 5/7/91 - */ - -/* - * Mac II machine-dependent clock routines. - */ - -#include <sys/param.h> -#include <sys/device.h> -#include <sys/limits.h> -#include <sys/kernel.h> -#include <sys/systm.h> - -#include <machine/autoconf.h> -#include <machine/psl.h> -#include <machine/cpu.h> - -#include <mac68k/mac68k/pram.h> -#include <machine/viareg.h> - -#include <dev/clock_subr.h> - -#ifdef DEBUG -int clock_debug = 0; -#endif - -int rtclock_intr(void *); - -u_int clk_interval; -u_int8_t clk_inth, clk_intl; - -#define DIFF19041970 2082844800 - -/* - * The Macintosh timers decrement once every 1.2766 microseconds. - * MGFH2, p. 180 - */ -#define CLK_RATE 12766 - -/* - * Start the real-time clock; i.e. set timer latches and boot timer. - * - * We use VIA1 timer 1. - */ -void -startrtclock() -{ -#ifndef HZ - /* - * By default, if HZ is not specified, use 60 Hz, unless we are - * using A/UX style interrupts. We then need to readjust values - * based on a 100Hz value in param.c. - */ - if (mac68k_machine.aux_interrupts == 0) { -#define HZ_60 60 - hz = HZ_60; - tick = 1000000 / HZ_60; - tickadj = 240000 / (60 * HZ_60);/* can adjust 240ms in 60s */ - } -#endif - - /* - * Calculate clocks needed to hit hz ticks/sec. - * - * The VIA clock speed is 1.2766us, so the timer value needed is: - * - * 1 1,000,000us 1 - * CLK_INTERVAL = -------- * ----------- * ------ - e 1.2766us 1s hz - * - * While it may be tempting to simplify the following further, - * we can run into integer overflow problems. - * Also note: do *not* define HZ to be less than 12; overflow - * will occur, yielding invalid results. - */ - clk_interval = ((100000000UL / hz) * 100) / 12766; - clk_inth = ((clk_interval >> 8) & 0xff); - clk_intl = (clk_interval & 0xff); - - /* be certain clock interrupts are off */ - via_reg(VIA1, vIER) = V1IF_T1; - - /* set timer latch */ - via_reg(VIA1, vACR) |= ACR_T1LATCH; - - /* set VIA timer 1 latch to ``hz'' Hz */ - via_reg(VIA1, vT1L) = clk_intl; - via_reg(VIA1, vT1LH) = clk_inth; - - /* set VIA timer 1 counter started for ``hz'' Hz */ - via_reg(VIA1, vT1C) = clk_intl; - via_reg(VIA1, vT1CH) = clk_inth; -} - -void -cpu_initclocks() -{ - tickfix = 1000000 - (hz * tick); - if (tickfix != 0) { - int ftp; - - ftp = min(ffs(tickfix), ffs(hz)); - tickfix >>= (ftp - 1); - tickfixinterval = hz >> (ftp - 1); - } - - /* clear then enable clock interrupt. */ - via_reg(VIA1, vIFR) |= V1IF_T1; - via_reg(VIA1, vIER) = 0x80 | V1IF_T1; -} - -void -setstatclockrate(rateinhz) - int rateinhz; -{ -} - -/* - * Returns number of usec since last clock tick/interrupt. - * - * Check high byte twice to prevent missing a roll-over. - * (race condition?) - */ -u_long -clkread() -{ - int high, high2, low; - - high = via_reg(VIA1, vT1CH); - low = via_reg(VIA1, vT1C); - - high2 = via_reg(VIA1, vT1CH); - if (high != high2) - high = high2; - - /* return count left in timer / 1.27 */ - return ((clk_interval - (high << 8) - low) * 10000 / CLK_RATE); -} - -static u_long ugmt_2_pramt(u_long); -static u_long pramt_2_ugmt(u_long); - -/* - * Convert GMT to Mac PRAM time, using rtc_offset - * GMT bias adjustment is done elsewhere. - */ -static u_long -ugmt_2_pramt(t) - u_long t; -{ - /* don't know how to open a file properly. */ - /* assume compiled timezone is correct. */ - - return (t + DIFF19041970 - 60 * tz.tz_minuteswest); -} - -/* - * Convert a Mac PRAM time value to GMT, using rtc_offset - * GMT bias adjustment is done elsewhere. - */ -static u_long -pramt_2_ugmt(t) - u_long t; -{ - return (t - DIFF19041970 + 60 * tz.tz_minuteswest); -} - -/* - * Time from the booter. - */ -u_long macos_boottime; - -/* - * Bias in minutes east from GMT (also from booter). - */ -long macos_gmtbias; - -/* - * Flag for whether or not we can trust the PRAM. If we don't - * trust it, we don't write to it, and we take the MacOS value - * that is passed from the booter (which will only be a second - * or two off by now). - */ -int mac68k_trust_pram = 1; - -/* - * Set global GMT time register, using a file system time base for comparison - * and sanity checking. - */ -void -inittodr(base) - time_t base; -{ - u_long timbuf; - - timbuf = pram_readtime(); - if (timbuf == 0) { - /* We don't know how to access PRAM on this hardware. */ - timbuf = macos_boottime; - mac68k_trust_pram = 0; - } else { - timbuf = pramt_2_ugmt(pram_readtime()); - if ((timbuf - (macos_boottime + 60 * tz.tz_minuteswest)) > - 10 * 60) { -#ifdef DIAGNOSTIC - printf("PRAM time does not appear" - " to have been read correctly.\n"); - printf("PRAM: 0x%lx, macos_boottime: 0x%lx.\n", - timbuf, macos_boottime + 60 * tz.tz_minuteswest); -#endif - timbuf = macos_boottime; - mac68k_trust_pram = 0; - } -#ifdef DEBUG - else - printf("PRAM: 0x%lx, macos_boottime: 0x%lx.\n", - timbuf, macos_boottime); -#endif - } - - /* - * GMT bias is passed in from Booter - * To get GMT, *subtract* GMTBIAS from *our* time - * (gmtbias is in minutes, mult by 60) - */ - timbuf -= macos_gmtbias * 60; - - if (base < 5 * SECYR) { - printf("WARNING: file system time earlier than 1975\n"); - printf(" -- CHECK AND RESET THE DATE!\n"); - base = 36 * SECYR; /* Last update here in 2006... */ - } - if (timbuf < base) { - printf( - "WARNING: Battery clock has earlier time than UNIX fs.\n"); - timbuf = base; - } - time.tv_sec = timbuf; - time.tv_usec = 0; -} - -/* - * Set battery backed clock to a new time, presumably after someone has - * changed system time. - */ -void -resettodr() -{ - if (mac68k_trust_pram) - /* - * GMT bias is passed in from the Booter. - * To get *our* time, add GMTBIAS to GMT. - * (gmtbias is in minutes, multiply by 60). - */ - pram_settime(ugmt_2_pramt(time.tv_sec + macos_gmtbias * 60)); -} - -#define DELAY_CALIBRATE (0xffffff << 7) /* Large value for calibration */ - -u_int delay_factor = DELAY_CALIBRATE; -volatile int delay_flag = 1; - -int _delay(u_int); -static int delay_timer1_irq(void *); - -static int -delay_timer1_irq(dummy) - void *dummy; -{ - delay_flag = 0; - return (1); -} - -/* - * Calibrate delay_factor with VIA1 timer T1. - */ -void -mac68k_calibrate_delay() -{ - u_int sum, n; - - /* Disable VIA1 timer 1 interrupts and set up service routine */ - via_reg(VIA1, vIER) = V1IF_T1; - via1_register_irq(VIA1_T1, delay_timer1_irq, NULL, NULL); - - /* Set the timer for one-shot mode, then clear and enable interrupts */ - via_reg(VIA1, vACR) &= ~ACR_T1LATCH; - via_reg(VIA1, vIFR) = V1IF_T1; /* (this is needed for IIsi) */ - via_reg(VIA1, vIER) = 0x80 | V1IF_T1; - -#ifdef DEBUG - if (clock_debug) - printf("mac68k_calibrate_delay(): entering timing loop\n"); -#endif - - (void)_spl(IPLTOPSL(mac68k_machine.via1_ipl) - 1); - - for (sum = 0, n = 8; n > 0; n--) { - delay_flag = 1; - via_reg(VIA1, vT1C) = 0; /* 1024 clock ticks */ - via_reg(VIA1, vT1CH) = 4; /* (approx 1.3 msec) */ - sum += ((delay_factor >> 7) - _delay(1)); - } - - (void)splhigh(); - - /* Disable timer interrupts and reset service routine */ - via_reg(VIA1, vIER) = V1IF_T1; - via1_register_irq(VIA1_T1, rtclock_intr, NULL, NULL); - - /* - * If this weren't integer math, the following would look - * a lot prettier. It should really be something like - * this: - * delay_factor = ((sum / 8) / (1024 * 1.2766)) * 128; - * That is, average the sum, divide by the number of usec, - * and multiply by a scale factor of 128. - * - * We can accomplish the same thing by simplifying and using - * shifts, being careful to avoid as much loss of precision - * as possible. (If the sum exceeds UINT_MAX/10000, we need - * to rearrange the calculation slightly to do this.) - */ - if (sum > (UINT_MAX / 10000)) /* This is a _fast_ machine! */ - delay_factor = (((sum >> 3) * 10000) / CLK_RATE) >> 3; - else - delay_factor = (((sum * 10000) >> 3) / CLK_RATE) >> 3; - - /* Reset the delay_flag for normal use */ - delay_flag = 1; - -#ifdef DEBUG - if (clock_debug) - printf("mac68k_calibrate_delay(): delay_factor calibrated\n"); -#endif -} diff --git a/sys/arch/mac68k/mac68k/conf.c b/sys/arch/mac68k/mac68k/conf.c deleted file mode 100644 index cccd2f4827c..00000000000 --- a/sys/arch/mac68k/mac68k/conf.c +++ /dev/null @@ -1,254 +0,0 @@ -/* $OpenBSD: conf.c,v 1.49 2011/10/06 20:49:28 deraadt Exp $ */ -/* $NetBSD: conf.c,v 1.41 1997/02/11 07:35:49 scottr Exp $ */ - -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/*- - * Derived a long time ago from - * @(#)conf.c 7.9 (Berkeley) 5/28/91 - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/buf.h> -#include <sys/ioctl.h> -#include <sys/tty.h> -#include <sys/conf.h> -#include <sys/vnode.h> -#include <dev/cons.h> - -#include "st.h" -#include "sd.h" -#include "cd.h" -#include "ch.h" -#include "vnd.h" -#include "rd.h" - -struct bdevsw bdevsw[] = -{ - bdev_notdef(), /* 0 */ - bdev_notdef(), /* 1 */ - bdev_notdef(), /* 2 */ - bdev_swap_init(1,sw), /* 3: swap pseudo-device */ - bdev_disk_init(NSD,sd), /* 4: SCSI disk */ - bdev_tape_init(NST,st), /* 5: SCSI tape */ - bdev_disk_init(NCD,cd), /* 6: SCSI CD-ROM */ - bdev_notdef(), /* 7 */ - bdev_disk_init(NVND,vnd), /* 8: vnode disk driver */ - bdev_notdef(), /* 9: was: concatenated disk driver */ - bdev_notdef(), /* 10 */ - bdev_notdef(), /* 11 */ - bdev_notdef(), /* 12 */ - bdev_disk_init(NRD,rd), /* 13: RAM disk -- for install */ - bdev_lkm_dummy(), /* 14 */ - bdev_lkm_dummy(), /* 15 */ - bdev_lkm_dummy(), /* 16 */ - bdev_lkm_dummy(), /* 17 */ - bdev_lkm_dummy(), /* 18 */ - bdev_lkm_dummy(), /* 19 */ -}; -int nblkdev = nitems(bdevsw); - -#define mmread mmrw -#define mmwrite mmrw -cdev_decl(mm); -#include "bio.h" -#include "pty.h" -#include "uk.h" -cdev_decl(fd); -#include "zsc.h" -cdev_decl(zsc); -#include "zstty.h" -cdev_decl(zs); -#include "bpfilter.h" -#include "tun.h" -#include "asc.h" -cdev_decl(asc); -#include "ksyms.h" -#ifdef NNPFS -#include <nnpfs/nnnpfs.h> -cdev_decl(nnpfs_dev); -#endif -#include "wsdisplay.h" -#include "wskbd.h" -#include "wsmouse.h" -#include "wsmux.h" - -#include "pf.h" - -#include "systrace.h" - -#include "vscsi.h" -#include "pppx.h" - -struct cdevsw cdevsw[] = -{ - cdev_cn_init(1,cn), /* 0: virtual console */ - cdev_ctty_init(1,ctty), /* 1: controlling terminal */ - cdev_mm_init(1,mm), /* 2: /dev/{null,mem,kmem,...} */ - cdev_notdef(), /* 3 was /dev/drum */ - cdev_tty_init(NPTY,pts), /* 4: pseudo-tty slave */ - cdev_ptc_init(NPTY,ptc), /* 5: pseudo-tty master */ - cdev_log_init(1,log), /* 6: /dev/klog */ - cdev_notdef(), /* 7 */ - cdev_notdef(), /* 8 */ - cdev_notdef(), /* 9 */ - cdev_notdef(), /* 10 was GRF */ - cdev_notdef(), /* 11 was ITE */ - cdev_tty_init(NZSTTY,zs), /* 12: 2 mac serial ports -- BG*/ - cdev_disk_init(NSD,sd), /* 13: SCSI disk */ - cdev_tape_init(NST,st), /* 14: SCSI tape */ - cdev_disk_init(NCD,cd), /* 15: SCSI CD-ROM */ - cdev_notdef(), /* 16 */ - cdev_ch_init(NCH,ch), /* 17: SCSI autochanger */ - cdev_disk_init(NRD,rd), /* 18: ramdisk device */ - cdev_disk_init(NVND,vnd), /* 19: vnode disk driver */ - cdev_notdef(), /* 20: was: concatenated disk driver */ - cdev_fd_init(1,filedesc), /* 21: file descriptor pseudo-device */ - cdev_bpf_init(NBPFILTER,bpf), /* 22: Berkeley packet filter */ - cdev_notdef(), /* 23 was ADB */ - cdev_tun_init(NTUN,tun), /* 24: network tunnel */ - cdev_lkm_init(NLKM,lkm), /* 25: loadable module driver */ - cdev_lkm_dummy(), /* 26 */ - cdev_lkm_dummy(), /* 27 */ - cdev_lkm_dummy(), /* 28 */ - cdev_lkm_dummy(), /* 29 */ - cdev_lkm_dummy(), /* 30 */ - cdev_lkm_dummy(), /* 31 */ - cdev_random_init(1,random), /* 32: random data source */ - cdev_notdef(), /* 33 */ - cdev_uk_init(NUK,uk), /* 34: SCSI unknown */ - cdev_pf_init(NPF,pf), /* 35: packet filter */ - cdev_audio_init(NASC,asc), /* 36: ASC audio device */ - cdev_ksyms_init(NKSYMS,ksyms), /* 37: Kernel symbols device */ - cdev_wsdisplay_init(NWSDISPLAY, wsdisplay), /* 38: displays */ - cdev_mouse_init(NWSKBD, wskbd), /* 39: keyboards */ - cdev_mouse_init(NWSMOUSE, wsmouse), /* 40: mice */ - cdev_mouse_init(NWSMUX, wsmux), /* 41: ws multiplexor */ - cdev_notdef(), /* 42 */ - cdev_notdef(), /* 43 */ - cdev_notdef(), /* 44 */ - cdev_notdef(), /* 45 */ - cdev_notdef(), /* 46 */ - cdev_notdef(), /* 47 */ - cdev_notdef(), /* 48 */ - cdev_bio_init(NBIO,bio), /* 49: ioctl tunnel */ - cdev_systrace_init(NSYSTRACE,systrace), /* 50 system call tracing */ -#ifdef NNPFS - cdev_nnpfs_init(NNNPFS,nnpfs_dev), /* 51: nnpfs communication device */ -#else - cdev_notdef(), /* 51 */ -#endif - cdev_ptm_init(NPTY,ptm), /* 52: pseudo-tty ptm device */ - cdev_vscsi_init(NVSCSI,vscsi), /* 53: vscsi */ - cdev_disk_init(1,diskmap), /* 54: disk mapper */ - cdev_pppx_init(NPPPX,pppx), /* 55: pppx */ -}; -int nchrdev = nitems(cdevsw); - -int mem_no = 2; /* major device number of memory special file */ - -/* - * Swapdev is a fake device implemented - * in sw.c used only internally to get to swstrategy. - * It cannot be provided to the users, because the - * swstrategy routine munches the b_dev and b_blkno entries - * before calling the appropriate driver. This would horribly - * confuse, e.g. the hashing routines. Instead, /dev/drum is - * provided as a character (raw) device. - */ -dev_t swapdev = makedev(3, 0); - -/* - * Returns true if dev is /dev/mem or /dev/kmem. - */ -int -iskmemdev(dev) - dev_t dev; -{ - - return (major(dev) == mem_no && minor(dev) < 2); -} - -/* - * Returns true if dev is /dev/zero. - */ -int -iszerodev(dev) - dev_t dev; -{ - - return (major(dev) == mem_no && minor(dev) == 12); -} - -dev_t -getnulldev() -{ - return makedev(mem_no, 2); -} - -int chrtoblktbl[] = { - /* XXXX This needs to be dynamic for LKMs. */ - /*VCHR*/ /*VBLK*/ - /* 0 */ NODEV, - /* 1 */ NODEV, - /* 2 */ NODEV, - /* 3 */ NODEV, - /* 4 */ NODEV, - /* 5 */ NODEV, - /* 6 */ NODEV, - /* 7 */ NODEV, - /* 8 */ NODEV, - /* 9 */ NODEV, - /* 10 */ NODEV, - /* 11 */ NODEV, - /* 12 */ NODEV, - /* 13 */ 4, /* sd */ - /* 14 */ 5, /* st */ - /* 15 */ 6, /* cd */ - /* 16 */ NODEV, - /* 17 */ NODEV, - /* 18 */ 13, /* rd */ - /* 19 */ 8 /* vnd */ -}; -int nchrtoblktbl = nitems(chrtoblktbl); - -cons_decl(ws); -#define zscnpollc nullcnpollc -cons_decl(zs); - -struct consdev constab[] = { -#if NWSDISPLAY > 0 - cons_init(ws), -#endif -#if NZSTTY > 0 - cons_init(zs), -#endif - { 0 }, -}; diff --git a/sys/arch/mac68k/mac68k/disksubr.c b/sys/arch/mac68k/mac68k/disksubr.c deleted file mode 100644 index c5f49162537..00000000000 --- a/sys/arch/mac68k/mac68k/disksubr.c +++ /dev/null @@ -1,519 +0,0 @@ -/* $OpenBSD: disksubr.c,v 1.63 2011/04/16 03:21:15 krw Exp $ */ -/* $NetBSD: disksubr.c,v 1.22 1997/11/26 04:18:20 briggs Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1988 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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. - * - */ - -/* rewritten, 2-5-93 MLF */ -/* it's a lot cleaner now, and adding support for new partition types - * isn't a bitch anymore - * known bugs: - * 1) when only an HFS_PART part exists on a drive it gets assigned to "B" - * this is because of line 623 of sd.c, I think this line should go. - * 2) /sbin/disklabel expects the whole disk to be in "D", we put it in - * "C" (I think) and we don't set that position in the disklabel structure - * as used. Again, not my fault. - */ -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/buf.h> -#include <sys/disk.h> -#include <sys/disklabel.h> -#include <sys/malloc.h> -#include <sys/syslog.h> - -#include <mac68k/mac68k/dpme.h> /* MF the structure of a mac partition entry */ - -#define NUM_PARTS_PROBED 32 - -#define NO_PART 0 -#define ROOT_PART 1 -#define UFS_PART 2 -#define SWAP_PART 3 -#define HFS_PART 4 -#define SCRATCH_PART 5 - -int getFreeLabelEntry(struct disklabel *); -int whichType(struct partmapentry *); -int fixPartTable(struct partmapentry *, long, char *); -void setPart(struct partmapentry *, struct disklabel *, int, int); -int getNamedType(struct partmapentry *, int8_t *, int, int, int); -int read_mac_label(char *, struct disklabel *, int); - -/* - * Find an entry in the disk label that is unused and return it - * or -1 if no entry - */ -int -getFreeLabelEntry(struct disklabel *lp) -{ - int i; - - for (i = 0; i < MAXPARTITIONS; i++) { - if (i != RAW_PART && lp->d_partitions[i].p_fstype == FS_UNUSED) - return i; - } - return -1; -} - -/* - * figure out what the type of the given part is and return it - */ -int -whichType(struct partmapentry *part) -{ - struct blockzeroblock *bzb; - - if (part->pmPartType[0] == '\0') - return NO_PART; - - /* - * Do not show MacOS internal use partitions. - */ - if (strcmp(PART_DRIVER_TYPE, (char *)part->pmPartType) == 0 || - strcmp(PART_DRIVER43_TYPE, (char *)part->pmPartType) == 0 || - strcmp(PART_DRIVERATA_TYPE, (char *)part->pmPartType) == 0 || - strcmp(PART_FWB_COMPONENT_TYPE, (char *)part->pmPartType) == 0 || - strcmp(PART_PARTMAP_TYPE, (char *)part->pmPartType) == 0) - return NO_PART; - - if (strcmp(PART_UNIX_TYPE, (char *)part->pmPartType) == 0) { - /* unix part, swap, root, usr */ - bzb = (struct blockzeroblock *)(&part->pmBootArgs); - if (bzb->bzbMagic != BZB_MAGIC) - return NO_PART; - - if (bzb->bzbFlags & BZB_ROOTFS) - return ROOT_PART; - - if ((bzb->bzbFlags & BZB_USRFS) || - (bzb->bzbFlags & BZB_EXFS4) || - (bzb->bzbFlags & BZB_EXFS5) || - (bzb->bzbFlags & BZB_EXFS6)) - return UFS_PART; - - if (bzb->bzbType == BZB_TYPESWAP) - return SWAP_PART; - } - if (strcmp(PART_MAC_TYPE, (char *)part->pmPartType) == 0) - return HFS_PART; - - return SCRATCH_PART; /* no known type, but label it, anyway */ -} - -/* - * Take part table in crappy form, place it in a structure we can depend - * upon. Make sure names are NUL terminated. Capitalize the names - * of part types. - */ -int -fixPartTable(struct partmapentry *partTable, long size, char *base) -{ - struct partmapentry *pmap; - char *s; - int i; - - for (i = 0; i < NUM_PARTS_PROBED; i++) { - pmap = (struct partmapentry *)((i * size) + base + DEV_BSIZE); - partTable[i] = *pmap; - pmap = &partTable[i]; - - if (pmap->pmSig != DPME_MAGIC) { /* this is not valid */ - pmap->pmPartType[0] = '\0'; - return i; - } - - pmap->pmPartName[31] = '\0'; - pmap->pmPartType[31] = '\0'; - - /* toupper the string, in case caps are different... */ - for (s = pmap->pmPartType; *s; s++) - if ((*s >= 'a') && (*s <= 'z')) - *s = (*s - 'a' + 'A'); - } - return NUM_PARTS_PROBED; -} - -void -setPart(struct partmapentry *part, struct disklabel *lp, int fstype, int slot) -{ - DL_SETPSIZE(&lp->d_partitions[slot], part->pmPartBlkCnt); - DL_SETPOFFSET(&lp->d_partitions[slot], part->pmPyPartStart); - lp->d_partitions[slot].p_fstype = fstype; -} - -int -getNamedType(struct partmapentry *part, int8_t *parttypes, int num_parts, - int type, int alt) -{ - struct blockzeroblock *bzb; - int i; - - for (i = 0; i < num_parts; i++) { - if (parttypes[i] != type) - continue; - - switch (type) { - case ROOT_PART: - case UFS_PART: - bzb = (struct blockzeroblock *)&part[i].pmBootArgs; - if (alt >= 0 && alt != bzb->bzbCluster) - continue; - break; - case SWAP_PART: - break; - } - return i; - } - return -1; -} - -/* - * read in the entire diskpartition table, it may be bigger or smaller - * than NUM_PARTS_PROBED but read that many entries. Each entry has a magic - * number so we'll know if an entry is crap. - * next fill in the disklabel with info like this - * next fill in the root, usr, and swap parts. - * then look for anything else and fit it in. - * A: root - * B: Swap - * C: Whole disk - * - * AKB -- I added to Mike's original algorithm by searching for a bzbCluster - * of zero for root, first. This allows A/UX to live on cluster 1 and - * NetBSD to live on cluster 0--regardless of the actual order on the - * disk. This whole algorithm should probably be changed in the future. - */ -int -read_mac_label(char *dlbuf, struct disklabel *lp, int spoofonly) -{ - int i, num_parts; - int root_part, swap_part, usr_part; - uint64_t bsdstart, bsdend; - struct partmapentry *pmap; - int8_t parttype[NUM_PARTS_PROBED]; - - pmap = (struct partmapentry *)malloc(NUM_PARTS_PROBED * - sizeof(struct partmapentry), M_DEVBUF, M_NOWAIT); - if (pmap == NULL) - return (ENOMEM); - - bsdend = 0; - bsdstart = DL_GETDSIZE(lp); - - num_parts = fixPartTable(pmap, lp->d_secsize, dlbuf); - for (i = 0; i < num_parts; i++) - parttype[i] = whichType(&pmap[i]); - - /* - * Find out our /, swap and /usr partitions, preferrably - * with a bzbCluster value of zero. - */ - root_part = getNamedType(pmap, parttype, num_parts, ROOT_PART, 0); - if (root_part < 0) - root_part = - getNamedType(pmap, parttype, num_parts, ROOT_PART, -1); - swap_part = getNamedType(pmap, parttype, num_parts, SWAP_PART, -1); - usr_part = getNamedType(pmap, parttype, num_parts, UFS_PART, 0); - if (usr_part < 0) - usr_part = - getNamedType(pmap, parttype, num_parts, UFS_PART, -1); - - /* - * Figure out the OpenBSD part of the disk. - * Unfortunately, since each OpenBSD partition maps to an A/UX - * partition, the OpenBSD area may not be contiguous. - * We return the range containing all OpenBSD partitions, and - * hope the user will setup the disk with a single contiguous - * area... - */ - - for (i = 0; i < num_parts; i++) { - switch (parttype[i]) { - case ROOT_PART: - /* - * If there are multiple A/UX Root partitions, - * only count `ours' in the OpenBSD area. - */ - if (i != root_part) - continue; - break; - case SWAP_PART: - case UFS_PART: - break; - default: - continue; - } - - if (bsdstart > pmap[i].pmPyPartStart) - bsdstart = pmap[i].pmPyPartStart; - if (bsdend < pmap[i].pmPyPartStart + pmap[i].pmPartBlkCnt) - bsdend = pmap[i].pmPyPartStart + pmap[i].pmPartBlkCnt; - } - - /* - * Add all partitions to the disklabel. - */ - - if (root_part >= 0) - setPart(&pmap[root_part], lp, FS_BSDFFS, 0); /* a */ - if (swap_part >= 0) - setPart(&pmap[swap_part], lp, FS_SWAP, 1); /* b */ - if (usr_part >= 0) - setPart(&pmap[usr_part], lp, FS_BSDFFS, 6); /* g */ - - for (i = 0; i < num_parts; i++) { - int slot, fstype; - - if (i == root_part || i == swap_part || i == usr_part) - continue; - - if ((slot = getFreeLabelEntry(lp)) < 0) - break; - - switch (parttype[i]) { - default: - fstype = FS_UNUSED; - break; - case ROOT_PART: - fstype = FS_BSDFFS; - break; - case UFS_PART: - fstype = FS_BSDFFS; - break; - case SWAP_PART: - fstype = FS_SWAP; - break; - case HFS_PART: - fstype = FS_HFS; - break; - case SCRATCH_PART: - fstype = FS_OTHER; - break; - } - if (fstype != FS_UNUSED) - setPart(&pmap[i], lp, fstype, slot); - } - - free(pmap, M_DEVBUF); - - DL_SETBSTART(lp, bsdstart); - DL_SETBEND(lp, bsdend < DL_GETDSIZE(lp) ? bsdend : DL_GETDSIZE(lp)); - - /* - * Clear BSD partitions if spoofing. We had to insert them to be sure - * the HFS partitions would appear at the right positions. - */ - if (spoofonly) { - for (i = 0; i < MAXPARTITIONS; i++) { - switch (lp->d_partitions[i].p_fstype) { - case FS_BSDFFS: - case FS_SWAP: /* XXX maybe unwise */ - lp->d_partitions[i].p_fstype = FS_UNUSED; - DL_SETPSIZE(&lp->d_partitions[i], 0); - DL_SETPOFFSET(&lp->d_partitions[i], 0); - break; - } - } - - return (0); - } - - lp->d_npartitions = MAXPARTITIONS; - lp->d_version = 1; - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - return (checkdisklabel(lp, lp, bsdstart, bsdend)); -} - -/* - * Attempt to read a disk label from a device using the indicated strategy - * routine. The label must be partly set up before this: secpercyl and - * anything required in the strategy routine (e.g., sector size) must be - * filled in before calling us. - */ -int -readdisklabel(dev_t dev, void (*strat)(struct buf *), - struct disklabel *lp, int spoofonly) -{ - struct buf *bp = NULL; - u_int16_t *sbSigp; - int size; - int error; - - if ((error = initdisklabel(lp))) - goto done; - - size = roundup((NUM_PARTS_PROBED + 1) << DEV_BSHIFT, lp->d_secsize); - bp = geteblk(size); - bp->b_dev = dev; - - bp->b_blkno = LABELSECTOR; - bp->b_bcount = size; - CLR(bp->b_flags, B_READ | B_WRITE | B_DONE); - SET(bp->b_flags, B_BUSY | B_READ | B_RAW); - (*strat)(bp); - if (biowait(bp)) { - error = bp->b_error; - goto done; - } - - sbSigp = (u_int16_t *)bp->b_data; - if (*sbSigp == 0x4552) { - error = read_mac_label(bp->b_data, lp, spoofonly); - if (error == 0) - goto done; - } - - if (spoofonly) - goto doslabel; - - /* Get a MI label */ - bp->b_blkno = LABELSECTOR; - bp->b_bcount = lp->d_secsize; - CLR(bp->b_flags, B_READ | B_WRITE | B_DONE); - SET(bp->b_flags, B_BUSY | B_READ | B_RAW); - (*strat)(bp); - if (biowait(bp)) { - error = bp->b_error; - goto done; - } - - error = checkdisklabel(bp->b_data + LABELOFFSET, lp, 0, - DL_GETDSIZE(lp)); - if (error == 0) - goto done; - -doslabel: - error = readdoslabel(bp, strat, lp, NULL, spoofonly); - if (error == 0) - goto done; - -#if defined(CD9660) - error = iso_disklabelspoof(dev, strat, lp); - if (error == 0) - goto done; -#endif -#if defined(UDF) - error = udf_disklabelspoof(dev, strat, lp); - if (error == 0) - goto done; -#endif - -done: - if (bp) { - bp->b_flags |= B_INVAL; - brelse(bp); - } - disk_change = 1; - return (error); -} - -/* - * Write disk label back to device after modification. - * - * To avoid spreading havoc into the MacOS partition structures, we will - * refuse to write a disklabel if the media has a MacOS signature. - */ -int -writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp) -{ - struct buf *bp = NULL; - struct disklabel *dlp; - int error = 0; - u_int16_t *sbSigp; - - /* get a buffer and initialize it */ - bp = geteblk((int)lp->d_secsize); - bp->b_dev = dev; - - bp->b_blkno = LABELSECTOR; - bp->b_bcount = lp->d_secsize; - CLR(bp->b_flags, B_READ | B_WRITE | B_DONE); - SET(bp->b_flags, B_BUSY | B_READ | B_RAW); - (*strat)(bp); - if ((error = biowait(bp)) != 0) - goto done; - - /* Check for MacOS fingerprints */ - sbSigp = (u_int16_t *)bp->b_data; - if (*sbSigp == 0x4552) { - /* XXX AND THEN DO NOT WRITE?? */ - goto done; - } - - dlp = (struct disklabel *)(bp->b_data + LABELOFFSET); - *dlp = *lp; - CLR(bp->b_flags, B_READ | B_WRITE | B_DONE); - SET(bp->b_flags, B_BUSY | B_WRITE | B_RAW); - (*strat)(bp); - error = biowait(bp); - -done: - if (bp) { - bp->b_flags |= B_INVAL; - brelse(bp); - } - disk_change = 1; - return (error); -} diff --git a/sys/arch/mac68k/mac68k/dpme.h b/sys/arch/mac68k/mac68k/dpme.h deleted file mode 100644 index 10a2cf77673..00000000000 --- a/sys/arch/mac68k/mac68k/dpme.h +++ /dev/null @@ -1,105 +0,0 @@ -/* $OpenBSD: dpme.h,v 1.7 2008/03/09 12:03:03 sobrado Exp $ */ -/* $NetBSD: dpme.h,v 1.8 1997/11/30 04:46:59 briggs Exp $ */ - -/* - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include <sys/types.h> - -/* - * Partition map structure from Inside Macintosh V-579. - */ -struct partmapentry { - u_int16_t pmSig; - u_int16_t pmSigPad; - u_int32_t pmMapBlkCnt; - u_int32_t pmPyPartStart; - u_int32_t pmPartBlkCnt; - u_int8_t pmPartName[32]; - u_int8_t pmPartType[32]; - u_int32_t pmLgDataStart; - u_int32_t pmDataCnt; - u_int32_t pmPartStatus; - u_int32_t pmLgBootStart; - u_int32_t pmBootSize; - u_int32_t pmBootLoad; - u_int32_t pmBootLoad2; - u_int32_t pmBootEntry; - u_int32_t pmBootEntry2; - u_int32_t pmBootCksum; - int8_t pmProcessor[16]; - u_int8_t pmBootArgs[128]; - u_int8_t blockpadding[248]; -}; - -/* - * Disk Partition Map Entry Magic number. Valid entries have this - * in the pmSig field. - */ -#define DPME_MAGIC 0x504d - -/* - * "pmBootArgs" for APPLE_UNIX_SVR2 partition. - * OpenBSD/mac68k only uses Magic, Cluster, Type, and Flags. - */ -struct blockzeroblock { - u_int32_t bzbMagic; - u_int8_t bzbCluster; - u_int8_t bzbType; - u_int16_t bzbBadBlockInode; - u_int16_t bzbFlags; - u_int16_t bzbReserved; - u_int32_t bzbCreationTime; - u_int32_t bzbMountTime; - u_int32_t bzbUMountTime; -}; - -#define BZB_MAGIC 0xABADBABE -#define BZB_TYPEFS 1 -#define BZB_TYPESWAP 3 -#define BZB_ROOTFS 0x8000 -#define BZB_USRFS 0x4000 -#define BZB_EXFS4 0x4 -#define BZB_EXFS5 0x5 -#define BZB_EXFS6 0x6 - -/* MF */ -#define PART_UNIX_TYPE "APPLE_UNIX_SVR2" -#define PART_MAC_TYPE "APPLE_HFS" -#define PART_SCRATCH "APPLE_SCRATCH" -#define PART_DRIVER_TYPE "APPLE_DRIVER" -#define PART_DRIVER43_TYPE "APPLE_DRIVER43" -#define PART_DRIVERATA_TYPE "APPLE_DRIVER_ATA" -#define PART_FWB_COMPONENT_TYPE "FWB DRIVER COMPONENTS" -#define PART_PARTMAP_TYPE "APPLE_PARTITION_MAP" diff --git a/sys/arch/mac68k/mac68k/genassym.cf b/sys/arch/mac68k/mac68k/genassym.cf deleted file mode 100644 index 65dc4faafc7..00000000000 --- a/sys/arch/mac68k/mac68k/genassym.cf +++ /dev/null @@ -1,86 +0,0 @@ -# $OpenBSD: genassym.cf,v 1.14 2006/01/01 13:14:44 miod Exp $ -# $NetBSD: genassym.cf,v 1.7 1998/01/06 08:46:16 thorpej Exp $ - -# -# Copyright (c) 1990 The Regents of the University of California. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# @(#)genassym.c 7.8 (Berkeley) 5/7/91 -# - -include <sys/param.h> -include <sys/buf.h> -include <sys/proc.h> -include <sys/mbuf.h> -include <sys/msgbuf.h> -include <sys/syscall.h> -include <sys/systm.h> -include <sys/types.h> -include <sys/user.h> - -include <uvm/uvm_extern.h> - -include <machine/cpu.h> -include <machine/psl.h> -include <machine/reg.h> -include <machine/pte.h> - -# proc fields and values -struct proc -member P_MD_REGS p_md.md_regs -member P_MD_FLAGS p_md.md_flags - -# PSL values -export PSL_S -export PSL_IPL7 -export PSL_LOWIPL -export PSL_USER -define PSL_TS PSL_T | PSL_S -define SPL1 PSL_S | PSL_IPL1 - -# pte/ste bits -export PG_FRAME - -# general constants -export USPACE -export PGSHIFT -export USRSTACK - -# pcb fields -struct pcb -member pcb_ps -member pcb_usp -member pcb_regs -member PCB_FPCTX pcb_fpregs -define SIZEOF_PCB sizeof(struct pcb) - -# exception frame size -define FR_SIZE sizeof(struct trapframe) - -# mac68k-specific -define CPUINFO_CLASS offsetof(struct cpu_model_info, class) -export MACH_CLASSAV diff --git a/sys/arch/mac68k/mac68k/intr.c b/sys/arch/mac68k/mac68k/intr.c deleted file mode 100644 index 42557df9fb5..00000000000 --- a/sys/arch/mac68k/mac68k/intr.c +++ /dev/null @@ -1,223 +0,0 @@ -/* $OpenBSD: intr.c,v 1.14 2010/09/20 06:33:47 matthew Exp $ */ -/* $NetBSD: intr.c,v 1.2 1998/08/25 04:03:56 scottr Exp $ */ - -/*- - * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. - * 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 - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Link and dispatch interrupts. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/malloc.h> -#include <sys/vmmeter.h> -#include <sys/evcount.h> - -#include <uvm/uvm_extern.h> - -#include <machine/cpu.h> -#include <machine/intr.h> - -#define NISR 8 -#define ISRLOC 0x18 - -void intr_init(void); -void netintr(void); - -#ifdef DEBUG -int intr_debug = 0; -#endif - -/* - * Some of the below are not used yet, but might be used someday on the - * Q700/900/950 where the interrupt controller may be reprogrammed to - * interrupt on different levels as listed in locore.s - */ -u_short mac68k_ttyipl; -u_short mac68k_netipl; -u_short mac68k_vmipl; -u_short mac68k_clockipl; -u_short mac68k_statclockipl; - -struct intrhand intrs[NISR]; - -void intr_computeipl(void); - -void -intr_init() -{ - /* Standard spl(9) interrupt priorities */ - mac68k_ttyipl = (PSL_S | PSL_IPL1); - - if (mac68k_machine.aux_interrupts) { - mac68k_netipl = (PSL_S | PSL_IPL3); - mac68k_vmipl = (PSL_S | PSL_IPL6); - } else { - if (current_mac_model->class == MACH_CLASSAV) - mac68k_netipl = (PSL_S | PSL_IPL4); - else if (mac68k_machine.sonic) - mac68k_netipl = (PSL_S | PSL_IPL3); - else - mac68k_netipl = (PSL_S | PSL_IPL2); - - mac68k_vmipl = (PSL_S | PSL_IPL2); - } - - mac68k_clockipl = mac68k_statclockipl = mac68k_vmipl; - intr_computeipl(); -} - -/* - * Compute the interrupt levels for the spl*() - * calls. This doesn't have to be fast. - */ -void -intr_computeipl() -{ - /* - * Enforce `bio <= net <= tty <= imp <= statclock <= clock' - * as defined in spl(9) - */ - if ((PSL_S | PSL_IPL2) > mac68k_netipl) - mac68k_netipl = (PSL_S | PSL_IPL2); - - if (mac68k_netipl > mac68k_ttyipl) - mac68k_ttyipl = mac68k_netipl; - - if (mac68k_ttyipl > mac68k_vmipl) - mac68k_vmipl = mac68k_ttyipl; - - if (mac68k_vmipl > mac68k_statclockipl) - mac68k_statclockipl = mac68k_vmipl; - - if (mac68k_statclockipl > mac68k_clockipl) - mac68k_clockipl = mac68k_statclockipl; -} - -/* - * Establish an autovectored interrupt handler. - * Called by driver attach functions. - */ -void -intr_establish(int (*func)(void *), void *arg, int ipl, const char *name) -{ - struct intrhand *ih; - -#ifdef DIAGNOSTIC - if (ipl < 0 || ipl >= NISR) - panic("intr_establish: bad ipl %d", ipl); -#endif - - ih = &intrs[ipl]; - -#ifdef DIAGNOSTIC - if (ih->ih_fn != NULL) - panic("intr_establish: attempt to share ipl %d", ipl); -#endif - - ih->ih_fn = func; - ih->ih_arg = arg; - ih->ih_ipl = ipl; - evcount_attach(&ih->ih_count, name, &ih->ih_ipl); -} - -/* - * Disestablish an interrupt handler. - */ -void -intr_disestablish(int ipl) -{ - struct intrhand *ih; - -#ifdef DIAGNOSTIC - if (ipl < 0 || ipl >= NISR) - panic("intr_disestablish: bad ipl %d", ipl); -#endif - - ih = &intrs[ipl]; - -#ifdef DIAGNOSTIC - if (ih->ih_fn == NULL) - panic("intr_disestablish: no vector on ipl %d", ipl); -#endif - - ih->ih_fn = NULL; - evcount_detach(&ih->ih_count); -} - -/* - * This is the dispatcher called by the low-level - * assembly language interrupt routine. - */ -void -intr_dispatch(int evec) /* format | vector offset */ -{ - struct intrhand *ih; - int ipl, vec; - - vec = (evec & 0x0fff) >> 2; - ipl = vec - ISRLOC; -#ifdef DIAGNOSTIC - if (ipl < 0 || ipl >= NISR) - panic("intr_dispatch: bad vec 0x%x", vec); -#endif - - uvmexp.intrs++; - ih = &intrs[ipl]; - if (ih->ih_fn != NULL) { - if ((*ih->ih_fn)(ih->ih_arg) != 0) - ih->ih_count.ec_count++; - } else { -#if 0 - printf("spurious interrupt, ipl %d\n", ipl); -#endif - } -} - -#ifdef DIAGNOSTIC -void -splassert_check(int wantipl, const char *func) -{ - int oldipl; - - __asm __volatile ("movew sr,%0" : "=&d" (oldipl)); - - oldipl = PSLTOIPL(oldipl); - - if (oldipl < wantipl) { - splassert_fail(wantipl, oldipl, func); - /* - * If the splassert_ctl is set to not panic, raise the ipl - * in a feeble attempt to reduce damage. - */ - _spl(PSL_S | IPLTOPSL(wantipl)); - } -} -#endif diff --git a/sys/arch/mac68k/mac68k/iop.c b/sys/arch/mac68k/mac68k/iop.c deleted file mode 100644 index d7da7ac1a47..00000000000 --- a/sys/arch/mac68k/mac68k/iop.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $OpenBSD: iop.c,v 1.1 2006/01/22 13:53:16 miod Exp $ */ -/* $NetBSD: iop.c,v 1.10 2005/12/24 23:24:00 perry Exp $ */ - -/* - * Copyright (c) 2000 Allen Briggs. - * 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. 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. - */ - -#include <sys/param.h> -#include <sys/systm.h> - -#include <machine/cpu.h> -#include <machine/iop.h> -#include <machine/viareg.h> - -IOPHW *mac68k_iops[2]; - -void -iop_serial_compatible() -{ - IOPHW *ioph; - - switch (current_mac_model->machineid) { - case MACH_MACQ900: - case MACH_MACQ950: - mac68k_iops[SCC_IOP] = (IOPHW *)((u_char *)IOBase + 0xc000); - mac68k_iops[ISM_IOP] = (IOPHW *)((u_char *)IOBase + 0x1e000); - break; - case MACH_MACIIFX: - mac68k_iops[SCC_IOP] = (IOPHW *)((u_char *)IOBase + 0x4000); - mac68k_iops[ISM_IOP] = (IOPHW *)((u_char *)IOBase + 0x12000); - break; - default: - return; - } - - ioph = mac68k_iops[SCC_IOP]; - ioph->control_status = 0; /* Reset */ - ioph->control_status = IOP_BYPASS; /* Set to bypass */ - - ioph = mac68k_iops[ISM_IOP]; - ioph->control_status = 0; /* Reset */ -} diff --git a/sys/arch/mac68k/mac68k/locore.s b/sys/arch/mac68k/mac68k/locore.s deleted file mode 100644 index 3d87bc3029c..00000000000 --- a/sys/arch/mac68k/mac68k/locore.s +++ /dev/null @@ -1,1698 +0,0 @@ -/* $OpenBSD: locore.s,v 1.63 2010/06/29 20:30:32 guenther Exp $ */ -/* $NetBSD: locore.s,v 1.103 1998/07/09 06:02:50 scottr Exp $ */ - -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* - * from: Utah $Hdr: locore.s 1.58 91/04/22$ - * - * @(#)locore.s 7.11 (Berkeley) 5/9/91 - */ - -#include "assym.h" -#include <machine/asm.h> -#include <machine/trap.h> - -/* - * This is for kvm_mkdb, and should be the address of the beginning - * of the kernel text segment (not necessarily the same as kernbase). - */ - .text -GLOBAL(kernel_text) - -/* - * Clear and skip the first page of text; it will not be mapped. - */ - .fill NBPG / 4, 4, 0 - -/* - * Initialization - */ - - .data -| Scratch memory. Careful when messing with these... -ASLOCAL(longscratch) - .long 0 -ASLOCAL(longscratch2) - .long 0 -ASLOCAL(pte_tmp) | for get_pte() - .long 0 -GLOBAL(macos_crp1) - .long 0 -GLOBAL(macos_crp2) - .long 0 -GLOBAL(macos_tc) - .long 0 -GLOBAL(macos_tt0) - .long 0 -GLOBAL(macos_tt1) - .long 0 -GLOBAL(bletch) - .long 0 - -GLOBAL(sanity_check) - .long 0x18621862 | this is our stack overflow checker. - - .space 4 * NBPG -ASLOCAL(tmpstk) - -#include <mac68k/mac68k/vectors.s> - -BSS(esym,4) - -ASENTRY_NOPROFILE(start) -GLOBAL(kernel_start) - movw #PSL_HIGHIPL,sr | no interrupts. ever. - lea _ASM_LABEL(tmpstk),sp | give ourselves a temporary stack - - movl #CACHE_OFF,d0 - movc d0,cacr | clear and disable on-chip cache(s) - - /* Initialize source/destination control registers for movs */ - movql #FC_USERD,d0 | user space - movc d0,sfc | as source - movc d0,dfc | and destination of transfers - - /* - * Some parameters provided by MacOS - * - * LAK: This section is the new way to pass information from the booter - * to the kernel. At A1 there is an environment variable which has - * a bunch of stuff in ascii format, "VAR=value\0VAR=value\0\0". - */ - movl a1,sp@- | Address of buffer - movl d4,sp@- | Some flags... (mostly not used) - jbsr _C_LABEL(getenvvars) | Parse the environment buffer - addql #8,sp - - /* Determine MMU/MPU from what we can test empirically */ - movl #0x200,d0 | data freeze bit - movc d0,cacr | only exists on 68030 - movc cacr,d0 | read it back - tstl d0 | zero? - jeq Lnot68030 | yes, we have 68020/68040 - - lea _C_LABEL(mmutype),a0 | no, we have 68030 - movl #MMU_68030,a0@ | set to reflect 68030 PMMU - lea _C_LABEL(cputype),a0 - movl #CPU_68030,a0@ | and 68030 MPU - jra Lstart1 - -Lnot68030: - bset #31,d0 | data cache enable bit - movc d0,cacr | only exists on 68040 - movc cacr,d0 | read it back - tstl d0 | zero? - beq Lis68020 | yes, we have 68020 - - movql #CACHE40_OFF,d0 | now turn it back off - movc d0,cacr | before we access any data - .word 0xf4f8 | cpusha bc ;push and invalidate caches - lea _C_LABEL(mmutype),a0 - movl #MMU_68040,a0@ | Reflect 68040 MMU - lea _C_LABEL(cputype),a0 - movl #CPU_68040,a0@ | and 68040 MPU - jra Lstart1 - -Lis68020: - movl #CACHE_OFF,d0 | disable and clear cache - movc d0,cacr - lea _C_LABEL(mmutype),a0 | Must be 68020+68851 - movl #MMU_68851,a0@ | Reflect 68851 PMMU - lea _C_LABEL(cputype),a0 - movl #CPU_68020,a0@ | and 68020 MPU - -Lstart1: - /* - * Now that we know what CPU we have, initialize the address error - * and bus error handlers in the vector table: - * - * vectab+8 bus error - * vectab+12 address error - */ - lea _C_LABEL(cputype),a0 - lea _C_LABEL(vectab),a2 -#if defined(M68040) - cmpl #CPU_68040,a0@ | 68040? - jne 1f | no, skip - movl #_C_LABEL(buserr40),a2@(8) - movl #_C_LABEL(addrerr4060),a2@(12) - jra Lstart2 -1: -#endif -#if defined(M68020) || defined(M68030) -#if defined(M68030) - cmpl #CPU_68030,a0@ | 68030? - jeq 1f | yes, ok -#endif -#if defined(M68020) - cmpl #CPU_68020,a0@ | 68020? - jeq 1f | yes, ok -#endif - jra 9f -1: - movl #_C_LABEL(busaddrerr2030),a2@(8) - movl #_C_LABEL(busaddrerr2030),a2@(12) - jra Lstart2 -#endif -9: - /* Config botch; no hope. */ - movl _C_LABEL(MacOSROMBase),a1 | Load MacOS ROMBase - jra Ldoboot1 - -Lstart2: - jbsr _C_LABEL(setmachdep) | Set some machine-dep stuff - jbsr _C_LABEL(consinit) | XXX Should only be if graybar on - -/* - * Figure out MacOS mappings and bootstrap OpenBSD - */ - lea _C_LABEL(macos_tc),a0 | get current TC - cmpl #MMU_68040,_C_LABEL(mmutype) | check to see if 68040 - jeq Lget040TC - - pmove tc,a0@ - jra Lstart3 - -Lget040TC: -#if 0 - movl _C_LABEL(current_mac_model),a1 | if an AV Mac, save current - cmpl #MACH_CLASSAV,a1@(CPUINFO_CLASS) | TC so internal video will - jne LnotAV | get configured -#endif - .long 0x4e7a0003 | movc tc,d0 - jra LsaveTC -LnotAV: - movql #0,d0 | otherwise, - .long 0x4e7b0003 | movc d0,tc ;Disable MMU -LsaveTC: - movl d0,a0@ - -Lstart3: - movl a0@,sp@- | get Mac OS mapping, relocate video, - jbsr _C_LABEL(bootstrap_mac68k) | bootstrap pmap, et al. - addql #4,sp - - /* - * Set up the vector table, and race to get the MMU - * enabled. - */ - movl #_C_LABEL(vectab),d0 | set Vector Base Register - movc d0,vbr - -/* - * We might not be running physical, but we don't have read-only mappings - * yet either. It's time to override copypage() with the 68040 - * optimized version, copypage040(), if possible. - * This relies upon the fact that copypage() immediately follows - * copypage040() in memory. - */ - movl #_C_LABEL(mmutype),a0 - cmpl #MMU_68040,a0@ - jgt Lmmu_enable - movl #_C_LABEL(copypage040),a0 - movl #_C_LABEL(copypage),a1 - movl a1, a2 -1: - movw a0@+, a2@+ - cmpl a0, a1 - jgt 1b - -Lmmu_enable: - movl _C_LABEL(Sysseg),a1 | system segment table addr - addl _C_LABEL(load_addr),a1 | Make it physical addr - cmpl #MMU_68040,_C_LABEL(mmutype) - jne Lenablepre040MMU | if not 040, skip - - movql #0,d0 - .long 0x4e7b0003 | movc d0,tc ;Disable MMU - .long 0x4e7b0004 | movc d0,itt0 ;Disable itt0 - .long 0x4e7b0005 | movc d0,itt1 ;Disable itt1 - .long 0x4e7b0006 | movc d0,dtt0 ;Disable dtt0 - .long 0x4e7b0007 | movc d0,dtt1 ;Disable dtt1 - movl a1,d1 - .word 0xf4d8 | cinva bc - .word 0xf518 | pflusha - .long 0x4e7b1807 | movc d1,srp - movl #0x8000,d0 - .long 0x4e7b0003 | movc d0,tc ;Enable MMU - movl #CACHE40_ON,d0 - movc d0,cacr | turn on both caches - jra Lloaddone - -Lenablepre040MMU: - tstl _C_LABEL(mmutype) | TTx instructions will break 68851 - jgt LnokillTT - - lea _ASM_LABEL(longscratch),a0 | disable TTx registers on 68030 - movl #0,a0@ - .long 0xf0100800 | movl a0@,tt0 - .long 0xf0100c00 | movl a0@,tt1 - -LnokillTT: - lea _C_LABEL(protorp),a0 - movl #0x80000202,a0@ | nolimit + share global + 4 byte PTEs - movl a1,a0@(4) | + segtable address - pmove a0@,srp | load the supervisor root pointer - movl #0x80000002,a0@ | reinit upper half for CRP loads - lea _ASM_LABEL(longscratch),a2 - movl #0x82c0aa00,a2@ | value to load TC with - pmove a2@,tc | load it - -Lloaddone: - -/* - * Should be running mapped from this point on - */ -/* select the software page size now */ - lea _ASM_LABEL(tmpstk),sp | temporary stack - jbsr _C_LABEL(uvm_setpagesize) | select software page size - -/* set kernel stack, user SP, proc0, and initial pcb */ - movl _C_LABEL(proc0paddr),a1 | get proc0 pcb addr - lea a1@(USPACE-4),sp | set kernel stack to end of area - lea _C_LABEL(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,_C_LABEL(curpcb) | proc0 is running - -/* flush TLB and turn on caches */ - jbsr _ASM_LABEL(TBIA) | invalidate TLB - cmpl #MMU_68040,_C_LABEL(mmutype) | 68040? - jeq Lnocache0 | yes, cache already on - movl #CACHE_ON,d0 - movc d0,cacr | clear cache(s) - -Lnocache0: -/* Final setup for call to main(). */ - jbsr _C_LABEL(mac68k_init) - -/* - * Create a fake exception frame so that cpu_fork() can copy it. - * main() never returns; we exit to user mode from a forked process - * later on. - */ - clrw sp@- | vector offset/frame type - clrl sp@- | PC - filled in by "execve" - movw #PSL_USER,sp@- | in user mode - clrl sp@- | stack adjust count and padding - lea sp@(-64),sp | construct space for D0-D7/A0-A7 - lea _C_LABEL(proc0),a0 | save pointer to frame - movl sp,a0@(P_MD_REGS) | in proc0.p_md.md_regs - - jra _C_LABEL(main) | main() - PANIC("main() returned") - /* NOTREACHED */ - -/* - * proc_trampoline - * Call function in register a2 with a3 as an arg and then rei. Note - * that we restore the stack before calling, thus giving "a2" more stack. - * (for the case that, e.g., if curproc had a deeply nested call chain...) - * cpu_fork() also depends on struct frame being a second arg to the - * function in a2. - */ -GLOBAL(proc_trampoline) - movl a3,sp@- | push function arg (curproc) - jbsr a2@ | call function - addql #4,sp | pop arg - movl sp@(FR_SP),a0 | usp to a0 - movl a0,usp | setup user's stack pointer - movml sp@+,#0x7fff | restore all but sp - addql #8,sp | pop sp and stack adjust - jra _ASM_LABEL(rei) | all done - -/* - * Trap/interrupt vector routines - */ -#include <m68k/m68k/trap_subr.s> - - .data -GLOBAL(m68k_fault_addr) - .long 0 - -#if defined(M68040) -ENTRY_NOPROFILE(addrerr4060) - clrl sp@- | stack adjust count - moveml #0xFFFF,sp@- | save user registers - movl usp,a0 | save the user SP - movl a0,sp@(FR_SP) | in the savearea - movl sp@(FR_HW+8),sp@- - clrl sp@- | dummy code - movl #T_ADDRERR,sp@- | mark address error - jra _ASM_LABEL(faultstkadj) | and deal with it -#endif - -#if defined(M68040) -ENTRY_NOPROFILE(buserr40) - clrl sp@- | stack adjust count - moveml #0xFFFF,sp@- | save user registers - movl usp,a0 | save the user SP - movl a0,sp@(FR_SP) | in the savearea - movl sp@(FR_HW+20),d1 | get fault address - moveq #0,d0 - movw sp@(FR_HW+12),d0 | get SSW - btst #11,d0 | check for mis-aligned - jeq Lbe1stpg | no skip - addl #3,d1 | get into next page - andl #PG_FRAME,d1 | and truncate -Lbe1stpg: - movl d1,sp@- | pass fault address. - movl d0,sp@- | pass SSW as code - btst #10,d0 | test ATC - jeq Lberr40 | it is a bus error - movl #T_MMUFLT,sp@- | show that we are an MMU fault - jra _ASM_LABEL(faultstkadj) | and deal with it -Lberr40: - tstl _C_LABEL(nofault) | catch bus error? - jeq Lisberr | no, handle as usual - movl sp@(FR_HW+8+20),_C_LABEL(m68k_fault_addr) | save fault addr - movl _C_LABEL(nofault),sp@- | yes, - jbsr _C_LABEL(longjmp) | longjmp(nofault) - /* NOTREACHED */ -#endif - -ENTRY_NOPROFILE(busaddrerr2030) -#if !(defined(M68020) || defined(M68030)) - jra _badtrap -#else - clrl sp@- | stack adjust count - moveml #0xFFFF,sp@- | save user registers - movl usp,a0 | save the user SP - movl a0,sp@(FR_SP) | in the savearea - moveq #0,d0 - movw sp@(FR_HW+10),d0 | grab SSW for fault processing - btst #12,d0 | RB set? - jeq LbeX0 | no, test RC - bset #14,d0 | yes, must set FB - movw d0,sp@(FR_HW+10) | for hardware too -LbeX0: - btst #13,d0 | RC set? - jeq LbeX1 | no, skip - bset #15,d0 | yes, must set FC - movw d0,sp@(FR_HW+10) | for hardware too -LbeX1: - btst #8,d0 | data fault? - jeq Lbe0 | no, check for hard cases - movl sp@(FR_HW+16),d1 | fault address is as given in frame - jra Lbe10 | thats it -Lbe0: - btst #4,sp@(FR_HW+6) | long (type B) stack frame? - jne Lbe4 | yes, go handle - movl sp@(FR_HW+2),d1 | no, can use save PC - btst #14,d0 | FB set? - jeq Lbe3 | no, try FC - addql #4,d1 | yes, adjust address - jra Lbe10 | done -Lbe3: - btst #15,d0 | FC set? - jeq Lbe10 | no, done - addql #2,d1 | yes, adjust address - jra Lbe10 | done -Lbe4: - movl sp@(FR_HW+36),d1 | long format, use stage B address - btst #15,d0 | FC set? - jeq Lbe10 | no, all done - subql #2,d1 | yes, adjust address -Lbe10: - movl d1,sp@- | push fault VA - movl d0,sp@- | and padded SSW - movw sp@(FR_HW+8+6),d0 | get frame format/vector offset - andw #0x0FFF,d0 | clear out frame format - cmpw #12,d0 | address error vector? - jeq Lisaerr | yes, go to it - movl d1,a0 | fault address - 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,sp@(FR_HW+8) | 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 - 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? - jne Lisberr1 | yes, needs not be fast. -Lismerr: - movl #T_MMUFLT,sp@- | show that we are an MMU fault - jra _ASM_LABEL(faultstkadj) | and deal with it -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? - jne Lismerr | no, was not WPE, must be MMU fault - jra Lisberr1 | real bus err needs not be fast. -Lisaerr: - movl #T_ADDRERR,sp@- | mark address error - jra _ASM_LABEL(faultstkadj) | and deal with it -Lisberr1: - clrw sp@ | re-clear pad word - tstl _C_LABEL(nofault) | catch bus error? - jeq Lisberr | no, handle as usual - movl sp@(FR_HW+8+16),_C_LABEL(m68k_fault_addr) | save fault addr - movl _C_LABEL(nofault),sp@- | yes, - jbsr _C_LABEL(longjmp) | longjmp(nofault) - /* NOTREACHED */ -#endif -Lisberr: | also used by M68040/60 - movl #T_BUSERR,sp@- | mark bus error - jra _ASM_LABEL(faultstkadj) | and deal with it - -/* - * FP exceptions. - */ -ENTRY_NOPROFILE(fpfline) -#if defined(M68040) - cmpl #FPU_68040,_C_LABEL(fputype) | 68040 FPU? - jne Lfp_unimp | no, skip FPSP - cmpw #0x202c,sp@(6) | format type 2? - jne _C_LABEL(illinst) | no, not an FP emulation -Ldofp_unimp: -#ifdef FPSP - jmp _ASM_LABEL(fpsp_unimp) | yes, go handle it -#endif -Lfp_unimp: -#endif /* M68040 */ -#ifdef FPU_EMULATE - clrl sp@- | stack adjust count - moveml #0xFFFF,sp@- | save registers - moveq #T_FPEMULI,d0 | denote as FP emulation trap - jra _ASM_LABEL(fault) | do it -#else - jra _C_LABEL(illinst) -#endif - -ENTRY_NOPROFILE(fpunsupp) -#if defined(M68040) - cmpl #FPU_68040,_C_LABEL(fputype) | 68040 FPU? - jne _C_LABEL(illinst) | no, treat as illinst -#ifdef FPSP - jmp _ASM_LABEL(fpsp_unsupp) | yes, go handle it -#endif -Lfp_unsupp: -#endif /* M68040 */ -#ifdef FPU_EMULATE - clrl sp@- | stack adjust count - moveml #0xFFFF,sp@- | save registers - moveq #T_FPEMULD,d0 | denote as FP emulation trap - jra _ASM_LABEL(fault) | do it -#else - jra _C_LABEL(illinst) -#endif - -/* - * Handles all other FP coprocessor exceptions. - * Note that since some FP exceptions generate mid-instruction frames - * and may cause signal delivery, we need to test for stack adjustment - * after the trap call. - */ -ENTRY_NOPROFILE(fpfault) - clrl sp@- | stack adjust count - moveml #0xFFFF,sp@- | save user registers - movl usp,a0 | and save - movl a0,sp@(FR_SP) | the user stack pointer - clrl sp@- | no VA arg - movl _C_LABEL(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 #FPU_68040,_C_LABEL(fputype) - jge Lfptnull -#endif - tstb a0@ | null state frame? - jeq Lfptnull | yes, safe - clrw d0 | no, need to tweak BIU - movb a0@(1),d0 | get frame size - bset #3,a0@(0,d0:w) | set exc_pend bit of BIU -Lfptnull: - fmovem fpsr,sp@- | push fpsr as code argument - frestore a0@ | restore state - movl #T_FPERR,sp@- | push type arg - jra _ASM_LABEL(faultstkadj) | call trap and deal with stack cleanup - -/* - * Other exceptions only cause four and six word stack frame and require - * no post-trap stack adjustment. - */ - -ENTRY_NOPROFILE(badtrap) - moveml #0xC0C0,sp@- | save scratch regs - movw sp@(22),sp@- | push exception vector info - clrw sp@- - movl sp@(22),sp@- | and PC - jbsr _C_LABEL(straytrap) | report - addql #8,sp | pop args - moveml sp@+,#0x0303 | restore regs - jra _ASM_LABEL(rei) | all done - -ENTRY_NOPROFILE(trap0) - clrl sp@- | pad SR to longword - moveml #0xFFFF,sp@- | save user registers - movl usp,a0 | save the user SP - movl a0,sp@(FR_SP) | in the savearea - movl d0,sp@- | push syscall number - jbsr _C_LABEL(syscall) | handle it - addql #4,sp | pop syscall arg - tstl _C_LABEL(astpending) - jne Lrei2 - tstl _C_LABEL(softpending) - jeq Ltrap1 - movw #SPL1,sr - tstl _C_LABEL(softpending) - jne Lsir1 -Ltrap1: - movl sp@(FR_SP),a0 | grab and restore - movl a0,usp | user SP - moveml sp@+,#0x7FFF | restore most registers - addql #8,sp | pop SSP and align word - rte - -/* - * Trap 1 - sigreturn - */ -ENTRY_NOPROFILE(trap1) - jra _ASM_LABEL(sigreturn) - -/* - * Trap 2 - trace trap - */ -ENTRY_NOPROFILE(trap2) - jra _C_LABEL(trace) - -/* - * Trap 12 is the entry point for the cachectl "syscall" (both HP-UX & BSD) - * cachectl(command, addr, length) - * command in d0, addr in a1, length in d1 - */ -ENTRY_NOPROFILE(trap12) - movl d1,sp@- | push length - movl a1,sp@- | push addr - movl d0,sp@- | push command - movl CURPROC,sp@- | push proc pointer - jbsr _C_LABEL(cachectl) | do it - lea sp@(16),sp | pop args - jra _ASM_LABEL(rei) | all done - -/* - * Trace (single-step) trap. Kernel-mode is special. - * User mode traps are simply passed on to trap(). - */ -ENTRY_NOPROFILE(trace) - clrl sp@- | stack adjust count - moveml #0xFFFF,sp@- - moveq #T_TRACE,d0 - - | Check PSW and see what happened. - | T=0 S=0 (should not happen) - | T=1 S=0 trace trap from user mode - | T=0 S=1 trace trap on a trap instruction - | T=1 S=1 trace trap from system mode (kernel breakpoint) - - movw sp@(FR_HW),d1 | get PSW - notw d1 | XXX no support for T0 on 680[234]0 - andw #PSL_TS,d1 | from system mode (T=1, S=1)? - jeq Lkbrkpt | yes, kernel breakpoint - jra _ASM_LABEL(fault) | no, user-mode fault - -/* - * Trap 15 is used for: - * - GDB breakpoints (in user programs) - * - KGDB breakpoints (in the kernel) - * - trace traps for SUN binaries (not fully supported yet) - * User mode traps are simply passed to trap(). - */ -ENTRY_NOPROFILE(trap15) - clrl sp@- | stack adjust count - moveml #0xFFFF,sp@- - moveq #T_TRAP15,d0 - movw sp@(FR_HW),d1 | get PSW - andw #PSL_S,d1 | from system mode? - jne Lkbrkpt | yes, kernel breakpoint - jra _ASM_LABEL(fault) | no, user-mode fault - -Lkbrkpt: | 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 we are not on tmpstk switch to it. - | (so debugger can change the stack pointer) - movl a6,d1 - cmpl #_ASM_LABEL(tmpstk),d1 - jls Lbrkpt2 | already on tmpstk - | Copy frame to the temporary stack - movl sp,a0 | a0=src - lea _ASM_LABEL(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 - | Let KGDB handle it (if connected) - movl a2,sp@- | push frame ptr - movl d2,sp@- | push trap type - jbsr _C_LABEL(kgdb_trap) | handle the trap - addql #8,sp | pop args - cmpl #0,d0 | did kgdb handle it? - jne Lbrkpt3 | yes, done -#endif -#ifdef DDB - | Let DDB handle it - movl a2,sp@- | push frame ptr - movl d2,sp@- | push trap type - jbsr _C_LABEL(kdb_trap) | handle the trap - addql #8,sp | pop args -#endif -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 <m68k/m68k/sigreturn.s> - -/* - * Interrupt handlers. - * - * Most 68k-based Macintosh computers - * - * Level 0: Spurious: ignored - * Level 1: VIA1 (clock, ADB) - * Level 2: VIA2 (NuBus, SCSI) - * Level 3: - * Level 4: Serial (SCC) - * Level 5: - * Level 6: - * Level 7: Non-maskable: parity errors, RESET button - * - * On the Q700, Q900 and Q950 in "A/UX mode": this should become: - * - * Level 0: Spurious: ignored - * Level 1: Software - * Level 2: VIA2 (except ethernet, sound) - * Level 3: Ethernet - * Level 4: Serial (SCC) - * Level 5: Sound - * Level 6: VIA1 - * Level 7: NMIs: parity errors, RESET button, YANCC error - * - * On the 660AV and 840AV: - * - * Level 0: Spurious: ignored - * Level 1: VIA1 (clock, ADB) - * Level 2: VIA2 (NuBus, SCSI) - * Level 3: PSC device interrupt - * Level 4: PSC DMA and serial - * Level 5: ??? - * Level 6: ??? - * Level 7: NMIs: parity errors?, RESET button - */ - -#define INTERRUPT_SAVEREG moveml #0xC0C0,sp@- -#define INTERRUPT_RESTOREREG moveml sp@+,#0x0303 - -ENTRY_NOPROFILE(spurintr) - addql #1,_C_LABEL(uvmexp)+UVMEXP_INTRS - jra _ASM_LABEL(rei) - -ENTRY_NOPROFILE(intrhand) /* levels 3 through 6 */ - INTERRUPT_SAVEREG - movw sp@(22),sp@- | push exception vector info - clrw sp@- - jbsr _C_LABEL(intr_dispatch) | call dispatch routine - addql #4,sp - INTERRUPT_RESTOREREG - jra _ASM_LABEL(rei) | all done - -ENTRY_NOPROFILE(lev7intr) - clrl sp@- | pad SR to longword - moveml #0xFFFF,sp@- | save registers - movl usp,a0 | and save - movl a0,sp@(FR_SP) | the user stack pointer - jbsr _C_LABEL(nmihand) | call handler - movl sp@(FR_SP),a0 | restore - movl a0,usp | user SP - moveml sp@+,#0x7FFF | and remaining registers - addql #8,sp | pop SSP and align word - jra _ASM_LABEL(rei) - -/* - * We could tweak rtclock_intr and gain 12 cycles on the 020 and 030 by - * saving the status register directly to the stack, but this would lose - * badly on the 040. Aligning the stack takes 10 more cycles than this - * code does, so it's a good compromise. - */ -ENTRY_NOPROFILE(rtclock_intr) - movl d2,sp@- | save d2 - movw sr,d2 | save SPL - movw _C_LABEL(mac68k_clockipl),sr | raise SPL to splclock() - movl a6@,a1 | unwind to frame in intr_dispatch - lea a1@(28),a1 | push pointer to interrupt frame - movl a1,sp@- | 28 = 16 for regs in intrhand, - | + 4 for args to intr_dispatch - | + 4 for return address to intrhand - | + 4 for value of A6 - jbsr _C_LABEL(hardclock) | call generic clock int routine - addql #4,sp | pop params - movw d2,sr | restore SPL - movl sp@+,d2 | restore d2 - movl #1,d0 | clock taken care of - rts | go back from whence we came - -/* - * Emulation of VAX REI instruction. - * - * This code deals with checking for and servicing ASTs - * (profiling, scheduling) and software interrupts (network, softclock). - * We check for ASTs first, just like the VAX. To avoid excess overhead - * the T_ASTFLT handling code will also check for software interrupts so we - * do not have to do it here. After identifing that we need an AST we - * drop the IPL to allow device interrupts. - * - * This code is complicated by the fact that sendsig may have been called - * necessitating a stack cleanup. - */ - -BSS(softpending,4) - -ASENTRY_NOPROFILE(rei) - tstl _C_LABEL(astpending) | AST pending? - jeq Lchksir | no, go check for SIR -Lrei1: - btst #5,sp@ | yes, are we returning to user mode? - jne Lchksir | no, go check for SIR - movw #PSL_LOWIPL,sr | lower SPL - clrl sp@- | stack adjust - moveml #0xFFFF,sp@- | save all registers - movl usp,a1 | including - movl a1,sp@(FR_SP) | the users SP -Lrei2: - clrl sp@- | VA == none - clrl sp@- | code == none - movl #T_ASTFLT,sp@- | type == async system trap - jbsr _C_LABEL(trap) | go handle it - lea sp@(12),sp | pop value args - movl sp@(FR_SP),a0 | restore user SP - movl a0,usp | from save area - movw sp@(FR_ADJ),d0 | need to adjust stack? - jne Laststkadj | yes, go to it - moveml sp@+,#0x7FFF | no, restore most user regs - addql #8,sp | toss SP and stack adjust - rte | and do real RTE -Laststkadj: - lea sp@(FR_HW),a1 | pointer to HW frame - addql #8,a1 | source pointer - movl a1,a0 | source - addw d0,a0 | + hole size = dest pointer - movl a1@-,a0@- | copy - movl a1@-,a0@- | 8 bytes - movl a0,sp@(FR_SP) | new SSP - moveml sp@+,#0x7FFF | restore user registers - movl sp@,sp | and our SP - rte | and do real RTE -Lchksir: - tstl _C_LABEL(softpending) | SIR pending? - jeq Ldorte | no, all done - movl d0,sp@- | need a scratch register - movw sp@(4),d0 | get SR - andw #PSL_IPL7,d0 | mask all but IPL - jne Lnosir | came from interrupt, no can do - movl sp@+,d0 | restore scratch register -Lgotsir: - movw #SPL1,sr | prevent others from servicing int - tstl _C_LABEL(softpending) | too late? - jeq Ldorte | yes, oh well... - clrl sp@- | stack adjust - moveml #0xFFFF,sp@- | save all registers - movl usp,a1 | including - movl a1,sp@(FR_SP) | the users SP -Lsir1: - clrl sp@- | VA == none - clrl sp@- | code == none - movl #T_SSIR,sp@- | type == software interrupt - jbsr _C_LABEL(trap) | go handle it - lea sp@(12),sp | pop value args - movl sp@(FR_SP),a0 | restore - movl a0,usp | user SP - moveml sp@+,#0x7FFF | and all remaining registers - addql #8,sp | pop SP and stack adjust - rte -Lnosir: - movl sp@+,d0 | restore scratch register -Ldorte: - rte | real return - -/* - * Use common m68k sigcode. - */ -#include <m68k/m68k/sigcode.s> - -/* - * Primitives - */ - -/* - * Use common m68k support routines. - */ -#include <m68k/m68k/support.s> - - .data -GLOBAL(curpcb) - .long 0 - -ASBSS(nullpcb,SIZEOF_PCB) - -ENTRY_NOPROFILE(cpu_idle_cycle) - stop #PSL_LOWIPL - rts - -/* - * cpu_switchto(struct proc *oldproc, struct proc *newproc) - * - * NOTE: On the mc68851 (318/319/330) we attempt to avoid flushing the - * entire ATC. The effort involved in selective flushing may not be - * worth it, maybe we should just flush the whole thing? - * - * NOTE 2: With the new VM layout we now no longer know if an inactive - * user's PTEs have been changed (formerly denoted by the SPTECHG p_flag - * bit). For now, we just always flush the full ATC. - */ -ENTRY(cpu_switchto) - movl sp@(4), d0 | oldproc - beq Lswnofpsave | is NULL, don't save anything - - /* - * Save state of previous process in its pcb. - */ - movl _C_LABEL(curpcb),a1 - movw sr, a1@(PCB_PS) | save sr before switching context - moveml #0xFCFC,a1@(PCB_REGS) | save non-scratch registers - movl usp,a2 | grab USP (a2 has been saved) - movl a2,a1@(PCB_USP) | and save it - - tstl _C_LABEL(fputype) | Do we have an FPU? - jeq Lswnofpsave | No Then don't attempt save. - lea a1@(PCB_FPCTX),a2 | pointer to FP save area - fsave a2@ | save FP state - tstb a2@ | null state frame? - jeq Lswnofpsave | yes, all done - fmovem fp0-fp7,a2@(FPF_REGS) | save FP general registers - fmovem fpcr/fpsr/fpi,a2@(FPF_FPCR) | save FP control registers - -Lswnofpsave: - movl sp@(8), a0 | newproc - - movl a0, CURPROC - movb #SONPROC,a0@(P_STAT) - movl a0@(P_ADDR),a1 | get p_addr - movl a1,_C_LABEL(curpcb) - - /* - * Activate the process's address space. - * XXX Should remember the last USTP value loaded, and call this - * XXX only if it has changed. - */ - pea a0@ | push proc - jbsr _C_LABEL(pmap_activate) | pmap_activate(p) - addql #4,sp - movl _C_LABEL(curpcb),a1 | restore p_addr - - lea _ASM_LABEL(tmpstk),sp | now goto a tmp stack for NMI - - moveml a1@(PCB_REGS),#0xFCFC | and registers - movl a1@(PCB_USP),a0 - movl a0,usp | and USP - - tstl _C_LABEL(fputype) | If we don't have an FPU, - jeq Lnofprest | don't try to restore it. - lea a1@(PCB_FPCTX),a0 | pointer to FP save area - tstb a0@ | null state frame? - jeq Lresfprest | yes, easy -#if defined(M68040) -#if defined(M68020) || defined(M68030) - cmpl #MMU_68040,_C_LABEL(mmutype) | 68040? - jne Lresnot040 | no, skip -#endif - clrl sp@- | yes... - frestore sp@+ | ...magic! -Lresnot040: -#endif - fmovem a0@(FPF_FPCR),fpcr/fpsr/fpi | restore FP control registers - fmovem a0@(FPF_REGS),fp0-fp7 | restore FP general registers -Lresfprest: - frestore a0@ | restore state - -Lnofprest: - movw a1@(PCB_PS),sr | no, restore PS - moveq #1,d0 | return 1 (for alternate returns) - rts - -/* - * savectx(pcb) - * Update pcb, saving current processor state. - */ -ENTRY(savectx) - movl sp@(4),a1 - movw sr,a1@(PCB_PS) - movl usp,a0 | grab USP - movl a0,a1@(PCB_USP) | and save it - moveml #0xFCFC,a1@(PCB_REGS) | save non-scratch registers - - tstl _C_LABEL(fputype) | Do we have FPU? - jeq Lsvnofpsave | No? Then don't save state. - lea a1@(PCB_FPCTX),a0 | pointer to FP save area - fsave a0@ | save FP state - tstb a0@ | null state frame? - jeq Lsvnofpsave | yes, all done - fmovem fp0-fp7,a0@(FPF_REGS) | save FP general registers - fmovem fpcr/fpsr/fpi,a0@(FPF_FPCR) | save FP control registers -Lsvnofpsave: - moveq #0,d0 | return 0 - rts - -#if defined(M68040) -ENTRY(suline) - movl sp@(4),a0 | address to write - movl _C_LABEL(curpcb),a1 | current pcb - movl #Lslerr,a1@(PCB_ONFAULT) | where to return to on a fault - movl sp@(8),a1 | address of line - movl a1@+,d0 | get lword - movsl d0,a0@+ | put lword - nop | sync - movl a1@+,d0 | get lword - movsl d0,a0@+ | put lword - nop | sync - movl a1@+,d0 | get lword - movsl d0,a0@+ | put lword - nop | sync - movl a1@+,d0 | get lword - movsl d0,a0@+ | put lword - nop | sync - moveq #0,d0 | indicate no fault - jra Lsldone -Lslerr: - moveq #-1,d0 -Lsldone: - movl _C_LABEL(curpcb),a1 | current pcb - clrl a1@(PCB_ONFAULT) | clear fault address - rts -#endif - -/* - * Invalidate entire TLB. - */ -ASENTRY_NOPROFILE(TBIA) -#if defined(M68040) - cmpl #MMU_68040,_C_LABEL(mmutype) | 68040? - jne Lmotommu3 | no, skip - .word 0xf518 | yes, pflusha - rts -Lmotommu3: -#endif - pflusha -#if defined(M68020) - tstl _C_LABEL(mmutype) - jgt Ltbia851 | 68851 implies no d-cache -#endif - movl #DC_CLEAR,d0 - movc d0,cacr | invalidate on-chip d-cache -Ltbia851: - rts - -/* - * Invalidate any TLB entry for given VA (TB Invalidate Single) - */ -ENTRY(TBIS) - movl sp@(4),a0 -#if defined(M68040) - cmpl #MMU_68040,_C_LABEL(mmutype) | 68040? - jne Lmotommu4 | no, skip - movc dfc,d1 - moveq #FC_USERD,d0 | user space - movc d0,dfc - .word 0xf508 | pflush a0@ - moveq #FC_SUPERD,d0 | supervisor space - movc d0,dfc - .word 0xf508 | pflush a0@ - movc d1,dfc - rts -Lmotommu4: -#endif -#if defined(M68020) - tstl _C_LABEL(mmutype) - jle Ltbis851 - pflushs #0,#0,a0@ | flush address from both sides - rts -Ltbis851: -#endif - pflush #0,#0,a0@ | flush address from both sides - movl #DC_CLEAR,d0 - movc d0,cacr | invalidate on-chip data cache - rts - -/* - * Invalidate supervisor side of TLB - */ -ENTRY(TBIAS) -#if defined(M68040) - cmpl #MMU_68040,_C_LABEL(mmutype) | 68040? - jne Lmotommu5 | no, skip - .word 0xf518 | yes, pflusha (for now) XXX - rts -Lmotommu5: -#endif -#if defined(M68020) - tstl _C_LABEL(mmutype) - jle Ltbias851 - pflushs #4,#4 | flush supervisor TLB entries - rts -Ltbias851: -#endif - pflush #4,#4 | flush supervisor TLB entries - movl #DC_CLEAR,d0 - movc d0,cacr | invalidate on-chip d-cache - rts - -/* - * Invalidate instruction cache - */ -ENTRY(ICIA) -#if defined(M68040) - cmpl #MMU_68040,_C_LABEL(mmutype) | 68040? - jne Lmotommu7 | no, skip - .word 0xf498 | cinva ic - rts -Lmotommu7: -#endif - movl #IC_CLEAR,d0 - movc d0,cacr | invalidate i-cache - rts - -/* - * Invalidate data cache. - * - * NOTE: we do not flush 68030 on-chip cache as there are no aliasing - * problems with DC_WA. The only cases we have to worry about are context - * switch and TLB changes, both of which are handled "in-line" in resume - * and TBI*. - * Because of this, since there is no way on 68040 and 68060 to flush - * user and supervisor modes specfically, DCIS and DCIU are the same entry - * point as DCIA. - */ -ENTRY(DCIA) -ENTRY(DCIS) -ENTRY(DCIU) -#if defined(M68040) - cmpl #MMU_68040,_C_LABEL(mmutype) | 68040 or 68060? - jgt 1f | no, skip - .word 0xf478 | cpusha dc -1: -#endif - rts - -#ifdef M68040 -ENTRY(ICPA) - .word 0xf498 | cinva ic - rts -ENTRY(DCFA) - .word 0xf478 | cpusha dc - rts -ENTRY(ICPL) /* invalidate instruction physical cache line */ - movl sp@(4),a0 | address - .word 0xf488 | cinvl ic,a0@ - rts -ENTRY(ICPP) /* invalidate instruction physical cache page */ - movl sp@(4),a0 | address - .word 0xf490 | cinvp ic,a0@ - rts -ENTRY(DCPL) /* invalidate data physical cache line */ - movl sp@(4),a0 | address - .word 0xf448 | cinvl dc,a0@ - rts -ENTRY(DCPP) /* invalidate data physical cache page */ - movl sp@(4),a0 | address - .word 0xf450 | cinvp dc,a0@ - rts -ENTRY(DCFL) /* data cache flush line */ - movl sp@(4),a0 | address - .word 0xf468 | cpushl dc,a0@ - rts -ENTRY(DCFP) /* data cache flush page */ - movl sp@(4),a0 | address - .word 0xf470 | cpushp dc,a0@ - rts -#endif /* M68040 */ - -ENTRY(PCIA) -#if defined(M68040) - cmpl #MMU_68040,_C_LABEL(mmutype) | 68040? - jne LmotommuB | no, skip - .word 0xf478 | cpusha dc - rts -LmotommuB: -#endif - movl #DC_CLEAR,d0 - movc d0,cacr | invalidate on-chip d-cache - rts - -ENTRY_NOPROFILE(getsfc) - movc sfc,d0 - rts - -ENTRY_NOPROFILE(getdfc) - movc dfc,d0 - rts - -/* - * Load a new user segment table pointer. - */ -ENTRY(loadustp) - movl sp@(4),d0 | new USTP - moveq #PGSHIFT,d1 - lsll d1,d0 | convert to addr -#if defined(M68040) - cmpl #MMU_68040,_C_LABEL(mmutype) | 68040? - jne LmotommuC | no, skip - .word 0xf518 | pflusha - .long 0x4e7b0806 | movec d0, URP - rts -LmotommuC: -#endif - pflusha | flush entire TLB - lea _C_LABEL(protorp),a0 | CRP prototype - movl d0,a0@(4) | stash USTP - pmove a0@,crp | load root pointer - movl #CACHE_CLR,d0 - movc d0,cacr | invalidate cache(s) - rts - -/* - * Set processor priority level calls. Most are implemented with - * inline asm expansions. However, spl0 requires special handling - * as we need to check for our emulated software interrupts. - */ - -ENTRY(spl0) - moveq #0,d0 - movw sr,d0 | get old SR for return - movw #PSL_LOWIPL,sr | restore new SR - tstl _C_LABEL(softpending) | software interrupt pending? - jeq Lspldone | no, all done - subql #4,sp | make room for RTE frame - movl sp@(4),sp@(2) | position return address - clrw sp@(6) | set frame type 0 - movw #PSL_LOWIPL,sp@ | and new SR - jra Lgotsir | go handle it -Lspldone: - rts - -/* - * Save and restore 68881 state. - * Pretty awful looking since our assembler does not - * recognize FP mnemonics. - */ -ENTRY(m68881_save) - movl sp@(4),a0 | save area pointer - fsave a0@ | save state - tstb a0@ | null state frame? - jeq Lm68881sdone | yes, all done - fmovem fp0-fp7,a0@(FPF_REGS) | save FP general registers - fmovem fpcr/fpsr/fpi,a0@(FPF_FPCR) | save FP control registers -Lm68881sdone: - rts - -ENTRY(m68881_restore) - movl sp@(4),a0 | save area pointer - tstb a0@ | null state frame? - jeq Lm68881rdone | yes, easy - fmovem a0@(FPF_FPCR),fpcr/fpsr/fpi | restore FP control registers - fmovem a0@(FPF_REGS),fp0-fp7 | restore FP general registers -Lm68881rdone: - frestore a0@ | restore state - rts - -/* - * delay() - delay for a specified number of microseconds - * _delay() - calibrator helper for delay() - * - * Notice that delay_factor is scaled up by a factor of 128 to avoid loss - * of precision for small delays. As a result of this we need to avoid - * overflow. - * - * The branch target for the loops must be aligned on a half-line (8-byte) - * boundary to minimize cache effects. This guarantees both that there - * will be no prefetch stalls due to cache line burst operations and that - * the loops will run from a single cache half-line. - */ - .balign 8 | align to half-line boundary - -ALTENTRY(_delay, delay) -ENTRY(delay) - movl sp@(4),d0 | get microseconds to delay - cmpl #0x40000,d0 | is it a "large" delay? - bls Ldelayshort | no, normal calculation - movql #0x7f,d1 | adjust for scaled multipler (to - addl d1,d0 | avoid overflow) - lsrl #7,d0 - mulul _C_LABEL(delay_factor),d0 | calculate number of loop iterations - bra Ldelaysetup | go do it! -Ldelayshort: - mulul _C_LABEL(delay_factor),d0 | calculate number of loop iterations - lsrl #7,d0 | adjust for scaled multiplier -Ldelaysetup: - jeq Ldelayexit | bail out if nothing to do - movql #0,d1 | put bits 15-0 in d1 for the - movw d0,d1 | inner loop, and move bits - movw #0,d0 | 31-16 to the low-order word - subql #1,d1 | of d0 for the outer loop - swap d0 -Ldelay: - tstl _C_LABEL(delay_flag) | this never changes for delay()! - dbeq d1,Ldelay | (used only for timing purposes) - dbeq d0,Ldelay - addqw #1,d1 | adjust end count and - swap d0 | return the longword result - orl d1,d0 -Ldelayexit: - rts - -/* - * Handle the nitty-gritty of rebooting the machine. - * Basically we just turn off the MMU and jump to the appropriate ROM routine. - * Note that we must be running in an address range that is mapped one-to-one - * logical to physical so that the PC is still valid immediately after the MMU - * is turned off. We have conveniently mapped the last page of physical - * memory this way. - */ -ENTRY_NOPROFILE(doboot) -#if defined(M68040) - cmpl #MMU_68040,_C_LABEL(mmutype) | 68040? - jeq Lnocache5 | yes, skip -#endif - movl #CACHE_OFF,d0 - movc d0,cacr | disable on-chip cache(s) -Lnocache5: - movl _C_LABEL(maxaddr),a0 | last page of physical memory - lea Lbootcode,a1 | start of boot code - lea Lebootcode,a3 | end of boot code -Lbootcopy: - movw a1@+,a0@+ | copy a word - cmpl a3,a1 | done yet? - jcs Lbootcopy | no, keep going -#if defined(M68040) - cmpl #MMU_68040,_C_LABEL(mmutype) | 68040? - jne LmotommuE | no, skip - .word 0xf4f8 | cpusha bc -LmotommuE: -#endif - movl _C_LABEL(maxaddr),a0 - jmp a0@ | jump to last page - -Lbootcode: - lea a0@(0x800),sp | physical SP in case of NMI - movl _C_LABEL(MacOSROMBase),a1 | Load MacOS ROMBase - -#if defined(M68040) - cmpl #MMU_68040,_C_LABEL(mmutype) | 68040? - jne LmotommuF | no, skip - movl #0,d0 - movc d0,cacr | caches off - .long 0x4e7b0003 | movc d0,tc (disable MMU) - jra Ldoboot1 -LmotommuF: -#endif - movl #0,a3@ | value for pmove to TC (turn off MMU) - pmove a3@,tc | disable MMU - -Ldoboot1: - lea a1@(0x90),a1 | offset of ROM reset routine - jmp a1@ | and jump to ROM to reset machine -Lebootcode: - -/* - * u_long ptest040(caddr_t addr, u_int fc); - * - * ptest040() does an 040 PTESTR (addr) and returns the 040 MMUSR iff - * translation is enabled. This allows us to find the physical address - * corresponding to a MacOS logical address for get_physical(). - * sar 01-oct-1996 - */ -ENTRY_NOPROFILE(ptest040) -#if defined(M68040) - .long 0x4e7a0003 | movc tc,d0 - andw #0x8000,d0 - jeq Lget_phys1 | MMU is disabled - movc dfc,d1 | Save DFC - movl sp@(8),d0 | Set FC for ptestr - movc d0,dfc - movl sp@(4),a0 | logical address to look up - .word 0xf568 | ptestr (a0) - .long 0x4e7a0805 | movc mmusr,d0 - movc d1,dfc | Restore DFC - rts -Lget_phys1: -#endif - movql #0,d0 | return failure - rts - -/* - * LAK: (7/24/94) This routine was added so that the - * C routine that runs at startup can figure out how MacOS - * had mapped memory. We want to keep the same mapping so - * that when we set our MMU pointer, the PC doesn't point - * in the middle of nowhere. - * - * long get_pte(void *addr, unsigned long pte[2], unsigned short *psr) - * - * Takes "addr" and looks it up in the current MMU pages. Puts - * the PTE of that address in "pte" and the result of the - * search in "psr". "pte" should be 2 longs in case it is - * a long-format entry. - * - * One possible problem here is that setting the TT register - * may screw something up if we access user data space in a - * called function or in an interrupt service routine. - * - * Returns -1 on error, 0 if pte is a short-format pte, or - * 1 if pte is a long-format pte. - * - * Be sure to only call this routine if the MMU is enabled. This - * routine is probably more general than it needs to be -- it - * could simply return the physical address (replacing - * get_physical() in machdep). - * - * "gas" does not understand the tt0 register, so we must hand- - * assemble the instructions. - */ -ENTRY_NOPROFILE(get_pte) - subql #4,sp | make temporary space - - lea _ASM_LABEL(longscratch),a0 - movl #0x00ff8710,a0@ | Set up FC 1 r/w access - .long 0xf0100800 | pmove a0@,tt0 - - movl sp@(8),a0 | logical address to look up - movl #0,a1 | clear in case of failure - ptestr #FC_USERD,a0@,#7,a1 | search for logical address - pmove psr,sp@ | store processor status register - movw sp@,d1 - movl sp@(16),a0 | where to store the psr - movw d1,a0@ | send back to caller - andw #0xc400,d1 | if bus error, exceeded limit, or invalid - jne get_pte_fail1 | leave now - tstl a1 | check address we got back - jeq get_pte_fail2 | if 0, then was not set -- fail - - movl a1,d0 - movl d0,_ASM_LABEL(pte_tmp) | save for later - - | send first long back to user - movl sp@(12),a0 | address of where to put pte - movsl a1@,d0 | - movl d0,a0@ | first long - - andl #3,d0 | dt bits of pte - cmpl #1,d0 | should be 1 if page descriptor - jne get_pte_fail3 | if not, get out now - - movl sp@(16),a0 | addr of stored psr - movw a0@,d0 | get psr again - andw #7,d0 | number of levels it found - addw #-1,d0 | find previous level - movl sp@(8),a0 | logical address to look up - movl #0,a1 | clear in case of failure - - cmpl #0,d0 - jeq pte_level_zero - cmpl #1,d0 - jeq pte_level_one - cmpl #2,d0 - jeq pte_level_two - cmpl #3,d0 - jeq pte_level_three - cmpl #4,d0 - jeq pte_level_four - cmpl #5,d0 - jeq pte_level_five - cmpl #6,d0 - jeq pte_level_six - jra get_pte_fail4 | really should have been one of these... - -pte_level_zero: - | must get CRP to get length of entries at first level - lea _ASM_LABEL(longscratch),a0 | space for two longs - pmove crp,a0@ | save root pointer - movl a0@,d0 | load high long - jra pte_got_parent -pte_level_one: - ptestr #FC_USERD,a0@,#1,a1 | search for logical address - pmove psr,sp@ | store processor status register - movw sp@,d1 - jra pte_got_it -pte_level_two: - ptestr #FC_USERD,a0@,#2,a1 | search for logical address - pmove psr,sp@ | store processor status register - movw sp@,d1 - jra pte_got_it -pte_level_three: - ptestr #FC_USERD,a0@,#3,a1 | search for logical address - pmove psr,sp@ | store processor status register - movw sp@,d1 - jra pte_got_it -pte_level_four: - ptestr #FC_USERD,a0@,#4,a1 | search for logical address - pmove psr,sp@ | store processor status register - movw sp@,d1 - jra pte_got_it -pte_level_five: - ptestr #FC_USERD,a0@,#5,a1 | search for logical address - pmove psr,sp@ | store processor status register - movw sp@,d1 - jra pte_got_it -pte_level_six: - ptestr #FC_USERD,a0@,#6,a1 | search for logical address - pmove psr,sp@ | store processor status register - movw sp@,d1 - -pte_got_it: - andw #0xc400,d1 | if bus error, exceeded limit, or invalid - jne get_pte_fail5 | leave now - tstl a1 | check address we got back - jeq get_pte_fail6 | if 0, then was not set -- fail - - movsl a1@,d0 | get pte of parent - movl d0,_C_LABEL(macos_tt0) | XXX for later analysis (kill me) -pte_got_parent: - andl #3,d0 | dt bits of pte - cmpl #2,d0 | child is short-format descriptor - jeq short_format - cmpl #3,d0 | child is long-format descriptor - jne get_pte_fail7 - - | long_format -- we must go back, change the tt, and get the - | second long. The reason we didn't do this in the first place - | is that the first long might have been the last long of RAM. - - movl _ASM_LABEL(pte_tmp),a1 | get address of our original pte - addql #4,a1 | address of ite second long - - | send second long back to user - movl sp@(12),a0 | address of where to put pte - movsl a1@,d0 | - movl d0,a0@(4) | write in second long - - movql #1,d0 | return long-format - jra get_pte_success - -short_format: - movql #0,d0 | return short-format - jra get_pte_success - -#ifndef DEBUG -get_pte_fail1: -get_pte_fail2: -get_pte_fail3: -get_pte_fail4: -get_pte_fail5: -get_pte_fail6: -get_pte_fail7: -get_pte_fail8: -get_pte_fail9: -get_pte_fail10: -#endif -get_pte_fail: - movql #-1,d0 | return failure - -get_pte_success: - lea _ASM_LABEL(longscratch),a0 | disable tt - movl #0,a0@ - .long 0xf0100800 | pmove a0@,tt0 - - addql #4,sp | return temporary space - rts - -#ifdef DEBUG -get_pte_fail10: - jbsr _C_LABEL(printstar) -get_pte_fail9: - jbsr _C_LABEL(printstar) -get_pte_fail8: - jbsr _C_LABEL(printstar) -get_pte_fail7: - jbsr _C_LABEL(printstar) -get_pte_fail6: - jbsr _C_LABEL(printstar) -get_pte_fail5: - jbsr _C_LABEL(printstar) -get_pte_fail4: - jbsr _C_LABEL(printstar) -get_pte_fail3: - jbsr _C_LABEL(printstar) -get_pte_fail2: - jbsr _C_LABEL(printstar) -get_pte_fail1: - jbsr _C_LABEL(printstar) - jra get_pte_fail -#endif - -/* - * Misc. global variables. - */ - .data -GLOBAL(machineid) - .long 0 - -GLOBAL(mmutype) - .long MMU_68851 | default to 68851 PMMU - -GLOBAL(cputype) - .long CPU_68020 | default to 68020 CPU - -GLOBAL(fputype) - .long FPU_68882 | default to 68882 FPU - -GLOBAL(protorp) - .long 0,0 | prototype root pointer - -GLOBAL(cold) - .long 1 | cold start flag - -GLOBAL(want_resched) - .long 0 - -GLOBAL(proc0paddr) - .long 0 | KVA of proc0 u-area - -GLOBAL(intiolimit) - .long 0 | KVA of end of internal IO space - -GLOBAL(load_addr) - .long 0 | Physical address of kernel - -ASLOCAL(lastpage) - .long 0 | LAK: to store the addr of last page in mem - -GLOBAL(MacOSROMBase) - .long 0x40800000 -GLOBAL(mac68k_vrsrc_cnt) - .long 0 -GLOBAL(mac68k_vrsrc_vec) - .word 0, 0, 0, 0, 0, 0 diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c deleted file mode 100644 index 0d3abcc1361..00000000000 --- a/sys/arch/mac68k/mac68k/machdep.c +++ /dev/null @@ -1,2046 +0,0 @@ -/* $OpenBSD: machdep.c,v 1.159 2011/06/26 22:39:59 deraadt Exp $ */ -/* $NetBSD: machdep.c,v 1.207 1998/07/08 04:39:34 thorpej Exp $ */ - -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -/* - * from: Utah $Hdr: machdep.c 1.63 91/04/24$ - * - * @(#)machdep.c 7.16 (Berkeley) 6/3/91 - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/signalvar.h> -#include <sys/kernel.h> -#include <sys/proc.h> -#include <sys/buf.h> -#include <sys/exec.h> -#include <sys/core.h> -#include <sys/kcore.h> -#include <sys/vnode.h> -#include <sys/reboot.h> -#include <sys/conf.h> -#include <sys/file.h> -#include <sys/timeout.h> -#include <sys/malloc.h> -#include <sys/mbuf.h> -#include <sys/msgbuf.h> -#include <sys/user.h> -#include <sys/mount.h> -#include <sys/extent.h> -#include <sys/syscallargs.h> - -#include <machine/db_machdep.h> -#include <ddb/db_sym.h> -#include <ddb/db_extern.h> -#include <ddb/db_var.h> - -#include <machine/autoconf.h> -#include <machine/cpu.h> -#include <machine/reg.h> -#include <machine/psl.h> -#include <machine/pte.h> -#include <machine/kcore.h> -#include <machine/bus.h> -#include <machine/pmap.h> - -#include <net/if.h> -#include <uvm/uvm_extern.h> -#include <uvm/uvm_swap.h> - -#include <sys/sysctl.h> - -#include <dev/cons.h> -#include <mac68k/dev/adbvar.h> - -#include <machine/iop.h> -#include <machine/psc.h> -#include <machine/viareg.h> - -#include "wsdisplay.h" - -/* The following is used externally (sysctl_hw) */ -char machine[] = MACHINE; /* from <machine/param.h> */ - -struct mac68k_machine_S mac68k_machine; - -volatile u_char *Via1Base, *Via2Base, *PSCBase = NULL; -u_long NuBusBase = NBBASE; -u_long IOBase; - -vaddr_t SCSIBase; - -/* These are used to map kernel space: */ -#define NBMEMRANGES 8 -extern int numranges; -extern u_long low[NBMEMRANGES]; -extern u_long high[NBMEMRANGES]; - -/* These are used to map NuBus space: */ -#define NBMAXRANGES 16 -int nbnumranges; /* = 0 == don't use the ranges */ -u_long nbphys[NBMAXRANGES]; /* Start physical addr of this range */ -u_long nblog[NBMAXRANGES]; /* Start logical addr of this range */ -long nblen[NBMAXRANGES]; /* Length of this range If the length is */ - /* negative, all phys addrs are the same. */ - -/* From Booter via locore */ -long videoaddr; /* Addr used in kernel for video. */ -long videorowbytes; /* Used in kernel for video. */ -long videobitdepth; /* Number of bihs per pixel */ -u_long videosize; /* height = 31:16, width 15:0 */ - -/* - * Values for IIvx-like internal video - * -- should be zero if it is not used (usual case). - */ -u_int32_t mac68k_vidlog; /* logical addr */ -u_int32_t mac68k_vidphys; /* physical addr */ -u_int32_t mac68k_vidlen; /* mem length */ - -/* Callback and cookie to run bell */ -int (*mac68k_bell_callback)(void *, int, int, int); -caddr_t mac68k_bell_cookie; - -struct vm_map *exec_map = NULL; -struct vm_map *phys_map = NULL; - -int physmem; /* size of physical memory, in pages */ - -struct uvm_constraint_range dma_constraint = { 0x0, (paddr_t)-1 }; -struct uvm_constraint_range *uvm_md_constraints[] = { NULL }; - -/* - * safepri is a safe priority for sleep to set for a spin-wait - * during autoconfiguration or after a panic. - */ -int safepri = PSL_LOWIPL; - -/* - * Extent maps to manage all memory space, including I/O ranges. Allocate - * storage for 8 regions in each, initially. Later, iomem_malloc_safe - * will indicate that it's safe to use malloc() to dynamically allocate - * region descriptors. - * - * The extent maps are not static! Machine-dependent NuBus and on-board - * I/O routines need access to them for bus address space allocation. - */ -long iomem_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)]; -struct extent *iomem_ex; -int iomem_malloc_safe; - -/* XXX should be in locore.s for consistency */ -int astpending = 0; - -void identifycpu(void); -u_long get_physical(u_int, u_long *); - -void initcpu(void); -int cpu_dumpsize(void); -int cpu_dump(int (*)(dev_t, daddr64_t, caddr_t, size_t), daddr64_t *); -void cpu_init_kcore_hdr(void); -int fpu_probe(void); - -/* functions called from locore.s */ -void dumpsys(void); -void mac68k_init(void); -void straytrap(int, int); -void nmihand(struct frame); - -/* - * Machine-dependent crash dump header info. - */ -cpu_kcore_hdr_t cpu_kcore_hdr; - - /* - * Early initialization, before main() is called. - */ -void -mac68k_init() -{ - int i; - extern vaddr_t avail_start; - - /* - * Tell the VM system about available physical memory. - */ - for (i = 0; i < numranges; i++) { - if (low[i] <= avail_start && avail_start < high[i]) - uvm_page_physload(atop(avail_start), atop(high[i]), - atop(avail_start), atop(high[i]), 0); - else - uvm_page_physload(atop(low[i]), atop(high[i]), - atop(low[i]), atop(high[i]), 0); - } - - /* - * Initialize the I/O mem extent map. - * Note: we don't have to check the return value since - * creation of a fixed extent map will never fail (since - * descriptor storage has already been allocated). - * - * N.B. The iomem extent manages _all_ physical addresses - * on the machine. When the amount of RAM is found, all - * extents of RAM are allocated from the map. - */ - iomem_ex = extent_create("iomem", 0x0, 0xffffffff, M_DEVBUF, - (caddr_t)iomem_ex_storage, sizeof(iomem_ex_storage), - EX_NOCOALESCE|EX_NOWAIT); - - /* Initialize the interrupt handlers. */ - intr_init(); - - /* Initialize the VIAs */ - via_init(); - - /* Initialize the PSC (if present) */ - psc_init(); -} - -/* - * Console initialization: called early on from main, - * before vm init or startup. Do enough configuration - * to choose and initialize a console. - */ -void -consinit(void) -{ - /* - * Generic console: sys/dev/cons.c - * Initializes either ite or ser as console. - * Can be called from locore.s and init_main.c. (Ugh.) - */ - static int init; /* = 0 */ - - if (!init) { - cninit(); -#ifdef DDB - /* - * Initialize kernel debugger, if compiled in. - */ - ddb_init(); -#endif - init = 1; - } else { -#if NWSDISPLAY > 0 - /* - * XXX This is an evil hack on top of an evil hack! - * - * With the graybar stuff, we've got a catch-22: we need - * to do at least some console setup really early on, even - * before we're running with the mappings we need. On - * the other hand, we're not nearly ready to do anything - * with wscons or the ADB driver at that point. - * - * To get around this, wscninit() ignores the first call - * it gets (from cninit(), if not on a serial console). - * Once we're here, we call wscninit() again, which sets - * up the console devices and does the appropriate wscons - * initialization. - */ - if (mac68k_machine.serial_console == 0) { - cons_decl(ws); - wscninit(NULL); - } -#endif - - mac68k_calibrate_delay(); - -#if NZSC > 0 && defined(KGDB) - zs_kgdb_init(); -#endif - - if (boothowto & RB_KDB) { -#ifdef KGDB - /* XXX - Ask on console for kgdb_dev? */ - /* Note: this will just return if kgdb_dev==NODEV */ - kgdb_connect(1); -#else /* KGDB */ -#ifdef DDB - /* Enter DDB. We don't have a monitor PROM. */ - Debugger(); -#endif /* DDB */ -#endif /* KGDB */ - } - } -} - -#define CURRENTBOOTERVER 111 - -/* - * cpu_startup: allocate memory for variable-sized tables, - * initialize cpu, and do autoconfiguration. - */ -void -cpu_startup(void) -{ - unsigned i; - int vers; - vaddr_t minaddr, maxaddr; - int delay; - - /* - * Initialize the kernel crash dump header. - */ - cpu_init_kcore_hdr(); - - /* - * Initialize error message buffer (at end of core). - * high[numranges-1] was decremented in pmap_bootstrap. - */ - for (i = 0; i < atop(MSGBUFSIZE); i++) - pmap_enter(pmap_kernel(), (vaddr_t)msgbufp + i * NBPG, - high[numranges - 1] + i * NBPG, - VM_PROT_READ|VM_PROT_WRITE, - VM_PROT_READ|VM_PROT_WRITE|PMAP_WIRED); - pmap_update(pmap_kernel()); - initmsgbuf((caddr_t)msgbufp, round_page(MSGBUFSIZE)); - - /* - * Good {morning,afternoon,evening,night}. - */ - printf(version); - identifycpu(); - - vers = mac68k_machine.booter_version; - if (vers < CURRENTBOOTERVER) { - /* fix older booters with indices, not versions */ - if (vers < 100) - vers += 99; - - printf("\nYou booted with booter version %d.%d.\n", - vers / 100, vers % 100); - printf("Booter version %d.%d is necessary to fully support\n", - CURRENTBOOTERVER / 100, CURRENTBOOTERVER % 100); - printf("this kernel.\n\n"); - for (delay = 0; delay < 1000000; delay++); - } - printf("real mem = %u (%uMB)\n", ptoa(physmem), - ptoa(physmem)/1024/1024); - - /* - * Allocate a submap for exec arguments. This map effectively - * limits the number of processes exec'ing at any time. - */ - minaddr = vm_map_min(kernel_map); - exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, - 16 * NCARGS, VM_MAP_PAGEABLE, FALSE, NULL); - - /* - * Allocate a submap for physio - */ - phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, - VM_PHYS_SIZE, 0, FALSE, NULL); - - printf("avail mem = %lu (%luMB)\n", ptoa(uvmexp.free), - ptoa(uvmexp.free) / 1024 / 1024); - - /* - * Set up CPU-specific registers, cache, etc. - */ - initcpu(); - - /* - * Set up buffers, so they can be used to read disk labels. - */ - bufinit(); - - /* - * Configure the system. - */ - if (boothowto & RB_CONFIG) { -#ifdef BOOT_CONFIG - user_config(); -#else - printf("kernel does not support -c; continuing..\n"); -#endif - } - - /* Safe for extent allocation to use malloc now. */ - iomem_malloc_safe = 1; -} - -void -initcpu() -{ -#if defined(M68040) - extern void (*vectab[256])(void); - void addrerr4060(void); -#endif -#ifdef M68040 - void buserr40(void); -#endif -#ifdef FPSP - extern u_long fpvect_tab, fpvect_end, fpsp_tab; -#endif - - switch (cputype) { -#ifdef M68040 - case CPU_68040: - vectab[2] = buserr40; - vectab[3] = addrerr4060; -#ifdef FPSP - bcopy(&fpsp_tab, &fpvect_tab, - (&fpvect_end - &fpvect_tab) * sizeof (fpvect_tab)); -#endif - break; -#endif - default: - break; - } - - DCIS(); -} - -void doboot(void) - __attribute__((__noreturn__)); - -int waittime = -1; - -void -boot(howto) - int howto; -{ - extern u_long maxaddr; - - /* take a snap shot before clobbering any registers */ - if (curproc && curproc->p_addr) - savectx(&curproc->p_addr->u_pcb); - - /* If system is cold, just halt. */ - if (cold) { - /* (Unless the user explicitly asked for reboot.) */ - if ((howto & RB_USERREQ) == 0) - howto |= RB_HALT; - goto haltsys; - } - - boothowto = howto; - if ((howto & RB_NOSYNC) == 0 && waittime < 0) { - waittime = 0; - vfs_shutdown(); - - if (mac68k_machine.aux_interrupts != 0) { - /* - * If we've been adjusting the clock, the todr - * will be out of synch; adjust it now unless - * the system was sitting in ddb. - */ - if ((howto & RB_TIMEBAD) == 0) { - resettodr(); - } else { - printf("WARNING: not updating battery clock\n"); - } - } else { -#ifdef DIAGNOSTIC - printf("OpenBSD/mac68k does not trust itself to update" - " the clock on shutdown on this machine.\n"); -#endif - } - } - if_downall(); - - uvm_shutdown(); - splhigh(); /* Disable interrupts. */ - - /* If rebooting and a dump is requested, do it. */ - if (howto & RB_DUMP) { - dumpsys(); - } - -haltsys: - /* Run any shutdown hooks. */ - doshutdownhooks(); - - if (howto & RB_HALT) { - if (howto & RB_POWERDOWN) { - printf("\nAttempting to power down...\n"); - via_powerdown(); - /* - * Shut down machines whose power functions - * are accessed via modified ADB calls. - */ - adb_poweroff(); - } - printf("\nThe operating system has halted.\n"); - printf("Please press any key to reboot.\n\n"); - cnpollc(1); - (void)cngetc(); - cnpollc(0); - } - - /* Map the last physical page VA = PA for doboot() */ - pmap_enter(pmap_kernel(), (vaddr_t)maxaddr, (vaddr_t)maxaddr, - VM_PROT_ALL, VM_PROT_ALL|PMAP_WIRED); - pmap_update(pmap_kernel()); - - printf("rebooting...\n"); - DELAY(1000000); - doboot(); - /* NOTREACHED */ -} - -/* - * Initialize the kernel crash dump header. - */ -void -cpu_init_kcore_hdr() -{ - cpu_kcore_hdr_t *h = &cpu_kcore_hdr; - int i; - - bzero(&cpu_kcore_hdr, sizeof(cpu_kcore_hdr)); - - h->mmutype = mmutype; - h->kernel_pa = low[0]; - h->sysseg_pa = pmap_kernel()->pm_stpa; - - /* - * mac68k has multiple RAM segments on some models. - */ - for (i = 0; i < numranges; i++) { - h->ram_segs[i].start = low[i]; - h->ram_segs[i].size = high[i] - low[i]; - } -} - -/* - * Compute the size of the machine-dependent crash dump header. - * Returns size in disk blocks. - */ -int -cpu_dumpsize() -{ - int size; - - size = ALIGN(sizeof(kcore_seg_t)) + ALIGN(sizeof(cpu_kcore_hdr_t)); - return (btodb(roundup(size, dbtob(1)))); -} - -/* - * Called by dumpsys() to dump the machine-dependent header. - */ -int -cpu_dump(dump, blknop) - int (*dump)(dev_t, daddr64_t, caddr_t, size_t); - daddr64_t *blknop; -{ - int buf[dbtob(1) / sizeof(int)]; - cpu_kcore_hdr_t *chdr; - kcore_seg_t *kseg; - int error; - - kseg = (kcore_seg_t *)buf; - chdr = (cpu_kcore_hdr_t *)&buf[ALIGN(sizeof(kcore_seg_t)) / - sizeof(int)]; - - /* Create the segment header. */ - CORE_SETMAGIC(*kseg, KCORE_MAGIC, MID_MACHINE, CORE_CPU); - kseg->c_size = dbtob(1) - ALIGN(sizeof(kcore_seg_t)); - - bcopy(&cpu_kcore_hdr, chdr, sizeof(cpu_kcore_hdr_t)); - error = (*dump)(dumpdev, *blknop, (caddr_t)buf, sizeof(buf)); - *blknop += btodb(sizeof(buf)); - return (error); -} - -/* - * These variables are needed by /sbin/savecore - */ -u_long dumpmag = 0x8fca0101; /* magic number */ -int dumpsize = 0; /* pages */ -long dumplo = 0; /* blocks */ - -/* - * This is called by main to set dumplo and dumpsize. - * Dumps always skip the first block of disk space in - * case there might be a disk label stored there. If there - * is extra space, put dump at the end to reduce the chance - * that swapping trashes it. - */ -void -dumpconf(void) -{ - cpu_kcore_hdr_t *h = &cpu_kcore_hdr; - int nblks; /* size of dump area */ - int i; - - if (dumpdev == NODEV || - (nblks = (bdevsw[major(dumpdev)].d_psize)(dumpdev)) == 0) - return; - if (nblks <= ctod(1)) - return; - - dumpsize = 0; - for (i = 0; h->ram_segs[i].size && i < NPHYS_RAM_SEGS; i++) - dumpsize += atop(h->ram_segs[i].size); - dumpsize += cpu_dumpsize(); - - /* Always skip the first block, in case there is a label there. */ - if (dumplo < ctod(1)) - dumplo = ctod(1); - - /* Put dump at end of partition, and make it fit. */ - if (dumpsize > dtoc(nblks - dumplo)) - dumpsize = dtoc(nblks - dumplo); - if (dumplo < nblks - ctod(dumpsize)) - dumplo = nblks - ctod(dumpsize); -} - -void -dumpsys() -{ - cpu_kcore_hdr_t *h = &cpu_kcore_hdr; - daddr64_t blkno; /* current block to write */ - /* dump routine */ - int (*dump)(dev_t, daddr64_t, caddr_t, size_t); - int pg; /* page being dumped */ - vaddr_t maddr; /* PA being dumped */ - int seg; /* RAM segment being dumped */ - int error; /* error code from (*dump)() */ - extern int msgbufmapped; - - /* XXX initialized here because of gcc lossage */ - seg = 0; - maddr = h->ram_segs[seg].start; - pg = 0; - - /* Don't record dump msgs in msgbuf. */ - msgbufmapped = 0; - - /* Make sure dump device is valid. */ - if (dumpdev == NODEV) - return; - if (dumpsize == 0) { - dumpconf(); - if (dumpsize == 0) - return; - } - if (dumplo <= 0) { - printf("\ndump to dev %u,%u not possible\n", major(dumpdev), - minor(dumpdev)); - return; - } - dump = bdevsw[major(dumpdev)].d_dump; - blkno = dumplo; - - printf("\ndumping to dev %u,%u offset %ld\n", major(dumpdev), - minor(dumpdev), dumplo); - -#ifdef UVM_SWAP_ENCRYPT - uvm_swap_finicrypt_all(); -#endif - - printf("dump "); - - /* Write the dump header. */ - error = cpu_dump(dump, &blkno); - if (error) - goto bad; - - 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 - while (maddr >= - (h->ram_segs[seg].start + h->ram_segs[seg].size)) { - if (++seg >= NPHYS_RAM_SEGS || - h->ram_segs[seg].size == 0) { - error = EINVAL; /* XXX ?? */ - goto bad; - } - maddr = h->ram_segs[seg].start; - } - pmap_enter(pmap_kernel(), (vaddr_t)vmmap, maddr, - VM_PROT_READ, VM_PROT_READ|PMAP_WIRED); - pmap_update(pmap_kernel()); - - error = (*dump)(dumpdev, blkno, vmmap, NBPG); -bad: - switch (error) { - case 0: - maddr += NBPG; - blkno += btodb(NBPG); - break; - - case ENXIO: - printf("device bad\n"); - return; - - case EFAULT: - printf("device not ready\n"); - return; - - case EINVAL: - printf("area improper\n"); - return; - - case EIO: - printf("i/o error\n"); - return; - - case EINTR: - printf("aborted from console\n"); - return; - - default: - printf("error %d\n", error); - return; - } - } - printf("succeeded\n"); -} - -/* - * Return the best possible estimate of the time in the timeval - * to which tvp points. We do this by returning the current time - * plus the amount of time since the last clock interrupt (clock.c:clkread). - * - * Check that this time is no less than any previously-reported time, - * which could happen around the time of a clock adjustment. Just for fun, - * we guarantee that the time will be greater than the value obtained by a - * previous call. - */ -void -microtime(tvp) - register struct timeval *tvp; -{ - int s = splhigh(); - static struct timeval lasttime; - - *tvp = time; - tvp->tv_usec += clkread(); - while (tvp->tv_usec >= 1000000) { - tvp->tv_sec++; - tvp->tv_usec -= 1000000; - } - if (tvp->tv_sec == lasttime.tv_sec && - tvp->tv_usec <= lasttime.tv_usec && - (tvp->tv_usec = lasttime.tv_usec + 1) >= 1000000) { - tvp->tv_sec++; - tvp->tv_usec -= 1000000; - } - lasttime = *tvp; - splx(s); -} - -void -straytrap(pc, evec) - int pc; - int evec; -{ - printf("unexpected trap; vector offset 0x%x from 0x%x.\n", - (int) (evec & 0xfff), pc); -#ifdef DEBUG -#ifdef DDB - Debugger(); -#endif -#endif -} - -int *nofault; - -/* - * Level 7 interrupts can be caused by the keyboard or parity errors. - */ -void nmihand(struct frame); - -void -nmihand(frame) - struct frame frame; -{ - static int nmihanddeep = 0; - - if (nmihanddeep) - return; - nmihanddeep = 1; - -#ifdef DDB - if (db_console) - Debugger(); -#endif - - nmihanddeep = 0; -} - -/* - * It should be possible to probe for the top of RAM, but Apple has - * memory structured so that in at least some cases, it's possible - * for RAM to be aliased across all memory--or for it to appear that - * there is more RAM than there really is. - */ -int get_top_of_ram(void); - -int -get_top_of_ram() -{ - return ((mac68k_machine.mach_memsize * (1024 * 1024)) - 4096); -} - -/* - * machine dependent system variables. - */ -int -cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) - int *name; - u_int namelen; - void *oldp; - size_t *oldlenp; - void *newp; - size_t newlen; - struct proc *p; -{ - dev_t consdev; - - /* all sysctl names at this level are terminal */ - if (namelen != 1) - return (ENOTDIR); /* overloaded */ - - switch (name[0]) { - case CPU_CONSDEV: - if (cn_tab != NULL) - consdev = cn_tab->cn_dev; - else - consdev = NODEV; - return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev, - sizeof consdev)); - default: - return (EOPNOTSUPP); - } - /* NOTREACHED */ -} - -static char *envbuf = NULL; - -/* - * getenvvars: Grab a few useful variables - */ -void getenvvars(u_long, char *); -long getenv(char *); - -void -getenvvars(flag, buf) - u_long flag; - char *buf; -{ - extern u_long bootdev; -#if defined(DDB) || NKSYMS > 0 - extern u_long end, esym; -#endif - extern u_long macos_boottime; - extern vaddr_t MacOSROMBase; - extern long macos_gmtbias; - extern u_short ADBDelay; - extern u_int32_t HwCfgFlags3; - int root_scsi_id; - vaddr_t ROMBase; - - /* - * If flag & 0x80000000 == 0, then we're booting with the old booter - * and we should freak out. - */ - if ((flag & 0x80000000) == 0) { - /* Freak out; print something if that becomes available */ - } else - envbuf = buf; - - /* These next two should give us mapped video & serial */ - /* We need these for pre-mapping graybars & echo, but probably */ - /* only on MacII or LC. -- XXX */ - /* videoaddr = getenv("MACOS_VIDEO"); */ - - /* - * The following are not in a structure so that they can be - * accessed more quickly. - */ - videoaddr = getenv("VIDEO_ADDR"); - videorowbytes = getenv("ROW_BYTES"); - videobitdepth = getenv("SCREEN_DEPTH"); - videosize = getenv("DIMENSIONS"); - - /* - * More misc stuff from booter. - */ - mac68k_machine.machineid = getenv("MACHINEID"); - mac68k_machine.mach_memsize = getenv("MEMSIZE"); - mac68k_machine.do_graybars = getenv("GRAYBARS"); - mac68k_machine.serial_boot_echo = getenv("SERIALECHO"); - mac68k_machine.serial_console = getenv("SERIALCONSOLE"); - - mac68k_machine.modem_flags = getenv("SERIAL_MODEM_FLAGS"); - mac68k_machine.modem_cts_clk = getenv("SERIAL_MODEM_HSKICLK"); - mac68k_machine.modem_dcd_clk = getenv("SERIAL_MODEM_GPICLK"); - mac68k_machine.modem_flags = getenv("SERIAL_MODEM_DSPEED"); - mac68k_machine.print_flags = getenv("SERIAL_PRINT_FLAGS"); - mac68k_machine.print_cts_clk = getenv("SERIAL_PRINT_HSKICLK"); - mac68k_machine.print_dcd_clk = getenv("SERIAL_PRINT_GPICLK"); - mac68k_machine.print_d_speed = getenv("SERIAL_PRINT_DSPEED"); - mac68k_machine.booter_version = getenv("BOOTERVER"); - - /* - * For now, we assume that the boot device is off the first controller. - * Booter versions 1.11.0 and later set a flag to tell us to construct - * bootdev using the SCSI ID passed in via the environment. - */ - root_scsi_id = getenv("ROOT_SCSI_ID"); - if (((mac68k_machine.booter_version < CURRENTBOOTERVER) || - (flag & 0x40000)) && bootdev == 0) - bootdev = MAKEBOOTDEV(4, 0, 0, root_scsi_id, 0); - - /* - * Booter 1.11.3 and later pass a BOOTHOWTO variable with the - * appropriate bits set. - */ - boothowto = getenv("BOOTHOWTO"); - if (boothowto == 0) - boothowto = getenv("SINGLE_USER"); - - /* - * Get end of symbols for kernel debugging - */ -#if defined(DDB) || NKSYMS > 0 - esym = getenv("END_SYM"); - if (esym == 0) - esym = (long) &end; -#endif - - /* Get MacOS time */ - macos_boottime = getenv("BOOTTIME"); - - /* Save GMT BIAS saved in Booter parameters dialog box */ - macos_gmtbias = getenv("GMTBIAS"); - - /* - * Save globals stolen from MacOS - */ - - ROMBase = (vaddr_t)getenv("ROMBASE"); - if (ROMBase != 0) - MacOSROMBase = ROMBase; - ADBDelay = (u_short) getenv("ADBDELAY"); - HwCfgFlags3 = getenv("HWCFGFLAG3"); -} - -char toupper(char); - -char -toupper(c) - char c; -{ - if (c >= 'a' && c <= 'z') { - return c - 'a' + 'A'; - } else { - return c; - } -} - -long -getenv(str) - char *str; -{ - /* - * Returns the value of the environment variable "str". - * - * Format of the buffer is "var=val\0var=val\0...\0var=val\0\0". - * - * Returns 0 if the variable is not there, and 1 if the variable is - * there without an "=val". - */ - - char *s, *s1; - int val, base; - - s = envbuf; - while (1) { - for (s1 = str; *s1 && *s && *s != '='; s1++, s++) { - if (toupper(*s1) != toupper(*s)) { - break; - } - } - if (*s1) { /* No match */ - while (*s) { - s++; - } - s++; - if (*s == '\0') { /* Not found */ - /* Boolean flags are FALSE (0) if not there */ - return 0; - } - continue; - } - if (*s == '=') {/* Has a value */ - s++; - val = 0; - base = 10; - if (*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X')) { - base = 16; - s += 2; - } else - if (*s == '0') { - base = 8; - } - while (*s) { - if (toupper(*s) >= 'A' && toupper(*s) <= 'F') { - val = val * base + toupper(*s) - 'A' + 10; - } else { - val = val * base + (*s - '0'); - } - s++; - } - return val; - } else { /* TRUE (1) */ - return 1; - } - } -} - -struct cpu_model_info cpu_models[] = { - -/* The first four. */ - { MACH_MACII, "II", MACH_CLASSII }, - { MACH_MACIIX, "IIx", MACH_CLASSII }, - { MACH_MACIICX, "IIcx", MACH_CLASSII }, - { MACH_MACSE30, "SE/30", MACH_CLASSII }, - -/* The rest of the II series... */ - { MACH_MACIICI, "IIci", MACH_CLASSIIci }, - { MACH_MACIISI, "IIsi", MACH_CLASSIIsi }, - { MACH_MACIIVI, "IIvi", MACH_CLASSIIvx }, - { MACH_MACIIVX, "IIvx", MACH_CLASSIIvx }, - { MACH_MACIIFX, "IIfx", MACH_CLASSIIfx }, - -/* The Centris/Quadra series. */ - { MACH_MACQ700, "Quadra 700", MACH_CLASSQ }, - { MACH_MACQ900, "Quadra 900", MACH_CLASSQ }, - { MACH_MACQ950, "Quadra 950", MACH_CLASSQ }, - { MACH_MACQ800, "Quadra 800", MACH_CLASSQ }, - { MACH_MACQ650, "Quadra 650", MACH_CLASSQ }, - { MACH_MACC650, "Centris 650", MACH_CLASSQ }, - { MACH_MACQ605, "Quadra 605", MACH_CLASSQ }, - { MACH_MACQ605_33, "Quadra 605/33", MACH_CLASSQ }, - { MACH_MACC610, "Centris 610", MACH_CLASSQ }, - { MACH_MACQ610, "Quadra 610", MACH_CLASSQ }, - { MACH_MACQ630, "Quadra 630", MACH_CLASSQ2 }, - { MACH_MACC660AV, "Centris 660AV", MACH_CLASSAV }, - { MACH_MACQ840AV, "Quadra 840AV", MACH_CLASSAV }, - -/* The Powerbooks/Duos... */ - { MACH_MACPB100, "PowerBook 100", MACH_CLASSPB }, - /* PB 100 has no MMU! */ - { MACH_MACPB140, "PowerBook 140", MACH_CLASSPB }, - { MACH_MACPB145, "PowerBook 145", MACH_CLASSPB }, - { MACH_MACPB150, "PowerBook 150", MACH_CLASSDUO }, - { MACH_MACPB160, "PowerBook 160", MACH_CLASSPB }, - { MACH_MACPB165, "PowerBook 165", MACH_CLASSPB }, - { MACH_MACPB165C, "PowerBook 165c", MACH_CLASSPB }, - { MACH_MACPB170, "PowerBook 170", MACH_CLASSPB }, - { MACH_MACPB180, "PowerBook 180", MACH_CLASSPB }, - { MACH_MACPB180C, "PowerBook 180c", MACH_CLASSPB }, - { MACH_MACPB190, "PowerBook 190", MACH_CLASSPB }, - { MACH_MACPB190CS, "PowerBook 190cs", MACH_CLASSPB }, - { MACH_MACPB500, "PowerBook 500", MACH_CLASSPB }, - -/* The Duos */ - { MACH_MACPB210, "PowerBook Duo 210", MACH_CLASSDUO }, - { MACH_MACPB230, "PowerBook Duo 230", MACH_CLASSDUO }, - { MACH_MACPB250, "PowerBook Duo 250", MACH_CLASSDUO }, - { MACH_MACPB270, "PowerBook Duo 270C", MACH_CLASSDUO }, - { MACH_MACPB280, "PowerBook Duo 280", MACH_CLASSDUO }, - { MACH_MACPB280C, "PowerBook Duo 280C", MACH_CLASSDUO }, - -/* The Performas... */ - { MACH_MACP600, "Performa 600", MACH_CLASSIIvx }, - { MACH_MACP460, "Performa 460", MACH_CLASSLC }, - { MACH_MACP550, "Performa 550", MACH_CLASSLC }, - { MACH_MACP580, "Performa 580", MACH_CLASSQ2 }, - { MACH_MACTV, "TV", MACH_CLASSLC }, - -/* The LCs... */ - { MACH_MACLCII, "LC II", MACH_CLASSLC }, - { MACH_MACLCIII, "LC III", MACH_CLASSLC }, - { MACH_MACLC475, "LC 475", MACH_CLASSQ }, - { MACH_MACLC475_33, "LC 475/33", MACH_CLASSQ }, - { MACH_MACLC520, "LC 520", MACH_CLASSLC }, - { MACH_MACLC575, "LC 575", MACH_CLASSQ2 }, - { MACH_MACCCLASSIC, "Color Classic", MACH_CLASSLC }, - { MACH_MACCCLASSICII, "Color ClassicII", MACH_CLASSLC }, -/* Does this belong here? */ - { MACH_MACCLASSICII, "Classic II", MACH_CLASSLC }, - -/* The unknown one and the end... */ - { 0, "Unknown", MACH_CLASSII } -}; /* End of cpu_models[] initialization. */ - -struct intvid_info_t { - int machineid; - u_long fbbase; - u_long fbmask; - u_long fblen; -} intvid_info[] = { - { MACH_MACCLASSICII, 0x009f9a80, 0x0, 21888 }, - { MACH_MACPB140, 0xfee08000, 0x0, 32 * 1024 }, - { MACH_MACPB145, 0xfee08000, 0x0, 32 * 1024 }, - { MACH_MACPB170, 0xfee08000, 0x0, 32 * 1024 }, - { MACH_MACPB150, 0x60000000, 0x0, 128 * 1024 }, - { MACH_MACPB160, 0x60000000, 0x0ffe0000, 128 * 1024 }, - { MACH_MACPB165, 0x60000000, 0x0ffe0000, 128 * 1024 }, - { MACH_MACPB180, 0x60000000, 0x0ffe0000, 128 * 1024 }, - { MACH_MACPB210, 0x60000000, 0x0, 128 * 1024 }, - { MACH_MACPB230, 0x60000000, 0x0, 128 * 1024 }, - { MACH_MACPB250, 0x60000000, 0x0, 128 * 1024 }, - { MACH_MACPB270, 0x60000000, 0x0, 128 * 1024 }, - { MACH_MACPB280, 0x60000000, 0x0, 128 * 1024 }, - { MACH_MACPB280C, 0x60000000, 0x0, 128 * 1024 }, - { MACH_MACIICI, 0x0, 0x0, 320 * 1024 }, - { MACH_MACIISI, 0x0, 0x0, 320 * 1024 }, - { MACH_MACCCLASSIC, 0x50f40000, 0x0, 512 * 1024 }, -/*??*/ { MACH_MACLCII, 0x50f40000, 0x0, 512 * 1024 }, - { MACH_MACPB165C, 0xfc040000, 0x0, 512 * 1024 }, - { MACH_MACPB180C, 0xfc040000, 0x0, 512 * 1024 }, - { MACH_MACPB190, 0x60000000, 0x0, 512 * 1024 }, - { MACH_MACPB190CS, 0x60000000, 0x0, 512 * 1024 }, - { MACH_MACPB500, 0x60000000, 0x0, 512 * 1024 }, - { MACH_MACLCIII, 0x60b00000, 0x0, 768 * 1024 }, - { MACH_MACLC520, 0x60000000, 0x0, 1024 * 1024 }, - { MACH_MACP550, 0x60000000, 0x0, 1024 * 1024 }, - { MACH_MACTV, 0x60000000, 0x0, 1024 * 1024 }, - { MACH_MACLC475, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACLC475_33, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACLC575, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACC610, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACC650, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACP580, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACQ605, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACQ605_33, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACQ610, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACQ630, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACQ650, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACC660AV, 0x50100000, 0x0, 1024 * 1024 }, - { MACH_MACQ700, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACQ800, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACQ900, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACQ950, 0xf9000000, 0x0, 1024 * 1024 }, - { MACH_MACQ840AV, 0x50100000, 0x0, 2048 * 1024 }, - { 0, 0x0, 0x0, 0 }, -}; /* End of intvid_info[] initialization. */ - -/* - * Missing Mac Models: - * PowerMac 6100 - * PowerMac 7100 - * PowerMac 8100 - * PowerBook 540 - * PowerBook 520 - * PowerBook 150 - * Duo 280 - * Performa 6000s - * ...? - */ - -char cpu_model[120]; /* for sysctl() */ - -int -fpu_probe() -{ - /* - * A 68881 idle frame is 28 bytes and a 68882's is 60 bytes. - * We, of course, need to have enough room for either. - */ - int fpframe[60 / sizeof(int)]; - label_t faultbuf; - u_char b; - - nofault = (int *) &faultbuf; - if (setjmp(&faultbuf)) { - nofault = (int *) 0; - return (FPU_NONE); - } - - /* - * Synchronize FPU or cause a fault. - * This should leave the 881/882 in the IDLE state, - * state, so we can determine which we have by - * examining the size of the FP state frame - */ - asm("fnop"); - - nofault = (int *) 0; - - /* - * Presumably, if we're an 040 and did not take exception - * above, we have an FPU. Don't bother probing. - */ - if (mmutype == MMU_68040) - return (FPU_68040); - - /* - * Presumably, this will not cause a fault--the fnop should - * have if this will. We save the state in order to get the - * size of the frame. - */ - asm("movl %0, a0; fsave a0@" : : "a" (fpframe) : "a0" ); - - b = *((u_char *) fpframe + 1); - - /* - * Now, restore a NULL state to reset the FPU. - */ - fpframe[0] = fpframe[1] = 0; - m68881_restore((struct fpframe *) fpframe); - - /* - * The size of a 68881 IDLE frame is 0x18 - * and a 68882 frame is 0x38 - */ - if (b == 0x18) - return (FPU_68881); - if (b == 0x38) - return (FPU_68882); - - /* - * If it's not one of the above, we have no clue what it is. - */ - return (FPU_UNKNOWN); -} - -void -identifycpu() -{ -#ifdef DEBUG - extern u_int delay_factor; -#endif - - /* - * Print the machine type... - */ - snprintf(cpu_model, sizeof cpu_model, "Apple Macintosh %s", - cpu_models[mac68k_machine.cpu_model_index].model); - - /* - * ... and the CPU type... - */ - switch (cputype) { - case CPU_68040: - strlcat(cpu_model, ", 68040 CPU", sizeof cpu_model); - break; - case CPU_68030: - strlcat(cpu_model, ", 68030 CPU", sizeof cpu_model); - break; - case CPU_68020: - strlcat(cpu_model, ", 68020 CPU", sizeof cpu_model); - break; - default: - strlcat(cpu_model, ", unknown CPU", sizeof cpu_model); - break; - } - - /* - * ... and the MMU type... - */ - switch (mmutype) { - case MMU_68040: - case MMU_68030: - strlcat(cpu_model, "+MMU", sizeof cpu_model); - break; - case MMU_68851: - strlcat(cpu_model, ", MC68851 MMU", sizeof cpu_model); - break; - default: - printf("%s\n", cpu_model); - panic("unknown MMU type %d", mmutype); - /* NOTREACHED */ - } - - /* - * ... and the FPU type... - */ - fputype = fpu_probe(); /* should eventually move to locore */ - - switch (fputype) { - case FPU_68040: - strlcat(cpu_model, "+FPU", sizeof cpu_model); - break; - case FPU_68882: - strlcat(cpu_model, ", MC6882 FPU", sizeof cpu_model); - break; - case FPU_68881: - strlcat(cpu_model, ", MC6881 FPU", sizeof cpu_model); - break; - case FPU_UNKNOWN: - strlcat(cpu_model, ", unknown FPU", sizeof cpu_model); - break; - default: - /*strlcat(cpu_model, ", no FPU", sizeof cpu_model);*/ - break; - } - - /* - * ... and finally, the cache type. - */ - if (cputype == CPU_68040) - strlcat(cpu_model, ", 4k on-chip physical I/D caches", sizeof cpu_model); - - printf("%s\n", cpu_model); -#ifdef DEBUG - printf("cpu: delay factor %d\n", delay_factor); -#endif -} - -void get_machine_info(void); - -void -get_machine_info() -{ - int i; - - for (i = 0; cpu_models[i].machineid != 0; i++) - if (mac68k_machine.machineid == cpu_models[i].machineid) - break; - - mac68k_machine.cpu_model_index = i; -} - -const struct cpu_model_info *current_mac_model; - -/* - * Sets a bunch of machine-specific variables - */ -void setmachdep(void); - -void -setmachdep() -{ - struct cpu_model_info *cpui; - - /* - * First, set things that need to be set on the first pass only - * Ideally, we'd only call this once, but for some reason, the - * VIAs need interrupts turned off twice !? - */ - get_machine_info(); - - load_addr = 0; - cpui = &(cpu_models[mac68k_machine.cpu_model_index]); - current_mac_model = cpui; - - mac68k_machine.via1_ipl = 1; - mac68k_machine.aux_interrupts = 0; - - /* - * Set up any machine specific stuff that we have to before - * ANYTHING else happens - */ - switch (cpui->class) { /* Base this on class of machine... */ - case MACH_CLASSII: - VIA2 = VIA2OFF; - IOBase = 0x50f00000; - Via1Base = (volatile u_char *)IOBase; - mac68k_machine.scsi80 = 1; - via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ - via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */ - break; - case MACH_CLASSPB: - VIA2 = VIA2OFF; - IOBase = 0x50f00000; - Via1Base = (volatile u_char *)IOBase; - mac68k_machine.scsi80 = 1; - /* Disable everything but PM; we need it. */ - via_reg(VIA1, vIER) = 0x6f; /* disable VIA1 int */ - /* Are we disabling something important? */ - via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */ - if (cputype == CPU_68040) - mac68k_machine.sonic = 1; - break; - case MACH_CLASSDUO: - /* - * The Duo definitely does not use a VIA2, but it looks - * like the VIA2 functions might be on the MSC at the RBV - * locations. The rest is copied from the Powerbooks. - */ - VIA2 = RBVOFF; - IOBase = 0x50f00000; - Via1Base = (volatile u_char *)IOBase; - mac68k_machine.scsi80 = 1; - /* Disable everything but PM; we need it. */ - via_reg(VIA1, vIER) = 0x6f; /* disable VIA1 int */ - /* Are we disabling something important? */ - via_reg(VIA2, rIER) = 0x7f; /* disable VIA2 int */ - break; - case MACH_CLASSQ: - case MACH_CLASSQ2: - VIA2 = VIA2OFF; - IOBase = 0x50f00000; - Via1Base = (volatile u_char *)IOBase; - mac68k_machine.sonic = 1; - mac68k_machine.scsi96 = 1; - via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ - via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */ - - /* Enable A/UX interrupt scheme */ - mac68k_machine.aux_interrupts = 1; - via_reg(VIA1, vBufB) &= (0xff ^ DB1O_AuxIntEnb); - via_reg(VIA1, vDirB) |= DB1O_AuxIntEnb; - mac68k_machine.via1_ipl = 6; - - break; - case MACH_CLASSAV: - VIA2 = VIA2OFF; - IOBase = 0x50f00000; - Via1Base = (volatile u_char *)IOBase; - mac68k_machine.scsi96 = 1; - via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ - via_reg(VIA2, vIER) = 0x7f; /* disable VIA2 int */ - break; - case MACH_CLASSIIci: - VIA2 = RBVOFF; - IOBase = 0x50f00000; - Via1Base = (volatile u_char *)IOBase; - mac68k_machine.scsi80 = 1; - via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ - via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */ - break; - case MACH_CLASSIIsi: - VIA2 = RBVOFF; - IOBase = 0x50f00000; - Via1Base = (volatile u_char *)IOBase; - mac68k_machine.scsi80 = 1; - via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ - via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */ - break; - case MACH_CLASSIIvx: - VIA2 = RBVOFF; - IOBase = 0x50f00000; - Via1Base = (volatile u_char *)IOBase; - mac68k_machine.scsi80 = 1; - via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ - via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */ - break; - case MACH_CLASSLC: - VIA2 = RBVOFF; - IOBase = 0x50f00000; - Via1Base = (volatile u_char *)IOBase; - mac68k_machine.scsi80 = 1; - via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ - via_reg(VIA2, rIER) = 0x7f; /* disable RBV int */ - break; - case MACH_CLASSIIfx: - VIA2 = OSSOFF; - IOBase = 0x50f00000; - Via1Base = (volatile u_char *)IOBase; - mac68k_machine.scsi80 = 1; - via_reg(VIA1, vIER) = 0x7f; /* disable VIA1 int */ - break; - default: - case MACH_CLASSH: - break; - } -} - -/* - * Set IO offsets. - */ -void -mac68k_set_io_offsets(base) - vaddr_t base; -{ - extern volatile u_char *sccA; - - switch (current_mac_model->class) { - case MACH_CLASSQ: - Via1Base = (volatile u_char *)base; - - /* The following two may be overridden. */ - sccA = (volatile u_char *)base + 0xc000; - SCSIBase = base + 0xf000; - - switch (current_mac_model->machineid) { - case MACH_MACQ900: - case MACH_MACQ950: - sccA = (volatile u_char *)base + 0xc020; - iop_serial_compatible(); - mac68k_machine.scsi96_2 = 1; - break; - case MACH_MACQ700: - break; - default: - SCSIBase = base + 0x10000; - break; - } - break; - case MACH_CLASSQ2: - /* - * Note the different offset for sccA for this class of - * machines. This seems to be common on many of the - * Quadra-type machines. - */ - Via1Base = (volatile u_char *)base; - sccA = (volatile u_char *)base + 0xc020; - SCSIBase = base + 0x10000; - break; - case MACH_CLASSAV: - Via1Base = (volatile u_char *)base; - sccA = (volatile u_char *)base + 0x4000; - SCSIBase = base + 0x18000; - PSCBase = (volatile u_char *)base + 0x31000; - break; - case MACH_CLASSII: - case MACH_CLASSPB: - case MACH_CLASSDUO: - case MACH_CLASSIIci: - case MACH_CLASSIIsi: - case MACH_CLASSIIvx: - case MACH_CLASSLC: - Via1Base = (volatile u_char *)base; - sccA = (volatile u_char *)base + 0x4000; - SCSIBase = base; - break; - case MACH_CLASSIIfx: - Via1Base = (volatile u_char *)base; - sccA = (volatile u_char *)base + 0x4020; - iop_serial_compatible(); - SCSIBase = base; - break; - default: - case MACH_CLASSH: - panic("Unknown/unsupported machine class (%d).", - current_mac_model->class); - break; - } - - Via2Base = Via1Base + 0x2000 * VIA2; -} - -#if GRAYBARS -u_long gray_nextaddr = 0; - -void -gray_bar() -{ - static int i = 0; - static int flag = 0; - -/* MF basic premise as I see it: - 1) Save the scratch regs as they are not saved by the compilier. - 2) Check to see if we want gray bars, if so, - display some lines of gray, - a couple of lines of white(about 8), - and loop to slow this down. - 3) restore regs -*/ - - __asm __volatile (" movl a0,sp@-; - movl a1,sp@-; - movl d0,sp@-; - movl d1,sp@-"); - -/* check to see if gray bars are turned off */ - if (mac68k_machine.do_graybars) { - /* MF the 10*rowbytes/4 is done lots, but we want this to be - * slow */ - for (i = 0; i < 10 * videorowbytes / 4; i++) - ((u_long *)videoaddr)[gray_nextaddr++] = 0xaaaaaaaa; - for (i = 0; i < 2 * videorowbytes / 4; i++) - ((u_long *)videoaddr)[gray_nextaddr++] = 0x00000000; - } - - __asm __volatile (" movl sp@+,d1; - movl sp@+,d0; - movl sp@+,a1; - movl sp@+,a0"); -} -#endif - -/* in locore */ -extern u_long ptest040(caddr_t addr, u_int fc); -extern int get_pte(u_int addr, u_long pte[2], u_short * psr); - -/* - * LAK (7/24/94): given a logical address, puts the physical address - * in *phys and return 1, or returns 0 on failure. This is intended - * to look through MacOS page tables. - */ - -u_long -get_physical(u_int addr, u_long * phys) -{ - extern u_int macos_tc; - u_long pte[2], ph, mask; - u_short psr; - int i, numbits; - - if (mmutype == MMU_68040) { - ph = ptest040((caddr_t)addr, FC_SUPERD); - if ((ph & MMU40_RES) == 0) { - ph = ptest040((caddr_t)addr, FC_USERD); - if ((ph & MMU40_RES) == 0) - return 0; - } - if ((ph & MMU40_TTR) != 0) - ph = addr; - - mask = (macos_tc & 0x4000) ? 0x00001fff : 0x00000fff; - ph &= (~mask); - } else { - i = get_pte(addr, pte, &psr); - - switch (i) { - case -1: - return 0; - case 0: - ph = pte[0] & 0xFFFFFF00; - break; - case 1: - ph = pte[1] & 0xFFFFFF00; - break; - default: - panic("get_physical(): bad get_pte()"); - } - - /* - * We must now figure out how many levels down we went and - * mask the bits appropriately -- the returned value may only - * be the upper n bits, and we have to take the rest from addr. - */ - numbits = 0; - psr &= 0x0007; /* Number of levels we went */ - for (i = 0; i < psr; i++) - numbits += (macos_tc >> (12 - i * 4)) & 0x0f; - - /* - * We have to take the most significant "numbits" from - * the returned value "ph", and the rest from our addr. - * Assume that numbits != 0. - */ - mask = (1 << (32 - numbits)) - 1; - } - *phys = ph + (addr & mask); - - return 1; -} - -void check_video(char *, u_long, u_long); - -void -check_video(id, limit, maxm) - char *id; - u_long limit, maxm; -{ - u_long addr, phys; - - if (!get_physical(videoaddr, &phys)) { - if (mac68k_machine.do_graybars) - printf("get_mapping(): %s. False start.\n", id); - } else { - mac68k_vidlog = videoaddr; - mac68k_vidphys = phys; - mac68k_vidlen = 32768; - addr = videoaddr + 32768; - while (get_physical(addr, &phys)) { - if ((phys - mac68k_vidphys) != mac68k_vidlen) - break; - if (mac68k_vidlen + 32768 > limit) { - if (mac68k_machine.do_graybars) { - printf("mapping: %s. Does it never end?\n", - id); - printf(" Forcing VRAM size "); - printf("to a conservative %ldK.\n", - maxm/1024); - } - mac68k_vidlen = maxm; - break; - } - mac68k_vidlen += 32768; - addr += 32768; - } - if (mac68k_machine.do_graybars) { - printf(" %s internal video at paddr 0x%x, len 0x%x.\n", - id, mac68k_vidphys, mac68k_vidlen); - } - } -} - -/* - * Find out how MacOS has mapped itself so we can do the same thing. - * Returns the address of logical 0 so that locore can map the kernel - * properly. - */ -u_int -get_mapping(void) -{ - struct intvid_info_t *iip; - u_long addr, lastpage, phys, len, limit; - int i, last, same; - - numranges = 0; - for (i = 0; i < NBMEMRANGES; i++) { - low[i] = 0; - high[i] = 0; - } - - lastpage = get_top_of_ram(); - - get_physical(0, &load_addr); - - last = 0; - for (addr = 0; addr <= lastpage && get_physical(addr, &phys); - addr += PAGE_SIZE) { - if (numranges > 0 && phys != high[last]) { - /* - * Attempt to find if this page is already - * accounted for in an existing physical segment. - */ - for (i = 0; i < numranges; i++) { - if (low[i] <= phys && phys <= high[i]) { - last = i; - break; - } - } - if (i >= numranges) - last = numranges - 1; - - if (low[last] <= phys && phys < high[last]) - continue; /* Skip pages we've seen. */ - } - - if (numranges > 0 && phys == high[last]) { - /* Common case: extend existing segment on high end */ - high[last] += PAGE_SIZE; - } else if (numranges < NBMEMRANGES - 1) { - /* This is a new physical segment. */ - for (last = 0; last < numranges; last++) - if (phys < low[last]) - break; - - /* Create space for segment, if necessary */ - if (last < numranges && phys < low[last]) { - for (i = numranges; i > last; i--) { - low[i] = low[i - 1]; - high[i] = high[i - 1]; - } - } - - numranges++; - low[last] = phys; - high[last] = phys + PAGE_SIZE; - } else { - /* Not enough ranges. Display a warning message? */ - continue; - } - - /* Coalesce adjoining segments as appropriate */ - if (last < (numranges - 1) && high[last] == low[last + 1] && - low[last + 1] != load_addr) { - high[last] = high[last + 1]; - for (i = last + 1; i < numranges; i++) { - low[i] = low[i + 1]; - high[i] = high[i + 1]; - } - --numranges; - } - } - if (mac68k_machine.do_graybars) { - printf("System RAM: %ld bytes in %ld pages.\n", - addr, addr / PAGE_SIZE); - for (i = 0; i < numranges; i++) { - printf(" Low = 0x%lx, high = 0x%lx\n", - low[i], high[i]); - } - } - - /* - * If we can't figure out the PA of the frame buffer by groveling - * the page tables, assume that we already have the correct - * address. This is the case on several of the PowerBook 1xx - * series, in particular. - */ - if (!get_physical(videoaddr, &phys)) - phys = videoaddr; - - /* - * Find on-board video, if we have an idea of where to look - * on this system. - */ - for (iip = intvid_info; iip->machineid != 0; iip++) - if (mac68k_machine.machineid == iip->machineid) - break; - - if (mac68k_machine.machineid == iip->machineid && - (phys & ~iip->fbmask) >= iip->fbbase && - (phys & ~iip->fbmask) < (iip->fbbase + iip->fblen)) { - mac68k_vidphys = phys & ~iip->fbmask; - mac68k_vidlen = 32768 - (phys & 0x7fff); - - limit = iip->fbbase + iip->fblen - mac68k_vidphys; - if (mac68k_vidlen > limit) { - mac68k_vidlen = limit; - } else { - addr = videoaddr + mac68k_vidlen; - while (get_physical(addr, &phys)) { - if ((phys - mac68k_vidphys) != mac68k_vidlen) - break; - if (mac68k_vidlen + 32768 > limit) { - mac68k_vidlen = limit; - break; - } - mac68k_vidlen += 32768; - addr += 32768; - } - } - } - - if (mac68k_vidlen > 0) { - /* - * We've already figured out where internal video is. - * Tell the user what we know. - */ - if (mac68k_machine.do_graybars) - printf("On-board video at addr 0x%lx (phys 0x%x), len 0x%x.\n", - videoaddr, mac68k_vidphys, mac68k_vidlen); - } else { - /* - * We should now look through all of NuBus space to find where - * the internal video is being mapped. Just to be sure we - * handle all the cases, we simply map our NuBus space exactly - * how MacOS did it. As above, we find a bunch of ranges that - * are contiguously mapped. Since there are a lot of pages - * that are all mapped to 0, we handle that as a special case - * where the length is negative. We search in increments of - * 32768 because that's the page size that MacOS uses. - */ - nbnumranges = 0; - for (i = 0; i < NBMAXRANGES; i++) { - nbphys[i] = 0; - nblog[i] = 0; - nblen[i] = 0; - } - - same = 0; - for (addr = NBBASE; addr < NBTOP; addr += 32768) { - if (!get_physical(addr, &phys)) { - continue; - } - len = nbnumranges == 0 ? 0 : nblen[nbnumranges - 1]; - -#if DEBUG - if (mac68k_machine.do_graybars) - printf ("0x%lx --> 0x%lx\n", addr, phys); -#endif - if (nbnumranges > 0 - && addr == nblog[nbnumranges - 1] + len - && phys == nbphys[nbnumranges - 1]) { - /* Same as last one */ - nblen[nbnumranges - 1] += 32768; - same = 1; - } else { - if ((nbnumranges > 0) - && !same - && (addr == nblog[nbnumranges - 1] + len) - && (phys == nbphys[nbnumranges - 1] + len)) - nblen[nbnumranges - 1] += 32768; - else { - if (same) { - nblen[nbnumranges - 1] = -len; - same = 0; - } - if (nbnumranges == NBMAXRANGES) { - if (mac68k_machine.do_graybars) - printf("get_mapping(): " - "Too many NuBus ranges.\n"); - break; - } - nbnumranges++; - nblog[nbnumranges - 1] = addr; - nbphys[nbnumranges - 1] = phys; - nblen[nbnumranges - 1] = 32768; - } - } - } - if (same) { - nblen[nbnumranges - 1] = -nblen[nbnumranges - 1]; - same = 0; - } - if (mac68k_machine.do_graybars) { - printf("Non-system RAM (nubus, etc.):\n"); - for (i = 0; i < nbnumranges; i++) { - printf(" Log = 0x%lx, Phys = 0x%lx, Len = 0x%lx (%lu)\n", - nblog[i], nbphys[i], nblen[i], nblen[i]); - } - } - - /* - * We must now find the logical address of internal video in the - * ranges we made above. Internal video is at physical 0, but - * a lot of pages map there. Instead, we look for the logical - * page that maps to 32768 and go back one page. - */ - for (i = 0; i < nbnumranges; i++) { - if (nblen[i] > 0 - && nbphys[i] <= 32768 - && 32768 <= nbphys[i] + nblen[i]) { - mac68k_vidlog = nblog[i] - nbphys[i]; - mac68k_vidlen = nblen[i] + nbphys[i]; - mac68k_vidphys = 0; - break; - } - } - if (i == nbnumranges) { - if (0x60000000 <= videoaddr && videoaddr < 0x70000000) { - if (mac68k_machine.do_graybars) - printf("Checking for Internal Video "); - /* - * Kludge for IIvx internal video (60b0 0000). - * PB 520 (6000 0000) - */ - check_video("PB/IIvx (0x60?00000)", - 1 * 1024 * 1024, 1 * 1024 * 1024); - } else if (0x50F40000 <= videoaddr - && videoaddr < 0x50FBFFFF) { - /* - * Kludge for LC internal video - */ - check_video("LC video (0x50f40000)", - 512 * 1024, 512 * 1024); - } else if (0x50100100 <= videoaddr - && videoaddr < 0x50400000) { - /* - * Kludge for AV internal video - */ - check_video("AV video (0x50100100)", - 1 * 1024 * 1024, 1 * 1024 * 1024); - } else { - if (mac68k_machine.do_graybars) - printf( " no internal video at address 0 -- " - "videoaddr is 0x%lx.\n", videoaddr); - } - } else { - if (mac68k_machine.do_graybars) { - printf(" Video address = 0x%lx\n", videoaddr); - printf(" Int video starts at 0x%x\n", - mac68k_vidlog); - printf(" Length = 0x%x (%d) bytes\n", - mac68k_vidlen, mac68k_vidlen); - } - } - } - - return load_addr; /* Return physical address of logical 0 */ -} - -#ifdef DEBUG -/* - * Debugging code for locore page-traversal routine. - */ -void printstar(void); -void -printstar(void) -{ - /* - * Be careful as we assume that no registers are clobbered - * when we call this from assembly. - */ - __asm __volatile (" movl a0,sp@-; - movl a1,sp@-; - movl d0,sp@-; - movl d1,sp@-"); - - /* printf("*"); */ - - __asm __volatile (" movl sp@+,d1; - movl sp@+,d0; - movl sp@+,a1; - movl sp@+,a0"); -} -#endif - -/* - * Console bell callback; modularizes the console terminal emulator - * and the audio system, so neither requires direct knowledge of the - * other. - */ - -void -mac68k_set_bell_callback(callback, cookie) - int (*callback)(void *, int, int, int); - void *cookie; -{ - mac68k_bell_callback = callback; - mac68k_bell_cookie = (caddr_t)cookie; -} - -int -mac68k_ring_bell(freq, length, volume) - int freq, length, volume; -{ - if (mac68k_bell_callback) - return ((*mac68k_bell_callback)(mac68k_bell_cookie, - freq, length, volume)); - else - return (ENXIO); -} diff --git a/sys/arch/mac68k/mac68k/mainbus.c b/sys/arch/mac68k/mac68k/mainbus.c deleted file mode 100644 index cc46bb457bb..00000000000 --- a/sys/arch/mac68k/mac68k/mainbus.c +++ /dev/null @@ -1,87 +0,0 @@ -/* $OpenBSD: mainbus.c,v 1.8 2008/06/26 05:42:12 ray Exp $ */ -/* $NetBSD: mainbus.c,v 1.7 1996/12/17 06:47:41 scottr 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. - * - * 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. - */ - -#include <sys/param.h> -#include <sys/device.h> -#include <sys/systm.h> - -static int mainbus_match(struct device *, void *, void *); -static void mainbus_attach(struct device *, struct device *, void *); -static int mainbus_search(struct device *, void *, void *); - -struct cfattach mainbus_ca = { - sizeof(struct device), mainbus_match, mainbus_attach -}; - -struct cfdriver mainbus_cd = { - NULL, "mainbus", DV_DULL -}; - -static int -mainbus_match(parent, vcf, aux) - struct device *parent; - void *vcf; - void *aux; -{ - static int mainbus_matched = 0; - - /* Allow only one instance. */ - if (mainbus_matched) - return (0); - - mainbus_matched = 1; - return 1; -} - -static void -mainbus_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - printf("\n"); - - /* Search for and attach children. */ - config_search(mainbus_search, self, NULL); -} - -static int -mainbus_search(parent, vcf, aux) - struct device *parent; - void *vcf; - void *aux; -{ - struct cfdata *cf = (struct cfdata *) vcf; - - if ((*cf->cf_attach->ca_match)(parent, cf, NULL) > 0) - config_attach(parent, cf, NULL, NULL); - return 0; -} diff --git a/sys/arch/mac68k/mac68k/mem.c b/sys/arch/mac68k/mac68k/mem.c deleted file mode 100644 index 41d54f2a2ed..00000000000 --- a/sys/arch/mac68k/mac68k/mem.c +++ /dev/null @@ -1,243 +0,0 @@ -/* $OpenBSD: mem.c,v 1.22 2010/12/26 15:40:59 miod Exp $ */ -/* $NetBSD: mem.c,v 1.22 1999/03/27 00:30:07 mycroft Exp $ */ - -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1986, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)mem.c 8.3 (Berkeley) 1/12/94 - */ - -/* - * Memory special file - */ - -#include <sys/param.h> -#include <sys/conf.h> -#include <sys/buf.h> -#include <sys/proc.h> -#include <sys/systm.h> -#include <sys/uio.h> -#include <sys/malloc.h> - -#include <machine/cpu.h> - -#include <uvm/uvm_extern.h> - -extern u_long maxaddr; - -static caddr_t devzeropage; - -#define mmread mmrw -#define mmwrite mmrw -cdev_decl(mm); - -/*ARGSUSED*/ -int -mmopen(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; -{ - - switch (minor(dev)) { - case 0: - case 1: - case 2: - case 12: - return (0); - default: - return (ENXIO); - } -} - -/*ARGSUSED*/ -int -mmclose(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; -{ - - return (0); -} - -/*ARGSUSED*/ -int -mmrw(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; -{ - vaddr_t o, v; - int c; - struct iovec *iov; - int error = 0; - static int physlock; - vm_prot_t prot; - - if (minor(dev) == 0) { - /* lock against other uses of shared vmmap */ - while (physlock > 0) { - physlock++; - error = tsleep((caddr_t)&physlock, PZERO | PCATCH, - "mmrw", 0); - if (error) - return (error); - } - physlock = 1; - } - while (uio->uio_resid > 0 && error == 0) { - iov = uio->uio_iov; - if (iov->iov_len == 0) { - uio->uio_iov++; - uio->uio_iovcnt--; - if (uio->uio_iovcnt < 0) - panic("mmrw"); - continue; - } - switch (minor(dev)) { - -/* minor device 0 is physical memory */ - case 0: - v = uio->uio_offset; - - /* - * Only allow reads in physical RAM. - */ - if (v >= maxaddr || v < 0) { - error = EFAULT; - goto unlock; - } - - prot = uio->uio_rw == UIO_READ ? VM_PROT_READ : - VM_PROT_WRITE; - pmap_enter(pmap_kernel(), (vaddr_t)vmmap, - trunc_page(v), prot, prot|PMAP_WIRED); - pmap_update(pmap_kernel()); - o = m68k_page_offset(uio->uio_offset); - c = min(uio->uio_resid, (int)(NBPG - o)); - error = uiomove((caddr_t)vmmap + o, c, uio); - pmap_remove(pmap_kernel(), (vaddr_t)vmmap, - (vaddr_t)vmmap + NBPG); - pmap_update(pmap_kernel()); - continue; - -/* minor device 1 is kernel memory */ - case 1: - v = uio->uio_offset; - c = min(iov->iov_len, MAXPHYS); - if (!uvm_kernacc((caddr_t)v, c, - uio->uio_rw == UIO_READ ? B_READ : B_WRITE)) - return (EFAULT); - error = uiomove((caddr_t)v, c, uio); - continue; - -/* minor device 2 is EOF/RATHOLE */ - case 2: - if (uio->uio_rw == UIO_WRITE) - uio->uio_resid = 0; - return (0); - -/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */ - case 12: - if (uio->uio_rw == UIO_WRITE) { - c = iov->iov_len; - break; - } - - /* - * On the first call, allocate and zero a page - * of memory for use with /dev/zero. - */ - if (devzeropage == NULL) - devzeropage = malloc(PAGE_SIZE, M_TEMP, - M_WAITOK | M_ZERO); - c = min(iov->iov_len, PAGE_SIZE); - error = uiomove(devzeropage, c, uio); - continue; - - default: - return (ENXIO); - } - if (error) - break; - iov->iov_base = (caddr_t)iov->iov_base + c; - iov->iov_len -= c; - uio->uio_offset += c; - uio->uio_resid -= c; - } - if (minor(dev) == 0) { -unlock: - if (physlock > 1) - wakeup((caddr_t)&physlock); - physlock = 0; - } - return (error); -} - -paddr_t -mmmmap(dev, off, prot) - dev_t dev; - off_t off; - int prot; -{ - /* - * /dev/mem is the only one that makes sense through this - * interface. For /dev/kmem any physaddr we return here - * could be transient and hence incorrect or invalid at - * a later time. /dev/null just doesn't make any sense - * and /dev/zero is a hack that is handled via the default - * pager in mmap(). - */ - if (minor(dev) != 0) - return (-1); - - /* - * Only allow access to physical RAM. - */ - if ((u_int)off >= maxaddr) - return (-1); - - return ((paddr_t)off); -} - -int -mmioctl(dev, cmd, data, flags, p) - dev_t dev; - u_long cmd; - caddr_t data; - int flags; - struct proc *p; -{ - return (EOPNOTSUPP); -} diff --git a/sys/arch/mac68k/mac68k/pmap_bootstrap.c b/sys/arch/mac68k/mac68k/pmap_bootstrap.c deleted file mode 100644 index a1b722f9e59..00000000000 --- a/sys/arch/mac68k/mac68k/pmap_bootstrap.c +++ /dev/null @@ -1,251 +0,0 @@ -/* $OpenBSD: pmap_bootstrap.c,v 1.43 2010/11/20 20:33:24 miod Exp $ */ -/* $NetBSD: pmap_bootstrap.c,v 1.50 1999/04/07 06:14:33 scottr Exp $ */ - -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)pmap_bootstrap.c 8.1 (Berkeley) 6/10/93 - */ - -#include <sys/param.h> -#include <sys/msgbuf.h> -#include <sys/reboot.h> -#include <sys/systm.h> - -#include <uvm/uvm_extern.h> -#include <uvm/uvm_km.h> - -#include <machine/autoconf.h> -#include <machine/cpu.h> -#include <machine/frame.h> -#include <machine/pmap.h> -#include <machine/pte.h> -#include <machine/vmparam.h> - -#include "zsc.h" - -#if NZSC > 0 -extern int zsinited; -#endif - -/* - * These are used to map the RAM: - */ -int numranges; /* = 0 == don't use the ranges */ -u_long low[8]; -u_long high[8]; -u_long maxaddr; /* PA of the last physical page */ -int vidlen; -#define VIDMAPSIZE atop(vidlen) -extern u_int32_t mac68k_vidphys; -extern u_int32_t videoaddr; -extern u_int32_t videorowbytes; -extern u_int32_t videosize; -static u_int32_t newvideoaddr; - -void bootstrap_mac68k(int); - -/* - * pmap_bootstrap() is very tricky on mac68k because it can be called - * with the MMU either on or off. If it's on, we assume that it's mapped - * with the same PA <=> LA mapping that we eventually want. - * The page sizes and the protections will be wrong, anyway. - * - * nextpa is the first address following the loaded kernel. On a IIsi - * on 12 May 1996, that was 0xf9000 beyond firstpa. - */ - -#define RELOC(v, t) *((t*)((u_int)&(v))) -#define PA2VA(v, t) *((t*)((u_int)&(v) - firstpa)) - -/* - * Present a totally tricky view of the world here... - * - count video mappings in the internal IO space (which will - * require some contortion later on) - * - no external IO space - */ -#define MACHINE_IIOMAPSIZE (IIOMAPSIZE + VIDMAPSIZE) -#define MACHINE_INTIOBASE IOBase -#define MACHINE_EIOMAPSIZE 0 - - /* vidpa internal video space for some machines - * PT pages VIDMAPSIZE pages - * - * XXX note that VIDMAPSIZE, hence vidlen, is needed very early - * in pmap_bootstrap(), so slightly abuse the purpose of - * PMAP_MD_LOCALS here... - */ -#define PMAP_MD_LOCALS \ - paddr_t vidpa; \ - int i; \ - \ - vidlen = round_page(((videosize >> 16) & 0xffff) * videorowbytes + \ - m68k_page_offset(mac68k_vidphys)); - -#define PMAP_MD_RELOC1() \ -do { \ - vidpa = eiopa - VIDMAPSIZE * sizeof(pt_entry_t); \ -} while (0) - - /* - * Validate the internal IO space, ROM space, and - * framebuffer PTEs (RW+CI). - * - * Note that this is done after the fake IIO space has been - * validated, hence the rom and video pte were already written to - * with incorrect values. - */ -#define PMAP_MD_MAPIOSPACE() \ -do { \ - if (vidlen != 0) { \ - pte = PA2VA(vidpa, u_int *); \ - epte = pte + VIDMAPSIZE; \ - protopte = trunc_page(mac68k_vidphys) | \ - PG_RW | PG_V | PG_CI; \ - while (pte < epte) { \ - *pte++ = protopte; \ - protopte += NBPG; \ - } \ - } \ -} while (0) - -#define PMAP_MD_RELOC2() \ -do { \ - IOBase = iiobase; \ - if (vidlen != 0) { \ - newvideoaddr = iiobase + ptoa(IIOMAPSIZE) \ - + m68k_page_offset(mac68k_vidphys); \ - } \ -} while (0) - -/* - * Compute memory size from the memory segment information. - */ -#define PMAP_MD_MEMSIZE() \ -do { \ - physmem = 0; \ - for (i = 0; i < numranges; i++) \ - physmem += atop(high[i] - low[i]); \ - /* reserve one page for the message buffer */ \ - maxaddr = high[numranges - 1] - PAGE_SIZE; \ - high[numranges - 1] -= round_page(MSGBUFSIZE); \ -} while (0) - -#define PMAP_MD_RELOC3() /* nothing */ - -#include <m68k/m68k/pmap_bootstrap.c> - -void -bootstrap_mac68k(tc) - int tc; -{ -#if NZSC > 0 - extern void zs_init(void); -#endif - extern caddr_t esym; - paddr_t nextpa; - - if (mac68k_machine.do_graybars) - printf("Bootstrapping OpenBSD/mac68k.\n"); - - mac68k_vidphys = videoaddr; - - if (((tc & 0x80000000) && (mmutype == MMU_68030)) || - ((tc & 0x8000) && (mmutype == MMU_68040))) { - - if (mac68k_machine.do_graybars) - printf("Getting mapping from MMU.\n"); - (void) get_mapping(); - if (mac68k_machine.do_graybars) - printf("Done.\n"); - } else { - /* MMU not enabled. Fake up ranges. */ - numranges = 1; - low[0] = 0; - high[0] = mac68k_machine.mach_memsize * (1024 * 1024); - if (mac68k_machine.do_graybars) - printf("Faked range to byte 0x%lx.\n", high[0]); - } - nextpa = load_addr + round_page((vaddr_t)esym); - - if (mac68k_machine.do_graybars) - printf("Bootstrapping the pmap system.\n"); - - pmap_bootstrap(nextpa, load_addr); - - if (mac68k_machine.do_graybars) - printf("Pmap bootstrapped.\n"); - - if (!vidlen) - panic("Don't know how to relocate video!"); - - if (mac68k_machine.do_graybars) - printf("Video address 0x%lx -> 0x%lx.\n", - (unsigned long)videoaddr, (unsigned long)newvideoaddr); - - mac68k_set_io_offsets(IOBase); - - /* - * If the serial ports are going (for console or 'echo'), then - * we need to make sure the IO change gets propagated properly. - * This resets the base addresses for the 8530 (serial) driver. - * - * WARNING!!! No printfs() (etc) BETWEEN zs_init() and the end - * of this function (where we start using the MMU, so the new - * address is correct). - */ -#if NZSC > 0 - if (zsinited != 0) - zs_init(); -#endif - - videoaddr = newvideoaddr; -} - -void -pmap_init_md() -{ - vaddr_t addr; - - /* - * Mark as unavailable the regions which we have mapped in - * pmap_bootstrap(). - */ - addr = (vaddr_t)MACHINE_INTIOBASE; - if (uvm_map(kernel_map, &addr, - ptoa(MACHINE_IIOMAPSIZE), - NULL, UVM_UNKNOWN_OFFSET, 0, - UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, - UVM_INH_NONE, UVM_ADV_RANDOM, - UVM_FLAG_FIXED))) - panic("pmap_init: bogons in the VM system!"); -} diff --git a/sys/arch/mac68k/mac68k/pram.c b/sys/arch/mac68k/mac68k/pram.c deleted file mode 100644 index 65cf35b6183..00000000000 --- a/sys/arch/mac68k/mac68k/pram.c +++ /dev/null @@ -1,98 +0,0 @@ -/* $OpenBSD: pram.c,v 1.11 2006/01/18 23:21:17 miod Exp $ */ -/* $NetBSD: pram.c,v 1.11 1996/10/21 05:42:29 scottr Exp $ */ - -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/types.h> -#include <sys/param.h> - -#include <mac68k/mac68k/pram.h> -#include <mac68k/dev/adbvar.h> - -/* - * getPramTime - * This function can be called regrardless of the machine - * type. It calls the correct hardware-specific code. - */ -unsigned long -pram_readtime() -{ - unsigned long time; - - switch (adbHardware) { - case ADB_HW_II: /* access PRAM via VIA interface */ - return (getPramTimeII()); - - case ADB_HW_IISI: /* access PRAM via pseudo-adb functions */ - case ADB_HW_CUDA: - if (adb_read_date_time(&time) != 0) - return (0); - else - return (time); - - case ADB_HW_PB: /* don't know how to access this yet */ - return (0); - - case ADB_HW_UNKNOWN: - default: - return (0); - } -} - -/* - * setPramTime - * This function can be called regrardless of the machine - * type. It calls the correct hardware-specific code. - */ -void -pram_settime(unsigned long time) -{ - switch (adbHardware) { - case ADB_HW_II: /* access PRAM via ADB interface */ - setPramTimeII(time); - break; - - case ADB_HW_IISI: /* access PRAM via pseudo-adb functions */ - case ADB_HW_CUDA: - adb_set_date_time(time); - break; - - case ADB_HW_PB: /* don't know how to access this yet */ - break; - - case ADB_HW_UNKNOWN: - default: - break; - } -} diff --git a/sys/arch/mac68k/mac68k/pram.h b/sys/arch/mac68k/mac68k/pram.h deleted file mode 100644 index 34f1726b324..00000000000 --- a/sys/arch/mac68k/mac68k/pram.h +++ /dev/null @@ -1,54 +0,0 @@ -/* $OpenBSD: pram.h,v 1.9 2007/04/10 17:14:42 miod Exp $ */ -/* $NetBSD: pram.h,v 1.3 1996/05/05 06:18:53 briggs Exp $ */ - -/* - * RTC toolkit version 1.08b, copyright 1995, erik vogan - * - * All rights and privileges to this code hereby donated - * to the ALICE group for use in NetBSD. see the copyright - * below for more info... - */ -/* - * Copyright (c) 1995 Erik Vogan - * All rights reserved. - * - * This code is derived from software contributed to the Alice Group - * by Erik Vogan. - * - * 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 Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * The following routines are used to get/set the PRAM time - * (which is stored as seconds since 1904). - */ - -unsigned long pram_readtime(void); -void pram_settime(unsigned long); - -unsigned long getPramTimeII(void); -void setPramTimeII(unsigned long); diff --git a/sys/arch/mac68k/mac68k/pramasm.s b/sys/arch/mac68k/mac68k/pramasm.s deleted file mode 100644 index e09d8823e0e..00000000000 --- a/sys/arch/mac68k/mac68k/pramasm.s +++ /dev/null @@ -1,194 +0,0 @@ -/* $OpenBSD: pramasm.s,v 1.7 2007/04/10 17:14:42 miod Exp $ */ -/* $NetBSD: pramasm.s,v 1.4 1995/09/28 03:15:54 briggs Exp $ */ - -/* - * RTC toolkit version 1.08b, copyright 1995, erik vogan - * - * All rights and privileges to this code hereby donated - * to the ALICE group for use in NetBSD. see the copyright - * below for more info... - */ -/* - * Copyright (c) 1995 Erik Vogan - * All rights reserved. - * - * This code is derived from software contributed to the Alice Group - * by Erik Vogan. - * - * 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 Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * The following are the C interface functions to RTC access functions - * that are defined later in this file. - */ - - /* The following routines are the hardware - * specific routines for the machines that - * use the II-like method to access the PRAM. */ - -/* - * The following are the C interface functions to RTC access functions - * that are defined later in this file. - */ - - .text - - .even - -.globl _getPramTimeII -_getPramTimeII: - link a6,#-4 | create a little home for ourselves - jbsr _readClock | call the routine to read the time - unlk a6 | clean up after ourselves - rts | and return to caller - -.globl _setPramTimeII -_setPramTimeII: - link a6,#-4 | create a little home for ourselves - movel a6@(8),d0 | get the passed in long (seconds since 1904) - jbsr _writeClock | call the routine to write the time - unlk a6 | clean up after ourselves - rts | and return to caller - -/* - * The following are the RTC access functions used by the interface - * routines, above. - */ - -_readClock: - moveml #0x7cc0, sp@- | store off the regs we need - moveq #00,d0 | zero out our result reg -readagan: - moveq #00,d5 | and our temp result reg - moveq #03,d4 | set our count down reg to 4 - movel #0x00000081,d1 | read sec byte 0 first -getSecb: - bsr _Transfer | get that byte - rorl #8,d5 | shift our time to the right - swap d1 | we want to access our new data - moveb d1,d5 | move that byte to the spot we vacated - swap d1 | return our PRAM command to orig. config - addqb #4,d1 | increment to the next sec byte - dbf d4,getSecb | any more bytes to get ? - cmpl d5,d0 | same secs value we as we just got ? - beq gotTime | we got a good time value - movel d5,d0 | copy our current time to the compare reg - bra readagan | read the time again -gotTime: - rorl #8,d0 | make that last shift to correctly order - | time bytes!!! - movel #0x00d50035,d1 | we have to set the write protect bit - | so the clock doesn't run down ! - bsr _Transfer | (so says Apple...) - moveml sp@+, #0x033e | restore our regs - rts | and return to caller - -_writeClock: - moveml #0x78c0, sp@- | store off the regs we need - moveq #03,d4 | set our count down reg to 4 - movel #0x00550035,d1 | de-write-protect the PRAM - bsr _Transfer | so we can set our value - moveq #1,d1 | write sec byte 0 first -putSecb: - swap d1 | we want access to data byte of command - moveb d0,d1 | set our first secs byte - swap d1 | and return command to orig. config - bsr _Transfer | write that byte - rorl #8,d0 | shift our time to the right - addqb #4,d1 | increment to the next sec byte - dbf d4,putSecb | any more bytes to put ? - movel #0x00d50035,d1 | we have to set the write protect bit - | so the clock doesn't run down ! - bsr _Transfer | (so says Apple...) - moveml sp@+, #0x031e | restore our regs - rts | and return to caller - -_Transfer: - movew sr,sp@- | store the SR (we'll change it!) - oriw #0x0700,sr | disable all interrupts - moveal _Via1Base,a1 | move VIA1 addr in reference reg - moveq #0,d2 | zero out d2 (it'll hold VIA1 reg B contents) - moveb a1@,d2 | and get VIA1 reg B contents - andib #0xF8,d2 | don't touch any but RTC bits - | (and zero all those) - movew d1,d3 | we want to manipulate our command - andiw #0xFF00,d3 | zero the LSB - beq oldPRAMc | do an old PRAM style command -xPRAMc: - rorw #8,d1 | swap the command bytes (1st byte of 2) - bsr writebyte | and write the command byte - rorw #8,d1 | swap the command bytes again (2nd byte of 2) - bsr writebyte | write that byte to RTC too - moveq #0x1F,d3 | r/w bit is $F for an extended command - | (but command is swapped to MSW!! so add $10) - bra Rwbrnch | go figure out if it's a read or a write cmd -oldPRAMc: - bsr writebyte | only one byte for an old PRAM command - moveq #0x17,d3 | r/w bit is $7 for and old PRAM command - | ( command is swapped to MSW, add $10) -Rwbrnch: - swap d1 | better get that (data/dummy) byte ready - btst d3,d1 | test bit no. d3 of reg d1 (read or write ?) - beq Wtrue | 0 = write, 1 = read (branch on write) -Rtrue: - bsr readbyte | read a byte from the RTC - bra Cleanup | and call mom to clean up after us -Wtrue: - bsr writebyte | write the data to the RTC -Cleanup: - swap d1 | move command to LSW again - bset #2,a1@ | bring the RTC enable line high (end of xfer) - movew sp@+,sr | restore prior interrupt status - rts | and return to caller - -writebyte: - moveq #7,d3 | set our bit counter to 8 -wagain: - lsrb #1,d2 | ditch the old data channel value - roxlb #1,d1 | and move a new value to X - roxlb #1,d2 | now move value from X to data channel - moveb d2,a1@ | set our VIA1 reg B contents to match - bset #1,a1@ | and finish strobing the clock line - dbf d3,wagain | do this until we've sent a whole byte - lsrb #1,d2 | ditch the data channel value one last time - roxlb #1,d1 | get rid of the extra X bit we've carried - lslb #1,d2 | and restore d2 to prior status - rts | return to caller - -readbyte: - moveq #7,d3 | set our bit counter to 8 - bclr #0,a1@(0x0400) | set VIA1 reg B data line to input -ragain: - bclr #1,a1@ | strobe the clock line to make - bset #1,a1@ | the data valid - moveb a1@,d2 | and get out data byte - lsrb #1,d2 | get the data channel value to X - roxlb #1,d1 | and move X to data byte - dbf d3,ragain | do this until we've received a whole byte - bset #0,a1@(0x0400) | and return RTC data line to output - rts | return to caller diff --git a/sys/arch/mac68k/mac68k/psc.c b/sys/arch/mac68k/mac68k/psc.c deleted file mode 100644 index b1e5d9cf705..00000000000 --- a/sys/arch/mac68k/mac68k/psc.c +++ /dev/null @@ -1,355 +0,0 @@ -/* $OpenBSD: psc.c,v 1.6 2004/12/14 14:50:55 martin Exp $ */ -/* $NetBSD: psc.c,v 1.8 2004/03/26 12:15:46 wiz Exp $ */ - - -/*- - * Copyright (c) 1997 David Huang <khym@azeotrope.org> - * 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. 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. - * - */ - -/* - * This handles registration/unregistration of PSC (Peripheral - * Subsystem Controller) interrupts. The PSC is used only on the - * Centris/Quadra 660av and the Quadra 840av. - */ - -#include <sys/param.h> -#include <sys/systm.h> - -#include <machine/bus.h> -#include <machine/cpu.h> -#include <machine/psc.h> - -static void psc_kill_dma(void); -int psc_lev3_intr(void *); -static void psc_lev3_noint(void *); -int psc_lev4_intr(void *); -static int psc_lev4_noint(void *); -int psc_lev5_intr(void *); -static void psc_lev5_noint(void *); -int psc_lev6_intr(void *); -static void psc_lev6_noint(void *); - -void (*psc3_ihandler)(void *) = psc_lev3_noint; -void *psc3_iarg; - -int (*psc4_itab[4])(void *) = { - psc_lev4_noint, /* 0 */ - psc_lev4_noint, /* 1 */ - psc_lev4_noint, /* 2 */ - psc_lev4_noint /* 3 */ -}; - -void *psc4_iarg[4] = { - (void *)0, (void *)1, (void *)2, (void *)3 -}; - -void (*psc5_itab[2])(void *) = { - psc_lev5_noint, /* 0 */ - psc_lev5_noint /* 1 */ -}; - -void *psc5_iarg[2] = { - (void *)0, (void *)1 -}; - -void (*psc6_itab[3])(void *) = { - psc_lev6_noint, /* 0 */ - psc_lev6_noint, /* 1 */ - psc_lev6_noint /* 2 */ -}; - -void *psc6_iarg[3] = { - (void *)0, (void *)1, (void *)2 -}; - -/* - * Make excessively sure that all PSC DMA is shut down. - */ -void -psc_kill_dma() -{ - int i; - - for (i = 0; i < 9; i++) { - psc_reg2(PSC_CTLBASE + (i << 4)) = 0x8800; - psc_reg2(PSC_CTLBASE + (i << 4)) = 0x1000; - psc_reg2(PSC_CMDBASE + (i << 5)) = 0x1100; - psc_reg2(PSC_CMDBASE + (i << 5) + PSC_SET1) = 0x1100; - } -} - -/* - * Setup the interrupt vectors and disable most of the PSC interrupts - */ -void -psc_init() -{ - int s, i; - - /* - * Only Quadra AVs have a PSC. - */ - if (current_mac_model->class == MACH_CLASSAV) { - s = splhigh(); - psc_kill_dma(); - intr_establish(psc_lev3_intr, NULL, 3, "psc"); - intr_establish(psc_lev4_intr, NULL, 4, "psc"); - intr_establish(psc_lev5_intr, NULL, 5, "psc"); - intr_establish(psc_lev6_intr, NULL, 6, "psc"); - for (i = 3; i < 7; i++) { - /* Clear any flags */ - psc_reg1(PSC_ISR_BASE + 0x10 * i) = 0x0F; - /* Clear any interrupt enable */ - psc_reg1(PSC_IER_BASE + 0x10 * i) = 0x0F; - } - psc_reg1(PSC_LEV4_IER) = 0x86; /* enable SCC */ - splx(s); - } -} - -int -add_psc_lev3_intr(handler, arg) - void (*handler)(void *); - void *arg; -{ - int s; - - s = splhigh(); - - psc3_ihandler = handler; - psc3_iarg = arg; - - splx(s); - - return 1; -} - -int -remove_psc_lev3_intr() -{ - return add_psc_lev3_intr(psc_lev3_noint, (void *)0); -} - -int -psc_lev3_intr(arg) - void *arg; -{ - u_int8_t intbits; - - while ((intbits = psc_reg1(PSC_LEV3_ISR)) != psc_reg1(PSC_LEV3_ISR)) - ; - intbits &= 0x1 & psc_reg1(PSC_LEV3_IER); - - if (intbits) - psc3_ihandler(psc3_iarg); - - return 0; -} - -static void -psc_lev3_noint(arg) - void *arg; -{ -#ifdef DEBUG - printf("psc_lev3_noint\n"); -#endif -} - -int -psc_lev4_intr(arg) - void * arg; -{ - u_int8_t intbits, bitnum; - u_int mask; - - while ((intbits = psc_reg1(PSC_LEV4_ISR)) != psc_reg1(PSC_LEV4_ISR)) - ; - intbits &= 0xf & psc_reg1(PSC_LEV4_IER); - - mask = 1; - bitnum = 0; - do { - if (intbits & mask) - psc4_itab[bitnum](psc4_iarg[bitnum]); - mask <<= 1; - } while (intbits >= mask && ++bitnum); - - return 0; -} - -int -add_psc_lev4_intr(dev, handler, arg) - int dev; - int (*handler)(void *); - void *arg; -{ - int s; - - if ((dev < 0) || (dev > 3)) - return 0; - - s = splhigh(); - - psc4_itab[dev] = handler; - psc4_iarg[dev] = arg; - - splx(s); - - return 1; -} - -int -remove_psc_lev4_intr(dev) - int dev; -{ - return add_psc_lev4_intr(dev, psc_lev4_noint, (void *)dev); -} - -int -psc_lev4_noint(arg) - void *arg; -{ -#ifdef DEBUG - printf("psc_lev4_noint: device %d\n", (int)arg); -#endif - return 0; -} - -int -psc_lev5_intr(arg) - void *arg; -{ - u_int8_t intbits, bitnum; - u_int mask; - - while ((intbits = psc_reg1(PSC_LEV5_ISR)) != psc_reg1(PSC_LEV5_ISR)) - ; - intbits &= 0x3 & psc_reg1(PSC_LEV5_IER); - - mask = 1; - bitnum = 0; - do { - if (intbits & mask) - psc5_itab[bitnum](psc5_iarg[bitnum]); - mask <<= 1; - } while (intbits >= mask && ++bitnum); - - return 0; -} - -int -add_psc_lev5_intr(dev, handler, arg) - int dev; - void (*handler)(void *); - void *arg; -{ - int s; - - if ((dev < 0) || (dev > 1)) - return 0; - - s = splhigh(); - - psc5_itab[dev] = handler; - psc5_iarg[dev] = arg; - - splx(s); - - return 1; -} - -int -remove_psc_lev5_intr(dev) - int dev; -{ - return add_psc_lev5_intr(dev, psc_lev5_noint, (void *)dev); -} - -void -psc_lev5_noint(arg) - void *arg; -{ -#ifdef DEBUG - printf("psc_lev5_noint: device %d\n", (int)arg); -#endif -} - -int -psc_lev6_intr(arg) - void *arg; -{ - u_int8_t intbits, bitnum; - u_int mask; - - while ((intbits = psc_reg1(PSC_LEV6_ISR)) != psc_reg1(PSC_LEV6_ISR)) - ; - intbits &= 0x7 & psc_reg1(PSC_LEV6_IER); - - mask = 1; - bitnum = 0; - do { - if (intbits & mask) - psc6_itab[bitnum](psc6_iarg[bitnum]); - mask <<= 1; - } while (intbits >= mask && ++bitnum); - - return 0; -} - -int -add_psc_lev6_intr(dev, handler, arg) - int dev; - void (*handler)(void *); - void *arg; -{ - int s; - - if ((dev < 0) || (dev > 2)) - return 0; - - s = splhigh(); - - psc6_itab[dev] = handler; - psc6_iarg[dev] = arg; - - splx(s); - - return 1; -} - -int -remove_psc_lev6_intr(dev) - int dev; -{ - return add_psc_lev6_intr(dev, psc_lev6_noint, (void *)dev); -} - -void -psc_lev6_noint(arg) - void *arg; -{ -#ifdef DEBUG - printf("psc_lev6_noint: device %d\n", (int)arg); -#endif -} diff --git a/sys/arch/mac68k/mac68k/sys_machdep.c b/sys/arch/mac68k/mac68k/sys_machdep.c deleted file mode 100644 index 77db7b5750e..00000000000 --- a/sys/arch/mac68k/mac68k/sys_machdep.c +++ /dev/null @@ -1,98 +0,0 @@ -/* $OpenBSD: sys_machdep.c,v 1.10 2005/08/01 11:54:24 miod Exp $ */ -/* $NetBSD: sys_machdep.c,v 1.9 1996/05/05 06:18:58 briggs Exp $ */ - -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. -*/ -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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. - * - */ -/* - * @(#)sys_machdep.c 7.7 (Berkeley) 5/7/91 - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/ioctl.h> -#include <sys/file.h> -#include <sys/time.h> -#include <sys/proc.h> -#include <sys/signalvar.h> -#include <sys/uio.h> -#include <sys/kernel.h> -#include <sys/mtio.h> -#include <sys/buf.h> -#include <sys/mount.h> - -#include <sys/syscallargs.h> - -int -sys_sysarch(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ -#if 0 /* unused */ - struct sys_sysarch_args /* { - syscallarg(int) op; - syscallarg(char *) parms; - } */ *uap = v; -#endif - - return ENOSYS; -} diff --git a/sys/arch/mac68k/mac68k/trap.c b/sys/arch/mac68k/mac68k/trap.c deleted file mode 100644 index 72dd8884573..00000000000 --- a/sys/arch/mac68k/mac68k/trap.c +++ /dev/null @@ -1,1014 +0,0 @@ -/* $OpenBSD: trap.c,v 1.61 2011/11/16 20:50:18 deraadt Exp $ */ -/* $NetBSD: trap.c,v 1.68 1998/12/22 08:47:07 scottr Exp $ */ - -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1986, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah $Hdr: trap.c 1.37 92/12/20$ - * - * @(#)trap.c 8.5 (Berkeley) 1/4/94 - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/proc.h> -#include <sys/acct.h> -#include <sys/kernel.h> -#include <sys/signalvar.h> -#include <sys/resourcevar.h> -#include <sys/syscall.h> -#include <sys/syslog.h> -#include <sys/user.h> -#ifdef KGDB -#include <sys/kgdb.h> -#endif -#ifdef KTRACE -#include <sys/ktrace.h> -#endif -#ifdef DEBUG -#include <dev/cons.h> -#endif - -#include <machine/db_machdep.h> -#include <machine/psl.h> -#include <machine/trap.h> -#include <machine/cpu.h> -#include <machine/reg.h> - -#include <m68k/fpe/fpu_emulate.h> - -#include "systrace.h" -#include <dev/systrace.h> - -#include <uvm/uvm_extern.h> -#include <uvm/uvm_pmap.h> - -int astpending; - -char *trap_type[] = { - "Bus error", - "Address error", - "Illegal instruction", - "Zero divide", - "CHK instruction", - "TRAPV instruction", - "Privilege violation", - "Trace trap", - "MMU fault", - "SSIR trap", - "Format error", - "68881 exception", - "Coprocessor violation", - "Async system trap" -}; -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) */ - FMT1SIZE, /* type 1 - throwaway (68020/030/040) */ - FMT2SIZE, /* type 2 - normal 6-word (68020/030/040) */ - FMT3SIZE, /* type 3 - FP post-instruction (68040) */ - FMT4SIZE, /* type 4 - LC040 FP exception (68LC040) */ - -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) */ - FMTASIZE, /* type A - short bus fault (68020/030) */ - FMTBSIZE, /* type B - long bus fault (68020/030) */ - -1, -1, -1, -1 /* type C-F - undefined */ -}; - -#ifdef M68040 -#define KDFAULT(c) (mmutype == MMU_68040 ? \ - ((c) & SSW4_TMMASK) == SSW4_TMKD : \ - ((c) & (SSW_DF|SSW_FCMASK)) == (SSW_DF|FC_SUPERD)) -#define WRFAULT(c) (mmutype == MMU_68040 ? \ - ((c) & SSW4_RW) == 0 : \ - ((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) -#endif - -#ifdef DEBUG -int mmudebug = 0; -int mmupid = -1; -#define MDB_FOLLOW 1 -#define MDB_WBFOLLOW 2 -#define MDB_WBFAILED 4 -#define MDB_ISPID(pid) ((pid) == mmupid) -#endif - -/* trap() and syscall() only called from locore */ -void trap(int, u_int, u_int, struct frame); -void syscall(register_t, struct frame); - -#if defined(M68040) -int writeback(struct frame *); -void wb_userret(struct proc *, struct frame *); -#if DEBUG -static void dumpssw(u_short); -static void dumpwb(int, u_short, u_int, u_int); -#endif -#endif - -#ifdef M68040 -/* - * Handle writeback completion on 68040. - */ -void -wb_userret(struct proc *p, struct frame *fp) -{ - /* - * Deal with user mode writebacks (from trap, or from sigreturn). - * If any writeback fails, go back and attempt signal delivery - * unless we have already been here and attempted the writeback - * (e.g. bad address with user ignoring SIGSEGV). In that case, - * we just return to the user without successfully completing - * the writebacks. Maybe we should just drop the sucker? - */ - if (mmutype == MMU_68040 && fp->f_format == FMT7) { - int sig; - union sigval sv; - - if ((sig = writeback(fp)) != 0) { - sv.sival_ptr = (void *)fp->f_fmt7.f_fa; - trapsignal(p, sig, T_MMUFLT, SEGV_MAPERR, sv); - - userret(p); - } - } -} -#endif - -/* - * Trap is called from locore to handle most types of processor traps, - * including events such as simulated software interrupts/AST's. - * System calls are broken out for efficiency. - */ -/*ARGSUSED*/ -void -trap(type, code, v, frame) - int type; - u_int code; - u_int v; - struct frame frame; -{ - struct proc *p; - int i, s; - u_int ucode; - int typ = 0; - union sigval sv; - - uvmexp.traps++; - 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: type 0x%x, code 0x%x, v 0x%x -- no pcb", - type, code, v); -#endif - - if (USERMODE(frame.f_sr)) { - type |= T_USER; - p->p_md.md_regs = frame.f_regs; - } - - switch (type) { - default: -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, (db_regs_t *)&frame)) - goto kgdb_cont; -#endif -#ifdef DDB - (void)kdb_trap(type, (db_regs_t *)&frame); -#endif -#ifdef KGDB -kgdb_cont: -#endif - splx(s); - if (panicstr) { - printf("trap during panic!\n"); -#ifdef DEBUG - /* XXX should be a machine-dependent hook */ - printf("(press a key)\n"); - cnpollc(1); (void)cngetc(); cnpollc(0); -#endif - } - regdump(&(frame.F_t), 128); - type &= ~T_USER; - 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) - goto dopanic; - /* - * 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; - return; - - case T_BUSERR|T_USER: /* Bus error */ - typ = BUS_OBJERR; - ucode = code & ~T_USER; - i = SIGBUS; - break; - case T_ADDRERR|T_USER: /* Address error */ - typ = BUS_ADRALN; - ucode = code & ~T_USER; - i = SIGBUS; - break; - - case T_ILLINST|T_USER: /* Illegal instruction fault */ - ucode = frame.f_format; /* XXX was ILL_PRIVIN_FAULT */ - typ = ILL_ILLOPC; - i = SIGILL; - v = frame.f_pc; - break; - - case T_PRIVINST|T_USER: /* Privileged instruction fault */ - ucode = frame.f_format; /* XXX was ILL_PRIVIN_FAULT */ - typ = ILL_PRVOPC; - i = SIGILL; - v = frame.f_pc; - break; - /* - * divde by zero, CHK/TRAPV inst - */ - case T_ZERODIV|T_USER: /* Divide by zero trap */ - ucode = frame.f_format; - typ = FPE_INTDIV; - i = SIGFPE; - v = frame.f_pc; - break; - - case T_CHKINST|T_USER: /* CHK instruction trap */ - ucode = frame.f_format; - type = FPE_FLTSUB; - i = SIGFPE; - v = frame.f_pc; - break; - - case T_TRAPVINST|T_USER: /* TRAPV instruction trap */ - ucode = frame.f_format; - typ = ILL_ILLTRP; - i = SIGILL; - v = frame.f_pc; - break; - /* - * User coprocessor violation - */ - case T_COPERR|T_USER: - typ = ILL_COPROC; - ucode = 0; - i = SIGILL; - break; - /* - * 6888x exceptions - */ - case T_FPERR|T_USER: - typ = FPE_FLTRES; - ucode = code; - i = SIGFPE; - v = frame.f_pc; - break; - - /* - * FPU faults in supervisor mode. - */ - case T_ILLINST: /* fnop generates this, apparently. */ - case T_FPEMULI: - case T_FPEMULD: { - extern label_t *nofault; - - if (nofault) /* If we're probing. */ - longjmp(nofault); - if (type == T_ILLINST) - printf("Kernel Illegal Instruction trap.\n"); - else - printf("Kernel FPU trap.\n"); - goto dopanic; - } - - /* - * Unimplemented FPU instructions/datatypes. - */ - case T_FPEMULI|T_USER: - case T_FPEMULD|T_USER: -#ifdef FPU_EMULATE - i = fpu_emulate(&frame, &p->p_addr->u_pcb.pcb_fpregs, - &typ); - /* XXX -- deal with tracing? (frame.f_sr & PSL_T) */ - if (i == 0) - goto out; -#else - uprintf("pid %d killed: no floating point support.\n", - p->p_pid); - i = SIGILL; - typ = ILL_COPROC; -#endif - ucode = frame.f_format; - v = frame.f_pc; - break; - - case T_COPERR: /* Kernel coprocessor violation */ - case T_FMTERR: /* Kernel format error */ - case T_FMTERR|T_USER: /* User format error */ - /* - * The user has most likely trashed the RTE or FP state info - * in the stack frame of a signal handler. - */ - printf("pid %d: kernel %s exception\n", p->p_pid, - type==T_COPERR ? "coprocessor" : "format"); - type |= T_USER; - p->p_sigacts->ps_sigact[SIGILL] = SIG_DFL; - i = sigmask(SIGILL); - p->p_sigacts->ps_sigignore &= ~i; - p->p_sigacts->ps_sigcatch &= ~i; - p->p_sigmask &= ~i; - i = SIGILL; - ucode = frame.f_format; /* XXX was ILL_RESAD_FAULT */ - typ = ILL_COPROC; - v = frame.f_pc; - break; - - /* - * XXX: Trace traps are a nightmare. - * - * HP-UX uses trap #1 for breakpoints, - * OpenBSD/m68k uses trap #2, - * SUN 3.x uses trap #15, - * DDB and KGDB uses trap #15 (for kernel breakpoints; - * handled elsewhere). - * - * OpenBSD 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_TRAP15: /* kernel breakpoint */ - frame.f_sr &= ~PSL_T; - return; - - case T_TRACE|T_USER: /* user trace trap */ - case T_TRACE: /* Kernel trace trap */ - case T_TRAP15|T_USER: /* Sun user trace trap */ - frame.f_sr &= ~PSL_T; - i = SIGTRAP; - typ = TRAP_TRACE; - break; - - case T_ASTFLT: /* System async trap, cannot happen */ - goto dopanic; - - case T_ASTFLT|T_USER: /* User async trap. */ - astpending = 0; - /* - * We check for software interrupts first. This is because - * they are at a higher level than ASTs, and on a VAX would - * interrupt the AST. We assume that if we are processing - * an AST that we must be at IPL0 so we don't bother to - * check. Note that we ensure that we are at least at SIR - * IPL while processing the SIR. - */ - splsoft(); - /* FALLTHROUGH */ - - case T_SSIR: /* Software interrupt */ - case T_SSIR|T_USER: - { - int sir, q, mask; - - while ((sir = softpending) != 0) { - atomic_clearbits_int(&softpending, sir); - - for (q = SI_NQUEUES - 1, mask = 1 << (SI_NQUEUES - 1); - mask != 0; q--, mask >>= 1) - if (mask & sir) - softintr_dispatch(q); - } - } - - /* - * If this was not an AST trap, we are all done. - */ - if (type != (T_ASTFLT|T_USER)) { - uvmexp.traps--; - return; - } - spl0(); - if (p->p_flag & P_OWEUPC) { - ADDUPROF(p); - } - if (type == (T_ASTFLT | T_USER) && want_resched) { - preempt(NULL); - } - goto out; - - case T_MMUFLT: /* Kernel mode page fault */ - case T_MMUFLT|T_USER: /* page fault */ - { - vaddr_t va; - struct vmspace *vm = p->p_vmspace; - struct vm_map *map; - int rv; - vm_prot_t ftype, vftype; - extern struct vm_map *kernel_map; - -#ifdef DEBUG - if ((mmudebug & MDB_WBFOLLOW) || MDB_ISPID(p->p_pid)) - printf("trap: T_MMUFLT pid=%d, code=%x, v=%x, pc=%x, sr=%x\n", - p->p_pid, code, v, frame.f_pc, frame.f_sr); -#endif - /* - * It is only a kernel address space fault iff: - * 1. (type & T_USER) == 0 and - * 2. pcb_onfault not set or - * 3. pcb_onfault set but supervisor data fault - * The last can occur during an exec() copyin where the - * argument space is lazy-allocated. - */ - if ((type & T_USER) == 0 && - (!p->p_addr->u_pcb.pcb_onfault || KDFAULT(code))) - map = kernel_map; - else - map = vm ? &vm->vm_map : kernel_map; - - if (WRFAULT(code)) { - vftype = VM_PROT_WRITE; - ftype = VM_PROT_READ | VM_PROT_WRITE; - } - else - vftype = ftype = VM_PROT_READ; - - va = trunc_page((vaddr_t)v); - - if (map == kernel_map && va == 0) { - printf("trap: bad kernel %s access at 0x%x\n", - (ftype & VM_PROT_WRITE) ? "read/write" : "read", v); - goto dopanic; - } - rv = uvm_fault(map, va, 0, ftype); -#ifdef DEBUG - if (rv && MDB_ISPID(p->p_pid)) - printf("uvm_fault(%p, 0x%lx, 0, 0x%x) -> 0x%x\n", - map, va, ftype, rv); -#endif - /* - * If this was a stack access, we keep track of the maximum - * accessed stack size. Also, if vm_fault gets a protection - * failure, it is due to accessing the stack region outside - * the current limit and we need to reflect that as an access - * error. - */ - if ((vm != NULL && (caddr_t)va >= vm->vm_maxsaddr) - && map != kernel_map) { - if (rv == 0) - uvm_grow(p, va); - else if (rv == EACCES) - rv = EFAULT; - } - if (rv == 0) { - if (type == T_MMUFLT) { -#if defined(M68040) - if (mmutype == MMU_68040) - (void)writeback(&frame); -#endif - return; - } - goto out; - } - if (type == T_MMUFLT) { - if (p->p_addr->u_pcb.pcb_onfault) - goto copyfault; - printf("uvm_fault(%p, 0x%lx, 0, 0x%x) -> 0x%x\n", - map, va, ftype, rv); - printf(" type %x, code [mmu,,ssw]: %x\n", - type, code); - goto dopanic; - } - frame.f_pad = code & 0xffff; - ucode = vftype; - typ = SEGV_MAPERR; - i = SIGSEGV; - break; - } - } - sv.sival_ptr = (void *)v; - trapsignal(p, i, ucode, typ, sv); -out: - if ((type & T_USER) == 0) - return; - userret(p); -#ifdef M68040 - wb_userret(p, &frame); -#endif -} - -#if defined(M68040) -#ifdef DEBUG -struct writebackstats { - int calls; - int cpushes; - int move16s; - int wb1s, wb2s, wb3s; - int wbsize[4]; -} wbstats; - -char *f7sz[] = { "longword", "byte", "word", "line" }; -char *f7tt[] = { "normal", "MOVE16", "AFC", "ACK" }; -char *f7tm[] = { "d-push", "u-data", "u-code", "M-data", - "M-code", "k-data", "k-code", "RES" }; -char wberrstr[] = - "WARNING: pid %d(%s) writeback [%s] failed, pc=%x fa=%x wba=%x wbd=%x\n"; -#endif - -int -writeback(struct frame *fp) -{ - struct fmt7 *f = &fp->f_fmt7; - struct proc *p = curproc; - int err = 0; - u_int fa; - paddr_t pa; - caddr_t oonfault = p->p_addr->u_pcb.pcb_onfault; - -#ifdef DEBUG - if ((mmudebug & MDB_WBFOLLOW) || MDB_ISPID(p->p_pid)) { - printf(" pid=%d, fa=%x,", p->p_pid, f->f_fa); - dumpssw(f->f_ssw); - } - wbstats.calls++; -#endif - /* - * Deal with special cases first. - */ - if ((f->f_ssw & SSW4_TMMASK) == SSW4_TMDCP) { - /* - * Dcache push fault. - * Line-align the address and write out the push data to - * the indicated physical address. - */ -#ifdef DEBUG - if ((mmudebug & MDB_WBFOLLOW) || MDB_ISPID(p->p_pid)) { - printf(" pushing %s to PA %x, data %x", - f7sz[(f->f_ssw & SSW4_SZMASK) >> 5], - f->f_fa, f->f_pd0); - if ((f->f_ssw & SSW4_SZMASK) == SSW4_SZLN) - printf("/%x/%x/%x", - f->f_pd1, f->f_pd2, f->f_pd3); - printf("\n"); - } - if (f->f_wb1s & SSW4_WBSV) - panic("writeback: cache push with WB1S valid"); - wbstats.cpushes++; -#endif - /* - * XXX there are security problems if we attempt to do a - * cache push after a signal handler has been called. - */ - pmap_kenter_pa((vaddr_t)vmmap, - trunc_page((vaddr_t)f->f_fa), VM_PROT_WRITE); - pmap_update(pmap_kernel()); - fa = (u_int)&vmmap[m68k_page_offset(f->f_fa) & ~0x000f]; - bcopy((caddr_t)&f->f_pd0, (caddr_t)fa, 16); - pmap_extract(pmap_kernel(), (vaddr_t)fa, &pa); - DCFL(pa); - pmap_kremove((vaddr_t)vmmap, PAGE_SIZE); - pmap_update(pmap_kernel()); - } else if ((f->f_ssw & (SSW4_RW|SSW4_TTMASK)) == SSW4_TTM16) { - /* - * MOVE16 fault. - * Line-align the address and write out the push data to - * the indicated virtual address. - */ -#ifdef DEBUG - if ((mmudebug & MDB_WBFOLLOW) || MDB_ISPID(p->p_pid)) - printf(" MOVE16 to VA %x(%x), data %x/%x/%x/%x\n", - f->f_fa, f->f_fa & ~0xF, f->f_pd0, f->f_pd1, - f->f_pd2, f->f_pd3); - if (f->f_wb1s & SSW4_WBSV) - panic("writeback: MOVE16 with WB1S valid"); - wbstats.move16s++; -#endif - if (KDFAULT(f->f_wb1s)) - bcopy((caddr_t)&f->f_pd0, (caddr_t)(f->f_fa & ~0xF), 16); - else - err = suline((caddr_t)(f->f_fa & ~0xF), (caddr_t)&f->f_pd0); - if (err) { - fa = f->f_fa & ~0xF; -#ifdef DEBUG - if (mmudebug & MDB_WBFAILED) - printf(wberrstr, p->p_pid, p->p_comm, - "MOVE16", fp->f_pc, f->f_fa, - f->f_fa & ~0xF, f->f_pd0); -#endif - } - } else if (f->f_wb1s & SSW4_WBSV) { - /* - * Writeback #1. - * Position the "memory-aligned" data and write it out. - */ - u_int wb1d = f->f_wb1d; - int off; - -#ifdef DEBUG - if ((mmudebug & MDB_WBFOLLOW) || MDB_ISPID(p->p_pid)) - dumpwb(1, f->f_wb1s, f->f_wb1a, f->f_wb1d); - wbstats.wb1s++; - wbstats.wbsize[(f->f_wb2s&SSW4_SZMASK)>>5]++; -#endif - off = (f->f_wb1a & 3) * 8; - switch (f->f_wb1s & SSW4_SZMASK) { - case SSW4_SZLW: - if (off) - wb1d = (wb1d >> (32 - off)) | (wb1d << off); - if (KDFAULT(f->f_wb1s)) - *(long *)f->f_wb1a = wb1d; - else - err = copyout(&wb1d, (caddr_t)f->f_wb1a, - sizeof(int)); - break; - case SSW4_SZB: - off = 24 - off; - if (off) - wb1d >>= off; - if (KDFAULT(f->f_wb1s)) - *(char *)f->f_wb1a = wb1d; - else { - char tmp = wb1d; - - err = copyout(&tmp, (caddr_t)f->f_wb1a, - sizeof(char)); - } - break; - case SSW4_SZW: - off = (off + 16) % 32; - if (off) - wb1d = (wb1d >> (32 - off)) | (wb1d << off); - if (KDFAULT(f->f_wb1s)) - *(short *)f->f_wb1a = wb1d; - else { - short tmp = wb1d; - - err = copyout(&tmp, (caddr_t)f->f_wb1a, - sizeof(short)); - } - break; - } - if (err) { - fa = f->f_wb1a; -#ifdef DEBUG - if (mmudebug & MDB_WBFAILED) - printf(wberrstr, p->p_pid, p->p_comm, - "#1", fp->f_pc, f->f_fa, - f->f_wb1a, f->f_wb1d); -#endif - } - } - /* - * Deal with the "normal" writebacks. - * - * XXX writeback2 is known to reflect a LINE size writeback after - * a MOVE16 was already dealt with above. Ignore it. - */ - if (err == 0 && (f->f_wb2s & SSW4_WBSV) && - (f->f_wb2s & SSW4_SZMASK) != SSW4_SZLN) { -#ifdef DEBUG - if ((mmudebug & MDB_WBFOLLOW) || MDB_ISPID(p->p_pid)) - dumpwb(2, f->f_wb2s, f->f_wb2a, f->f_wb2d); - wbstats.wb2s++; - wbstats.wbsize[(f->f_wb2s&SSW4_SZMASK)>>5]++; -#endif - switch (f->f_wb2s & SSW4_SZMASK) { - case SSW4_SZLW: - if (KDFAULT(f->f_wb2s)) - *(long *)f->f_wb2a = f->f_wb2d; - else - err = copyout(&f->f_wb2d, (caddr_t)f->f_wb2a, - sizeof(int)); - break; - case SSW4_SZB: - if (KDFAULT(f->f_wb2s)) - *(char *)f->f_wb2a = f->f_wb2d; - else { - char tmp = f->f_wb2d; - - err = copyout(&tmp, (caddr_t)f->f_wb2a, - sizeof(char)); - } - break; - case SSW4_SZW: - if (KDFAULT(f->f_wb2s)) - *(short *)f->f_wb2a = f->f_wb2d; - else { - short tmp = f->f_wb2d; - - err = copyout(&tmp, (caddr_t)f->f_wb2a, - sizeof(short)); - } - break; - } - if (err) { - fa = f->f_wb2a; -#ifdef DEBUG - if (mmudebug & MDB_WBFAILED) { - printf(wberrstr, p->p_pid, p->p_comm, - "#2", fp->f_pc, f->f_fa, - f->f_wb2a, f->f_wb2d); - dumpssw(f->f_ssw); - dumpwb(2, f->f_wb2s, f->f_wb2a, f->f_wb2d); - } -#endif - } - } - if (err == 0 && (f->f_wb3s & SSW4_WBSV)) { -#ifdef DEBUG - if ((mmudebug & MDB_WBFOLLOW) || MDB_ISPID(p->p_pid)) - dumpwb(3, f->f_wb3s, f->f_wb3a, f->f_wb3d); - wbstats.wb3s++; - wbstats.wbsize[(f->f_wb3s&SSW4_SZMASK)>>5]++; -#endif - switch (f->f_wb3s & SSW4_SZMASK) { - case SSW4_SZLW: - if (KDFAULT(f->f_wb3s)) - *(long *)f->f_wb3a = f->f_wb3d; - else - err = copyout(&f->f_wb3d, (caddr_t)f->f_wb3a, - sizeof(int)); - break; - case SSW4_SZB: - if (KDFAULT(f->f_wb3s)) - *(char *)f->f_wb3a = f->f_wb3d; - else { - char tmp = f->f_wb3d; - - err = copyout(&tmp, (caddr_t)f->f_wb3a, - sizeof(char)); - } - break; - case SSW4_SZW: - if (KDFAULT(f->f_wb3s)) - *(short *)f->f_wb3a = f->f_wb3d; - else { - short tmp = f->f_wb3d; - - err = copyout(&tmp, (caddr_t)f->f_wb3a, - sizeof(short)); - } - break; -#ifdef DEBUG - case SSW4_SZLN: - panic("writeback: wb3s indicates LINE write"); -#endif - } - if (err) { - fa = f->f_wb3a; -#ifdef DEBUG - if (mmudebug & MDB_WBFAILED) - printf(wberrstr, p->p_pid, p->p_comm, - "#3", fp->f_pc, f->f_fa, - f->f_wb3a, f->f_wb3d); -#endif - } - } - p->p_addr->u_pcb.pcb_onfault = oonfault; - /* - * Any problems are SIGSEGV's - */ - if (err) - err = SIGSEGV; - return (err); -} - -#ifdef DEBUG -void -dumpssw(ssw) - u_short ssw; -{ - printf(" SSW: %x: ", ssw); - if (ssw & SSW4_CP) - printf("CP,"); - if (ssw & SSW4_CU) - printf("CU,"); - if (ssw & SSW4_CT) - printf("CT,"); - if (ssw & SSW4_CM) - printf("CM,"); - if (ssw & SSW4_MA) - printf("MA,"); - if (ssw & SSW4_ATC) - printf("ATC,"); - if (ssw & SSW4_LK) - printf("LK,"); - if (ssw & SSW4_RW) - printf("RW,"); - printf(" SZ=%s, TT=%s, TM=%s\n", - f7sz[(ssw & SSW4_SZMASK) >> 5], - f7tt[(ssw & SSW4_TTMASK) >> 3], - f7tm[ssw & SSW4_TMMASK]); -} - -void -dumpwb(num, s, a, d) - int num; - u_short s; - u_int a, d; -{ - struct proc *p = curproc; - paddr_t pa; - int tmp; - - printf(" writeback #%d: VA %x, data %x, SZ=%s, TT=%s, TM=%s\n", - num, a, d, f7sz[(s & SSW4_SZMASK) >> 5], - f7tt[(s & SSW4_TTMASK) >> 3], f7tm[s & SSW4_TMMASK]); - printf(" PA "); - if (pmap_extract(p->p_vmspace->vm_map.pmap, (vaddr_t)a, &pa) == FALSE) - printf("<invalid address>"); - else { - if (copyin((caddr_t)a, &tmp, sizeof(int)) == 0) - printf("%lx, current value %lx", pa, tmp); - else - printf("%lx, current value inaccessible", pa); - } - printf("\n"); -} -#endif -#endif - -/* - * Process a system call. - */ -void -syscall(code, frame) - register_t code; - struct frame frame; -{ - caddr_t params; - struct sysent *callp; - struct proc *p; - int error, opc, nsys; - size_t argsize; - register_t args[8], rval[2]; - - uvmexp.syscalls++; - if (!USERMODE(frame.f_sr)) - panic("syscall"); - p = curproc; - p->p_md.md_regs = frame.f_regs; - opc = frame.f_pc; - - nsys = p->p_emul->e_nsysent; - callp = p->p_emul->e_sysent; - - params = (caddr_t)frame.f_regs[SP] + sizeof(int); - - switch (code) { - case SYS_syscall: - /* - * Code is first argument, followed by actual args. - */ - if (copyin(params, &code, sizeof(register_t)) != 0) - code = -1; - params += sizeof(int); - /* - * XXX sigreturn requires special stack manipulation - * that is only done if entered via the sigreturn - * trap. Cannot allow here, so make sure we fail. - */ - if (code == SYS_sigreturn) - code = nsys; - break; - case SYS___syscall: - /* - * Like syscall, but code is a quad, so as to maintain - * quad alignment for the rest of the arguments. - */ - if (callp != sysent) - break; - if (copyin(params + _QUAD_LOWWORD * sizeof(int), &code, - sizeof(register_t)) != 0) - code = -1; - params += sizeof(quad_t); - break; - default: - break; - } - if (code < 0 || code >= nsys) - callp += p->p_emul->e_nosys; /* illegal */ - else - callp += code; - argsize = callp->sy_argsize; - if (argsize) - error = copyin(params, (caddr_t)args, argsize); - else - error = 0; -#ifdef SYSCALL_DEBUG - scdebug_call(p, code, args); -#endif -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) - ktrsyscall(p, code, argsize, args); -#endif - if (error) - goto bad; - rval[0] = 0; - rval[1] = frame.f_regs[D1]; -#if NSYSTRACE > 0 - if (ISSET(p->p_flag, P_SYSTRACE)) - error = systrace_redirect(code, p, args, rval); - else -#endif - error = (*callp->sy_call)(p, args, rval); - switch (error) { - case 0: - frame.f_regs[D0] = rval[0]; - frame.f_regs[D1] = rval[1]; - frame.f_sr &= ~PSL_C; /* carry bit */ - break; - case ERESTART: - /* - * We always enter through a `trap' instruction, which is 2 - * bytes, so adjust the pc by that amount. - */ - frame.f_pc = opc - 2; - break; - case EJUSTRETURN: - /* nothing to do */ - break; - default: -bad: - if (p->p_emul->e_errno) - error = p->p_emul->e_errno[error]; - frame.f_regs[D0] = error; - frame.f_sr |= PSL_C; /* carry bit */ - break; - } - -#ifdef SYSCALL_DEBUG - scdebug_ret(p, code, error, rval); -#endif - userret(p); -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSRET)) - ktrsysret(p, code, error, rval[0]); -#endif -} diff --git a/sys/arch/mac68k/mac68k/vectors.s b/sys/arch/mac68k/mac68k/vectors.s deleted file mode 100644 index c2d7e85ce88..00000000000 --- a/sys/arch/mac68k/mac68k/vectors.s +++ /dev/null @@ -1,140 +0,0 @@ -/* $OpenBSD: vectors.s,v 1.9 2006/01/13 19:36:47 miod Exp $ */ -| $NetBSD: vectors.s,v 1.10 1998/08/12 06:58:42 scottr Exp $ - -| Copyright (c) 1988 University of Utah -| Copyright (c) 1990 Regents of the University of California. -| All rights reserved. -| -| Redistribution and use in source and binary forms, with or without -| modification, are permitted provided that the following conditions -| are met: -| 1. Redistributions of source code must retain the above copyright -| notice, this list of conditions and the following disclaimer. -| 2. Redistributions in binary form must reproduce the above copyright -| notice, this list of conditions and the following disclaimer in the -| documentation and/or other materials provided with the distribution. -| 3. Neither the name of the University nor the names of its contributors -| may be used to endorse or promote products derived from this software -| without specific prior written permission. -| -| THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -| ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -| ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -| FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -| OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -| LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -| OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -| SUCH DAMAGE. -| -| @(#)vectors.s 7.2 (Berkeley) 5/7/91 -| - -#define BADTRAP16 \ - VECTOR(badtrap) ; VECTOR(badtrap) ; \ - VECTOR(badtrap) ; VECTOR(badtrap) ; \ - VECTOR(badtrap) ; VECTOR(badtrap) ; \ - VECTOR(badtrap) ; VECTOR(badtrap) ; \ - VECTOR(badtrap) ; VECTOR(badtrap) ; \ - VECTOR(badtrap) ; VECTOR(badtrap) ; \ - VECTOR(badtrap) ; VECTOR(badtrap) ; \ - VECTOR(badtrap) ; VECTOR(badtrap) - - .data -GLOBAL(vectab) - VECTOR_UNUSED /* 0: NOT USED (reset SSP) */ - VECTOR_UNUSED /* 1: NOT USED (reset PC) */ - VECTOR_UNUSED /* 2: bus error */ - VECTOR_UNUSED /* 3: address error */ - VECTOR(illinst) /* 4: illegal instruction */ - VECTOR(zerodiv) /* 5: zero divide */ - VECTOR(chkinst) /* 6: CHK instruction */ - VECTOR(trapvinst) /* 7: TRAPV instruction */ - VECTOR(privinst) /* 8: privilege violation */ - VECTOR(trace) /* 9: trace */ - VECTOR(illinst) /* 10: line 1010 emulator */ - VECTOR(fpfline) /* 11: line 1111 emulator */ - VECTOR(badtrap) /* 12: unassigned, reserved */ - VECTOR(coperr) /* 13: coprocessor protocol violation */ - VECTOR(fmterr) /* 14: format error */ - VECTOR(badtrap) /* 15: uninitialized interrupt vector */ - VECTOR(badtrap) /* 16: unassigned, reserved */ - VECTOR(badtrap) /* 17: unassigned, reserved */ - VECTOR(badtrap) /* 17: unassigned, reserved */ - VECTOR(badtrap) /* 19: unassigned, reserved */ - VECTOR(badtrap) /* 20: unassigned, reserved */ - VECTOR(badtrap) /* 21: unassigned, reserved */ - VECTOR(badtrap) /* 22: unassigned, reserved */ - VECTOR(badtrap) /* 23: unassigned, reserved */ - VECTOR(spurintr) /* 24: spurious interrupt */ - VECTOR(intrhand) /* 25: level 1 interrupt autovector */ - VECTOR(intrhand) /* 26: level 2 interrupt autovector */ - VECTOR(intrhand) /* 27: level 3 interrupt autovector */ - VECTOR(intrhand) /* 28: level 4 interrupt autovector */ - VECTOR(intrhand) /* 29: level 5 interrupt autovector */ - VECTOR(intrhand) /* 30: level 6 interrupt autovector */ - VECTOR(lev7intr) /* 31: level 7 interrupt autovector */ - VECTOR(trap0) /* 32: syscalls */ - VECTOR(trap1) /* 33: sigreturn syscall or breakpoint */ - VECTOR(trap2) /* 34: breakpoint or sigreturn syscall */ - VECTOR(illinst) /* 35: TRAP instruction vector */ - VECTOR(illinst) /* 36: TRAP instruction vector */ - VECTOR(illinst) /* 37: TRAP instruction vector */ - VECTOR(illinst) /* 38: TRAP instruction vector */ - VECTOR(illinst) /* 39: TRAP instruction vector */ - VECTOR(illinst) /* 40: TRAP instruction vector */ - VECTOR(illinst) /* 41: TRAP instruction vector */ - VECTOR(illinst) /* 42: TRAP instruction vector */ - VECTOR(illinst) /* 43: TRAP instruction vector */ - VECTOR(trap12) /* 44: TRAP instruction vector */ - VECTOR(illinst) /* 45: TRAP instruction vector */ - VECTOR(illinst) /* 46: TRAP instruction vector */ - VECTOR(trap15) /* 47: TRAP instruction vector */ - -GLOBAL(fpvect_tab) - VECTOR(fpfault) /* 48: FPCP branch/set on unordered cond */ - VECTOR(fpfault) /* 49: FPCP inexact result */ - VECTOR(fpfault) /* 50: FPCP divide by zero */ - VECTOR(fpfault) /* 51: FPCP underflow */ - VECTOR(fpfault) /* 52: FPCP operand error */ - VECTOR(fpfault) /* 53: FPCP overflow */ - VECTOR(fpfault) /* 54: FPCP signalling NAN */ -GLOBAL(fpvect_end) - - VECTOR(fpunsupp) /* 55: FPCP unimplemented data type */ - VECTOR(badtrap) /* 56: unassigned, reserved */ - VECTOR(badtrap) /* 57: unassigned, reserved */ - VECTOR(badtrap) /* 58: unassigned, reserved */ - VECTOR(badtrap) /* 59: unassigned, reserved */ - VECTOR(badtrap) /* 60: unassigned, reserved */ - VECTOR(badtrap) /* 61: unassigned, reserved */ - VECTOR(badtrap) /* 62: unassigned, reserved */ - VECTOR(badtrap) /* 63: unassigned, reserved */ - BADTRAP16 /* 64-255: user interrupt vectors */ - BADTRAP16 /* 64-255: user interrupt vectors */ - BADTRAP16 /* 64-255: user interrupt vectors */ - BADTRAP16 /* 64-255: user interrupt vectors */ - BADTRAP16 /* 64-255: user interrupt vectors */ - BADTRAP16 /* 64-255: user interrupt vectors */ - BADTRAP16 /* 64-255: user interrupt vectors */ - BADTRAP16 /* 64-255: user interrupt vectors */ - BADTRAP16 /* 64-255: user interrupt vectors */ - BADTRAP16 /* 64-255: user interrupt vectors */ - BADTRAP16 /* 64-255: user interrupt vectors */ - BADTRAP16 /* 64-255: user interrupt vectors */ - -#ifdef FPSP - /* - * 68040: this chunk of vectors is copied into the fpfault zone - */ -GLOBAL(fpsp_tab) - ASVECTOR(fpsp_bsun) /* 48: FPCP branch/set on unordered cond */ - ASVECTOR(inex) /* 49: FPCP inexact result */ - ASVECTOR(dz) /* 50: FPCP divide by zero */ - ASVECTOR(fpsp_unfl) /* 51: FPCP underflow */ - ASVECTOR(fpsp_operr) /* 52: FPCP operand error */ - ASVECTOR(fpsp_ovfl) /* 53: FPCP overflow */ - ASVECTOR(fpsp_snan) /* 54: FPCP signalling NAN */ -#endif /* FPSP */ diff --git a/sys/arch/mac68k/mac68k/via.c b/sys/arch/mac68k/mac68k/via.c deleted file mode 100644 index ed645bd5297..00000000000 --- a/sys/arch/mac68k/mac68k/via.c +++ /dev/null @@ -1,517 +0,0 @@ -/* $OpenBSD: via.c,v 1.33 2010/09/20 06:33:47 matthew Exp $ */ -/* $NetBSD: via.c,v 1.62 1997/09/10 04:38:48 scottr Exp $ */ - -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * 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 the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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 code handles both the VIA, RBV and OSS functionality. - */ - -#include <sys/param.h> -#include <sys/kernel.h> -#include <sys/syslog.h> -#include <sys/systm.h> -#include <sys/evcount.h> - -#include <machine/cpu.h> -#include <machine/frame.h> -#include <machine/intr.h> -#include <machine/viareg.h> - -int rtclock_intr(void *); - -int via1_intr(void *); -int via2_intr(void *); -int rbv_intr(void *); -int oss_intr(void *); -int via2_nubus_intr(void *); -int rbv_nubus_intr(void *); - -static int slot_ignore(void *); - -int VIA2 = VIA2OFF; /* default for II, IIx, IIcx, SE/30. */ - -struct intrhand via1intrs[7]; -via2hand_t via2intrs[7]; - -/* - * Nubus slot interrupt routines and parameters for slots 9-15. Note - * that for simplicity of code, "v2IRQ0" for internal video is treated - * as a slot 15 interrupt; this slot is quite fictitious in real-world - * Macs. See also GMFH, pp. 165-167, and "Monster, Loch Ness." - */ -struct intrhand slotintrs[7]; - -static struct via2hand nubus_intr; - -void -via_init() -{ - unsigned int i; - - /* Initialize VIA1 */ - /* set all timers to 0 */ - via_reg(VIA1, vT1L) = 0; - via_reg(VIA1, vT1LH) = 0; - via_reg(VIA1, vT1C) = 0; - via_reg(VIA1, vT1CH) = 0; - via_reg(VIA1, vT2C) = 0; - via_reg(VIA1, vT2CH) = 0; - - /* turn off timer latch */ - via_reg(VIA1, vACR) &= 0x3f; - - intr_establish(via1_intr, NULL, mac68k_machine.via1_ipl, "via1"); - - /* register default VIA1 interrupts */ - via1_register_irq(VIA1_T1, rtclock_intr, NULL, "clock"); - - for (i = 0; i < 7; i++) - SLIST_INIT(&via2intrs[i]); - - if (VIA2 == VIA2OFF) { - /* Initialize VIA2 */ - via2_reg(vT1L) = 0; - via2_reg(vT1LH) = 0; - via2_reg(vT1C) = 0; - via2_reg(vT1CH) = 0; - via2_reg(vT2C) = 0; - via2_reg(vT2CH) = 0; - - /* turn off timer latch */ - via2_reg(vACR) &= 0x3f; - - /* register default VIA2 interrupts */ - nubus_intr.vh_ipl = 1; - nubus_intr.vh_fn = via2_nubus_intr; - via2_register_irq(&nubus_intr, NULL); - /* 4 snd_intr, 5 via2t2_intr */ - - /* - * Turn off SE/30 video interrupts. - */ - if (mac68k_machine.machineid == MACH_MACSE30) { - via_reg(VIA1, vBufB) |= (0x40); - via_reg(VIA1, vDirB) |= (0x40); - } - - /* - * Set vPCR for SCSI interrupts. - */ - via2_reg(vPCR) = 0x66; - switch(mac68k_machine.machineid) { - case MACH_MACPB140: - case MACH_MACPB145: - case MACH_MACPB150: - case MACH_MACPB160: - case MACH_MACPB165: - case MACH_MACPB165C: - case MACH_MACPB170: - case MACH_MACPB180: - case MACH_MACPB180C: - break; - default: - via2_reg(vBufB) |= 0x02; /* Unlock NuBus */ - via2_reg(vDirB) |= 0x02; - break; - } - - intr_establish(via2_intr, NULL, 2, "via2"); - } else if (current_mac_model->class == MACH_CLASSIIfx) { /* OSS */ - volatile u_char *ossintr; - ossintr = (volatile u_char *)Via2Base + 6; - *ossintr = 0; - intr_establish(oss_intr, NULL, 2, "via2"); - } else { /* RBV */ - if (current_mac_model->class == MACH_CLASSIIci) { - /* - * Disable cache card. (p. 174--GtMFH) - */ - via2_reg(rBufB) |= DB2O_CEnable; - } - intr_establish(rbv_intr, NULL, 2, "via2"); - - nubus_intr.vh_ipl = 1; - nubus_intr.vh_fn = rbv_nubus_intr; - via2_register_irq(&nubus_intr, NULL); - /* XXX necessary? */ - add_nubus_intr(0, IPL_NONE, slot_ignore, (void *)0, "dummy"); - } -} - -/* - * Set the state of the modem serial port's clock source. - */ -void -via_set_modem(int onoff) -{ - via_reg(VIA1, vDirA) |= DA1O_vSync; - if (onoff) - via_reg(VIA1, vBufA) |= DA1O_vSync; - else - via_reg(VIA1, vBufA) &= ~DA1O_vSync; -} - -int -via1_intr(void *arg) -{ - struct intrhand *ih; - u_int8_t intbits, bitnum; - u_int mask; - - intbits = via_reg(VIA1, vIFR); /* get interrupts pending */ - intbits &= via_reg(VIA1, vIER); /* only care about enabled */ - - if (intbits == 0) - return (0); - - /* - * Unflag interrupts here. - */ - via_reg(VIA1, vIFR) = intbits; - - intbits &= 0x7f; - mask = 1; - for (bitnum = 0, ih = via1intrs; ; bitnum++, ih++) { - if ((intbits & mask) != 0 && ih->ih_fn != NULL) - if ((*ih->ih_fn)(ih->ih_arg) != 0) - ih->ih_count.ec_count++; - mask <<= 1; - if (intbits < mask) - break; - } - - return (1); -} - -int -via2_intr(void *arg) -{ - struct via2hand *v2h; - via2hand_t *anchor; - u_int8_t intbits, bitnum; - u_int mask; - int handled, rc; - - intbits = via2_reg(vIFR); /* get interrupts pending */ - intbits &= via2_reg(vIER); /* only care about enabled */ - - if (intbits == 0) - return (0); - - via2_reg(vIFR) = intbits; - - intbits &= 0x7f; - mask = 1; - for (bitnum = 0, anchor = via2intrs; ; bitnum++, anchor++) { - if ((intbits & mask) != 0) { - handled = 0; - SLIST_FOREACH(v2h, anchor, v2h_link) { - struct intrhand *ih = &v2h->v2h_ih; - rc = (*ih->ih_fn)(ih->ih_arg); - if (rc != 0) { - ih->ih_count.ec_count++; - handled |= rc; - } - } - } - mask <<= 1; - if (intbits < mask) - break; - } - - return (1); -} - -int -rbv_intr(void *arg) -{ - struct via2hand *v2h; - via2hand_t *anchor; - u_int8_t intbits, bitnum; - u_int mask; - int handled, rc; - - intbits = via2_reg(vIFR + rIFR); - intbits &= via2_reg(vIER + rIER); - - if (intbits == 0) - return (0); - - via2_reg(rIFR) = intbits; - - intbits &= 0x7f; - mask = 1; - for (bitnum = 0, anchor = via2intrs; ; bitnum++, anchor++) { - if ((intbits & mask) != 0) { - handled = 0; - SLIST_FOREACH(v2h, anchor, v2h_link) { - struct intrhand *ih = &v2h->v2h_ih; - rc = (*ih->ih_fn)(ih->ih_arg); - if (rc != 0) { - ih->ih_count.ec_count++; - handled |= rc; - } - } - } - mask <<= 1; - if (intbits < mask) - break; - } - - return (1); -} - -int nubus_intr_mask = 0; - -void -add_nubus_intr(int slot, int ipl, int (*func)(void *), void *client_data, - const char *name) -{ - struct intrhand *ih; - int s; - - /* - * Map Nubus slot 0 to "slot" 15; see note on Nubus slot - * interrupt tables. - */ -#ifdef DIAGNOSTIC - if (slot != 0 && (slot < 9 || slot > 14)) - panic("add_nubus_intr: wrong slot %d", slot + 9); -#endif - if (slot == 0) - slot = 15 - 9; - else - slot -= 9; - - s = splhigh(); - - ih = &slotintrs[slot]; - -#ifdef DIAGNOSTIC - if (ih->ih_fn != NULL) - panic("add_nubus_intr: attempt to share slot %d", slot + 9); -#endif - - ih->ih_fn = func; - ih->ih_arg = client_data; - ih->ih_ipl = ipl; - evcount_attach(&ih->ih_count, name, &ih->ih_ipl); - - nubus_intr_mask |= 1 << slot; - - splx(s); -} - -void -enable_nubus_intr() -{ - if ((nubus_intr_mask & 0x3f) == 0) - return; - - if (VIA2 == VIA2OFF) - via2_reg(vIER) = 0x80 | V2IF_SLOTINT; - else - via2_reg(rIER) = 0x80 | V2IF_SLOTINT; -} - -int -oss_intr(void *arg) -{ - struct intrhand *ih; - u_int8_t intbits, bitnum; - u_int mask; - int s; - - intbits = via2_reg(vIFR + rIFR); - - if (intbits == 0) - return (0); - - intbits &= 0x7f; - mask = 1; - for (bitnum = 0, ih = slotintrs; ; bitnum++, ih++) { - if (intbits & mask) { - if (ih->ih_fn != NULL) { - s = _splraise(IPLTOPSL(ih->ih_ipl)); - if ((*ih->ih_fn)(ih->ih_arg) != 0) - ih->ih_count.ec_count++; - splx(s); - } - via2_reg(rIFR) = mask; - } - mask <<= 1; - if (intbits < mask) - break; - } - - return (1); -} - -/*ARGSUSED*/ -int -via2_nubus_intr(void *bitarg) -{ - struct intrhand *ih; - u_int8_t i, intbits, mask; - int s, rv = 0; - - via2_reg(vIFR) = V2IF_SLOTINT; - while ((intbits = (~via2_reg(vBufA)) & nubus_intr_mask)) { - for (i = 6, ih = &slotintrs[i], mask = 1 << i; mask != 0; - i--, ih--, mask >>= 1) { - if (intbits & mask) { - if (ih->ih_fn != NULL) { - s = _splraise(IPLTOPSL(ih->ih_ipl)); - if ((*ih->ih_fn)(ih->ih_arg) != 0) { - ih->ih_count.ec_count++; - rv = 1; - } - splx(s); - } - } - } - via2_reg(vIFR) = V2IF_SLOTINT; - } - return (rv); -} - -/*ARGSUSED*/ -int -rbv_nubus_intr(void *bitarg) -{ - struct intrhand *ih; - u_int8_t i, intbits, mask; - int s, rv = 0; - - via2_reg(rIFR) = 0x80 | V2IF_SLOTINT; - while ((intbits = (~via2_reg(rBufA)) & via2_reg(rSlotInt))) { - for (i = 6, ih = &slotintrs[i], mask = 1 << i; mask != 0; - i--, ih--, mask >>= 1) { - if (intbits & mask) { - if (ih->ih_fn != NULL) { - s = _splraise(IPLTOPSL(ih->ih_ipl)); - if ((*ih->ih_fn)(ih->ih_arg) != 0) { - ih->ih_count.ec_count++; - rv = 1; - } - splx(s); - } - } - } - via2_reg(rIFR) = 0x80 | V2IF_SLOTINT; - } - return (rv); -} - -static int -slot_ignore(void *client_data) -{ - int mask = (1 << (int)client_data); - - if (VIA2 == VIA2OFF) { - via2_reg(vDirA) |= mask; - via2_reg(vBufA) = mask; - via2_reg(vDirA) &= ~mask; - } else - via2_reg(rBufA) = mask; - - return (1); -} - -void -via_powerdown() -{ - if (VIA2 == VIA2OFF) { - via2_reg(vDirB) |= 0x04; /* Set write for bit 2 */ - via2_reg(vBufB) &= ~0x04; /* Shut down */ - } else if (VIA2 == RBVOFF) { - via2_reg(rBufB) &= ~0x04; - } else if (VIA2 == OSSOFF) { - /* - * Thanks to Brad Boyer <flar@cegt201.bradley.edu> for the - * Linux/mac68k code that I derived this from. - */ - via2_reg(OSS_oRCR) |= OSS_POWEROFF; - } -} - -void -via1_register_irq(int irq, int (*irq_func)(void *), void *client_data, - const char *name) -{ - struct intrhand *ih; - -#ifdef DIAGNOSTIC - if (irq < 0 || irq > 7) - panic("via1_register_irq: bad irq %d", irq); -#endif - - ih = &via1intrs[irq]; - - /* - * VIA1 interrupts are special, since we start with temporary handlers, - * and later switch to better routines whenever possible. - * To avoid a loop in evcount lists, only invoke evcount_attach() if - * name is non-NULL, and have the replacements calls in adb_direct.c, - * clock.c and pm_direct.c pass a NULL pointer. - */ -#ifdef DIAGNOSTIC - if (ih->ih_fn != NULL && name != NULL) - panic("via1_register_irq: improper invocation"); -#endif - - ih->ih_fn = irq_func; - ih->ih_arg = client_data; - ih->ih_ipl = irq; - if (name != NULL) - evcount_attach(&ih->ih_count, name, &ih->ih_ipl); -} - -int -via2_register_irq(struct via2hand *vh, const char *name) -{ - int irq = vh->vh_ipl; - -#ifdef DIAGNOSTIC - if (irq < 0 || irq > 7) - panic("via2_register_irq: bad irq %d", irq); -#endif - - if (name != NULL) - evcount_attach(&vh->vh_count, name, &vh->vh_ipl); - SLIST_INSERT_HEAD(&via2intrs[irq], vh, v2h_link); - return (0); -} diff --git a/sys/arch/mac68k/mac68k/vm_machdep.c b/sys/arch/mac68k/mac68k/vm_machdep.c deleted file mode 100644 index ee41e438c57..00000000000 --- a/sys/arch/mac68k/mac68k/vm_machdep.c +++ /dev/null @@ -1,262 +0,0 @@ -/* $OpenBSD: vm_machdep.c,v 1.41 2007/10/13 07:18:01 miod Exp $ */ -/* $NetBSD: vm_machdep.c,v 1.29 1998/07/28 18:34:55 thorpej Exp $ */ - -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1986, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/* - * from: Utah $Hdr: vm_machdep.c 1.21 91/04/06$ - * - * @(#)vm_machdep.c 8.6 (Berkeley) 1/12/94 - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/proc.h> -#include <sys/signalvar.h> -#include <sys/malloc.h> -#include <sys/buf.h> -#include <sys/user.h> -#include <sys/vnode.h> -#include <sys/core.h> -#include <sys/exec.h> -#include <sys/ptrace.h> - -#include <uvm/uvm_extern.h> - -#include <machine/cpu.h> -#include <machine/pmap.h> -#include <machine/pte.h> -#include <machine/reg.h> - -void savectx(struct pcb *); - -/* - * Finish a fork operation, with process p2 nearly set up. - * Copy and update the kernel stack and pcb, making the child - * ready to run, and marking it so that it can return differently - * than the parent. Returns 1 in the child process, 0 in the parent. - * We currently double-map the user area so that the stack is at the same - * address in each process; in the future we will probably relocate - * the frame pointers on the stack after copying. - */ -void -cpu_fork(p1, p2, stack, stacksize, func, arg) - struct proc *p1, *p2; - void *stack; - size_t stacksize; - void (*func)(void *); - void *arg; -{ - struct pcb *pcb = &p2->p_addr->u_pcb; - struct trapframe *tf; - struct switchframe *sf; - extern struct pcb *curpcb; - - p2->p_md.md_flags = p1->p_md.md_flags; - - /* Copy pcb from proc p1 to p2. */ - if (p1 == curproc) { - /* Sync the PCB before we copy it. */ - savectx(curpcb); - } -#ifdef DIAGNOSTIC - else if (p1 != &proc0) - panic("cpu_fork: curproc"); -#endif - *pcb = p1->p_addr->u_pcb; - - /* - * Copy the trap frame. - */ - tf = (struct trapframe *)((u_int)p2->p_addr + USPACE) -1; - p2->p_md.md_regs = (int *)tf; - *tf = *(struct trapframe *)p1->p_md.md_regs; - - /* - * If specified, give the child a different stack. - */ - if (stack != NULL) - tf->tf_regs[15] = (u_int)stack + stacksize; - - sf = (struct switchframe *)tf - 1; - sf->sf_pc = (u_int)proc_trampoline; - pcb->pcb_regs[6] = (int)func; /* A2 */ - pcb->pcb_regs[7] = (int)arg; /* A3 */ - pcb->pcb_regs[11] = (int)sf; /* SSP */ - pcb->pcb_ps = PSL_LOWIPL; /* start kthreads at IPL 0 */ -} - -/* - * cpu_exit is called as the last action during exit. - */ -void -cpu_exit(p) - struct proc *p; -{ - pmap_deactivate(p); - sched_exit(p); -} - -/* - * Dump the machine specific segment at the start of a core dump. - * This means the CPU and FPU registers. The format used here is - * the same one ptrace uses, so gdb can be machine independent. - * - * XXX - Generate Sun format core dumps for Sun executables? - */ -struct md_core { - struct reg intreg; - struct fpreg freg; -}; -int -cpu_coredump(p, vp, cred, chdr) - struct proc *p; - struct vnode *vp; - struct ucred *cred; - struct core *chdr; -{ - struct md_core md_core; - struct coreseg cseg; - int error; - - CORE_SETMAGIC(*chdr, COREMAGIC, MID_MACHINE, 0); - chdr->c_hdrsize = ALIGN(sizeof(*chdr)); - chdr->c_seghdrsize = ALIGN(sizeof(cseg)); - chdr->c_cpusize = sizeof(md_core); - - /* Save integer registers. */ - error = process_read_regs(p, &md_core.intreg); - if (error) - return error; - - if (fputype) { - /* Save floating point registers. */ - error = process_read_fpregs(p, &md_core.freg); - if (error) - return error; - } else { - /* Make sure these are clear. */ - bzero((caddr_t)&md_core.freg, sizeof(md_core.freg)); - } - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_MACHINE, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = chdr->c_cpusize; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize, - (off_t)chdr->c_hdrsize, UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, - NULL, p); - if (error) - return error; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&md_core, sizeof(md_core), - (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE, - IO_NODELOCKED|IO_UNIT, cred, NULL, p); - if (error) - return error; - - chdr->c_nseg++; - return 0; -} - -/* - * Map an IO request into kernel virtual address space. - * - * XXX we allocate KVA space by using kmem_alloc_wait which we know - * allocates space without backing physical memory. This implementation - * is a total crock, the multiple mappings of these physical pages should - * be reflected in the higher-level VM structures to avoid problems. - */ -void -vmapbuf(bp, len) - struct buf *bp; - vsize_t len; -{ - struct pmap *upmap, *kpmap; - vaddr_t uva; /* User VA (map from) */ - vaddr_t kva; /* Kernel VA (new to) */ - vaddr_t pa; /* physical address */ - vsize_t off; - -#ifdef DIAGNOSTIC - if ((bp->b_flags & B_PHYS) == 0) - panic("vmapbuf"); -#endif - - uva = trunc_page((vaddr_t)(bp->b_saveaddr = bp->b_data)); - off = (vaddr_t)bp->b_data - uva; - len = round_page(off + len); - kva = uvm_km_valloc_wait(phys_map, len); - bp->b_data = (caddr_t)(kva + off); - - upmap = vm_map_pmap(&bp->b_proc->p_vmspace->vm_map); - kpmap = vm_map_pmap(phys_map); - do { - if (pmap_extract(upmap, uva, &pa) == FALSE) - panic("vmapbuf: null page frame"); - pmap_enter(kpmap, kva, pa, VM_PROT_READ | VM_PROT_WRITE, - VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED); - uva += PAGE_SIZE; - kva += PAGE_SIZE; - len -= PAGE_SIZE; - } while (len); - pmap_update(pmap_kernel()); -} - -/* - * Free the io map PTEs associated with this IO operation. - */ -void -vunmapbuf(bp, len) - struct buf *bp; - vsize_t len; -{ - vaddr_t kva; - vsize_t off; - -#ifdef DIAGNOSTIC - if ((bp->b_flags & B_PHYS) == 0) - panic("vunmapbuf"); -#endif - - kva = trunc_page((vaddr_t)bp->b_data); - off = (vaddr_t)bp->b_data - kva; - len = round_page(off + len); - - pmap_remove(vm_map_pmap(phys_map), kva, kva + len); - pmap_update(pmap_kernel()); - uvm_km_free_wakeup(phys_map, kva, len); - bp->b_data = bp->b_saveaddr; - bp->b_saveaddr = 0; -} diff --git a/sys/arch/mac68k/mac68k/wscons_machdep.c b/sys/arch/mac68k/mac68k/wscons_machdep.c deleted file mode 100644 index 7771cfeedb8..00000000000 --- a/sys/arch/mac68k/mac68k/wscons_machdep.c +++ /dev/null @@ -1,117 +0,0 @@ -/* $OpenBSD: wscons_machdep.c,v 1.6 2008/01/23 16:37:56 jsing Exp $ */ -/* $NetBSD: maccons.c,v 1.5 2005/01/15 16:00:59 chs Exp $ */ - -/* - * Copyright (C) 1999 Scott Reynolds. 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. 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. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/device.h> -#include <sys/conf.h> -#include <sys/timeout.h> - -#include <machine/autoconf.h> -#include <machine/bus.h> -#include <machine/cpu.h> - -#include <dev/cons.h> - -#include <dev/wscons/wskbdvar.h> -#include <dev/wscons/wsdisplayvar.h> -#include <dev/rasops/rasops.h> - -#include <mac68k/dev/nubus.h> -#include <mac68k/dev/macfbvar.h> -#include <dev/adb/akbdvar.h> - -#include "wsdisplay.h" -#include "wskbd.h" - -cons_decl(ws); - -int maccons_initted = (-1); - -void -wscnprobe(struct consdev *cp) -{ -#if NWSDISPLAY > 0 - int maj, unit; -#endif - - cp->cn_dev = NODEV; - cp->cn_pri = CN_LOWPRI; - -#if NWSDISPLAY > 0 - unit = 0; - for (maj = 0; maj < nchrdev; maj++) - if (cdevsw[maj].d_open == wsdisplayopen) - break; - - if (maj != nchrdev) { - cp->cn_pri = CN_MIDPRI; - cp->cn_dev = makedev(maj, unit); - } -#endif -} - -void -wscninit(struct consdev *cp) -{ - /* - * XXX evil hack; see consinit() for an explanation. - * note: maccons_initted is initialized to (-1). - */ - if (++maccons_initted > 0) { - macfb_cnattach(); - akbd_cnattach(); - } -} - -int -wscngetc(dev_t dev) -{ -#if NWSKBD > 0 - return wskbd_cngetc(dev); -#else - return 0; -#endif -} - -void -wscnputc(dev_t dev, int c) -{ -#if NWSDISPLAY > 0 - wsdisplay_cnputc(dev,c); -#endif -} - -void -wscnpollc(dev_t dev, int on) -{ -#if NWSKBD > 0 - wskbd_cnpollc(dev,on); -#endif -} |